where(["orderCode"=>$event])->findOrEmpty(); if($orderinfo->isEmpty()==false&& $orderinfo->order_type!=1){ $cgdCode = makeNo('CG'); $wsm =(new WarehouseInfo())->where(['supplierNo' => $orderinfo->supNo, 'companyNo' =>$orderinfo->supplierNo, 'wsm_type' => 2, 'is_del' => 0])->findOrEmpty(); if($wsm->isEmpty()){ $wsm_code = makeNo('WSM'); $inwsm = [ 'wsm_code' => $wsm_code, 'name' => $orderinfo->supName, 'wsm_type' => 2, 'supplierNo' => $orderinfo->supNo, 'supplierName' => $orderinfo->supName, 'addr' => '', 'addrs_code' => '', 'contactor' => $orderinfo->cgderid , 'contactor_name' => $orderinfo->cgder , 'mobile' => '', 'position' => '', 'companyNo' => $orderinfo->supplierNo, 'companyName' => $orderinfo->supplierName, 'status' => 1, 'is_del' => 0, 'addtime' => date('Y-m-d H:i:s'), 'updatetime' => date('Y-m-d H:i:s'), 'createrid' => $orderinfo->apply_id, 'creater' => $orderinfo->apply_name, 'updaterid' => $orderinfo->apply_id, 'updater' => $orderinfo->apply_name, ]; WarehouseInfo::create($inwsm); }else { $wsm_code = $wsm['wsm_code']; } //判断该供应商是否开通了供应商账号 $from_tag=AccountCompany::IsOpenAccount($orderinfo->supNo); $info = (new BbcFill())->where(["fillCode"=>$orderinfo->other_orderNo])->findOrEmpty(); if($info->isEmpty())return; if($info->fill_type==2){ $origins=(new GoodNake())->where([['spuCode', '=', $orderinfo->good_code], ['min_num', '<=', $info->good_num], ['is_del', '=', 0]])->order('min_num desc')->findOrEmpty(); $good = (new Good())->where(['spuCode'=>$orderinfo->good_code])->findOrEmpty(); $origin =array_merge($good->toArray(),$origins->toArray()); } if($info->fill_type==3){ $origin =(new \app\admin\model\ConsultBids())->where([['spuCode', '=', $orderinfo->good_code] ,['is_del', '=', 0]])->findOrEmpty()->toArray(); } $cg = [ 'cgdNo' => $cgdCode, 'bkcode' => '', 'wsm_code' => $wsm_code, 'cgder' => $orderinfo->cgder, 'cgder_id' => $orderinfo->cgderid, 'spuCode' => $orderinfo->good_code, 'skuCode' => $orderinfo->skuCode, 'good_name' => $orderinfo->good_name, 'good_num' => $orderinfo->good_num, 'good_price' => $orderinfo->origin_price, 'total_fee' => round(bcmul($orderinfo->origin_price , $orderinfo->good_num,4),2), 'pakge_fee' => $origin['pakge_fee']??"0", 'cert_fee' => $origin['cert_fee']??'0', 'open_fee' => $origin['open_fee']??'0', 'teach_fee' => $origin['cost_fee']??'0', 'mark_fee' => $origin['mark_fee']??'0', 'demo_fee' => $origin['demo_fee']??'0', 'nake_fee' => $origin['nake_fee']??'0', 'weight' => $origin['weight'], 'delivery_fee' => $origin['delivery_fee']??0, 'gold_price' =>0, 'diff_weight' => '0', 'diff_fee' => '0', 'supplierNo' => $orderinfo->supNo , 'supplier_name' => $orderinfo->supName, 'companyNo' => $orderinfo->supplierNo, 'companyName' => $orderinfo->supplierName, 'send_status' => 1, 'send_num' => 0, 'wsend_num' => $orderinfo->good_num, 'remark' => '', 'status' => 0,//0初始化 'lasttime' => date('Y-m-d H:i:s'), 'is_del' => 0, 'order_type' => $orderinfo->order_type, 'order_source' =>11, 'good_type' => $orderinfo->good_type, 'addtime' => date('Y-m-d H:i:s'), 'updatetime' => date('Y-m-d H:i:s'), 'good_createrid' => $origin['createrid'], 'good_creater' => $origin['creater'],//商品创建人 'from_tag' => $from_tag==false ? 2 : 1,//来源标签:1采销(默认),2供应商端 ]; $cgd=PurcheaseOrder::create($cg); $events=['order_type' => 'CGD', 'order_code' =>$cgdCode,//咨询单详情编号 'order_id' => $cgd->id, 'order_status' => 2, 'action_process' =>0, 'action_status' => 0, 'action_uid' => $orderinfo->apply_id, 'action_name' => $orderinfo->apply_name, ]; event('ProcessOrder',$events); $orderOut= (new OrderOut())->where(["orderCode"=>$orderinfo->orderCode]) ->field("outCode,'{$cgdCode}' cgdNo,send_num")->select(); if($orderOut->isEmpty()==false) (new OrderSend())->saveAll($orderOut->toArray()); $rela = [ 'orderCode' => $event, 'cgdNo' => $cgdCode, 'spuCode' => $orderinfo->good_code, 'good_num' => $orderinfo->good_num, 'wsend_num' =>$orderinfo->good_num, 'send_num' => 0, 'wait_num' => 0, 'status' => 1, 'source' => 2 ]; OrderNum::create($rela); $goodstock =new GoodStock(); $stockinfo = $goodstock->where(['spuCode' =>$orderinfo->good_code, 'wsm_code' => $wsm_code, 'is_del' => 0])->findOrEmpty(); if($stockinfo->isEmpty()){ $stokc = [ 'spuCode' => $orderinfo->good_code, 'wsm_code' => $wsm_code, 'wait_in_stock' => $orderinfo->good_num, 'wait_out_stock' => 0, 'usable_stock' => 0, 'intra_stock' => 0, 'total_stock' => 0, 'status' => 1, 'addtime' => date('Y-m-d H:i:s'), 'updatetime' => date('Y-m-d H:i:s') ]; $stockinfo= GoodStock::create($stokc); }else{ $stockinfo->inc( 'wait_in_stock' ,$orderinfo->good_num)->update(); } $good_data[] = ['good_log_code' => $cgdCode, 'stock_id' =>$stockinfo->id, 'type' => 1,'stock' => $orderinfo->good_num, 'stock_name' => 'wait_in_stock']; GoodLog::LogAdd(['id'=>$orderinfo->apply_id,'nickname'=>$orderinfo->apply_name], $good_data, 'CGD'); } } }