Explorar el Código

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

release_toaliyun_real
hupeng hace 7 años
padre
commit
26b5fd81d1
Se han modificado 2 ficheros con 50 adiciones y 4 borrados
  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 Ver fichero

@@ -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 Ver fichero

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

@Autowired
WxOrderMapper wxOrderMapper;

@Autowired
WxMerchantBUserMapper wxMerchantBUserMapper;

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



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

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()) {
logger.error("已过期: couponOrder-" + couponOrderId);
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME);
@@ -91,8 +118,25 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public ResultData refund(Long couponOrderId, Long bUserId) {

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())) {
logger.error("已过期: couponOrder-" + couponOrderId);
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME);


Cargando…
Cancelar
Guardar