diff --git a/application/routine/model/store/StoreProduct.php b/application/routine/model/store/StoreProduct.php index e777590b..55a7f61f 100644 --- a/application/routine/model/store/StoreProduct.php +++ b/application/routine/model/store/StoreProduct.php @@ -25,7 +25,6 @@ class StoreProduct extends ModelBasic { return self::where('is_del',0)->where('is_show',1)->where('id',$productId)->field($field)->find(); } - public static function validWhere() { 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(); } - /** * 热卖产品 * @param string $field @@ -146,4 +144,16 @@ class StoreProduct extends ModelBasic 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(); + } + + } \ No newline at end of file diff --git a/application/routine/model/store/StoreSeckill.php b/application/routine/model/store/StoreSeckill.php index 22ced0d2..d77168a8 100644 --- a/application/routine/model/store/StoreSeckill.php +++ b/application/routine/model/store/StoreSeckill.php @@ -106,4 +106,17 @@ class StoreSeckill extends ModelBasic $res = false !== self::where('id',$seckillId)->dec('stock',$num)->inc('sales',$num)->update(); 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(); + } } \ No newline at end of file