From 4afe153948b739476624897f9bf080083eac85c6 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Mon, 24 Aug 2020 18:26:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E8=B4=AD=E4=B9=B0=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constants/SsdbKeysPrefix.php | 5 ++++ app/Service/PurchaseLimitService.php | 25 +++++++++++++++++++ app/Service/PurchaseLimitServiceInterface.php | 2 ++ 3 files changed, 32 insertions(+) diff --git a/app/Constants/SsdbKeysPrefix.php b/app/Constants/SsdbKeysPrefix.php index bf76f9d..b29fa48 100644 --- a/app/Constants/SsdbKeysPrefix.php +++ b/app/Constants/SsdbKeysPrefix.php @@ -46,4 +46,9 @@ class SsdbKeysPrefix extends AbstractConstants * @Message("Coupon rebate List") */ const COUPON_REBATE_LIST = 'coupon_rebate_list_'; + + /** + * @Message("Coupon rebate List") + */ + const PURCHASE_LIMIT = 'purchase_limit_'; } diff --git a/app/Service/PurchaseLimitService.php b/app/Service/PurchaseLimitService.php index 3010d27..093b418 100644 --- a/app/Service/PurchaseLimitService.php +++ b/app/Service/PurchaseLimitService.php @@ -7,11 +7,26 @@ use Hyperf\DbConnection\Db; use App\Model\Goods; use App\Model\Combination; use App\Model\ShopCar; +use App\Constants\LogLabel; +use App\Commons\Log; +use Hyperf\Utils\ApplicationContext; +use App\TaskWorker\SSDBTask; +use App\Constants\SsdbKeysPrefix; class PurchaseLimitService implements PurchaseLimitServiceInterface { public function addShopCar($params) { + //获取ssdb购买记录 + $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); + $record_exists = $ssdb->exec('hexists',SsdbKeysPrefix::PURCHASE_LIMIT. date('Ymd') .'_'.$params['user_id'], $params['good_id']); + if($record_exists) + { + $error = [ + 'error' => '特价商品每日只能购买一次' + ]; + return $error; + } //获取主表商品表信息 $goods = Goods::where([ ['id','=',$params['good_id']], @@ -182,6 +197,16 @@ class PurchaseLimitService implements PurchaseLimitServiceInterface return $res; } + public function ssdbPurchaseRecord($params) + { + $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); + //添加领取记录到ssdb + $data = [ + $order_id,$coupon->user_id, + ]; + $ssdb->exec('multi_hset', SsdbKeysPrefix::COUPON_REBATE_LIST.$coupon->send_user_id, $data); + } + public function test($params) { return $params; diff --git a/app/Service/PurchaseLimitServiceInterface.php b/app/Service/PurchaseLimitServiceInterface.php index 4cbcaf3..3b0d66d 100644 --- a/app/Service/PurchaseLimitServiceInterface.php +++ b/app/Service/PurchaseLimitServiceInterface.php @@ -12,5 +12,7 @@ interface PurchaseLimitServiceInterface public function getStoreIdByMarketId($params); + public function ssdbPurchaseRecord($params); + public function test($params); } \ No newline at end of file