|
|
|
@ -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; |
|
|
|
|