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

Commit 07e3e544 authored by 胡佳晨's avatar 胡佳晨

下单修改

parent 80cea881
......@@ -181,7 +181,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
advanceMap = orderUtils.useCoupon(payOrderParam.getAdvanceCode(), "购买 "+performanceData.getTitle(), BigDecimal.ZERO,payOrderParam.getPerformanceId(),payOrderParam.getTimeId(),payOrderParam.getTicketId());
Integer typeVoucher = (Integer) advanceMap.get("type");
if (typeVoucher.equals(-1)) {
return ResponseDto.failure("券不可用");
return ResponseDto.failure("优先券券不可用");
}
}
......@@ -191,38 +191,41 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
}
} else {
if (DateUtil.compareStrDay(DateUtil.getNowTime(), timeStart) == -1) {
orderUtils.backAdvanceCoupon(advanceMap,uid);
return ResponseDto.failure(ErrorMapping.get("20011"));//未开始
}
}
if (DateUtil.compareStrDay(DateUtil.getNowTime(), timeEnd) == 1) {
orderUtils.backAdvanceCoupon(advanceMap,uid);
return ResponseDto.failure(ErrorMapping.get("20012"));//已结束
}
//快递票判断
if (payOrderParam.getIsExpress() != null) {
if (payOrderParam.getIsExpress() == 1 && DateUtil.compareStrDay(DateUtil.getNowTime(), timeExpressEnd) == 1) {
orderUtils.backAdvanceCoupon(advanceMap,uid);
return ResponseDto.failure(ErrorMapping.get("20013"));//快递票不卖
}
if (payOrderParam.getIsExpress() == 1 && payOrderParam.getAddressId().isEmpty()) {
orderUtils.backAdvanceCoupon(advanceMap,uid);
return ResponseDto.failure(ErrorMapping.get("20014"));//快递票未填写收货地址
}
}
//实名判断
if (isTrueName == 1 && payOrderParam.getEnterIdList().size() <= 0) {
orderUtils.backAdvanceCoupon(advanceMap,uid);
return ResponseDto.failure(ErrorMapping.get("20015"));//需要实名 未实名
}
if (isTrueName == 1 && payOrderParam.getEnterIdList().size() != payOrderParam.getNumber()) {
orderUtils.backAdvanceCoupon(advanceMap,uid);
return ResponseDto.failure(ErrorMapping.get("20015"));//入场人数量错误
}
// 判断库存
int surplusGeneral = orderUtils.changeSurplus(isPay, payOrderParam.getTicketId(), -payOrderParam.getNumber());
log.debug("TAG_REDIS 正常 剩余库存 -> count:" + surplusGeneral);
if (surplusGeneral < 0) {//库存回滚
orderUtils.changeSurplus(isPay, payOrderParam.getTicketId(), payOrderParam.getNumber());
log.debug("TAG_REDIS 售罄 回滚库存1 -> count:" + payOrderParam.getNumber());
return ResponseDto.failure(ErrorMapping.get("20016"));//没抢到
} else {
isDownGeneral = true;
......@@ -237,7 +240,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
int age = IDCard.getAgeByIdCard(adamEnters.getIdCard());
if (age > 25) {
orderUtils.changeSurplus(isPay, payOrderParam.getTicketId(), payOrderParam.getNumber());
log.debug("TAG_REDIS 学生票 回滚库存2 -> count:" + payOrderParam.getNumber());
orderUtils.backAdvanceCoupon(advanceMap,uid);
return ResponseDto.failure(ErrorMapping.get("20017"));//年龄超了
}
}
......@@ -250,7 +253,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
String res1 = orderUtils.judgeOrderLimit(performanceData.getType(), uid, entersVoList.get(i).getIdCard(), payOrderParam.getPerformanceId(), payOrderParam.getTicketId(), performanceLimit, performanceMemberLimit, ticketLimit, ticketMemberLimit, 1, 1, memberType, isTrueName);
if (!res1.equals("")) {
orderUtils.changeSurplus(isPay, payOrderParam.getTicketId(), payOrderParam.getNumber());
log.debug("TAG_REDIS 限购 回滚库存3 -> count:" + payOrderParam.getNumber());
orderUtils.backAdvanceCoupon(advanceMap,uid);
return ResponseDto.failure(res1);//乱七八糟异常
}
}
......@@ -258,7 +261,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
String res1 = orderUtils.judgeOrderLimit(performanceData.getType(), uid, "", payOrderParam.getPerformanceId(), payOrderParam.getTicketId(), performanceLimit, performanceMemberLimit, ticketLimit, ticketMemberLimit, payOrderParam.getNumber(), payOrderParam.getNumber(), memberType, isTrueName);
if (!res1.equals("")) {
orderUtils.changeSurplus(isPay, payOrderParam.getTicketId(), payOrderParam.getNumber());
log.debug("TAG_REDIS 限购 回滚库存3 -> count:" + payOrderParam.getNumber());
orderUtils.backAdvanceCoupon(advanceMap,uid);
return ResponseDto.failure(res1);//乱七八糟异常
}
}
......@@ -271,7 +274,6 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
log.error("Kylin Order Pay Error = ", e);
if (isDownGeneral) {
orderUtils.changeSurplus(isPay, payOrderParam.getTicketId(), payOrderParam.getNumber());
log.debug("TAG_REDIS 异常 回滚库存4 -> count:" + payOrderParam.getNumber());
for (AdamEntersVo enters : entersVoList) {
dataUtils.changeBuyInfo(uid, enters.getIdCard(), payOrderParam.getPerformanceId(), payOrderParam.getTicketId(), -1);
}
......@@ -281,11 +283,6 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
}
}
}
if (advanceMap != null) {
orderUtils.backCoupon(advanceMap.get("uCouponId").toString(), uid);
}
if (e.getMessage().equals("券不可用")) {
return ResponseDto.failure(ErrorMapping.get("20030"));//券不可用
}
......
......@@ -180,7 +180,7 @@ public class OrderUtils {
* @param totalPrice 订单总价
* @return
*/
public HashMap<String, Object> useCoupon(String uCouponId, String content, BigDecimal totalPrice,String performanceId,String timesId,String ticketId) {
public HashMap<String, Object> useCoupon(String uCouponId, String content, BigDecimal totalPrice, String performanceId, String timesId, String ticketId) {
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
params.add("uCouponId", uCouponId);
params.add("content", content);
......@@ -227,6 +227,12 @@ public class OrderUtils {
return hashMap;
}
public void backAdvanceCoupon(HashMap<String, Object> advanceMap,String uid) {
if (advanceMap != null) {
backCoupon(advanceMap.get("uCouponId").toString(), uid);
}
}
public void backCoupon(String uCouponId, String uid) {
BackCouponParam param = BackCouponParam.getNew();
param.setuCouponIds(uCouponId);
......
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