|
|
@@ -26,6 +26,7 @@ import com.cyksj.mapper.*;
|
|
|
import com.cyksj.mapper.manage.form.FormFieldsDataMapper;
|
|
|
import com.cyksj.mapper.manage.form.QuestionnairePromotionMapper;
|
|
|
import com.cyksj.model.dto.DoubleVerifyDto;
|
|
|
+import com.cyksj.model.dto.GalaxyCoinPayConfigDto;
|
|
|
import com.cyksj.model.dto.QuestionnaireView;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.manage.views.AccountView;
|
|
|
@@ -44,6 +45,7 @@ import com.cyksj.service.mange.ticket.TicketAdvertiseConfigClickRecordService;
|
|
|
import com.cyksj.service.order.OrderDonService;
|
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
|
import com.cyksj.service.relation.GroupsRelationNetflixService;
|
|
|
+import com.cyksj.service.sys.SysConfigService;
|
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
|
import com.cyksj.service.user.UserService;
|
|
|
import com.cyksj.web.util.StpUserUtil;
|
|
|
@@ -142,6 +144,10 @@ public class GroupRelationController {
|
|
|
|
|
|
private final ClaudeUserMapper claudeUserMapper;
|
|
|
|
|
|
+ private final UserMapper userMapper;
|
|
|
+
|
|
|
+ private final SysConfigService sysConfigService;
|
|
|
+
|
|
|
private final static Sequence SEQUENCE = new Sequence(0);
|
|
|
|
|
|
@RequestMapping("/get/renewal")
|
|
|
@@ -1280,4 +1286,41 @@ public class GroupRelationController {
|
|
|
Boolean flag = groupRelationFrontService.getMirrorPopups(userId);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(flag);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 银河币续费车票列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/galaxyCoin/tickets")
|
|
|
+ public Result<SearchResult<GalaxyCoinRenewTicketsView>> getGalaxyCoinTickets() throws Exception {
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
+ DateTime now = DateTime.now();
|
|
|
+ String conditionSql = String.format("(gr.expiry_time is null or gr.expiry_time > '%s'", now);
|
|
|
+ conditionSql += String.format(" or (sku.is_mirror and gr.expiry_time > '%s')", DateUtil.offsetDay(now, -7));
|
|
|
+ SearchResult<GalaxyCoinRenewTicketsView> search = beanSearcher.search(GalaxyCoinRenewTicketsView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .field(GalaxyCoinRenewTicketsView::getUserId, userIdList).op(Operator.InList)
|
|
|
+ .put("condition", conditionSql)
|
|
|
+ .orderBy(GalaxyCoinRenewTicketsView::getExpiryTime).asc()
|
|
|
+ .build());
|
|
|
+ User user = userMapper.selectById(userId);
|
|
|
+ if (user.getGalaxyCoin().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+ BigDecimal userGalaxyCoin = user.getGalaxyCoin();
|
|
|
+ SysConfig payDeductConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
+ .eq(SysConfig::getSysKey, Constant.GALAXY_COIN_PAY_DEDUCT_KEY)
|
|
|
+ .last("limit 1"));
|
|
|
+ GalaxyCoinPayConfigDto galaxyCoinPayConfigDto = Jsons.parseObject(payDeductConfig.getSysValue(), GalaxyCoinPayConfigDto.class);
|
|
|
+ BigDecimal maxRate = galaxyCoinPayConfigDto.getMaxRate();
|
|
|
+ BigDecimal payGalaxyCoin = galaxyCoinPayConfigDto.getGalaxyCoin();
|
|
|
+ BigDecimal payMoney = galaxyCoinPayConfigDto.getMoney();
|
|
|
+ for (GalaxyCoinRenewTicketsView galaxyCoinRenewTicketsView : search.getDataList()) {
|
|
|
+ Long skuId = galaxyCoinRenewTicketsView.getSkuId();
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
|
|
|
+ //此次最大可抵扣银河币数量
|
|
|
+ BigDecimal maxDeductGalaxyCoin = sku.getPrice().multiply(maxRate).divide(payMoney).multiply(payGalaxyCoin);
|
|
|
+ galaxyCoinRenewTicketsView.setMaxGalaxyCoinDeduct(userGalaxyCoin.compareTo(maxDeductGalaxyCoin) > 0 ? maxDeductGalaxyCoin : userGalaxyCoin);
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
}
|