|
@@ -2747,6 +2747,14 @@ class Sale extends Base
|
|
|
if (empty($info)) {
|
|
|
return error_show(1004, "订单数据未找到");
|
|
|
}
|
|
|
+ $sale =Db::name("sale")->where(["orderCode"=>$info["orderCode"]])->find();
|
|
|
+ if($sale==false){
|
|
|
+ return error_show(1004, "订单数据未找到");
|
|
|
+ }
|
|
|
+ $cgd = Db::name("purchease_diff")->where(['id'=>$info['cgd_diffid']])->find();
|
|
|
+ if($cgd==false){
|
|
|
+ return error_show(1004, "采购工差单数据未找到");
|
|
|
+ }
|
|
|
$is_act = isset($this->post['is_act']) && $this->post['is_act'] !== "" ? intval($this->post['is_act']) : "";
|
|
|
if ($is_act === '') {
|
|
|
return error_show(1004, "参数is_act不能为空");
|
|
@@ -2763,17 +2771,51 @@ class Sale extends Base
|
|
|
$info['status'] = $status;
|
|
|
$info['remark'] = $remark;
|
|
|
$info['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $up = Db::name("sale_diff")->save($info);
|
|
|
- if ($up) {
|
|
|
- $stx = ["order_code"=>$info["orderCode"],"status"=>$item,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
- ActionLog::logAdd($this->post['token'],$stx,"XSGCD",$info['status'],$info);
|
|
|
- $order=["order_type"=>"XSGCD","order_code"=>$info["orderCode"],"order_id"=>$info['id'],
|
|
|
- "order_status"=>$info['status'],"before_status"=> $item];
|
|
|
- ProcessOrder::AddProcess($this->post['token'],$order);
|
|
|
- return app_show(0, "更新成功");
|
|
|
- } else {
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $up = Db::name("sale_diff")->save($info);
|
|
|
+ if ($up) {
|
|
|
+ $stx = ["order_code"=>$info["orderCode"],"status"=>$item,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stx,"XSGCD",$info['status'],$info);
|
|
|
+ $order=["order_type"=>"XSGCD","order_code"=>$info["orderCode"],"order_id"=>$info['id'],"order_status"=>$info['status'],"before_status"=> $item];
|
|
|
+ ProcessOrder::AddProcess($this->post['token'],$order);
|
|
|
+ $upda=[
|
|
|
+ "status"=>$status,
|
|
|
+ "remark"=>$remark,
|
|
|
+ "updatetime"=> date("Y-m-d H:i:s"),
|
|
|
+ ];
|
|
|
+ $cgdup =Db::name("purchease_diff")->where(["id"=>$info['cgd_diffid']])->save($upda);
|
|
|
+ if($cgdup){
|
|
|
+ if($status==2){
|
|
|
+ if($is_act==1){
|
|
|
+ $sale['diff_weight'] = $info['diff_weight'];
|
|
|
+ $sale['diff_fee'] = $info['diff_price'];
|
|
|
+ $sale['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $sal=Db::name("sale")->save($sale);
|
|
|
+ if($sal==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1003, "订单更新工差失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $cgdup =Db::name("purchease_order")->where(["cgdNo"=>$cgd['cgdNo']])->save
|
|
|
+ (["diff_weight"=>$cgd['diff_weight'],"diff_fee"=>$cgd['diff_price'],"updatetime"=> date("Y-m-d H:i:s")]);
|
|
|
+ if($cgdup==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1003, "采购订单更新工差失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0, "更新成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
return error_show(1003, "更新失败");
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1003, $e->getMessage());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|