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