'修复已知问题'

dev-discount
199901012 4 years ago
parent 8c9f6762d8
commit e36a5763a0
  1. 37
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountCouponRelController.java
  2. 2
      hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java
  3. 2
      hai-service/src/main/java/com/hai/common/exception/ErrorCode.java
  4. 2
      hai-service/src/main/java/com/hai/service/HighDiscountCouponRelService.java
  5. 9
      hai-service/src/main/java/com/hai/service/impl/HighDiscountCouponRelServiceImpl.java

@ -5,19 +5,24 @@ import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighDiscountCouponRel; import com.hai.entity.HighDiscountCouponRel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.service.HighAgentService; import com.hai.service.HighAgentService;
import com.hai.service.HighCouponService;
import com.hai.service.HighDiscountCouponRelService; import com.hai.service.HighDiscountCouponRelService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @Auther: 胡锐 * @Auther: 胡锐
@ -34,6 +39,9 @@ public class HighDiscountCouponRelController {
@Resource @Resource
private HighDiscountCouponRelService highDiscountCouponRelService; private HighDiscountCouponRelService highDiscountCouponRelService;
@Resource
private HighCouponService highCouponService;
@RequestMapping(value="/insertDiscountCoupon",method = RequestMethod.POST) @RequestMapping(value="/insertDiscountCoupon",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "增加优惠券和卡券关系") @ApiOperation(value = "增加优惠券和卡券关系")
@ -41,25 +49,36 @@ public class HighDiscountCouponRelController {
try { try {
JSONObject jsonObject = JSONObject.parseObject(reqBody); JSONObject jsonObject = JSONObject.parseObject(reqBody);
Long discountId = jsonObject.getLong("discountId"); Long discountId = jsonObject.getLong("discountId");
Long couponId = jsonObject.getLong("couponId"); String couponIdStr = jsonObject.getString("couponId");
if (discountId == null || couponId == null) { if (discountId == null || StringUtils.isBlank(couponIdStr)) {
log.error("HighDiscountCouponRelController -> insertDiscountCoupon() error!","参数错误"); log.error("HighDiscountCouponRelController -> insertDiscountCoupon() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
} }
String[] couponId = couponIdStr.split(",");
List<HighDiscountCouponRel> list = new ArrayList<>();
HighDiscountCouponRel rel;
for (String id : couponId) {
// 查询卡券消息
HighCoupon coupon = highCouponService.getCouponById(Long.parseLong(id));
if (coupon == null) {
log.error("HighDiscountCouponRelController -> insertDiscountCoupon() error!","未找到卡券信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}
// 是否存在 // 是否存在
if (highDiscountCouponRelService.getRelByDiscountCoupon(discountId,couponId) != null) { if (highDiscountCouponRelService.getRelByDiscountCoupon(discountId,Long.parseLong(id)) != null) {
log.error("HighDiscountCouponRelController -> insertDiscountCoupon() error!","重复增加"); log.error("HighDiscountCouponRelController -> insertDiscountCoupon() error!","重复增加" + coupon.getCouponName());
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "重复增加"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "重复增加" + coupon.getCouponName());
} }
rel =new HighDiscountCouponRel();
HighDiscountCouponRel rel = new HighDiscountCouponRel();
rel.setDiscountId(discountId); rel.setDiscountId(discountId);
rel.setCouponId(couponId); rel.setCouponId(Long.parseLong(id));
rel.setStatus(1); rel.setStatus(1);
rel.setCreateTime(new Date()); rel.setCreateTime(new Date());
highDiscountCouponRelService.insertDiscountCoupon(rel); list.add(rel);
}
highDiscountCouponRelService.insertDiscountCouponList(list);
return ResponseMsgUtil.success("操作成功"); return ResponseMsgUtil.success("操作成功");

@ -31,6 +31,8 @@ public class HighCouponSchedule {
for (HighUserCoupon highUserCoupon : userCoupons) { for (HighUserCoupon highUserCoupon : userCoupons) {
highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用 highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponService.updateUserCoupon(highUserCoupon); highUserCouponService.updateUserCoupon(highUserCoupon);
} }
} }
} }

@ -80,7 +80,7 @@ public enum ErrorCode {
PHONE_NUM_EXISTED("2108","电话号码已被使用"), PHONE_NUM_EXISTED("2108","电话号码已被使用"),
MERCHANT_STATUS_ERROR("2109","商户状态不正常,请联系管理员"), MERCHANT_STATUS_ERROR("2109","商户状态不正常,请联系管理员"),
SELECT_HANDSEL_COUPON_ERROR("2110","请选择赠送卡卷名单"), SELECT_HANDSEL_COUPON_ERROR("2110","请选择赠送卡卷名单"),
NOT_FOUND_COUPON("2111","未找到卡信息"), NOT_FOUND_COUPON("2111","未找到卡信息"),
WRITE_COUPON_NUMBER_ERROR("2112","请填写卡卷数量"), WRITE_COUPON_NUMBER_ERROR("2112","请填写卡卷数量"),
COUPON_UNABLE_UP_SHELF("2113","卡卷状态错误"), COUPON_UNABLE_UP_SHELF("2113","卡卷状态错误"),
NOT_FOUND_APPROVE("2114","未找到审批记录"), NOT_FOUND_APPROVE("2114","未找到审批记录"),

@ -17,7 +17,7 @@ public interface HighDiscountCouponRelService {
* @Description 增加 * @Description 增加
* @Date 2021/4/3 23:12 * @Date 2021/4/3 23:12
**/ **/
void insertDiscountCoupon(HighDiscountCouponRel highDiscountCouponRel); void insertDiscountCouponList(List<HighDiscountCouponRel> highDiscountCouponRelList);
/** /**
* @Author 胡锐 * @Author 胡锐

@ -12,6 +12,8 @@ import com.hai.service.HighCouponService;
import com.hai.service.HighDiscountCouponRelService; import com.hai.service.HighDiscountCouponRelService;
import com.hai.service.HighDiscountService; import com.hai.service.HighDiscountService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
@ -31,8 +33,11 @@ public class HighDiscountCouponRelServiceImpl implements HighDiscountCouponRelSe
private HighCouponService highCouponService; private HighCouponService highCouponService;
@Override @Override
public void insertDiscountCoupon(HighDiscountCouponRel highDiscountCouponRel) { @Transactional(propagation= Propagation.REQUIRES_NEW)
highDiscountCouponRelMapper.insert(highDiscountCouponRel); public void insertDiscountCouponList(List<HighDiscountCouponRel> highDiscountCouponRelList) {
for (HighDiscountCouponRel rel : highDiscountCouponRelList) {
highDiscountCouponRelMapper.insert(rel);
}
} }
@Override @Override

Loading…
Cancel
Save