|
|
@@ -1,10 +1,12 @@
|
|
|
package com.cyksj.web.controller.manage.group;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.annotation.Log;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
@@ -19,6 +21,7 @@ import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
import com.cyksj.mapper.OrderDonMapper;
|
|
|
import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
+import com.cyksj.model.manage.views.AccountView;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationBackView;
|
|
|
import com.cyksj.model.views.GroupsRelationIndependentView;
|
|
|
import com.cyksj.model.views.GroupsRelationRechargeView;
|
|
|
@@ -37,6 +40,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author chan
|
|
|
@@ -167,29 +171,28 @@ public class CmsGroupRelationController {
|
|
|
* Chat GPT独立规格续费 列表
|
|
|
*/
|
|
|
@GetMapping("/get/chatGPT/independent/renew")
|
|
|
- public Result<SearchResult<GroupsRelationIndependentView>> getIndependentRenew(Boolean isRenew) {
|
|
|
- String condition = " sku_id in (select id from goods_don_sku sku where sku.goods_id = 18 and sku.num = 1)" +
|
|
|
- " and exists (select id from order_don o where o.user_id = gr.user_id and o.relation_id = gr.id and o.status not in ('close','noPayment','refund') and o.order_type = 2 limit 1)";
|
|
|
- if (isRenew != null) {
|
|
|
- if (isRenew) {
|
|
|
- condition += String.format(" and exists (select id from groups_relation_independent_renew gnr where gnr.user_id = gr.user_id and gnr.relation_id = gr.id and gnr.is_renew = 1 limit 1)");
|
|
|
- } else {
|
|
|
- condition += String.format(" and (select count(*) from groups_relation_independent_renew gnr where gnr.user_id = gr.user_id and gnr.relation_id = gr.id and gnr.is_renew = 1) = 0");
|
|
|
+ public Result<SearchResult<GroupsRelationIndependentView>> getIndependentRenew(String account) {
|
|
|
+ String condition = " sku_id in (select id from goods_don_sku sku where sku.goods_id in (18,26) and sku.num = 1)" +
|
|
|
+ " and o.status not in ('close','noPayment','refund') and o.order_type = 2";
|
|
|
+ if (StrUtil.isNotEmpty(account)) {
|
|
|
+ List<AccountView> dbAccounts = beanSearcher.searchAll(AccountView.class, MapUtils.builder().field(AccountView::getAccount, account).op(Operator.Contain).build());
|
|
|
+ if (CollUtil.isNotEmpty(dbAccounts)) {
|
|
|
+ String collect = dbAccounts.stream().map(e -> String.valueOf(e.getGroupsId())).collect(Collectors.joining(","));
|
|
|
+ condition += String.format(" and groups_id in (%s)", collect);
|
|
|
}
|
|
|
}
|
|
|
SearchResult<GroupsRelationIndependentView> search = beanSearcher.search(GroupsRelationIndependentView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
.put("condition", condition)
|
|
|
+ .orderBy(GroupsRelationIndependentView::getIsRenew)
|
|
|
+ .orderBy(GroupsRelationIndependentView::getSubmitTime).desc()
|
|
|
.build());
|
|
|
search.getDataList().forEach(e->{
|
|
|
- Optional.ofNullable(groupsRelationIndependentRenewMapper.selectOne(Wrappers.lambdaQuery(GroupsRelationIndependentRenew.class).eq(GroupsRelationIndependentRenew::getUserId, e.getUserId())
|
|
|
- .eq(GroupsRelationIndependentRenew::getRelationId, e.getRelationId()).last("limit 1"))).ifPresent(data -> e.setIsRenew(data.getIsRenew()));
|
|
|
- Number count = beanSearcher.searchCount(OrderDonRenewView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
- .field(OrderDonRenewView::getUserId, e.getUserId())
|
|
|
- .field(OrderDonRenewView::getRelationId, e.getRelationId())
|
|
|
- .field(OrderDonRenewView::getOrderType, 2)
|
|
|
- .field(OrderDonRenewView::getStatus, Constant.noOrderAllStatus).op(Operator.NotIn)
|
|
|
- .build());
|
|
|
- e.setNumOfRenew(count.intValue());
|
|
|
+ GroupsTrips groupsTrips = beanSearcher.searchFirst(GroupsTrips.class, MapUtils.builder().field(GroupsTrips::getId, e.getGroupsId()).build());
|
|
|
+ if (groupsTrips != null) {
|
|
|
+ e.setAccount(groupsTrips.getAccount());
|
|
|
+ e.setPassword(groupsTrips.getPassword());
|
|
|
+ e.setAccountExpiryTime(e.getExpiryTime());
|
|
|
+ }
|
|
|
});
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
|
@@ -212,6 +215,8 @@ public class CmsGroupRelationController {
|
|
|
if (cmsUser != null) {
|
|
|
groupsRelationIndependentRenew.setOperator(cmsUser.getNickname());
|
|
|
}
|
|
|
+ groupsRelationIndependentRenew.setOrderId(view.getOrderId());
|
|
|
+
|
|
|
if (groupsRelationIndependentRenew.getId() == null) {
|
|
|
groupsRelationIndependentRenew.setRelationId(relationId);
|
|
|
groupsRelationIndependentRenew.setUserId(userId);
|