|
@@ -396,13 +396,13 @@ class Orderback extends \app\BaseController
|
|
try {
|
|
try {
|
|
|
|
|
|
$info = Db::name("order_back")
|
|
$info = Db::name("order_back")
|
|
- ->field('id,order_type,status,outCode,good_code,return_num')
|
|
|
|
|
|
+ ->field('id,order_type,status,outCode,good_code,return_num,orderCode,returnCode')
|
|
->where(['thNo' => $param['thNo'], 'is_del' => 0])
|
|
->where(['thNo' => $param['thNo'], 'is_del' => 0])
|
|
->find();
|
|
->find();
|
|
|
|
|
|
if (empty($info)) throw new Exception('未找到数据');
|
|
if (empty($info)) throw new Exception('未找到数据');
|
|
- $order= Db::name('sale')->where(['orderCode'=>$info['orderCode'],"is_del"=>0])->find();
|
|
|
|
- if($order==false){
|
|
|
|
|
|
+ $sale= Db::name('sale')->where(['orderCode'=>$info['orderCode'],"is_del"=>0])->find();
|
|
|
|
+ if($sale==false){
|
|
Db::rollback();
|
|
Db::rollback();
|
|
return error_show(1004,"未找到销售单数据");
|
|
return error_show(1004,"未找到销售单数据");
|
|
}
|
|
}
|
|
@@ -418,7 +418,7 @@ class Orderback extends \app\BaseController
|
|
}
|
|
}
|
|
|
|
|
|
if($param['can_sell_num']!=0&& $param['can_sell_wsm']!=''){
|
|
if($param['can_sell_num']!=0&& $param['can_sell_wsm']!=''){
|
|
- if($order['is_stock']==1){ //库存品退回原仓库 备库单释放数量 采购单
|
|
|
|
|
|
+ if($sale['is_stock']==1){ //库存品退回原仓库 备库单释放数量 采购单
|
|
$param['can_sell_wsm'] = $out['wsm_code'];
|
|
$param['can_sell_wsm'] = $out['wsm_code'];
|
|
}
|
|
}
|
|
$stock = Db::name("good_stock")->where(["spuCode"=>$info['good_code'],'wsm_code'=>$param['can_sell_wsm']])->find();
|
|
$stock = Db::name("good_stock")->where(["spuCode"=>$info['good_code'],'wsm_code'=>$param['can_sell_wsm']])->find();
|
|
@@ -481,11 +481,11 @@ class Orderback extends \app\BaseController
|
|
$update_data['defective_num'] = $param['defective_num'];
|
|
$update_data['defective_num'] = $param['defective_num'];
|
|
$update_data['loss_num'] = $param['loss_num'];
|
|
$update_data['loss_num'] = $param['loss_num'];
|
|
|
|
|
|
- if($order['is_stock']==1){
|
|
|
|
- $order['th_num']+= $info['return_num'];
|
|
|
|
- $order['th_fee']+= round($info['return_num']*$order['sale_price'],2);
|
|
|
|
- $order['updatetime']= date("Y-m-d H:i:s");
|
|
|
|
- $uap=Db::name("sale")->save($order);
|
|
|
|
|
|
+ if($sale['is_stock']==1){
|
|
|
|
+ $sale['th_num']+= $info['return_num'];
|
|
|
|
+ $sale['th_fee']+= round($info['return_num']*$sale['sale_price'],2);
|
|
|
|
+ $sale['updatetime']= date("Y-m-d H:i:s");
|
|
|
|
+ $uap=Db::name("sale")->save($sale);
|
|
if($uap==false){
|
|
if($uap==false){
|
|
Db::rollback();
|
|
Db::rollback();
|
|
return error_show(1005,'销售单订单更新失败');
|
|
return error_show(1005,'销售单订单更新失败');
|
|
@@ -506,8 +506,8 @@ class Orderback extends \app\BaseController
|
|
Db::rollback();
|
|
Db::rollback();
|
|
return error_show(1005,'未找到采购单数据');
|
|
return error_show(1005,'未找到采购单数据');
|
|
}
|
|
}
|
|
- $cgd['th_fee'] = round($cgd['good_price']*$param['can_sell_num'],2);
|
|
|
|
- $cgd['th_num']-= $param['can_sell_num'];
|
|
|
|
|
|
+ $cgd['th_fee']+= round($cgd['good_price']*$param['can_sell_num'],2);
|
|
|
|
+ $cgd['th_num']+= $param['can_sell_num'];
|
|
$cgd['updatetime']= date("Y-m-d H:i:s");
|
|
$cgd['updatetime']= date("Y-m-d H:i:s");
|
|
$cgdup =Db::name("purchease_order")->save($cgd);
|
|
$cgdup =Db::name("purchease_order")->save($cgd);
|
|
if($cgdup==false){
|
|
if($cgdup==false){
|
|
@@ -540,10 +540,10 @@ class Orderback extends \app\BaseController
|
|
}
|
|
}
|
|
}else{
|
|
}else{
|
|
if($returninfo['return_tag']==1){
|
|
if($returninfo['return_tag']==1){
|
|
- $order['th_num']+= $info['return_num'];
|
|
|
|
- $order['th_fee']+= round($info['return_num']*$order['sale_price'],2);
|
|
|
|
- $order['updatetime']= date("Y-m-d H:i:s");
|
|
|
|
- $uap=Db::name("sale")->save($order);
|
|
|
|
|
|
+ $sale['th_num']+= $info['return_num'];
|
|
|
|
+ $sale['th_fee']+= round($info['return_num']*$sale['sale_price'],2);
|
|
|
|
+ $sale['updatetime']= date("Y-m-d H:i:s");
|
|
|
|
+ $uap=Db::name("sale")->save($sale);
|
|
if($uap==false){
|
|
if($uap==false){
|
|
Db::rollback();
|
|
Db::rollback();
|
|
return error_show(1005,'销售单订单更新失败');
|
|
return error_show(1005,'销售单订单更新失败');
|
|
@@ -574,10 +574,10 @@ class Orderback extends \app\BaseController
|
|
}
|
|
}
|
|
|
|
|
|
}else{
|
|
}else{
|
|
- $order['th_num']+= $info['return_num'];
|
|
|
|
- $order['th_fee']+= round($info['return_num']*$order['sale_price'],2);
|
|
|
|
- $order['updatetime']= date("Y-m-d H:i:s");
|
|
|
|
- $uap=Db::name("sale")->save($order);
|
|
|
|
|
|
+ $sale['th_num']+= $info['return_num'];
|
|
|
|
+ $sale['th_fee']+= round($info['return_num']*$sale['sale_price'],2);
|
|
|
|
+ $sale['updatetime']= date("Y-m-d H:i:s");
|
|
|
|
+ $uap=Db::name("sale")->save($sale);
|
|
if($uap==false){
|
|
if($uap==false){
|
|
Db::rollback();
|
|
Db::rollback();
|
|
return error_show(1005,'销售单订单更新失败');
|
|
return error_show(1005,'销售单订单更新失败');
|
|
@@ -598,8 +598,8 @@ class Orderback extends \app\BaseController
|
|
Db::rollback();
|
|
Db::rollback();
|
|
return error_show(1005,'未找到采购单数据');
|
|
return error_show(1005,'未找到采购单数据');
|
|
}
|
|
}
|
|
- $cgd['th_fee'] = round($cgd['good_price']*$param['can_sell_num'],2);
|
|
|
|
- $cgd['th_num']-= $param['can_sell_num'];
|
|
|
|
|
|
+ $cgd['th_fee']+= round($cgd['good_price']*$param['can_sell_num'],2);
|
|
|
|
+ $cgd['th_num']+= $param['can_sell_num'];
|
|
$cgd['updatetime']= date("Y-m-d H:i:s");
|
|
$cgd['updatetime']= date("Y-m-d H:i:s");
|
|
$cgdup =Db::name("purchease_order")->save($cgd);
|
|
$cgdup =Db::name("purchease_order")->save($cgd);
|
|
if($cgdup==false){
|
|
if($cgdup==false){
|