Sfoglia il codice sorgente

[卡券][修改]:卡券核销,退款前先验证核销员合法性

release_toaliyun_real
hupeng 7 anni fa
parent
commit
26b5fd81d1
2 ha cambiato i file con 50 aggiunte e 4 eliminazioni
  1. +5
    -3
      mallinkService/src/main/java/com/simple/common/ErrorCode.java
  2. +45
    -1
      mallinkService/src/main/java/com/simple/service/impl/WxCouponOrderServiceImpl.java

+ 5
- 3
mallinkService/src/main/java/com/simple/common/ErrorCode.java Vedi File

@@ -83,9 +83,11 @@ public enum ErrorCode{
/** /**
* 卡券 * 卡券
*/ */
COUPON_ORDER_IS_USED(4000, "卡券已核销"),
COUPON_ORDER_IS_OVER_TIME(4001, "卡券已过期"),
COUPON_ORDER_IS_INVALID(4002, "卡券已经作废"),
COUPON_ORDER_IS_NULL(4000, "卡券不存在"),
COUPON_ORDER_IS_USED(4001, "卡券已核销"),
COUPON_ORDER_IS_OVER_TIME(4002, "卡券已过期"),
COUPON_ORDER_IS_INVALID(4003, "卡券已经作废"),



/** /**
* 微信 * 微信


+ 45
- 1
mallinkService/src/main/java/com/simple/service/impl/WxCouponOrderServiceImpl.java Vedi File

@@ -9,10 +9,13 @@ import com.simple.common.ResultData;
import com.simple.domain.po.MallUserInfo; import com.simple.domain.po.MallUserInfo;
import com.simple.domain.po.WxCouponOrder; import com.simple.domain.po.WxCouponOrder;
import com.simple.domain.po.WxMerchantBUser; import com.simple.domain.po.WxMerchantBUser;
import com.simple.domain.po.WxOrder;
import com.simple.enums.EnumCouponOrderStatus; import com.simple.enums.EnumCouponOrderStatus;
import com.simple.enums.EnumCouponStatus; import com.simple.enums.EnumCouponStatus;
import com.simple.exception.MallinkException; import com.simple.exception.MallinkException;
import com.simple.mapper.WxOrderMapper;
import com.simple.mapper.WxCouponOrderMapper; import com.simple.mapper.WxCouponOrderMapper;
import com.simple.mapper.WxMerchantBUserMapper;
import com.simple.service.WxCouponOrderService; import com.simple.service.WxCouponOrderService;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +32,12 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
@Autowired @Autowired
WxCouponOrderMapper wxCouponOrderMapper; WxCouponOrderMapper wxCouponOrderMapper;


@Autowired
WxOrderMapper wxOrderMapper;

@Autowired
WxMerchantBUserMapper wxMerchantBUserMapper;

@Override @Override
public PageInfo<WxCouponOrder> listAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { public PageInfo<WxCouponOrder> listAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findList(record)); return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findList(record));
@@ -57,11 +66,29 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
} }





@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public ResultData verify(Long couponOrderId, Long bUserId) { public ResultData verify(Long couponOrderId, Long bUserId) {

WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(couponOrderId); WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(couponOrderId);
if(wxCouponOrder == null){
logger.error("券ID不存在:"+ couponOrderId);
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}

WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(bUserId.longValue());
if(wxMerchantBUser == null){
logger.error("核销员ID不存在:"+ bUserId);
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}

WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(wxCouponOrder.getOrderId());

if (!wxOrder.getMerchantId().equals(wxMerchantBUser.getMerchantId())){
logger.error("券: couponMerchantId-" + wxOrder.getMerchantId()+"核销: couponMerchantId-"+wxMerchantBUser.getMerchantId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}

if (wxCouponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) { if (wxCouponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) {
logger.error("已过期: couponOrder-" + couponOrderId); logger.error("已过期: couponOrder-" + couponOrderId);
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME);
@@ -91,8 +118,25 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public ResultData refund(Long couponOrderId, Long bUserId) { public ResultData refund(Long couponOrderId, Long bUserId) {

WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(couponOrderId); WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(couponOrderId);
if(wxCouponOrder == null){
logger.error("券ID不存在:"+ couponOrderId);
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}


WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(bUserId.longValue());
if(wxMerchantBUser == null){
logger.error("操作员ID不存在:"+ bUserId);
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}

WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(wxCouponOrder.getOrderId());

if (!wxOrder.getMerchantId().equals(wxMerchantBUser.getMerchantId())){
logger.error("券: couponMerchantId-" + wxOrder.getMerchantId()+"核销: couponMerchantId-"+wxMerchantBUser.getMerchantId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}
if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode())) { if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode())) {
logger.error("已过期: couponOrder-" + couponOrderId); logger.error("已过期: couponOrder-" + couponOrderId);
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME);


Caricamento…
Annulla
Salva