| @@ -125,7 +125,7 @@ public class WxCampaignController extends BaseController { | |||||
| for (String couponIdStr : ids) { | for (String couponIdStr : ids) { | ||||
| Long couponId = Long.parseLong(couponIdStr); | Long couponId = Long.parseLong(couponIdStr); | ||||
| WxCoupon wxCoupon = wxCouponService.getById(couponId); | |||||
| WxCoupon wxCoupon = wxCouponService.getById(couponId,campaign.getTenantId()); | |||||
| if (wxCoupon == null) { | if (wxCoupon == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -147,7 +147,7 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| WxCoupon coupon = wxCouponService.getById(wxCoupon.getId()); | |||||
| WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),wxCoupon.getTenantId()); | |||||
| if (null == coupon) { | if (null == coupon) { | ||||
| return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId()); | return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId()); | ||||
| } | } | ||||
| @@ -289,7 +289,7 @@ public class WxCouponController extends BaseController { | |||||
| @SystemControllerLog(description = "券投放-删除") | @SystemControllerLog(description = "券投放-删除") | ||||
| public ResultData delete(Long id) { | public ResultData delete(Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::delete"); | logger.debug("[" + getIpAddr() + "] WxCouponController::delete"); | ||||
| wxCouponService.deleteById(id); | |||||
| wxCouponService.deleteById(id,getTenantInfo().getTenantId()); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | return new ResultData(Result.SUCCESS, "删除成功", null); | ||||
| } | } | ||||
| @@ -299,7 +299,7 @@ public class WxCouponController extends BaseController { | |||||
| @SystemControllerLog(description = "券投放-查询") | @SystemControllerLog(description = "券投放-查询") | ||||
| public ResultData findById(@RequestParam Long id) { | public ResultData findById(@RequestParam Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | ||||
| return new ResultData(wxCouponService.getVoById(id)); | |||||
| return new ResultData(wxCouponService.getVoById(id,getTenantInfo().getTenantId())); | |||||
| } | } | ||||
| @@ -395,7 +395,7 @@ public class WxCouponController extends BaseController { | |||||
| @SystemControllerLog(description = "券投放-富文本获取") | @SystemControllerLog(description = "券投放-富文本获取") | ||||
| public ResultData getHtml(@RequestParam Long id) { | public ResultData getHtml(@RequestParam Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById"); | logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById"); | ||||
| return new ResultData(wxCouponService.getHtmlById(id)); | |||||
| return new ResultData(wxCouponService.getHtmlById(id,getTenantInfo().getTenantId())); | |||||
| } | } | ||||
| @ApiOperation("卡延期") | @ApiOperation("卡延期") | ||||
| @@ -409,7 +409,7 @@ public class WxCouponController extends BaseController { | |||||
| return new ResultData(ResultData.ERROR, "缺少validEndDate"); | return new ResultData(ResultData.ERROR, "缺少validEndDate"); | ||||
| } | } | ||||
| return new ResultData(wxCouponService.cardDefer(wxCoupon.getId(),wxCoupon.getValidEndDate())); | |||||
| return new ResultData(wxCouponService.cardDefer(wxCoupon.getId(),getTenantInfo().getTenantId(),wxCoupon.getValidEndDate())); | |||||
| } | } | ||||
| } | } | ||||
| @@ -97,7 +97,7 @@ public class WxCouponPresentController extends BaseController { | |||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | return new ResultData(e.getErrorCode(), e.getMessage()); | ||||
| } | } | ||||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponPresent.getCouponId()); | |||||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponPresent.getCouponId(),wxCouponPresent.getTenantId()); | |||||
| if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) { //时间范围 | if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) { //时间范围 | ||||
| if (new Date().after(wxCoupon.getValidEndDate())) { | if (new Date().after(wxCoupon.getValidEndDate())) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EXPIRED); | return new ResultData(ErrorCode.COUPON_IS_EXPIRED); | ||||
| @@ -106,7 +106,7 @@ public class WxCouponSendController extends BaseController { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | ||||
| } | } | ||||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId()); | |||||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId(),getTenantInfo().getTenantId()); | |||||
| if (!EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode().equals(wxCoupon.getStatus())) { | if (!EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode().equals(wxCoupon.getStatus())) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | ||||
| } | } | ||||
| @@ -180,7 +180,7 @@ public class WxOrderController extends BaseController { | |||||
| user.setOperatorType(EnumUserType.MALLUSER.getCode()); | user.setOperatorType(EnumUserType.MALLUSER.getCode()); | ||||
| user.setOperatorId(getUserId()); | user.setOperatorId(getUserId()); | ||||
| WxOrder order = null; | WxOrder order = null; | ||||
| WxCoupon coupon = wxCouponService.getById(couponId); | |||||
| WxCoupon coupon = wxCouponService.getById(couponId,wxCouponChannel.getTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -101,7 +101,7 @@ public class MemCouponController extends BaseController { | |||||
| memCouponFromDsp.setCouponId(couponChannel.getCouponId()); | memCouponFromDsp.setCouponId(couponChannel.getCouponId()); | ||||
| } | } | ||||
| // 1. 检查券是否已超限, 无剩余库存 | // 1. 检查券是否已超限, 无剩余库存 | ||||
| WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId()); | |||||
| WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId(),memCouponFromDsp.getTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId()); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId()); | ||||
| } | } | ||||
| @@ -144,7 +144,7 @@ public class MemCouponController extends BaseController { | |||||
| memCouponFromDsp.setCouponId(couponChannel.getCouponId()); | memCouponFromDsp.setCouponId(couponChannel.getCouponId()); | ||||
| } | } | ||||
| // 1. 检查券是否已超限, 无剩余库存 | // 1. 检查券是否已超限, 无剩余库存 | ||||
| WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId()); | |||||
| WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId(),couponChannel.getTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId()); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId()); | ||||
| } | } | ||||
| @@ -246,7 +246,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| if (page.getSize() > 0) { | if (page.getSize() > 0) { | ||||
| List<WxCouponOrder> list = page.getList(); | List<WxCouponOrder> list = page.getList(); | ||||
| for (WxCouponOrder c : list) { | for (WxCouponOrder c : list) { | ||||
| WxCoupon coupon = wxCouponService.getById(c.getCouponId()); | |||||
| WxCoupon coupon = wxCouponService.getById(c.getCouponId(),c.getTenantId()); | |||||
| c.setCouponName(coupon.getTitle()); | c.setCouponName(coupon.getTitle()); | ||||
| c.setSalePrice(coupon.getPrice()); | c.setSalePrice(coupon.getPrice()); | ||||
| @@ -276,7 +276,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| //if (page.getSize() > 0) { | //if (page.getSize() > 0) { | ||||
| List<WxCouponOrder> list = page.getList(); | List<WxCouponOrder> list = page.getList(); | ||||
| for (WxCouponOrder c : list) { | for (WxCouponOrder c : list) { | ||||
| WxCoupon coupon = wxCouponService.getById(c.getCouponId()); | |||||
| WxCoupon coupon = wxCouponService.getById(c.getCouponId(),c.getTenantId()); | |||||
| c.setCouponName(coupon.getTitle()); | c.setCouponName(coupon.getTitle()); | ||||
| c.setSalePrice(coupon.getPrice()); | c.setSalePrice(coupon.getPrice()); | ||||
| } | } | ||||
| @@ -164,7 +164,7 @@ public class WxCouponController extends BaseController { | |||||
| if (wxCoupon.getId() == null) { | if (wxCoupon.getId() == null) { | ||||
| return new ResultData(ResultData.ERROR, "缺少id"); | return new ResultData(ResultData.ERROR, "缺少id"); | ||||
| } | } | ||||
| WxCoupon coupon = wxCouponService.getById(wxCoupon.getId()); | |||||
| WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),getTenantInfo().getTenantId()); | |||||
| if(coupon.getSourceType().intValue() != EnumCouponSourceType.COUPONSource_Bapi.getCode().intValue()){ | if(coupon.getSourceType().intValue() != EnumCouponSourceType.COUPONSource_Bapi.getCode().intValue()){ | ||||
| return new ResultData(Result.ERROR,"非B端券,不能进行此操作"); | return new ResultData(Result.ERROR,"非B端券,不能进行此操作"); | ||||
| @@ -241,7 +241,7 @@ public class WxCouponController extends BaseController { | |||||
| wxCoupon.setMerchantParams(JSONObject.toJSONString(merchantList)); | wxCoupon.setMerchantParams(JSONObject.toJSONString(merchantList)); | ||||
| WxCoupon coupon = wxCouponService.getById(wxCoupon.getId()); | |||||
| WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),wxCoupon.getTenantId()); | |||||
| if (null == coupon) { | if (null == coupon) { | ||||
| return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId()); | return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId()); | ||||
| } | } | ||||
| @@ -328,7 +328,7 @@ public class WxCouponController extends BaseController { | |||||
| return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程"); | return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程"); | ||||
| } | } | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::delete"); | logger.debug("[" + getIpAddr() + "] WxCouponController::delete"); | ||||
| wxCouponService.deleteById(id); | |||||
| wxCouponService.deleteById(id,getTenantInfo().getTenantId()); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | return new ResultData(Result.SUCCESS, "删除成功", null); | ||||
| } | } | ||||
| @@ -337,7 +337,7 @@ public class WxCouponController extends BaseController { | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | ||||
| public ResultData findById(@RequestParam Long id) { | public ResultData findById(@RequestParam Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | ||||
| return new ResultData(wxCouponService.getVoById(id)); | |||||
| return new ResultData(wxCouponService.getVoById(id,getTenantInfo().getTenantId())); | |||||
| } | } | ||||
| @@ -428,7 +428,7 @@ public class WxCouponController extends BaseController { | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | ||||
| public ResultData getHtml(@RequestParam Long id) { | public ResultData getHtml(@RequestParam Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById"); | logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById"); | ||||
| return new ResultData(wxCouponService.getHtmlById(id)); | |||||
| return new ResultData(wxCouponService.getHtmlById(id,getTenantInfo().getTenantId())); | |||||
| } | } | ||||
| @@ -157,7 +157,7 @@ public class WxCouponOrderController extends BaseController { | |||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| } else { | } else { | ||||
| wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId()); | |||||
| wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId(),wxMerchantBUser.getTenantId()); | |||||
| if (wxCouponCVo == null) { | if (wxCouponCVo == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -214,7 +214,7 @@ public class WxCouponOrderController extends BaseController { | |||||
| } | } | ||||
| wxCouponOrderCVo.setHtml(wxCouponCVo.getHtml()); | wxCouponOrderCVo.setHtml(wxCouponCVo.getHtml()); | ||||
| } else { | } else { | ||||
| WxCoupon wxCoupon = wxCouponService.getHtmlById(wxCouponOrderCVo.getCouponId()); | |||||
| WxCoupon wxCoupon = wxCouponService.getHtmlById(wxCouponOrderCVo.getCouponId(),wxCouponOrderCVo.getTenantId()); | |||||
| if (wxCoupon == null) { | if (wxCoupon == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -341,7 +341,7 @@ public class WxCarController extends BaseController { | |||||
| } | } | ||||
| return new ResultData(Result.SUCCESS,"已经使用过优惠券, 不能重复使用."); | return new ResultData(Result.SUCCESS,"已经使用过优惠券, 不能重复使用."); | ||||
| } else { | } else { | ||||
| WxCoupon coupon = couponService.getById(userCar.getCouponId()); | |||||
| WxCoupon coupon = couponService.getById(userCar.getCouponId(),park.getFinalTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券为空"); | ||||
| } | } | ||||
| @@ -86,7 +86,7 @@ public class WxCouponController extends BaseController { | |||||
| // 库存 | // 库存 | ||||
| if (couponIdL > 0L) { | if (couponIdL > 0L) { | ||||
| // 更新状态 | // 更新状态 | ||||
| WxCouponCVo couponCVo = couponService.getVoStatusById(couponIdL); | |||||
| WxCouponCVo couponCVo = couponService.getVoStatusById(couponIdL,wxCouponCVo.getTenantId()); | |||||
| if (wxCouponCVo == null) { | if (wxCouponCVo == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -184,7 +184,7 @@ public class WxCouponController extends BaseController { | |||||
| return null; | return null; | ||||
| } | } | ||||
| WxCoupon c = couponService.getById(cc.getCouponId()); | |||||
| WxCoupon c = couponService.getById(cc.getCouponId(),cc.getTenantId()); | |||||
| if (c == null) { | if (c == null) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -203,7 +203,7 @@ public class WxCouponController extends BaseController { | |||||
| return null; | return null; | ||||
| } | } | ||||
| WxCoupon c = couponService.getHtmlById(cc.getCouponId()); | |||||
| WxCoupon c = couponService.getHtmlById(cc.getCouponId(),cc.getTenantId()); | |||||
| if (c == null) { | if (c == null) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -222,7 +222,7 @@ public class WxCouponController extends BaseController { | |||||
| return null; | return null; | ||||
| } | } | ||||
| WxCoupon c = couponService.getById(cc.getCouponId()); | |||||
| WxCoupon c = couponService.getById(cc.getCouponId(),cc.getTenantId()); | |||||
| if (c == null) { | if (c == null) { | ||||
| c = new WxCoupon(); | c = new WxCoupon(); | ||||
| } | } | ||||
| @@ -140,7 +140,7 @@ public class WxCouponOrderController extends BaseController { | |||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| } else { | } else { | ||||
| wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId()); | |||||
| wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId(),wxCouponOrderCVo.getTenantId()); | |||||
| if (wxCouponCVo == null) { | if (wxCouponCVo == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -209,7 +209,7 @@ public class WxCouponOrderController extends BaseController { | |||||
| wxCouponOrderCVo.setContentType(wxCouponCVo.getContentType()); | wxCouponOrderCVo.setContentType(wxCouponCVo.getContentType()); | ||||
| wxCouponOrderCVo.setHtml(wxCouponCVo.getHtml()); | wxCouponOrderCVo.setHtml(wxCouponCVo.getHtml()); | ||||
| } else { | } else { | ||||
| WxCoupon wxCoupon = wxCouponService.getHtmlById(wxCouponOrderCVo.getCouponId()); | |||||
| WxCoupon wxCoupon = wxCouponService.getHtmlById(wxCouponOrderCVo.getCouponId(),wxCouponOrderCVo.getTenantId()); | |||||
| if (wxCoupon == null) { | if (wxCoupon == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -80,7 +80,7 @@ public class WxCouponPasswordController extends BaseController { | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "会员用户未找到" + memberId); | throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "会员用户未找到" + memberId); | ||||
| } | } | ||||
| WxCoupon coupon = couponService.getById(couponPassword.getCouponId()); | |||||
| WxCoupon coupon = couponService.getById(couponPassword.getCouponId(),couponPassword.getTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -93,7 +93,7 @@ public class WxOrderController extends BaseController { | |||||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | ||||
| } | } | ||||
| WxCoupon coupon = wxCouponService.getById(wxCouponChannel.getCouponId()); | |||||
| WxCoupon coupon = wxCouponService.getById(wxCouponChannel.getCouponId(),wxCouponChannel.getTenantId()); | |||||
| if (null == coupon) { | if (null == coupon) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -415,7 +415,7 @@ public class WxOrderController extends BaseController { | |||||
| } | } | ||||
| WxCoupon wxCoupon = null; | WxCoupon wxCoupon = null; | ||||
| try { | try { | ||||
| wxCoupon = wxCouponService.getById(id); | |||||
| wxCoupon = wxCouponService.getById(id,getTenantInfo().getTenantId()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("券ID获取券信息失败, couponId: " + couponId); | logger.error("券ID获取券信息失败, couponId: " + couponId); | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| @@ -186,7 +186,7 @@ public class WxPayOrderController extends BaseController { | |||||
| if (null == order) { | if (null == order) { | ||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "未查询到Order["+orderId+"]."); | return new ResultData(ErrorCode.PAY_ORDER_ERROR, "未查询到Order["+orderId+"]."); | ||||
| } | } | ||||
| WxCoupon wxCoupon = wxCouponService.getById(order.getProductId()); | |||||
| WxCoupon wxCoupon = wxCouponService.getById(order.getProductId(),order.getTenantId()); | |||||
| if (null == wxCoupon) { | if (null == wxCoupon) { | ||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "未查询到优惠券[orderId:"+orderId+"]."); | return new ResultData(ErrorCode.PAY_ORDER_ERROR, "未查询到优惠券[orderId:"+orderId+"]."); | ||||
| } | } | ||||
| @@ -113,7 +113,7 @@ public class WxPressOrderController extends BaseController { | |||||
| wxCouponCVo = cdOperations.get(cdKey); | wxCouponCVo = cdOperations.get(cdKey); | ||||
| } else { | } else { | ||||
| // 券信息没有入缓存,需要从数据库中读取 | // 券信息没有入缓存,需要从数据库中读取 | ||||
| wxCouponCVo = wxCouponService.getVoById(order.getProductId()); | |||||
| wxCouponCVo = wxCouponService.getVoById(order.getProductId(),order.getTenantId()); | |||||
| if (wxCouponCVo != null) { | if (wxCouponCVo != null) { | ||||
| // 券详情优化,进缓存 | // 券详情优化,进缓存 | ||||
| couponCVoRedisTemplate.opsForValue().set(cdKey, wxCouponCVo, 3600, TimeUnit.SECONDS); | couponCVoRedisTemplate.opsForValue().set(cdKey, wxCouponCVo, 3600, TimeUnit.SECONDS); | ||||
| @@ -460,7 +460,7 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT); | throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT); | ||||
| } | } | ||||
| // 5. get coupon | // 5. get coupon | ||||
| WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId()); | |||||
| WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId(),couponOrderCVo.getTenantId()); | |||||
| if (wxCoupon == null) { | if (wxCoupon == null) { | ||||
| logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId()); | logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId()); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | ||||
| @@ -610,7 +610,7 @@ public class PosServiceImpl implements PosService { | |||||
| } | } | ||||
| if (couponSelected) { | if (couponSelected) { | ||||
| // 5. get coupon | // 5. get coupon | ||||
| WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId()); | |||||
| WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId(),couponOrderCVo.getTenantId()); | |||||
| if (wxCoupon == null) { | if (wxCoupon == null) { | ||||
| logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId()); | logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId()); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | ||||
| @@ -1083,7 +1083,7 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); | throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); | ||||
| } | } | ||||
| // 5. 核销后无法反向 | // 5. 核销后无法反向 | ||||
| WxCoupon coupon = couponMapper.selectById(couponOrderCVo.getCouponId()); | |||||
| WxCoupon coupon = couponMapper.selectById(couponOrderCVo.getCouponId(),couponOrderCVo.getTenantId()); | |||||
| if (coupon.getSalePrice() > 0 || | if (coupon.getSalePrice() > 0 || | ||||
| (coupon.getSubsidyType() > EnumCouponSubsidyType.NO_SUBSIDY.getCode() && coupon.getSubsidyNum() > 0)) { | (coupon.getSubsidyType() > EnumCouponSubsidyType.NO_SUBSIDY.getCode() && coupon.getSubsidyNum() > 0)) { | ||||
| logger.error("券包ID: " + couponOrderIdStr + "核销无法退回"); | logger.error("券包ID: " + couponOrderIdStr + "核销无法退回"); | ||||
| @@ -2188,7 +2188,7 @@ public class PosServiceImpl implements PosService { | |||||
| logger.error("交易核销成长值异常:" + e.getMessage()); | logger.error("交易核销成长值异常:" + e.getMessage()); | ||||
| } | } | ||||
| WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId()); | |||||
| WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId(),couponOrderCVo.getTenantId()); | |||||
| if (wxCoupon == null) { | if (wxCoupon == null) { | ||||
| logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId()); | logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId()); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | ||||
| @@ -191,7 +191,7 @@ public class CouponSendSchedule { | |||||
| // 发放免费券 | // 发放免费券 | ||||
| try { | try { | ||||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cu.getId(), cs.getCouponId(), null,EnumPayWay.PAY_WAY_NOT_UNPAY_SYSTEM_SEND); | |||||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cu.getId(), cs.getTenantId(),cs.getCouponId(), null,EnumPayWay.PAY_WAY_NOT_UNPAY_SYSTEM_SEND); | |||||
| wxCouponActionLogService.addOne(tenantEntity, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); | wxCouponActionLogService.addOne(tenantEntity, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("定时发券:发券失败 levelId=" + l.getId() + " couponId=" + cs.getCouponId() + " userId=" + cu.getId() + e.getMessage()); | logger.error("定时发券:发券失败 levelId=" + l.getId() + " couponId=" + cs.getCouponId() + " userId=" + cu.getId() + e.getMessage()); | ||||
| @@ -321,7 +321,7 @@ public class CouponSendSchedule { | |||||
| for (WxCUserBasicInfo cu : newUserList) { | for (WxCUserBasicInfo cu : newUserList) { | ||||
| // 发放生日券 | // 发放生日券 | ||||
| try { | try { | ||||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cu.getId(), cs.getCouponId(), null,EnumPayWay.PAY_WAY_NOT_UNPAY_SYSTEM_SEND); | |||||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cu.getId(),cs.getTenantId(), cs.getCouponId(), null,EnumPayWay.PAY_WAY_NOT_UNPAY_SYSTEM_SEND); | |||||
| wxCouponActionLogService.addOne(tenantEntity, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); | wxCouponActionLogService.addOne(tenantEntity, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); | ||||
| couponSendedUsers.add(cu); | couponSendedUsers.add(cu); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -1,31 +0,0 @@ | |||||
| package com.iformall.domain.po.msg; | |||||
| import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * 更新券库存消息 | |||||
| * @author Stormeye | |||||
| * @date 2019/4/9 13:55 | |||||
| */ | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class UpdateCouponStockMsg extends BaseMsg { | |||||
| private static final long serialVersionUID = 223232132183760321L; | |||||
| public static final String OPERATE_TYPE_INCREASE = "increase"; | |||||
| public static final String OPERATE_TYPE_DECREASE = "decrease"; | |||||
| @io.swagger.annotations.ApiModelProperty(value="券Id",name="couponId") | |||||
| private Long couponId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新数量",name="number") | |||||
| private long number; | |||||
| @io.swagger.annotations.ApiModelProperty(value="操作类型 1-增加库存 ,2-减少库存",name="operateType") | |||||
| private String operateType; | |||||
| } | |||||
| @@ -16,13 +16,17 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> { | |||||
| List<WxCoupon> findList(WxCoupon wxCoupon); | List<WxCoupon> findList(WxCoupon wxCoupon); | ||||
| List<WxCoupon> findCouponList(WxCoupon wxCoupon); | List<WxCoupon> findCouponList(WxCoupon wxCoupon); | ||||
| WxCoupon selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| WxCouponCVo findVoDetail(@Param("id")Long id); | |||||
| WxCouponCVo findVoStatusDetail(@Param("id")Long id); | |||||
| WxCouponCVo findVoDetail(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| WxCouponCVo findVoStatusDetail(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| void deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| Integer reduceInventory(@Param("id")Long id,@Param("number")Integer number); | |||||
| Integer reduceInventory(@Param("id")Long id,@Param("tenantId")String tenantId,@Param("number")Integer number); | |||||
| Integer backInventory(@Param("id")Long id, @Param("number")Integer number,@Param("remainInventory")Integer remainInventory); | |||||
| Integer backInventory(@Param("id")Long id,@Param("tenantId")String tenantId, @Param("number")Integer number,@Param("remainInventory")Integer remainInventory); | |||||
| void offExpiriedCouponByValidDate(); | void offExpiriedCouponByValidDate(); | ||||
| @@ -52,14 +52,14 @@ public interface WxCouponService { | |||||
| * @param id | * @param id | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| WxCoupon getById(Long id); | |||||
| WxCoupon getById(Long id,String tenantId); | |||||
| WxCoupon getHtmlById(Long id); | |||||
| WxCoupon getHtmlById(Long id,String tenantId); | |||||
| WxCouponCVo getVoById(Long id); | |||||
| WxCouponCVo getVoById(Long id,String tenantId); | |||||
| WxCouponCVo getVoStatusById(Long id); | |||||
| WxCouponCVo getVoStatusById(Long id,String tenantId); | |||||
| /** | /** | ||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| * | * | ||||
| @@ -77,7 +77,7 @@ public interface WxCouponService { | |||||
| * | * | ||||
| * @param id | * @param id | ||||
| */ | */ | ||||
| void deleteById(Long id); | |||||
| void deleteById(Long id,String tenantId); | |||||
| /** | /** | ||||
| @@ -214,7 +214,7 @@ public interface WxCouponService { | |||||
| * @param number 减少数量 | * @param number 减少数量 | ||||
| * @param remainInventory 当前库存 | * @param remainInventory 当前库存 | ||||
| */ | */ | ||||
| void reduceRemainInventory(Long id, Integer number); | |||||
| void reduceRemainInventory(Long id,String tenantId, Integer number); | |||||
| /** | /** | ||||
| * 库存退回 | * 库存退回 | ||||
| @@ -223,12 +223,12 @@ public interface WxCouponService { | |||||
| * @param number 回退数量 | * @param number 回退数量 | ||||
| * @param remainInventory 当前库存 | * @param remainInventory 当前库存 | ||||
| */ | */ | ||||
| void backRemainInventory(Long id, Integer number, Integer remainInventory); | |||||
| void backRemainInventory(Long id,String tenantId, Integer number, Integer remainInventory); | |||||
| /** | /** | ||||
| * 卡延期 | * 卡延期 | ||||
| * @param wxCoupon | * @param wxCoupon | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| ResultData cardDefer(Long id,Date validEndDate); | |||||
| ResultData cardDefer(Long id,String tenantId,Date validEndDate); | |||||
| } | } | ||||
| @@ -86,7 +86,7 @@ public interface WxOrderService { | |||||
| * @param wxCouponSendVo 商户注券时必须指定 | * @param wxCouponSendVo 商户注券时必须指定 | ||||
| * @return WxCouponOrder | * @return WxCouponOrder | ||||
| */ | */ | ||||
| WxCouponOrder sendFreeCouponToUser(Long userId, Long couponId, WxCouponSendVo wxCouponSendVo,EnumPayWay payWay); | |||||
| WxCouponOrder sendFreeCouponToUser(Long userId, String tenantId,Long couponId, WxCouponSendVo wxCouponSendVo,EnumPayWay payWay); | |||||
| /** | /** | ||||
| * orderSuccess 订单已支付 | * orderSuccess 订单已支付 | ||||
| @@ -103,7 +103,7 @@ public class MemCouponFromDspServiceImpl implements MemCouponFromDspService { | |||||
| List<MemCouponFromDsp> couponFromDsps = memCouponFromDspMapper.findList(memQ); | List<MemCouponFromDsp> couponFromDsps = memCouponFromDspMapper.findList(memQ); | ||||
| for (MemCouponFromDsp memCouponFromDsp: couponFromDsps) { | for (MemCouponFromDsp memCouponFromDsp: couponFromDsps) { | ||||
| // 注入券码, 无论此券是有价还是免费 | // 注入券码, 无论此券是有价还是免费 | ||||
| WxCoupon coupon = couponMapper.selectById(memCouponFromDsp.getCouponId()); | |||||
| WxCoupon coupon = couponMapper.selectById(memCouponFromDsp.getCouponId(),memCouponFromDsp.getTenantId()); | |||||
| if (coupon != null) { | if (coupon != null) { | ||||
| try { | try { | ||||
| Long couponOrderId = wxOrderService.saveOuterOrderForCoupon(user, coupon, memCouponFromDsp.getCouponChannelId(), null, null); | Long couponOrderId = wxOrderService.saveOuterOrderForCoupon(user, coupon, memCouponFromDsp.getCouponChannelId(), null, null); | ||||
| @@ -228,7 +228,7 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||||
| public void saveOrUpdateCouponChannel(Long couponId, Map<Long, WxCouponChannel> wxCouponChannelsMap, WxCampaign record){ | public void saveOrUpdateCouponChannel(Long couponId, Map<Long, WxCouponChannel> wxCouponChannelsMap, WxCampaign record){ | ||||
| WxCoupon wxCoupon = wxCouponService.getById(couponId); | |||||
| WxCoupon wxCoupon = wxCouponService.getById(couponId,record.getTenantId()); | |||||
| if (wxCoupon == null) { | if (wxCoupon == null) { | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -103,7 +103,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| } | } | ||||
| // 2. coupon | // 2. coupon | ||||
| Integer subsidyRate = 0; | Integer subsidyRate = 0; | ||||
| WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId()); | |||||
| WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId(),cardInfo.getTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| logger.error("card's coupon not found: " + cardInfo.getCouponId()); | logger.error("card's coupon not found: " + cardInfo.getCouponId()); | ||||
| return new ResultData(ErrorCode.CARD_IS_NOT_FOUND); | return new ResultData(ErrorCode.CARD_IS_NOT_FOUND); | ||||
| @@ -619,7 +619,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| } | } | ||||
| // 2. coupon | // 2. coupon | ||||
| Integer subsidyRate = 0; | Integer subsidyRate = 0; | ||||
| WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId()); | |||||
| WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId(),cardInfo.getTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| logger.error("card's coupon not found: " + cardInfo.getCouponId()); | logger.error("card's coupon not found: " + cardInfo.getCouponId()); | ||||
| throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND); | throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND); | ||||
| @@ -720,7 +720,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| } | } | ||||
| // 2. coupon | // 2. coupon | ||||
| Integer subsidyRate = 0; | Integer subsidyRate = 0; | ||||
| WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId()); | |||||
| WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId(),cardInfo.getTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| logger.error("card's coupon not found: " + cardInfo.getCouponId()); | logger.error("card's coupon not found: " + cardInfo.getCouponId()); | ||||
| throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND); | throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND); | ||||
| @@ -810,7 +810,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| // 2. coupon | // 2. coupon | ||||
| Integer subsidyRate = 0; | Integer subsidyRate = 0; | ||||
| WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId()); | |||||
| WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId(),cardInfo.getTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| logger.error("card's coupon not found: " + cardInfo.getCouponId()); | logger.error("card's coupon not found: " + cardInfo.getCouponId()); | ||||
| throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND); | throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND); | ||||
| @@ -89,7 +89,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| if (orignal.getStatus().equals(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) | if (orignal.getStatus().equals(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) | ||||
| && record.getStatus().equals(EnumCouponChannelStatus.STATUS_THROW_IN.getCode())) { | && record.getStatus().equals(EnumCouponChannelStatus.STATUS_THROW_IN.getCode())) { | ||||
| WxCoupon wxCoupon = wxCouponService.getById(orignal.getCouponId()); | |||||
| WxCoupon wxCoupon = wxCouponService.getById(orignal.getCouponId(),orignal.getTenantId()); | |||||
| if (wxCoupon == null) | if (wxCoupon == null) | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| if (wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF)) | if (wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF)) | ||||
| @@ -214,7 +214,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| WxCouponChannelAddVo vo = new WxCouponChannelAddVo(); | WxCouponChannelAddVo vo = new WxCouponChannelAddVo(); | ||||
| WxCoupon wxCoupon = wxCouponService.getById(couponid); | |||||
| WxCoupon wxCoupon = wxCouponService.getById(couponid,tenantEntity.getTenantId()); | |||||
| if(wxCoupon==null){ | if(wxCoupon==null){ | ||||
| logger.debug(couponid+ErrorCode.COUPON_IS_EMPTY.getMessage()); | logger.debug(couponid+ErrorCode.COUPON_IS_EMPTY.getMessage()); | ||||
| vo.toCouponChannnelVo(null,channelId); | vo.toCouponChannnelVo(null,channelId); | ||||
| @@ -101,7 +101,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { | |||||
| return new ResultData(e.getErrorCode(),e.getMessage()); | return new ResultData(e.getErrorCode(),e.getMessage()); | ||||
| } | } | ||||
| WxCoupon wxCoupon = wxCouponService.getById(record.getCouponId()); | |||||
| WxCoupon wxCoupon = wxCouponService.getById(record.getCouponId(),record.getTenantId()); | |||||
| if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode()) ) { //时间范围 | if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode()) ) { //时间范围 | ||||
| if (new Date().after(wxCoupon.getValidEndDate())) { | if (new Date().after(wxCoupon.getValidEndDate())) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EXPIRED); | return new ResultData(ErrorCode.COUPON_IS_EXPIRED); | ||||
| @@ -274,7 +274,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { | |||||
| // 发放免费券 | // 发放免费券 | ||||
| WxCouponOrder couponOrder = null; | WxCouponOrder couponOrder = null; | ||||
| try { | try { | ||||
| couponOrder = wxOrderService.sendFreeCouponToUser(tempCUser.getId(), wxCoupon.getId(),null,EnumPayWay.PAY_WAY_NOT_UNPAY_BATCH_SEND); | |||||
| couponOrder = wxOrderService.sendFreeCouponToUser(tempCUser.getId(),wxCoupon.getTenantId(), wxCoupon.getId(),null,EnumPayWay.PAY_WAY_NOT_UNPAY_BATCH_SEND); | |||||
| if (couponOrder != null) { | if (couponOrder != null) { | ||||
| wxCouponActionLogService.addOne(couponOrder, wxCoupon.getId(), couponOrder.getId(), EnumCouponSendSendType.INJECT.getCode(), couponInjectId); | wxCouponActionLogService.addOne(couponOrder, wxCoupon.getId(), couponOrder.getId(), EnumCouponSendSendType.INJECT.getCode(), couponInjectId); | ||||
| } | } | ||||
| @@ -359,7 +359,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| public WxCouponOrder verify(WxCouponOrder couponOrder, WxMerchantBUser bUser) { | public WxCouponOrder verify(WxCouponOrder couponOrder, WxMerchantBUser bUser) { | ||||
| // 1. 获取券信息 | // 1. 获取券信息 | ||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId()); | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId()); | |||||
| if (wxCoupon == null) { | if (wxCoupon == null) { | ||||
| logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId()); | logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId()); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | ||||
| @@ -545,7 +545,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| } | } | ||||
| public void recordAfterVerified(WxCouponOrder couponOrder, Long merchantId) { | public void recordAfterVerified(WxCouponOrder couponOrder, Long merchantId) { | ||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId()); | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId()); | |||||
| WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy(); | WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy(); | ||||
| if (couponOrder.getCouponType().equals(EnumCouponType.COUPON_PRESS.getCode()) | if (couponOrder.getCouponType().equals(EnumCouponType.COUPON_PRESS.getCode()) | ||||
| && couponOrder.getCouponPrice().equals(wxCoupon.getSalePrice())) { | && couponOrder.getCouponPrice().equals(wxCoupon.getSalePrice())) { | ||||
| @@ -646,7 +646,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| // coupon | // coupon | ||||
| WxCoupon coupon; | WxCoupon coupon; | ||||
| try { | try { | ||||
| coupon = wxCouponMapper.selectById(couponOrder.getCouponId()); | |||||
| coupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("查找卡券错误: " + "CouponId:" + couponMerchantQ.getProductId()); | logger.error("查找卡券错误: " + "CouponId:" + couponMerchantQ.getProductId()); | ||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | ||||
| @@ -753,7 +753,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | ||||
| } | } | ||||
| // 2. get coupon info | // 2. get coupon info | ||||
| WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId()); | |||||
| WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId(),order.getTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| logger.error("找不到券信息"); | logger.error("找不到券信息"); | ||||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | ||||
| @@ -1274,7 +1274,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public WxPayOrder microPayPreVerify(WxOrder microOrder, WxCouponOrder couponOrder, WxMerchantBUser bUser, Integer payPrice, EnumPayWay payWay,String ipstr,String authCode) { | public WxPayOrder microPayPreVerify(WxOrder microOrder, WxCouponOrder couponOrder, WxMerchantBUser bUser, Integer payPrice, EnumPayWay payWay,String ipstr,String authCode) { | ||||
| // 1. 获取券信息 | // 1. 获取券信息 | ||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId()); | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId()); | |||||
| if (wxCoupon == null) { | if (wxCoupon == null) { | ||||
| logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId()); | logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId()); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | ||||
| @@ -1453,7 +1453,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| int num = wxCouponOrderMapper.updateById(updateCouponOrder); | int num = wxCouponOrderMapper.updateById(updateCouponOrder); | ||||
| if (num == 1) { | if (num == 1) { | ||||
| WxCouponOrder couponOrder = wxCouponOrderMapper.selectById(couponOrderId); | WxCouponOrder couponOrder = wxCouponOrderMapper.selectById(couponOrderId); | ||||
| WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId()); | |||||
| WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId(),bUser.getTenantId()); | |||||
| doAfterVerify(couponOrder, bUser, coupon); | doAfterVerify(couponOrder, bUser, coupon); | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| @@ -1471,7 +1471,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| if (num == 1) { | if (num == 1) { | ||||
| WxCouponOrder couponOrder = wxCouponOrderMapper.selectById(couponOrderId); | WxCouponOrder couponOrder = wxCouponOrderMapper.selectById(couponOrderId); | ||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(couponOrder.getcUserId()); | WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(couponOrder.getcUserId()); | ||||
| WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId()); | |||||
| WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId()); | |||||
| doAfterVerify(couponOrder, coupon, wxCUserBasicInfo); | doAfterVerify(couponOrder, coupon, wxCUserBasicInfo); | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| @@ -181,7 +181,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| } | } | ||||
| //更新库存 | //更新库存 | ||||
| wxCouponService.reduceRemainInventory(wxCouponOfDb.getId(), merchantLnventory); | |||||
| wxCouponService.reduceRemainInventory(wxCouponOfDb.getId(),wxCouponOfDb.getTenantId(), merchantLnventory); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -210,7 +210,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| } | } | ||||
| //退回coupon库存 | //退回coupon库存 | ||||
| if(merchantRemain!=0) { | if(merchantRemain!=0) { | ||||
| wxCouponService.backRemainInventory(queryById.getId(), merchantRemain, wxCouponOfDb.getRemainInventory()); | |||||
| wxCouponService.backRemainInventory(queryById.getId(),wxCouponOfDb.getTenantId(), merchantRemain, wxCouponOfDb.getRemainInventory()); | |||||
| } | } | ||||
| } | } | ||||
| wxCouponSendMapper.updateById(record); | wxCouponSendMapper.updateById(record); | ||||
| @@ -369,7 +369,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| // 发放免费券 | // 发放免费券 | ||||
| WxCouponOrder couponOrder = null; | WxCouponOrder couponOrder = null; | ||||
| try { | try { | ||||
| couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, send.getCouponId(), null,payWay); | |||||
| couponOrder = wxOrderService.sendFreeCouponToUser(cUserId,send.getTenantId(), send.getCouponId(), null,payWay); | |||||
| if (couponOrder != null) { | if (couponOrder != null) { | ||||
| bRet = true; | bRet = true; | ||||
| @@ -639,7 +639,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| } | } | ||||
| couponSendList.forEach(cs -> { | couponSendList.forEach(cs -> { | ||||
| // 发放免费券 | // 发放免费券 | ||||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, cs.getCouponId(), cs,payWay); | |||||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cUserId,cs.getTenantId(), cs.getCouponId(), cs,payWay); | |||||
| if (couponOrder != null) { | if (couponOrder != null) { | ||||
| wxCouponActionLogService.addOne(couponOrder, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); | wxCouponActionLogService.addOne(couponOrder, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); | ||||
| sendMsgForSendCoupon(couponOrder, cs, couponOrder, wxCUserBasicInfo); | sendMsgForSendCoupon(couponOrder, cs, couponOrder, wxCUserBasicInfo); | ||||
| @@ -178,19 +178,18 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxCoupon getById(Long id) { | |||||
| // TODO 富文本优化 | |||||
| return wxCouponMapper.selectById(id); | |||||
| public WxCoupon getById(Long id,String tenantId) { | |||||
| return wxCouponMapper.selectById(id,tenantId); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxCoupon getHtmlById(Long id) { | |||||
| return wxCouponMapper.selectById(id); | |||||
| public WxCoupon getHtmlById(Long id,String tenantId) { | |||||
| return wxCouponMapper.selectById(id,tenantId); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxCouponCVo getVoById(Long id) { | |||||
| WxCouponCVo wxCouponCVo = wxCouponMapper.findVoDetail(id); | |||||
| public WxCouponCVo getVoById(Long id,String tenantId) { | |||||
| WxCouponCVo wxCouponCVo = wxCouponMapper.findVoDetail(id,tenantId); | |||||
| List<WxMerchantVo> merchantList = wxCouponCVo.getMerchantVoList(); | List<WxMerchantVo> merchantList = wxCouponCVo.getMerchantVoList(); | ||||
| if (merchantList != null) { | if (merchantList != null) { | ||||
| merchantList = merchantList.stream().filter( | merchantList = merchantList.stream().filter( | ||||
| @@ -202,8 +201,8 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxCouponCVo getVoStatusById(Long id) { | |||||
| WxCouponCVo wxCouponCVo = wxCouponMapper.findVoStatusDetail(id); | |||||
| public WxCouponCVo getVoStatusById(Long id,String tenantId) { | |||||
| WxCouponCVo wxCouponCVo = wxCouponMapper.findVoStatusDetail(id,tenantId); | |||||
| return wxCouponCVo; | return wxCouponCVo; | ||||
| } | } | ||||
| @@ -390,7 +389,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| } else { | } else { | ||||
| if(record.getInventory() != null && record.getRemainInventory() != null) { | if(record.getInventory() != null && record.getRemainInventory() != null) { | ||||
| // 库存修改检查 | // 库存修改检查 | ||||
| WxCoupon oldCoupon = wxCouponMapper.selectById(record.getId()); | |||||
| WxCoupon oldCoupon = wxCouponMapper.selectById(record.getId(),record.getTenantId()); | |||||
| if (Objects.equals(oldCoupon.getRemainInventory(), record.getRemainInventory())) { | if (Objects.equals(oldCoupon.getRemainInventory(), record.getRemainInventory())) { | ||||
| // 库存未变, 不更新库存 | // 库存未变, 不更新库存 | ||||
| record.setRemainInventory(null); | record.setRemainInventory(null); | ||||
| @@ -493,8 +492,8 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void deleteById(Long id) { | |||||
| wxCouponMapper.deleteById(id); | |||||
| public void deleteById(Long id,String tenantId) { | |||||
| wxCouponMapper.deleteById(id,tenantId); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -624,7 +623,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| // 3. check 新的有效期是否合适 | // 3. check 新的有效期是否合适 | ||||
| // 4. 更新库存及有效期 | // 4. 更新库存及有效期 | ||||
| boolean bChanged = false; | boolean bChanged = false; | ||||
| WxCoupon oldCoupon = wxCouponMapper.selectById(wxCoupon.getId()); | |||||
| WxCoupon oldCoupon = wxCouponMapper.selectById(wxCoupon.getId(),wxCoupon.getTenantId()); | |||||
| if(oldCoupon == null) { | if(oldCoupon == null) { | ||||
| logger.error(ErrorCode.COUPON_IS_EMPTY.getMessage()); | logger.error(ErrorCode.COUPON_IS_EMPTY.getMessage()); | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| @@ -733,8 +732,8 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| @Override | @Override | ||||
| @Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | @Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | ||||
| public void reduceRemainInventory(Long id, Integer number) { | |||||
| int num = wxCouponMapper.reduceInventory(id, number); | |||||
| public void reduceRemainInventory(Long id,String tenantId, Integer number) { | |||||
| int num = wxCouponMapper.reduceInventory(id,tenantId, number); | |||||
| if (num == 0) { | if (num == 0) { | ||||
| throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); | throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); | ||||
| } | } | ||||
| @@ -742,8 +741,8 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| @Override | @Override | ||||
| @Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | @Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | ||||
| public void backRemainInventory(Long id, Integer number, Integer remainInventory) { | |||||
| int num = wxCouponMapper.backInventory(id, number, remainInventory); | |||||
| public void backRemainInventory(Long id,String tenantId, Integer number, Integer remainInventory) { | |||||
| int num = wxCouponMapper.backInventory(id,tenantId, number, remainInventory); | |||||
| if (num == 0) { | if (num == 0) { | ||||
| throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL); | throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL); | ||||
| } | } | ||||
| @@ -751,8 +750,8 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| @Override | @Override | ||||
| @Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | @Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | ||||
| public ResultData cardDefer(Long id,Date validEndDate) { | |||||
| WxCoupon coupon = wxCouponMapper.selectById(id); | |||||
| public ResultData cardDefer(Long id,String tenantId,Date validEndDate) { | |||||
| WxCoupon coupon = wxCouponMapper.selectById(id,tenantId); | |||||
| if (null == coupon) { | if (null == coupon) { | ||||
| return new ResultData(Result.ERROR,id+"未查询到券信息."); | return new ResultData(Result.ERROR,id+"未查询到券信息."); | ||||
| } | } | ||||
| @@ -1120,7 +1120,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| msgReplaceMap.put("contract", businessId.toString()); | msgReplaceMap.put("contract", businessId.toString()); | ||||
| }else if(isCoupon(flowType)){ | }else if(isCoupon(flowType)){ | ||||
| wxMsgRecord.setModelType(EnumMsgModel.FLOW_C_APPLY_NODIFY.getCode()); | wxMsgRecord.setModelType(EnumMsgModel.FLOW_C_APPLY_NODIFY.getCode()); | ||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(businessId); | |||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(Long.parseLong(businessId),tenantEntity.getTenantId()); | |||||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | ||||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | msgReplaceMap.put("name",wxCoupon.getTitle()); | ||||
| }else if(isSettle(flowType)){ | }else if(isSettle(flowType)){ | ||||
| @@ -1147,7 +1147,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| msgReplaceMap.put("contract", businessId.toString()); | msgReplaceMap.put("contract", businessId.toString()); | ||||
| }else if(isCoupon(flowType)){ | }else if(isCoupon(flowType)){ | ||||
| mailMsg.setModelType(EnumMailMsgModel.MAIL_C_APPLY_NODIFY.getCode()); | mailMsg.setModelType(EnumMailMsgModel.MAIL_C_APPLY_NODIFY.getCode()); | ||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(businessId); | |||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(Long.parseLong(businessId),tenantEntity.getTenantId()); | |||||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | ||||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | msgReplaceMap.put("name",wxCoupon.getTitle()); | ||||
| }else if(isSettle(flowType)){ | }else if(isSettle(flowType)){ | ||||
| @@ -1184,7 +1184,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| msgReplaceMap.put("contract", businessId.toString()); | msgReplaceMap.put("contract", businessId.toString()); | ||||
| }else if(isCoupon(flowType)){ | }else if(isCoupon(flowType)){ | ||||
| wxMsgRecord.setModelType(EnumMsgModel.FLOW_C_PASS_NODIFY.getCode()); | wxMsgRecord.setModelType(EnumMsgModel.FLOW_C_PASS_NODIFY.getCode()); | ||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(businessId); | |||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(Long.parseLong(businessId),tenantEntity.getTenantId()); | |||||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | ||||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | msgReplaceMap.put("name",wxCoupon.getTitle()); | ||||
| }else if(isSettle(flowType)){ | }else if(isSettle(flowType)){ | ||||
| @@ -1211,7 +1211,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| msgReplaceMap.put("contract", businessId.toString()); | msgReplaceMap.put("contract", businessId.toString()); | ||||
| }else if(isCoupon(flowType)){ | }else if(isCoupon(flowType)){ | ||||
| mailMsg.setModelType(EnumMailMsgModel.MAIL_C_PASS_NODIFY.getCode()); | mailMsg.setModelType(EnumMailMsgModel.MAIL_C_PASS_NODIFY.getCode()); | ||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(businessId); | |||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(Long.parseLong(businessId),tenantEntity.getTenantId()); | |||||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | ||||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | msgReplaceMap.put("name",wxCoupon.getTitle()); | ||||
| }else if(isSettle(flowType)){ | }else if(isSettle(flowType)){ | ||||
| @@ -1337,7 +1337,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| msgReplaceMap.put("contract", businessId.toString()); | msgReplaceMap.put("contract", businessId.toString()); | ||||
| } else if (isCoupon(flowType)) { | } else if (isCoupon(flowType)) { | ||||
| wxMsgRecord.setModelType(EnumMsgModel.FLOW_C_REJECT_NODIFY.getCode()); | wxMsgRecord.setModelType(EnumMsgModel.FLOW_C_REJECT_NODIFY.getCode()); | ||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(businessId); | |||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(Long.parseLong(businessId),tenantEntity.getTenantId()); | |||||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | ||||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | msgReplaceMap.put("name",wxCoupon.getTitle()); | ||||
| }else if (isSettle(flowType)) { | }else if (isSettle(flowType)) { | ||||
| @@ -1372,7 +1372,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| msgReplaceMap.put("contract", businessId.toString()); | msgReplaceMap.put("contract", businessId.toString()); | ||||
| }else if(isCoupon(flowType)){ | }else if(isCoupon(flowType)){ | ||||
| mailMsg.setModelType(EnumMailMsgModel.MAIL_C_REJECT_NODIFY.getCode()); | mailMsg.setModelType(EnumMailMsgModel.MAIL_C_REJECT_NODIFY.getCode()); | ||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(businessId); | |||||
| WxCoupon wxCoupon = this.wxCouponMapper.selectById(Long.parseLong(businessId),tenantEntity.getTenantId()); | |||||
| msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | msgReplaceMap.put("type",EnumCouponType.getEnum(wxCoupon.getType()).getMessage()); | ||||
| msgReplaceMap.put("name",wxCoupon.getTitle()); | msgReplaceMap.put("name",wxCoupon.getTitle()); | ||||
| }else if(isSettle(flowType)){ | }else if(isSettle(flowType)){ | ||||
| @@ -294,7 +294,7 @@ public class WxGameServiceImpl implements WxGameService { | |||||
| public void saveOrUpdateCouponChannel(Long couponId, Map<Long, WxCouponChannel> wxCouponChannelsMap, WxGame record){ | public void saveOrUpdateCouponChannel(Long couponId, Map<Long, WxCouponChannel> wxCouponChannelsMap, WxGame record){ | ||||
| WxCoupon wxCoupon = wxCouponService.getById(couponId); | |||||
| WxCoupon wxCoupon = wxCouponService.getById(couponId,record.getTenantId()); | |||||
| if (wxCoupon == null) { | if (wxCoupon == null) { | ||||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -384,7 +384,7 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { | |||||
| Long id = wxOrderGroup.getId(); | Long id = wxOrderGroup.getId(); | ||||
| WxOrderGroup group = wxOrderGroupMapper.selectById(id); | WxOrderGroup group = wxOrderGroupMapper.selectById(id); | ||||
| if (group != null && group.getStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING.getCode())) { | if (group != null && group.getStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING.getCode())) { | ||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(wxOrderGroup.getCouponId()); | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(wxOrderGroup.getCouponId(),group.getTenantId()); | |||||
| Integer status = wxCoupon.getStatus(); | Integer status = wxCoupon.getStatus(); | ||||
| if (status.equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { | if (status.equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { | ||||
| group.setStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode()); | group.setStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode()); | ||||
| @@ -156,7 +156,7 @@ public class WxOrderPressServiceImpl implements WxOrderPressService { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | ||||
| } | } | ||||
| // 2. get coupon info | // 2. get coupon info | ||||
| WxCoupon coupon = wxCouponMapper.selectById(order.getProductId()); | |||||
| WxCoupon coupon = wxCouponMapper.selectById(order.getProductId(),order.getTenantId()); | |||||
| if (order == null) { | if (order == null) { | ||||
| logger.error("找不到券信息"); | logger.error("找不到券信息"); | ||||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | ||||
| @@ -56,7 +56,6 @@ import com.iformall.domain.po.WxPayAccount; | |||||
| import com.iformall.domain.po.WxPayOrder; | import com.iformall.domain.po.WxPayOrder; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.po.msg.FmInsideOrderSuccessMsg; | import com.iformall.domain.po.msg.FmInsideOrderSuccessMsg; | ||||
| import com.iformall.domain.po.msg.UpdateCouponStockMsg; | |||||
| import com.iformall.domain.vo.WxCouponSendVo; | import com.iformall.domain.vo.WxCouponSendVo; | ||||
| import com.iformall.domain.vo.WxMerchantVo; | import com.iformall.domain.vo.WxMerchantVo; | ||||
| import com.iformall.domain.vo.WxOrderCouponPressVo; | import com.iformall.domain.vo.WxOrderCouponPressVo; | ||||
| @@ -593,7 +592,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| boolean stocksetlock = redisLock.lock("couponLockStockSet_"+coupon.getId(), timeStr); | boolean stocksetlock = redisLock.lock("couponLockStockSet_"+coupon.getId(), timeStr); | ||||
| if (stocksetlock) { | if (stocksetlock) { | ||||
| if (!redisLock.hasCouponStockCache(coupon.getId())) { | if (!redisLock.hasCouponStockCache(coupon.getId())) { | ||||
| WxCoupon cou = wxCouponMapper.selectById(coupon.getId()); | |||||
| WxCoupon cou = wxCouponMapper.selectById(coupon.getId(),coupon.getTenantId()); | |||||
| if (null == cou) { | if (null == cou) { | ||||
| redisLock.unlock("couponLockStockSet_"+coupon.getId(), timeStr); | redisLock.unlock("couponLockStockSet_"+coupon.getId(), timeStr); | ||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"未查询到券!"+coupon.getId()); | throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"未查询到券!"+coupon.getId()); | ||||
| @@ -660,7 +659,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| try { | try { | ||||
| //减库存,从redis中取,然后发mq消息同步到数据库 | //减库存,从redis中取,然后发mq消息同步到数据库 | ||||
| wxCouponService.reduceRemainInventory(coupon.getId(), 1); | |||||
| wxCouponService.reduceRemainInventory(coupon.getId(),coupon.getTenantId(), 1); | |||||
| long stock = redisLock.decrease(EnumCacheKey.COUPON_STOCK.getMessage()+coupon.getId(), 1); | long stock = redisLock.decrease(EnumCacheKey.COUPON_STOCK.getMessage()+coupon.getId(), 1); | ||||
| if (stock < 0 ) { | if (stock < 0 ) { | ||||
| @@ -784,7 +783,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| } | } | ||||
| WxCoupon coupon = null; | WxCoupon coupon = null; | ||||
| try { | try { | ||||
| coupon = wxCouponMapper.selectById(couponId); | |||||
| coupon = wxCouponMapper.selectById(couponId,updateOrder.getTenantId()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("券未找到, e:" + e.getMessage()); | logger.error("券未找到, e:" + e.getMessage()); | ||||
| redisLock.unlock(couponIdStr, timeStr); | redisLock.unlock(couponIdStr, timeStr); | ||||
| @@ -797,7 +796,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| } | } | ||||
| try { | try { | ||||
| int num = wxCouponMapper.backInventory(coupon.getId(), 1, coupon.getRemainInventory()); | |||||
| int num = wxCouponMapper.backInventory(coupon.getId(),coupon.getTenantId(), 1, coupon.getRemainInventory()); | |||||
| if (num <= 0) { | if (num <= 0) { | ||||
| logger.error("此券加库存失败, couponId: " + couponIdStr); | logger.error("此券加库存失败, couponId: " + couponIdStr); | ||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券couponId:["+couponIdStr+"]库存回滚失败,更新记录条数小于等于0."); | throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券couponId:["+couponIdStr+"]库存回滚失败,更新记录条数小于等于0."); | ||||
| @@ -1236,7 +1235,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.NESTED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.NESTED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public WxCouponOrder sendFreeCouponToUser(Long userId, Long couponId, WxCouponSendVo wxCouponSendVo,EnumPayWay payWay) { | |||||
| public WxCouponOrder sendFreeCouponToUser(Long userId,String tenantId, Long couponId, WxCouponSendVo wxCouponSendVo,EnumPayWay payWay) { | |||||
| // check 用户状态 | // check 用户状态 | ||||
| WxCUserBasicInfo user = null; | WxCUserBasicInfo user = null; | ||||
| try { | try { | ||||
| @@ -1251,7 +1250,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| // 检查券状态 | // 检查券状态 | ||||
| String couponIdStr = String.valueOf(couponId); | String couponIdStr = String.valueOf(couponId); | ||||
| WxCoupon coupon = wxCouponMapper.selectById(couponId); | |||||
| WxCoupon coupon = wxCouponMapper.selectById(couponId,tenantId); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| logger.error("券不存在, couponId: " + couponIdStr); | logger.error("券不存在, couponId: " + couponIdStr); | ||||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | ||||
| @@ -1331,7 +1330,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| public int couponOrderSuccess(WxOrder updateOrder) { | public int couponOrderSuccess(WxOrder updateOrder) { | ||||
| Date currentDate = new Date(); | Date currentDate = new Date(); | ||||
| // 检查券相关 | // 检查券相关 | ||||
| WxCoupon coupon = wxCouponMapper.selectById(updateOrder.getProductId()); | |||||
| WxCoupon coupon = wxCouponMapper.selectById(updateOrder.getProductId(),updateOrder.getTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| logger.error("券不存在, couponId: " + updateOrder.getProductId()); | logger.error("券不存在, couponId: " + updateOrder.getProductId()); | ||||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | ||||
| @@ -1388,7 +1387,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Override | @Override | ||||
| public void sendOrderSuccessActionMsg(WxOrder updateOrder) { | public void sendOrderSuccessActionMsg(WxOrder updateOrder) { | ||||
| // 检查券相关 | // 检查券相关 | ||||
| WxCoupon coupon = wxCouponMapper.selectById(updateOrder.getProductId()); | |||||
| WxCoupon coupon = wxCouponMapper.selectById(updateOrder.getProductId(),updateOrder.getTenantId()); | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| logger.error("券不存在, couponId: " + updateOrder.getProductId()); | logger.error("券不存在, couponId: " + updateOrder.getProductId()); | ||||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | ||||
| @@ -130,7 +130,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| wxPayOrderMapper.updateById(oldRecord); | wxPayOrderMapper.updateById(oldRecord); | ||||
| //处理其他信息 | //处理其他信息 | ||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(order.getProductId()); | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(order.getProductId(),order.getTenantId()); | |||||
| if(wxCoupon != null) { | if(wxCoupon != null) { | ||||
| if (isOrderGroupCoupon(oldRecord, wxCoupon)) { | if (isOrderGroupCoupon(oldRecord, wxCoupon)) { | ||||
| // 如果是Coupon是拼团, 创建拼团信息, 不创建COUPON_ORDER | // 如果是Coupon是拼团, 创建拼团信息, 不创建COUPON_ORDER | ||||
| @@ -250,7 +250,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| } | } | ||||
| } | } | ||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(order.getProductId()); | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(order.getProductId(),order.getTenantId()); | |||||
| if (wxCoupon.getType().equals(EnumCouponType.COUPON_GROUP.getCode()) && | if (wxCoupon.getType().equals(EnumCouponType.COUPON_GROUP.getCode()) && | ||||
| wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { | wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { | ||||
| logger.error("券已经下架了>>>" + order.getProductId()); | logger.error("券已经下架了>>>" + order.getProductId()); | ||||
| @@ -824,7 +824,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| return; | return; | ||||
| } | } | ||||
| Long productId = order.getProductId(); | Long productId = order.getProductId(); | ||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(productId); | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(productId,order.getTenantId()); | |||||
| if(wxCoupon != null) { | if(wxCoupon != null) { | ||||
| if (isOrderGroupCoupon(record, wxCoupon)) { | if (isOrderGroupCoupon(record, wxCoupon)) { | ||||
| // 如果是Coupon是拼团, 创建拼团信息, 不创建COUPON_ORDER | // 如果是Coupon是拼团, 创建拼团信息, 不创建COUPON_ORDER | ||||
| @@ -94,7 +94,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||||
| private boolean isMerchantOrder(WxOrder wxOrder, Long merchantId) { | private boolean isMerchantOrder(WxOrder wxOrder, Long merchantId) { | ||||
| if (wxOrder.getType().equals(EnumOrderType.COUPON.getCode())) { | if (wxOrder.getType().equals(EnumOrderType.COUPON.getCode())) { | ||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(wxOrder.getProductId()); | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(wxOrder.getProductId(),wxOrder.getTenantId()); | |||||
| if (wxCoupon != null) { | if (wxCoupon != null) { | ||||
| WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | ||||
| wxCouponMerchant.setProductId(wxCoupon.getId()); | wxCouponMerchant.setProductId(wxCoupon.getId()); | ||||
| @@ -122,7 +122,7 @@ public class WxTopicServiceImpl implements WxTopicService { | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| String[] couponArray = couponId.split("-"); | String[] couponArray = couponId.split("-"); | ||||
| //保存coupon_channel | //保存coupon_channel | ||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(Long.parseLong(couponArray[1])); | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(Long.parseLong(couponArray[1]),record.getTenantId()); | |||||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | WxCouponChannel wxCouponChannel = new WxCouponChannel(); | ||||
| wxCouponChannel.setId(idWorker.nextId()); | wxCouponChannel.setId(idWorker.nextId()); | ||||
| wxCouponChannel.setBeginTime(record.getBeginTime()); | wxCouponChannel.setBeginTime(record.getBeginTime()); | ||||
| @@ -68,7 +68,7 @@ public class FmInsideOrderSuccessMsgServiceImpl implements MsgSendService { | |||||
| logger.error("用户未找到: " + msg.getCUserId()); | logger.error("用户未找到: " + msg.getCUserId()); | ||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "用户未找到" + msg.getCUserId()); | throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "用户未找到" + msg.getCUserId()); | ||||
| } | } | ||||
| WxCoupon coupon = couponService.getById(msg.getCouponId()); | |||||
| WxCoupon coupon = couponService.getById(msg.getCouponId(),couponChannel.getTenantId()); | |||||
| if(coupon == null) { | if(coupon == null) { | ||||
| logger.error("券未找到" + msg.getCouponId()); | logger.error("券未找到" + msg.getCouponId()); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL.getCode(), "券未找到" + msg.getCouponId()); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL.getCode(), "券未找到" + msg.getCouponId()); | ||||
| @@ -6,7 +6,6 @@ import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.iformall.domain.po.msg.BaseMsg; | import com.iformall.domain.po.msg.BaseMsg; | ||||
| import com.iformall.domain.po.msg.UpdateCouponStockMsg; | |||||
| import com.iformall.enums.EnumPayWay; | import com.iformall.enums.EnumPayWay; | ||||
| import com.iformall.service.WxCouponService; | import com.iformall.service.WxCouponService; | ||||
| import com.iformall.service.msg.MsgSendService; | import com.iformall.service.msg.MsgSendService; | ||||
| @@ -25,11 +24,11 @@ public class UpdateCouponStockMsgServiceImpl implements MsgSendService { | |||||
| @Override | @Override | ||||
| public void send(BaseMsg baseMsg) throws Exception { | public void send(BaseMsg baseMsg) throws Exception { | ||||
| UpdateCouponStockMsg msg = (UpdateCouponStockMsg)baseMsg; | |||||
| if (null != msg ) { | |||||
| if (msg.getOperateType().equals(UpdateCouponStockMsg.OPERATE_TYPE_DECREASE)) { | |||||
| wxCouponService.reduceRemainInventory(msg.getCouponId(), (int)msg.getNumber()); | |||||
| } | |||||
| } | |||||
| // UpdateCouponStockMsg msg = (UpdateCouponStockMsg)baseMsg; | |||||
| // if (null != msg ) { | |||||
| // if (msg.getOperateType().equals(UpdateCouponStockMsg.OPERATE_TYPE_DECREASE)) { | |||||
| // wxCouponService.reduceRemainInventory(msg.getCouponId(), (int)msg.getNumber()); | |||||
| // } | |||||
| // } | |||||
| } | } | ||||
| } | } | ||||
| @@ -292,6 +292,15 @@ | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | <if test=" null != sortColumns">order by ${sortColumns}</if> | ||||
| </sql> | </sql> | ||||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns"/> from wx_coupon c where id = #{id} and tenant_id = #{tenantId} | |||||
| </select> | |||||
| <delete id="deleteById" parameterType="java.util.HashMap"> | |||||
| update wx_coupon set is_del = 1 where id = #{id} and tenant_id = #{tenantId} | |||||
| </delete> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap"> | <select id="findList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap"> | ||||
| select | select | ||||
| <include refid="allColumns"/> | <include refid="allColumns"/> | ||||
| @@ -654,25 +663,25 @@ | |||||
| <result column="source_type" jdbcType="INTEGER" property="sourceType"/> | <result column="source_type" jdbcType="INTEGER" property="sourceType"/> | ||||
| </resultMap> | </resultMap> | ||||
| <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap"> | |||||
| <select id="findVoDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMap"> | |||||
| select | select | ||||
| <include refid="allColumns"/> | <include refid="allColumns"/> | ||||
| from wx_coupon c | from wx_coupon c | ||||
| where id = #{id} | |||||
| where id = #{id} and tenant_id =#{tenantId} | |||||
| </select> | </select> | ||||
| <select id="findVoStatusDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMapL"> | |||||
| <select id="findVoStatusDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMapL"> | |||||
| select id, remain_inventory, status | select id, remain_inventory, status | ||||
| from wx_coupon | from wx_coupon | ||||
| where id = #{id} | |||||
| where id = #{id} and tenant_id =#{tenantId} | |||||
| </select> | </select> | ||||
| <update id="reduceInventory"> | <update id="reduceInventory"> | ||||
| update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory - #{number} >= 0 | |||||
| update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory - #{number} >= 0 | |||||
| </update> | </update> | ||||
| <update id="backInventory"> | <update id="backInventory"> | ||||
| update wx_coupon SET remain_inventory = remain_inventory + #{number} where id = #{id} and remain_inventory + #{number} <= inventory | |||||
| update wx_coupon SET remain_inventory = remain_inventory + #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory + #{number} <= inventory | |||||
| </update> | </update> | ||||
| <update id="offExpiriedCouponByValidDate"> | <update id="offExpiriedCouponByValidDate"> | ||||
| @@ -171,7 +171,7 @@ public class DataInitController extends BaseController { | |||||
| List<WxCouponOrder> coList = couponOrderMapper.findListOfVerifiedByDate(dateMap); | List<WxCouponOrder> coList = couponOrderMapper.findListOfVerifiedByDate(dateMap); | ||||
| // 2 重新计算积分,比较是否需要修复 | // 2 重新计算积分,比较是否需要修复 | ||||
| coList.forEach(co -> { | coList.forEach(co -> { | ||||
| WxCoupon coupon = couponMapper.selectById(co.getCouponId()); | |||||
| WxCoupon coupon = couponMapper.selectById(co.getCouponId(),co.getTenantId()); | |||||
| WxMerchantBUser buUser = merchantBUserMapper.selectById(co.getBUserId()); | WxMerchantBUser buUser = merchantBUserMapper.selectById(co.getBUserId()); | ||||