From 4351e71d782741143a98f86f6648acd16689165f Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Fri, 27 May 2022 19:48:02 +0800
Subject: [PATCH] Merge branch 'developer' into hive2.0

---
 zq-erp/src/main/java/com/matrix/system/app/action/ApiFollowupAction.java |   74 ++++++------------------------------
 1 files changed, 13 insertions(+), 61 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiFollowupAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiFollowupAction.java
index 13455fa..ba2e8b8 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiFollowupAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiFollowupAction.java
@@ -1,11 +1,15 @@
 package com.matrix.system.app.action;
 
+import com.matrix.beauty.followup.dao.SysFollowupDao;
+import com.matrix.beauty.followup.entry.SysFollowup;
+import com.matrix.beauty.followup.service.SysFollowupService;
 import com.matrix.core.constance.MatrixConstance;
 import com.matrix.core.pojo.AjaxResult;
 import com.matrix.core.tools.StringUtils;
 import com.matrix.core.tools.WebUtil;
 import com.matrix.system.app.dto.*;
 import com.matrix.system.common.bean.SysUsers;
+import com.matrix.system.common.tools.DataAuthUtil;
 import com.matrix.system.hive.bean.*;
 import com.matrix.system.hive.dao.*;
 import com.matrix.system.hive.plugin.util.CollectionUtils;
@@ -33,21 +37,11 @@
     private SysFollowupDao followupDao;
 
     @Autowired
-    private SysVipAlbumDao vipAlbumDao;
-
-    @Autowired
-    private SysVipInfoDao vipInfoDao;
-
-    @Autowired
     private SysFollowupCommentDao followupCommentDao;
 
 
-
     @Autowired
-    private SysOrderItemDao orderItemDao;
-
-    @Autowired
-    private SysBeauticianStateDao beauticianStateDao;
+    private SysFollowupService followupService;
 
 
     @ApiOperation(value = "新增跟进记录", notes = "新增跟进记录")
@@ -56,51 +50,7 @@
     })
     @PostMapping(value = "/addFollowup")
     public AjaxResult addFollowup(@RequestBody @Validated SysFollowup followup) {
-        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
-        followup.setCreateBy(user.getSuName());
-        followup.setUpdateBy(user.getSuName());
-        followup.setStaffId(user.getSuId());
-        followup.setCompanyId(user.getCompanyId());
-        followup.setShopId(user.getShopId());
-        //处理订单摘要
-        if(followup.getOrderId()!=null){
-            List<SysOrderItem> sysOrderItems = orderItemDao.selectByOrderId(followup.getOrderId());
-            String abs="";
-            if(sysOrderItems.size()>1){
-                abs= sysOrderItems.get(0).getShoppingGoods().getName()+"等"+sysOrderItems.size()+"件商品";
-            }else{
-                abs= sysOrderItems.get(0).getShoppingGoods().getName();
-            }
-           followup.setOrderAbstract(abs);
-        }
-        //服务单摘要
-        if(followup.getServiceId()!=null){
-            List<SysBeauticianState> sysBeauticianStates = beauticianStateDao.selectBySerIds(followup.getServiceId());
-            String abs="";
-            if(sysBeauticianStates.size()>1){
-                abs= sysBeauticianStates.get(0).getProjInfo().getName()+"等"+sysBeauticianStates.size()+"项服务";
-            }else{
-                abs= sysBeauticianStates.get(0).getProjInfo().getName();
-            }
-            followup.setOrderAbstract(abs);
-        }
-
-        followupDao.insert(followup);
-        //插入图片
-        List<SysVipAlbum> albums=followup.getAlbums();
-        if(CollectionUtils.isNotEmpty(albums)){
-            for (SysVipAlbum vipAlbum:albums){
-                if(StringUtils.isNotBlank(vipAlbum.getImg())){
-                    vipAlbum.setCreateBy(user.getSuName());
-                    vipAlbum.setUpdateBy(user.getSuName());
-                    vipAlbum.setSource(SysVipAlbum.SOURCE_FOLLOW);
-                    vipAlbum.setVipId(followup.getVipId());
-                    vipAlbum.setSourceId(followup.getId());
-                    vipAlbumDao.insert(vipAlbum);
-                }
-            }
-        }
-
+        followupService.save(followup);
         return AjaxResult.buildSuccessInstance("保存成功");
     }
 
@@ -113,18 +63,18 @@
         SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
         SysFollowup followup = followupDao.selectById(id);
         String zans=followup.getZans();
-        if(StringUtils.isBlank(zans)){
+        if(StringUtils.isNotBlank(zans)){
             List<Long> zanIds = StringUtils.strToCollToLong(zans, ",");
             List<Long> zaned = zanIds.stream().filter(zanid -> zanid.equals(user.getSuId())).collect(Collectors.toList());
-            if(CollectionUtils.isEmpty(zaned)){
+            if(CollectionUtils.isNotEmpty(zaned)){
                 //取消赞
                 List<Long> newZaned = zanIds.stream().filter(zanid -> !zanid.equals(user.getSuId())).collect(Collectors.toList());
                 zans=StringUtils.collToStr(newZaned,",");
 
             }else{
                 //点赞
-                zaned.add(user.getSuId());
-                zans=StringUtils.collToStr(zaned,",");
+                zanIds.add(user.getSuId());
+                zans=StringUtils.collToStr(zanIds,",");
             }
         }else{
             //直接点赞
@@ -157,7 +107,9 @@
     @PostMapping(value = "/findFollowup")
     public AjaxResult findFollowup(@RequestBody @Validated FollowupListDto followupListDto) {
         SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
-        followupListDto.setShopId(user.getShopId());
+        if(!DataAuthUtil.hasAllShopAuth()){
+            followupListDto.setShopId(user.getShopId());
+        }
         followupListDto.setCompanyId(user.getCompanyId());
         followupListDto.setSelfStaff(user.getSuId());
         //TODO 需要设置跨店数据权限

--
Gitblit v1.9.1