|
@@ -883,10 +883,17 @@ class Purch extends Base
|
|
|
if($diff_weight===""){
|
|
|
return error_show(1002,"参数diff_weight不能为空");
|
|
|
}
|
|
|
-// $apply_id =GetUserInfo($token);
|
|
|
-// if(empty($apply_id)||$apply_id['code']!=0){
|
|
|
-// return error_show(1002,"申请人数据不存在");
|
|
|
-// }
|
|
|
+ $orderCode = Db::name("order_num")->where([["cgdNo","=",$cg['cgdNo']],["status","=",1]])->findOrEmpty();
|
|
|
+ $order=[];
|
|
|
+ if(!empty($orderCode)){
|
|
|
+ $order = Db::name("sale")->where("orderCode", '=', $orderCode['orderCode'])->findOrEmpty();
|
|
|
+ if(empty($order)){
|
|
|
+ return error_show(1002,"未找到确认单信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $userCommon = new \app\admin\common\User();
|
|
|
+ $supp =$userCommon->handle("getCodeAndName",["code"=>[$cg['companyNo'],$order['customer_code']??"",$order['supplierNo']??""]]);
|
|
|
+ $SuppArr= $supp['data']??[];
|
|
|
$rid= $this->uid;
|
|
|
$rname= $this->uname;
|
|
|
$diff_price = round($diff_weight*$cg['gold_price']+$diff_weight*$cg['teach_fee'],2);
|
|
@@ -911,6 +918,10 @@ class Purch extends Base
|
|
|
"diff_weight"=>$diff_weight,
|
|
|
"diff_price"=>$diff_price,
|
|
|
"gold_price"=>$cg['good_price'],
|
|
|
+ "supplierName"=>$cg['supplier_name'],
|
|
|
+ "supplierNo"=>$cg['supplierNo'],
|
|
|
+ "companyNo"=>$cg['companyNo'],
|
|
|
+ "companyName"=>$SuppArr[$cg['companyNo']]??'',
|
|
|
"status"=>1,
|
|
|
"is_del"=>0,
|
|
|
"addtime"=>date("Y-m-d H:i:s"),
|
|
@@ -930,15 +941,7 @@ class Purch extends Base
|
|
|
'cgd_diff_id' => $item,//采购工差单id
|
|
|
'updatetime' => date("Y-m-d H:i:s")
|
|
|
];
|
|
|
-
|
|
|
- $orderCode = Db::name("order_num")->where([["cgdNo","=",$cg['cgdNo']],["status","=",1]])->find();
|
|
|
- if($orderCode!=false){
|
|
|
- $order = Db::name("sale")->where("orderCode", '=', $orderCode['orderCode'])->find();
|
|
|
- if($order==false){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1002,"未找到确认单信息");
|
|
|
- }
|
|
|
-
|
|
|
+ if(!empty($order)){
|
|
|
$data=[
|
|
|
"cgd_diffid"=>$item,
|
|
|
"orderCode"=>$orderCode['orderCode'],
|
|
@@ -947,19 +950,16 @@ class Purch extends Base
|
|
|
"diff_weight"=>$diff_weight,
|
|
|
"diff_price"=>round($diff_weight*$order['gold_price']+$diff_weight*$order['cost_price'],2),
|
|
|
"gold_price"=>$order['sale_price'],
|
|
|
+ "customerName"=>$SuppArr[$order['customer_code']]??"",
|
|
|
+ "customerNo"=>$order['customer_code'],
|
|
|
+ "companyNo"=>$order['supplierNo'],
|
|
|
+ "companyName"=>$SuppArr[$order['supplierNo']]??'',
|
|
|
"status"=>1,
|
|
|
"addtime"=>date("Y-m-d H:i:s"),
|
|
|
"updatetime"=>date("Y-m-d H:i:s")
|
|
|
];
|
|
|
$cgd = Db::name('sale_diff')->insert($data,true);
|
|
|
if($cgd==0){
|
|
|
-// $sto = ["order_code"=>$cg['bkcode'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
|
|
|
-// ActionLog::logAdd($this->post['token'],$sto,"ZXGCD",1,$sto);
|
|
|
-// $process=["order_code"=>$cg['bkcode'],"order_id"=>$cgd,"order_status"=>1,"order_type"=>'ZXGCD'];
|
|
|
-// ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
-// Db::commit();
|
|
|
-// return error_show(0,"新建成功");
|
|
|
-// }else{
|
|
|
Db::rollback();
|
|
|
return error_show(1002,"新建失败");
|
|
|
|
|
@@ -968,7 +968,6 @@ class Purch extends Base
|
|
|
ActionLog::logAdd($this->post['token'],$sto,"XSGCD",1,$data);
|
|
|
$process=["order_code"=>$orderCode['orderCode'],"order_id"=>$cgd,"order_status"=>1,"order_type"=>'XSGCD',"before_status"=>1,'holder_id'=>$order['apply_id']];
|
|
|
ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
-
|
|
|
$update_standing_book_data['sale_diff_id']=$cgd;//工差单id
|
|
|
|
|
|
}
|