合并pre重庆中石油业务

dev-discount
胡锐 2 years ago
commit 12361207d4
  1. 34
      hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java
  2. 25
      hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherMapper.java
  3. 14
      hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherSqlProvider.java
  4. 18
      hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java
  5. 60
      hai-service/src/main/java/com/hai/entity/HighCouponCodeOtherExample.java
  6. 7
      hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java
  7. 7
      hai-service/src/main/java/com/hai/service/HighDiscountUserRelService.java
  8. 25
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeOtherServiceImpl.java
  9. 111
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java
  10. 11
      hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java

@ -1,16 +1,21 @@
package com.cweb.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.Base64Util;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.AESEncodeUtil;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighDiscountAgentCode;
import com.hai.entity.HighDiscountAgentRel;
import com.hai.config.ChongQingCNPCService;
import com.hai.entity.*;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.HighDiscountAgentCodeService;
import com.hai.service.HighDiscountAgentRelService;
import com.hai.service.HighDiscountCouponRelService;
@ -20,13 +25,17 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DeadlockLoserDataAccessException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.net.URLDecoder;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Auther: 胡锐
@ -158,4 +167,25 @@ public class HighDiscountController {
}
}
@RequestMapping(value="/useDiscount",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "使用优惠券")
public ResponseData useDiscount(@RequestParam(name = "discountAgentCodeId", required = true) Long discountAgentCodeId) {
try {
highDiscountAgentCodeService.useDiscount(discountAgentCodeId);
return ResponseMsgUtil.success("操作成功");
} catch (DeadlockLoserDataAccessException deadlockLoserDataAccessException) {
log.error("HighActivityController -> userLottery() error!", "服务器繁忙");
return ResponseMsgUtil.builderResponse(ErrorCode.SERVER_BUSY_ERROR.getCode(),ErrorCode.SERVER_BUSY_ERROR.getMsg(),null);
} catch (Exception e) {
log.error("HighDiscountController -> useDiscount() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -39,18 +39,18 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt
int deleteByPrimaryKey(Long id);
@Insert({
"insert into high_coupon_code_other (`type`, coupon_agent_code_id, ",
"order_id, child_order_id, ",
"cou_type_code, cou_no, ",
"`status`, active_time, ",
"insert into high_coupon_code_other (`type`, discount_agent_code_id, ",
"coupon_agent_code_id, order_id, ",
"child_order_id, cou_type_code, ",
"cou_no, `status`, active_time, ",
"valid_start_date, valid_end_date, ",
"use_time, station_code, ",
"station_name, create_time, ",
"ext_1, ext_2, ext_3)",
"values (#{type,jdbcType=INTEGER}, #{couponAgentCodeId,jdbcType=BIGINT}, ",
"#{orderId,jdbcType=BIGINT}, #{childOrderId,jdbcType=BIGINT}, ",
"#{couTypeCode,jdbcType=VARCHAR}, #{couNo,jdbcType=VARCHAR}, ",
"#{status,jdbcType=INTEGER}, #{activeTime,jdbcType=TIMESTAMP}, ",
"values (#{type,jdbcType=INTEGER}, #{discountAgentCodeId,jdbcType=BIGINT}, ",
"#{couponAgentCodeId,jdbcType=BIGINT}, #{orderId,jdbcType=BIGINT}, ",
"#{childOrderId,jdbcType=BIGINT}, #{couTypeCode,jdbcType=VARCHAR}, ",
"#{couNo,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{activeTime,jdbcType=TIMESTAMP}, ",
"#{validStartDate,jdbcType=TIMESTAMP}, #{validEndDate,jdbcType=TIMESTAMP}, ",
"#{useTime,jdbcType=TIMESTAMP}, #{stationCode,jdbcType=VARCHAR}, ",
"#{stationName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
@ -67,6 +67,7 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="discount_agent_code_id", property="discountAgentCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_agent_code_id", property="couponAgentCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT),
@Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.BIGINT),
@ -88,15 +89,16 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt
@Select({
"select",
"id, `type`, coupon_agent_code_id, order_id, child_order_id, cou_type_code, cou_no, ",
"`status`, active_time, valid_start_date, valid_end_date, use_time, station_code, ",
"station_name, create_time, ext_1, ext_2, ext_3",
"id, `type`, discount_agent_code_id, coupon_agent_code_id, order_id, child_order_id, ",
"cou_type_code, cou_no, `status`, active_time, valid_start_date, valid_end_date, ",
"use_time, station_code, station_name, create_time, ext_1, ext_2, ext_3",
"from high_coupon_code_other",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="discount_agent_code_id", property="discountAgentCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_agent_code_id", property="couponAgentCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT),
@Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.BIGINT),
@ -128,6 +130,7 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt
@Update({
"update high_coupon_code_other",
"set `type` = #{type,jdbcType=INTEGER},",
"discount_agent_code_id = #{discountAgentCodeId,jdbcType=BIGINT},",
"coupon_agent_code_id = #{couponAgentCodeId,jdbcType=BIGINT},",
"order_id = #{orderId,jdbcType=BIGINT},",
"child_order_id = #{childOrderId,jdbcType=BIGINT},",

@ -32,6 +32,10 @@ public class HighCouponCodeOtherSqlProvider {
sql.VALUES("`type`", "#{type,jdbcType=INTEGER}");
}
if (record.getDiscountAgentCodeId() != null) {
sql.VALUES("discount_agent_code_id", "#{discountAgentCodeId,jdbcType=BIGINT}");
}
if (record.getCouponAgentCodeId() != null) {
sql.VALUES("coupon_agent_code_id", "#{couponAgentCodeId,jdbcType=BIGINT}");
}
@ -107,6 +111,7 @@ public class HighCouponCodeOtherSqlProvider {
sql.SELECT("id");
}
sql.SELECT("`type`");
sql.SELECT("discount_agent_code_id");
sql.SELECT("coupon_agent_code_id");
sql.SELECT("order_id");
sql.SELECT("child_order_id");
@ -148,6 +153,10 @@ public class HighCouponCodeOtherSqlProvider {
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
}
if (record.getDiscountAgentCodeId() != null) {
sql.SET("discount_agent_code_id = #{record.discountAgentCodeId,jdbcType=BIGINT}");
}
if (record.getCouponAgentCodeId() != null) {
sql.SET("coupon_agent_code_id = #{record.couponAgentCodeId,jdbcType=BIGINT}");
}
@ -222,6 +231,7 @@ public class HighCouponCodeOtherSqlProvider {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
sql.SET("discount_agent_code_id = #{record.discountAgentCodeId,jdbcType=BIGINT}");
sql.SET("coupon_agent_code_id = #{record.couponAgentCodeId,jdbcType=BIGINT}");
sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}");
sql.SET("child_order_id = #{record.childOrderId,jdbcType=BIGINT}");
@ -252,6 +262,10 @@ public class HighCouponCodeOtherSqlProvider {
sql.SET("`type` = #{type,jdbcType=INTEGER}");
}
if (record.getDiscountAgentCodeId() != null) {
sql.SET("discount_agent_code_id = #{discountAgentCodeId,jdbcType=BIGINT}");
}
if (record.getCouponAgentCodeId() != null) {
sql.SET("coupon_agent_code_id = #{couponAgentCodeId,jdbcType=BIGINT}");
}

@ -19,10 +19,15 @@ public class HighCouponCodeOther implements Serializable {
private Long id;
/**
* 类型 1 贵州中石化 2 重庆中石油
* 类型 1 贵州中石化 2 重庆中石油 3 优惠券
*/
private Integer type;
/**
* 代理商优惠券code
*/
private Long discountAgentCodeId;
/**
* 代理商卡券销售码id
*/
@ -112,6 +117,14 @@ public class HighCouponCodeOther implements Serializable {
this.type = type;
}
public Long getDiscountAgentCodeId() {
return discountAgentCodeId;
}
public void setDiscountAgentCodeId(Long discountAgentCodeId) {
this.discountAgentCodeId = discountAgentCodeId;
}
public Long getCouponAgentCodeId() {
return couponAgentCodeId;
}
@ -254,6 +267,7 @@ public class HighCouponCodeOther implements Serializable {
HighCouponCodeOther other = (HighCouponCodeOther) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getDiscountAgentCodeId() == null ? other.getDiscountAgentCodeId() == null : this.getDiscountAgentCodeId().equals(other.getDiscountAgentCodeId()))
&& (this.getCouponAgentCodeId() == null ? other.getCouponAgentCodeId() == null : this.getCouponAgentCodeId().equals(other.getCouponAgentCodeId()))
&& (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
&& (this.getChildOrderId() == null ? other.getChildOrderId() == null : this.getChildOrderId().equals(other.getChildOrderId()))
@ -278,6 +292,7 @@ public class HighCouponCodeOther implements Serializable {
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getDiscountAgentCodeId() == null) ? 0 : getDiscountAgentCodeId().hashCode());
result = prime * result + ((getCouponAgentCodeId() == null) ? 0 : getCouponAgentCodeId().hashCode());
result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
result = prime * result + ((getChildOrderId() == null) ? 0 : getChildOrderId().hashCode());
@ -305,6 +320,7 @@ public class HighCouponCodeOther implements Serializable {
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", type=").append(type);
sb.append(", discountAgentCodeId=").append(discountAgentCodeId);
sb.append(", couponAgentCodeId=").append(couponAgentCodeId);
sb.append(", orderId=").append(orderId);
sb.append(", childOrderId=").append(childOrderId);

@ -245,6 +245,66 @@ public class HighCouponCodeOtherExample {
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdIsNull() {
addCriterion("discount_agent_code_id is null");
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdIsNotNull() {
addCriterion("discount_agent_code_id is not null");
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdEqualTo(Long value) {
addCriterion("discount_agent_code_id =", value, "discountAgentCodeId");
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdNotEqualTo(Long value) {
addCriterion("discount_agent_code_id <>", value, "discountAgentCodeId");
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdGreaterThan(Long value) {
addCriterion("discount_agent_code_id >", value, "discountAgentCodeId");
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdGreaterThanOrEqualTo(Long value) {
addCriterion("discount_agent_code_id >=", value, "discountAgentCodeId");
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdLessThan(Long value) {
addCriterion("discount_agent_code_id <", value, "discountAgentCodeId");
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdLessThanOrEqualTo(Long value) {
addCriterion("discount_agent_code_id <=", value, "discountAgentCodeId");
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdIn(List<Long> values) {
addCriterion("discount_agent_code_id in", values, "discountAgentCodeId");
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdNotIn(List<Long> values) {
addCriterion("discount_agent_code_id not in", values, "discountAgentCodeId");
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdBetween(Long value1, Long value2) {
addCriterion("discount_agent_code_id between", value1, value2, "discountAgentCodeId");
return (Criteria) this;
}
public Criteria andDiscountAgentCodeIdNotBetween(Long value1, Long value2) {
addCriterion("discount_agent_code_id not between", value1, value2, "discountAgentCodeId");
return (Criteria) this;
}
public Criteria andCouponAgentCodeIdIsNull() {
addCriterion("coupon_agent_code_id is null");
return (Criteria) this;

@ -94,4 +94,11 @@ public interface HighDiscountAgentCodeService {
Integer getSalesDiscount(Long discountAgentId);
List<HighDiscountAgentCode> getDiscountAgentCodByLimit(Long discountAgentId , Long num);
/**
* 优惠券前往使用
* @param discountAgentCodeId
* @throws Exception
*/
void useDiscount(Long discountAgentCodeId) throws Exception;
}

@ -48,6 +48,13 @@ public interface HighDiscountUserRelService {
**/
HighDiscountUserRel getRelByDiscount(Long discountId);
/**
* 根据代理商优惠券code查询
* @param agentCodeId
* @return
*/
HighDiscountUserRel getRelByAgentCodeId(Long agentCodeId);
/**
* @Author 胡锐
* @Description 根据id查询

@ -7,6 +7,8 @@ import com.hai.dao.HighCouponCodeOtherMapper;
import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.*;
import com.hai.service.HighCouponCodeOtherService;
import com.hai.service.HighDiscountAgentCodeService;
import com.hai.service.HighDiscountUserRelService;
import com.hai.service.HighOrderService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
@ -31,6 +33,12 @@ public class HighCouponCodeOtherServiceImpl implements HighCouponCodeOtherServic
@Resource
private HighOrderService highOrderService;
@Resource
private HighDiscountAgentCodeService discountAgentCodeService;
@Resource
private HighDiscountUserRelService discountUserRelService;
@Override
public void update(HighCouponCodeOther couponCodeOther) {
highCouponCodeOtherMapper.updateByPrimaryKey(couponCodeOther);
@ -107,11 +115,26 @@ public class HighCouponCodeOtherServiceImpl implements HighCouponCodeOtherServic
if (couponCodeOther.getCouponAgentCodeId() != null) {
HighCouponAgentCode agentCode = highCouponAgentCodeMapper.selectByPrimaryKey(couponCodeOther.getCouponAgentCodeId());
if (agentCode == null) {
if (agentCode != null) {
agentCode.setStatus(3);
highCouponAgentCodeMapper.updateByPrimaryKey(agentCode);
}
}
if (couponCodeOther.getDiscountAgentCodeId() != null) {
HighDiscountAgentCode discountAgentCode = discountAgentCodeService.getCodeById(couponCodeOther.getDiscountAgentCodeId());
if (discountAgentCode != null) {
discountAgentCode.setStatus(3);
discountAgentCodeService.updateCode(discountAgentCode);
HighDiscountUserRel discountUserRel = discountUserRelService.getRelByAgentCodeId(couponCodeOther.getDiscountAgentCodeId());
if (discountUserRel != null) {
discountUserRel.setStatus(2);
discountUserRel.setUseTime(couponCodeOther.getUseTime());
discountUserRelService.updateDiscountUserRel(discountUserRel);
}
}
}
}
}
}

@ -1,12 +1,24 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil;
import com.hai.config.ChongQingCNPCService;
import com.hai.dao.HighCouponCodeMapper;
import com.hai.dao.HighCouponCodeOtherMapper;
import com.hai.dao.HighDiscountAgentCodeMapper;
import com.hai.entity.*;
import com.hai.model.HighUserModel;
import com.hai.service.*;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@ -14,6 +26,7 @@ import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Auther: 胡锐
@ -47,6 +60,18 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
@Resource
private HighDiscountUserRelService highDiscountUserRelService;
@Resource
private HighCouponCodeOtherMapper highCouponCodeOtherMapper;
@Resource
private HighDiscountCouponRelService highDiscountCouponRelService;
@Resource
private UserCenter userCenter;
@Resource
private RedisTemplate redisTemplate;
@Override
public void insertCodeList(List<HighDiscountAgentCode> discountAgentCodeList) {
highDiscountAgentCodeMapper.insertListCode(discountAgentCodeList);
@ -158,4 +183,90 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
public List<HighDiscountAgentCode> getDiscountAgentCodByLimit(Long discountAgentId, Long num) {
return highDiscountAgentCodeMapper.getDiscountAgentCodByLimit(discountAgentId,num);
}
@Override
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW, timeout = 30)
public void useDiscount(Long discountAgentCodeId) throws Exception {
HighUserModel userModel = userCenter.getSessionModel(HighUserModel.class);
if (userModel == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, "");
}
if (StringUtils.isBlank(userModel.getHighUser().getPhone())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "客户未设置手机号");
}
// 查询优惠券code
HighDiscountAgentCode discountAgentCode = getCodeById(discountAgentCodeId);
if (discountAgentCode == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券code错误");
}
if (!discountAgentCode.getStatus().equals(2)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误");
}
HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelByAgentCodeId(discountAgentCodeId);
if (discountUserRel != null) {
if (!userModel.getHighUser().getId().equals(discountUserRel.getUserId())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用,领取人和使用人不一致。");
}
}
String key = "DiscountAgentId_" + discountAgentCode.getDiscountAgentId();
try {
// 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, discountAgentCode.getId());
if(lock) {
if (StringUtils.isBlank(discountAgentCode.getExt2())) {
HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(discountAgentCode.getDiscountAgentId());
if (rel == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到代理商关联关系");
}
HighDiscount discount = highDiscountService.getDiscountById(rel.getDiscountId());
if (discount == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到优惠券");
}
List<HighDiscountCouponRel> couponRelList = highDiscountCouponRelService.getRelByDiscount(discount.getId());
if (couponRelList.size() == 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置卡券");
}
List<HighDiscountCouponRel> couponList = couponRelList.stream().filter(o -> o.getHighCoupon().getCouponSource().equals(5)).collect(Collectors.toList());
if (couponList.size() == 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置重庆中石油卡券");
}
String tradeId = discountAgentCode.getId()+""+System.currentTimeMillis()+"";
// 给用户发码
JSONObject response = ChongQingCNPCService.sendCNPCTicket(
couponList.get(0).getHighCoupon().getCouponKey(),
tradeId,
1,
userModel.getHighUser().getPhone());
JSONObject couponDetail = response.getJSONObject("ticketDetail");
JSONArray codeList = response.getJSONArray("codeList");
for (Object data : codeList) {
HighCouponCodeOther couponCodeOther = new HighCouponCodeOther();
couponCodeOther.setType(3);
couponCodeOther.setDiscountAgentCodeId(discountAgentCode.getId());
couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode"));
couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data)));
couponCodeOther.setActiveTime(new Date());
couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd"));
couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd"));
couponCodeOther.setStatus(20);
couponCodeOther.setCreateTime(new Date());
highCouponCodeOtherMapper.insert(couponCodeOther);
}
discountAgentCode.setExt2(tradeId);
updateCode(discountAgentCode);
}
} else {
// 加锁失败,重试
Thread.sleep(100);
useDiscount(discountAgentCodeId);
}
} catch (Exception e) {
} finally {
// 删除key,释放锁
redisTemplate.delete(key);
}
}
}

@ -199,6 +199,17 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic
return null;
}
@Override
public HighDiscountUserRel getRelByAgentCodeId(Long agentCodeId) {
HighDiscountUserRelExample example = new HighDiscountUserRelExample();
example.createCriteria().andDiscountAgentCodeIdEqualTo(agentCodeId);
List<HighDiscountUserRel> list = highDiscountUserRelMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override
public HighDiscountUserRel getRelById(Long id) {
HighDiscountUserRel rel = highDiscountUserRelMapper.selectByPrimaryKey(id);

Loading…
Cancel
Save