|
@@ -2410,25 +2410,44 @@ class Sale extends Base
|
|
|
return error_show(1004, "参数id不能为空");
|
|
|
}
|
|
|
$info = Db::name("sale_diff")->where(["id" => $id])->find();
|
|
|
- if (empty($info)) {
|
|
|
+ if ($info==false) {
|
|
|
return error_show(1004, "订单数据未找到");
|
|
|
}
|
|
|
+ $cgd = Db::name("purchease_diff")->where(['id'=>$info['cgd_diffid']])->find();
|
|
|
+ if($cgd==false){
|
|
|
+ return error_show(1004, "采购工差单数据未找到");
|
|
|
+ }
|
|
|
$status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "3";
|
|
|
$remark = isset($this->post['remark']) && $this->post['remark'] !== "" ? trim($this->post['remark']) : "";
|
|
|
$ite=$info['status'];
|
|
|
- $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"=>$ite,"action_remark"=>'',"action_type"=>"status"];
|
|
|
- ActionLog::logAdd($this->post['token'],$stx,"QRGCD",$info['status'],$info);
|
|
|
- $order=["order_type"=>"QRGCD","order_code"=>$info["orderCode"],"order_id"=>$info['id'],"order_status"=>$info['status']];
|
|
|
- ProcessOrder::AddProcess($this->post['token'],$order);
|
|
|
- return app_show(0, "更新成功");
|
|
|
- } else {
|
|
|
- return error_show(1003, "更新失败");
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $upda=[
|
|
|
+ "status"=>$status,
|
|
|
+ "remark"=>$remark,
|
|
|
+ "updatetime"=> date("Y-m-d H:i:s"),
|
|
|
+ ];
|
|
|
+ $up = Db::name("sale_diff")->where($info)->save($upda);
|
|
|
+ if ($up) {
|
|
|
+ $stx = ["order_code"=>$info["orderCode"],"status"=>$ite,"action_remark"=>'',"action_type"=>"status"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stx,"QRGCD",$info['status'],$info);
|
|
|
+ $order=["order_type"=>"QRGCD","order_code"=>$info["orderCode"],"order_id"=>$info['id'],"order_status"=>$status];
|
|
|
+ ProcessOrder::AddProcess($this->post['token'],$order);
|
|
|
+ $cgdup =Db::name("purchease_diff")->where(["id"=>$info['cgd_diffid']])->save($upda);
|
|
|
+ if($cgdup){
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0, "更新成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1003, "更新失败");
|
|
|
+
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1003,$e->getMessage());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|