lyhzzz 5 달 전
부모
커밋
08831fdac7

+ 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.HashMap;
 import java.util.HashSet;
 import java.util.List;
 
@@ -18,7 +19,7 @@ import java.util.List;
  */
 public interface IProductCooperationService extends IService<ProductCooperation> {
 
-    void add(ProductOrder productOrder, List<User> users,List<String>numList1, HashSet<String> numList2, HashSet<String> numList3,String sceneType);
+    void add(ProductOrder productOrder, List<User> users, List<String>numList1, HashMap<Long,String> map1, HashMap<Long,String> map2, String sceneType);
 
     void paySuccess(String orderSn);
 }

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

@@ -33,18 +33,18 @@ public class ProductCooperationServiceImpl extends ServiceImpl<IProductCooperati
     IProductOrderService productOrderService;
 
     @Override
-    public void add(ProductOrder productOrder, List<User> users,List<String> list , HashSet<String> numList, HashSet<String> numLis2, String sceneType) {
+    public void add(ProductOrder productOrder, List<User> users,List<String> list , HashMap<Long,String> map1, HashMap<Long,String> map2, String sceneType) {
 
         if(StringUtils.isBlank(sceneType)){
-            this.saveList(productOrder,users,list,numList,"mesh");
-            this.saveList(productOrder,users,list,numLis2,"laser");
+            this.saveList(productOrder,users,list,map1,"mesh");
+            this.saveList(productOrder,users,list,map2,"laser");
         }else {
-            this.saveList(productOrder,users,list,numList,sceneType);
+            this.saveList(productOrder,users,list,map1,sceneType);
         }
 
     }
 
-    private void saveList(ProductOrder productOrder, List<User> users,List<String> list , HashSet<String> numList,String sceneType){
+    private void saveList(ProductOrder productOrder, List<User> users,List<String> list ,  HashMap<Long,String> map1,String sceneType){
         List<ProductCooperation> productCooperations = new ArrayList<>();
 
         for (String num : list) {
@@ -54,7 +54,7 @@ public class ProductCooperationServiceImpl extends ServiceImpl<IProductCooperati
                 productCooperation.setCooperationUserId(user.getId());
                 productCooperation.setNum(num);
                 productCooperation.setSceneType(sceneType);
-                if(numList.contains(num)){
+                if(map1.get(user.getId()) != null){
                     productCooperation.setNeedPay(1);
                 }
                 productCooperations.add(productCooperation);

+ 5 - 0
src/main/java/com/fdkankan/ucenter/service/impl/SceneCooperationCountServiceImpl.java

@@ -36,7 +36,12 @@ public class SceneCooperationCountServiceImpl extends ServiceImpl<ISceneCooperat
         if(needPay == null || needPay.isEmpty() || size <=0){
             return;
         }
+        HashSet<String> hashSet = new HashSet<>();
         for (ProductCooperation productCooperation : needPay) {
+            if(hashSet.contains(productCooperation.getNum()+productCooperation.getSceneType())){
+                continue;
+            }
+            hashSet.add(productCooperation.getNum()+productCooperation.getSceneType());
             List<SceneCooperation> sceneCooperations = sceneCooperationService.getByNum(productCooperation.getNum(), productCooperation.getSceneType());
 
             String num = productCooperation.getNum();

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

@@ -396,8 +396,8 @@ 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) {
-        HashSet<String> needNumListMesh =new HashSet<>();
-        HashSet<String> needNumListLaser =new HashSet<>();
+        HashMap<Long,String> needNumListMesh = new HashMap<>();
+        HashMap<Long,String> needNumListLaser =new HashMap<>();
         if(StringUtils.isBlank(sceneType)){
             needNumListMesh = getTotalCount(numList,users,"mesh",cameraId);
             needNumListLaser =  getTotalCount(numList,users,"laser",cameraId);
@@ -413,13 +413,13 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
 
     }
 
-    private HashSet<String> getTotalCount(List<String> numList, List<User> users,String sceneType,Long cameraId){
+    private HashMap<Long,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);
-        HashSet<String> needNumList = new HashSet<>();
+        HashMap<Long,String> needNumList = new HashMap<>();
         for (String num : numList) {
             Integer freeCount = freeMap.get(num) == null ? 1 :freeMap.get(num);
 
@@ -432,8 +432,8 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
                 }
             }
 
-            if(users.size() - freeCount >0){
-                needNumList.add(num);
+            for (int i = 0 ; i< users.size() -freeCount;i++){
+                needNumList.put(users.get(i).getId(),num);
             }
 
         }

+ 2 - 2
src/main/resources/mapper/ucenter/SceneProMapper.xml

@@ -24,7 +24,7 @@
     <select id="pageListAndFolder" resultType="com.fdkankan.ucenter.vo.response.SceneVo">
         <include refid="HasFolder"></include>
         SELECT * FROM (
-        SELECT  p.id ,null as name ,0 as isFolder,null as type,null as parentId ,p.create_time,num,scene_name,scene_dec,
+        SELECT DISTINCT  p.id ,null as name ,0 as isFolder,null as type,null as parentId ,p.create_time,num,scene_name,scene_dec,
         p.status,pay_status,thumb,web_site,0 as is_upgrade,sn_code,view_count,p.build_type, null as removePortrait,p.scene_source
         FROM t_scene_pro p
         <include refid="sceneJoinCamera"></include>
@@ -39,7 +39,7 @@
           and  p.is_obj  = #{param.isObj}
         </if>
         UNION ALL
-        SELECT  p.id as id ,null as name ,0 as isFolder,null as type,null as parentId,e.algorithm_time as createTime ,num,title as scene_name,description as scene_dec,
+        SELECT  DISTINCT  p.id as id ,null as name ,0 as isFolder,null as type,null as parentId,e.algorithm_time as createTime ,num,title as scene_name,description as scene_dec,
         scene_status as status,pay_status,thumb,web_site,1 as is_upgrade,sn_code,view_count,e.build_type,p.remove_portrait as removePortrait,p.scene_source
         FROM t_scene_plus p
         LEFT JOIN t_scene_plus_ext e on p.id = e.plus_id