Jelajahi Sumber

Merge remote-tracking branch 'origin/ScrmStores' into ScrmStores

吴树波 1 hari lalu
induk
melakukan
66fb0097ec

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreScrmServiceImpl.java

@@ -147,7 +147,7 @@ public class FsStoreScrmServiceImpl implements IFsStoreScrmService
         //验证资质日期是否正常
         LocalDate today = LocalDate.now(ZoneId.of("Asia/Shanghai"));
         if(fsStore.getBusinessLicenseExpireEnd().isBefore(today) || fsStore.getDrugLicenseExpiryEnd().isBefore(today)
-                || fsStore.getMedicalDevice2ExpiryEnd().isBefore(today) || fsStore.getMedicalLicenseExpiryEnd().isBefore(today)) {
+                || fsStore.getMedicalDevice2ExpiryEnd().isBefore(today) || fsStore.getMedicalLicenseExpiryEnd().isBefore(today) || fsStore.getStatus() == 0) {
             fsStore.setStatus(0);
         }else {
             fsStore.setStatus(1);

+ 3 - 0
fs-service/src/main/java/com/fs/user/domain/param/FsUserComplaintParam.java

@@ -8,4 +8,7 @@ public class FsUserComplaintParam extends FsUserComplaint {
     private String userName;
 
     private String nickName;
+
+    //查询标识1店铺
+    private Integer queryIdentifier;
 }

+ 3 - 0
fs-service/src/main/java/com/fs/user/domain/vo/FsUserComplaintVo.java

@@ -8,4 +8,7 @@ import lombok.Data;
 public class FsUserComplaintVo extends FsUserComplaint {
     @Excel(name = "用户")
     private String nickName;
+
+    @Excel(name = "店铺名称")
+    private String storeName;
 }

+ 7 - 0
fs-service/src/main/java/com/fs/user/mapper/FsUserComplaintMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.user.domain.FsUserComplaint;
 import com.fs.user.domain.param.FsUserComplaintParam;
 import com.fs.user.domain.vo.FsUserComplaintVo;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 用户投诉Mapper接口
@@ -63,4 +64,10 @@ public interface FsUserComplaintMapper extends BaseMapper<FsUserComplaint>{
      * @return 结果
      */
     int deleteFsUserComplaintByIds(Long[] ids);
+
+    /**
+     * @param complaintId 投诉ID
+     * @param storeId 店铺id
+     * **/
+    int updateComplaintById(@Param("complaintId") Long complaintId, @Param("storeId") Long storeId);
 }

+ 6 - 0
fs-service/src/main/java/com/fs/user/service/IFsUserComplaintService.java

@@ -68,4 +68,10 @@ public interface IFsUserComplaintService extends IService<FsUserComplaint>{
 
     List<ProductScrmListVO> getProductListByOrderId(Long orderId);
 
+    /**
+     * @param complaintId 投诉ID
+     * @param storeId 店铺id
+     * **/
+    int updateComplaintById(Long complaintId,Long storeId);
+
 }

+ 5 - 0
fs-service/src/main/java/com/fs/user/service/impl/FsUserComplaintServiceImpl.java

@@ -158,5 +158,10 @@ public class FsUserComplaintServiceImpl extends ServiceImpl<FsUserComplaintMappe
 
         return result;
     }
+
+    @Override
+    public int updateComplaintById(Long complaintId, Long storeId) {
+        return baseMapper.updateComplaintById(complaintId,storeId);
+    }
 }
 

+ 36 - 8
fs-service/src/main/resources/mapper/user/FsUserComplaintMapper.xml

@@ -57,9 +57,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectFsUserComplaintVoList" resultType="com.fs.user.domain.vo.FsUserComplaintVo">
         select c.id, u.nick_name,c.title, c.content, c.images, c.type, c.link_id, c.create_time, c.create_by, c.update_time, c.update_by,
-               c.remark,c.complaint_type,c.is_handle_store,c.is_handle_platform,c.is_read_user,c.is_read_store,c.is_read_platform,c.store_id,is_process_completed
-        from fs_user_complaint c
-        left join fs_user u on c.fs_user_id = u.user_id
+               c.remark,c.complaint_type,c.is_handle_store,c.is_handle_platform,c.is_read_user,c.is_read_store,c.is_read_platform,c.store_id,is_process_completed, ss.store_name
+        from
+        fs_user_complaint c
+        LEFT JOIN fs_user u ON c.fs_user_id = u.user_id
+        LEFT JOIN fs_store_scrm ss ON c.store_id = ss.store_id
         <where>
             <if test="fsUserId != null "> and c.fs_user_id = #{fsUserId}</if>
             <if test="nickName != null and nickName != ''"> and u.nick_name like CONCAT('%',#{nickName},'%')</if>
@@ -75,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isReadStore != null "> and c.is_read_store = #{isReadStore}</if>
             <if test="isReadPlatform != null "> and c.is_read_platform = #{isReadPlatform}</if>
             <if test="storeId != null "> and c.store_id = #{storeId}</if>
+            <if test="queryIdentifier != null and queryIdentifier == 1">OR (c.complaint_type = 1 AND c.store_id IS NULL)</if>
         </where>
         order by id desc
     </select>
@@ -85,11 +88,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectFsUserComplaintVoById" parameterType="Long" resultType="com.fs.user.domain.vo.FsUserComplaintVo">
-        select c.id, u.nick_name,c.title, c.content, c.images, c.type, c.link_id, c.create_time, c.create_by, c.update_time, c.update_by,
-               c.remark,c.complaint_type,c.is_handle_store,c.is_handle_platform,c.is_read_user,c.is_read_store,c.is_read_platform,c.store_id
-               ,c.is_process_completed
-        from fs_user_complaint c
-                 left join fs_user u on c.fs_user_id = u.user_id
+        SELECT
+            c.id,
+            u.nick_name,
+            c.title,
+            c.content,
+            c.images,
+            c.type,
+            c.link_id,
+            c.create_time,
+            c.create_by,
+            c.update_time,
+            c.update_by,
+            c.remark,
+            c.complaint_type,
+            c.is_handle_store,
+            c.is_handle_platform,
+            c.is_read_user,
+            c.is_read_store,
+            c.is_read_platform,
+            c.store_id,
+            c.is_process_completed,
+            ss.store_name
+        FROM
+            fs_user_complaint c
+                LEFT JOIN fs_user u ON c.fs_user_id = u.user_id
+                LEFT JOIN fs_store_scrm ss ON c.store_id = ss.store_id
         where c.id = #{id}
     </select>
 
@@ -180,4 +204,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <update id="updateComplaintById">
+        update  fs_user_complaint set store_id = #{storeId} where id = #{complaintId} and  store_id IS NULL
+    </update>
 </mapper>

+ 1 - 0
fs-store/src/main/java/com/fs/hisStore/controller/store/FsUserComplaintController.java

@@ -39,6 +39,7 @@ public class FsUserComplaintController extends BaseController
     {
         param.setStoreId(UserUtil.getLoginUserStoreID());
         param.setComplaintType(1); //店铺仅能看咨询的
+        param.setQueryIdentifier(1);
         startPage();
         List<FsUserComplaintVo> list = fsUserComplaintService.selectFsUserComplaintVoList(param);
         return getDataTable(list);

+ 45 - 5
fs-store/src/main/java/com/fs/hisStore/controller/store/FsUserComplaintMsgController.java

@@ -5,15 +5,22 @@ import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.exception.ServiceException;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.hisStore.utils.UserUtil;
 import com.fs.user.domain.FsUserComplaintMsg;
+import com.fs.user.domain.vo.FsUserComplaintVo;
 import com.fs.user.service.IFsUserComplaintMsgService;
+import com.fs.user.service.IFsUserComplaintService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
 
 /**
  * 投诉消息记录Controller
@@ -28,6 +35,9 @@ public class FsUserComplaintMsgController extends BaseController
     @Autowired
     private IFsUserComplaintMsgService fsUserComplaintMsgService;
 
+    @Autowired
+    private IFsUserComplaintService fsUserComplaintService;
+
     /**
      * 查询投诉消息记录列表
      */
@@ -65,15 +75,45 @@ public class FsUserComplaintMsgController extends BaseController
      */
     @Log(title = "投诉消息记录", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody FsUserComplaintMsg fsUserComplaintMsg)
-    {
-        if (fsUserComplaintMsg.getComplaintId() == null){
+    public AjaxResult add(@RequestBody FsUserComplaintMsg fsUserComplaintMsg) {
+        Long complaintId = fsUserComplaintMsg.getComplaintId();
+        if (complaintId == null) {
             return AjaxResult.error("未查询到相关投诉!");
         }
+
         Long storeId = UserUtil.getLoginUserStoreID();
         fsUserComplaintMsg.setUserId(storeId);
-        fsUserComplaintMsg.setSendType(3); //店铺
-        return toAjax(fsUserComplaintMsgService.insertFsUserComplaintMsg(fsUserComplaintMsg));
+        fsUserComplaintMsg.setSendType(3);
+
+        Map<Long, Lock> complaintLockPool = new ConcurrentHashMap<>();
+        Lock complaintLock = complaintLockPool.computeIfAbsent(complaintId, k -> new ReentrantLock());
+
+        try {
+            complaintLock.lock();
+            FsUserComplaintVo complaintVo = fsUserComplaintService.selectFsUserComplaintVoById(complaintId);
+            if (complaintVo == null) {
+                throw new ServiceException("操作失败,数据不存在!");
+            }
+
+            if (complaintVo.getComplaintType() == 1) {
+                Long targetStoreId = complaintVo.getStoreId();
+
+                if (targetStoreId != null && !targetStoreId.equals(storeId)) {
+                    throw new ServiceException("当前咨询,已有店铺处理!");
+                }
+
+                if (targetStoreId == null) {
+                    int updateCount = fsUserComplaintService.updateComplaintById(complaintId, storeId);
+                    if (updateCount <= 0) {
+                        throw new ServiceException("当前咨询,已有店铺处理!");
+                    }
+                }
+            }
+            return toAjax(fsUserComplaintMsgService.insertFsUserComplaintMsg(fsUserComplaintMsg));
+
+        } finally {
+            complaintLock.unlock();
+        }
     }
 
     /**