|
@@ -331,7 +331,7 @@ class Purch extends \app\BaseController
|
|
|
}
|
|
|
$cg = Db::name('purchease_order')->where(['cgdNo'=>$cgdNo,'is_del'=>0])->find();
|
|
|
if($cg==""){
|
|
|
- return error_show(1002,"未找到商品数据");
|
|
|
+ return error_show(1002,"未找到采购单数据");
|
|
|
}
|
|
|
$gd= Db::name('good')->where(['good_code'=>$cg['good_code']])->find();
|
|
|
if($gd==""){
|
|
@@ -438,17 +438,57 @@ class Purch extends \app\BaseController
|
|
|
if(empty($dio)){
|
|
|
return error_show(1002,"退货订单未找到");
|
|
|
}
|
|
|
+ $cgd = Db::name("purchease_order")->where(['cgdNo'=>$dio['cgdNo']])->find();
|
|
|
+ if(empty($cgd)){
|
|
|
+ return error_show(1002,"采购单未找到");
|
|
|
+ }
|
|
|
$status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
|
|
|
if($status===""){
|
|
|
return error_show(1002,"参数status不能为空");
|
|
|
}
|
|
|
- $dio['status']=$status;
|
|
|
- $dio['updatetime']=date("Y-m-d H:i:s");
|
|
|
- $item = Db::name("purchease_diff")->update($dio);
|
|
|
- if($item){
|
|
|
- return error_show(0,"更新成功");
|
|
|
- }else{
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $dio['status']=$status;
|
|
|
+ $dio['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $item = Db::name("purchease_diff")->update($dio);
|
|
|
+ if($item){
|
|
|
+ if($cgd['order_type']==2){
|
|
|
+ $order = Db::name("sale")->where(["orderCode"=>$cgd['bkcode']])->find();
|
|
|
+ if(empty($order)){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002,"未找到确认单信息");
|
|
|
+ }
|
|
|
+ $data=[
|
|
|
+ "orderCode"=>$cgd['bkcode'],
|
|
|
+ "good_code"=>$cgd['good_type_code'],
|
|
|
+ "good_kode"=>$cgd['good_code'],
|
|
|
+ "good_name"=>$cgd['good_name'],
|
|
|
+ "diff_weight"=>$dio['diff_weight'],
|
|
|
+ "diff_price"=>$dio['diff_weight']*$cgd['gold_price'],
|
|
|
+ "gold_price"=>$cgd['gold_price'],
|
|
|
+ "status"=>1,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $cgd = Db::name('sale_diff')->insert($data);
|
|
|
+ if($cgd){
|
|
|
+ Db::commit();
|
|
|
+ return error_show(0,"新建成功");
|
|
|
+ }else{
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002,"新建失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ return error_show(0,"更新成功");
|
|
|
+ }else{
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002,"更新失败");
|
|
|
+ }
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
return error_show(1002,"更新失败");
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|