|
|
@@ -16,7 +16,6 @@ import com.alipay.api.request.*;
|
|
|
import com.alipay.api.response.AlipayFundTransCommonQueryResponse;
|
|
|
import com.alipay.api.response.AlipayTradeFastpayRefundQueryResponse;
|
|
|
import com.alipay.api.response.AlipayTradeQueryResponse;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.cyksj.common.EnvCommonService;
|
|
|
@@ -24,6 +23,7 @@ import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.constant.TaskTypeEnum;
|
|
|
import com.cyksj.common.constant.TransferConstant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
+import com.cyksj.common.i18n.I18nMessageUtil;
|
|
|
import com.cyksj.common.snowflake.Sequence;
|
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
import com.cyksj.common.util.Codec;
|
|
|
@@ -220,7 +220,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(payRequest.getSkuId());
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
|
|
|
if (goodsDon == null || !goodsDon.getStatus()) {
|
|
|
- throw new BusinessRuntimeException("商品已下架");
|
|
|
+ throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("goods_status_down"));
|
|
|
}
|
|
|
Boolean isNoLogin = payRequest.getIsNoLogin();
|
|
|
User user;
|
|
|
@@ -233,7 +233,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
} else {
|
|
|
user = userMapper.selectById(payRequest.getUserId());
|
|
|
if (user == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
- if (user.getIsBlack()) throw BusinessRuntimeException.getInstance("系统检测操作异常,请稍后再试");
|
|
|
+ if (user.getIsBlack()) throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("user_black_error"));
|
|
|
//ChatGPT Plus账号限购校验
|
|
|
checkChatGPTPlusPurchaseLimit(user.getId(), goodsDon.getId(), goodsDon.getTitle(), sku.getId(), sku.getSpecVal());
|
|
|
payOpenId = user.getOpenId();
|
|
|
@@ -255,7 +255,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setOrderNo(donNo);
|
|
|
orderDon.setOpenId(payOpenId);
|
|
|
if (sku.getPrice() == null || sku.getPrice().compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("下单商品价格异常");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sku_price_error"));
|
|
|
}
|
|
|
if (payRequest.getDonMoney().compareTo(sku.getPrice()) < 0) {
|
|
|
log.info("规格:{}支付金额:{}异常,调整用户userId:{}支付金额为:{}", sku.getSpecVal(), payRequest.getDonMoney(), user.getId(), sku.getPrice());
|
|
|
@@ -268,14 +268,14 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
List<Long> dpSkuIds = payRequest.getDpSkuIds();
|
|
|
if (CollUtil.isNotEmpty(dpSkuIds)) {
|
|
|
if (dpSkuIds.size() > 1) {
|
|
|
- throw BusinessRuntimeException.getInstance("暂只支持优惠加购一件商品");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("dp_one_goods_pay_error"));
|
|
|
}
|
|
|
//是否满足关联
|
|
|
List<GoodsDiscountPlusPurchaseRelation> ds_relations = discountPlusPurchaseRelationMapper.selectList(Wrappers.lambdaQuery(GoodsDiscountPlusPurchaseRelation.class)
|
|
|
.eq(GoodsDiscountPlusPurchaseRelation::getSkuId, sku.getId())
|
|
|
.in(GoodsDiscountPlusPurchaseRelation::getDisSid, dpSkuIds));
|
|
|
if (ds_relations.size() != dpSkuIds.size()) {
|
|
|
- throw BusinessRuntimeException.getInstance("系统异常,请刷新页面重新下单");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sys_error"));
|
|
|
}
|
|
|
BigDecimal goods_discount_plus_pay = BigDecimal.ZERO;
|
|
|
List<Long> dsSkuIds = new ArrayList<>();
|
|
|
@@ -329,7 +329,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (relationId != 0) {
|
|
|
Long gtSkuId = groupsRelationMapper.getGroupTripsSkuIdByRelationId(relationId);
|
|
|
if (!gtSkuId.equals(orderDon.getSkuId())) {
|
|
|
- throw BusinessRuntimeException.getInstance("车位与车队规格不一致");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sys_error"));
|
|
|
}
|
|
|
}
|
|
|
orderDon.setPayDesc(goodsDon.getPayDesc());
|
|
|
@@ -339,7 +339,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (orderDon.getIsDp()) {
|
|
|
List<GoodsDonSkuView> dp_skuViewList = beanSearcher.searchAll(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getSkuId, dpSkuIds).op(Operator.InList).build());
|
|
|
if (dp_skuViewList.size() != dpSkuIds.size()) {
|
|
|
- throw BusinessRuntimeException.getInstance("系统异常,请刷新页面重新下单");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sys_error"));
|
|
|
}
|
|
|
dp_skuViewList.forEach(dp_SkuView -> {
|
|
|
payTitle.append(" + ");
|
|
|
@@ -629,9 +629,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
updateById(orderDon);
|
|
|
});
|
|
|
if (groupsRelation.getUserId() != 0) {
|
|
|
- User user = userMapper.selectById(orderDon.getUserId());
|
|
|
- if (user != null) {
|
|
|
- checkIsSameUser(groupsRelation.getUserId(), orderDon.getUserId(), user.getOpenId(), user.getLoginPhone());
|
|
|
+ List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(orderDon.getUserId(), null);
|
|
|
+ if (!relationUserIdList.contains(userId)) {
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sys_error"));
|
|
|
}
|
|
|
}
|
|
|
//throw new BusinessRuntimeException("订单用户与车位用户不匹配!");
|
|
|
@@ -676,7 +676,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
Long userId = payRequest.getUserId();
|
|
|
User user = userMapper.selectById(userId);
|
|
|
if (user == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
- if (user.getIsBlack()) throw BusinessRuntimeException.getInstance("系统检测操作异常,请稍后再试");
|
|
|
+ if (user.getIsBlack()) throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("user_black_error"));
|
|
|
Long renewSkuId = payRequest.getSkuId();
|
|
|
CouponUser couponUser = null;
|
|
|
if (StrUtil.isNotBlank(payRequest.getCouponExCode()) || payRequest.getCouponId() != null) {
|
|
|
@@ -686,14 +686,14 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
Long relationId = payRequest.getRelationId();
|
|
|
if (relationId == null || relationId <= 0 || renewSkuId == null || payRequest.getNum() == null) {
|
|
|
- throw new BusinessRuntimeException("缺少必填参数");
|
|
|
+ throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("params_error"));
|
|
|
}
|
|
|
//是否有其他规格的续费订单 若有请先关闭
|
|
|
Integer count = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getRelationId, payRequest.getRelationId())
|
|
|
.eq(OrderDon::getStatus, OrderDon.Status.noPayment).eq(OrderDon::getOrderType, 2));
|
|
|
if (count > 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("您有该车票未支付的续费订单..");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("order_renew_ticket_noPayment_error"));
|
|
|
}
|
|
|
|
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(renewSkuId);
|
|
|
@@ -705,36 +705,39 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
//todo 多账号同一用户绑定 续费
|
|
|
if (!relation.getUserId().equals(user.getId())) {
|
|
|
- checkIsSameUser(relation.getUserId(), userId, user.getOpenId(), user.getLoginPhone());
|
|
|
+ List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(relation.getUserId(), null);
|
|
|
+ if (!relationUserIdList.contains(userId)) {
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sys_error"));
|
|
|
+ }
|
|
|
}
|
|
|
GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
|
|
|
if (groupsTrips == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该车队不存在,请联系客服");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sys_error"));
|
|
|
}
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
|
|
|
|
|
|
if (goodsDon == null || !goodsDon.getStatus()) {
|
|
|
- throw new BusinessRuntimeException("商品已下架");
|
|
|
+ throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("goods_status_down"));
|
|
|
}
|
|
|
|
|
|
if (goodsDon.getType() == 2) {
|
|
|
- throw new BusinessRuntimeException("实物不支持续费");
|
|
|
+ throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("ticket_unsupported_renew_error"));
|
|
|
}
|
|
|
|
|
|
if (goodsDon.getSpecialType() != null && goodsDon.getSpecialType() == GoodsDon.SpecialType.recharge) {
|
|
|
- throw new BusinessRuntimeException("代充账号不允许续费");
|
|
|
+ throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("ticket_unsupported_renew_error"));
|
|
|
}
|
|
|
//用户车票规格
|
|
|
Long tripsSkuId = groupsTrips.getSkuId();
|
|
|
GoodsDonSkuView goodsDonSkuView = beanSearcher.searchFirst(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getGoodsId, goodsDon.getId())
|
|
|
.field(GoodsDonSkuView::getSkuId, tripsSkuId).build());
|
|
|
if (goodsDonSkuView == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该续费规格不属于该车队");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sys_error"));
|
|
|
}
|
|
|
|
|
|
if (GroupsTrips.Status.waiting.equals(groupsTrips.getStatus())) {
|
|
|
if (!noChekGoodsTemp.contains(goodsDon.getTitle())) {
|
|
|
- throw new BusinessRuntimeException("亲,该车次还未发车,需等待客服发车才能续费哦.");
|
|
|
+ throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("account_not_set_unsupport_renew_error"));
|
|
|
}
|
|
|
}
|
|
|
//netflix 续费逻辑 月付可续费所有规格 其他规格只能续费对应规格
|
|
|
@@ -743,13 +746,13 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (goodsDon.getType() == 1 && goodsDon.getId() == 1) {
|
|
|
if (tripsSkuId != 4 && tripsSkuId != renewSkuId) {
|
|
|
if (tripsSkuId == 5) {
|
|
|
- throw BusinessRuntimeException.getInstance("季付车票只能续费季付");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("ticket_netflix_season_renew_error"));
|
|
|
} else if (tripsSkuId == 6) {
|
|
|
- throw BusinessRuntimeException.getInstance("年付车票只能续费年付");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("ticket_netflix_year_renew_error"));
|
|
|
} else {
|
|
|
//天数可续费其他规格
|
|
|
if (goodsDonSkuView.getDays() == null || goodsDonSkuView.getDays() <= 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("请选择对应规格的车票续费");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("ticket_same_renew_error"));
|
|
|
}
|
|
|
}
|
|
|
} else if (tripsSkuId == 4 && tripsSkuId != renewSkuId) {
|
|
|
@@ -938,19 +941,19 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (isLoginPopularize == null || !isLoginPopularize) {
|
|
|
int noPayCount = count(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).eq(OrderDon::getGoodsId, goodsId).eq(OrderDon::getStatus, OrderDon.Status.noPayment.toString()));
|
|
|
if (noPayCount > 0) {
|
|
|
- throw new BusinessRuntimeException("您有未支付订单.");
|
|
|
+ throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("order_noPayment_error"));
|
|
|
}
|
|
|
}
|
|
|
if (!redisService.setNx(RedisKey.GROUPS_RELATION_NUM_KEY + relationId, userId, 60 * 5L)) {
|
|
|
log.info("=====>用户:{}未抢到座位:{}", userId, relationId);
|
|
|
- throw new BusinessRuntimeException("客官手慢啦,该座位已经有人啦!");
|
|
|
+ throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("sys_busy_error"));
|
|
|
}
|
|
|
int count = groupsMapper.decrAvailableNum(groupsId);
|
|
|
if (count == 0) {
|
|
|
log.error("车位异常 groupId:{}", groupsId);
|
|
|
groupsMapper.updateAvailableNum(groupsId);
|
|
|
redisService.del(RedisKey.GROUPS_RELATION_NUM_KEY + relationId);
|
|
|
- throw new BusinessRuntimeException("车位异常");
|
|
|
+ throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("sys_busy_error"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -961,7 +964,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
Address address = addressMapper.selectById(addressId);
|
|
|
if (address == null) {
|
|
|
- throw new BusinessRuntimeException("请添加收货地址.");
|
|
|
+ throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("address_choose_error"));
|
|
|
}
|
|
|
OrderDonTransport transport = new OrderDonTransport();
|
|
|
transport.setOrderId(orderId);
|
|
|
@@ -1091,9 +1094,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
@Override
|
|
|
public void zeroOrderConfirm(Long orderId) {
|
|
|
OrderDon orderDon = this.getById(orderId);
|
|
|
- if (orderDon == null) throw BusinessRuntimeException.getInstance("订单不存在");
|
|
|
+ if (orderDon == null) throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("order_nt"));
|
|
|
if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("订单异常");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("order_error"));
|
|
|
}
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
@@ -1396,22 +1399,22 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
GoodsDonSku goodsDonSku = goodsDonSkuMapper.selectById(skuId);
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(goodsDonSku.getGoodsId());
|
|
|
if (StrUtil.isNotBlank(couponExCode) && couponId != null) {
|
|
|
- throw BusinessRuntimeException.getInstance("优惠券与优惠码不可同时使用..");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_coupon_code_error"));
|
|
|
}
|
|
|
if (StrUtil.isNotBlank(couponExCode)) {
|
|
|
CouponPopularizeDto exists = couponMapper.checkExCode(couponExCode);
|
|
|
if (exists == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠码不存在");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_not_exist"));
|
|
|
}
|
|
|
//推广码
|
|
|
if (exists.getIsGeneral() != null) {
|
|
|
if (exists.getIsGeneral() && userId.equals(exists.getUserId())) {
|
|
|
- throw BusinessRuntimeException.getInstance("不可以使用自己的优惠码");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_own_use_error"));
|
|
|
}
|
|
|
if (!exists.getIsGeneral()) {
|
|
|
UserDistribute userDistribute = userDistributeMapper.selectById(exists.getDistributeId());
|
|
|
if (userDistribute != null && userDistribute.getUserId().equals(userId)) {
|
|
|
- throw BusinessRuntimeException.getInstance("不可以使用自己的优惠码");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_own_use_error"));
|
|
|
}
|
|
|
}
|
|
|
//是否有上下级关系
|
|
|
@@ -1422,35 +1425,35 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
//是否是 当天注册新用户 且下过单
|
|
|
User user = userMapper.selectById(userId);
|
|
|
if (user.getCreatedTime().before(DateUtil.beginOfDay(DateTime.now()))) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠码只适用于新用户");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_new_user_error"));
|
|
|
}
|
|
|
CouponNewUserView couponNewUserView = beanSearcher.searchFirst(CouponNewUserView.class, MapUtils.builder().field(CouponNewUserView::getUserId, userId).op(Operator.Equal).build());
|
|
|
- if (couponNewUserView != null) throw BusinessRuntimeException.getInstance("该优惠码只适用于新用户");
|
|
|
+ if (couponNewUserView != null) throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_new_user_error"));
|
|
|
}
|
|
|
if (userDistributeShared != null && !userDistributeShared.getSharedId().equals(exists.getUserId())) {
|
|
|
- throw BusinessRuntimeException.getInstance("您已有推广,无法使用其他人推广码");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_popularize_repeat_use_error"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
checkCouponGoods(goodsDon, skuId, exists.getCouponId(), true);
|
|
|
//检验是优惠券使用范围
|
|
|
if (isRenew && exists.getUseScope() == Coupon.UseScope.orders) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠码续费时不可使用");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_only_order_error"));
|
|
|
}
|
|
|
if (!isRenew && exists.getUseScope() == Coupon.UseScope.renew) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠码下单时不可使用");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_only_renew_order_error"));
|
|
|
}
|
|
|
if (exists.getScope() == Coupon.Scope.newUser) {
|
|
|
CouponNewUserView couponNewUserView = beanSearcher.searchFirst(CouponNewUserView.class, MapUtils.builder().field(CouponNewUserView::getUserId, userId).op(Operator.Equal).build());
|
|
|
if (couponNewUserView != null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该新用户优惠码有且仅可使用一次");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_new_user_error"));
|
|
|
}
|
|
|
}
|
|
|
if (exists.getIsValidTime() && exists.getValidEndTime().before(DateTime.now())) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠码已失效");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_expired_error"));
|
|
|
}
|
|
|
if (exists.getIsValidTime() && exists.getValidStartTime().after(DateTime.now())) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠码待生效");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_not_effective_error"));
|
|
|
}
|
|
|
return exists;
|
|
|
} else if (couponId != null) {
|
|
|
@@ -1459,10 +1462,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
.field(CouponUserView::getUserId, userId).op(Operator.Equal)
|
|
|
.build());
|
|
|
if (couponUserView == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠券不存在");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_not_exist"));
|
|
|
}
|
|
|
if (couponUserView.getCouponUserStatus() == CouponUser.Status.used) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠券已使用");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_used_error"));
|
|
|
}
|
|
|
couponFontService.setCouponUserStatus(couponUserView, DateTime.now());
|
|
|
if (couponUserView.getCouponUserStatus() != CouponUser.Status.unused) {
|
|
|
@@ -1471,16 +1474,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
checkCouponGoods(goodsDon, skuId, couponUserView.getCouponId(), false);
|
|
|
//检验是优惠券使用范围
|
|
|
if (isRenew && couponUserView.getUseScope() == Coupon.UseScope.orders) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠券续费时不可使用");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_only_order_error"));
|
|
|
}
|
|
|
if (!isRenew && couponUserView.getUseScope() == Coupon.UseScope.renew) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠券下单时不可使用");
|
|
|
- }
|
|
|
- if (couponUserView.getScope() == Coupon.Scope.newUser) {
|
|
|
- CouponNewUserView couponNewUserView = beanSearcher.searchFirst(CouponNewUserView.class, MapUtils.builder().field(CouponNewUserView::getUserId, userId).op(Operator.Equal).build());
|
|
|
- if (couponNewUserView != null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该新用户优惠券有且仅可使用一次");
|
|
|
- }
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_only_renew_error"));
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
@@ -1491,7 +1488,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
CouponUser couponUser = null;
|
|
|
if (StrUtil.isNotBlank(couponExCode)) {
|
|
|
if (exists == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠码不存在");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_not_exist"));
|
|
|
}
|
|
|
couponUser = new CouponUser();
|
|
|
couponUser.setCouponId(exists.getCouponId());
|
|
|
@@ -1503,7 +1500,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if ((exists.getPopularizeId() != null && exists.getIsGeneral()) || exists.getPopularizeId() == null) {
|
|
|
CouponUser received = couponUserMapper.selectOne(Wrappers.lambdaQuery(CouponUser.class).eq(CouponUser::getUserId, userId).eq(CouponUser::getCouponId, couponUser.getCouponId()).last("limit 1"));
|
|
|
if (received != null && received.getStatus() != CouponUser.Status.unused) {
|
|
|
- throw BusinessRuntimeException.getInstance("您已使用该优惠码所对应的优惠券");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_used_error"));
|
|
|
}
|
|
|
couponUser.setUserId(userId);
|
|
|
couponUser.setStatus(CouponUser.Status.used);
|
|
|
@@ -1513,13 +1510,13 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
couponUserMapper.insert(couponUser);
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
log.info("用户已领取该{}优惠券", couponUser.getCouponId());
|
|
|
- throw BusinessRuntimeException.getInstance("您已领取该优惠码对应的优惠券,请使用优惠券");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_code_used_error"));
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
couponUser = couponUserMapper.selectOne(Wrappers.lambdaQuery(CouponUser.class).eq(CouponUser::getUserId, userId).eq(CouponUser::getCouponId, couponId).last("limit 1"));
|
|
|
if (couponUser == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该优惠券不存在");
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_not_exist"));
|
|
|
}
|
|
|
couponUser.setStatus(CouponUser.Status.used);
|
|
|
couponUserMapper.updateById(couponUser);
|
|
|
@@ -1534,7 +1531,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
.eq(CouponSku::getCouponId, couponId)
|
|
|
.select(CouponSku::getId).last("limit 1"));
|
|
|
if (couponSku == null) {
|
|
|
- throw BusinessRuntimeException.getInstance(String.format("该%s不适用于该规格", isCouponCode ? "优惠码" : "优惠券"));
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_sku_not_available_error"));
|
|
|
}
|
|
|
} else {
|
|
|
//实物、潮玩 优惠码优惠券 针对平台
|
|
|
@@ -1544,7 +1541,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
.eq(CouponSku::getCouponId, couponId)
|
|
|
.select(CouponSku::getId).last("limit 1"));
|
|
|
if (couponSku == null) {
|
|
|
- throw BusinessRuntimeException.getInstance(String.format("该%s不可用于该商品", isCouponCode ? "优惠码" : "优惠券"));
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_sku_not_available_error"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1797,41 +1794,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
return noPayment;
|
|
|
}
|
|
|
|
|
|
- public void checkIsSameUser(Long relationUserId, Long userId, String openId, String loginPhone) {
|
|
|
- //手机用户与微信用户
|
|
|
- LambdaQueryWrapper<UserBindDetail> wrapper = Wrappers.lambdaQuery(UserBindDetail.class);
|
|
|
- Boolean isPcUser = false;
|
|
|
- if (StrUtil.isNotBlank(openId)) {
|
|
|
- wrapper.eq(UserBindDetail::getUserId, userId);
|
|
|
- } else {
|
|
|
- isPcUser = true;
|
|
|
- wrapper.eq(UserBindDetail::getPhone, loginPhone);
|
|
|
- }
|
|
|
- UserBindDetail userBindDetail = userBindDetailMapper.selectOne(wrapper.last("limit 1"));
|
|
|
- if (userBindDetail == null) {
|
|
|
- throw new BusinessRuntimeException("");
|
|
|
- }
|
|
|
- if (userBindDetail != null) {
|
|
|
- if (isPcUser) {
|
|
|
- if (!relationUserId.equals(userBindDetail.getUserId())) {
|
|
|
- throw new BusinessRuntimeException("");
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (StrUtil.isEmpty(userBindDetail.getPhone())) {
|
|
|
- throw new BusinessRuntimeException("");
|
|
|
- }
|
|
|
- User otherUser = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
|
|
|
- .eq(User::getLoginPhone, userBindDetail.getPhone()).last("limit 1"));
|
|
|
- if (otherUser == null) {
|
|
|
- throw new BusinessRuntimeException("");
|
|
|
- }
|
|
|
- if (!relationUserId.equals(otherUser.getId())) {
|
|
|
- throw new BusinessRuntimeException("");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 购买Midjourney课程 赠送车票
|
|
|
*/
|
|
|
@@ -1976,7 +1938,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
} else if (coupon.getType() == Coupon.Type.reduce) {
|
|
|
if (goodsType == 2) {
|
|
|
if (skuMoney.compareTo(coupon.getReduceCondition()) < 0) {
|
|
|
- throw BusinessRuntimeException.getInstance(String.format("满%s可用", coupon.getReduceCondition().divide(BigDecimal.valueOf(100))));
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("coupon_reduce_money_not_available_error"));
|
|
|
}
|
|
|
}
|
|
|
BigDecimal subtractMoney = orderDon.getMoney().subtract(coupon.getReduceMoney());
|
|
|
@@ -2001,9 +1963,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
BigDecimal userBalance = user.getBalance();
|
|
|
//扣除余额 是否成功
|
|
|
Integer success = userMapper.deductBalance(user.getId(), subBalance, userBalance);
|
|
|
- if (success != 1) throw BusinessRuntimeException.getInstance("您的余额不足!");
|
|
|
- orderDon.setBalance(balance);
|
|
|
- userBenefitsService.recordBalanceBySource(user.getId(), BigDecimal.valueOf(-balance.longValue()), UserBalanceSourceRecord.Source.payment);
|
|
|
+ if (success != 1) throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("user_balance_not_enough"));
|
|
|
+ orderDon.setBalance(subBalance);
|
|
|
+ userBenefitsService.recordBalanceBySource(user.getId(), BigDecimal.valueOf(-subBalance.longValue()), UserBalanceSourceRecord.Source.payment);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2022,7 +1984,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public void orderNotify(OrderDon orderDon){
|
|
|
+ public void orderNotify(OrderDon orderDon){
|
|
|
Long goodsId = orderDon.getGoodsId();
|
|
|
if (orderDon.getIsNoLogin()) {
|
|
|
orderDon.setExCode(exchangeCodeService.getExCode(goodsId, orderDon.getSkuId(), 1));
|