浏览代码

Merge branch 'master' of http://1.14.104.71:10880/root/ylrz_scrm_java

caoliqin 1 周之前
父节点
当前提交
93223c53a0

+ 5 - 2
fs-company/src/main/java/com/fs/qw/QwMsgController.java

@@ -201,15 +201,18 @@ public class QwMsgController extends BaseController
         if(qwExternalContactId == null) {
         if(qwExternalContactId == null) {
             throw new CustomException("企微外部联系人id不能为空!");
             throw new CustomException("企微外部联系人id不能为空!");
         }
         }
+
         QwExternalContactInfo contactInfo = qwExternalContactInfoService.selectQwExternalContactInfoByExternalContactId(qwExternalContactId);
         QwExternalContactInfo contactInfo = qwExternalContactInfoService.selectQwExternalContactInfoByExternalContactId(qwExternalContactId);
         if (contactInfo==null){
         if (contactInfo==null){
-
             contactInfo = new QwExternalContactInfo();
             contactInfo = new QwExternalContactInfo();
             contactInfo.setExternalContactId(qwExternalContactId);
             contactInfo.setExternalContactId(qwExternalContactId);
             qwExternalContactInfoService.insertQwExternalContactInfo(contactInfo);
             qwExternalContactInfoService.insertQwExternalContactInfo(contactInfo);
-
         }
         }
 
 
+        // 已购状态
+        Boolean isBuy = qwExternalContactService.getBuyStatusByExtId(qwExternalContactId);
+        contactInfo.setIsBuy(isBuy ? "是" : "否");
+
         return R.ok().put("moreInfo",contactInfo);
         return R.ok().put("moreInfo",contactInfo);
     }
     }
 
 

+ 6 - 0
fs-service-system/src/main/java/com/fs/qw/mapper/QwExternalContactMapper.java

@@ -396,4 +396,10 @@ public interface QwExternalContactMapper extends BaseMapper<QwExternalContact> {
     @Update("update qw_external_contact set comment_status = #{commentStatus} where fs_user_id = #{fsUserId}")
     @Update("update qw_external_contact set comment_status = #{commentStatus} where fs_user_id = #{fsUserId}")
     int updateQwExternalContactByFsUserId(@Param("commentStatus") Integer commentStatus, @Param("fsUserId")Long fsUserId);
     int updateQwExternalContactByFsUserId(@Param("commentStatus") Integer commentStatus, @Param("fsUserId")Long fsUserId);
 
 
+    /**
+     * 根据外部联系人ID查询用户是否已购产品
+     * @param qwExternalContactId   外部联系人ID
+     * @return  Boolean
+     */
+    Boolean getBuyStatusByExtId(@Param("qwExternalContactId") Long qwExternalContactId);
 }
 }

+ 8 - 0
fs-service-system/src/main/java/com/fs/qw/mapper/QwSessionMapper.java

@@ -2,6 +2,7 @@ package com.fs.qw.mapper;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.qw.domain.QwSession;
 import com.fs.qw.domain.QwSession;
+import com.fs.qw.vo.QwContactListVO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Select;
 
 
@@ -66,4 +67,11 @@ public interface QwSessionMapper extends BaseMapper<QwSession>
 
 
     @Select("select * from qw_session where qw_ext_id = #{qwExtId} and qw_user_id = #{qwUserId}")
     @Select("select * from qw_session where qw_ext_id = #{qwExtId} and qw_user_id = #{qwUserId}")
     QwSession selectQwSessionByExtIdAndQwUserId(@Param("qwExtId") Long qwExtId, @Param("qwUserId") Long id);
     QwSession selectQwSessionByExtIdAndQwUserId(@Param("qwExtId") Long qwExtId, @Param("qwUserId") Long id);
+
+    /**
+     * 根据企微用户ID查询会话列表
+     * @param qwUserId  企微用户ID
+     * @return  list
+     */
+    List<QwContactListVO> selectContactListByQwUserId(@Param("qwUserId") Long qwUserId);
 }
 }

+ 7 - 0
fs-service-system/src/main/java/com/fs/qw/service/IQwExternalContactService.java

@@ -222,4 +222,11 @@ public interface IQwExternalContactService extends IService<QwExternalContact> {
      * @return
      * @return
      */
      */
     int updateQwExternalContactByFsUserId(Integer commentStatus, Long fsUserId);
     int updateQwExternalContactByFsUserId(Integer commentStatus, Long fsUserId);
+
+    /**
+     * 根据外部联系人ID查询用户是否已购产品
+     * @param qwExternalContactId   外部联系人ID
+     * @return  Boolean
+     */
+    Boolean getBuyStatusByExtId(Long qwExternalContactId);
 }
 }

+ 10 - 0
fs-service-system/src/main/java/com/fs/qw/service/impl/QwExternalContactServiceImpl.java

@@ -215,6 +215,16 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
         return qwExternalContactMapper.updateQwExternalContactByFsUserId(commentStatus, fsUserId);
         return qwExternalContactMapper.updateQwExternalContactByFsUserId(commentStatus, fsUserId);
     }
     }
 
 
+    /**
+     * 根据外部联系人ID查询用户是否已购产品
+     * @param qwExternalContactId   外部联系人ID
+     * @return  Boolean
+     */
+    @Override
+    public Boolean getBuyStatusByExtId(Long qwExternalContactId) {
+        return qwExternalContactMapper.getBuyStatusByExtId(qwExternalContactId);
+    }
+
     /**
     /**
      * 查询企业微信客户
      * 查询企业微信客户
      *
      *

+ 7 - 16
fs-service-system/src/main/java/com/fs/qw/service/impl/QwMsgServiceImpl.java

@@ -455,26 +455,17 @@ public class QwMsgServiceImpl extends ServiceImpl<QwMsgMapper, QwMsg> implements
 
 
     @Override
     @Override
     public List<QwContactListVO> selectQwConversationByUserId(Long userId) {
     public List<QwContactListVO> selectQwConversationByUserId(Long userId) {
-        LambdaQueryWrapper<QwSession> sessionWrapper = new LambdaQueryWrapper<>();
-        sessionWrapper.select(QwSession.class, q -> !q.getColumn().equals("remark"));
-        sessionWrapper.eq(QwSession::getQwUserId, userId);
-        sessionWrapper.orderByDesc(QwSession::getUpdateTime);
-        List<QwSession> qwSessions = qwSessionMapper.selectList(sessionWrapper);
-        if (CollectionUtil.isEmpty(qwSessions)){
-            return Collections.EMPTY_LIST;
+        // 查询会话列表
+        List<QwContactListVO> contactList = qwSessionMapper.selectContactListByQwUserId(userId);
+        if (contactList.isEmpty()) {
+            return new ArrayList<>();
         }
         }
+
         ArrayList<QwContactListVO> qwContactListVOS = new ArrayList<>();
         ArrayList<QwContactListVO> qwContactListVOS = new ArrayList<>();
-        for (QwSession qwSession : qwSessions) {
-            QwContactListVO listVO = new QwContactListVO();
-            listVO.setId(userId);
-            listVO.setExtId(qwSession.getQwExtId());
-            listVO.setAvatar(qwSession.getAvatar());
-            listVO.setConversationId(qwSession.getSessionId().toString());
-            listVO.setDisplayName(qwSession.getNickName());
-//            listVO.setIndex(qwSession.getNickName().substring(0, 1));
+        for (QwContactListVO listVO : contactList) {
             LambdaQueryWrapper<QwMsg> lambdaQueryWrapper = new LambdaQueryWrapper<>();
             LambdaQueryWrapper<QwMsg> lambdaQueryWrapper = new LambdaQueryWrapper<>();
             lambdaQueryWrapper.select(QwMsg.class, q -> !q.getColumn().equals("remark"));
             lambdaQueryWrapper.select(QwMsg.class, q -> !q.getColumn().equals("remark"));
-            lambdaQueryWrapper.eq(QwMsg::getSessionId, qwSession.getSessionId());
+            lambdaQueryWrapper.eq(QwMsg::getSessionId, Integer.parseInt(listVO.getConversationId()));
             lambdaQueryWrapper.orderByDesc(QwMsg::getMsgId);
             lambdaQueryWrapper.orderByDesc(QwMsg::getMsgId);
             lambdaQueryWrapper.last("limit 1");
             lambdaQueryWrapper.last("limit 1");
             List<QwMsg> qwMsgs = qwMsgMapper.selectList(lambdaQueryWrapper);
             List<QwMsg> qwMsgs = qwMsgMapper.selectList(lambdaQueryWrapper);

+ 33 - 2
fs-service-system/src/main/java/com/fs/store/domain/FsUser.java

@@ -1,13 +1,14 @@
 package com.fs.store.domain;
 package com.fs.store.domain;
 
 
-import java.math.BigDecimal;
-import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fs.common.annotation.Excel;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
 import com.fs.common.core.domain.BaseEntity;
 import com.vdurmont.emoji.EmojiParser;
 import com.vdurmont.emoji.EmojiParser;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 
 
+import java.math.BigDecimal;
+import java.util.Date;
+
 /**
 /**
  * 用户对象 fs_user
  * 用户对象 fs_user
  *
  *
@@ -143,6 +144,36 @@ public class FsUser extends BaseEntity
 
 
     private String courseMaOpenId;//看课小程序openId
     private String courseMaOpenId;//看课小程序openId
 
 
+    // 企微重粉
+    private Integer qwRepeat;
+    // 小程序(看课)重粉
+    private Integer userRepeat;
+    // 是否已购0 否 1程序内下单 2程序外下单
+    private Integer payOrder;
+
+    public Integer getQwRepeat() {
+        return qwRepeat;
+    }
+
+    public void setQwRepeat(Integer qwRepeat) {
+        this.qwRepeat = qwRepeat;
+    }
+
+    public Integer getUserRepeat() {
+        return userRepeat;
+    }
+
+    public void setUserRepeat(Integer userRepeat) {
+        this.userRepeat = userRepeat;
+    }
+
+    public Integer getPayOrder() {
+        return payOrder;
+    }
+
+    public void setPayOrder(Integer payOrder) {
+        this.payOrder = payOrder;
+    }
 
 
     public Long getQwExtId() {
     public Long getQwExtId() {
         return qwExtId;
         return qwExtId;

+ 7 - 0
fs-service-system/src/main/resources/mapper/qw/QwExternalContactMapper.xml

@@ -499,6 +499,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         GROUP BY user_id,external_user_id
         GROUP BY user_id,external_user_id
     </select>
     </select>
 
 
+    <select id="getBuyStatusByExtId" resultType="java.lang.Boolean">
+        select IF(u.pay_order = 1, true, false)
+        from qw_external_contact ec
+        left join fs_user u on ec.fs_user_id = u.user_id
+        where ec.id = #{qwExternalContactId}
+    </select>
+
     <update id="updateContactByIds" parameterType="map">
     <update id="updateContactByIds" parameterType="map">
         update qw_external_contact
         update qw_external_contact
         set status = #{status}
         set status = #{status}

+ 16 - 0
fs-service-system/src/main/resources/mapper/qw/QwSessionMapper.xml

@@ -46,6 +46,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where session_id = #{sessionId}
         where session_id = #{sessionId}
     </select>
     </select>
 
 
+    <select id="selectContactListByQwUserId" resultType="com.fs.qw.vo.QwContactListVO">
+        select
+            s.qw_user_id as id,
+            s.qw_ext_id extId,
+            s.avatar,
+            s.session_id conversationId,
+            s.nick_name displayName,
+            ec.comment_status isBlack,
+            if(u.qw_repeat = 1 OR u.user_repeat = 1, true, false) isRepeat
+        from qw_session s
+        left join qw_external_contact ec on s.qw_ext_id = ec.id
+        left join fs_user u on ec.fs_user_id = u.user_id
+        where s.qw_user_id = #{qwUserId}
+        order by s.update_time desc
+    </select>
+
     <insert id="insertQwSession" parameterType="QwSession" useGeneratedKeys="true" keyProperty="sessionId">
     <insert id="insertQwSession" parameterType="QwSession" useGeneratedKeys="true" keyProperty="sessionId">
         insert into qw_session
         insert into qw_session
         <trim prefix="(" suffix=")" suffixOverrides=",">
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 22 - 1
fs-service-system/src/main/resources/mapper/store/FsUserMapper.xml

@@ -44,6 +44,9 @@
         <result property="isShow" column="is_show"/>
         <result property="isShow" column="is_show"/>
         <result property="qwExtId"    column="qw_ext_id"    />
         <result property="qwExtId"    column="qw_ext_id"    />
         <result property="isAddQw"    column="is_add_qw"    />
         <result property="isAddQw"    column="is_add_qw"    />
+        <result property="qwRepeat" column="qw_repeat"/>
+        <result property="userRepeat" column="user_repeat"/>
+        <result property="payOrder" column="pay_order"/>
     </resultMap>
     </resultMap>
 
 
     <sql id="selectFsUserVo">
     <sql id="selectFsUserVo">
@@ -86,7 +89,10 @@
                register_date,
                register_date,
                register_code,
                register_code,
                source,
                source,
-               user_code
+               user_code,
+               qw_repeat,
+               user_repeat,
+               pay_order
         from fs_user
         from fs_user
     </sql>
     </sql>
 
 
@@ -125,6 +131,9 @@
             <if test="registerCode != null   and registerCode != '' ">and register_code = #{registerCode}</if>
             <if test="registerCode != null   and registerCode != '' ">and register_code = #{registerCode}</if>
             <if test="source != null  and source != '' ">and source = #{source}</if>
             <if test="source != null  and source != '' ">and source = #{source}</if>
             <if test="isShow != null  ">and is_show = #{isShow}</if>
             <if test="isShow != null  ">and is_show = #{isShow}</if>
+            <if test="qwRepeat != null  ">and qw_repeat = #{qwRepeat}</if>
+            <if test="userRepeat != null  ">and user_repeat = #{userRepeat}</if>
+            <if test="payOrder != null  ">and pay_order = #{payOrder}</if>
         </where>
         </where>
         order by user_id desc
         order by user_id desc
     </select>
     </select>
@@ -172,6 +181,9 @@
                 <if test="phone != null  and phone != ''">or phone like concat('%',#{phone},'%')</if>
                 <if test="phone != null  and phone != ''">or phone like concat('%',#{phone},'%')</if>
                 )
                 )
             </if>
             </if>
+            <if test="qwRepeat != null  ">and qw_repeat = #{qwRepeat}</if>
+            <if test="userRepeat != null  ">and user_repeat = #{userRepeat}</if>
+            <if test="payOrder != null  ">and pay_order = #{payOrder}</if>
         </where>
         </where>
         order by user_id desc
         order by user_id desc
         limit 10
         limit 10
@@ -322,6 +334,9 @@
             <if test="isShow != null">is_show,</if>
             <if test="isShow != null">is_show,</if>
             <if test="qwExtId != null">qw_ext_id,</if>
             <if test="qwExtId != null">qw_ext_id,</if>
             <if test="isAddQw != null">is_add_qw,</if>
             <if test="isAddQw != null">is_add_qw,</if>
+            <if test="qwRepeat != null">qw_repeat,</if>
+            <if test="userRepeat != null">user_repeat,</if>
+            <if test="payOrder != null">pay_order,</if>
         </trim>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="username != null">#{username},</if>
             <if test="username != null">#{username},</if>
@@ -363,6 +378,9 @@
             <if test="isShow != null">#{isShow},</if>
             <if test="isShow != null">#{isShow},</if>
             <if test="qwExtId != null">#{qwExtId},</if>
             <if test="qwExtId != null">#{qwExtId},</if>
             <if test="isAddQw != null">#{isAddQw},</if>
             <if test="isAddQw != null">#{isAddQw},</if>
+            <if test="qwRepeat != null">#{qwRepeat},</if>
+            <if test="userRepeat != null">#{userRepeat},</if>
+            <if test="payOrder != null">#{payOrder},</if>
         </trim>
         </trim>
     </insert>
     </insert>
 
 
@@ -408,6 +426,9 @@
             <if test="isShow != null">is_show = #{isShow},</if>
             <if test="isShow != null">is_show = #{isShow},</if>
             <if test="qwExtId != null">qw_ext_id = #{qwExtId},</if>
             <if test="qwExtId != null">qw_ext_id = #{qwExtId},</if>
             <if test="isAddQw != null">is_add_qw = #{isAddQw},</if>
             <if test="isAddQw != null">is_add_qw = #{isAddQw},</if>
+            <if test="qwRepeat != null">qw_repeat = #{qwRepeat},</if>
+            <if test="userRepeat != null">user_repeat = #{userRepeat},</if>
+            <if test="payOrder != null">pay_order = #{payOrder},</if>
         </trim>
         </trim>
         where user_id = #{userId}
         where user_id = #{userId}
     </update>
     </update>