Browse Source

Merge branch 'wugg-dev' of wugg/phpstock into version1.5

wugg 2 years ago
parent
commit
f86233fd73
1 changed files with 24 additions and 0 deletions
  1. 24 0
      app/admin/controller/After.php

+ 24 - 0
app/admin/controller/After.php

@@ -1125,6 +1125,29 @@ class After extends Base
 	                                return error_show(1005,'采购单数据更新失败');
 	                            }
                             }
+                            // 库存品退货 不退商品 需要计算成本
+                            	$sabebn =Db::name("sale_info")->where(["orderCode"=>$info['orderCode']])->select()->toArray();
+                            	 if(!empty($sabebn)){
+									$total_num= $info['error_num'];
+		                            foreach ($sabebn as $ve){
+		                                $tempnum=0;
+		                                if ($total_num==0) break;
+		                                if($total_num>=$ve['num']){
+		                                    $tempnum = $ve['num'];
+		                                    $total_num-=$ve['num'];
+		                                    $ve['num']=0;
+		                                }else{
+		                                    $tempnum = $total_num;
+		                                    $total_num=0;
+		                                    $ve['num']-=$total_num;
+		                                }
+										$bnin=GoodStockInfo::ReturnBn($thNo,$ve['id'],$tempnum);
+		                                if($bnin==false){
+		                                     Db::rollback();
+		                                    return error_show(1005, '可售商品Bn库存数入库失败');
+		                                }
+		                            }
+                                }
 
 
                             if($info['error_num']>=$out['send_num']){
@@ -1156,6 +1179,7 @@ class After extends Base
                                 Db::rollback();
                                 return error_show(1004,"退货单更新失败");
                             }
+
                         }
 
                         Db::commit();