Browse Source

返券合并

master
parent
commit
4e26801b4d
  1. 2
      app/Amqp/Consumer/couponRebateConsumer.php
  2. 10
      app/Constants/SsdbKeysPrefix.php
  3. 17
      app/Service/CouponRebateService.php

2
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
{

10
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';
}

17
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,

Loading…
Cancel
Save