Browse Source

删除牙刷修改

wangxiaoming 6 years ago
parent
commit
b4e02d81de

+ 21 - 2
tooth-wechat-service/src/main/java/com/iamberry/wechat/service/apparatus/ApparatusServiceImpl.java

@@ -277,9 +277,28 @@ public class ApparatusServiceImpl implements ApparatusService {
             throw new RuntimeException("删除失败,未查询出待入账");
         }
         if(stayIntegralList != null && stayIntegralList.size() > 1){
-            throw new RuntimeException("删除失败,查出多个待入账");
+            //因为系统没有牙刷绑定与待入账积分绑定关系,所以只能对比时间来判断是删除的那个牙刷,下面是比较时间计算那个时间相近
+            long num = 0;
+            for(int i=0;i<stayIntegralList.size();i++){
+                StayIntegral si = stayIntegralList.get(i);
+                long item = si.getStayCreateTime().getTime() - apparatus.getApparatusCreateTime().getTime();
+                if(item < 0){
+                    item *= -1;  //计算绝对值
+                }
+                if(i == 0 ){
+                    num = item;
+                    stayIntegral = stayIntegralList.get(i);
+                }else{
+                    if(item < num){
+                        num = item;
+                        stayIntegral = stayIntegralList.get(i);
+                    }
+                }
+            }
+        }else{
+            stayIntegral = stayIntegralList.get(0);
         }
-        stayIntegral = stayIntegralList.get(0);
+
         stayStatus = stayIntegral.getStayStatus();
         stayIntegraNum = stayIntegral.getStayNumber();