Shop.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\shop\admin;
  12. use app\dict\site\SiteDict;
  13. use app\job\schedule\SiteExpireClose;
  14. use app\service\admin\shop\admin\ShopService;
  15. use core\base\BaseAdminController;
  16. use think\Response;
  17. class Shop extends BaseAdminController
  18. {
  19. /**
  20. * 店铺列表
  21. * @return Response
  22. */
  23. public function pages()
  24. {
  25. $data = $this->request->params([
  26. [ 'keyword', '' ],
  27. [ 'status', '' ],
  28. [ 'group_id', '' ],
  29. [ 'create_time', [] ],
  30. [ 'expire_time', [] ],
  31. [ 'is_self', '' ],
  32. [ 'category_id', '' ],
  33. ]);
  34. return success(( new ShopService() )->getPage($data));
  35. }
  36. /**
  37. * 店铺列表
  38. * @return Response
  39. */
  40. public function lists()
  41. {
  42. $data = $this->request->params([
  43. [ 'keywords', '' ],
  44. [ 'status', '' ],
  45. [ 'group_id', '' ],
  46. [ 'create_time', [] ],
  47. [ 'expire_time', [] ],
  48. [ 'is_self', '' ],
  49. [ 'category_id', '' ],
  50. ]);
  51. return success(( new ShopService() )->getList($data));
  52. }
  53. /**
  54. * 店铺详情
  55. * @param int $id
  56. * @return Response
  57. */
  58. public function info(int $id)
  59. {
  60. return success(( new ShopService() )->getInfo($id));
  61. }
  62. /**
  63. * 添加店铺
  64. * ['site_name' => '', 'username' => '', 'head_img' => '', 'real_name' => '', 'password' => '', 'expire_time' => 0]
  65. * @return Response
  66. */
  67. public function add()
  68. {
  69. $data = $this->request->params([
  70. [ 'site_name', '' ],
  71. [ 'uid', 0 ],
  72. [ 'username', '' ],
  73. [ 'real_name', '' ],
  74. [ 'password', '' ],
  75. [ 'group_id', 0 ],
  76. [ 'expire_time', 0 ],
  77. [ 'is_self', '' ],
  78. [ 'category_id', '' ],
  79. [ 'phone', '' ],
  80. [ 'apply_id', '' ],
  81. [ 'business_license', '' ],
  82. ]);
  83. $this->validate($data, 'app\validate\site\Site.add');
  84. if (empty($data[ 'uid' ])) $this->validate($data, 'app\validate\sys\User.add');
  85. $site_id = ( new ShopService() )->add($data);
  86. return success('ADD_SUCCESS', [ 'site_id' => $site_id ]);
  87. }
  88. /**
  89. * 编辑店铺
  90. */
  91. public function edit($id)
  92. {
  93. $data = $this->request->params([
  94. ['site_name', ''],
  95. ['group_id', 0],
  96. ['expire_time', 0],
  97. ['is_self', ''],
  98. ['category_id', ''],
  99. ['phone', ''],
  100. ['business_license', ''],
  101. ['latitude', ''],
  102. ['longitude', ''],
  103. ['province_id', ''],
  104. ['city_id', ''],
  105. ['district_id', ''],
  106. ['address', ''],
  107. ['full_address', ''],
  108. ]);
  109. $this->validate(array_merge($data, ['site_id' => $id]), 'app\validate\site\Site.edit');
  110. ( new ShopService() )->edit($id, $data);
  111. return success('MODIFY_SUCCESS');
  112. }
  113. /**
  114. * 开启店铺
  115. */
  116. public function openShop($id)
  117. {
  118. ( new ShopService() )->openShop($id);
  119. return success();
  120. }
  121. /**
  122. * 关闭店铺
  123. */
  124. public function closeShop($id)
  125. {
  126. ( new ShopService() )->closeShop($id);
  127. return success();
  128. }
  129. /**
  130. * 删除店铺
  131. * @param $id
  132. * @return Response
  133. */
  134. public function del($id)
  135. {
  136. ( new ShopService() )->del($id);
  137. return success('DELETE_SUCCESS');
  138. }
  139. /**
  140. * 店铺账户信息修改
  141. * @param int $id
  142. * @return Response
  143. */
  144. public function editShopAccount(int $id)
  145. {
  146. $data = $this->request->params([
  147. [ 'bank_type', '' ],
  148. [ 'bank_account_name', '' ],
  149. [ 'bank_account_no', 0 ],
  150. [ 'bank_name', '' ],
  151. [ 'bank_address', '' ]
  152. ]);
  153. $this->validate($data, 'app\validate\shop\ShopAccount.edit');
  154. ( new ShopService() )->editShopAccount($id, $data);
  155. return success('EDIT_SUCCESS');
  156. }
  157. /**
  158. * 店铺选择列表
  159. * @return Response
  160. */
  161. public function select()
  162. {
  163. $data = $this->request->params([
  164. [ 'keyword', '' ],
  165. [ 'status', '' ],
  166. [ 'group_id', '' ],
  167. [ 'create_time', [] ],
  168. [ 'expire_time', [] ],
  169. [ 'is_self', '' ],
  170. [ 'category_id', '' ],
  171. [ "site_ids", [] ],
  172. [ "verify_site_ids", [] ]
  173. ]);
  174. return success(( new ShopService() )->getSelectPage($data));
  175. }
  176. /**
  177. * 获取店铺拥有的应用
  178. * @return Response
  179. */
  180. public function addons()
  181. {
  182. $data = $this->request->params([
  183. [ 'title', '' ],
  184. ]);
  185. $data = ( new ShopService() )->getSiteAddons($data);
  186. return success(data:$data);
  187. }
  188. /**
  189. * 获取店铺收支信息
  190. * @param int $id
  191. * @return Response
  192. */
  193. public function getAccountLogList(int $id)
  194. {
  195. return success(( new ShopService() )->getShopAccountLog($id));
  196. }
  197. /**
  198. * 获取店铺提现记录
  199. * @param int $id
  200. * @return Response
  201. */
  202. public function getShopCashOutList(int $id)
  203. {
  204. return success(( new ShopService() )->getShopCashOutlog($id));
  205. }
  206. /**
  207. * 获取店铺账户信息
  208. * @param int $id
  209. * @return Response
  210. */
  211. public function getShopAccountInfo(int $id)
  212. {
  213. return success(( new ShopService() )->getShopAccountInfo($id));
  214. }
  215. /**
  216. * 店铺状态
  217. * @return Response
  218. */
  219. public function getStatusList()
  220. {
  221. return success(SiteDict::getStatus());
  222. }
  223. }