diff --git a/app/Service/CouponRebateService.php b/app/Service/CouponRebateService.php index a3bff6e..c31cf19 100644 --- a/app/Service/CouponRebateService.php +++ b/app/Service/CouponRebateService.php @@ -36,7 +36,7 @@ class CouponRebateService implements CouponRebateServiceInterface $sendUserId = $params["send_user_id"]; $phone = $params["phone"]; $now = time(); - $idsData = is_array($ids) ? $ids : explode(',',$ids); + $idsData = is_array($ids) ? $ids : explode(',',$ids); // status: 0领取成功 >0领取失败 $result = [ @@ -57,8 +57,8 @@ class CouponRebateService implements CouponRebateServiceInterface $receiveSsdb = []; // 判断是否已全部领取 - $couponActivity = $ssdb->exec('get', SsdbKeysPrefix::COUPON_REBATE_ACTIVITY); - $userReceiveCouponIds = $ssdb->exec('hgetall', SsdbKeysPrefix::COUPON_REBATE_FORWARD . $couponActivity); + $couponActivity = $ssdb->exec('hget', SsdbKeysPrefix::COUPON_REBATE_ACTIVITY,0); + $userReceiveCouponIds = $ssdb->exec('hgetall', SsdbKeysPrefix::COUPON_REBATE_RECEIVE . $couponActivity . $userId); if($userReceiveCouponIds !== false){ $ids = array_diff($idsData, $userReceiveCouponIds); }else{ @@ -187,7 +187,7 @@ class CouponRebateService implements CouponRebateServiceInterface $saveSsdb[] = $vssdb; } // 记录到ssdb - if(false === $ssdb->exec('multi_hset',SsdbKeysPrefix::COUPON_REBATE_RECEIVE.$userId,$saveSsdb)){ + if(false === $ssdb->exec('multi_hset',SsdbKeysPrefix::COUPON_REBATE_RECEIVE . $couponActivity . $userId, $saveSsdb)){ $errorData['msg'] = '记录领取优惠券到ssdb失败'; $this->log->event( LogLabel::COUPON_LOG, @@ -254,12 +254,12 @@ class CouponRebateService implements CouponRebateServiceInterface $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); // $rrss1 = $ssdb->exec('hgetall', SsdbKeysPrefix::COUPON_REBATE_FORWARD . $couponActivity); - // $rrss2 = $ssdb->exec('get', SsdbKeysPrefix::COUPON_REBATE_REPAY . $couponActivity); - // $rrss3 = $ssdb->exec('get', SsdbKeysPrefix::COUPON_REBATE_ACTIVITY); - // return [$rrss3]; + // $rrss2 = $ssdb->exec('hget', SsdbKeysPrefix::COUPON_REBATE_REPAY . $couponActivity,0); + // $rrss3 = $ssdb->exec('hget', SsdbKeysPrefix::COUPON_REBATE_ACTIVITY,0); + // return [$rrss1,$rrss2,$rrss3]; // 记录活动本次 activity_type 活动标志值 - if (false === $ssdb->exec('set', SsdbKeysPrefix::COUPON_REBATE_ACTIVITY, $couponActivity)) { + if (false === $ssdb->exec('hset', SsdbKeysPrefix::COUPON_REBATE_ACTIVITY, [0,$couponActivity])) { $this->log->event( LogLabel::COUPON_LOG, @@ -292,7 +292,7 @@ class CouponRebateService implements CouponRebateServiceInterface }; // 记录返还类型优惠券 - if (false === $ssdb->exec('set', SsdbKeysPrefix::COUPON_REBATE_REPAY . $couponActivity, $couponRepay)) { + if (false === $ssdb->exec('hset', SsdbKeysPrefix::COUPON_REBATE_REPAY . $couponActivity, [0,$couponRepay])) { $this->log->event( LogLabel::COUPON_LOG, diff --git a/app/Service/CouponService.php b/app/Service/CouponService.php index 67f9e56..c0ff451 100644 --- a/app/Service/CouponService.php +++ b/app/Service/CouponService.php @@ -27,13 +27,16 @@ class CouponService implements CouponServiceInterface */ public function getSystemCouponUserList($userId,$receiveType) { - $activityType = 2;/* 优惠券活动标志 2 */ + /* 优惠券活动标志 2 */ + $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); + $couponActivity = $ssdb->exec('hget', SsdbKeysPrefix::COUPON_REBATE_ACTIVITY,0); + $result = [ 'active_type' => 1, 'not_receive' => [], 'jump_data' => [ - 'src' => "/zh_cjdianc/pages/couponrebate/index?activity_type=".$activityType, - 'src2' => "/zh_cjdianc/pages/couponrebate/index?activity_type=".$activityType, + 'src' => "/zh_cjdianc/pages/couponrebate/index?activity_type=".$couponActivity, + 'src2' => "/zh_cjdianc/pages/couponrebate/index?activity_type=".$couponActivity, 'coupons' => [] ] ]; @@ -65,8 +68,7 @@ class CouponService implements CouponServiceInterface $couponIds = array_diff($c_ids, $cr_ids); // 获取领取型优惠券 - $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); - $couponRebateIds = $ssdb->exec('hgetall',SsdbKeysPrefix::COUPON_REBATE_FORWARD.$activityType); + $couponRebateIds = $ssdb->exec('hgetall',SsdbKeysPrefix::COUPON_REBATE_FORWARD.$couponActivity); $couponIds = ($couponRebateIds === false || empty($couponRebateIds)) ? $couponIds : array_merge($couponIds,$couponRebateIds) ;