|
@@ -344,15 +344,69 @@ class Reorder extends \app\BaseController
|
|
|
return error_show(1004,"参数return_wsm不能为空");
|
|
|
}
|
|
|
$info['return_wsm'] =$return_wsm;
|
|
|
+ $cgd = Db::name("purchease_order")->where(["bkcode"=>$info['orderCode'],"order_type"=>2])->find();
|
|
|
+ if(empty($cgd)){
|
|
|
+ return error_show(1002,"未找到采购单数据");
|
|
|
+ }
|
|
|
+ $gd= Db::name('good')->where(['good_code'=>$cgd['good_code']])->find();
|
|
|
+ if($gd==""){
|
|
|
+ return error_show(1002,"未找到商品数据");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ $token = isset($this->post['token']) && $this->post['token'] !=="" ?trim($this->post['token']):"";
|
|
|
+ $apply_id =GetUserInfo($token);
|
|
|
+ if(empty($apply_id)||$apply_id['code']!=0){
|
|
|
+ return error_show(1002,"申请人数据不存在");
|
|
|
+ }
|
|
|
+ $rid= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
|
|
|
+ $rname= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
|
|
|
$info['status'] =$status;
|
|
|
$info['remark'] =$remark;
|
|
|
$info["updatetime"]=date("Y-m-d H:i:s");
|
|
|
$up = Db::name("sale_return")->save($info);
|
|
|
if($up){
|
|
|
+
|
|
|
$ste = ["order_code"=>$code,"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
ActionLog::logAdd($this->post['token'],$ste,"xsd",$info['status'],$ste);
|
|
|
+ if($info['order_type']==2&&$status==4){
|
|
|
+ $returnCode=makeNo("TH");
|
|
|
+ $data = [
|
|
|
+ "returnCode"=>$returnCode,
|
|
|
+ "cgdNo"=>$cgd['cgdNo'],
|
|
|
+ "good_code"=>$cgd['good_type_code'],
|
|
|
+ "return_num"=>$cgd['wsend_num'],
|
|
|
+ "good_name"=>$cgd['good_name'],
|
|
|
+ "good_price"=>$cgd['good_price'],
|
|
|
+ "good_catid"=>$gd['cat_id'],
|
|
|
+ "apply_name"=>$rname,
|
|
|
+ "apply_id"=>$rid,
|
|
|
+ "good_total"=>$cgd['good_num'],
|
|
|
+ "post_company"=>"",
|
|
|
+ "post_code"=>"",
|
|
|
+ "post_fee"=>"",
|
|
|
+ "status"=>1,
|
|
|
+ "remark"=>'',
|
|
|
+ "is_del"=>0,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $pd = Db::name('purchease_back')->insert($data);
|
|
|
+ if($pd){
|
|
|
+ $cgd['wsend_num']=0;
|
|
|
+ $cgd['status']=3;
|
|
|
+ $cgd['send_status']=3;
|
|
|
+ $cgd['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $up=Db::name('purchease_order')->save($cgd);
|
|
|
+ if($up){
|
|
|
+ return app_show(0,"更新成功");
|
|
|
+ }else{
|
|
|
+ return error_show(1004,"更新失败");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return error_show(1004,"更新失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
return app_show(0,"更新成功");
|
|
|
}else{
|
|
|
return error_show(1004,"更新失败");
|
|
@@ -394,7 +448,6 @@ class Reorder extends \app\BaseController
|
|
|
if($order['wsend_num']<$num){
|
|
|
return error_show(1002,"仓库未发货数量不足退货");
|
|
|
}
|
|
|
-
|
|
|
$returnCode=makeNo("RXS");
|
|
|
Db::startTrans();
|
|
|
try{
|
|
@@ -415,41 +468,14 @@ class Reorder extends \app\BaseController
|
|
|
"updatetime"=>date("Y-m-d H:i:s")
|
|
|
];
|
|
|
$create = Db::name("sale_return")->insert($in);
|
|
|
- if($create){
|
|
|
- $addrorder= Db::name("order_addr")->where(['orderCode'=>$ordeCode])->select();
|
|
|
- $addrinfo=[];
|
|
|
- foreach ($addrorder as $value){
|
|
|
- $addrorder= Db::name("order_addr")->where(['orderCode'=>$ordeCode,"id"=>$value['addrid']])
|
|
|
- ->find();
|
|
|
- if(empty($addrorder)){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1002,"订单地址数据不存在");
|
|
|
- }
|
|
|
- $total = Db::name("sale_returnaddr")->where(['orderCode'=>$ordeCode,"id"=>$value['addrid'],"is_del"=>0])
|
|
|
- ->sum("return_num");
|
|
|
- if($addrorder['receipt_quantity']-$total<$value['return_num']){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1002,"订单地址退货数量超出发货数量");
|
|
|
- }
|
|
|
- $temp=[];
|
|
|
- $temp['returnCode']=$returnCode;
|
|
|
- $temp['orderCode']=$ordeCode;
|
|
|
- $temp['addrid']=$value['addrid'];
|
|
|
- $temp['return_num']=$value['return_num'];
|
|
|
- $temp['send_num']= $addrorder['receipt_quantity'];
|
|
|
- $temp['addtime']= date("Y-m-d H:i:s");
|
|
|
- $temp['updatetime']= date("Y-m-d H:i:s");
|
|
|
- $addrinfo[]=$temp;
|
|
|
- }
|
|
|
- $return = Db::name("sale_returnaddr")->insertAll($addrinfo);
|
|
|
- if($return<=0){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1002,"订单地址退货数据更新失败");
|
|
|
+ if($create) {
|
|
|
+ if ($order['send_type'] == 1) {
|
|
|
+ $wsend = DB::name("order_out")->where(['orderCode' => $ordeCode, "status" => 1, "order_type" => 2])
|
|
|
+ ->save(["status" => 0, "updatetime" => date("Y-m-d H:i:s")]);
|
|
|
+
|
|
|
}
|
|
|
- $info=[];
|
|
|
- $wsmorder= Db::name("sale_info")->where(['orderCode'=>$ordeCode])->find();
|
|
|
- Db::commit();
|
|
|
- return app_show(0,"退货单新建成功");
|
|
|
+ Db::commit();
|
|
|
+ return error_show(0,"退货单新建成功");
|
|
|
}
|
|
|
Db::rollback();
|
|
|
return error_show(1005,"退货单新建失败");
|