success('提交成功', $list); } //获取店铺 public function getShop(ShopList $shopList){ $platform_id = $this->request->post('platform_id/d'); if(empty($platform_id)){ $this->error('参数有误'); } return $this->success('ok', $shopList->where('platform', $platform_id)->column('name', 'id')); } //获取规格 public function getSpec(ShopList $shopList){ $shop_id = $this->request->post('shop_id/d'); if( empty($shop_id)){ $this->error('参数有误'); } $spec = $shopList->where('id', $shop_id)->value('type_spec'); $shopList = $spec?json_decode($spec, true): []; return $this->success('ok', $shopList); } //发货记录 public function delivery(ShopDelivery $shopDelivery){ $data = $this->request->post(); $result = $shopDelivery::where($data)->select(); $this->success(); } //添加记录 public function create(ShopDelivery $shopDelivery, SpecService $specService) { $data = $this->request->post(); $result = false; Db::startTrans(); try { validate(ShopValidate::class)->scene('add')->check($data); //发货数据 $resData = $specService::getDeliveryList($this->userinfo['id'], $data); //扣除库存 $result = $shopDelivery->saveAll($resData); Db::commit(); }catch (ValidateException $e) { Db::rollback(); return $this->error($e->getError()); } catch (\Exception $e) { Db::rollback(); $this->error($e->getMessage()); } if ($result === false) { $this->error(__('没有新增任何数据')); } $this->success(); } }