|
|
|
@@ -2,15 +2,19 @@ package com.simple.service.impl; |
|
|
|
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.simple.common.ErrorCode; |
|
|
|
import com.simple.common.IdWorker; |
|
|
|
import com.simple.common.Result; |
|
|
|
import com.simple.common.ResultData; |
|
|
|
import com.simple.domain.po.MallUserInfo; |
|
|
|
import com.simple.domain.po.WxCouponOrder; |
|
|
|
import com.simple.enums.EnumCouponOrderStatus; |
|
|
|
import com.simple.mapper.WxCouponOrderMapper; |
|
|
|
import com.simple.service.WxCouponOrderService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
@@ -20,7 +24,6 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { |
|
|
|
@Autowired |
|
|
|
WxCouponOrderMapper wxCouponOrderMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxCouponOrder> listAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { |
|
|
|
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findList(record)); |
|
|
|
@@ -48,7 +51,10 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { |
|
|
|
wxCouponOrderMapper.deleteByPrimaryKey(id); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) |
|
|
|
public ResultData verify(Long id, MallUserInfo mallUserInfo) { |
|
|
|
WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(id); |
|
|
|
if (wxCouponOrder.getCouponOrderStatus() == 2) { |
|
|
|
@@ -69,5 +75,26 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) |
|
|
|
public ResultData refund(Long id, MallUserInfo mallUserInfo) { |
|
|
|
WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(id); |
|
|
|
|
|
|
|
if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode())) { |
|
|
|
return new ResultData(ErrorCode.COUPON_ORDER_IS_OVER_TIME); |
|
|
|
} |
|
|
|
if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode())) { |
|
|
|
return new ResultData(ErrorCode.COUPON_ORDER_IS_INVALID); |
|
|
|
} |
|
|
|
if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode())) { |
|
|
|
return new ResultData(ErrorCode.COUPON_ORDER_IS_USED); |
|
|
|
} |
|
|
|
|
|
|
|
wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()); //3退款,券作废 |
|
|
|
wxCouponOrder.setBUserId(mallUserInfo.getId()); |
|
|
|
wxCouponOrder.setUpdateDate(new Date()); |
|
|
|
wxCouponOrderMapper.updateByPrimaryKeySelective(wxCouponOrder); |
|
|
|
return new ResultData(wxCouponOrder); |
|
|
|
} |
|
|
|
|
|
|
|
} |