123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use app\main\constants\PayConstants;
- use app\main\service\GoodsService;
- use think\Exception;
- class Defaultcustomgoods extends Backend
- {
- public function index()
- {
- $businessLine = $this->request->param('business_line', PayConstants::BUSINESS_WECHAT);
- $showAppSet = false;
- if ($this->group < 3) {
- $showAppSet = true;
- }
- $adminId = 0;
- if ($this->request->isPost()) {
- $params = $this->request->post("row/a");
- if (empty($params['goods_id'])) {
- $this->error('请添加一个商品');
- }
- $goodsIds = $params['goods_id'];
- $default = $params['default'] ?? '';
- try {
- GoodsService::instance()->saveChannelGoodsList($goodsIds, $adminId, $businessLine, $default);
- } catch (Exception $e) {
- $this->error($e->getMessage());
- }
- $this->success('操作成功');
- }
- $customGoodsList = GoodsService::instance()->getCustomGoodsList($adminId);
- $this->assignconfig('customGoodsList', json_encode($customGoodsList));
- $this->assignconfig('business_line', $businessLine);
- $this->assign('business_line', $businessLine);
- $this->assign('show_app_set', $showAppSet);
- return $this->fetch();
- }
- }
|