|
@@ -4,6 +4,7 @@ import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
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.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
import com.cyksj.common.constant.Constant;
|
|
@@ -11,12 +12,15 @@ import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.GoodsDonSkuMapper;
|
|
import com.cyksj.mapper.GoodsDonSkuMapper;
|
|
|
|
|
+import com.cyksj.mapper.GroupsRelationIndependentRenewMapper;
|
|
|
import com.cyksj.mapper.GroupsRelationMapper;
|
|
import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
import com.cyksj.mapper.OrderDonMapper;
|
|
import com.cyksj.mapper.OrderDonMapper;
|
|
|
import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationBackView;
|
|
import com.cyksj.model.manage.views.GroupsRelationBackView;
|
|
|
|
|
+import com.cyksj.model.views.GroupsRelationIndependentView;
|
|
|
import com.cyksj.model.views.GroupsRelationRechargeView;
|
|
import com.cyksj.model.views.GroupsRelationRechargeView;
|
|
|
|
|
+import com.cyksj.model.views.OrderDonRenewView;
|
|
|
import com.cyksj.service.scheduler.SchedulerService;
|
|
import com.cyksj.service.scheduler.SchedulerService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
import com.ejlchina.searcher.SearchResult;
|
|
@@ -29,6 +33,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author chan
|
|
* @author chan
|
|
@@ -54,6 +59,8 @@ public class CmsGroupRelationController {
|
|
|
|
|
|
|
|
private final GoodsDonSkuMapper goodsDonSkuMapper;
|
|
private final GoodsDonSkuMapper goodsDonSkuMapper;
|
|
|
|
|
|
|
|
|
|
+ private final GroupsRelationIndependentRenewMapper groupsRelationIndependentRenewMapper;
|
|
|
|
|
+
|
|
|
@GetMapping("/get")
|
|
@GetMapping("/get")
|
|
|
public Result<List<GroupsRelationBackView>> get(){
|
|
public Result<List<GroupsRelationBackView>> get(){
|
|
|
List<GroupsRelationBackView> search = beanSearcher.searchAll(GroupsRelationBackView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
List<GroupsRelationBackView> search = beanSearcher.searchAll(GroupsRelationBackView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
@@ -150,4 +157,80 @@ public class CmsGroupRelationController {
|
|
|
}
|
|
}
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(false);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(false);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 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");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ SearchResult<GroupsRelationIndependentView> search = beanSearcher.search(GroupsRelationIndependentView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
|
|
+ .put("condition", condition)
|
|
|
|
|
+ .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)
|
|
|
|
|
+ .build());
|
|
|
|
|
+ e.setNumOfRenew(count.intValue());
|
|
|
|
|
+ });
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 编辑车票独立续费状态
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/update/independent/renew/status")
|
|
|
|
|
+ public Result<String> updateRenewStatus(@RequestBody GroupsRelationIndependentView view) {
|
|
|
|
|
+ long adminId = StpUtil.getLoginIdAsLong();
|
|
|
|
|
+ Long relationId = view.getRelationId();
|
|
|
|
|
+ Long userId = view.getUserId();
|
|
|
|
|
+ Boolean isRenew = view.getIsRenew();
|
|
|
|
|
+ if (ObjectUtil.hasEmpty(relationId, userId, isRenew)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("参数错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ GroupsRelationIndependentRenew groupsRelationIndependentRenew = Optional.ofNullable(groupsRelationIndependentRenewMapper.selectOne(Wrappers.lambdaQuery(GroupsRelationIndependentRenew.class).eq(GroupsRelationIndependentRenew::getUserId, userId)
|
|
|
|
|
+ .eq(GroupsRelationIndependentRenew::getRelationId, relationId).last("limit 1"))).orElse(new GroupsRelationIndependentRenew());
|
|
|
|
|
+ CmsUser cmsUser = cmsUserMapper.selectById(adminId);
|
|
|
|
|
+ if (cmsUser != null) {
|
|
|
|
|
+ groupsRelationIndependentRenew.setOperator(cmsUser.getNickname());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (groupsRelationIndependentRenew.getId() == null) {
|
|
|
|
|
+ groupsRelationIndependentRenew.setRelationId(relationId);
|
|
|
|
|
+ groupsRelationIndependentRenew.setUserId(userId);
|
|
|
|
|
+ groupsRelationIndependentRenew.setIsRenew(isRenew);
|
|
|
|
|
+ groupsRelationIndependentRenewMapper.insert(groupsRelationIndependentRenew);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ groupsRelationIndependentRenew.setIsRenew(isRenew);
|
|
|
|
|
+ groupsRelationIndependentRenewMapper.updateById(groupsRelationIndependentRenew);
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 独立账号续费记录
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/independent/renew/record")
|
|
|
|
|
+ public Result<SearchResult<OrderDonRenewView>> getIndependentRenewRecord(Long userId, Long relationId) {
|
|
|
|
|
+ if (ObjectUtil.hasEmpty(relationId, userId)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("参数错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ SearchResult<OrderDonRenewView> search = beanSearcher.search(OrderDonRenewView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
|
|
+ .field(OrderDonRenewView::getUserId, userId)
|
|
|
|
|
+ .field(OrderDonRenewView::getRelationId, relationId)
|
|
|
|
|
+ .field(OrderDonRenewView::getOrderType, 2)
|
|
|
|
|
+ .build());
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|