Product.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\merchant\store\product;
  12. use app\common\repositories\store\product\CdkeyLibraryRepository;
  13. use app\common\repositories\store\product\ProductAttrValueRepository;
  14. use app\common\repositories\store\product\ProductBatchProcessRepository;
  15. use app\common\repositories\store\product\SpuRepository;
  16. use app\common\repositories\store\shipping\ShippingTemplateRepository;
  17. use app\common\repositories\store\StoreCategoryRepository;
  18. use app\common\repositories\system\operate\OperateLogRepository;
  19. use crmeb\services\UploadService;
  20. use think\App;
  21. use crmeb\basic\BaseController;
  22. use app\common\repositories\store\product\ProductRepository as repository;
  23. use think\exception\ValidateException;
  24. use think\facade\Cache;
  25. class Product extends BaseController
  26. {
  27. protected $repository;
  28. /**
  29. * Product constructor.
  30. * @param App $app
  31. * @param repository $repository
  32. */
  33. public function __construct(App $app, repository $repository)
  34. {
  35. parent::__construct($app);
  36. $this->repository = $repository;
  37. }
  38. /**
  39. * 获取列表数据
  40. *
  41. * @return \think\response\Json
  42. */
  43. public function lst()
  44. {
  45. // 获取分页参数
  46. [$page, $limit] = $this->getPage();
  47. // 获取查询参数
  48. $type = $this->request->param('type', 1);
  49. $where = $this->request->params([
  50. 'temp_id',
  51. 'cate_id',
  52. 'keyword',
  53. 'mer_cate_id',
  54. 'is_gift_bag',
  55. 'status',
  56. 'us_status',
  57. 'product_id',
  58. 'mer_labels',
  59. ['order', 'sort'],
  60. 'is_ficti',
  61. 'svip_price_type',
  62. 'filters_type',
  63. 'is_action',
  64. 'is_good',
  65. 'not_product_id',
  66. 'form_id',
  67. 'mer_form_id',
  68. 'cate_hot'
  69. ]);
  70. // 根据类型和商家ID获取查询条件
  71. $where = array_merge($where, $this->repository->switchType($type, $this->request->merId(), 0));
  72. // 调用仓库方法获取列表数据并返回JSON格式的响应
  73. return app('json')->success($this->repository->getList($this->request->merId(), $where, $page, $limit));
  74. }
  75. /**
  76. * 获取商品详情
  77. * @param int $id 商品ID
  78. * @return \think\response\Json
  79. */
  80. public function detail($id)
  81. {
  82. // 判断商品是否存在
  83. if (!$this->repository->merExists($this->request->merId(), $id))
  84. return app('json')->fail('数据不存在');
  85. // 返回商品详情
  86. $is_copy = $this->request->param('is_copy',0);
  87. return app('json')->success($this->repository->getAdminOneProduct($id, null,0,$is_copy));
  88. }
  89. public function getEdit($id)
  90. {
  91. // 判断商品是否存在
  92. if (!$this->repository->merExists($this->request->merId(), $id))
  93. return app('json')->fail('数据不存在');
  94. // 返回商品详情
  95. $is_copy = $this->request->param('is_copy',0);
  96. $data = $this->repository->getEdit($id, $is_copy);
  97. return app('json')->success($data);
  98. }
  99. /**
  100. * 创建商品
  101. * @return \think\response\Json
  102. */
  103. public function create()
  104. {
  105. // 获取参数
  106. $params = $this->request->params($this->repository::CREATE_PARAMS);
  107. // 校验参数
  108. $data = $this->repository->checkParams($params, $this->request->merId());
  109. // 设置商家ID和管理员ID
  110. $data['mer_id'] = $this->request->merId();
  111. $data['admin_id'] = $this->request->merAdminId();
  112. // 判断是否为礼包商品并且商家礼包数量是否超过限制
  113. if ($data['is_gift_bag'] && !$this->repository->checkMerchantBagNumber($data['mer_id']))
  114. return app('json')->fail('礼包数量超过数量限制');
  115. // 设置商品状态
  116. $data['status'] = $this->request->merchant()->is_audit ? 0 : 1;
  117. // 设置商家状态
  118. $data['mer_status'] = ($this->request->merchant()->is_del || !$this->request->merchant()->mer_state || !$this->request->merchant()->status) ? 0 : 1;
  119. // 设置评分
  120. $data['rate'] = 5;
  121. // 设置管理员信息
  122. $data['admin_info'] = $this->request->adminInfo();
  123. var_dump($data);die();
  124. // 创建商品
  125. $this->repository->create($data, 0);
  126. // 返回创建成功信息
  127. return app('json')->success('添加成功');
  128. }
  129. /**
  130. * 修改商品
  131. * @param int $id 商品ID
  132. * @return \think\response\Json
  133. */
  134. public function update($id)
  135. {
  136. // 获取参数
  137. $params = $this->request->params($this->repository::CREATE_PARAMS);
  138. $data = $this->repository->checkParams($params, $this->request->merId(), $id);
  139. // 判断商品是否存在
  140. if (!$this->repository->merExists($this->request->merId(), $id))
  141. return app('json')->fail('数据不存在');
  142. // 获取商品信息
  143. $pro = $this->repository->getWhere(['product_id' => $id]);
  144. if ($pro->status == -2) {
  145. $data['status'] = 0;
  146. } else {
  147. // 设置商品状态
  148. $data['status'] = $this->request->merchant()->is_audit ? 0 : 1;
  149. }
  150. // 设置商家状态
  151. $data['mer_status'] = ($this->request->merchant()->is_del || !$this->request->merchant()->mer_state || !$this->request->merchant()->status) ? 0 : 1;
  152. // 设置商家ID和管理员ID
  153. $data['mer_id'] = $this->request->merId();
  154. // 设置管理员信息
  155. $data['admin_info'] = $this->request->adminInfo();
  156. $productData = $this->repository->edit($id, $data, $this->request->merId(), 0);
  157. $product = $productData->toArray();
  158. ksort($product);
  159. $cache_unique = 'get_product_show_' . $id . '_' . md5(json_encode($product));
  160. Cache::delete($cache_unique);
  161. return app('json')->success('编辑成功');
  162. }
  163. /**
  164. * 删除商品
  165. *
  166. * @param int $id 商品ID
  167. * @return \think\response\Json
  168. */
  169. public function delete($id)
  170. {
  171. // 判断商品是否存在
  172. if (!$this->repository->merExists($this->request->merId(), $id))
  173. return app('json')->fail('数据不存在');
  174. // 判断商品是否已经上架
  175. if ($this->repository->getWhereCount(['product_id' => $id, 'is_show' => 1, 'status' => 1]))
  176. return app('json')->fail('商品上架中');
  177. // 删除商品
  178. $this->repository->delete($id);
  179. //queue(ChangeSpuStatusJob::class,['product_type' => 0,'id' => $id]);
  180. app()->make(CdkeyLibraryRepository::class)->cancel($id);
  181. // 返回操作结果
  182. return app('json')->success('转入回收站');
  183. }
  184. /**
  185. * 永久删除商品
  186. *
  187. * @param int $id 商品ID
  188. * @return \think\response\Json
  189. */
  190. public function destory($id)
  191. {
  192. // 判断商品是否存在于回收站
  193. if (!$this->repository->merDeleteExists($this->request->merId(), $id))
  194. return app('json')->fail('只能删除回收站的商品');
  195. // if(app()->make(StoreCartRepository::class)->getProductById($id))
  196. // return app('json')->fail('商品有被加入购物车不可删除');
  197. $seckillProduct = $this->repository->getWhere(['old_product_id' => $id, 'is_del' => 0, 'product_type' => 1], 'product_id, store_name, is_show');
  198. if($seckillProduct) {
  199. return app('json')->fail('该商品有秒杀商品不可删除,请先删除关联秒杀商品再操作!秒杀商品ID:'. $seckillProduct->product_id);
  200. }
  201. // 永久删除商品
  202. $this->repository->destory($id);
  203. return app('json')->success('删除成功');
  204. }
  205. /**
  206. * 获取状态过滤器
  207. *
  208. * @return \Illuminate\Http\JsonResponse
  209. */
  210. public function getStatusFilter()
  211. {
  212. // 调用 repository 的 getFilter 方法获取商品状态过滤器
  213. return app('json')->success($this->repository->getFilter($this->request->merId(), '商品', 0));
  214. }
  215. /**
  216. * 配置信息
  217. *
  218. * @return \Illuminate\Http\JsonResponse
  219. */
  220. public function config()
  221. {
  222. $data = systemConfig(['extension_status', 'svip_switch_status', 'integral_status', 'extension_one_rate', 'extension_two_rate']);
  223. $merData = merchantConfig($this->request->merId(), ['mer_integral_status', 'mer_integral_rate', 'mer_svip_status', 'svip_store_rate']);
  224. // 计算商家 svip 店铺比例
  225. $svip_store_rate = $merData['svip_store_rate'] > 0 ? bcdiv($merData['svip_store_rate'], 100, 2) : 0;
  226. // 判断商家 svip 状态
  227. $data['mer_svip_status'] = ($data['svip_switch_status'] && $merData['mer_svip_status'] != 0) ? 1 : 0;
  228. // 设置商家 svip 店铺比例
  229. $data['svip_store_rate'] = $svip_store_rate;
  230. // 判断积分状态
  231. $data['integral_status'] = $data['integral_status'] && $merData['mer_integral_status'] ? 1 : 0;
  232. // 设置积分比例
  233. $data['integral_rate'] = $merData['mer_integral_rate'] ?: 0;
  234. // 获取商家配送方式
  235. $data['delivery_way'] = $this->request->merchant()->delivery_way ? $this->request->merchant()->delivery_way : [2];
  236. // 获取商家审核状态
  237. $data['is_audit'] = $this->request->merchant()->is_audit;
  238. // 设置分销一比例
  239. $data['extension_one_rate'] = $data['extension_one_rate'] ? $data['extension_one_rate'] * 100 : 0;
  240. // 设置分销二比例
  241. $data['extension_two_rate'] = $data['extension_two_rate'] ? $data['extension_two_rate'] * 100 : 0;
  242. // 返回配置信息
  243. return app('json')->success($data);
  244. }
  245. /**
  246. * 从回收站中恢复指定ID的商品
  247. *
  248. * @param int $id 商品ID
  249. * @return \Illuminate\Http\JsonResponse 返回JSON格式的操作结果
  250. */
  251. public function restore($id)
  252. {
  253. // 判断商品是否存在于回收站中
  254. if (!$this->repository->merDeleteExists($this->request->merId(), $id))
  255. return app('json')->fail('只能恢复回收站的商品');
  256. // 恢复商品
  257. $this->repository->restore($id);
  258. // 返回操作结果
  259. return app('json')->success('商品已恢复');
  260. }
  261. /**
  262. * 获取上传临时密钥
  263. *
  264. * @return \Illuminate\Http\JsonResponse 返回JSON格式的上传临时密钥
  265. */
  266. public function temp_key()
  267. {
  268. // 创建上传服务实例
  269. $upload = UploadService::create();
  270. // 获取上传临时密钥
  271. $re = $upload->getTempKeys();
  272. // 返回上传临时密钥
  273. return app('json')->success($re);
  274. }
  275. /**
  276. * 更新商品排序
  277. *
  278. * @param int $id 商品ID
  279. * @return \think\response\Json 返回JSON格式的操作结果
  280. */
  281. public function updateSort($id)
  282. {
  283. // 获取请求参数中的排序值
  284. $sort = $this->request->param('sort');
  285. // 调用商品仓库的更新排序方法
  286. $this->repository->updateSort($id, $this->request->merId(), ['sort' => $sort]);
  287. // 返回操作成功的JSON格式数据
  288. return app('json')->success('修改成功');
  289. }
  290. /**
  291. * 预览商品信息
  292. *
  293. * @return \think\response\Json 返回JSON格式的操作结果
  294. */
  295. public function preview()
  296. {
  297. // 获取请求参数中的商品信息
  298. $data = $this->request->param();
  299. // 设置商家信息
  300. $data['merchant'] = [
  301. 'mer_name' => $this->request->merchant()->mer_name,
  302. 'is_trader' => $this->request->merchant()->is_trader,
  303. 'mer_avatar' => $this->request->merchant()->mer_avatar,
  304. 'product_score' => $this->request->merchant()->product_score,
  305. 'service_score' => $this->request->merchant()->service_score,
  306. 'postage_score' => $this->request->merchant()->postage_score,
  307. 'service_phone' => $this->request->merchant()->service_phone,
  308. 'care_count' => $this->request->merchant()->care_count,
  309. 'type_name' => $this->request->merchant()->type_name->type_name ?? '',
  310. 'care' => true,
  311. 'recommend' => $this->request->merchant()->recommend,
  312. ];
  313. // 设置商家ID和状态
  314. $data['mer_id'] = $this->request->merId();
  315. $data['status'] = 1;
  316. $data['mer_status'] = 1;
  317. $data['rate'] = 3;
  318. // 调用商品仓库的预览方法并返回操作结果
  319. return app('json')->success($this->repository->preview($data));
  320. }
  321. /**
  322. * 设置SPU标签
  323. * @param int $id SPU ID
  324. * @return \think\response\Json 返回JSON格式的操作结果
  325. */
  326. public function setLabels($id)
  327. {
  328. // 获取请求参数中的标签数据
  329. $data = $this->request->params(['mer_labels']);
  330. // 调用SpuRepository类的setLabels方法设置SPU标签
  331. app()->make(SpuRepository::class)->setLabels($id, 0, $data, $this->request->merId());
  332. // 返回操作成功的JSON格式数据
  333. return app('json')->success('修改成功');
  334. }
  335. /**
  336. * 获取属性值
  337. * @param int $id 属性ID
  338. * @return \think\response\Json 返回JSON格式的属性值
  339. */
  340. public function getAttrValue($id)
  341. {
  342. // 调用repository对象的getAttrValue方法获取属性值
  343. $data = $this->repository->getAttrValue($id, $this->request->merId());
  344. return app('json')->success($data);
  345. }
  346. /**
  347. * 免审
  348. * @param int $id SPU ID
  349. * @return \think\response\Json 返回JSON格式的操作结果
  350. * @throws \app\common\exception\ValidateException
  351. */
  352. public function freeTrial($id)
  353. {
  354. // 定义需要获取的请求参数
  355. $params = [
  356. "mer_cate_id",
  357. "sort",
  358. "is_show",
  359. "is_good",
  360. "attr",
  361. "attrValue",
  362. 'spec_type'
  363. ];
  364. // 获取请求参数中的数据
  365. $data = $this->request->params($params);
  366. // 判断商户分类是否存在
  367. if (!empty($data['mer_cate_id'])) {
  368. $count = app()->make(StoreCategoryRepository::class)->getWhereCount(['store_category_id' => $data['mer_cate_id'], 'is_show' => 1, 'mer_id' => $this->request->merId()]);
  369. if (!$count) throw new ValidateException('商户分类不存在或不可用');
  370. }
  371. // 设置状态为1
  372. $data['status'] = 1;
  373. // 调用repository对象的freeTrial方法进行免费试用
  374. $this->repository->freeTrial($id, $data, $this->request->merId(), $this->request->adminInfo());
  375. return app('json')->success('编辑成功');
  376. }
  377. /**
  378. * 上下架
  379. * @Author:Qinii
  380. * @Date: 2020/5/18
  381. * @param int $id
  382. * @return mixed
  383. */
  384. public function switchStatus($id)
  385. {
  386. $status = $this->request->param('status', 0) == 1 ? 1 : 0;
  387. $this->repository->switchShow($id, $status, 'is_show', $this->request->merId(), $this->request->adminInfo());
  388. return app('json')->success('修改成功');
  389. }
  390. /**
  391. * 批量上下架
  392. * @return \think\response\Json
  393. * @author Qinii
  394. * @day 2022/9/6
  395. */
  396. public function batchShow()
  397. {
  398. $ids = $this->request->param('ids');
  399. if (empty($ids)) return app('json')->fail('请选择商品');
  400. $status = $this->request->param('status') == 1 ? 1 : 0;
  401. $this->repository->batchSwitchShow($ids, $status, 'is_show', $this->request->merId(), $this->request->adminInfo());
  402. return app('json')->success('修改成功');
  403. }
  404. /**
  405. * 批量设置模板
  406. * @return \think\response\Json
  407. * @author Qinii
  408. * @day 2022/9/6
  409. */
  410. public function batchTemplate()
  411. {
  412. $ids = $this->request->param('ids');
  413. $ids = is_array($ids) ? $ids : explode(',', $ids);
  414. $data = $this->request->params(['temp_id']);
  415. if (empty($ids)) return app('json')->fail('请选择商品');
  416. if (empty($data['temp_id'])) return app('json')->fail('请选择运费模板');
  417. if (!$this->repository->merInExists($this->request->merId(), $ids)) return app('json')->fail('请选择您自己商品');
  418. $make = app()->make(ShippingTemplateRepository::class);
  419. if (!$make->merInExists($this->request->merId(), [$data['temp_id']]))
  420. return app('json')->fail('请选择您自己的运费模板');
  421. $data['delivery_free'] = 0;
  422. $this->repository->updates($ids, $data);
  423. return app('json')->success('修改成功');
  424. }
  425. /**
  426. * 批量标签
  427. * @return \think\response\Json
  428. * @author Qinii
  429. * @day 2022/9/6
  430. */
  431. public function batchLabels()
  432. {
  433. $ids = $this->request->param('ids');
  434. $data = $this->request->params(['mer_labels']);
  435. if (empty($ids)) return app('json')->fail('请选择商品');
  436. if (!$this->repository->merInExists($this->request->merId(), $ids))
  437. return app('json')->fail('请选择您自己商品');
  438. app()->make(SpuRepository::class)->batchLabels($ids, $data, $this->request->merId());
  439. return app('json')->success('修改成功');
  440. }
  441. /**
  442. * 批量设置推荐类型
  443. * @return \think\response\Json
  444. * @author Qinii
  445. * @day 2022/9/6
  446. */
  447. public function batchHot()
  448. {
  449. $ids = $this->request->param('ids');
  450. $data['is_good'] = 1;
  451. if (empty($ids)) return app('json')->fail('请选择商品');
  452. if (!$this->repository->merInExists($this->request->merId(), $ids))
  453. return app('json')->fail('请选择您自己商品');
  454. $this->repository->updates($ids, $data);
  455. return app('json')->success('修改成功');
  456. }
  457. /**
  458. * 批量设置佣金
  459. * @param ProductAttrValueRepository $repository
  460. * @return \think\response\Json
  461. * @author Qinii
  462. * @day 2022/12/26
  463. */
  464. public function batchExtension(ProductAttrValueRepository $repository)
  465. {
  466. $ids = $this->request->param('ids');
  467. $data = $this->request->params(['extension_one', 'extension_two']);
  468. if ($data['extension_one'] > 1 || $data['extension_one'] < 0 || $data['extension_two'] < 0 || $data['extension_two'] > 1) {
  469. return app('json')->fail('比例0~1之间');
  470. }
  471. if (empty($ids)) return app('json')->fail('请选择商品');
  472. if (!$this->repository->merInExists($this->request->merId(), $ids))
  473. return app('json')->fail('请选择您自己商品');
  474. $repository->updatesExtension($ids, $data);
  475. return app('json')->success('修改成功');
  476. }
  477. /**
  478. * 批量设置商品SVIP类型
  479. */
  480. public function batchSvipType()
  481. {
  482. // 获取请求参数中的商品ID
  483. $ids = $this->request->param('ids');
  484. // 获取请求参数中的SVIP价格类型
  485. $data = $this->request->params([['svip_price_type', 0]]);
  486. // 如果商品ID为空,则返回错误信息
  487. if (empty($ids)) return app('json')->fail('请选择商品');
  488. // 如果商品不属于当前商家,则返回错误信息
  489. if (!$this->repository->merInExists($this->request->merId(), $ids))
  490. return app('json')->fail('请选择您自己商品');
  491. // 更新商品SVIP类型
  492. $this->repository->updates($ids, $data);
  493. // 返回操作成功信息
  494. return app('json')->success('修改成功');
  495. }
  496. /**
  497. * 判断商品属性是否符合格式要求
  498. * @param int $id 商品ID
  499. * @return \think\response\Json 返回JSON格式的数据
  500. */
  501. public function isFormatAttr($id)
  502. {
  503. // 获取请求参数中的商品属性、商品项和商品类型
  504. $data = $this->request->params([
  505. ['attrs', []],
  506. ['items', []],
  507. ['product_type', 0],
  508. ]);
  509. $is_copy = $this->request->param('is_copy',0);
  510. // 判断商品属性是否符合格式要求
  511. $data = $this->repository->isFormatAttr($data['attrs'], $id,[],$is_copy);
  512. // 返回操作成功信息和商品属性
  513. return app('json')->success($data);
  514. }
  515. /**
  516. * 获取批量操作类型
  517. * @return \think\response\Json
  518. *
  519. * @date 2023/10/12
  520. * @author yyw
  521. */
  522. public function getBatchList()
  523. {
  524. $productBatch = app()->make(ProductBatchProcessRepository::class);
  525. return app('json')->success($productBatch->getTypeList());
  526. }
  527. /**
  528. * 商品批量操作
  529. * @return \think\response\Json
  530. *
  531. * @date 2023/10/12
  532. * @author yyw
  533. */
  534. public function batchProcess()
  535. {
  536. $ids = $this->request->param('ids', []);
  537. $batch_type = $this->request->param('batch_type');
  538. $batch_select_type = $this->request->param('batch_select_type', 'select');
  539. $admin_info = $this->request->adminInfo();
  540. // 商品列表 搜索条件
  541. $where = $this->request->param('where', []) ?: [];
  542. if (!empty($where)) {
  543. $where = array_merge($where, $this->repository->switchType($where['type'], $this->request->merId(), 0));
  544. }
  545. $productBatch = app()->make(ProductBatchProcessRepository::class);
  546. $type_info = $productBatch->getTypeInfo($batch_type);
  547. $data = $this->request->params($type_info['param']);
  548. $res = $productBatch->setProductIds($this->request->merId(), $batch_type, $batch_select_type, $where, $ids, $data, $admin_info);
  549. if (is_string($res)) {
  550. return app('json')->success($res);
  551. }
  552. return app('json')->success('修改成功');
  553. }
  554. /**
  555. * 获取操作日志列表
  556. *
  557. * @param int $product_id 商品ID
  558. * @return \think\response\Json
  559. */
  560. public function getOperateList($product_id)
  561. {
  562. // 从请求参数中获取类型和日期
  563. $where = $this->request->params([
  564. ['type', ''],
  565. ['date', '']
  566. ]);
  567. // 设置关联ID和关联类型
  568. $where['relevance_id'] = $product_id;
  569. $where['relevance_type'] = OperateLogRepository::RELEVANCE_PRODUCT;
  570. // 获取分页信息
  571. [$page, $limit] = $this->getPage();
  572. // 调用操作日志仓库的lst方法获取操作日志列表并返回JSON格式的成功响应
  573. return app('json')->success(app()->make(OperateLogRepository::class)->lst($where, $page, $limit));
  574. }
  575. /**
  576. * 解绑卡密库
  577. * @return \think\response\Json
  578. * @author Qinii
  579. */
  580. public function unbind()
  581. {
  582. $data = $this->request->params(['value_id','library_id']);
  583. $this->repository->unbindCdkeyLibrary($data['value_id'],$data['library_id']);
  584. return app('json')->success('删除成功');
  585. }
  586. /**
  587. * 可以用于选择为活动商品的 商品选择列表
  588. * @return \think\response\Json
  589. * @author Qinii
  590. */
  591. public function product_list()
  592. {
  593. $where = $this->request->params([
  594. ['keyword',''], //商品搜索
  595. ['mer_labels', ''], //商户标签
  596. ['is_show',''], //上下架
  597. ['mer_cate_id',''], //商户分类
  598. ['in_type','0,1'], //商品类型
  599. ['status', 1], //商品审核状态
  600. ['cate_pid',''], //平台商品分类选择 1,2 级
  601. ['cate_id',''], //平台商品分类 3级
  602. ]);
  603. [$page, $limit] = $this->getPage();
  604. $data = $this->repository->getList($this->request->merId(), $where, $page, $limit);
  605. return app('json')->success($data);
  606. }
  607. }