|
|
|
@@ -123,6 +123,13 @@ public class PosServiceImpl implements PosService { |
|
|
|
logger.error(errMessage); |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); |
|
|
|
} |
|
|
|
|
|
|
|
PosMallConfig config = posMallConfigService.getByTenantId(tenantId); |
|
|
|
if (config == null) { |
|
|
|
logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isBlank(merchantIdStr)) { |
|
|
|
String errMessage = "request params[merchant_id] error."; |
|
|
|
logger.error(errMessage); |
|
|
|
@@ -179,12 +186,6 @@ public class PosServiceImpl implements PosService { |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
PosMallConfig config = posMallConfigService.getByTenantId(tenantId); |
|
|
|
if (config == null) { |
|
|
|
logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); |
|
|
|
} |
|
|
|
|
|
|
|
Integer discount = 100; |
|
|
|
if (config.getDiscount().equals(EnumEnableType.Enable.getCode())) { |
|
|
|
|
|
|
|
@@ -221,34 +222,38 @@ public class PosServiceImpl implements PosService { |
|
|
|
Double remainAmountD = posAmount * 1.0D * discount / 100; |
|
|
|
long remainAmount = Math.round(remainAmountD); |
|
|
|
|
|
|
|
// 优惠券列表 |
|
|
|
if (config.getCoupon().equals(EnumEnableType.Enable.getCode())) { |
|
|
|
Map<String, Object> coQ = new HashMap<>(); |
|
|
|
coQ.put("tenantId", tenantId); |
|
|
|
coQ.put("cUserId", user.getId()); |
|
|
|
coQ.put("merchantId", merchantId); |
|
|
|
coQ.put("posOrderId", posOrderId); |
|
|
|
List<Map> couponOrderList = couponOrderService.findAvailCouponOrder(coQ); |
|
|
|
if (couponOrderList.size() > 0) { |
|
|
|
retMap.put(WxPayConstant.AVAIL_CO_LIST, |
|
|
|
JSONArray.toJSONString( |
|
|
|
couponOrderList |
|
|
|
.stream() |
|
|
|
.filter(co -> |
|
|
|
(co.get("type") == EnumCouponType.COUPON_MULTIMCH.getCode() || |
|
|
|
co.get("type") == EnumCouponType.COUPON_MANJIAN.getCode() || |
|
|
|
co.get("type") == EnumCouponType.COUPON_DAIJIN.getCode() |
|
|
|
)) |
|
|
|
.collect(Collectors.toList()) |
|
|
|
)); |
|
|
|
} else { |
|
|
|
retMap.put(WxPayConstant.AVAIL_CO_LIST, "[]"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
retMap.put(WxPayConstant.AVAIL_CO_LIST, "[]"); |
|
|
|
} |
|
|
|
|
|
|
|
retMap.put(WxPayConstant.MEM_ID, user.getId().toString()); |
|
|
|
retMap.put(WxPayConstant.MEM_PHONE, user.getPhone()); |
|
|
|
retMap.put(WxPayConstant.ORG_AMOUNT, posAmountStr); |
|
|
|
retMap.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(remainAmount)); |
|
|
|
|
|
|
|
// 优惠券列表 |
|
|
|
Map<String, Object> coQ = new HashMap<>(); |
|
|
|
coQ.put("tenantId", tenantId); |
|
|
|
coQ.put("cUserId", user.getId()); |
|
|
|
coQ.put("merchantId", merchantId); |
|
|
|
coQ.put("posOrderId", posOrderId); |
|
|
|
List<Map> couponOrderList = couponOrderService.findAvailCouponOrder(coQ); |
|
|
|
if (couponOrderList.size() > 0) { |
|
|
|
retMap.put(WxPayConstant.AVAIL_CO_LIST, |
|
|
|
JSONArray.toJSONString( |
|
|
|
couponOrderList |
|
|
|
.stream() |
|
|
|
.filter(co -> |
|
|
|
(co.get("type") == EnumCouponType.COUPON_MULTIMCH.getCode() || |
|
|
|
co.get("type") == EnumCouponType.COUPON_MANJIAN.getCode() || |
|
|
|
co.get("type") == EnumCouponType.COUPON_DAIJIN.getCode() |
|
|
|
)) |
|
|
|
.collect(Collectors.toList()) |
|
|
|
)); |
|
|
|
} else { |
|
|
|
retMap.put(WxPayConstant.AVAIL_CO_LIST, "[]"); |
|
|
|
} |
|
|
|
return retMap; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -270,6 +275,15 @@ public class PosServiceImpl implements PosService { |
|
|
|
logger.error(errMessage); |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); |
|
|
|
} |
|
|
|
PosMallConfig config = posMallConfigService.getByTenantId(tenantId); |
|
|
|
if (config == null) { |
|
|
|
logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); |
|
|
|
} |
|
|
|
if (!config.getCoupon().equals(EnumEnableType.Enable.getCode())) { |
|
|
|
logger.error(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(merchantIdStr)) { |
|
|
|
String errMessage = "request params[merchant_id] error."; |
|
|
|
logger.error(errMessage); |
|
|
|
@@ -388,6 +402,15 @@ public class PosServiceImpl implements PosService { |
|
|
|
logger.error(errMessage); |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); |
|
|
|
} |
|
|
|
PosMallConfig config = posMallConfigService.getByTenantId(tenantId); |
|
|
|
if (config == null) { |
|
|
|
logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); |
|
|
|
} |
|
|
|
if (!config.getCoupon().equals(EnumEnableType.Enable.getCode())) { |
|
|
|
logger.error(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(merchantIdStr)) { |
|
|
|
String errMessage = "request params[merchant_id] error."; |
|
|
|
logger.error(errMessage); |
|
|
|
|