|
@@ -2,6 +2,7 @@ package com.cyksj.web.controller.group;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
+import cn.hutool.core.date.DateUnit;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
@@ -29,16 +30,17 @@ import com.cyksj.model.dto.QuestionnaireView;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
import com.cyksj.model.request.OrderPayRequest;
|
|
import com.cyksj.model.request.OrderPayRequest;
|
|
|
|
|
+import com.cyksj.model.request.OrderRefundReq;
|
|
|
import com.cyksj.model.request.SpecialGoodsTicketReq;
|
|
import com.cyksj.model.request.SpecialGoodsTicketReq;
|
|
|
import com.cyksj.model.response.GptStandbyResp;
|
|
import com.cyksj.model.response.GptStandbyResp;
|
|
|
import com.cyksj.model.views.*;
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.chatgpt.ChatGptAuthService;
|
|
import com.cyksj.service.chatgpt.ChatGptAuthService;
|
|
|
|
|
+import com.cyksj.service.mange.CmsOrderDonService;
|
|
|
import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
|
import com.cyksj.service.mange.ticket.TicketAdvertiseConfigClickRecordService;
|
|
import com.cyksj.service.mange.ticket.TicketAdvertiseConfigClickRecordService;
|
|
|
import com.cyksj.service.order.OrderDonService;
|
|
import com.cyksj.service.order.OrderDonService;
|
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
|
-import com.cyksj.service.sys.SysConfigService;
|
|
|
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
|
import com.cyksj.service.user.UserService;
|
|
import com.cyksj.service.user.UserService;
|
|
|
import com.cyksj.web.util.StpUserUtil;
|
|
import com.cyksj.web.util.StpUserUtil;
|
|
@@ -52,7 +54,11 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.math.RoundingMode;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Optional;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -87,8 +93,6 @@ public class GroupRelationController {
|
|
|
|
|
|
|
|
private final RedisService redisService;
|
|
private final RedisService redisService;
|
|
|
|
|
|
|
|
- private final UserFuncPropertyMapper userFuncPropertyMapper;
|
|
|
|
|
-
|
|
|
|
|
private final DoubleVerifyClickRefreshRecordMapper refreshRecordMapper;
|
|
private final DoubleVerifyClickRefreshRecordMapper refreshRecordMapper;
|
|
|
|
|
|
|
|
private final QuestionResponseRecordMapper questionResponseRecordMapper;
|
|
private final QuestionResponseRecordMapper questionResponseRecordMapper;
|
|
@@ -107,10 +111,12 @@ public class GroupRelationController {
|
|
|
|
|
|
|
|
private final GoodsCoursewareFileMapper goodsCoursewareFileMapper;
|
|
private final GoodsCoursewareFileMapper goodsCoursewareFileMapper;
|
|
|
|
|
|
|
|
- private final SysConfigService sysConfigService;
|
|
|
|
|
-
|
|
|
|
|
private final GptTicketStandbyMapper gptTicketStandbyMapper;
|
|
private final GptTicketStandbyMapper gptTicketStandbyMapper;
|
|
|
|
|
|
|
|
|
|
+ private final CmsOrderDonService cmsOrderDonService;
|
|
|
|
|
+
|
|
|
|
|
+ private final GoodsDonSkuMapper goodsDonSkuMapper;
|
|
|
|
|
+
|
|
|
private final static Sequence SEQUENCE = new Sequence(0);
|
|
private final static Sequence SEQUENCE = new Sequence(0);
|
|
|
|
|
|
|
|
@RequestMapping("/get/renewal")
|
|
@RequestMapping("/get/renewal")
|
|
@@ -592,7 +598,7 @@ public class GroupRelationController {
|
|
|
.field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
|
|
.field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
|
|
|
.field(RenewalView::getGoodsId, 26)
|
|
.field(RenewalView::getGoodsId, 26)
|
|
|
.field(RenewalView::getAccount, "@yinhe.ac.cn").op(Operator.Contain)
|
|
.field(RenewalView::getAccount, "@yinhe.ac.cn").op(Operator.Contain)
|
|
|
- .field(RenewalView::getExpiryTime).op(Operator.NotNull)
|
|
|
|
|
|
|
+ .field(RenewalView::getExpiryTime, DateUtil.offsetDay(DateTime.now(), 10)).op(Operator.GreaterThan)
|
|
|
.build());
|
|
.build());
|
|
|
GptStandbyResp gptStandbyResp = new GptStandbyResp();
|
|
GptStandbyResp gptStandbyResp = new GptStandbyResp();
|
|
|
gptStandbyResp.setIsHasAccount(number.intValue() > 0 ? true : false);
|
|
gptStandbyResp.setIsHasAccount(number.intValue() > 0 ? true : false);
|
|
@@ -616,7 +622,7 @@ public class GroupRelationController {
|
|
|
.field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
|
|
.field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
|
|
|
.field(RenewalView::getGoodsId, 26)
|
|
.field(RenewalView::getGoodsId, 26)
|
|
|
.field(RenewalView::getAccount, "@yinhe.ac.cn").op(Operator.Contain)
|
|
.field(RenewalView::getAccount, "@yinhe.ac.cn").op(Operator.Contain)
|
|
|
- .field(RenewalView::getExpiryTime).op(Operator.NotNull)
|
|
|
|
|
|
|
+ .field(RenewalView::getExpiryTime, DateUtil.offsetDay(DateTime.now(), 10)).op(Operator.GreaterThan)
|
|
|
.build());
|
|
.build());
|
|
|
if (number.intValue() == 0) {
|
|
if (number.intValue() == 0) {
|
|
|
throw BusinessRuntimeException.getInstance("你未有车票账号");
|
|
throw BusinessRuntimeException.getInstance("你未有车票账号");
|
|
@@ -631,4 +637,62 @@ public class GroupRelationController {
|
|
|
gptTicketStandbyMapper.insert(gptTicketStandby);
|
|
gptTicketStandbyMapper.insert(gptTicketStandby);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(number.intValue() > 0 ? true : false);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(number.intValue() > 0 ? true : false);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * midjourney车票退款
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/refund/ticketOrder/{relationId}")
|
|
|
|
|
+ @NoSubmit
|
|
|
|
|
+ public Result<String> ticketRefundOrders(@PathVariable Long relationId) throws Exception {
|
|
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
|
|
+ List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
|
|
+ RenewalView renewalView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder()
|
|
|
|
|
+ .field(RenewalView::getRelationId, relationId)
|
|
|
|
|
+ .field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
|
|
|
|
|
+ .field(RenewalView::getGoodsId, 26)
|
|
|
|
|
+ .field(RenewalView::getAccount, "@yinhe.ac.cn").op(Operator.Contain)
|
|
|
|
|
+ .field(RenewalView::getExpiryTime, DateUtil.offsetDay(DateTime.now(), 10)).op(Operator.LessEqual)
|
|
|
|
|
+ .build());
|
|
|
|
|
+ if (renewalView == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("你车票不存在或不符合退款要求");
|
|
|
|
|
+ }
|
|
|
|
|
+ OrderDon orderDon = orderDonService.getOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
+ .in(OrderDon::getUserId, relationUserIdList)
|
|
|
|
|
+ .eq(OrderDon::getRelationId, relationId)
|
|
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
|
|
+ .orderByDesc(OrderDon::getId)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+
|
|
|
|
|
+ if (orderDon == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("你对应车票的订单不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
|
|
+ if (sku == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("该车票规格不存在,请联系客服进行人工退款..");
|
|
|
|
|
+ }
|
|
|
|
|
+ Date expiryTime = renewalView.getExpiryTime();
|
|
|
|
|
+ long remainDay = DateUtil.between(DateTime.now(), expiryTime, DateUnit.DAY) + 1;
|
|
|
|
|
+ BigDecimal money = orderDon.getMoney();
|
|
|
|
|
+ BigDecimal refundMoney = null;
|
|
|
|
|
+ BigDecimal refundBalance= null;
|
|
|
|
|
+ String refundType = null;
|
|
|
|
|
+ if (money.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ BigDecimal dayMoney = money.divide(BigDecimal.valueOf(sku.getMonths()).multiply(BigDecimal.valueOf(30)), 2, RoundingMode.HALF_DOWN);
|
|
|
|
|
+ refundMoney = BigDecimal.valueOf(remainDay).multiply(dayMoney);
|
|
|
|
|
+ refundType = "money";
|
|
|
|
|
+ }
|
|
|
|
|
+ OrderRefundReq refundReq = new OrderRefundReq();
|
|
|
|
|
+ if (orderDon.getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ BigDecimal dayMoney = orderDon.getBalance().divide(BigDecimal.valueOf(sku.getMonths()).multiply(BigDecimal.valueOf(30)), 2, RoundingMode.HALF_DOWN);
|
|
|
|
|
+ refundBalance = BigDecimal.valueOf(remainDay).multiply(dayMoney);
|
|
|
|
|
+ refundReq.setIsOnly(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ refundReq.setOrderId(orderDon.getId());
|
|
|
|
|
+ refundReq.setRefundDesc("失效车票退款");
|
|
|
|
|
+ refundReq.setRefundMoney(Optional.ofNullable(refundMoney).orElse(BigDecimal.ZERO));
|
|
|
|
|
+ refundReq.setRefundBalance(Optional.ofNullable(refundBalance).orElse(BigDecimal.ZERO));
|
|
|
|
|
+ refundReq.setRefundType(Optional.ofNullable(refundType).orElse("balance"));
|
|
|
|
|
+ cmsOrderDonService.unifiedRefund(refundReq);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|