|
|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.extra.servlet.ServletUtil;
|
|
|
import cn.hutool.http.Header;
|
|
|
@@ -49,6 +50,7 @@ import com.cyksj.service.relation.GroupsRelationNetflixService;
|
|
|
import com.cyksj.service.sys.SysConfigService;
|
|
|
import com.cyksj.service.user.UserBenefitsService;
|
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
|
+import com.cyksj.service.user.UserService;
|
|
|
import com.cyksj.task.JobManager;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.param.Operator;
|
|
|
@@ -94,6 +96,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
private final BeanSearcher beanSearcher;
|
|
|
|
|
|
+ private final UserService userService;
|
|
|
+
|
|
|
private final GroupsMapper groupsMapper;
|
|
|
|
|
|
private final JobManager jobManager;
|
|
|
@@ -169,21 +173,40 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("goods_status_down"));
|
|
|
}
|
|
|
Boolean isNoLogin = payRequest.getIsNoLogin();
|
|
|
- User user;
|
|
|
+ User user = null;
|
|
|
String payOpenId = null;
|
|
|
Long relationId = 0L;
|
|
|
+ Long userId = payRequest.getUserId();
|
|
|
+ Long goodsId = goodsDon.getId();
|
|
|
+ if (userId != null) {
|
|
|
+ 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(I18nMessageUtil.getI18nMsg("order_noPayment_error"));
|
|
|
+ }
|
|
|
+ }
|
|
|
GroupsRelation relation = null;
|
|
|
-
|
|
|
- if (isNoLogin != null && isNoLogin) {
|
|
|
+ String orderPhone = payRequest.getPhone();
|
|
|
+ if (StrUtil.isNotBlank(orderPhone)) {
|
|
|
+ user = saveOrGetOrderPhoneUser(payRequest);
|
|
|
+ userId = user.getId();
|
|
|
+ payRequest.setUserId(userId);
|
|
|
+ isNoLogin = false;
|
|
|
+ }
|
|
|
+ if (userId == null) {
|
|
|
user = new User();
|
|
|
user.setId(0l);
|
|
|
+ isNoLogin = true;
|
|
|
} else {
|
|
|
- user = userMapper.selectById(payRequest.getUserId());
|
|
|
+ user = userMapper.selectById(userId);
|
|
|
if (user == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
- if (user.getIsBlack()) throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("user_black_error"));
|
|
|
- //ChatGPT Plus账号限购校验
|
|
|
- checkChatGPTPlusPurchaseLimit(user.getId(), goodsDon.getId(), goodsDon.getTitle(), sku.getId(), sku.getSpecVal());
|
|
|
+ if (user.getIsBlack())
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("user_black_error"));
|
|
|
payOpenId = user.getOpenId();
|
|
|
+ if (sku != null) {
|
|
|
+ //ChatGPT Plus账号限购校验
|
|
|
+ checkChatGPTPlusPurchaseLimit(user.getId(), goodsDon.getId(), goodsDon.getTitle(), sku.getId(), sku.getSpecVal());
|
|
|
+ }
|
|
|
if (goodsDon.getType() == 1) {
|
|
|
//获取座位
|
|
|
relation = getRelation(payRequest, sku);
|
|
|
@@ -431,8 +454,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
throw new BusinessRuntimeException(I18nMessageUtil.getI18nMsg("params_error"));
|
|
|
}
|
|
|
//是否有其他规格的续费订单 若有请先关闭
|
|
|
+ //是否有其他规格的续费订单 若有请先关闭
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, user);
|
|
|
Integer count = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getRelationId, payRequest.getRelationId())
|
|
|
+ .in(OrderDon::getUserId, userIdList)
|
|
|
.eq(OrderDon::getStatus, OrderDon.Status.noPayment).eq(OrderDon::getOrderType, 2));
|
|
|
if (count > 0) {
|
|
|
throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("order_renew_ticket_noPayment_error"));
|
|
|
@@ -1241,4 +1267,27 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDonLocationRelate.setIp(ip);
|
|
|
orderDonLocationRelateMapper.insert(orderDonLocationRelate);
|
|
|
}
|
|
|
+
|
|
|
+ public User saveOrGetOrderPhoneUser(OrderPayRequest payRequest) {
|
|
|
+ String orderPhone = payRequest.getPhone();
|
|
|
+ User user = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
|
|
|
+ .eq(User::getLoginPhone, orderPhone).last("limit 1"));
|
|
|
+ if (user == null) {
|
|
|
+ user = new User();
|
|
|
+ StringBuilder name = new StringBuilder();
|
|
|
+ name.append(Constant.DEFAULT_NAME);
|
|
|
+ user.setPopularizeId(payRequest.getPopularizeId());
|
|
|
+ user.setLoginPhone(orderPhone);
|
|
|
+ user.setNickname(String.format("%s%s", name.toString(), RandomUtil.randomString(6)));
|
|
|
+ //默认头像
|
|
|
+ user.setHeadimgurl(Constant.DEFAULT_HEAD_IMG);
|
|
|
+ String registerEnv = null;
|
|
|
+ user.setRegisterEnv(StrUtil.isEmpty(registerEnv) ? User.RegisterEnv.pc.name() : registerEnv);
|
|
|
+ userMapper.insert(user);
|
|
|
+ if (StrUtil.isEmpty(user.getShowId())) {
|
|
|
+ user.setShowId(userService.getUserShowId(user.getId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return user;
|
|
|
+ }
|
|
|
}
|