StoreManageController.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\api\controller\v1\admin;
  12. use app\Request;
  13. use app\services\admin\StoreManageServices;
  14. use app\services\shipping\ShippingTemplatesServices;
  15. class StoreManageController
  16. {
  17. protected StoreManageServices $services;
  18. public function __construct(StoreManageServices $services)
  19. {
  20. $this->services = $services;
  21. }
  22. /**
  23. * 商家统计
  24. * @return \think\Response
  25. * @author wuhaotian
  26. * @email 442384644@qq.com
  27. * @date 2025/11/13
  28. */
  29. public function statistics()
  30. {
  31. return app('json')->success($this->services->statistics());
  32. }
  33. /**
  34. * 商家商品
  35. * @param Request $request
  36. * @return \think\Response
  37. * @author wuhaotian
  38. * @email 442384644@qq.com
  39. * @date 2025/11/13
  40. */
  41. public function product(Request $request)
  42. {
  43. $where = $request->getMore([
  44. [['page', 'd'], 1],
  45. [['limit', 'd'], 10],
  46. ['type', ''],
  47. ['store_name', ''],
  48. ]);
  49. return app('json')->success($this->services->product($where));
  50. }
  51. /**
  52. * 商家商品上下架
  53. * @param Request $request
  54. * @return \think\Response
  55. * @author wuhaotian
  56. * @email 442384644@qq.com
  57. * @date 2025/11/13
  58. */
  59. public function productShow(Request $request)
  60. {
  61. [$id, $isShow] = $request->postMore([
  62. [['id', 'd'], 0],
  63. [['is_show', 'd'], 0],
  64. ], true);
  65. $this->services->productShow($id, $isShow);
  66. return app('json')->success('操作成功');
  67. }
  68. /**
  69. * 商家商品标签
  70. * @return \think\Response
  71. * @author wuhaotian
  72. * @email 442384644@qq.com
  73. * @date 2025/11/13
  74. */
  75. public function productLabel()
  76. {
  77. return app('json')->success($this->services->productLabel());
  78. }
  79. /**
  80. * 商家商品标签保存
  81. * @param Request $request
  82. * @return \think\Response
  83. * @author wuhaotian
  84. * @email 442384644@qq.com
  85. * @date 2025/11/13
  86. */
  87. public function saveProductLabel(Request $request)
  88. {
  89. [$ids, $label_list] = $request->postMore([
  90. ['ids', []],
  91. ['label_list', []],
  92. ], true);
  93. if (is_int($ids)) $ids = [$ids];
  94. $this->services->saveProductLabel($ids, $label_list);
  95. return app('json')->success('操作成功');
  96. }
  97. /**
  98. * 商家商品分类
  99. * @return \think\Response
  100. * @author wuhaotian
  101. * @email 442384644@qq.com
  102. * @date 2025/11/13
  103. */
  104. public function productCate()
  105. {
  106. return app('json')->success($this->services->productCate());
  107. }
  108. /**
  109. * 商家商品分类保存
  110. * @param Request $request
  111. * @return \think\Response
  112. * @author wuhaotian
  113. * @email 442384644@qq.com
  114. * @date 2025/11/13
  115. */
  116. public function saveProductCate(Request $request)
  117. {
  118. [$ids, $cate_id] = $request->postMore([
  119. ['ids', []],
  120. ['cate_id', []],
  121. ], true);
  122. if (is_int($ids)) $ids = [$ids];
  123. $this->services->saveProductCate($ids, $cate_id);
  124. return app('json')->success('操作成功');
  125. }
  126. /**
  127. * 商家商品属性
  128. * @param $id
  129. * @return \think\Response
  130. * @author wuhaotian
  131. * @email 442384644@qq.com
  132. * @date 2025/11/13
  133. */
  134. public function productAttr($id)
  135. {
  136. return app('json')->success($this->services->productAttr($id));
  137. }
  138. /**
  139. * 商家商品属性保存
  140. * @param Request $request
  141. * @param $id
  142. * @return \think\Response
  143. * @author wuhaotian
  144. * @email 442384644@qq.com
  145. * @date 2025/11/13
  146. */
  147. public function saveProductAttr(Request $request, $id)
  148. {
  149. [$attr_value] = $request->postMore([
  150. ['attr_value', []],
  151. ], true);
  152. $this->services->saveProductAttr($id, $attr_value);
  153. return app('json')->success('修改成功');
  154. }
  155. /**
  156. * 商家商品运费模版
  157. * @return \think\Response
  158. * @author wuhaotian
  159. * @email 442384644@qq.com
  160. * @date 2025/12/8
  161. */
  162. public function shippingTemp()
  163. {
  164. /** @var ShippingTemplatesServices $shippingTemplatesServices */
  165. $shippingTemplatesServices = app()->make(ShippingTemplatesServices::class);
  166. $data = $shippingTemplatesServices->getSelectList();
  167. $data = array_merge([['id' => 0, 'name' => '未选择']], $data);
  168. return app('json')->success($data);
  169. }
  170. /**
  171. * 创建商品
  172. * @param Request $request
  173. * @return \think\Response
  174. * @author wuhaotian
  175. * @email 442384644@qq.com
  176. * @date 2025/12/9
  177. */
  178. public function createProduct(Request $request)
  179. {
  180. $data = $request->postMore([
  181. ['store_name', ''],
  182. ['slider_image', []],
  183. ['cate_id', []],
  184. ['unit_name', ''],
  185. ['attr', []],
  186. ['content', ''],
  187. ['logistics', []],
  188. ['freight', 2],
  189. ['postage', 0],
  190. ['temp_id', 0],
  191. ['spec_type', 0],
  192. ]);
  193. $this->services->createProduct($data);
  194. return app('json')->success('创建成功');
  195. }
  196. /**
  197. * 商家用户列表
  198. * @param Request $request
  199. * @return \think\Response
  200. * @author wuhaotian
  201. * @email 442384644@qq.com
  202. * @date 2025/11/17
  203. */
  204. public function user(Request $request)
  205. {
  206. $where = $request->getMore([
  207. ['page', 1],
  208. ['limit', 10],
  209. ['nickname', ''],
  210. ['group_id', 0],
  211. ['level', 0],
  212. ['label_id', ''],
  213. ]);
  214. return app('json')->success($this->services->user($where));
  215. }
  216. /**
  217. * 用户信息
  218. * @param $uid
  219. * @return \think\Response
  220. * @throws \think\db\exception\DataNotFoundException
  221. * @throws \think\db\exception\DbException
  222. * @throws \think\db\exception\ModelNotFoundException
  223. * @author wuhaotian
  224. * @email 442384644@qq.com
  225. * @date 2025/11/17
  226. */
  227. public function userInfo($uid)
  228. {
  229. return app('json')->success($this->services->userInfo($uid));
  230. }
  231. /**
  232. * 用户分组
  233. * @return \think\Response
  234. * @throws \think\db\exception\DataNotFoundException
  235. * @throws \think\db\exception\DbException
  236. * @throws \think\db\exception\ModelNotFoundException
  237. * @author wuhaotian
  238. * @email 442384644@qq.com
  239. * @date 2025/11/17
  240. */
  241. public function userGroup()
  242. {
  243. return app('json')->success($this->services->userGroup());
  244. }
  245. /**
  246. * 用户等级
  247. * @return \think\Response
  248. * @throws \think\db\exception\DataNotFoundException
  249. * @throws \think\db\exception\DbException
  250. * @throws \think\db\exception\ModelNotFoundException
  251. * @author wuhaotian
  252. * @email 442384644@qq.com
  253. * @date 2025/11/17
  254. */
  255. public function userLevel()
  256. {
  257. return app('json')->success($this->services->userLevel());
  258. }
  259. /**
  260. * 用户标签
  261. * @param int $uid
  262. * @return \think\Response
  263. * @throws \think\db\exception\DataNotFoundException
  264. * @throws \think\db\exception\DbException
  265. * @throws \think\db\exception\ModelNotFoundException
  266. * @author wuhaotian
  267. * @email 442384644@qq.com
  268. * @date 2025/11/17
  269. */
  270. public function userLabel($uid = 0)
  271. {
  272. return app('json')->success($this->services->userLabel($uid));
  273. }
  274. /**
  275. * 用户优惠券列表
  276. * @param Request $request
  277. * @return \think\Response
  278. * @author wuhaotian
  279. * @email 442384644@qq.com
  280. * @date 2025/11/17
  281. */
  282. public function userCoupon(Request $request)
  283. {
  284. $where = $request->getMore([
  285. ['page', 1],
  286. ['limit', 10],
  287. ['coupon_title', ''],
  288. ['uid', 0],
  289. ]);
  290. return app('json')->success($this->services->userCoupon($where));
  291. }
  292. /**
  293. * 修改用户信息
  294. * @param Request $request
  295. * @param $uid
  296. * @return \think\Response
  297. * @throws \think\Exception
  298. * @throws \think\db\exception\DataNotFoundException
  299. * @throws \think\db\exception\DbException
  300. * @throws \think\db\exception\ModelNotFoundException
  301. * @author wuhaotian
  302. * @email 442384644@qq.com
  303. * @date 2025/11/17
  304. */
  305. public function userUpdate(Request $request, $uid)
  306. {
  307. $data = $request->postMore([
  308. ['type', 0],
  309. ['number', 0],
  310. ['status', 0],
  311. ['level', 0],
  312. ['group_id', 0],
  313. ['days', 0],
  314. ['coupon_id', 0],
  315. ['label_id', []],
  316. ]);
  317. $this->services->userUpdate($uid, $data);
  318. return app('json')->success('修改成功');
  319. }
  320. }