| @@ -71,7 +71,7 @@ public class WxCouponOrderController extends BaseController { | |||
| if(couponOrderId == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return wxCouponOrderService.detailAdminVo(couponOrderId); | |||
| return wxCouponOrderService.detailAdminVo(couponOrderId,getTenantInfo()); | |||
| } | |||
| @ApiOperation(value = "退券退款", notes = "{\"couponOrderId\":\"string\"}") | |||
| @@ -95,7 +95,7 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(couponOrderId); | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(couponOrderId,getTenantInfo().getTenantId()); | |||
| if (wxCouponOrder == null) { | |||
| logger.error("券ID不存在:" + couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| @@ -139,7 +139,7 @@ public class WxCouponOrderController extends BaseController { | |||
| } | |||
| WxCouponOrderCVo wxCouponOrderCVo = null; | |||
| try { | |||
| wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId); | |||
| wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId,wxMerchant); | |||
| } catch (Exception e) { | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| @@ -194,7 +194,7 @@ public class WxCouponOrderController extends BaseController { | |||
| } | |||
| WxCouponOrderCVo wxCouponOrderCVo = null; | |||
| try { | |||
| wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId); | |||
| wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId,getTenantInfo()); | |||
| } catch (Exception e) { | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| @@ -246,7 +246,7 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderService.detailCUserVo(couponOrderIdStr); | |||
| WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderService.detailCUserVo(couponOrderIdStr,getTenantInfo()); | |||
| if (wxCouponOrderCVo == null) | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| @@ -273,7 +273,7 @@ public class WxCouponOrderController extends BaseController { | |||
| } | |||
| } | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(couponOrderId); | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(couponOrderId,getTenantInfo().getTenantId()); | |||
| if (wxCouponOrder == null) { | |||
| logger.error("券ID不存在:" + couponOrderId); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| @@ -320,7 +320,7 @@ public class WxCouponOrderController extends BaseController { | |||
| logger.error("couponOrderId参数不正确: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCouponOrderService.getById(couponOrderId)); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCouponOrderService.getById(couponOrderId,getTenantInfo().getTenantId())); | |||
| } | |||
| @ApiOperation(value = "核销接口", notes = "{\"couponOrderId\":\"string\"}") | |||
| @@ -439,7 +439,7 @@ public class WxMicroPayController extends BaseController { | |||
| logger.error("couponOrderId参数不正确: " + couponOrderIdStr); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxCouponOrder = wxCouponOrderService.getById(couponOrderId); | |||
| wxCouponOrder = wxCouponOrderService.getById(couponOrderId,microOrder.getTenantId()); | |||
| } | |||
| WxPayOrder couponPayOrder = null; | |||
| @@ -142,7 +142,7 @@ public class WxCardPayController extends BaseController { | |||
| } | |||
| //查看所有者与扫码者是否为一致 | |||
| WxCouponOrder couponOrder = wxCouponOrderService.getById(cardId); | |||
| WxCouponOrder couponOrder = wxCouponOrderService.getById(cardId,cardInfo.getTenantId()); | |||
| if (!couponOrder.getOwnerId().equals(cUserId)) { | |||
| logger.error("卡已被领取: " + cardIdStr); | |||
| return new ResultData(ErrorCode.CARD_TRANSFERED); | |||
| @@ -115,7 +115,7 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId); | |||
| WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId,getTenantInfo()); | |||
| if (wxCouponOrderCVo == null) { | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| @@ -188,7 +188,7 @@ public class WxCouponOrderController extends BaseController { | |||
| } | |||
| WxCouponOrderCVo wxCouponOrderCVo = null; | |||
| try { | |||
| wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId); | |||
| wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId,getTenantInfo()); | |||
| } catch (Exception e) { | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| @@ -237,7 +237,7 @@ public class WxCouponOrderController extends BaseController { | |||
| Map res = new HashMap(); | |||
| res.put("CouponOrderStatus", wxCouponOrderService.getById(Long.valueOf(couponOrderId)).getCouponOrderStatus()); | |||
| res.put("CouponOrderStatus", wxCouponOrderService.getById(Long.valueOf(couponOrderId),getTenantInfo().getTenantId()).getCouponOrderStatus()); | |||
| return new ResultData(res); | |||
| } | |||
| @@ -333,7 +333,7 @@ public class WxCouponOrderController extends BaseController { | |||
| logger.info("转赠人与卡所有者相同"); | |||
| return new ResultData(ErrorCode.CARD_TRANSFER_INVALID.getCode(), "转赠人与卡所有者相同"); | |||
| } | |||
| wxCouponOrder.updateTenantInfo(getTenantInfo()); | |||
| return wxCouponOrderService.cardAccept(wxCouponOrder); | |||
| } | |||
| @@ -367,6 +367,7 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| wxCouponOrder.setOwnerId(memberId); | |||
| wxCouponOrder.updateTenantInfo(getTenantInfo()); | |||
| return wxCouponOrderService.queryCardStatus(wxCouponOrder); | |||
| } | |||
| @@ -253,7 +253,7 @@ public class PosServiceImpl implements PosService { | |||
| String couponOrderIdStr = couponOrderArr.getString(0); | |||
| if (couponOrderIdStr != null) { | |||
| try { | |||
| JSONObject couponPromoMap = calcOneCouponVerify(promotionCalc, couponOrderIdStr, merchantId); | |||
| JSONObject couponPromoMap = calcOneCouponVerify(promotionCalc,tenantEntity, couponOrderIdStr, merchantId); | |||
| couponList.add(couponPromoMap); | |||
| } catch (MallinkException e) { | |||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | |||
| @@ -405,11 +405,11 @@ public class PosServiceImpl implements PosService { | |||
| * @param couponOrderIdStr | |||
| * @return | |||
| */ | |||
| private JSONObject calcOneCouponVerify(PromotionCalc promotionCalc, String couponOrderIdStr, Long merchantId) { | |||
| private JSONObject calcOneCouponVerify(PromotionCalc promotionCalc,TenantEntity tenantinfo, String couponOrderIdStr, Long merchantId) { | |||
| JSONObject retObj = new JSONObject(); | |||
| Date now = new Date(); | |||
| // 1. 获取券包信息 | |||
| WxCouponOrderCVo couponOrderCVo = checkAndGetCouponOrder(couponOrderIdStr, merchantId, now); | |||
| WxCouponOrderCVo couponOrderCVo = checkAndGetCouponOrder(couponOrderIdStr,tenantinfo, merchantId, now); | |||
| // 2. 检查券类型 核销可用(4, 6, 8, 9) | |||
| EnumCouponType couponType = EnumCouponType.getEnum(couponOrderCVo.getCouponType()); | |||
| @@ -443,11 +443,11 @@ public class PosServiceImpl implements PosService { | |||
| * @param couponOrderIdStr | |||
| * @return | |||
| */ | |||
| public JSONObject oneCouponVerify(PromotionCalc promotionCalc, String couponOrderIdStr, Long merchantId, Long buUserId, Long posOrderId) { | |||
| public JSONObject oneCouponVerify(PromotionCalc promotionCalc,TenantEntity tenantinfo, String couponOrderIdStr, Long merchantId, Long buUserId, Long posOrderId) { | |||
| JSONObject retObj = new JSONObject(); | |||
| Date now = new Date(); | |||
| // 1. 获取券包信息 | |||
| WxCouponOrderCVo couponOrderCVo = checkAndGetCouponOrder(couponOrderIdStr, merchantId, now); | |||
| WxCouponOrderCVo couponOrderCVo = checkAndGetCouponOrder(couponOrderIdStr,tenantinfo, merchantId, now); | |||
| // 2. 检查券类型 核销可用(4, 6, 8, 9) | |||
| EnumCouponType couponType = EnumCouponType.getEnum(couponOrderCVo.getCouponType()); | |||
| @@ -636,9 +636,9 @@ public class PosServiceImpl implements PosService { | |||
| return retObj; | |||
| } | |||
| private WxCouponOrderCVo checkAndGetCouponOrder(String couponOrderIdStr, Long merchantId, Date currDate) { | |||
| private WxCouponOrderCVo checkAndGetCouponOrder(String couponOrderIdStr,TenantEntity tenantinfo, Long merchantId, Date currDate) { | |||
| // 1, 获取券包信息 | |||
| WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(couponOrderIdStr); | |||
| WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(couponOrderIdStr,tenantinfo); | |||
| if (couponOrderCVo == null) { | |||
| logger.error(ErrorCode.COUPON_ORDER_IS_NULL.getMessage() + ": " + couponOrderIdStr); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| @@ -874,7 +874,7 @@ public class PosServiceImpl implements PosService { | |||
| String couponOrderIdStr = couponOrderArr.getString(0); | |||
| if (couponOrderIdStr != null) { | |||
| try { | |||
| JSONObject couponPromoMap = oneCouponVerify(promotionCalc, couponOrderIdStr, merchantId, buUserId, posOrderId); | |||
| JSONObject couponPromoMap = oneCouponVerify(promotionCalc,tenantEntity, couponOrderIdStr, merchantId, buUserId, posOrderId); | |||
| couponList.add(couponPromoMap); | |||
| } catch (MallinkException e) { | |||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | |||
| @@ -1064,7 +1064,7 @@ public class PosServiceImpl implements PosService { | |||
| errParam(WxPayConstant.PAYMENT_INFO); | |||
| } | |||
| // 4. check couponOrderId | |||
| WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(couponOrderIdStr); | |||
| WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(couponOrderIdStr,merchant); | |||
| if (couponOrderCVo == null) { | |||
| logger.error(ErrorCode.COUPON_ORDER_IS_NULL.getMessage() + ": " + couponOrderIdStr); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| @@ -1596,7 +1596,7 @@ public class PosServiceImpl implements PosService { | |||
| // 3. check buUser | |||
| WxMerchantBUser buUser = checkAndGetMerchantUser(buUserId, merchantId); | |||
| WxCouponOrder couponOrder = couponOrderService.getById(cardId); | |||
| WxCouponOrder couponOrder = couponOrderService.getById(cardId,tenantEntity.getTenantId()); | |||
| if(couponOrder == null) { | |||
| logger.error("卡不存在: " + cardIdStr); | |||
| throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND); | |||
| @@ -1770,7 +1770,7 @@ public class PosServiceImpl implements PosService { | |||
| // 3. check buUser | |||
| WxMerchantBUser buUser = checkAndGetMerchantUser(buUserId, merchantId); | |||
| WxCouponOrder couponOrder = couponOrderService.getById(cardId); | |||
| WxCouponOrder couponOrder = couponOrderService.getById(cardId,tenantEntity.getTenantId()); | |||
| if(couponOrder == null) { | |||
| logger.error("卡不存在: " + cardIdStr); | |||
| throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND); | |||
| @@ -2177,7 +2177,7 @@ public class PosServiceImpl implements PosService { | |||
| updateCO.setPayVendor(EnumPayWay.PAY_WAY_POS_NEU.getCode()); | |||
| couponOrderMapper.updateById(updateCO); | |||
| } | |||
| WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(posPayOrderNo); | |||
| WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(posPayOrderNo,merchantBUser); | |||
| if (couponOrderCVo != null) { | |||
| // 3. 成长值 | |||
| try { | |||
| @@ -47,38 +47,53 @@ public class CouponOrderExpiringSchedule { | |||
| @Autowired | |||
| private WxOrderService wxOrderService; | |||
| @Autowired | |||
| private WxMallMapper wxMallMapper; | |||
| private List<WxMall> getMalls() { | |||
| WxMall wxMall = new WxMall(); | |||
| return wxMallMapper.findList(wxMall); | |||
| } | |||
| @Scheduled(cron = "0 0 5 * * ?") // 每天凌晨00:05 | |||
| // @Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||
| public void couponOrderExpiringSchedule() { | |||
| CouponOrderExpiringSchedule proxy = (CouponOrderExpiringSchedule) AopContext.currentProxy(); | |||
| List<WxCouponOrder> list = wxCouponOrderMapper.findExpiredFreeCouponOrderByValidDate(); | |||
| list.stream().forEach(co -> { | |||
| // 券过期,更改状态及库存退回 | |||
| try { | |||
| proxy.couponOrderExpire(co, true); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| }); | |||
| List<WxMall> malls = getMalls(); | |||
| for (WxMall mall: malls) { | |||
| List<WxCouponOrder> list = wxCouponOrderMapper.findExpiredFreeCouponOrderByValidDate(mall.getTenantId()); | |||
| list.stream().forEach(co -> { | |||
| // 券过期,更改状态及库存退回 | |||
| try { | |||
| proxy.couponOrderExpire(co, true); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| }); | |||
| } | |||
| } | |||
| @Scheduled(cron = "0 0 5 * * ?") // 每天凌晨00:05 | |||
| // @Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||
| public void couponOrderRefundSchedule() { | |||
| List<WxCouponOrder> list = wxCouponOrderMapper.findExpiredCouponOrderByValidDate(); | |||
| CouponOrderExpiringSchedule proxy = (CouponOrderExpiringSchedule) AopContext.currentProxy(); | |||
| list.stream().forEach(co -> { | |||
| try { | |||
| proxy.refund(co); | |||
| }catch(Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| }); | |||
| List<WxMall> malls = getMalls(); | |||
| for (WxMall mall: malls) { | |||
| List<WxCouponOrder> list = wxCouponOrderMapper.findExpiredCouponOrderByValidDate(mall.getTenantId()); | |||
| list.stream().forEach(co -> { | |||
| try { | |||
| proxy.refund(co); | |||
| }catch(Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| }); | |||
| } | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| @@ -12,14 +12,16 @@ import java.util.Map; | |||
| public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| WxCouponOrder selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| List<WxCouponOrder> findList(WxCouponOrder wxCouponOrder); | |||
| List<WxCouponOrder> findListOfOrderedByDate(Map dateMap); | |||
| List<WxCouponOrder> findListOfVerifiedByDate(Map dateMap); | |||
| List<WxCouponOrder> findExpiredFreeCouponOrderByValidDate(); | |||
| List<WxCouponOrder> findExpiredFreeCouponOrderByValidDate(@Param("tenantId")String tenantId); | |||
| List<WxCouponOrder> findExpiredCouponOrderByValidDate(); | |||
| List<WxCouponOrder> findExpiredCouponOrderByValidDate(@Param("tenantId")String tenantId); | |||
| // 券包核销 | |||
| int updateVerifyCouponOrder(WxCouponOrder wxCouponOrder); | |||
| @@ -43,10 +45,10 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| //List<WxCouponOrderCVo> findListOfCUser(WxCouponOrder wxCouponOrder); | |||
| List<WxCouponOrderCVo> findListOfCUserOptimize(WxCouponOrder wxCouponOrder); | |||
| WxCouponOrderCVo findDetailOfCUser(@Param("id")Long id); | |||
| WxCouponOrderCVo findSimpleDetailOfCUser(@Param("id")Long id); | |||
| WxCouponOrderCVo findDetailOfCUser(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| WxCouponOrderCVo findSimpleDetailOfCUser(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| List<WxCouponOrderBVo> findListOfAdmin(WxCouponOrderBVo wxCouponOrder); | |||
| WxCouponOrderBVo findDetailOfAdmin(@Param("id")Long id); | |||
| WxCouponOrderBVo findDetailOfAdmin(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| //营销报表 券数据图表 | |||
| List<MarkingCouponDataReportVo> couponDataMap(HashMap<String,Object> params); | |||
| @@ -76,14 +78,14 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| //// 卡相关接口 | |||
| List<WxCardCVo> findCardListOfCUser(WxCardCVo wxCardCVo); | |||
| WxCardCVo findCardDetailOfCUser(@Param("id")Long id); | |||
| WxCardCVo findCardDetailOfCUser(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| /// POS接口 | |||
| List<WxCouponOrderCVo> findAvailCouponOrder(Map<String,Object> params); | |||
| //卡延期,将过期的状态变为使用中 | |||
| void cardDefer(@Param("couponId")Long couponId,@Param("expireTime")Date expireTime); | |||
| void cardDefer(@Param("couponId")Long couponId,@Param("tenantId")String tenantId,@Param("expireTime")Date expireTime); | |||
| //查询待延期的idList | |||
| List<Long> cardDeferCouponOrderId(@Param("couponId")Long couponId); | |||
| List<Long> cardDeferCouponOrderId(@Param("couponId")Long couponId,@Param("tenantId")String tenantId); | |||
| } | |||
| @@ -32,7 +32,7 @@ public interface WxCouponOrderService { | |||
| * @param id | |||
| * @return | |||
| */ | |||
| WxCouponOrder getById(Long id); | |||
| WxCouponOrder getById(Long id,String tenantId); | |||
| /** | |||
| * 保存或更新实体 | |||
| @@ -47,7 +47,7 @@ public interface WxCouponOrderService { | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| //void deleteById(Long id); | |||
| /** | |||
| * 根据主键couponOrderId(券码)核销 | |||
| * | |||
| @@ -129,9 +129,9 @@ public interface WxCouponOrderService { | |||
| * C用户查券详情 | |||
| * | |||
| */ | |||
| WxCouponOrderCVo detailCUserVo(String couponOrderId); | |||
| WxCouponOrderCVo detailCUserVo(String couponOrderId,TenantEntity tenantinfo); | |||
| WxCouponOrderCVo simpleDetailCUserVo(String couponOrderId); | |||
| WxCouponOrderCVo simpleDetailCUserVo(String couponOrderId,TenantEntity tenantinfo); | |||
| /** | |||
| * C用户查券carlist | |||
| @@ -162,7 +162,7 @@ public interface WxCouponOrderService { | |||
| ResultData listAdminAsPage(WxCouponOrderBVo wxCouponOrder, Integer pageIndex, Integer pageSize); | |||
| ResultData detailAdminVo(Long couponOrderId); | |||
| ResultData detailAdminVo(Long couponOrderId,TenantEntity tenantinfo); | |||
| /** | |||
| * 日期分组 消费总数 | |||
| @@ -153,7 +153,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| @Override | |||
| public WxCouponOrder getById(Long id) { | |||
| public WxCouponOrder getById(Long id,String tenantId) { | |||
| return wxCouponOrderMapper.selectById(id); | |||
| } | |||
| @@ -169,10 +169,10 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| wxCouponOrderMapper.deleteById(id); | |||
| } | |||
| // @Override | |||
| // public void deleteById(Long id) { | |||
| // wxCouponOrderMapper.deleteById(id); | |||
| // } | |||
| @Override | |||
| @@ -219,6 +219,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| dateMap.put("startDate", startDate); | |||
| dateMap.put("endDate", endDate); | |||
| dateMap.put("merchantId", wxMerchant.getId()); | |||
| dateMap.put("tenantId", wxMerchant.getTenantId()); | |||
| Map resultMap = new HashMap(); | |||
| @@ -253,17 +254,17 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| @Override | |||
| public WxCouponOrderCVo detailCUserVo(String couponOrderId) { | |||
| public WxCouponOrderCVo detailCUserVo(String couponOrderId,TenantEntity tenantinfo) { | |||
| WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.findDetailOfCUser(Long.valueOf(couponOrderId)); | |||
| WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.findDetailOfCUser(Long.valueOf(couponOrderId),tenantinfo.getTenantId()); | |||
| if (wxCouponOrderCVo == null) | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| return wxCouponOrderCVo; | |||
| } | |||
| @Override | |||
| public WxCouponOrderCVo simpleDetailCUserVo(String couponOrderId) { | |||
| WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.findSimpleDetailOfCUser(Long.valueOf(couponOrderId)); | |||
| public WxCouponOrderCVo simpleDetailCUserVo(String couponOrderId,TenantEntity tenantinfo) { | |||
| WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.findSimpleDetailOfCUser(Long.valueOf(couponOrderId),tenantinfo.getTenantId()); | |||
| if (wxCouponOrderCVo == null) | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| return wxCouponOrderCVo; | |||
| @@ -295,7 +296,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| WxCouponOrderCVo wxCouponOrderCVo = null; | |||
| try { | |||
| wxCouponOrderCVo = wxCouponOrderMapper.findDetailOfCUser(Long.valueOf(couponOrderId)); | |||
| wxCouponOrderCVo = wxCouponOrderMapper.findDetailOfCUser(Long.valueOf(couponOrderId),wxMerchantBUser.getTenantId()); | |||
| } catch (Exception e) { | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| @@ -311,9 +312,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| @Override | |||
| public ResultData detailAdminVo(Long couponOrderId) { | |||
| public ResultData detailAdminVo(Long couponOrderId,TenantEntity tenantinfo) { | |||
| WxCouponOrderBVo wxCouponOrderBVo = wxCouponOrderMapper.findDetailOfAdmin(couponOrderId); | |||
| WxCouponOrderBVo wxCouponOrderBVo = wxCouponOrderMapper.findDetailOfAdmin(couponOrderId,tenantinfo.getTenantId()); | |||
| if (wxCouponOrderBVo == null) | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| return new ResultData(wxCouponOrderBVo); | |||
| @@ -1040,7 +1041,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| WxCardCVo cardCVo = wxCouponOrderMapper.findCardDetailOfCUser(Long.valueOf(couponOrderId)); | |||
| WxCardCVo cardCVo = wxCouponOrderMapper.findCardDetailOfCUser(Long.valueOf(couponOrderId),tenantinfo.getTenantId()); | |||
| Long couponId = cardCVo.getCouponId(); | |||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | |||
| wxCouponChannel.setCouponId(couponId); | |||
| @@ -1057,7 +1058,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| @Override | |||
| public ResultData cardAccept(WxCouponOrder record) { | |||
| //卡券是否存在 | |||
| WxCardCVo cardCVo = wxCouponOrderMapper.findCardDetailOfCUser(record.getId()); | |||
| WxCardCVo cardCVo = wxCouponOrderMapper.findCardDetailOfCUser(record.getId(),record.getTenantId()); | |||
| if (cardCVo == null) { | |||
| logger.info("卡券不存在" + record.getId()); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| @@ -1111,7 +1112,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| @Override | |||
| public ResultData queryCardStatus(WxCouponOrder record) { | |||
| //卡券是否存在 | |||
| WxCardCVo cardCVo = wxCouponOrderMapper.findCardDetailOfCUser(record.getId()); | |||
| WxCardCVo cardCVo = wxCouponOrderMapper.findCardDetailOfCUser(record.getId(),record.getTenantId()); | |||
| if (cardCVo == null) { | |||
| logger.info("卡券不存在" + record.getId()); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| @@ -767,8 +767,8 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| wxCouponChannelMapper.cardDefer(id,tenantId, validEndDate); | |||
| //更新coupon_order的状态,已过期的变为使用中 5-->4 | |||
| List<Long> couponOrderIds = wxCouponOrderMapper.cardDeferCouponOrderId(id); | |||
| wxCouponOrderMapper.cardDefer(id,validEndDate); | |||
| List<Long> couponOrderIds = wxCouponOrderMapper.cardDeferCouponOrderId(id,tenantId); | |||
| wxCouponOrderMapper.cardDefer(id,tenantId,validEndDate); | |||
| //更新coupon_passwd | |||
| couponPasswordMapper.updateExpiredTime(id, validEndDate); | |||
| @@ -31,7 +31,7 @@ public class FmInsideCouponVerifyMsgServiceImpl implements MsgSendService { | |||
| @Override | |||
| public void send(BaseMsg baseMsg) throws Exception{ | |||
| FmInsideCouponVerifyMsg msg = (FmInsideCouponVerifyMsg)baseMsg; | |||
| WxCouponOrder couponOrder = couponOrderService.getById(msg.getCouponOrderId()); | |||
| WxCouponOrder couponOrder = couponOrderService.getById(msg.getCouponOrderId(),msg.getTenantId()); | |||
| if(couponOrder == null) { | |||
| logger.error("券包ID未找到: " + msg.getCouponOrderId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL.getCode(), "券包ID未找到" + msg.getCouponOrderId()); | |||
| @@ -100,6 +100,10 @@ | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_coupon_order where id = #{id} and tenant_id=#{tenantId} | |||
| </select> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_coupon_order | |||
| <include refid="dynamicWhereConditions" /> | |||
| @@ -636,14 +640,14 @@ | |||
| </select> | |||
| <select id="findExpiredFreeCouponOrderByValidDate" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap"> | |||
| <select id="findExpiredFreeCouponOrderByValidDate" parameterType="String" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_coupon_order | |||
| where 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 id="findExpiredCouponOrderByValidDate" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap"> | |||
| <select id="findExpiredCouponOrderByValidDate" parameterType="String" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_coupon_order | |||
| where 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> | |||
| @@ -888,14 +892,14 @@ | |||
| </select> | |||
| <select id="findDetailOfAdmin" parameterType="java.lang.Long" resultMap="BVoResultMap"> | |||
| <select id="findDetailOfAdmin" parameterType="java.util.HashMap" resultMap="BVoResultMap"> | |||
| select <include refid="allAdminCouponOrderDetailColumns" /> | |||
| from wx_coupon c, wx_coupon_order co | |||
| left join wx_c_user_basic_info cu on cu.id = co.c_user_id | |||
| left join wx_merchant_b_user bu on co.b_user_id = bu.id | |||
| left join wx_merchant m on m.id = bu.merchant_id | |||
| left join wx_merchant_subsidy ms on co.id = ms.coupon_order_id and ms.type = 1 | |||
| where co.id = #{id} | |||
| where co.id = #{id} and co.tenant_id = #{tenantId} | |||
| and c.id = co.coupon_id | |||
| </select> | |||
| @@ -924,6 +928,7 @@ | |||
| where com.mc = 1 | |||
| and com.tcoid = co.id | |||
| and cm.merchant_id = #{merchantId} | |||
| and co.tenant_id = #{tenantId} | |||
| and cm.product_id = c.id | |||
| and cm.status = 0 | |||
| and co.coupon_id = c.id | |||
| @@ -942,6 +947,7 @@ | |||
| select <include refid="allBUserVerifiedCouponOrderColumns" /> | |||
| from wx_coupon_order co,wx_coupon c,wx_c_user_basic_info cu,wx_merchant_b_user bu | |||
| where co.coupon_id = c.id | |||
| and co.tenant_id = #{tenantId} | |||
| and cu.id = co.c_user_id | |||
| and bu.id = co.b_user_id | |||
| and bu.merchant_id = #{merchantId} | |||
| @@ -969,6 +975,7 @@ | |||
| as mc | |||
| from wx_coupon_order tco) com | |||
| where com.mc = 1 | |||
| and co.tenant_id = #{tenantId} | |||
| and com.tcoid = co.id | |||
| and cm.status = 0 | |||
| and cm.merchant_id = #{merchantId} | |||
| @@ -985,6 +992,7 @@ | |||
| select <include refid="allCouponOrderColumns" /> | |||
| from wx_coupon_order co, wx_merchant_b_user mbu | |||
| where mbu.id = co.b_user_id | |||
| and co.tenant_id = #{tenantId} | |||
| <if test="merchantId != null"> | |||
| and mbu.merchant_id = #{merchantId} | |||
| </if> | |||
| @@ -1158,17 +1166,17 @@ | |||
| <select id="findDetailOfCUser" parameterType="java.lang.Long" resultMap="CVoResultMap"> | |||
| <select id="findDetailOfCUser" parameterType="java.util.HashMap" resultMap="CVoResultMap"> | |||
| select <include refid="allCUserCouponOrderDetailColumns" /> | |||
| from wx_coupon_order co, wx_coupon c | |||
| where co.coupon_id = c.id | |||
| and co.id = #{id} | |||
| and co.id = #{id} and co.tenant_id = #{tenantId} | |||
| </select> | |||
| <select id="findSimpleDetailOfCUser" parameterType="java.lang.Long" resultMap="CVoResultMap"> | |||
| <select id="findSimpleDetailOfCUser" parameterType="java.util.HashMap" resultMap="CVoResultMap"> | |||
| select <include refid="simpleCUserCouponOrderDetailColumns" /> | |||
| from wx_coupon_order co | |||
| where co.id = #{id} | |||
| where co.id = #{id} and co.tenant_id = #{tenantId} | |||
| </select> | |||
| <select id="findAvailCouponOrder" parameterType="java.util.Map" resultMap="CVoResultMap"> | |||
| @@ -1390,19 +1398,19 @@ | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </select> | |||
| <select id="findCardDetailOfCUser" parameterType="java.lang.Long" resultMap="CCardVoResultMap"> | |||
| <select id="findCardDetailOfCUser" parameterType="java.util.HashMap" resultMap="CCardVoResultMap"> | |||
| select <include refid="allCUserCardDetailColumns" /> | |||
| from wx_coupon_order co,wx_coupon c, wx_card_info a | |||
| where co.coupon_id = c.id and co.id = a.id | |||
| and co.id = #{id} | |||
| and co.id = #{id} and co.tenant_id = #{tenantId} | |||
| </select> | |||
| <update id="cardDefer" parameterType="map"> | |||
| update wx_coupon_order set coupon_order_status = 4,update_date = now(), expired_time= #{expireTime} where coupon_id = #{couponId} and coupon_order_status in (4, 5) | |||
| update wx_coupon_order set coupon_order_status = 4,update_date = now(), expired_time= #{expireTime} where coupon_id = #{couponId} and tenant_id = #{tenantId} and coupon_order_status in (4, 5) | |||
| </update> | |||
| <select id="cardDeferCouponOrderId" parameterType="java.lang.Long" resultType="java.lang.Long"> | |||
| select id from wx_coupon_order where coupon_id = #{couponId} and coupon_order_status in (4, 5) | |||
| <select id="cardDeferCouponOrderId" parameterType="java.util.HashMap" resultType="java.lang.Long"> | |||
| select id from wx_coupon_order where coupon_id = #{couponId} and tenant_id = #{tenantId} and coupon_order_status in (4, 5) | |||
| </select> | |||
| </mapper> | |||
| @@ -168,6 +168,7 @@ public class DataInitController extends BaseController { | |||
| // 1 获取券码 | |||
| Map dateMap = new HashMap(); | |||
| dateMap.put("startDate", "2019-09-16 22:00:00"); | |||
| dateMap.put("tenantId", "11111111111"); | |||
| List<WxCouponOrder> coList = couponOrderMapper.findListOfVerifiedByDate(dateMap); | |||
| // 2 重新计算积分,比较是否需要修复 | |||
| coList.forEach(co -> { | |||