mirror of
https://github.com/crmeb/CRMEB.git
synced 2025-12-21 01:52:50 +00:00
判断是否可以出售
This commit is contained in:
parent
1b449b83df
commit
cd3c319304
@ -25,7 +25,6 @@ class StoreProduct extends ModelBasic
|
|||||||
{
|
{
|
||||||
return self::where('is_del',0)->where('is_show',1)->where('id',$productId)->field($field)->find();
|
return self::where('is_del',0)->where('is_show',1)->where('id',$productId)->field($field)->find();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function validWhere()
|
public static function validWhere()
|
||||||
{
|
{
|
||||||
return self::where('is_del',0)->where('is_show',1)->where('mer_id',0);
|
return self::where('is_del',0)->where('is_show',1)->where('mer_id',0);
|
||||||
@ -46,7 +45,6 @@ class StoreProduct extends ModelBasic
|
|||||||
return $model->select();
|
return $model->select();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 热卖产品
|
* 热卖产品
|
||||||
* @param string $field
|
* @param string $field
|
||||||
@ -146,4 +144,16 @@ class StoreProduct extends ModelBasic
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO 判断是否可以出售
|
||||||
|
* @param $id
|
||||||
|
* @param int $cartNum
|
||||||
|
* @return int|string
|
||||||
|
* @throws \think\Exception
|
||||||
|
*/
|
||||||
|
public static function isValidCartProduct($id,$cartNum =1){
|
||||||
|
return self::where('is_del',0)->where('is_show',1)->where('id',$id)->where('stock','>',$cartNum)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -106,4 +106,17 @@ class StoreSeckill extends ModelBasic
|
|||||||
$res = false !== self::where('id',$seckillId)->dec('stock',$num)->inc('sales',$num)->update();
|
$res = false !== self::where('id',$seckillId)->dec('stock',$num)->inc('sales',$num)->update();
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO 判断是否可以出售
|
||||||
|
* @param $id
|
||||||
|
* @param int $cartNum
|
||||||
|
* @return int|string
|
||||||
|
* @throws \think\Exception
|
||||||
|
*/
|
||||||
|
public static function isValidCartSeckill($id,$cartNum = 1){
|
||||||
|
if(!$id) return false;
|
||||||
|
$time = time();
|
||||||
|
return self::where('id',$id)->where('is_del',0)->where('status',1)->where('stock','>',$cartNum)->where('start_time','<',$time)->where('stop_time','>',$time)->count();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user