Product.php 24 KB

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