lyhzzz před 4 měsíci
rodič
revize
cd91195551

+ 5 - 1
doc/update1.10.9.sql

@@ -99,4 +99,8 @@ CREATE TABLE `t_scene_cooperation_count` (
 
 
 ALTER TABLE `4dkankan_v4`.`t_scene_cooperation`
-    ADD COLUMN `scene_type` varchar(255) NULL DEFAULT 'mesh' AFTER `rec_status`;
+    ADD COLUMN `scene_type` varchar(255) NULL DEFAULT 'mesh' AFTER `rec_status`;
+
+ALTER TABLE `4dkankan_v4`.`t_product_cooperation`
+    ADD COLUMN `scene_type` varchar(255) NULL DEFAULT 'mesh' AFTER `update_time`,
+    ADD COLUMN `need_pay` int NULL DEFAULT 0 AFTER `scene_type`;

+ 4 - 0
src/main/java/com/fdkankan/ucenter/entity/ProductCooperation.java

@@ -47,5 +47,9 @@ public class ProductCooperation implements Serializable {
     @TableField("update_time")
     private Date updateTime;
 
+    @TableField("scene_type")
+    private String sceneType;
 
+    @TableField("need_pay")
+    private Integer needPay;
 }

+ 2 - 1
src/main/java/com/fdkankan/ucenter/service/IProductCooperationService.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.ucenter.entity.ProductOrder;
 import com.fdkankan.ucenter.entity.User;
 
+import java.util.HashSet;
 import java.util.List;
 
 /**
@@ -17,7 +18,7 @@ import java.util.List;
  */
 public interface IProductCooperationService extends IService<ProductCooperation> {
 
-    void add(ProductOrder productOrder, List<User> users,List<String> numList,Long cameraId);
+    void add(ProductOrder productOrder, List<User> users,List<String>numList1, HashSet<String> numList2, HashSet<String> numList3,String sceneType);
 
     void paySuccess(String orderSn);
 }

+ 2 - 1
src/main/java/com/fdkankan/ucenter/service/ISceneCooperationCountService.java

@@ -1,5 +1,6 @@
 package com.fdkankan.ucenter.service;
 
+import com.fdkankan.ucenter.entity.ProductCooperation;
 import com.fdkankan.ucenter.entity.SceneCooperationCount;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -15,7 +16,7 @@ import java.util.List;
  */
 public interface ISceneCooperationCountService extends IService<SceneCooperationCount> {
 
-    void saveCount(List<String> numList, Integer size,String sceneType,String type);
+    void saveCount(List<ProductCooperation> needPay, Integer size);
 
      List<SceneCooperationCount> getByNumList(List<String> numList,String sceneType);
 

+ 2 - 2
src/main/java/com/fdkankan/ucenter/service/ISceneCooperationService.java

@@ -40,13 +40,13 @@ public interface ISceneCooperationService extends IService<SceneCooperation> {
 
     HashMap<String, List<User>> getByNumList(List<String> numList,String sceneType);
 
-    SceneCooperation getByNum(String num);
+    List<SceneCooperation> getByNum(String num,String sceneType);
 
     Object cooperationSceneList(SceneParam param, String username);
 
     ProductOrder saveBatchCooperation(SceneCooperationParam param, String username);
 
-     void  successAddCooperation(List<String> numList,List<Long> userIds,Long loginUserId,Long cameraId,String lang,String sceneType);
+     void  successAddCooperation(List<String> numList,List<Long> userIds,Long loginUserId,Long cameraId,String lang,String sceneType, List<ProductCooperation> needPay );
 
 
      ProductOrder saveCamera(SceneCooperationParam param, String username);

+ 23 - 9
src/main/java/com/fdkankan/ucenter/service/impl/ProductCooperationServiceImpl.java

@@ -9,13 +9,11 @@ import com.fdkankan.ucenter.service.IProductCooperationService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.ucenter.service.IProductOrderService;
 import com.fdkankan.ucenter.service.ISceneCooperationService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -35,21 +33,36 @@ public class ProductCooperationServiceImpl extends ServiceImpl<IProductCooperati
     IProductOrderService productOrderService;
 
     @Override
-    public void add(ProductOrder productOrder, List<User> users,List<String> numList,Long cameraId) {
+    public void add(ProductOrder productOrder, List<User> users,List<String> list , HashSet<String> numList, HashSet<String> numLis2, String sceneType) {
+
+        if(StringUtils.isBlank(sceneType)){
+            this.saveList(productOrder,users,list,numList,"mesh");
+            this.saveList(productOrder,users,list,numLis2,"laser");
+        }else {
+            this.saveList(productOrder,users,list,numList,sceneType);
+        }
+
+    }
+
+    private void saveList(ProductOrder productOrder, List<User> users,List<String> list , HashSet<String> numList,String sceneType){
         List<ProductCooperation> productCooperations = new ArrayList<>();
-        for (String num : numList) {
+
+        for (String num : list) {
             for (User user : users) {
                 ProductCooperation productCooperation = new ProductCooperation();
                 productCooperation.setOrderSn(productOrder.getOrderSn());
                 productCooperation.setCooperationUserId(user.getId());
                 productCooperation.setNum(num);
+                productCooperation.setSceneType(sceneType);
+                if(numList.contains(num)){
+                    productCooperation.setNeedPay(1);
+                }
                 productCooperations.add(productCooperation);
             }
         }
         if(!productCooperations.isEmpty()){
             this.saveBatch(productCooperations);
         }
-
     }
 
     @Override
@@ -66,12 +79,13 @@ public class ProductCooperationServiceImpl extends ServiceImpl<IProductCooperati
             return;
         }
         List<String> numList = list.stream().map(ProductCooperation::getNum).collect(Collectors.toList());
+        List<ProductCooperation> needPay = list.stream().filter(e -> e.getNeedPay() == 1).collect(Collectors.toList());
         Set<Long> userIds = list.stream().map(ProductCooperation::getCooperationUserId).collect(Collectors.toSet());
 
         if(productOrder.getCameraId() != null){
-            sceneCooperationService.successAddCooperation(numList,new ArrayList<>(userIds),productOrder.getUserId(), productOrder.getCameraId(), productOrder.getLang(),null);
+            sceneCooperationService.successAddCooperation(numList,new ArrayList<>(userIds),productOrder.getUserId(), productOrder.getCameraId(), productOrder.getLang(),null,needPay);
         }else {
-            sceneCooperationService.successAddCooperation(numList,new ArrayList<>(userIds),productOrder.getUserId(), null, productOrder.getLang(),productOrder.getSceneType());
+            sceneCooperationService.successAddCooperation(numList,new ArrayList<>(userIds),productOrder.getUserId(), null, productOrder.getLang(),productOrder.getSceneType(),needPay);
         }
     }
 }

+ 16 - 33
src/main/java/com/fdkankan/ucenter/service/impl/SceneCooperationCountServiceImpl.java

@@ -3,6 +3,8 @@ package com.fdkankan.ucenter.service.impl;
 import com.alibaba.druid.sql.visitor.functions.Concat;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.fdkankan.ucenter.entity.ProductCooperation;
+import com.fdkankan.ucenter.entity.SceneCooperation;
 import com.fdkankan.ucenter.entity.SceneCooperationCount;
 import com.fdkankan.ucenter.entity.User;
 import com.fdkankan.ucenter.mapper.ISceneCooperationCountMapper;
@@ -30,48 +32,29 @@ public class SceneCooperationCountServiceImpl extends ServiceImpl<ISceneCooperat
     @Autowired
     ISceneCooperationService sceneCooperationService;
     @Override
-    public void saveCount(List<String> numList, Integer size,String sceneType,String type) {
-        if(numList == null || numList.isEmpty() || size <=0){
+    public void saveCount(List<ProductCooperation> needPay, Integer size) {
+        if(needPay == null || needPay.isEmpty() || size <=0){
             return;
         }
-        if("scene".equals(type) && size<=1){
-            return;
-        }
-        HashMap<String, List<User>> userMap = new HashMap<>();
-        if("camera".equals(type)){
-            userMap = sceneCooperationService.getByNumList(numList, sceneType);
-        }
+        for (ProductCooperation productCooperation : needPay) {
+            List<SceneCooperation> sceneCooperations = sceneCooperationService.getByNum(productCooperation.getNum(), productCooperation.getSceneType());
 
-        List<SceneCooperationCount> sceneCooperationCounts = this.getByNumList(numList,sceneType);
-        Set<String> dbNumList = sceneCooperationCounts.stream().map(SceneCooperationCount::getNum).collect(Collectors.toSet());
-        Set<String> addNumList = new HashSet<>(numList);
-
-        List<SceneCooperationCount> saveList = new ArrayList<>();
-        for (String num : addNumList) {
-            if(!dbNumList.contains(num)){
-                List<User> users = userMap.get(num);
-                Integer totalSize = users == null ?size :users.size() + size;
+            String num = productCooperation.getNum();
+            SceneCooperationCount byNum = this.getByNum(num, productCooperation.getSceneType());
+            if(byNum == null){
                 SceneCooperationCount count = new SceneCooperationCount();
-                count.setSceneType(sceneType);
+                count.setSceneType(productCooperation.getSceneType());
                 count.setNum(num);
-                count.setCount(totalSize );
-                saveList.add(count);
-            }
-        }
-        if(!saveList.isEmpty()){
-            this.saveBatch(saveList);
-        }
-
-        for (SceneCooperationCount sceneCooperationCount : sceneCooperationCounts) {
-            List<User> users = userMap.get(sceneCooperationCount.getNum());
-            Integer totalSize = users == null ?size :users.size() + size;
-            if(sceneCooperationCount.getCount() < totalSize){
+                count.setCount(size + sceneCooperations.size());
+                this.save(count);
+            }else {
                 LambdaUpdateWrapper<SceneCooperationCount> wrapper = new LambdaUpdateWrapper<>();
-                wrapper.eq(SceneCooperationCount::getId,sceneCooperationCount.getId());
-                wrapper.set(SceneCooperationCount::getCount,totalSize);
+                wrapper.eq(SceneCooperationCount::getId,byNum.getId());
+                wrapper.set(SceneCooperationCount::getCount,size + sceneCooperations.size());
                 this.update(wrapper);
             }
         }
+
     }
 
     @Override

+ 19 - 28
src/main/java/com/fdkankan/ucenter/service/impl/SceneCooperationServiceImpl.java

@@ -311,8 +311,6 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
 
         if(productOrder == null){
             successAddCooperation(numList,users,param.getLang(),loginUser,param.getSceneType());
-        }else {
-            productCooperationService.add(productOrder,users,numList,null);
         }
         return productOrder;
 
@@ -356,8 +354,6 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
         if(productOrder == null){
             successAddCooperation(v3List,v4List,Arrays.asList(user),param.getLang(),loginUser,Arrays.asList(camera),null);
             cameraDetailService.updateCooperationByIds(Arrays.asList(param.getCameraId()),user.getId());
-        }else {
-            productCooperationService.add(productOrder,Arrays.asList(user),allList,param.getCameraId());
         }
 
         return productOrder;
@@ -373,7 +369,7 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
     }
 
     @Override
-    public void  successAddCooperation(List<String> numList,List<Long> userIds,Long loginUserId,Long cameraId,String lang,String sceneType){
+    public void  successAddCooperation(List<String> numList,List<Long> userIds,Long loginUserId,Long cameraId,String lang,String sceneType,List<ProductCooperation> needPay ){
         //this.deleteCooperationList(numList,userIds);
         List<ScenePro> proList = sceneProService.getListByNums(numList);
         List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
@@ -386,12 +382,7 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
         }else {
             saveCooperationCommon(user,lang,users,proList,plusList,null,"scene",sceneType);
         }
-        if(StringUtils.isBlank(sceneType)){
-            sceneCooperationCountService.saveCount(numList,userIds.size(),"mesh","camera");
-            sceneCooperationCountService.saveCount(numList,userIds.size(),"laser","camera");
-        }else {
-            sceneCooperationCountService.saveCount(numList,userIds.size(),sceneType,"scene");
-        }
+        sceneCooperationCountService.saveCount(needPay,userIds.size());
 
     }
 
@@ -405,27 +396,27 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
 
 
     private ProductOrder checkNeedPay(List<String> numList, List<User> users,User loginUser,Integer payType,Integer timeZone,Long cameraId,String lang,String sceneType) {
-        Integer totalCount = 0;
+        HashSet<String> needNumListMesh =new HashSet<>();
+        HashSet<String> needNumListLaser =new HashSet<>();
         if(StringUtils.isBlank(sceneType)){
-            totalCount += getTotalCount(numList,users,"mesh",cameraId);
-            totalCount += getTotalCount(numList,users,"laser",cameraId);
+            needNumListMesh = getTotalCount(numList,users,"mesh",cameraId);
+            needNumListLaser =  getTotalCount(numList,users,"laser",cameraId);
         }else {
-            totalCount += getTotalCount(numList,users,sceneType,cameraId);
+            needNumListMesh = getTotalCount(numList,users,sceneType,cameraId);
         }
-        if(totalCount <=0){
-            return null;
-        }
-        return productOrderService.createOrder(totalCount, "cooperation", loginUser, payType, timeZone,cameraId,lang,sceneType);
+        ProductOrder productOrder = productOrderService.createOrder(needNumListMesh.size() + needNumListLaser.size(), "cooperation", loginUser, payType, timeZone, cameraId, lang, sceneType);
+        productCooperationService.add(productOrder,users,numList,needNumListMesh,needNumListLaser,sceneType);
+        return productOrder;
 
     }
 
-    private Integer getTotalCount(List<String> numList, List<User> users,String sceneType,Long cameraId){
+    private HashSet<String> getTotalCount(List<String> numList, List<User> users,String sceneType,Long cameraId){
         List<SceneCooperationCount> freeCountList = sceneCooperationCountService.getByNumList(numList,sceneType);
         HashMap<String,Integer> freeMap = new HashMap<>();
         freeCountList.forEach(e -> freeMap.put(e.getNum(),e.getCount()));
 
         HashMap<String, List<User>> map = this.getByNumList(numList,sceneType);
-        Integer totalCount = 0;
+        HashSet<String> needNumList = new HashSet<>();
         for (String num : numList) {
             Integer freeCount = freeMap.get(num) == null ? 1 :freeMap.get(num);
 
@@ -438,10 +429,12 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
                 }
             }
 
-            totalCount +=  (users.size() - freeCount );
+            if(users.size() - freeCount >0){
+                needNumList.add(num);
+            }
 
         }
-        return totalCount;
+        return needNumList;
     }
 
     @Autowired
@@ -565,14 +558,12 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
     }
 
     @Override
-    public SceneCooperation getByNum(String num) {
+    public List<SceneCooperation> getByNum(String num,String sceneType) {
         LambdaQueryWrapper<SceneCooperation> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(SceneCooperation::getSceneNum,num);
+        wrapper.eq(SceneCooperation::getSceneType,sceneType);
         List<SceneCooperation> list = this.list(wrapper);
-        if(list == null || list.size() <=0){
-            return null;
-        }
-        return list.get(0);
+        return list;
     }
 
     @Override

+ 12 - 7
src/main/java/com/fdkankan/ucenter/service/impl/SceneProServiceImpl.java

@@ -484,14 +484,19 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         Page<SceneVo> sceneList = sceneService.getSceneList(param);
         for (SceneVo record : sceneList.getRecords()) {
             record.setUserName(username);
-            SceneCooperation sceneCooperationEntity = sceneCooperationService.getByNum(record.getNum());
-            if(sceneCooperationEntity != null && sceneCooperationEntity.getUserId()!= null){
-
-                User user1 = userService.getById(sceneCooperationEntity.getUserId());
-                if(user1 != null){
-                    record.setCooperationUserId(String.valueOf(sceneCooperationEntity.getUserId()));
-                    record.setCooperationUserName(user1.getUserName());
+            List<SceneCooperation> sceneCooperationEntitys = sceneCooperationService.getByNum(record.getNum(),"mesh");
+            if(sceneCooperationEntitys != null && !sceneCooperationEntitys.isEmpty()){
+                List<String> userNameList = new ArrayList<>();
+                List<Long> userIds = new ArrayList<>();
+                for (SceneCooperation sceneCooperationEntity : sceneCooperationEntitys) {
+                    User user1 = userService.getById(sceneCooperationEntity.getUserId());
+                    if(user1 != null){
+                        userIds.add(sceneCooperationEntity.getUserId());
+                        userNameList.add(user1.getUserName());
+                    }
                 }
+                record.setCooperationUserNameList(userNameList);
+                record.setCooperationUserIdList(userIds);
             }
         }
         return PageInfo.PageInfo(sceneList);