Shop.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. * @return Response
  91. */
  92. public function getStatusList()
  93. {
  94. return success(SiteDict::getStatus());
  95. }
  96. /**
  97. * 关闭店铺
  98. */
  99. public function closeShop($id)
  100. {
  101. ( new ShopService() )->closeShop($id);
  102. return success();
  103. }
  104. /**
  105. * 菜单或接口更新
  106. */
  107. public function edit($id)
  108. {
  109. $data = $this->request->params([
  110. [ 'site_name', '' ],
  111. [ 'group_id', 0 ],
  112. [ 'expire_time', 0 ],
  113. [ 'is_self', '' ],
  114. [ 'category_id', '' ],
  115. [ 'phone', '' ],
  116. [ 'business_license', '' ]
  117. ]);
  118. // $this->validate(array_merge($data, ['site_id' => $id]), 'app\validate\site\Site.edit');
  119. ( new ShopService() )->edit($id, $data);
  120. return success('MODIFY_SUCCESS');
  121. }
  122. /**
  123. * 删除店铺
  124. * @param $id
  125. * @return Response
  126. */
  127. public function del($id)
  128. {
  129. ( new ShopService() )->del($id);
  130. return success('DELETE_SUCCESS');
  131. }
  132. /**
  133. * 开启店铺
  134. */
  135. public function openShop($id)
  136. {
  137. $data = $this->request->params([
  138. [ 'status', SiteDict::ON ],
  139. ]);
  140. ( new ShopService() )->edit($id, $data);
  141. return success();
  142. }
  143. /**
  144. * 获取店铺拥有的应用
  145. * @return Response
  146. */
  147. public function addons()
  148. {
  149. $data = $this->request->params([
  150. [ 'title', '' ],
  151. ]);
  152. $data = ( new ShopService() )->getSiteAddons($data);
  153. return success(data:$data);
  154. }
  155. /**
  156. * 获取店铺收支信息
  157. * @param int $id
  158. * @return Response
  159. */
  160. public function getAccountLogList(int $id)
  161. {
  162. return success(( new ShopService() )->getShopAccountLog($id));
  163. }
  164. /**
  165. * 获取店铺提现记录
  166. * @param int $id
  167. * @return Response
  168. */
  169. public function getShopCashOutList(int $id)
  170. {
  171. return success(( new ShopService() )->getShopCashOutlog($id));
  172. }
  173. /**
  174. * 获取店铺账户信息
  175. * @param int $id
  176. * @return Response
  177. */
  178. public function getShopAccountInfo(int $id)
  179. {
  180. return success(( new ShopService() )->getShopAccountInfo($id));
  181. }
  182. /**
  183. * 店铺账户信息修改
  184. * @param int $id
  185. * @return Response
  186. */
  187. public function editShopAccount(int $id)
  188. {
  189. $data = $this->request->params([
  190. [ 'bank_type', '' ],
  191. [ 'bank_account_name', '' ],
  192. [ 'bank_account_no', 0 ],
  193. [ 'bank_name', '' ],
  194. [ 'bank_address', '' ]
  195. ]);
  196. $this->validate($data, 'app\validate\shop\ShopAccount.edit');
  197. ( new ShopService() )->editShopAccount($id, $data);
  198. return success('EDIT_SUCCESS');
  199. }
  200. }