From cd3c319304f34c59853d41556e6c3724b3eae8a0 Mon Sep 17 00:00:00 2001 From: sugar1569 Date: Tue, 2 Apr 2019 18:14:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=87=BA=E5=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/routine/model/store/StoreProduct.php | 14 ++++++++++++-- application/routine/model/store/StoreSeckill.php | 13 +++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) 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