|
@@ -405,36 +405,53 @@ class Purch extends Base
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function status(){
|
|
|
- $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ?trim($this->post['cgdNo']):"";
|
|
|
+ public function status()
|
|
|
+ {
|
|
|
+ $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo'] != "" ? $this->post['cgdNo'] : [];
|
|
|
|
|
|
- if($cgdNo==""){
|
|
|
- return error_show(1004,"参数cgdNo 不能为空");
|
|
|
- }
|
|
|
- $data = Db::name("purchease_order")->where(["cgdNo"=>$cgdNo,"is_del"=>0])->find();
|
|
|
- if(empty($data)){
|
|
|
- return error_show(1004,"未找到数据");
|
|
|
+ if (empty($cgdNo)) {
|
|
|
+ return error_show(1004, "参数cgdNo 不能为空");
|
|
|
}
|
|
|
- $remark= isset($this->post['remark']) && $this->post['remark']!="" ?trim($this->post['remark']):"";
|
|
|
- $status = isset($this->post['status'])&&$this->post['status']!==""? intval($this->post['status']):"";
|
|
|
- if($status===""){
|
|
|
- return error_show(1004,"参数status 不能为空");
|
|
|
+
|
|
|
+ $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
|
|
|
+ if ($status === "") {
|
|
|
+ return error_show(1004, "参数status 不能为空");
|
|
|
}
|
|
|
- if($data['send_status']>1 && $status==0){
|
|
|
- return error_show(1004,"采购单发货中无法取消");
|
|
|
+
|
|
|
+ if ($status == 0) {
|
|
|
+ $data = Db::name("purchease_order")
|
|
|
+ ->field('id,cgdNo')
|
|
|
+ ->whereIn('cgdNo', $cgdNo)
|
|
|
+ ->where(["is_del" => 0])
|
|
|
+ ->where('send_status', '>', 1)
|
|
|
+ ->find();
|
|
|
+ if (!empty($data)) {
|
|
|
+ return error_show(1004, $data['cgdNo'] . "采购单发货中无法取消");
|
|
|
+ }
|
|
|
}
|
|
|
- $order = ["order_code"=>$cgdNo,"status"=> $data['status'] ,"action_remark"=>$remark,"action_type"=>"status"];
|
|
|
- $data['status'] = $status;
|
|
|
- $data['remark'] = $remark;
|
|
|
- $data['updatetime'] =date("Y-m-d H:i:s");
|
|
|
- $upd=Db::name("purchease_order")->save($data);
|
|
|
- if($upd){
|
|
|
- $process=["order_code"=>$cgdNo,"order_id"=>$data['id'],"order_status"=>$status,"order_type"=>'CGD'];
|
|
|
- ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
- ActionLog::logAdd($this->post['token'],$order,'CGD',$status,$this->post);
|
|
|
- return app_show(0,"更新成功");
|
|
|
- }else{
|
|
|
- return error_show(1004,'更新失败');
|
|
|
+// if($data['send_status']>1 && $status==0){
|
|
|
+// return error_show(1004,"采购单发货中无法取消");
|
|
|
+// }
|
|
|
+// $order = ["order_code"=>$cgdNo,"status"=> $data['status'] ,"action_remark"=>$remark,"action_type"=>"status"];
|
|
|
+// $data['status'] = $status;
|
|
|
+// $data['remark'] = $remark;
|
|
|
+// $data['updatetime'] =date("Y-m-d H:i:s");
|
|
|
+ $upd = Db::name("purchease_order")
|
|
|
+ ->whereIn('cgdNo', $cgdNo)
|
|
|
+ ->save([
|
|
|
+ 'status' => $status,
|
|
|
+ 'remark' => $remark,
|
|
|
+ 'updatetime' => date("Y-m-d H:i:s"),
|
|
|
+ ]);
|
|
|
+ if ($upd) {
|
|
|
+ $process = ["order_code" => $cgdNo, "order_id" => $data['id'], "order_status" => $status, "order_type" => 'CGD'];
|
|
|
+ ProcessOrder::AddProcess($this->post['token'], $process);
|
|
|
+ $order = ["order_code" => $cgdNo, "status" => $data['status'], "action_remark" => $remark, "action_type" => "status"];
|
|
|
+ ActionLog::logAdd($this->post['token'], $order, 'CGD', $status, $this->post);
|
|
|
+ return app_show(0, "更新成功");
|
|
|
+ } else {
|
|
|
+ return error_show(1004, '更新失败');
|
|
|
}
|
|
|
}
|
|
|
public function diffcreat(){
|