Product.php 24 KB

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