Defaultcustomgoods.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use app\main\constants\PayConstants;
  5. use app\main\service\GoodsService;
  6. use think\Exception;
  7. class Defaultcustomgoods extends Backend
  8. {
  9. public function index()
  10. {
  11. $businessLine = $this->request->param('business_line', PayConstants::BUSINESS_WECHAT);
  12. $showAppSet = false;
  13. if ($this->group < 3) {
  14. $showAppSet = true;
  15. }
  16. $adminId = 0;
  17. if ($this->request->isPost()) {
  18. $params = $this->request->post("row/a");
  19. if (empty($params['goods_id'])) {
  20. $this->error('请添加一个商品');
  21. }
  22. $goodsIds = $params['goods_id'];
  23. $default = $params['default'] ?? '';
  24. try {
  25. GoodsService::instance()->saveChannelGoodsList($goodsIds, $adminId, $businessLine, $default);
  26. } catch (Exception $e) {
  27. $this->error($e->getMessage());
  28. }
  29. $this->success('操作成功');
  30. }
  31. $customGoodsList = GoodsService::instance()->getCustomGoodsList($adminId);
  32. $this->assignconfig('customGoodsList', json_encode($customGoodsList));
  33. $this->assignconfig('business_line', $businessLine);
  34. $this->assign('business_line', $businessLine);
  35. $this->assign('show_app_set', $showAppSet);
  36. return $this->fetch();
  37. }
  38. }