wugg 2 jaren geleden
bovenliggende
commit
06517ffd94

+ 33 - 33
app/admin/controller/Purchin.php

@@ -287,18 +287,18 @@ class Purchin extends Base
                         // "action_type"=>"edit"];
                     }
                     $good['wait_in_stock']-=$send_num;
-                    if($good['presale_stock']>0){
-                        if($good['presale_stock']>=$send_num){
-                            $good['presale_stock']-=$send_num;
-                            $good['wait_out_stock']+=$send_num;
-                        }else{
-                            $good['presale_stock']=0;
-                            $good['usable_stock']+=$send_num-$good['presale_stock'];
-                            $good['wait_out_stock']+=$good['presale_stock'];
-                        }
-                    }else{
+//                    if($good['presale_stock']>0){
+//                        if($good['presale_stock']>=$send_num){
+//                            $good['presale_stock']-=$send_num;
+//                            $good['wait_out_stock']+=$send_num;
+//                        }else{
+//                            $good['presale_stock']=0;
+//                            $good['usable_stock']+=$send_num-$good['presale_stock'];
+//                            $good['wait_out_stock']+=$good['presale_stock'];
+//                        }
+//                    }else{
                         $good['usable_stock']+=$send_num;
-                    }
+               //     }
 
                     $good['total_stock']=$good['usable_stock']+$good['wait_out_stock'];
                     $good['updatetime'] = date("Y-m-d H:i:s");
@@ -677,18 +677,18 @@ class Purchin extends Base
                     }
 //                    $good['usable_stock']+=$info['wsm_num'];
                     $good['wait_in_stock']-=$info['wsm_num'];
-                    if($good['presale_stock']>0){
-                        if($good['presale_stock']>=$info['wsm_num']){
-                            $good['presale_stock']-=$info['wsm_num'];
-                            $good['wait_out_stock']+$info['wsm_num'];
-                        }else{
-                            $good['presale_stock']=0;
-                            $good['usable_stock']+=$info['wsm_num']-$good['presale_stock'];
-                            $good['wait_out_stock']+=$good['presale_stock'];
-                        }
-                    }else{
+//                    if($good['presale_stock']>0){
+//                        if($good['presale_stock']>=$info['wsm_num']){
+//                            $good['presale_stock']-=$info['wsm_num'];
+//                            $good['wait_out_stock']+$info['wsm_num'];
+//                        }else{
+//                            $good['presale_stock']=0;
+//                            $good['usable_stock']+=$info['wsm_num']-$good['presale_stock'];
+//                            $good['wait_out_stock']+=$good['presale_stock'];
+//                        }
+//                    }else{
                         $good['usable_stock']+=$info['wsm_num'];
-                    }
+          //          }
 
                     $good['total_stock']=$good['usable_stock']+$good['wait_out_stock'];
                     $good['updatetime'] = date("Y-m-d H:i:s");
@@ -979,18 +979,18 @@ class Purchin extends Base
                             $order = ["order_code"=>$good['spuCode'],"status"=>1,"action_remark"=>'', "action_type"=>"edit"];
                         }
                     $good['wait_in_stock']-=$return['wsm_num']+$return['return_num']-$return['reissue_num'];
-                        if($good['presale_stock']>0){
-                            if($good['presale_stock']>=$return['wsm_num']){
-                                $good['presale_stock']-=$return['wsm_num'];
-                                $good['wait_out_stock']+=$return['wsm_num'];
-                            }else{
-                                $good['presale_stock']=0;
-                                $good['usable_stock']+=$return['wsm_num']-$good['presale_stock'];
-                                $good['wait_out_stock']+=$good['presale_stock'];
-                            }
-                        }else{
+//                        if($good['presale_stock']>0){
+//                            if($good['presale_stock']>=$return['wsm_num']){
+//                                $good['presale_stock']-=$return['wsm_num'];
+//                                $good['wait_out_stock']+=$return['wsm_num'];
+//                            }else{
+//                                $good['presale_stock']=0;
+//                                $good['usable_stock']+=$return['wsm_num']-$good['presale_stock'];
+//                                $good['wait_out_stock']+=$good['presale_stock'];
+//                            }
+//                        }else{
                             $good['usable_stock']+=$return['wsm_num'];
-                        }
+//                        }
 //                        $good['usable_stock']+=$return['wsm_num'];
 //                        $good['wait_in_stock']-=$return['wsm_num']+$return['return_num']-$return['reissue_num'];
                         $good['total_stock']=$good['usable_stock']+$good['wait_out_stock'];

+ 10 - 10
app/admin/controller/Reorder.php

@@ -284,18 +284,18 @@ class Reorder extends Base
                             "updatetime" => date("Y-m-d H:i:s"),
                         ];
                     }
-                    if($stock['presale_stock']>0){
-                            if($stock['presale_stock']>=$thnum){
-                                $stock['presale_stock']-=$thnum;
-                            }else{
-                                $stock['presale_stock']=0;
-                                $stock['usable_stock']+=$thnum;
-                                $stock['wait_out_stock'] -= ($thnum -$stock['presale_stock']);
-                            }
-                    }else{
+//                    if($stock['presale_stock']>0){
+//                            if($stock['presale_stock']>=$thnum){
+//                                $stock['presale_stock']-=$thnum;
+//                            }else{
+//                                $stock['presale_stock']=0;
+//                                $stock['usable_stock']+=$thnum;
+//                                $stock['wait_out_stock'] -= ($thnum -$stock['presale_stock']);
+//                            }
+//                    }else{
                         $stock['usable_stock']+=$thnum;
                         $stock['wait_out_stock'] -= $thnum;
-                    }
+              //      }
                     $stock['updatetime'] = date("Y-m-d H:i:s");
                     $st_up = Db::name("good_stock")->save($stock);
                     if ($st_up == false) {

+ 1 - 0
app/admin/controller/Resign.php

@@ -900,6 +900,7 @@ class Resign extends Base
                                 "order_status" => $info['status'],"before_status"=> $old_info_status
                             ]);
 
+
                             Db::commit();
                             return app_show(0, "采购单新建成功", ["cgdNo" => $cgdCode]);
                         }

+ 14 - 16
app/admin/controller/Sale.php

@@ -91,15 +91,15 @@ class Sale extends Base
         if($goodinfo['is_stock']==1){
             $stock =Db::name("good_stock")->alias("a")->leftJoin("warehouse_info b","a.wsm_code=b.wsm_code")->where
             (["spuCode"=>$spuCode, "a.is_del"=>0,"a.status"=>1,"b.wsm_type"=>5,"b.companyNo"=>$supplierNo])->field("a.id,a.wait_in_stock,a.presale_stock,a.usable_stock,a.wait_out_stock")->find();
-            if($stock==false){
+            if($stock==false ||$stock['usable_stock']<$good_num){
                 return error_show(1003,"库存数量不足");
             }
-            if($stock['usable_stock']>0 && $stock['usable_stock']<$good_num){
-                return error_show(1003,"可用库存数量不足");
-            }
-            if($stock['usable_stock']== 0 && $stock['wait_in_stock']- $stock['presale_stock']<$good_num){
-                return error_show(1003,"待入库存数量不足");
-            }
+//            if($stock['usable_stock']>0 && $stock['usable_stock']<$good_num){
+//                return error_show(1003,"可用库存数量不足");
+//            }
+//            if($stock['usable_stock']== 0 && $stock['wait_in_stock']- $stock['presale_stock']<$good_num){
+//                return error_show(1003,"待入库存数量不足");
+//            }
             $origin_price = 0;
         }else{
             if($is_activity==0){
@@ -118,7 +118,7 @@ class Sale extends Base
                 $act = Db::name("activity_info")->alias("a")->leftJoin("good_activity b","a.activity_code=b.activity_code")
                     ->where(["a.skuCode"=>$skuCode,"a.activity_code"=>$actcode,"a.is_del"=>0,"a.status"=>1,"b.status"=>6,"b.is_del"=>0])
                     ->find();
-                if($act==false){
+                if($act==false ){
                     return error_show(1003,"未找到相关活动价");
                 }
                 if($act['moq_num']>$good_num){
@@ -287,17 +287,17 @@ class Sale extends Base
                     }
                     if(isset($stock)){
 
-                        if($stock['usable_stock']==0){
-                            $stck = ["presale_stock"=>$stock['presale_stock']+$good_num,
-                                    "updatetime"=>date("Y-m-d H:i:s")
-                                     ];
-                        }else{
+//                        if($stock['usable_stock']==0){
+//                            $stck = ["presale_stock"=>$stock['presale_stock']+$good_num,
+//                                    "updatetime"=>date("Y-m-d H:i:s")
+//                                     ];
+//                        }else{
                             $stck = [
                             "usable_stock"=>$stock['usable_stock']-$good_num,
                             "wait_out_stock"=>$stock['wait_out_stock']+$good_num,
                             "updatetime"=>date("Y-m-d H:i:s")
                         ];
-                        }
+//                        }
 
                         $upad=Db::name("good_stock")->where($stock)->update($stck);
                         if($upad==false){
@@ -2975,7 +2975,6 @@ class Sale extends Base
             }
                 Db::rollback();
                 return error_show(1003, "更新失败");
-
         }catch (\Exception $e){
             Db::rollback();
             return error_show(1003,$e->getMessage());
@@ -3539,7 +3538,6 @@ class Sale extends Base
             if($insetrCgd==false){
                 return false;
             }
-
             if($good['is_gold_price']==1 && $good['is_stock']==1){
                 $gold = Db::name("gold_price1")
                     ->field('id,price')

+ 6 - 4
app/command/ImportOrderFromCHandleData.php

@@ -137,7 +137,9 @@ class ImportOrderFromCHandleData extends Command
                             ->find();
                         if ($good == false) throw new Exception('未找到相关阶梯价格');
 
-                        $sale_price = $good['sale_price'];
+                        //$sale_price = $good['sale_price']; //不改动售价
+
+                        //理论上不会出现实时金价的订单
                         if ($ct['is_gold_price'] == 1 && $is_stock != 1) {
                             $gold = Db::name("gold_price1")
                                 ->field('id,price')
@@ -165,7 +167,7 @@ class ImportOrderFromCHandleData extends Command
                             if ($act == false) throw new Exception('未找到相关活动价');
                             if ($act['moq_num'] > $good_num) throw new Exception('商品不满足活动价起订量' . $act['moq_num']);
                             if ($act['activity_stock'] < $good_num) throw new Exception('商品活动库存剩余' . $act['activity_stock']);
-                            $sale_price = $act['activity_price'];
+                            //$sale_price = $act['activity_price'];//不能改动价格
                         }
                     }
                     $cgd = [
@@ -539,8 +541,8 @@ class ImportOrderFromCHandleData extends Command
                 if($stoc==false){
                     return false;
                 }
-                $good_data[] = ['good_log_code' =>$cgdCode, "stock_id" => isset($stoc['id'])?$stoc['id']:Db::name("good_stock")->getLastInsID(), "type" => 1,'stock'=>$data['good_num'], "stock_name" => "wait_in_stock"];
-                GoodLog::LogAdd($this->post['token'],$good_data,"CGD");
+                $good_data[] = ['good_log_code' => $cgdCode, "stock_id" => isset($stoc['id']) ? $stoc['id'] : Db::name("good_stock")->getLastInsID(), "type" => 1, 'stock' => $data['good_num'], "stock_name" => "wait_in_stock"];
+                GoodLog::LogAdd(['id' => 0, 'nickname' => 'system'], $good_data, "CGD");
 
                 return true;
             }