lyhzzz 4 months ago
parent
commit
e716f2f573

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

@@ -36,9 +36,9 @@ public class SceneCooperationCountServiceImpl extends ServiceImpl<ISceneCooperat
         if(needPay == null || needPay.isEmpty() || size <=0){
             return;
         }
-        HashSet<String> strings = new HashSet<>();
+        HashMap<String,Integer> map = new HashMap<>();
         for (ProductCooperation productCooperation : needPay) {
-            strings.add(productCooperation.getSceneType() + productCooperation.getNum() + productCooperation.getCooperationUserId());
+            map.merge(productCooperation.getNum() + productCooperation.getSceneType(), 1, Integer::sum);
         }
 
         HashSet<String> hashSet = new HashSet<>();
@@ -54,12 +54,12 @@ public class SceneCooperationCountServiceImpl extends ServiceImpl<ISceneCooperat
                 SceneCooperationCount count = new SceneCooperationCount();
                 count.setSceneType(productCooperation.getSceneType());
                 count.setNum(num);
-                count.setCount( strings.size());
+                count.setCount( map.get(num + productCooperation.getSceneType()));
                 this.save(count);
             }else {
                 LambdaUpdateWrapper<SceneCooperationCount> wrapper = new LambdaUpdateWrapper<>();
                 wrapper.eq(SceneCooperationCount::getId,byNum.getId());
-                wrapper.set(SceneCooperationCount::getCount, byNum.getCount() + strings.size());
+                wrapper.set(SceneCooperationCount::getCount, byNum.getCount() + map.get(num + productCooperation.getSceneType()));
                 this.update(wrapper);
             }
         }