ソースを参照

fix order

release_toaliyun_real
xiaohanzi 4年前
コミット
9a8c9729ad
1個のファイルの変更23行の追加19行の削除
  1. +23
    -19
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java

+ 23
- 19
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java ファイルの表示

@@ -2268,12 +2268,12 @@ public class WxOrderServiceImpl implements WxOrderService {
// 检查券商户信息 // 检查券商户信息
if (!isCouponMerchantValid(coupon.getId(),coupon.getTenantId())) { if (!isCouponMerchantValid(coupon.getId(),coupon.getTenantId())) {
logger.error("商户不存在, couponId: " + coupon.getId()); logger.error("商户不存在, couponId: " + coupon.getId());
throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),premsg+"【"+coupon.getTitle()+"】商户信息没找到");
throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),premsg+"商户信息没找到");
} }
// 检查 优惠券 库存 // 检查 优惠券 库存
if (coupon.getRemainInventory() <= 0) { if (coupon.getRemainInventory() <= 0) {
logger.error("此券库存为0, couponId: " + coupon.getId()); logger.error("此券库存为0, couponId: " + coupon.getId());
throw new MallinkException(ErrorCode.REMAIN_IS_EMPTY.getCode(),premsg+"【"+coupon.getTitle()+"】库存不足");
throw new MallinkException(ErrorCode.REMAIN_IS_EMPTY.getCode(),premsg+"库存不足");
} }
} }


@@ -2385,17 +2385,17 @@ public class WxOrderServiceImpl implements WxOrderService {
WxOrderGroup group = wxOrderGroupMapper.selectById(orderGroupId,coupon.getTenantId()); WxOrderGroup group = wxOrderGroupMapper.selectById(orderGroupId,coupon.getTenantId());
if (group.getStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING_COMPLETE.getCode())) { if (group.getStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING_COMPLETE.getCode())) {
logger.error("下订单拼团人数已满>>>" + orderGroupId); logger.error("下订单拼团人数已满>>>" + orderGroupId);
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FINISHED.getCode(),premsg+"【"+coupon.getTitle()+"】拼团人数已满");
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FINISHED.getCode(),premsg+"拼团人数已满");
} }
if (group.getRemainPeople()<=0) { if (group.getRemainPeople()<=0) {
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FINISHED.getCode(),premsg+"【"+coupon.getTitle()+"】下单人数已满");
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FINISHED.getCode(),premsg+"下单人数已满");
} }
//判断拼团人数是否已经超出限制 //判断拼团人数是否已经超出限制
int groupCount = countGroupOrder(orderGroupId,true,group.getTenantId()); int groupCount = countGroupOrder(orderGroupId,true,group.getTenantId());
if (groupCount>=coupon.getPressLimitNum()) { if (groupCount>=coupon.getPressLimitNum()) {
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FINISHED.getCode(),premsg+"【"+coupon.getTitle()+"】下单人数超出优惠券人数限制!");
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FINISHED.getCode(),premsg+"下单人数超出优惠券人数限制!");
} }
WxOrder order = new WxOrder(); WxOrder order = new WxOrder();
@@ -2405,7 +2405,7 @@ public class WxOrderServiceImpl implements WxOrderService {
long count = wxOrderMapper.selectCount(new QueryWrapper(order)); long count = wxOrderMapper.selectCount(new QueryWrapper(order));
if (count > 0) { if (count > 0) {
logger.error("重复的拼团>>>" + orderGroupId); logger.error("重复的拼团>>>" + orderGroupId);
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_UNPAID.getCode(),premsg+"【"+coupon.getTitle()+"】您有未支付的拼团订单");
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_UNPAID.getCode(),premsg+"您有未支付的拼团订单");
} }
} }


@@ -2492,7 +2492,7 @@ public class WxOrderServiceImpl implements WxOrderService {
logger.info("OrderSave: " + orderSaveDto); logger.info("OrderSave: " + orderSaveDto);
String premsg = ""; String premsg = "";
if (singleProduct) { if (singleProduct) {
premsg = "券";
premsg = "券";
}else { }else {
premsg = "第["+curindex+"]张券"; premsg = "第["+curindex+"]张券";
} }
@@ -2504,21 +2504,25 @@ public class WxOrderServiceImpl implements WxOrderService {
logger.error("couponChannelId find error, " + orderSaveDto.getCouponChannelId()); logger.error("couponChannelId find error, " + orderSaveDto.getCouponChannelId());
throw new MallinkException(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF.getCode(),premsg+"投放渠道不存在"); throw new MallinkException(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF.getCode(),premsg+"投放渠道不存在");
} }
if (!singleProduct) {
premsg = premsg+"【"+wxCouponChannel.getTitle()+"】";
}
couponChannelCheck(orderSaveDto, wxCouponChannel,premsg); couponChannelCheck(orderSaveDto, wxCouponChannel,premsg);


WxCoupon coupon = wxCouponService.getById(wxCouponChannel.getCouponId(),wxCouponChannel.getTenantId()); WxCoupon coupon = wxCouponService.getById(wxCouponChannel.getCouponId(),wxCouponChannel.getTenantId());
if (null == coupon) { if (null == coupon) {
throw new MallinkException(ErrorCode.COUPON_IS_EMPTY.getCode(),premsg+"不存在"); throw new MallinkException(ErrorCode.COUPON_IS_EMPTY.getCode(),premsg+"不存在");
} }

if (coupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { if (coupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) {
throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),premsg+"【"+coupon.getTitle()+"】已作废");
throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),premsg+"已作废");
} }
//判断是否是拼团订单,如果是拼团订单,判断现在进行中的,和已完成的数量是否超出券的限制 //判断是否是拼团订单,如果是拼团订单,判断现在进行中的,和已完成的数量是否超出券的限制
if (coupon.getType().equals(EnumCouponType.COUPON_GROUP.getCode())) { if (coupon.getType().equals(EnumCouponType.COUPON_GROUP.getCode())) {
int ordercount = this.countUserCouponGroupOrder(wxCUserBasicInfo,coupon.getId(),coupon.getTenantId()); int ordercount = this.countUserCouponGroupOrder(wxCUserBasicInfo,coupon.getId(),coupon.getTenantId());
if ((ordercount+productCount)>=coupon.getUseLimitQuantity()) { if ((ordercount+productCount)>=coupon.getUseLimitQuantity()) {
throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),premsg+"拼团券["+coupon.getTitle()+"]您的有效拼团数量达到券的限购次数。");
throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),premsg+"您的有效拼团数量达到券的限购次数。");
} }
} }


@@ -2540,7 +2544,7 @@ public class WxOrderServiceImpl implements WxOrderService {
} }
} }
if (wxCouponCVo == null) { if (wxCouponCVo == null) {
throw new MallinkException(ErrorCode.COUPON_IS_EMPTY.getCode(),premsg+"【"+coupon.getTitle()+"】未查询到详细信息.");
throw new MallinkException(ErrorCode.COUPON_IS_EMPTY.getCode(),premsg+"未查询到详细信息.");
} }


//此处判断是否存在绝对保证库存不超卖的缓存,如果没有,则把当前的库存设置为最大值。如果有,则是后台设置的时候保存的,以那个为准。 //此处判断是否存在绝对保证库存不超卖的缓存,如果没有,则把当前的库存设置为最大值。如果有,则是后台设置的时候保存的,以那个为准。
@@ -2577,7 +2581,7 @@ public class WxOrderServiceImpl implements WxOrderService {
if (coupon.checkIsCreditCoupon()) { if (coupon.checkIsCreditCoupon()) {
//若用户剩余积分比积分售价低则不能支付 //若用户剩余积分比积分售价低则不能支付
if (wxCUserBasicInfo.getCredit() == null || wxCUserBasicInfo.getCredit() < coupon.getCreditPrice()) { if (wxCUserBasicInfo.getCredit() == null || wxCUserBasicInfo.getCredit() < coupon.getCreditPrice()) {
throw new MallinkException(ErrorCode.CREDIT_NOT_ENOUGH.getCode(), premsg+"【"+coupon.getTitle()+"】积分不够扣减值");
throw new MallinkException(ErrorCode.CREDIT_NOT_ENOUGH.getCode(), premsg+"积分不够扣减值");
} }
} }
@@ -2595,17 +2599,17 @@ public class WxOrderServiceImpl implements WxOrderService {
Date now = new Date(); Date now = new Date();
if (wxCouponChannel.getBeginTime().getTime() > now.getTime()) { if (wxCouponChannel.getBeginTime().getTime() > now.getTime()) {
logger.error("此券活动未开始:" + orderSaveDto.getCouponChannelId()); logger.error("此券活动未开始:" + orderSaveDto.getCouponChannelId());
throw new MallinkException(ErrorCode.COUPON_CHANNEL_IS_NOT_STARTED.getCode(),premsg+"【"+wxCouponChannel.getTitle()+"】活动未开始");
throw new MallinkException(ErrorCode.COUPON_CHANNEL_IS_NOT_STARTED.getCode(),premsg+"活动未开始");
} }
if (wxCouponChannel.getEndTime().getTime() < now.getTime()) { if (wxCouponChannel.getEndTime().getTime() < now.getTime()) {
logger.error("此券活动已结束:" + orderSaveDto.getCouponChannelId()); logger.error("此券活动已结束:" + orderSaveDto.getCouponChannelId());
throw new MallinkException(ErrorCode.COUPON_CHANNEL_IS_END.getCode(),premsg+"【"+wxCouponChannel.getTitle()+"】活动已结束");
throw new MallinkException(ErrorCode.COUPON_CHANNEL_IS_END.getCode(),premsg+"活动已结束");
} }
} }


if (wxCouponChannel.getStatus() == EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) { if (wxCouponChannel.getStatus() == EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) {
logger.error("此券已下架:" + orderSaveDto.getCouponChannelId()); logger.error("此券已下架:" + orderSaveDto.getCouponChannelId());
throw new MallinkException(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF.getCode(),premsg+"【"+wxCouponChannel.getTitle()+"】已下架");
throw new MallinkException(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF.getCode(),premsg+"已下架");
} }
} }


@@ -2621,21 +2625,21 @@ public class WxOrderServiceImpl implements WxOrderService {
if (jo.getIntValue("type") == EnumCouponConditionType.NEW_MEMBER.getCode()){ if (jo.getIntValue("type") == EnumCouponConditionType.NEW_MEMBER.getCode()){


if (user != null && user.getActRecord() > 0) if (user != null && user.getActRecord() > 0)
throw new MallinkException(ErrorCode.COUPON_ONLY_FOR_NEW_MEMBER.getCode(),premsg+"【"+coupon.getTitle()+"】限新会员,您已经参加过新会员活动");
throw new MallinkException(ErrorCode.COUPON_ONLY_FOR_NEW_MEMBER.getCode(),premsg+"限新会员,您已经参加过新会员活动");
if (this.countCouponConditionType1(coupon.getTenantId(),user.getId()) > 0) if (this.countCouponConditionType1(coupon.getTenantId(),user.getId()) > 0)
throw new MallinkException(ErrorCode.COUPON_ALREADY_IN_NEW_MEMBER.getCode(),premsg+"【"+coupon.getTitle()+"】限新会员,您已经不是新用户");
throw new MallinkException(ErrorCode.COUPON_ALREADY_IN_NEW_MEMBER.getCode(),premsg+"限新会员,您已经不是新用户");
}else if (jo.getIntValue("type") == EnumCouponConditionType.SCORE_SCOPE.getCode()){ }else if (jo.getIntValue("type") == EnumCouponConditionType.SCORE_SCOPE.getCode()){
int max = jo.getIntValue("max"); int max = jo.getIntValue("max");
int min = jo.getIntValue("min"); int min = jo.getIntValue("min");


if (max!=0 && min ==0 && user.getPoins() > max) { if (max!=0 && min ==0 && user.getPoins() > max) {
throw new MallinkException(ErrorCode.COUPON_SCORE_NOT_IN_RANGE.getCode(),premsg+"【"+coupon.getTitle()+"】您的成长值/等级与要求不符");
throw new MallinkException(ErrorCode.COUPON_SCORE_NOT_IN_RANGE.getCode(),premsg+"您的成长值/等级与要求不符");
} }
if (max==0 && min !=0 && user.getPoins() < min) { if (max==0 && min !=0 && user.getPoins() < min) {
throw new MallinkException(ErrorCode.COUPON_SCORE_NOT_IN_RANGE.getCode(),premsg+"【"+coupon.getTitle()+"】您的成长值/等级与要求不符");
throw new MallinkException(ErrorCode.COUPON_SCORE_NOT_IN_RANGE.getCode(),premsg+"您的成长值/等级与要求不符");
} }
if (max!=0 && min !=0 && (user.getPoins() < min || user.getPoins() > max)) { if (max!=0 && min !=0 && (user.getPoins() < min || user.getPoins() > max)) {
throw new MallinkException(ErrorCode.COUPON_SCORE_NOT_IN_RANGE.getCode(),premsg+"【"+coupon.getTitle()+"】您的成长值/等级与要求不符");
throw new MallinkException(ErrorCode.COUPON_SCORE_NOT_IN_RANGE.getCode(),premsg+"您的成长值/等级与要求不符");
} }
} }
} }


読み込み中…
キャンセル
保存