| @@ -347,8 +347,8 @@ public class WxCouponOrderController extends BaseController { | |||||
| return new ResultData(ErrorCode.VERIFY_ERROR, e.getMessage()); | return new ResultData(ErrorCode.VERIFY_ERROR, e.getMessage()); | ||||
| } | } | ||||
| if (couponOrder != null) { | |||||
| wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, wxMerchantBUser.getMerchantId()); | |||||
| if (couponOrder != null && couponOrder.getMerchantId() != null) { | |||||
| wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, couponOrder.getMerchantId()); | |||||
| } | } | ||||
| return new ResultData(couponOrder); | return new ResultData(couponOrder); | ||||
| @@ -42,6 +42,7 @@ public class WxCouponOrderController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxCouponService wxCouponService; | private WxCouponService wxCouponService; | ||||
| @Autowired | @Autowired | ||||
| private WxCouponOrderService wxCouponOrderService; | private WxCouponOrderService wxCouponOrderService; | ||||
| @@ -484,7 +485,7 @@ public class WxCouponOrderController extends BaseController { | |||||
| return new ResultData(ErrorCode.VERIFY_ERROR, e.getMessage()); | return new ResultData(ErrorCode.VERIFY_ERROR, e.getMessage()); | ||||
| } | } | ||||
| if (couponOrder != null) { | |||||
| if (couponOrder != null && couponOrder.getMerchantId() != null) { | |||||
| wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, couponOrder.getMerchantId()); | wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, couponOrder.getMerchantId()); | ||||
| } | } | ||||
| @@ -2,11 +2,13 @@ package com.iformall.schedule; | |||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.dto.WxSharingOrderDto; | import com.iformall.domain.dto.WxSharingOrderDto; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.WxCouponOrderService; | |||||
| import com.iformall.service.WxOrderService; | import com.iformall.service.WxOrderService; | ||||
| import com.iformall.service.WxProfitSharingOrderService; | import com.iformall.service.WxProfitSharingOrderService; | ||||
| import com.iformall.service.WxRefundOrderService; | import com.iformall.service.WxRefundOrderService; | ||||
| @@ -31,6 +33,9 @@ public class CouponOrderExpiringSchedule { | |||||
| @Autowired | @Autowired | ||||
| private WxCouponOrderMapper wxCouponOrderMapper; | private WxCouponOrderMapper wxCouponOrderMapper; | ||||
| @Autowired | |||||
| private WxCouponOrderService wxCouponOrderService; | |||||
| @Autowired | @Autowired | ||||
| private WxRefundOrderService wxRefundOrderService; | private WxRefundOrderService wxRefundOrderService; | ||||
| @@ -108,6 +113,32 @@ public class CouponOrderExpiringSchedule { | |||||
| couponOrderExpireRefund(order, true); | couponOrderExpireRefund(order, true); | ||||
| } | } | ||||
| @Scheduled(cron = "0 0 5 * * ?") // 每天凌晨00:05 | |||||
| // @Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||||
| public void couponOrderGoodsVerifySchedule() {//14天确认收获 系统自动核销 | |||||
| List<WxMall> malls = getMalls(); | |||||
| for (WxMall mall: malls) { | |||||
| List<WxCouponOrder> list = wxCouponOrderMapper.findExpiredCouponOrderGoodsVerify(mall.getTenantId()); | |||||
| if (null != list && list.size() > 0 ) { | |||||
| list.stream().forEach(co -> { | |||||
| WxCouponOrder couponOrder = null; | |||||
| try { | |||||
| couponOrder = wxCouponOrderService.verify(co,null,EnumCouponVerifyType.VERIFY_C_AUTO); | |||||
| } catch (MallinkException e) { | |||||
| logger.error("核销异常: " + e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| logger.error("核销异常: " + e.getMessage()); | |||||
| } | |||||
| if (couponOrder != null && couponOrder.getMerchantId() != null) { | |||||
| wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrder.getId(), couponOrder.getMerchantId()); | |||||
| } | |||||
| }); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| @@ -142,7 +142,8 @@ public enum ErrorCode{ | |||||
| COUPON_VALID_NOT_SUPPORTED(2046, "券类型不支持"), | COUPON_VALID_NOT_SUPPORTED(2046, "券类型不支持"), | ||||
| COUPON_IS_EMPTY_GIFT(2120, "子券不存在"), | COUPON_IS_EMPTY_GIFT(2120, "子券不存在"), | ||||
| COUPON_VALID_DATE_ERR_GIFT(2135, "子券有效期在券包有效期之前"), | |||||
| COUPON_IS_TAKE_OFF_GIFT(2122, "子券存在作废券"), | |||||
| COUPON_VALID_DATE_ERR_GIFT(2135, "存在子券有效期在券包有效期之前"), | |||||
| /** | /** | ||||
| * 车流 2040 | * 车流 2040 | ||||
| */ | */ | ||||
| @@ -16,6 +16,7 @@ public enum EnumCouponVerifyType { | |||||
| VERIFY_POS_PAY(2, "POS交易核销"), | VERIFY_POS_PAY(2, "POS交易核销"), | ||||
| VERIFY_C(3,"用户自主核销"), | VERIFY_C(3,"用户自主核销"), | ||||
| VERIFY_C_AUTO(30,"用户自主核销"), | |||||
| VERIFY_AUTO(4,"系统自动核销"), | VERIFY_AUTO(4,"系统自动核销"), | ||||
| ; | ; | ||||
| @@ -25,6 +25,8 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||||
| List<WxCouponOrder> findExpiredCouponOrderByValidDate(@Param("tenantId")String tenantId); | List<WxCouponOrder> findExpiredCouponOrderByValidDate(@Param("tenantId")String tenantId); | ||||
| List<WxCouponOrder> findExpiredCouponOrderGoodsVerify(@Param("tenantId")String tenantId); | |||||
| // 券包核销 | // 券包核销 | ||||
| int updateVerifyCouponOrder(WxCouponOrder wxCouponOrder); | int updateVerifyCouponOrder(WxCouponOrder wxCouponOrder); | ||||
| int updateVerifyCouponOrderStatus(WxCouponOrder wxCouponOrder); | int updateVerifyCouponOrderStatus(WxCouponOrder wxCouponOrder); | ||||
| @@ -97,4 +99,5 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||||
| Integer findWriteOffCount(WxCouponOrder wxCouponOrder); | Integer findWriteOffCount(WxCouponOrder wxCouponOrder); | ||||
| List<WxCouponOrderBVo> findGoodsList(WxCouponOrderBVo record); | List<WxCouponOrderBVo> findGoodsList(WxCouponOrderBVo record); | ||||
| } | } | ||||
| @@ -57,6 +57,7 @@ import java.util.*; | |||||
| @Service | @Service | ||||
| public class WxCouponOrderServiceImpl implements WxCouponOrderService { | public class WxCouponOrderServiceImpl implements WxCouponOrderService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | @Autowired | ||||
| @@ -447,9 +448,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| logger.error("券包: coupon-" + wxCoupon.getId() + "数据异常" + "couponOrder-" + couponOrder.getId()); | logger.error("券包: coupon-" + wxCoupon.getId() + "数据异常" + "couponOrder-" + couponOrder.getId()); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_DATE_ERROR); | throw new MallinkException(ErrorCode.COUPON_ORDER_DATE_ERROR); | ||||
| } | } | ||||
| if(!EnumCouponVerifyType.VERIFY_AUTO.equals(couponVerifyType)){ | |||||
| throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT); | |||||
| } | |||||
| // if(!EnumCouponVerifyType.VERIFY_AUTO.equals(couponVerifyType)){ | |||||
| // throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT); | |||||
| // } | |||||
| }else{ | }else{ | ||||
| if(!EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType)){ | if(!EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType)){ | ||||
| throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT); | throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT); | ||||
| @@ -348,6 +348,9 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| List<WxCoupon> list = wxCouponMapper.findList(couponQ); | List<WxCoupon> list = wxCouponMapper.findList(couponQ); | ||||
| if(list != null && list.size() > 0){ | if(list != null && list.size() > 0){ | ||||
| for (WxCoupon wc:list) { | for (WxCoupon wc:list) { | ||||
| if(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wc.getStatus())){ | |||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF_GIFT); | |||||
| } | |||||
| if(wc.getValidEndDate().before(record.getValidEndDate())){ | if(wc.getValidEndDate().before(record.getValidEndDate())){ | ||||
| return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR_GIFT); | return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR_GIFT); | ||||
| } | } | ||||
| @@ -476,6 +479,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| //券礼包子券类型判断时间 | //券礼包子券类型判断时间 | ||||
| WxCoupon couponQ = new WxCoupon(); | WxCoupon couponQ = new WxCoupon(); | ||||
| couponQ.updateTenantInfo(record); | couponQ.updateTenantInfo(record); | ||||
| couponQ.setStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()); | |||||
| couponQ.setGiftList(Long.toString(record.getId())); | couponQ.setGiftList(Long.toString(record.getId())); | ||||
| List<WxCoupon> couponList = wxCouponMapper.findCouponList(couponQ); | List<WxCoupon> couponList = wxCouponMapper.findCouponList(couponQ); | ||||
| if(couponList != null && couponList.size() > 0){ | if(couponList != null && couponList.size() > 0){ | ||||
| @@ -759,7 +759,13 @@ | |||||
| select <include refid="allColumns" /> from wx_coupon_order | select <include refid="allColumns" /> from wx_coupon_order | ||||
| where tenant_id = #{tenantId} and expired_time >= date_sub(curdate(),interval 360 day) and expired_time < now() and coupon_price > 0 and coupon_order_status in (0, 4) | where tenant_id = #{tenantId} and expired_time >= date_sub(curdate(),interval 360 day) and expired_time < now() and coupon_price > 0 and coupon_order_status in (0, 4) | ||||
| </select> | </select> | ||||
| <select id="findExpiredCouponOrderGoodsVerify" parameterType="String" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_coupon_order | |||||
| where tenant_id = #{tenantId} and coupon_type = 11 | |||||
| and update_date < DATE_ADD(curdate(),interval 14 day) | |||||
| and shipping_type = 2 and shipping_status = 24 and coupon_order_status = 0 | |||||
| </select> | |||||
| <resultMap id="BVoResultMap" type="com.iformall.domain.vo.WxCouponOrderBVo"> | <resultMap id="BVoResultMap" type="com.iformall.domain.vo.WxCouponOrderBVo"> | ||||
| <id column="id" jdbcType="BIGINT" property="id" /> | <id column="id" jdbcType="BIGINT" property="id" /> | ||||