From 4e26801b4d9ef7302022eb3642f94851c3affaef Mon Sep 17 00:00:00 2001 From: "DESKTOP-GG6FIN9\\Administrator" <15040771@qq.com> Date: Tue, 11 Aug 2020 15:34:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=94=E5=88=B8=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Amqp/Consumer/couponRebateConsumer.php | 2 +- app/Constants/SsdbKeysPrefix.php | 10 ++++++++++ app/Service/CouponRebateService.php | 17 ++++++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/Amqp/Consumer/couponRebateConsumer.php b/app/Amqp/Consumer/couponRebateConsumer.php index f9a3808..c3eb85a 100644 --- a/app/Amqp/Consumer/couponRebateConsumer.php +++ b/app/Amqp/Consumer/couponRebateConsumer.php @@ -16,7 +16,7 @@ use Hyperf\Di\Annotation\Inject; /** - * @Consumer(exchange="deviceCouponRebate", routingKey="deviceCouponRebate", queue="deviceCouponRebate", name ="couponRebateConsumer", nums=1) + * @Consumer(exchange="deviceCouponRebate1", routingKey="deviceCouponRebate1", queue="deviceCouponRebate1", name ="couponRebateConsumer", nums=1) */ class couponRebateConsumer extends ConsumerMessage { diff --git a/app/Constants/SsdbKeysPrefix.php b/app/Constants/SsdbKeysPrefix.php index 1e721c2..0eaad4b 100644 --- a/app/Constants/SsdbKeysPrefix.php +++ b/app/Constants/SsdbKeysPrefix.php @@ -36,4 +36,14 @@ class SsdbKeysPrefix extends AbstractConstants * @Message("Coupon rebate Key Prefix") */ const COUPON_REBATE_ACTIVITY = 'coupon_rebate_activity'; + + /** + * @Message("Store New User") + */ + const STORE_NEW_USER = 'store_new_user_'; + + /** + * @Message("Coupon rebate List") + */ + const COUPON_REBATE_LIST = 'coupon_rebate_list'; } diff --git a/app/Service/CouponRebateService.php b/app/Service/CouponRebateService.php index a3384ff..245ab7c 100644 --- a/app/Service/CouponRebateService.php +++ b/app/Service/CouponRebateService.php @@ -274,8 +274,11 @@ class CouponRebateService implements CouponRebateServiceInterface ->whereIn('r.system_coupon_user_id',$coupon_ids) ->select('r.user_id', 'r.send_user_id') ->first(); - /* 如果使用的优惠券为转发活动优惠券 则给赠送者返一张优惠券*/ - if ($coupon) { + /* 如果使用的优惠券为转发活动优惠券 + **则给赠送者返一张优惠券 + * **自己给自己转发的券不给返券 + */ + if ($coupon && ($coupon->user_id != $coupon->send_user_id)) { //是否已返过券 $exists_coupon_rebate = Db::table('ims_system_coupon_user_receive') ->where([ @@ -341,6 +344,14 @@ class CouponRebateService implements CouponRebateServiceInterface ->where('id', $active['repay']) ->increment('inventory_use'); + //添加领取记录到ssdb + $data = [ + 'msg', '领券', + 'order_id',$order_id, + 'user_id' , $coupon->user_id, + 'send_usr_id' , $coupon->send_user_id + ]; + $ssdb->execWithoutTask('multi_hset', SsdbKeysPrefix::COUPON_REBATE_LIST, $data); // 提交 Db::commit(); } catch (\Exception $e) { @@ -348,7 +359,7 @@ class CouponRebateService implements CouponRebateServiceInterface Db::rollBack(); $log_Data = array(); $log_Data['name'] = '返券'; - $log_Data['order_main_id'] = $order_id; + $log_Data['order_id'] = $order_id; $log_Data['msg'] = '返券失败'; $this->log->event( LogLabel::COUPON_LOG,