Browse Source

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

wugg 2 years ago
parent
commit
b56f2a1a32
1 changed files with 59 additions and 10 deletions
  1. 59 10
      app/admin/controller/After.php

+ 59 - 10
app/admin/controller/After.php

@@ -1083,7 +1083,44 @@ class After extends Base
 //                                'updatetime' => date("Y-m-d H:i:s")
 //                            ]);
                         Db::execute("UPDATE `wsm_standing_book` SET `thNo`=CONCAT(IFNULL(`thNo`,''),',{$thNo}'),`updatetime`='" . date('Y-m-d H:i:s') . "' WHERE FIND_IN_SET('{$bkcode}',`returnCode`)");//这里的returnCode可能有多个
-
+						 // 库存品退货 不退商品 需要计算成本
+//						if($info['except_code']==1){
+//							$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;
+//                        			$ve['num']-=$total_num;
+//                        			$total_num=0;
+//                        		}
+//                        		$bnin=GoodStockInfo::ReturnAdd($stockid,$ve['bnCode'],$tempnum,$ve['stockid']);
+//                        		if($bnin==false){
+//                        			 Db::rollback();
+//                                    return error_show(1005, '可售商品Bn库存数入库失败');
+//                        		}
+//								$up=Db::name("sale_info")->save($ve);
+//                        		if($up==false){
+//                        			 Db::rollback();
+//                                    return error_show(1005, '可售商品Bn库存数入库失败');
+//                        		}
+//								$bnin=GoodStockInfo::ReturnBn($info['returnCode'],$ve['id'],$tempnum);
+//                        		if($bnin==false){
+//                        			 Db::rollback();
+//                                    return error_show(1005, '可售商品Bn库存数入库失败');
+//                        		}
+//                        	}
+//                        }
+//						}else{
+//
+//						}
                         if($info['return_tag']==1){
                             $sale['th_num']+= $info['error_num'];
                             if($sale['th_num']==$sale['send_num']&& $sale['wsend_num']==0){
@@ -1125,11 +1162,11 @@ class After extends Base
 	                                return error_show(1005,'采购单数据更新失败');
 	                            }
                             }
-                            // 库存品退货 不退商品 需要计算成本
-                            	$sabebn =Db::name("sale_info")->where(["orderCode"=>$info['orderCode']])->select()->toArray();
+
+                                $sabebn =Db::name("sale_info")->where(["orderCode"=>$info['orderCode']])->select()->toArray();
                             	 if(!empty($sabebn)){
-									$total_num= $info['error_num'];
-		                            foreach ($sabebn as $ve){
+		                            $total_num =$info["error_num"];
+		                            foreach($sabebn as $ve){
 		                                $tempnum=0;
 		                                if ($total_num==0) break;
 		                                if($total_num>=$ve['num']){
@@ -1138,18 +1175,30 @@ class After extends Base
 		                                    $ve['num']=0;
 		                                }else{
 		                                    $tempnum = $total_num;
-		                                    $total_num=0;
 		                                    $ve['num']-=$total_num;
+		                                    $total_num=0;
 		                                }
-										$bnin=GoodStockInfo::ReturnBn($thNo,$ve['id'],$tempnum);
+
+		                                if($info['except_code']==1){
+		                                		$bnin=GoodStockInfo::AddBn($ve['stockid'],$ve['bnCode'],$tempnum);
+				                                if($bnin==false){
+				                                     Db::rollback();
+				                                    return error_show(1005, '可售商品Bn库存数入库失败');
+				                                }
+				                                $up=Db::name("sale_info")->save($ve);
+				                                if($up==false){
+				                                     Db::rollback();
+				                                    return error_show(1005, '可售商品Bn库存数入库失败');
+				                                }
+		                                	}
+
+										$bnin=GoodStockInfo::ReturnBn($info['returnCode'],$ve['id'],$tempnum);
 		                                if($bnin==false){
 		                                     Db::rollback();
 		                                    return error_show(1005, '可售商品Bn库存数入库失败');
 		                                }
 		                            }
-                                }
-
-
+                        }
                             if($info['error_num']>=$out['send_num']){
                                     $out['status']=4;
                                     $out['updatetime']=date("Y-m-d H:i:s");