wugg před 2 roky
rodič
revize
3499986c35
2 změnil soubory, kde provedl 12 přidání a 11 odebrání
  1. 2 2
      app/admin/controller/Check.php
  2. 10 9
      app/admin/model/GoodStockInfo.php

+ 2 - 2
app/admin/controller/Check.php

@@ -561,7 +561,7 @@ public function edit()
         }
         $list = Db::name("good_basic")->alias("b")
             ->join("good_stock c","c.spuCode=b.spuCode","left")
-            ->join("good_stock_info d","c.id=d.stock_id and d.balance_num>0","left")
+            ->join("good_stock_info d","c.id=d.stockid and d.balance_num>0","left")
             ->where(['c.wsm_code'=>$fo['wsm_code'],"b.is_del"=>0,"c.is_del"=>0])->field("d.bnCode,b.spuCode'商品编码',
             b.good_name '商品名称',b.craft_desc '商品描述',b.brand_id '品牌',b.good_unit '单位',b.supplierNo '供应商编码','' as '供应商名称','' as  '一级分类','' as '二级分类','' as  '三级分类',
             b.addtime '新建时间',c.wsm_code '仓库编码','' as '仓库名称',c.usable_stock '可用总库存',d.balance_num 'bn库存数','' as '盘点库存'")
@@ -614,7 +614,7 @@ public function edit()
                 continue;
             }
             $stock = Db::name("good_stock")->alias("a")
-            ->join("good_stock_info b","a.id=b.stock_id","left")
+            ->join("good_stock_info b","a.id=b.stockid","left")
             ->where(["a.spuCode"=>$value["value1"],"wsm_code"=>$fo['wsm_code'],"bnCode"=>$value['value0'],"is_del"=>0])->find();
             $stock_num = isset($stock) ? $stock['balance_num']:0;
             $insert[]=[

+ 10 - 9
app/admin/model/GoodStockInfo.php

@@ -11,6 +11,7 @@ use think\Model;
  */
 class GoodStockInfo extends Model
 {
+
     /**
 	* @param int $stockid 仓库库存id
 	* @param string $bn bn编号
@@ -38,7 +39,7 @@ class GoodStockInfo extends Model
 			$data["updatetime"]=date("Y-m-d H:i:s");
 		}
 
-		return self::save($data);
+		return (new self())->save($data);
     }
 
 	/**
@@ -50,7 +51,7 @@ class GoodStockInfo extends Model
 	* @throws \think\db\exception\DbException
 	* @throws \think\db\exception\ModelNotFoundException
 	*/
-    public function SaleBn(int $stockid,int $num){
+	static function SaleBn(int $stockid,int $num){
 		$arr = self::where([["stockid","=",$stockid],["balance_num",">",0]])->select()->toArray();
 		if(empty($arr)) throw new Exception("库存批次数量不足","1006");
 		$list=[];
@@ -70,7 +71,7 @@ class GoodStockInfo extends Model
 		    	$item['updatetime'] =date("Y-m-d H:i:s");
 		    	$temp=["bnCode"=>$item['bnCode'],"num"=>$num,"origin_price"=>$item["origin_price"]];
 		    }
-		    self::save($item);
+			(new self())->save($item);
 		    $list[]=$temp;
 		}
 		return $list;
@@ -82,13 +83,13 @@ class GoodStockInfo extends Model
 	* @return bool  盘点修改bn仓库库存数
 	* @throws \think\Exception
 	*/
-    public function CheckBn(int $stockid,string $bn,int $num){
+	static function CheckBn(int $stockid,string $bn,int $num){
 		$data=self::where(["stockid"=>$stockid,"bnCode"=>$bn])->findOrEmpty()->toArray();
 		if(empty($data)) throw new Exception("未找到Bn库存数据",1006);
 			$data["balance_num"]=$num;
 			$data["total_num"]=$data["used_num"]+$num;
 			$data["updatetime"]=date("Y-m-d H:i:s");
-		return self::save($data);
+		return (new self())->save($data);
     }
 	/**
 	* @param string $orderCode
@@ -100,7 +101,7 @@ class GoodStockInfo extends Model
 	* @throws \think\db\exception\DbException
 	* @throws \think\db\exception\ModelNotFoundException
 	 */
-    public function OrderBn(string $orderCode,int $stockid,int $num){
+	static function OrderBn(string $orderCode,int $stockid,int $num){
         $bnArr=self::SaleBn($stockid,$num);
         if(empty($bnArr)) throw new Exception("未找到Bn库存数据",1006);
         $ordBn=[];
@@ -127,7 +128,7 @@ class GoodStockInfo extends Model
 	 * @return bool
 	* @throws \think\Exception
 	 */
-    public function ReturnBn(string $returnCode,int $salebnid,int $num,int $type=1){
+	static function ReturnBn(string $returnCode,int $salebnid,int $num,int $type=1){
     	$sabn=self::name("sale_info")->where(['id'=>$salebnid])->findOrEmpty()->toArray();
     	if(empty($sabn))throw new Exception("未找到Bn订单数据",1006);
     	$return=[
@@ -150,7 +151,7 @@ class GoodStockInfo extends Model
 	 * @return bool
 	* @throws \think\Exception
  */
-    public function bnStock(int $stockid,string $bnCode,int $num,int $flag=0,float $origin_price=0){
+	static function bnStock(int $stockid,string $bnCode,int $num,int $flag=0,float $origin_price=0){
 			$stock =self::where(["stockid"=>$stockid,"bnCode"=>$bnCode])->lock(true)->findOrEmpty()->toArray();
 			if($flag==1) {
 				if(empty($stock)|| $stock['balance_num']< $num)
@@ -178,6 +179,6 @@ class GoodStockInfo extends Model
 						$stock['updatetime']=date("Y-m-d H:i:s");
 				}
 			}
-			return	self::save($stock);
+			return	(new self())->save($stock);
 	}
 }