'修复已知问题'

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

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

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

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

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

Loading…
Cancel
Save