|
@@ -1,6 +1,8 @@
|
|
|
package com.cyksj.web.controller.manage;
|
|
package com.cyksj.web.controller.manage;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -10,11 +12,11 @@ import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.BusinessType;
|
|
import com.cyksj.enums.BusinessType;
|
|
|
|
|
+import com.cyksj.enums.GatewayApiCode;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
-import com.cyksj.mapper.GoodsDonSkuMapper;
|
|
|
|
|
-import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
|
|
-import com.cyksj.mapper.OrderCommentMapper;
|
|
|
|
|
|
|
+import com.cyksj.mapper.*;
|
|
|
import com.cyksj.mapper.channel.ChannelPopularizeMapper;
|
|
import com.cyksj.mapper.channel.ChannelPopularizeMapper;
|
|
|
|
|
+import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponMapper;
|
|
import com.cyksj.mapper.manage.coupon.CouponMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.excel.ExcelOrderDonData;
|
|
import com.cyksj.model.excel.ExcelOrderDonData;
|
|
@@ -26,6 +28,7 @@ import com.cyksj.model.request.OrderRefundReq;
|
|
|
import com.cyksj.model.views.*;
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.service.mange.CmsOrderDonService;
|
|
import com.cyksj.service.mange.CmsOrderDonService;
|
|
|
import com.cyksj.service.order.OrderDonCommentService;
|
|
import com.cyksj.service.order.OrderDonCommentService;
|
|
|
|
|
+import com.cyksj.service.user.UserBindRelationService;
|
|
|
import com.cyksj.service.user.UserService;
|
|
import com.cyksj.service.user.UserService;
|
|
|
import com.cyksj.web.util.EasyExcelUtils;
|
|
import com.cyksj.web.util.EasyExcelUtils;
|
|
|
import com.cyksj.web.util.StpAbroadUtil;
|
|
import com.cyksj.web.util.StpAbroadUtil;
|
|
@@ -36,15 +39,18 @@ import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
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 javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author chan
|
|
* @author chan
|
|
@@ -75,9 +81,19 @@ public class CmsOrderController {
|
|
|
|
|
|
|
|
private final GroupsRelationMapper relationMapper;
|
|
private final GroupsRelationMapper relationMapper;
|
|
|
|
|
|
|
|
|
|
+ private final CmsUserMapper cmsUserMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final UserMapper userMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final OrderDonMapper orderDonMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final UserBindRelationService userBindRelationService;
|
|
|
|
|
+
|
|
|
|
|
+ private final OrderDonCustomerServiceRelateMapper orderDonCustomerServiceRelateMapper;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@GetMapping("/get")
|
|
@GetMapping("/get")
|
|
|
- public Result<SearchResult<OrderDonBackView>> get(Long channelId, String account, String showId) {
|
|
|
|
|
|
|
+ public Result<SearchResult<OrderDonBackView>> get(Long channelId, String account, String showId, Long acId, String nickname, String register, Boolean isGoogle, Boolean isSubsidy) {
|
|
|
MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
if (channelId != null) {
|
|
if (channelId != null) {
|
|
|
List<Long> popularizeIds = channelPopularizeMapper.getPopularizeIdByChannelId(channelId);
|
|
List<Long> popularizeIds = channelPopularizeMapper.getPopularizeIdByChannelId(channelId);
|
|
@@ -95,6 +111,41 @@ public class CmsOrderController {
|
|
|
if (StrUtil.isNotBlank(showId)) {
|
|
if (StrUtil.isNotBlank(showId)) {
|
|
|
builder.field(OrderDonBackView::getUserId, userService.getUserIdByShowId(showId));
|
|
builder.field(OrderDonBackView::getUserId, userService.getUserIdByShowId(showId));
|
|
|
}
|
|
}
|
|
|
|
|
+ String conditionSql = StrUtil.EMPTY;
|
|
|
|
|
+ if (acId != null) {
|
|
|
|
|
+ conditionSql += String.format(" o.user_id in (select user_id from corp_user where ac_id = %s)", acId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!ObjectUtil.isAllEmpty(nickname, register, isGoogle)) {
|
|
|
|
|
+ if (StrUtil.isNotEmpty(conditionSql)) {
|
|
|
|
|
+ conditionSql += " and ";
|
|
|
|
|
+ }
|
|
|
|
|
+ conditionSql += " exists (select u.id from user u where u.id = o.user_id";
|
|
|
|
|
+ if (StrUtil.isNotEmpty(nickname)) {
|
|
|
|
|
+ conditionSql += String.format(" and u.nickname like '%s%%'", nickname);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotEmpty(register)) {
|
|
|
|
|
+ if ("phone".equals(register)) {
|
|
|
|
|
+ conditionSql += " and u.login_phone != ''";
|
|
|
|
|
+ } else if ("email".equals(register)) {
|
|
|
|
|
+ conditionSql += " and u.email != ''";
|
|
|
|
|
+ } else if ("wechat".equals(register)) {
|
|
|
|
|
+ conditionSql += " and u.unionid != ''";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isGoogle != null && isGoogle) {
|
|
|
|
|
+ conditionSql += String.format(" and u.is_google is %s", isGoogle);
|
|
|
|
|
+ }
|
|
|
|
|
+ conditionSql += " limit 1)";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isSubsidy != null) {
|
|
|
|
|
+ if (StrUtil.isNotEmpty(conditionSql)) {
|
|
|
|
|
+ conditionSql += " and ";
|
|
|
|
|
+ }
|
|
|
|
|
+ conditionSql += " exists (select 1 from order_don_subsidy_relate ocr where ocr.order_id = o.id limit 1)";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(conditionSql)) {
|
|
|
|
|
+ builder.put("condition", conditionSql);
|
|
|
|
|
+ }
|
|
|
SearchResult<OrderDonBackView> search = beanSearcher.search(OrderDonBackView.class, builder.build());
|
|
SearchResult<OrderDonBackView> search = beanSearcher.search(OrderDonBackView.class, builder.build());
|
|
|
search.getDataList().forEach(data -> {
|
|
search.getDataList().forEach(data -> {
|
|
|
if (data.getPopularizeId() != null) {
|
|
if (data.getPopularizeId() != null) {
|
|
@@ -105,18 +156,30 @@ public class CmsOrderController {
|
|
|
data.setCouponName(couponMapper.getCouponNameByCouponUserId(data.getCouponUserId()));
|
|
data.setCouponName(couponMapper.getCouponNameByCouponUserId(data.getCouponUserId()));
|
|
|
data.setCouponMoney(data.getCouponMoney() == null ? BigDecimal.ZERO : data.getCouponMoney());
|
|
data.setCouponMoney(data.getCouponMoney() == null ? BigDecimal.ZERO : data.getCouponMoney());
|
|
|
}
|
|
}
|
|
|
- Optional.ofNullable(relationMapper.selectById(data.getRelationId()))
|
|
|
|
|
- .ifPresent(relation -> {
|
|
|
|
|
- data.setAccount(relation.getAccount());
|
|
|
|
|
- AccountView accountView = beanSearcher.searchFirst(AccountView.class, MapUtils.builder().field(AccountView::getGroupsId, relation.getGroupsId()).onlySelect(AccountView::getAccount).build());
|
|
|
|
|
- Optional.ofNullable(accountView).ifPresent(view -> data.setGtAccount(view.getAccount()));
|
|
|
|
|
- });
|
|
|
|
|
- Optional.ofNullable(skuMapper.selectById(data.getSkuId()))
|
|
|
|
|
- .ifPresent(sku -> {
|
|
|
|
|
- data.setSpecVal(sku.getSpecVal());
|
|
|
|
|
- data.setMonths(sku.getMonths());
|
|
|
|
|
- data.setDays(sku.getDays());
|
|
|
|
|
- });
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (data.getRelationId() != 0) {
|
|
|
|
|
+ Optional.ofNullable(relationMapper.getGroupRelationAccountView(data.getRelationId()))
|
|
|
|
|
+ .ifPresent(e -> {
|
|
|
|
|
+ data.setGtAccount(e.getTripsAccount());
|
|
|
|
|
+ data.setAccount(e.getAccount());
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ User user = userMapper.selectById(data.getUserId());
|
|
|
|
|
+ if (user != null) {
|
|
|
|
|
+ data.setNickname(user.getNickname());
|
|
|
|
|
+ data.setLoginPhone(user.getLoginPhone());
|
|
|
|
|
+ data.setEmail(user.getEmail());
|
|
|
|
|
+ data.setRegister(StrUtil.isNotEmpty(user.getUnionid()) ? "wechat" : StrUtil.isNotEmpty(user.getLoginPhone()) ? "phone" : "email");
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ if (data.getGoodsDonType() != null && data.getGoodsDonType() == 1) {
|
|
|
|
|
+ //获取订单关联客服
|
|
|
|
|
+ Optional.ofNullable(orderDonMapper.selectOrderRelate(data.getId())).ifPresent(e -> {
|
|
|
|
|
+ data.setCmsUserId(e.getCmsUserId());
|
|
|
|
|
+ data.setNickname(e.getNickname());
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
}
|
|
@@ -151,16 +214,6 @@ public class CmsOrderController {
|
|
|
if (data.getChannelId() == null) {
|
|
if (data.getChannelId() == null) {
|
|
|
data.setChannel("自然流量渠道");
|
|
data.setChannel("自然流量渠道");
|
|
|
}
|
|
}
|
|
|
- if (data.getGoodsDonType() != null && Constant.realGoodsType.contains(data.getGoodsDonType())) {
|
|
|
|
|
- OrderDonTransportView transportView = beanSearcher.searchFirst(OrderDonTransportView.class, MapUtils.builder().field(OrderDonTransportView::getOrderId, data.getId()).build());
|
|
|
|
|
- if (transportView != null) {
|
|
|
|
|
- data.setTransportStr(String.format("%s%s%s%s", transportView.getProvince(), transportView.getCity(), transportView.getDistrict(), transportView.getAddress()));
|
|
|
|
|
- data.setPhone(transportView.getPhone());
|
|
|
|
|
- data.setReceiver(transportView.getReceiver());
|
|
|
|
|
- data.setCodeCn(transportView.getCodeCn());
|
|
|
|
|
- data.setTrackingNumber(transportView.getTrackingNumber());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
if (data.getCouponUserId() != 0) {
|
|
if (data.getCouponUserId() != 0) {
|
|
|
data.setCouponName(couponMapper.getCouponNameByCouponUserId(data.getCouponUserId()));
|
|
data.setCouponName(couponMapper.getCouponNameByCouponUserId(data.getCouponUserId()));
|
|
|
data.setCouponMoney(data.getCouponMoney() == null ? BigDecimal.ZERO : data.getCouponMoney().divide(BigDecimal.valueOf(100)));
|
|
data.setCouponMoney(data.getCouponMoney() == null ? BigDecimal.ZERO : data.getCouponMoney().divide(BigDecimal.valueOf(100)));
|
|
@@ -284,25 +337,18 @@ public class CmsOrderController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 客服修改订单来源
|
|
|
|
|
- */
|
|
|
|
|
- @PutMapping("/update/order/source")
|
|
|
|
|
- public Result<String> updateOrderSource(@RequestBody OrderDon orderDon) {
|
|
|
|
|
- Long id = orderDon.getId();
|
|
|
|
|
- String labelSource = orderDon.getLabelSource();
|
|
|
|
|
- cmsOrderDonService.update(null, Wrappers.lambdaUpdate(OrderDon.class)
|
|
|
|
|
- .set(OrderDon::getLabelSource, labelSource)
|
|
|
|
|
- .eq(OrderDon::getId, id));
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 订单统一退款
|
|
* 订单统一退款
|
|
|
*/
|
|
*/
|
|
|
@PostMapping("/unified/refund")
|
|
@PostMapping("/unified/refund")
|
|
|
@Log(module = "订单管理/统一退款", businessType = BusinessType.PUT, isSaveRequestData = true)
|
|
@Log(module = "订单管理/统一退款", businessType = BusinessType.PUT, isSaveRequestData = true)
|
|
|
public Result<String> unifiedRefund(@RequestBody @Validated OrderRefundReq refundReq) throws Exception {
|
|
public Result<String> unifiedRefund(@RequestBody @Validated OrderRefundReq refundReq) throws Exception {
|
|
|
|
|
+ long adminId = StpAbroadUtil.getLoginIdAsLong();
|
|
|
|
|
+ CmsUser cmsUser = cmsUserMapper.selectById(adminId);
|
|
|
|
|
+ if (cmsUser == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
|
|
+ }
|
|
|
|
|
+ refundReq.setOperator(cmsUser.getNickname());
|
|
|
cmsOrderDonService.unifiedRefund(refundReq);
|
|
cmsOrderDonService.unifiedRefund(refundReq);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("退款成功");
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("退款成功");
|
|
|
}
|
|
}
|
|
@@ -312,6 +358,7 @@ public class CmsOrderController {
|
|
|
* 更换用户车票
|
|
* 更换用户车票
|
|
|
*/
|
|
*/
|
|
|
@PutMapping("/put/sameSpec/empty/relation")
|
|
@PutMapping("/put/sameSpec/empty/relation")
|
|
|
|
|
+ @Log(module = "更换用户车票", businessType = BusinessType.PUT, isSaveRequestData = true)
|
|
|
public Result<String> changeRelation(@RequestBody @Validated ChangeRelationReq req) throws Exception {
|
|
public Result<String> changeRelation(@RequestBody @Validated ChangeRelationReq req) throws Exception {
|
|
|
cmsOrderDonService.changeRelation(req);
|
|
cmsOrderDonService.changeRelation(req);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
@@ -327,6 +374,7 @@ public class CmsOrderController {
|
|
|
.field(EmptyGroupsRelationView::getStatus, GroupsTrips.Status.down.name()).op(Operator.NotEqual)
|
|
.field(EmptyGroupsRelationView::getStatus, GroupsTrips.Status.down.name()).op(Operator.NotEqual)
|
|
|
.field(EmptyGroupsRelationView::getSkuId, skuId).orderBy(EmptyGroupsRelationView::getAvailableNum)
|
|
.field(EmptyGroupsRelationView::getSkuId, skuId).orderBy(EmptyGroupsRelationView::getAvailableNum)
|
|
|
.desc();
|
|
.desc();
|
|
|
|
|
+ GoodsDonSku sku = skuMapper.selectById(skuId);
|
|
|
Date expiryTime = null;
|
|
Date expiryTime = null;
|
|
|
if (relationId != null) {
|
|
if (relationId != null) {
|
|
|
GroupsRelation relation = relationMapper.selectById(relationId);
|
|
GroupsRelation relation = relationMapper.selectById(relationId);
|
|
@@ -335,19 +383,136 @@ public class CmsOrderController {
|
|
|
if (groupsId != null) {
|
|
if (groupsId != null) {
|
|
|
builder.field(EmptyGroupsRelationView::getGroupsId, groupsId).op(Operator.NotEqual);
|
|
builder.field(EmptyGroupsRelationView::getGroupsId, groupsId).op(Operator.NotEqual);
|
|
|
}
|
|
}
|
|
|
|
|
+ String condition = StrUtil.EMPTY;
|
|
|
if (isNormal != null && isNormal) {
|
|
if (isNormal != null && isNormal) {
|
|
|
- builder.put("account_id", String.format("gt.account_id not in (select account_id from work_order where sku_id = %s and account_id is not null)", skuId));
|
|
|
|
|
|
|
+ condition += String.format("gt.account_id not in (select account_id from work_order where sku_id = %s and account_id is not null)", skuId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotEmpty(condition)) {
|
|
|
|
|
+ condition += " and ";
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer maxNum = sku.getNum();
|
|
|
|
|
+ Integer extraNum = 5;
|
|
|
|
|
+ //GPT 4人月付
|
|
|
|
|
+ if (sku.getId() == 178l) {
|
|
|
|
|
+ extraNum = 2;
|
|
|
|
|
+ }
|
|
|
|
|
+ maxNum += extraNum;
|
|
|
|
|
+ condition += String.format("(available_parking_num = 0 or available_parking_num > (select count(*) from groups_relation gr where gr.groups_id = gt.id and gr.user_id != 0 and gr.num <= %s))", maxNum);
|
|
|
|
|
+ if (StrUtil.isNotEmpty(condition)) {
|
|
|
|
|
+ builder.put("condition", condition);
|
|
|
}
|
|
}
|
|
|
if (expiryTime != null) {
|
|
if (expiryTime != null) {
|
|
|
builder.field(AccountView::getExpiryTime, expiryTime).op(Operator.GreaterEqual);
|
|
builder.field(AccountView::getExpiryTime, expiryTime).op(Operator.GreaterEqual);
|
|
|
builder.orderBy(AccountView::getExpiryTime).asc();
|
|
builder.orderBy(AccountView::getExpiryTime).asc();
|
|
|
}
|
|
}
|
|
|
- GoodsDonSku sku = skuMapper.selectById(skuId);
|
|
|
|
|
- if (!Constant.AI_goodsIds.contains(sku.getGoodsId())) {
|
|
|
|
|
|
|
+ if (sku.getNum() == 1 || !Constant.AI_goodsIds.contains(sku.getGoodsId())) {
|
|
|
builder.field(EmptyGroupsRelationView::getAvailableNum, 0).op(Operator.GreaterThan);
|
|
builder.field(EmptyGroupsRelationView::getAvailableNum, 0).op(Operator.GreaterThan);
|
|
|
}
|
|
}
|
|
|
SearchResult<EmptyGroupsRelationView> search = beanSearcher.search(EmptyGroupsRelationView.class,
|
|
SearchResult<EmptyGroupsRelationView> search = beanSearcher.search(EmptyGroupsRelationView.class,
|
|
|
builder.build());
|
|
builder.build());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 客服退款每月数据
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/refundOrder/data")
|
|
|
|
|
+ public Result<SearchResult<RefundOrderDonServiceDataView>> getRefundOrderData(String startTime, String endTime, String operator) {
|
|
|
|
|
+ String time = StrUtil.EMPTY;
|
|
|
|
|
+ if (StrUtil.isNotBlank(startTime)) {
|
|
|
|
|
+ time += String.format(" and o.created_time >= '%s'", startTime);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(endTime)) {
|
|
|
|
|
+ time += String.format(" and o.created_time < '%s'", endTime);
|
|
|
|
|
+ }
|
|
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
|
|
+ if (StrUtil.isNotBlank(time)) {
|
|
|
|
|
+ builder.put("time", time);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isEmpty(operator)) {
|
|
|
|
|
+ List<CmsUserVO> userVOS = beanSearcher.searchAll(CmsUserVO.class, MapUtils.builder().field(CmsUserVO::getRoleNames, "客服").op(Operator.Contain).build());
|
|
|
|
|
+ List<String> collect = userVOS.stream().map(CmsUserVO::getNickname).collect(Collectors.toList());
|
|
|
|
|
+ if (CollUtil.isNotEmpty(collect)) {
|
|
|
|
|
+ builder.field(RefundOrderDonServiceDataView::getOperator, collect).op(Operator.InList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ SearchResult<RefundOrderDonServiceDataView> search = beanSearcher.search(RefundOrderDonServiceDataView.class, builder.build());
|
|
|
|
|
+ search.getDataList().forEach(e->{
|
|
|
|
|
+ String goodsName = orderDonMapper.selectMaxRefundGoodsName(e.getOperator(), startTime, endTime);
|
|
|
|
|
+ e.setGoodsName(goodsName);
|
|
|
|
|
+ });
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 设置订单客服
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/set/service")
|
|
|
|
|
+ public Result<String> setOrderCustomerService(@RequestBody OrderDonCustomerServiceRelate relate) {
|
|
|
|
|
+ OrderDonCustomerServiceRelate orderDonCustomerServiceRelate = orderDonCustomerServiceRelateMapper.selectOne(Wrappers.lambdaQuery(OrderDonCustomerServiceRelate.class)
|
|
|
|
|
+ .eq(OrderDonCustomerServiceRelate::getOrderId, relate.getOrderId()).last("limit 1"));
|
|
|
|
|
+ if (orderDonCustomerServiceRelate != null) {
|
|
|
|
|
+ relate.setId(orderDonCustomerServiceRelate.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (relate.getId() == null) {
|
|
|
|
|
+ orderDonCustomerServiceRelateMapper.insert(relate);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ orderDonCustomerServiceRelateMapper.updateById(relate);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 用户退款详情
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/user/refund/detail")
|
|
|
|
|
+ public Result<OrderDonUserRefundDetailView> getUserRefundDetail(Long userId) {
|
|
|
|
|
+ if (userId == null || userId == 0) {
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Long> userIdList = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ String userIds = null;
|
|
|
|
|
+ if (CollUtil.isNotEmpty(userIdList)) {
|
|
|
|
|
+ userIds = userIdList.toString().replaceAll("\\[", "").replaceAll("]", "");
|
|
|
|
|
+ }
|
|
|
|
|
+ MapBuilder builder = MapUtils.builder();
|
|
|
|
|
+ if (StrUtil.isNotBlank(userIds)) {
|
|
|
|
|
+ builder.put("uid", String.format(" and user_id in (%s)", userIds));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ builder.put("uid", String.format(" and user_id = %s", userId));
|
|
|
|
|
+ }
|
|
|
|
|
+ OrderDonUserRefundDetailView orderDonUserRefundDetailView = beanSearcher.searchFirst(OrderDonUserRefundDetailView.class, builder.build());
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(orderDonUserRefundDetailView);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 用户订单列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/user/orders")
|
|
|
|
|
+ public Result<SearchResult<OrderDonUserRefundDetailView.OrderDonDetailView>> getUserOrdersDetail(Long userId) {
|
|
|
|
|
+ if (userId == null || userId == 0) {
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Long> userIdList = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ if (userIdList == null) {
|
|
|
|
|
+ userIdList = new ArrayList<>();
|
|
|
|
|
+ userIdList.add(userId);
|
|
|
|
|
+ }
|
|
|
|
|
+ SearchResult<OrderDonUserRefundDetailView.OrderDonDetailView> search = beanSearcher.search(OrderDonUserRefundDetailView.OrderDonDetailView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
|
|
+ .field(OrderDonUserRefundDetailView.OrderDonDetailView::getUserId, userIdList).op(Operator.InList)
|
|
|
|
|
+ .build());
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|