Ver código fonte

Merge branch 'codex/multi-quantity-orders' into pre

zoujiajian 1 semana atrás
pai
commit
4b4ca6a9d9

+ 2 - 1
netflix-web/src/main/java/com/cyksj/web/controller/manage/CmsOrderController.java

@@ -809,7 +809,8 @@ public class CmsOrderController {
     @Log(module = "订单管理/售前、售后客服", businessType = BusinessType.PUT, isSaveRequestData = true)
     public Result<String> putRealGoodsService(@RequestBody @Validated RealGoodsServiceReq request) {
         OrderDon orderDon = cmsOrderDonService.getById(request.getOrderId());
-        if (orderDon == null || orderDon.getRelationId() != 0) {
+        if (orderDon == null || orderDon.getRelationId() != 0
+                || multiQuantityOrderService.isMultiQuantityOrder(orderDon.getId())) {
             throw BusinessRuntimeException.getInstance("该订单不是实物订单");
         }
 	    Boolean isBefore = false;

+ 36 - 6
netflix-web/src/main/java/com/cyksj/web/controller/manage/group/CmsGroupRelationController.java

@@ -52,6 +52,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Optional;
@@ -98,6 +99,31 @@ public class CmsGroupRelationController {
 
     private final GptRechargeCardKeyChannelMapper gptRechargeCardKeyChannelMapper;
 
+    private List<Long> getOrderRelationIds(OrderDon orderDon) {
+        List<Long> relationIds = new ArrayList<>();
+        if (orderDon.getNum() != null && orderDon.getNum() > 1) {
+            relationIds.addAll(orderDonTicketRecordMapper.selectList(
+                            Wrappers.lambdaQuery(OrderDonTicketRecord.class)
+                                    .select(OrderDonTicketRecord::getRelationId)
+                                    .eq(OrderDonTicketRecord::getOrderId, orderDon.getId())
+                                    .eq(OrderDonTicketRecord::getStatus, OrderDonTicketRecord.Status.success)
+                                    .isNotNull(OrderDonTicketRecord::getRelationId))
+                    .stream()
+                    .map(OrderDonTicketRecord::getRelationId)
+                    .distinct()
+                    .collect(Collectors.toList()));
+        }
+        if (orderDon.getRelationId() != null && orderDon.getRelationId() > 0
+                && !relationIds.contains(orderDon.getRelationId())) {
+            relationIds.add(orderDon.getRelationId());
+        }
+        // An empty IN list has database-dependent semantics; use an impossible relation id.
+        if (relationIds.isEmpty()) {
+            relationIds.add(0L);
+        }
+        return relationIds;
+    }
+
     @GetMapping("/get")
     public Result<List<GroupsRelationBackView>> get(){
         List<GroupsRelationBackView> search = beanSearcher.searchAll(GroupsRelationBackView.class, MapUtils.flatBuilder(request.getParameterMap())
@@ -131,12 +157,14 @@ public class CmsGroupRelationController {
                     .eq(StrUtil.isNotBlank(orderNo), OrderDon::getOrderNo, orderNo)
                     .eq(StrUtil.isNotBlank(transactionId), OrderDon::getTransactionId, transactionId)
                     .last("limit 1"));
-            Long relationId = 0l;
             if (orderDon != null) {
-                relationId = orderDon.getRelationId();
                 builder.field(GroupsRelationRechargeView::getUserId, orderDon.getUserId());
+                List<Long> relationIds = getOrderRelationIds(orderDon);
+                builder.field(GroupsRelationRechargeView::getRelationId, relationIds)
+                        .op(Operator.InList);
+            } else {
+                builder.field(GroupsRelationRechargeView::getRelationId, 0L);
             }
-            builder.field(GroupsRelationRechargeView::getRelationId, relationId);
         }
         if (isVipError != null) {
             builder.field(GroupsRelationRechargeView::getRechargeStatus, GroupsRelation.RechargeStatus.recharge_error.name());
@@ -193,12 +221,14 @@ public class CmsGroupRelationController {
             OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
                     .eq(OrderDon::getOrderNo, orderNo)
                     .last("limit 1"));
-            Long relationId = 0l;
             if (orderDon != null) {
-                relationId = orderDon.getRelationId();
                 builder.field(ExcelRechargeAccountData::getUserId, orderDon.getUserId());
+                List<Long> relationIds = getOrderRelationIds(orderDon);
+                builder.field(ExcelRechargeAccountData::getRelationId, relationIds)
+                        .op(Operator.InList);
+            } else {
+                builder.field(ExcelRechargeAccountData::getRelationId, 0L);
             }
-            builder.field(ExcelRechargeAccountData::getRelationId, relationId);
         }
         if (isVipError != null) {
             builder.field(ExcelRechargeAccountData::getRechargeStatus, GroupsRelation.RechargeStatus.recharge_error.name());