记得上下班打卡 | git大法好,push需谨慎

Commit 94185669 authored by 张国柄's avatar 张国柄

领取券+同步coupon_code逻辑;

parent dbe0f00e
......@@ -386,6 +386,8 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
@Override
public ResponseDto<String> receiveCoupon(String ccode) {
String uid = CurrentUtil.getCurrentUid();
String mobile = (String) CurrentUtil.getTokenClaims().get(CurrentUtil.TOKEN_MOBILE);
CandyCouponCodeDto dto = redisDataUtils.getCouponByCode(ccode);
LocalDateTime now = LocalDateTime.now();
......@@ -404,11 +406,16 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
//添加baseDto -> baseDtoList
redisDataUtils.addCouponByUid(uid, baseDto);
//入库
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
LinkedList<Object[]> objsUserCoupon = CollectionUtil.linkedListObjectArr(),
objsCouponCode = CollectionUtil.linkedListObjectArr();
toMqSqls.add(SqlMapping.get("candy_coupon.receive"));
objsUserCoupon.add(new Object[]{uCouponId, uid, 1, infoDto.getCouponId(), ccode, now, now, infoDto.getExpireAt()});
toMqSqls.add(SqlMapping.get("candy_coupon_code.receive"));
objsCouponCode.add(new Object[]{uid, mobile, now, now, dto.getCouponId(), ccode});
queueUtils.sendMsgByRedis(
MQConst.CandyQueue.COUPON_RECEIVE.getKey(),
SqlMapping.get("candy_coupon.receive",
uCouponId, uid, 1, infoDto.getCouponId(), ccode, now, now, infoDto.getExpireAt()
)
SqlMapping.gets(toMqSqls, objsUserCoupon, objsCouponCode)
);
return ResponseDto.success(uCouponId);
}else if(dto.getState().equals(1)){
......
......@@ -6,3 +6,4 @@ candy_coupon.use_insert=INSERT INTO candy_user_coupon (ucoupon_id , uid , state
candy_coupon.back=UPDATE candy_user_coupon SET state = 1 WHERE uid = ? AND ucoupon_id = ?
# -- 领取券 --
candy_coupon.receive=INSERT INTO candy_user_coupon (ucoupon_id , uid , state , coupon_id , ccode , bind_at , bind_at, dued_at) VALUE ( ? , ? , ? , ? , ? , ? , ? , ?)
candy_coupon_code.receive=UPDATE candy_coupon_code SET redeem_uid=?,redeem_mobile=?,redeem_at=?,updated_at=? WHERE coupon_id=? AND ccode=?
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment