|
@@ -20,6 +20,7 @@ import com.fdkankan.ucenter.vo.request.SceneCooperationParam;
|
|
|
import com.fdkankan.ucenter.vo.request.SceneParam;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.opencv.face.Face;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -225,13 +226,15 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void saveBatchCooperation(SceneCooperationParam param, String username) {
|
|
|
+ public void saveBatchCooperation(SceneCooperationParam param, String loginUserName) {
|
|
|
if(param.getUserNameList() == null || param.getUserNameList().isEmpty() || StringUtils.isEmpty(param.getSceneNum())){
|
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
|
|
|
}
|
|
|
- if(param.getUserName().contains( username)){
|
|
|
+ if(param.getUserName().contains( loginUserName)){
|
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3024, LoginConstant.FAILURE_MSG_3024);
|
|
|
}
|
|
|
+ User loginUser = userService.getByUserName(loginUserName);
|
|
|
+
|
|
|
List<User> users = new ArrayList<>();
|
|
|
for (String userName : param.getUserNameList()) {
|
|
|
User user = userService.getByUserName(userName);
|
|
@@ -242,13 +245,48 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
|
}
|
|
|
String[] nums = param.getSceneNum().split(",");
|
|
|
List<String> numList = Arrays.asList(nums);
|
|
|
- List<ScenePro> proList = sceneProService.getListByNums(numList);
|
|
|
- List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
|
|
|
- this.deleteCooperationList(proList,plusList);
|
|
|
|
|
|
- saveCooperationCommon(param,users,proList,plusList);
|
|
|
+ ProductOrder productOrder = checkNeedPay(numList, users, loginUser, param.getPayType(), param.getTimeZone());
|
|
|
+
|
|
|
+ if(productOrder == null){
|
|
|
+ List<ScenePro> proList = sceneProService.getListByNums(numList);
|
|
|
+ List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
|
|
|
+ this.deleteCooperationList(proList,plusList);
|
|
|
+ saveCooperationCommon(param,users,proList,plusList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IProductOrderService productOrderService;
|
|
|
+
|
|
|
+ private ProductOrder checkNeedPay(List<String> numList, List<User> users,User loginUser,Integer payType,Integer timeZone) {
|
|
|
+ Integer totalCount = 0;
|
|
|
+ HashMap<String, List<User>> map = this.getByNumList(numList);
|
|
|
+ for (String num : map.keySet()) {
|
|
|
+ List<User> users1 = map.get(num);
|
|
|
+ if (users1.isEmpty()){
|
|
|
+ totalCount += users.size() -1 ;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<Long> collect1 = users1.stream().map(User::getId).collect(Collectors.toList());
|
|
|
+ List<Long> collect2 = users.stream().map(User::getId).collect(Collectors.toList());
|
|
|
+ List<Long> collect = collect2.stream().filter(e -> !collect1.contains(e)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ totalCount += collect.size();
|
|
|
+
|
|
|
+ }
|
|
|
+ if(totalCount <=0){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ return productOrderService.createOrder(totalCount,"cooperation",loginUser,payType,timeZone);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Autowired
|
|
|
LaserService laserService;
|
|
|
|
|
@@ -311,16 +349,20 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HashMap<String, User> getByNumList(List<String> numList) {
|
|
|
+ public HashMap<String, List<User>> getByNumList(List<String> numList) {
|
|
|
LambdaQueryWrapper<SceneCooperation> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.in(SceneCooperation::getSceneNum,numList);
|
|
|
List<SceneCooperation> list = this.list(wrapper);
|
|
|
- HashMap<String,User> cooMap = new HashMap<>();
|
|
|
+ HashMap<String,List<User>> cooMap = new HashMap<>();
|
|
|
if(list.size() >0){
|
|
|
List<Long> userIds = list.parallelStream().map(SceneCooperation::getUserId).collect(Collectors.toList());
|
|
|
if(userIds.size() >0){
|
|
|
HashMap<Long, User> userMap = userService.getByIds(userIds);
|
|
|
- list.forEach(entity -> cooMap.put(entity.getSceneNum(),userMap.get(entity.getUserId())));
|
|
|
+ for (SceneCooperation entity : list) {
|
|
|
+ User user = userMap.get(entity.getUserId());
|
|
|
+ cooMap.computeIfAbsent(entity.getSceneNum(), k -> new ArrayList<>());
|
|
|
+ cooMap.get(entity.getSceneNum()).add(user);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return cooMap;
|