ShopInfoController.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Services\ShopInfoService;
  4. use Illuminate\Http\Request;
  5. use Slowlyo\OwlAdmin\Controllers\AdminController;
  6. /**
  7. * 店铺
  8. *
  9. * @property ShopInfoService $service
  10. */
  11. class ShopInfoController extends AdminController
  12. {
  13. protected string $serviceName = ShopInfoService::class;
  14. public function list()
  15. {
  16. $crud = $this->baseCRUD()
  17. ->filterTogglable(false)
  18. ->headerToolbar([
  19. $this->createButton('dialog'),
  20. ...$this->baseHeaderToolBar(),
  21. ])
  22. ->columns([
  23. amis()->TableColumn('id', 'ID')->sortable(),
  24. amis()->TableColumn('auth_record_id', '店铺认证记录编号'),
  25. amis()->TableColumn('salesperson_id', '业务员编号'),
  26. amis()->TableColumn('state', '状态'),
  27. amis()->TableColumn('created_at', admin_trans('admin.created_at'))->type('datetime')->sortable(),
  28. amis()->TableColumn('updated_at', admin_trans('admin.updated_at'))->type('datetime')->sortable(),
  29. $this->rowActions('dialog'),
  30. ]);
  31. return $this->baseList($crud);
  32. }
  33. public function form($isEdit = false)
  34. {
  35. return $this->baseForm()->body([
  36. amis()->TextControl('auth_record_id', '店铺认证记录编号'),
  37. amis()->TextControl('salesperson_id', '业务员编号'),
  38. amis()->TextControl('state', '状态'),
  39. ]);
  40. }
  41. public function detail()
  42. {
  43. return $this->baseDetail()->body([
  44. amis()->TextControl('id', 'ID')->static(),
  45. amis()->TextControl('auth_record_id', '店铺认证记录编号')->static(),
  46. amis()->TextControl('salesperson_id', '业务员编号')->static(),
  47. amis()->TextControl('state', '状态')->static(),
  48. amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
  49. amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
  50. ]);
  51. }
  52. /**
  53. * [店铺管理]审核店铺
  54. *
  55. * @description 审核店铺认证申请
  56. *
  57. * @header x-xsrf-token required CSRF令牌 Example: your_csrf_token
  58. *
  59. * @bodyParam shop_id integer required 店铺ID Example: 1
  60. * @bodyParam action string required 审核操作(approve:通过,reject:拒绝) Example: approve
  61. * @bodyParam reason string required 审核意见 Example: 资料齐全,符合要求
  62. *
  63. * @response {
  64. * "code": 200,
  65. * "message": "审核成功",
  66. * "data": null
  67. * }
  68. */
  69. public function review(Request $request)
  70. {
  71. $validated = $request->validate([
  72. 'shop_id' => 'required|integer|exists:shop_info,id',
  73. 'action' => 'required|string|in:approve,reject',
  74. 'reason' => 'required|string|max:255',
  75. ]);
  76. return $this->service->reviewShop($validated);
  77. }
  78. /**
  79. * [店铺管理]拉黑店铺
  80. *
  81. * @description 将店铺加入黑名单
  82. *
  83. * @header x-xsrf-token required CSRF令牌 Example: your_csrf_token
  84. *
  85. * @bodyParam shop_id integer required 店铺ID Example: 1
  86. * @bodyParam reason string required 拉黑原因 Example: 违规经营
  87. *
  88. * @response {
  89. * "code": 200,
  90. * "message": "拉黑成功",
  91. * "data": null
  92. * }
  93. */
  94. public function blockShop(Request $request)
  95. {
  96. $validated = $request->validate([
  97. 'shop_id' => 'required|integer|exists:shop_infos,id',
  98. 'reason' => 'required|string|max:255',
  99. ]);
  100. return $this->service->blockShop($validated);
  101. }
  102. /**
  103. * [店铺管理]审核记录
  104. *
  105. * @description 获取店铺审核记录列表
  106. *
  107. * @queryParam shop_id integer required 店铺ID Example: 1
  108. * @queryParam page int 页码 Example: 1
  109. * @queryParam perPage int 每页数量 Example: 20
  110. *
  111. * @response {
  112. * "code": 200,
  113. * "message": "success",
  114. * "data": {
  115. * "current_page": 1,
  116. * "data": [{
  117. * "id": 1,
  118. * "shop_id": 1,
  119. * "state": "ENABLE",
  120. * "audit_remark": "资料齐全,符合要求",
  121. * "audit_time": "2024-03-20 10:00:00",
  122. * "auditor": 1,
  123. * "created_at": "2024-03-20 10:00:00"
  124. * }],
  125. * "total": 10
  126. * }
  127. * }
  128. */
  129. public function reviewRecords(Request $request)
  130. {
  131. $validated = $request->validate([
  132. 'shop_id' => 'required|integer|exists:shop_infos,id',
  133. 'page' => 'nullable|integer|min:1',
  134. 'perPage' => 'nullable|integer|min:1',
  135. ]);
  136. return $this->service->getShopReviewRecords($validated);
  137. }
  138. /**
  139. * [店铺管理]冻结店铺余额
  140. *
  141. * @description 冻结店铺钱包余额
  142. *
  143. * @header x-xsrf-token required CSRF令牌 Example: your_csrf_token
  144. *
  145. * @bodyParam shop_id integer required 店铺ID Example: 1
  146. * @bodyParam amount numeric required 冻结金额 Example: 100.00
  147. * @bodyParam reason string required 冻结原因 Example: 涉嫌违规操作
  148. *
  149. * @response {
  150. * "code": 200,
  151. * "message": "冻结成功",
  152. * "data": null
  153. * }
  154. */
  155. public function freezeBalance(Request $request)
  156. {
  157. $validated = $request->validate([
  158. 'shop_id' => 'required|integer|exists:shop_infos,id',
  159. 'amount' => 'required|numeric|min:0.01',
  160. 'reason' => 'required|string|max:255',
  161. ]);
  162. return $this->service->freezeShopBalance($validated);
  163. }
  164. }