|
@@ -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);
|
|
|
}
|
|
|
}
|