'', 'order_id' => '订单id', 'cloud_order_id' => '云仓转单id', 'cloud_supplier_id' => '云仓供货商id', 'goods_info' => '转单的商品信息', 'order_detail_ids' => 'oder_detail_id关联信息', 'province_id' => '省', 'city_id' => '市', 'district_id' => '区', 'address' => '地址详情', 'name' => '联系人', 'tel' => '联系电话', 'status' => '转单状态 -1取消 0 转单创建成功1 供货商已发货 2 已确认收货', 'is_delete' => '0未删除 1已删除', 'created_at' => '创建时间', 'deleted_at' => '删除时间', 'express_name' => '', 'express_no' => '', 'send_type' => '', 'order_type' => '订单类型', 'order_price' => '', 'confirm_time' => '确认收货时间', 'is_sale' => '是否过售后期', 'cancel_examine' => '是否申请售后 0未申请 1已申请 ', 'cancel_examine_time' => '取消时间', ]; } public function afterOtherDataSave() { \app\modules\admin\models\jushuitan\JuShuiTanForm::afterTransitOrderSave($this); } public function afterSave($insert, $changedAttributes) { \app\modules\admin\models\jushuitan\JuShuiTanForm::afterTransitOrderSave($this, $insert, $changedAttributes); } public static function checkMdFrontBind($mch, $md_id = 0) { try { // $md_id = get_md_id(); $mdAgentFrontBind = AgentFrontBind::findOne(['md_id' => $md_id, 'is_delete' => 0, 'status' => 1]); foreach ($mch['goods_list'] as $goods_item) { $goods_item['goods_name'] = mb_substr($goods_item['goods_name'], 0, 10); $supplierWhere = [ 'is_delete' => 0, 'status' => 1, 'type' => AgentFrontBind::TYPE_SUPPLIER, ]; //如果是云仓商品 且 配送方式为仓库配送 或集采 if (intval($goods_item['cloud_goods_id']) && (intval($goods_item['is_front_delivery']) || intval($goods_item['is_front_centralize']))) { if (intval($goods_item['is_front_delivery'])) { if (!in_array($mch['send'], ['shop', 'delivery'])) { throw new \Exception('只能选择自提配送或同城配送'); } } if (intval($goods_item['is_front_centralize'])) { if ($mch['send'] != 'shop') { throw new \Exception('只能选择自提配送'); } } if ($mch['send'] === 'shop') { if ($md_id <= 0) { throw new \Exception('自提订单请选择门店'); } //判断当前门店是否绑定仓库 if (!$mdAgentFrontBind) { throw new \Exception('当前门店未拥有商品:'.$goods_item['goods_name'].'...的售卖权限,请尝试其他门店下单'); } $supplierWhere['front_agent_admin_id'] = $mdAgentFrontBind->front_agent_admin_id; } if ($mch['send'] === 'delivery') { if ($md_id <= 0) { $goods = Goods::findOne($goods_item['goods_id']); if (!$goods) { throw new \Exception('商城商品' .$goods_item['goods_name']. '...状态异常'); } $md = Md::findOne(['store_id' => $goods->store_id, 'is_delete' => 0, 'shop_audit' => Md::SHOP_AUDIT_YES]); if (!$md) { throw new \Exception('当前商城暂未创建门店不支持仓库同城配送'); } $mdAgentFrontBind = AgentFrontBind::find()->where(['type' => AgentFrontBind::TYPE_STORE, 'type_id' => $goods->store_id, 'is_delete' => 0, 'status' => 1]) ->andWhere(['>', 'md_id', 0])->select('front_agent_admin_id')->column(); if (!$mdAgentFrontBind) { throw new \Exception('当前商城门店状态异常不能下单,请联系客服'); } $supplierWhere['front_agent_admin_id'] = $mdAgentFrontBind; } else { //判断当前门店是否绑定仓库 if (!$mdAgentFrontBind) { throw new \Exception('当前门店未拥有商品:'.$goods_item['goods_name'].'...的售卖权限,请尝试其他门店下单'); } $supplierWhere['front_agent_admin_id'] = $mdAgentFrontBind->front_agent_admin_id; } } if (intval($goods_item['is_front_delivery'])) { $erpInventory = AgentFrontErpInventory::findOne(['goods_no' => $goods_item['goods_no'], 'goods_id' => $goods_item['cloud_goods_id']]); if (!$erpInventory) { throw new \Exception('商品' .$goods_item['goods_name']. '...仓库暂无货源'); } if ($erpInventory->num <= $goods_item['num']) { throw new \Exception('商品' .$goods_item['goods_name']. '...仓库货源不足'); } } $cloud_supplier_id = $goods_item['cloud_supplier_id']; //如果下单的产品的供货商绑定的仓库和门店没有绑定,那么不能下单 if (!$cloud_supplier_id) { throw new \Exception('商品' .$goods_item['goods_name']. '...状态异常'); } $supplier = Supplier::findOne(['cloud_supplier_id' => $cloud_supplier_id, 'is_delete' => 0]); if (!$supplier) { throw new \Exception('供货商' .$goods_item['goods_name']. '...状态异常'); } $supplierWhere['type_id'] = $supplier->id; //判断当前商品供货商是否和门店仓库关联 $supplierAgentFrontBind = AgentFrontBind::findOne($supplierWhere); if (!$supplierAgentFrontBind) { throw new \Exception('商品' .$goods_item['goods_name']. '...状态异常 不能下单 请联系客服'); } } } return [ 'code' => 0, 'msg' => 'success' ]; } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } }