Browse Source

Merge branch 'release_real_202010' of https://git.malls.iformall.com/server/formallProject into release_real_202010

release_toaliyun_real
xhxu 5 years ago
parent
commit
6a658548ea
42 changed files with 139 additions and 160 deletions
  1. +1
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCampaignController.java
  2. +5
    -5
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java
  3. +1
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponPresentController.java
  4. +1
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java
  5. +1
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxOrderController.java
  6. +2
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/mem/MemCouponController.java
  7. +2
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java
  8. +5
    -5
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java
  9. +2
    -2
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java
  10. +1
    -1
      mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java
  11. +4
    -4
      mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java
  12. +2
    -2
      mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java
  13. +1
    -1
      mallinkCApi/src/main/java/com/iformall/controller/WxCouponPasswordController.java
  14. +2
    -2
      mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java
  15. +1
    -1
      mallinkCApi/src/main/java/com/iformall/controller/WxPayOrderController.java
  16. +1
    -1
      mallinkCApi/src/main/java/com/iformall/controller/WxPressOrderController.java
  17. +4
    -4
      mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java
  18. +2
    -2
      mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java
  19. +0
    -31
      mallinkService/src/main/java/com/iformall/domain/po/msg/UpdateCouponStockMsg.java
  20. +8
    -4
      mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java
  21. +8
    -8
      mallinkService/src/main/java/com/iformall/service/WxCouponService.java
  22. +1
    -1
      mallinkService/src/main/java/com/iformall/service/WxOrderService.java
  23. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/MemCouponFromDspServiceImpl.java
  24. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java
  25. +4
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java
  26. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java
  27. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponInjectServiceImpl.java
  28. +7
    -7
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
  29. +4
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java
  30. +18
    -19
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java
  31. +6
    -6
      mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java
  32. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java
  33. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderGroupServiceImpl.java
  34. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderPressServiceImpl.java
  35. +8
    -9
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  36. +3
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java
  37. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java
  38. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java
  39. +1
    -1
      mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideOrderSuccessMsgServiceImpl.java
  40. +6
    -7
      mallinkService/src/main/java/com/iformall/service/msg/impl/UpdateCouponStockMsgServiceImpl.java
  41. +15
    -6
      mallinkService/src/main/resources/mapper/WxCouponMapper.xml
  42. +1
    -1
      mallinkSysAdmin/src/main/java/com/iformall/controller/datafix/DataInitController.java

+ 1
- 1
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCampaignController.java View File

@@ -125,7 +125,7 @@ public class WxCampaignController extends BaseController {
for (String couponIdStr : ids) {
Long couponId = Long.parseLong(couponIdStr);

WxCoupon wxCoupon = wxCouponService.getById(couponId);
WxCoupon wxCoupon = wxCouponService.getById(couponId,campaign.getTenantId());
if (wxCoupon == null) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}


+ 5
- 5
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java View File

@@ -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) {
return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId());
}
@@ -289,7 +289,7 @@ public class WxCouponController extends BaseController {
@SystemControllerLog(description = "券投放-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::delete");
wxCouponService.deleteById(id);
wxCouponService.deleteById(id,getTenantInfo().getTenantId());
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@@ -299,7 +299,7 @@ public class WxCouponController extends BaseController {
@SystemControllerLog(description = "券投放-查询")
public ResultData findById(@RequestParam Long id) {
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 = "券投放-富文本获取")
public ResultData getHtml(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById");
return new ResultData(wxCouponService.getHtmlById(id));
return new ResultData(wxCouponService.getHtmlById(id,getTenantInfo().getTenantId()));
}
@ApiOperation("卡延期")
@@ -409,7 +409,7 @@ public class WxCouponController extends BaseController {
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()));
}

}

+ 1
- 1
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponPresentController.java View File

@@ -97,7 +97,7 @@ public class WxCouponPresentController extends BaseController {
logger.error(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 (new Date().after(wxCoupon.getValidEndDate())) {
return new ResultData(ErrorCode.COUPON_IS_EXPIRED);


+ 1
- 1
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java View File

@@ -106,7 +106,7 @@ public class WxCouponSendController extends BaseController {
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())) {
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF);
}


+ 1
- 1
mallinkAdmin/src/main/java/com/iformall/controller/market/WxOrderController.java View File

@@ -180,7 +180,7 @@ public class WxOrderController extends BaseController {
user.setOperatorType(EnumUserType.MALLUSER.getCode());
user.setOperatorId(getUserId());
WxOrder order = null;
WxCoupon coupon = wxCouponService.getById(couponId);
WxCoupon coupon = wxCouponService.getById(couponId,wxCouponChannel.getTenantId());
if (coupon == null) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}


+ 2
- 2
mallinkAdmin/src/main/java/com/iformall/controller/mem/MemCouponController.java View File

@@ -101,7 +101,7 @@ public class MemCouponController extends BaseController {
memCouponFromDsp.setCouponId(couponChannel.getCouponId());
}
// 1. 检查券是否已超限, 无剩余库存
WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId());
WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId(),memCouponFromDsp.getTenantId());
if (coupon == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId());
}
@@ -144,7 +144,7 @@ public class MemCouponController extends BaseController {
memCouponFromDsp.setCouponId(couponChannel.getCouponId());
}
// 1. 检查券是否已超限, 无剩余库存
WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId());
WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId(),couponChannel.getTenantId());
if (coupon == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId());
}


+ 2
- 2
mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java View File

@@ -246,7 +246,7 @@ public class WxCUserBasicInfoController extends BaseController {
if (page.getSize() > 0) {
List<WxCouponOrder> list = page.getList();
for (WxCouponOrder c : list) {
WxCoupon coupon = wxCouponService.getById(c.getCouponId());
WxCoupon coupon = wxCouponService.getById(c.getCouponId(),c.getTenantId());
c.setCouponName(coupon.getTitle());
c.setSalePrice(coupon.getPrice());

@@ -276,7 +276,7 @@ public class WxCUserBasicInfoController extends BaseController {
//if (page.getSize() > 0) {
List<WxCouponOrder> list = page.getList();
for (WxCouponOrder c : list) {
WxCoupon coupon = wxCouponService.getById(c.getCouponId());
WxCoupon coupon = wxCouponService.getById(c.getCouponId(),c.getTenantId());
c.setCouponName(coupon.getTitle());
c.setSalePrice(coupon.getPrice());
}


+ 5
- 5
mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java View File

@@ -164,7 +164,7 @@ public class WxCouponController extends BaseController {
if (wxCoupon.getId() == null) {
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()){
return new ResultData(Result.ERROR,"非B端券,不能进行此操作");
@@ -241,7 +241,7 @@ public class WxCouponController extends BaseController {

wxCoupon.setMerchantParams(JSONObject.toJSONString(merchantList));

WxCoupon coupon = wxCouponService.getById(wxCoupon.getId());
WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),wxCoupon.getTenantId());
if (null == coupon) {
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()+"未配置审批流程");
}
logger.debug("[" + getIpAddr() + "] WxCouponController::delete");
wxCouponService.deleteById(id);
wxCouponService.deleteById(id,getTenantInfo().getTenantId());
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)
public ResultData findById(@RequestParam Long id) {
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)
public ResultData getHtml(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById");
return new ResultData(wxCouponService.getHtmlById(id));
return new ResultData(wxCouponService.getHtmlById(id,getTenantInfo().getTenantId()));
}




+ 2
- 2
mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java View File

@@ -157,7 +157,7 @@ public class WxCouponOrderController extends BaseController {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
} else {
wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId());
wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId(),wxMerchantBUser.getTenantId());
if (wxCouponCVo == null) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
@@ -214,7 +214,7 @@ public class WxCouponOrderController extends BaseController {
}
wxCouponOrderCVo.setHtml(wxCouponCVo.getHtml());
} else {
WxCoupon wxCoupon = wxCouponService.getHtmlById(wxCouponOrderCVo.getCouponId());
WxCoupon wxCoupon = wxCouponService.getHtmlById(wxCouponOrderCVo.getCouponId(),wxCouponOrderCVo.getTenantId());
if (wxCoupon == null) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}


+ 1
- 1
mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java View File

@@ -341,7 +341,7 @@ public class WxCarController extends BaseController {
}
return new ResultData(Result.SUCCESS,"已经使用过优惠券, 不能重复使用.");
} else {
WxCoupon coupon = couponService.getById(userCar.getCouponId());
WxCoupon coupon = couponService.getById(userCar.getCouponId(),park.getFinalTenantId());
if (coupon == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券为空");
}


+ 4
- 4
mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java View File

@@ -86,7 +86,7 @@ public class WxCouponController extends BaseController {
// 库存
if (couponIdL > 0L) {
// 更新状态
WxCouponCVo couponCVo = couponService.getVoStatusById(couponIdL);
WxCouponCVo couponCVo = couponService.getVoStatusById(couponIdL,wxCouponCVo.getTenantId());
if (wxCouponCVo == null) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
@@ -184,7 +184,7 @@ public class WxCouponController extends BaseController {
return null;
}
WxCoupon c = couponService.getById(cc.getCouponId());
WxCoupon c = couponService.getById(cc.getCouponId(),cc.getTenantId());
if (c == null) {
return null;
}
@@ -203,7 +203,7 @@ public class WxCouponController extends BaseController {
return null;
}

WxCoupon c = couponService.getHtmlById(cc.getCouponId());
WxCoupon c = couponService.getHtmlById(cc.getCouponId(),cc.getTenantId());
if (c == null) {
return null;
}
@@ -222,7 +222,7 @@ public class WxCouponController extends BaseController {
return null;
}
WxCoupon c = couponService.getById(cc.getCouponId());
WxCoupon c = couponService.getById(cc.getCouponId(),cc.getTenantId());
if (c == null) {
c = new WxCoupon();
}


+ 2
- 2
mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java View File

@@ -140,7 +140,7 @@ public class WxCouponOrderController extends BaseController {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
} else {
wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId());
wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId(),wxCouponOrderCVo.getTenantId());
if (wxCouponCVo == null) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
@@ -209,7 +209,7 @@ public class WxCouponOrderController extends BaseController {
wxCouponOrderCVo.setContentType(wxCouponCVo.getContentType());
wxCouponOrderCVo.setHtml(wxCouponCVo.getHtml());
} else {
WxCoupon wxCoupon = wxCouponService.getHtmlById(wxCouponOrderCVo.getCouponId());
WxCoupon wxCoupon = wxCouponService.getHtmlById(wxCouponOrderCVo.getCouponId(),wxCouponOrderCVo.getTenantId());
if (wxCoupon == null) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}


+ 1
- 1
mallinkCApi/src/main/java/com/iformall/controller/WxCouponPasswordController.java View File

@@ -80,7 +80,7 @@ public class WxCouponPasswordController extends BaseController {
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) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}


+ 2
- 2
mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java View File

@@ -93,7 +93,7 @@ public class WxOrderController extends BaseController {
return new ResultData(ErrorCode.MEMBER_IS_LOCKED);
}

WxCoupon coupon = wxCouponService.getById(wxCouponChannel.getCouponId());
WxCoupon coupon = wxCouponService.getById(wxCouponChannel.getCouponId(),wxCouponChannel.getTenantId());
if (null == coupon) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
@@ -415,7 +415,7 @@ public class WxOrderController extends BaseController {
}
WxCoupon wxCoupon = null;
try {
wxCoupon = wxCouponService.getById(id);
wxCoupon = wxCouponService.getById(id,getTenantInfo().getTenantId());
} catch (Exception e) {
logger.error("券ID获取券信息失败, couponId: " + couponId);
return new ResultData(ErrorCode.COUPON_IS_EMPTY);


+ 1
- 1
mallinkCApi/src/main/java/com/iformall/controller/WxPayOrderController.java View File

@@ -186,7 +186,7 @@ public class WxPayOrderController extends BaseController {
if (null == order) {
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) {
return new ResultData(ErrorCode.PAY_ORDER_ERROR, "未查询到优惠券[orderId:"+orderId+"].");
}


+ 1
- 1
mallinkCApi/src/main/java/com/iformall/controller/WxPressOrderController.java View File

@@ -113,7 +113,7 @@ public class WxPressOrderController extends BaseController {
wxCouponCVo = cdOperations.get(cdKey);
} else {
// 券信息没有入缓存,需要从数据库中读取
wxCouponCVo = wxCouponService.getVoById(order.getProductId());
wxCouponCVo = wxCouponService.getVoById(order.getProductId(),order.getTenantId());
if (wxCouponCVo != null) {
// 券详情优化,进缓存
couponCVoRedisTemplate.opsForValue().set(cdKey, wxCouponCVo, 3600, TimeUnit.SECONDS);


+ 4
- 4
mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java View File

@@ -460,7 +460,7 @@ public class PosServiceImpl implements PosService {
throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT);
}
// 5. get coupon
WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId());
WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId(),couponOrderCVo.getTenantId());
if (wxCoupon == null) {
logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
@@ -610,7 +610,7 @@ public class PosServiceImpl implements PosService {
}
if (couponSelected) {
// 5. get coupon
WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId());
WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId(),couponOrderCVo.getTenantId());
if (wxCoupon == null) {
logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId());
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);
}
// 5. 核销后无法反向
WxCoupon coupon = couponMapper.selectById(couponOrderCVo.getCouponId());
WxCoupon coupon = couponMapper.selectById(couponOrderCVo.getCouponId(),couponOrderCVo.getTenantId());
if (coupon.getSalePrice() > 0 ||
(coupon.getSubsidyType() > EnumCouponSubsidyType.NO_SUBSIDY.getCode() && coupon.getSubsidyNum() > 0)) {
logger.error("券包ID: " + couponOrderIdStr + "核销无法退回");
@@ -2188,7 +2188,7 @@ public class PosServiceImpl implements PosService {
logger.error("交易核销成长值异常:" + e.getMessage());
}

WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId());
WxCoupon wxCoupon = couponMapper.selectById(couponOrderCVo.getCouponId(),couponOrderCVo.getTenantId());
if (wxCoupon == null) {
logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);


+ 2
- 2
mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java View File

@@ -191,7 +191,7 @@ public class CouponSendSchedule {

// 发放免费券
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());
} catch (Exception e) {
logger.error("定时发券:发券失败 levelId=" + l.getId() + " couponId=" + cs.getCouponId() + " userId=" + cu.getId() + e.getMessage());
@@ -321,7 +321,7 @@ public class CouponSendSchedule {
for (WxCUserBasicInfo cu : newUserList) {
// 发放生日券
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());
couponSendedUsers.add(cu);
} catch (Exception e) {


+ 0
- 31
mallinkService/src/main/java/com/iformall/domain/po/msg/UpdateCouponStockMsg.java View File

@@ -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;
}

+ 8
- 4
mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java View File

@@ -16,13 +16,17 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> {
List<WxCoupon> findList(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();



+ 8
- 8
mallinkService/src/main/java/com/iformall/service/WxCouponService.java View File

@@ -52,14 +52,14 @@ public interface WxCouponService {
* @param id
* @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
*/
void deleteById(Long id);
void deleteById(Long id,String tenantId);


/**
@@ -214,7 +214,7 @@ public interface WxCouponService {
* @param number 减少数量
* @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 remainInventory 当前库存
*/
void backRemainInventory(Long id, Integer number, Integer remainInventory);
void backRemainInventory(Long id,String tenantId, Integer number, Integer remainInventory);
/**
* 卡延期
* @param wxCoupon
* @return
*/
ResultData cardDefer(Long id,Date validEndDate);
ResultData cardDefer(Long id,String tenantId,Date validEndDate);
}

+ 1
- 1
mallinkService/src/main/java/com/iformall/service/WxOrderService.java View File

@@ -86,7 +86,7 @@ public interface WxOrderService {
* @param wxCouponSendVo 商户注券时必须指定
* @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 订单已支付


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/MemCouponFromDspServiceImpl.java View File

@@ -103,7 +103,7 @@ public class MemCouponFromDspServiceImpl implements MemCouponFromDspService {
List<MemCouponFromDsp> couponFromDsps = memCouponFromDspMapper.findList(memQ);
for (MemCouponFromDsp memCouponFromDsp: couponFromDsps) {
// 注入券码, 无论此券是有价还是免费
WxCoupon coupon = couponMapper.selectById(memCouponFromDsp.getCouponId());
WxCoupon coupon = couponMapper.selectById(memCouponFromDsp.getCouponId(),memCouponFromDsp.getTenantId());
if (coupon != null) {
try {
Long couponOrderId = wxOrderService.saveOuterOrderForCoupon(user, coupon, memCouponFromDsp.getCouponChannelId(), null, null);


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java View File

@@ -228,7 +228,7 @@ public class WxCampaignServiceImpl implements WxCampaignService {

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) {
return;
}


+ 4
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java View File

@@ -103,7 +103,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
}
// 2. coupon
Integer subsidyRate = 0;
WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId());
WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId(),cardInfo.getTenantId());
if (coupon == null) {
logger.error("card's coupon not found: " + cardInfo.getCouponId());
return new ResultData(ErrorCode.CARD_IS_NOT_FOUND);
@@ -619,7 +619,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
}
// 2. coupon
Integer subsidyRate = 0;
WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId());
WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId(),cardInfo.getTenantId());
if (coupon == null) {
logger.error("card's coupon not found: " + cardInfo.getCouponId());
throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND);
@@ -720,7 +720,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
}
// 2. coupon
Integer subsidyRate = 0;
WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId());
WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId(),cardInfo.getTenantId());
if (coupon == null) {
logger.error("card's coupon not found: " + cardInfo.getCouponId());
throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND);
@@ -810,7 +810,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {

// 2. coupon
Integer subsidyRate = 0;
WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId());
WxCoupon coupon = wxCouponMapper.selectById(cardInfo.getCouponId(),cardInfo.getTenantId());
if (coupon == null) {
logger.error("card's coupon not found: " + cardInfo.getCouponId());
throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND);


+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java View File

@@ -89,7 +89,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
if (orignal.getStatus().equals(EnumCouponChannelStatus.STATUS_TAKE_OFFF.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)
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
if (wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF))
@@ -214,7 +214,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {

WxCouponChannelAddVo vo = new WxCouponChannelAddVo();

WxCoupon wxCoupon = wxCouponService.getById(couponid);
WxCoupon wxCoupon = wxCouponService.getById(couponid,tenantEntity.getTenantId());
if(wxCoupon==null){
logger.debug(couponid+ErrorCode.COUPON_IS_EMPTY.getMessage());
vo.toCouponChannnelVo(null,channelId);


+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxCouponInjectServiceImpl.java View File

@@ -101,7 +101,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService {
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 (new Date().after(wxCoupon.getValidEndDate())) {
return new ResultData(ErrorCode.COUPON_IS_EXPIRED);
@@ -274,7 +274,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService {
// 发放免费券
WxCouponOrder couponOrder = null;
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) {
wxCouponActionLogService.addOne(couponOrder, wxCoupon.getId(), couponOrder.getId(), EnumCouponSendSendType.INJECT.getCode(), couponInjectId);
}


+ 7
- 7
mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java View File

@@ -359,7 +359,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
public WxCouponOrder verify(WxCouponOrder couponOrder, WxMerchantBUser bUser) {

// 1. 获取券信息
WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId());
WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId());
if (wxCoupon == null) {
logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
@@ -545,7 +545,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
}

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();
if (couponOrder.getCouponType().equals(EnumCouponType.COUPON_PRESS.getCode())
&& couponOrder.getCouponPrice().equals(wxCoupon.getSalePrice())) {
@@ -646,7 +646,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
// coupon
WxCoupon coupon;
try {
coupon = wxCouponMapper.selectById(couponOrder.getCouponId());
coupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId());
} catch (Exception e) {
logger.error("查找卡券错误: " + "CouponId:" + couponMerchantQ.getProductId());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR);
@@ -753,7 +753,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND);
}
// 2. get coupon info
WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId());
WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId(),order.getTenantId());
if (coupon == null) {
logger.error("找不到券信息");
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})
public WxPayOrder microPayPreVerify(WxOrder microOrder, WxCouponOrder couponOrder, WxMerchantBUser bUser, Integer payPrice, EnumPayWay payWay,String ipstr,String authCode) {
// 1. 获取券信息
WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId());
WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId());
if (wxCoupon == null) {
logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
@@ -1453,7 +1453,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
int num = wxCouponOrderMapper.updateById(updateCouponOrder);
if (num == 1) {
WxCouponOrder couponOrder = wxCouponOrderMapper.selectById(couponOrderId);
WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId());
WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId(),bUser.getTenantId());
doAfterVerify(couponOrder, bUser, coupon);
}
return 0;
@@ -1471,7 +1471,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
if (num == 1) {
WxCouponOrder couponOrder = wxCouponOrderMapper.selectById(couponOrderId);
WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(couponOrder.getcUserId());
WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId());
WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId());
doAfterVerify(couponOrder, coupon, wxCUserBasicInfo);
}
return 0;


+ 4
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java View File

@@ -181,7 +181,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
}

//更新库存
wxCouponService.reduceRemainInventory(wxCouponOfDb.getId(), merchantLnventory);
wxCouponService.reduceRemainInventory(wxCouponOfDb.getId(),wxCouponOfDb.getTenantId(), merchantLnventory);
}

@Override
@@ -210,7 +210,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
}
//退回coupon库存
if(merchantRemain!=0) {
wxCouponService.backRemainInventory(queryById.getId(), merchantRemain, wxCouponOfDb.getRemainInventory());
wxCouponService.backRemainInventory(queryById.getId(),wxCouponOfDb.getTenantId(), merchantRemain, wxCouponOfDb.getRemainInventory());
}
}
wxCouponSendMapper.updateById(record);
@@ -369,7 +369,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
// 发放免费券
WxCouponOrder couponOrder = null;
try {
couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, send.getCouponId(), null,payWay);
couponOrder = wxOrderService.sendFreeCouponToUser(cUserId,send.getTenantId(), send.getCouponId(), null,payWay);
if (couponOrder != null) {
bRet = true;

@@ -639,7 +639,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
}
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) {
wxCouponActionLogService.addOne(couponOrder, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId());
sendMsgForSendCoupon(couponOrder, cs, couponOrder, wxCUserBasicInfo);


+ 18
- 19
mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java View File

@@ -178,19 +178,18 @@ public class WxCouponServiceImpl implements WxCouponService {
}

@Override
public WxCoupon getById(Long id) {
// TODO 富文本优化
return wxCouponMapper.selectById(id);
public WxCoupon getById(Long id,String tenantId) {
return wxCouponMapper.selectById(id,tenantId);
}

@Override
public WxCoupon getHtmlById(Long id) {
return wxCouponMapper.selectById(id);
public WxCoupon getHtmlById(Long id,String tenantId) {
return wxCouponMapper.selectById(id,tenantId);
}

@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();
if (merchantList != null) {
merchantList = merchantList.stream().filter(
@@ -202,8 +201,8 @@ public class WxCouponServiceImpl implements WxCouponService {
}

@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;
}

@@ -390,7 +389,7 @@ public class WxCouponServiceImpl implements WxCouponService {
} else {
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())) {
// 库存未变, 不更新库存
record.setRemainInventory(null);
@@ -493,8 +492,8 @@ public class WxCouponServiceImpl implements WxCouponService {
}

@Override
public void deleteById(Long id) {
wxCouponMapper.deleteById(id);
public void deleteById(Long id,String tenantId) {
wxCouponMapper.deleteById(id,tenantId);
}

@Override
@@ -624,7 +623,7 @@ public class WxCouponServiceImpl implements WxCouponService {
// 3. check 新的有效期是否合适
// 4. 更新库存及有效期
boolean bChanged = false;
WxCoupon oldCoupon = wxCouponMapper.selectById(wxCoupon.getId());
WxCoupon oldCoupon = wxCouponMapper.selectById(wxCoupon.getId(),wxCoupon.getTenantId());
if(oldCoupon == null) {
logger.error(ErrorCode.COUPON_IS_EMPTY.getMessage());
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
@@ -733,8 +732,8 @@ public class WxCouponServiceImpl implements WxCouponService {

@Override
@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) {
throw new MallinkException(ErrorCode.ORDER_SAVE_ERR);
}
@@ -742,8 +741,8 @@ public class WxCouponServiceImpl implements WxCouponService {

@Override
@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) {
throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL);
}
@@ -751,8 +750,8 @@ public class WxCouponServiceImpl implements WxCouponService {

@Override
@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) {
return new ResultData(Result.ERROR,id+"未查询到券信息.");
}


+ 6
- 6
mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java View File

@@ -1120,7 +1120,7 @@ public class WxFlowServiceImpl implements WxFlowService {
msgReplaceMap.put("contract", businessId.toString());
}else if(isCoupon(flowType)){
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("name",wxCoupon.getTitle());
}else if(isSettle(flowType)){
@@ -1147,7 +1147,7 @@ public class WxFlowServiceImpl implements WxFlowService {
msgReplaceMap.put("contract", businessId.toString());
}else if(isCoupon(flowType)){
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("name",wxCoupon.getTitle());
}else if(isSettle(flowType)){
@@ -1184,7 +1184,7 @@ public class WxFlowServiceImpl implements WxFlowService {
msgReplaceMap.put("contract", businessId.toString());
}else if(isCoupon(flowType)){
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("name",wxCoupon.getTitle());
}else if(isSettle(flowType)){
@@ -1211,7 +1211,7 @@ public class WxFlowServiceImpl implements WxFlowService {
msgReplaceMap.put("contract", businessId.toString());
}else if(isCoupon(flowType)){
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("name",wxCoupon.getTitle());
}else if(isSettle(flowType)){
@@ -1337,7 +1337,7 @@ public class WxFlowServiceImpl implements WxFlowService {
msgReplaceMap.put("contract", businessId.toString());
} else if (isCoupon(flowType)) {
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("name",wxCoupon.getTitle());
}else if (isSettle(flowType)) {
@@ -1372,7 +1372,7 @@ public class WxFlowServiceImpl implements WxFlowService {
msgReplaceMap.put("contract", businessId.toString());
}else if(isCoupon(flowType)){
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("name",wxCoupon.getTitle());
}else if(isSettle(flowType)){


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java View File

@@ -294,7 +294,7 @@ public class WxGameServiceImpl implements WxGameService {

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) {
throw new MallinkException(ErrorCode.COUPON_IS_EMPTY);
}


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxOrderGroupServiceImpl.java View File

@@ -384,7 +384,7 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService {
Long id = wxOrderGroup.getId();
WxOrderGroup group = wxOrderGroupMapper.selectById(id);
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();
if (status.equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) {
group.setStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode());


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxOrderPressServiceImpl.java View File

@@ -156,7 +156,7 @@ public class WxOrderPressServiceImpl implements WxOrderPressService {
throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND);
}
// 2. get coupon info
WxCoupon coupon = wxCouponMapper.selectById(order.getProductId());
WxCoupon coupon = wxCouponMapper.selectById(order.getProductId(),order.getTenantId());
if (order == null) {
logger.error("找不到券信息");
throw new MallinkException(ErrorCode.COUPON_IS_EMPTY);


+ 8
- 9
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java View File

@@ -56,7 +56,6 @@ import com.iformall.domain.po.WxPayAccount;
import com.iformall.domain.po.WxPayOrder;
import com.iformall.domain.po.base.TenantEntity;
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.WxMerchantVo;
import com.iformall.domain.vo.WxOrderCouponPressVo;
@@ -593,7 +592,7 @@ public class WxOrderServiceImpl implements WxOrderService {
boolean stocksetlock = redisLock.lock("couponLockStockSet_"+coupon.getId(), timeStr);
if (stocksetlock) {
if (!redisLock.hasCouponStockCache(coupon.getId())) {
WxCoupon cou = wxCouponMapper.selectById(coupon.getId());
WxCoupon cou = wxCouponMapper.selectById(coupon.getId(),coupon.getTenantId());
if (null == cou) {
redisLock.unlock("couponLockStockSet_"+coupon.getId(), timeStr);
throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"未查询到券!"+coupon.getId());
@@ -660,7 +659,7 @@ public class WxOrderServiceImpl implements WxOrderService {

try {
//减库存,从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);
if (stock < 0 ) {
@@ -784,7 +783,7 @@ public class WxOrderServiceImpl implements WxOrderService {
}
WxCoupon coupon = null;
try {
coupon = wxCouponMapper.selectById(couponId);
coupon = wxCouponMapper.selectById(couponId,updateOrder.getTenantId());
} catch (Exception e) {
logger.error("券未找到, e:" + e.getMessage());
redisLock.unlock(couponIdStr, timeStr);
@@ -797,7 +796,7 @@ public class WxOrderServiceImpl implements WxOrderService {
}

try {
int num = wxCouponMapper.backInventory(coupon.getId(), 1, coupon.getRemainInventory());
int num = wxCouponMapper.backInventory(coupon.getId(),coupon.getTenantId(), 1, coupon.getRemainInventory());
if (num <= 0) {
logger.error("此券加库存失败, couponId: " + couponIdStr);
throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券couponId:["+couponIdStr+"]库存回滚失败,更新记录条数小于等于0.");
@@ -1236,7 +1235,7 @@ public class WxOrderServiceImpl implements WxOrderService {

@Override
@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 用户状态
WxCUserBasicInfo user = null;
try {
@@ -1251,7 +1250,7 @@ public class WxOrderServiceImpl implements WxOrderService {

// 检查券状态
String couponIdStr = String.valueOf(couponId);
WxCoupon coupon = wxCouponMapper.selectById(couponId);
WxCoupon coupon = wxCouponMapper.selectById(couponId,tenantId);
if (coupon == null) {
logger.error("券不存在, couponId: " + couponIdStr);
throw new MallinkException(ErrorCode.COUPON_IS_EMPTY);
@@ -1331,7 +1330,7 @@ public class WxOrderServiceImpl implements WxOrderService {
public int couponOrderSuccess(WxOrder updateOrder) {
Date currentDate = new Date();
// 检查券相关
WxCoupon coupon = wxCouponMapper.selectById(updateOrder.getProductId());
WxCoupon coupon = wxCouponMapper.selectById(updateOrder.getProductId(),updateOrder.getTenantId());
if (coupon == null) {
logger.error("券不存在, couponId: " + updateOrder.getProductId());
throw new MallinkException(ErrorCode.COUPON_IS_EMPTY);
@@ -1388,7 +1387,7 @@ public class WxOrderServiceImpl implements WxOrderService {
@Override
public void sendOrderSuccessActionMsg(WxOrder updateOrder) {
// 检查券相关
WxCoupon coupon = wxCouponMapper.selectById(updateOrder.getProductId());
WxCoupon coupon = wxCouponMapper.selectById(updateOrder.getProductId(),updateOrder.getTenantId());
if (coupon == null) {
logger.error("券不存在, couponId: " + updateOrder.getProductId());
throw new MallinkException(ErrorCode.COUPON_IS_EMPTY);


+ 3
- 3
mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java View File

@@ -130,7 +130,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
wxPayOrderMapper.updateById(oldRecord);
//处理其他信息
WxCoupon wxCoupon = wxCouponMapper.selectById(order.getProductId());
WxCoupon wxCoupon = wxCouponMapper.selectById(order.getProductId(),order.getTenantId());
if(wxCoupon != null) {
if (isOrderGroupCoupon(oldRecord, wxCoupon)) {
// 如果是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()) &&
wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) {
logger.error("券已经下架了>>>" + order.getProductId());
@@ -824,7 +824,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
return;
}
Long productId = order.getProductId();
WxCoupon wxCoupon = wxCouponMapper.selectById(productId);
WxCoupon wxCoupon = wxCouponMapper.selectById(productId,order.getTenantId());
if(wxCoupon != null) {
if (isOrderGroupCoupon(record, wxCoupon)) {
// 如果是Coupon是拼团, 创建拼团信息, 不创建COUPON_ORDER


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java View File

@@ -94,7 +94,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {

private boolean isMerchantOrder(WxOrder wxOrder, Long merchantId) {
if (wxOrder.getType().equals(EnumOrderType.COUPON.getCode())) {
WxCoupon wxCoupon = wxCouponMapper.selectById(wxOrder.getProductId());
WxCoupon wxCoupon = wxCouponMapper.selectById(wxOrder.getProductId(),wxOrder.getTenantId());
if (wxCoupon != null) {
WxCouponMerchant wxCouponMerchant = new WxCouponMerchant();
wxCouponMerchant.setProductId(wxCoupon.getId());


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java View File

@@ -122,7 +122,7 @@ public class WxTopicServiceImpl implements WxTopicService {
final IdWorker idWorker = IdWorker.get();
String[] couponArray = couponId.split("-");
//保存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.setId(idWorker.nextId());
wxCouponChannel.setBeginTime(record.getBeginTime());


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideOrderSuccessMsgServiceImpl.java View File

@@ -68,7 +68,7 @@ public class FmInsideOrderSuccessMsgServiceImpl implements MsgSendService {
logger.error("用户未找到: " + 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) {
logger.error("券未找到" + msg.getCouponId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL.getCode(), "券未找到" + msg.getCouponId());


+ 6
- 7
mallinkService/src/main/java/com/iformall/service/msg/impl/UpdateCouponStockMsgServiceImpl.java View File

@@ -6,7 +6,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iformall.domain.po.msg.BaseMsg;
import com.iformall.domain.po.msg.UpdateCouponStockMsg;
import com.iformall.enums.EnumPayWay;
import com.iformall.service.WxCouponService;
import com.iformall.service.msg.MsgSendService;
@@ -25,11 +24,11 @@ public class UpdateCouponStockMsgServiceImpl implements MsgSendService {

@Override
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());
// }
// }
}
}

+ 15
- 6
mallinkService/src/main/resources/mapper/WxCouponMapper.xml View File

@@ -292,6 +292,15 @@
<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 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
<include refid="allColumns"/>
@@ -654,25 +663,25 @@
<result column="source_type" jdbcType="INTEGER" property="sourceType"/>
</resultMap>

<select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap">
<select id="findVoDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMap">
select
<include refid="allColumns"/>
from wx_coupon c
where id = #{id}
where id = #{id} and tenant_id =#{tenantId}
</select>

<select id="findVoStatusDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMapL">
<select id="findVoStatusDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMapL">
select id, remain_inventory, status
from wx_coupon
where id = #{id}
where id = #{id} and tenant_id =#{tenantId}
</select>

<update id="reduceInventory">
update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory - #{number} &gt;= 0
update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory - #{number} &gt;= 0
</update>

<update id="backInventory">
update wx_coupon SET remain_inventory = remain_inventory + #{number} where id = #{id} and remain_inventory + #{number} &lt;= inventory
update wx_coupon SET remain_inventory = remain_inventory + #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory + #{number} &lt;= inventory
</update>

<update id="offExpiriedCouponByValidDate">


+ 1
- 1
mallinkSysAdmin/src/main/java/com/iformall/controller/datafix/DataInitController.java View File

@@ -171,7 +171,7 @@ public class DataInitController extends BaseController {
List<WxCouponOrder> coList = couponOrderMapper.findListOfVerifiedByDate(dateMap);
// 2 重新计算积分,比较是否需要修复
coList.forEach(co -> {
WxCoupon coupon = couponMapper.selectById(co.getCouponId());
WxCoupon coupon = couponMapper.selectById(co.getCouponId(),co.getTenantId());

WxMerchantBUser buUser = merchantBUserMapper.selectById(co.getBUserId());



Loading…
Cancel
Save