姜永辉 пре 1 година
родитељ
комит
ccab91d08f

+ 9 - 0
src/main/java/com/dk/mdm/controller/mst/CusFollowController.java

@@ -123,4 +123,13 @@ public class CusFollowController{
         return cusFollowService.selectCusFollow(customerQuery);
     }
 
+
+    @ApiOperation(
+            value = "测试推送",
+            notes = "测试推送"
+    )
+    @PostMapping("test_push")
+    public ResponseResultVO<?> testPush() {
+        return cusFollowService.customerReminder();
+    }
 }

+ 10 - 0
src/main/java/com/dk/mdm/mapper/mst/FollowPlanMapper.java

@@ -1,9 +1,11 @@
 package com.dk.mdm.mapper.mst;
 
+import com.dk.common.model.response.mst.StaffResponse;
 import com.dk.mdm.model.pojo.mst.FollowPlan;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.mst.FollowPlanQuery;
 import com.dk.mdm.model.response.mst.FollowPlanResponse;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -27,6 +29,14 @@ public interface FollowPlanMapper extends BaseMapper<FollowPlan>{
      * @date : 2024/2/26 10:36
      */
     Long countByCond(FollowPlanQuery followPlanQuery);
+
+
+    /**
+     * @desc   : 根据计划id查询
+     * @author : 姜永辉
+     * @date   : 2024/3/6 10:42
+     */
+    FollowPlan selectById(@Param("planId") String planId);
 	
 }
 

+ 28 - 24
src/main/java/com/dk/mdm/mapper/mst/FollowPlanMapper.xml

@@ -5,29 +5,33 @@
     <!-- 通用设置 -->
     <!-- 通用查询列 -->
     <sql id="Base_Column_List">
-        plan_id, cus_id, plan_type, follow_id, follow_user, next_follow_plan, next_follow_time, call_status, remarks, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
+        plan_id
+        , cus_id, plan_type, follow_id, follow_user, next_follow_plan, next_follow_time,
+        call_status, remarks, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time,
+        op_update_user_id, op_app_code, op_timestamp, op_db_user,xxl_job_id
     </sql>
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.FollowPlan">
         <id column="plan_id" property="planId"/>
-                <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
-                <result column="plan_type" property="planType"/>
-                <result column="follow_id" property="followId" typeHandler="UuidTypeHandler"/>
-                <result column="follow_user" property="followUser" typeHandler="UuidTypeHandler"/>
-                <result column="next_follow_plan" property="nextFollowPlan"/>
-            <result column="next_follow_time" property="nextFollowTime" typeHandler="TimestampTypeHandler"/>
-                <result column="call_status" property="callStatus"/>
-                <result column="remarks" property="remarks"/>
-                <result column="flg_valid" property="flgValid"/>
-                <result column="cp_id" property="cpId"/>
-            <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
-                <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
-            <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
-                <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
-                <result column="op_app_code" property="opAppCode"/>
-            <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
-                <result column="op_db_user" property="opDbUser"/>
+        <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
+        <result column="plan_type" property="planType"/>
+        <result column="follow_id" property="followId" typeHandler="UuidTypeHandler"/>
+        <result column="follow_user" property="followUser" typeHandler="UuidTypeHandler"/>
+        <result column="next_follow_plan" property="nextFollowPlan"/>
+        <result column="next_follow_time" property="nextFollowTime" typeHandler="TimestampTypeHandler"/>
+        <result column="call_status" property="callStatus"/>
+        <result column="remarks" property="remarks"/>
+        <result column="flg_valid" property="flgValid"/>
+        <result column="cp_id" property="cpId"/>
+        <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
+        <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
+        <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
+        <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
+        <result column="op_app_code" property="opAppCode"/>
+        <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
+        <result column="op_db_user" property="opDbUser"/>
+        <result column="xxl_job_id" property="xxlJobId"/>
     </resultMap>
 
     <!-- 通用条件列 -->
@@ -99,7 +103,7 @@
     <select id="selectByCond" resultMap="BaseResultMap">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM t_csm_follow_plan
+        FROM dkic_b.t_csm_follow_plan
         <include refid="Condition"/>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
@@ -110,7 +114,7 @@
     <select id="countByCond" resultType="Long">
         SELECT
         count(1)
-        FROM t_csm_follow_plan
+        FROM dkic_b.t_csm_follow_plan
         <include refid="Condition"/>
     </select>
 
@@ -118,7 +122,7 @@
     <select id="selectById" resultMap="BaseResultMap">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM t_csm_follow_plan
+        FROM dkic_b.t_csm_follow_plan
         WHERE plan_id = #{planId}::uuid
     </select>
 
@@ -126,7 +130,7 @@
     <select id="selectByIdForUpdate" resultMap="BaseResultMap">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM t_csm_follow_plan
+        FROM dkic_b.t_csm_follow_plan
         WHERE plan_id = #{planId}
         for update
     </select>
@@ -135,13 +139,13 @@
     <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM t_csm_follow_plan
+        FROM dkic_b.t_csm_follow_plan
         <include refid="idsForeach"/>
         for update
     </select>
 
     <insert id="insertBatch">
-        insert into t_csm_follow_plan
+        insert into dkic_b.t_csm_follow_plan
         (
         <trim suffixOverrides=",">
             cus_id,

+ 18 - 10
src/main/java/com/dk/mdm/service/mst/CusFollowService.java

@@ -2,6 +2,7 @@ package com.dk.mdm.service.mst;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.dk.common.exception.BaseBusinessException;
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.infrastructure.constant.Constant;
@@ -19,6 +20,7 @@ import com.dk.mdm.infrastructure.convert.mst.CusFollowConvert;
 import com.dk.mdm.infrastructure.convert.mst.MeasureReceiptConvert;
 import com.dk.mdm.infrastructure.util.AuthUtils;
 import com.dk.mdm.mapper.mst.*;
+import com.dk.mdm.model.pojo.ivt.InboundItem;
 import com.dk.mdm.model.pojo.mst.*;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
@@ -332,10 +334,10 @@ public class CusFollowService extends BaseService<CusFollow> {
     public ResponseResultVO customerReminder() {
         log.info("@XxlJob(\"customer-reminder\")");
         log.info("followPlan id: {}", XxlJobHelper.getJobParam());
-        FollowPlan followPlan = followPlanMapper.selectById(Long.valueOf(XxlJobHelper.getJobParam()));
+//        String planid = "10112024-0715-0000-0000-0004a8b4d1e6";
+        FollowPlan followPlan = followPlanMapper.selectById(XxlJobHelper.getJobParam());
         if (followPlan != null) {
             CusFollow follow = cusFollowMapper.selectById(followPlan.getFollowId());
-
             if (follow != null) {
                 FollowPlan plan = new FollowPlan().setPlanId(followPlan.getPlanId());
                 try {
@@ -354,7 +356,9 @@ public class CusFollowService extends BaseService<CusFollow> {
                 }
 
                 //修改状态
-                followPlanMapper.updateById(plan);
+                followPlanMapper.update(plan,
+                        new UpdateWrapper<FollowPlan>().lambda()
+                                .eq(FollowPlan::getPlanId, UUID.fromString(plan.getPlanId())));
 
                 //删除任务
                 xxlJobUtils.delete(followPlan.getXxlJobId());
@@ -374,7 +378,8 @@ public class CusFollowService extends BaseService<CusFollow> {
     public void planReminder() {
         log.info("@XxlJob(\"plan-reminder\")");
         log.info("followPlan id: {}", XxlJobHelper.getJobParam());
-        FollowPlan followPlan = followPlanMapper.selectById(Long.valueOf(XxlJobHelper.getJobParam()));
+//        String planid = "10112024-0715-0000-0000-0004a8b4d1e6";
+        FollowPlan followPlan = followPlanMapper.selectById(XxlJobHelper.getJobParam());
         if (followPlan != null && followPlan.getFlgValid()) {
             FollowPlan plan = new FollowPlan().setPlanId(followPlan.getPlanId());
             try {
@@ -410,9 +415,9 @@ public class CusFollowService extends BaseService<CusFollow> {
         //查到跟进人
         if (followStaff != null) {
             log.info("sendFollowMessage:{}", JSONObject.toJSONString(followStaff));
-            Customer customer = customerMapper.selectById(new CustomerQuery().setCusId(follow.getCusId()));
+            Customer customer = customerMapper.selectById(follow.getCusId());
             if (customer != null) {
-                String loginType = null;
+                String loginType = "1";
                 List<String> list = new ArrayList<>();
                 if (Constant.BasicDataConstant.FOLLOW_STATUS_4.getValue().equals(follow.getFollowStatus()) ||
                         Constant.BasicDataConstant.FOLLOW_STATUS_5.getValue().equals(follow.getFollowStatus())) {
@@ -430,7 +435,6 @@ public class CusFollowService extends BaseService<CusFollow> {
                 } else if (Constant.BasicDataConstant.FOLLOW_STATUS_3.getValue().equals(follow.getFollowStatus())) {
                     list.add("您有客户需要约尺服务");
                     loginType = "1";
-
                 }
                 list.add(customer.getCusName());
                 list.add(customer.getCusPhone());
@@ -529,11 +533,16 @@ public class CusFollowService extends BaseService<CusFollow> {
      * @desc : 调用中控服务获取公众号的token
      */
     public String getWxPublicAccountToken() {
+        JSONObject json = new JSONObject();
+        //有效期30天,最大可设置30天
+        json.put("appId", config.getWxPublicAccountAppId());
+        json.put("appSecret", config.getWxPublicAccountAppSecret());
         ResponseResultVO<JSONObject> res = HttpUtils.post(config.getWechatUrlToken(),
-                new HashMap() {{
+                new HashMap<String, Object>() {{
                     put("appId", config.getWxPublicAccountAppId());
                     put("appSecret", config.getWxPublicAccountAppSecret());
                 }});
+//        ResponseResultVO<JSONObject> res = HttpUtils.post(config.getWechatUrlToken(),json);
         if (res.getCode() == 200 && JSON.parseObject(JSON.toJSONString(res.getData())).get("code").toString().equals("200")) {
             return JSON.parseObject(JSON.toJSONString(res.getData())).get("data").toString();
         } else {
@@ -574,7 +583,6 @@ public class CusFollowService extends BaseService<CusFollow> {
         //设置ID
         Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.FOLLOWPLAN.getName(), true);
         String nextId = uniqueNoteCode.get("outId").toString();
-        cusFollow.setFollowId(nextId);
 
         // 约量尺 && 接受邀约
 //        预约量尺,邀约结果接受,通知设计师提醒时间是(服务时间);邀约结果拒绝,通知创建者提醒时间是(提醒时间)
@@ -596,7 +604,7 @@ public class CusFollowService extends BaseService<CusFollow> {
                         .setNextFollowTime(cusFollow.getNextFollowTime())
                         .setCallStatus(Constant.CallStatus.CALL_STATUS_UN_DONE.getName() + "")
                         .setXxlJobId(id)
-                        .setOpAppCode(Constant.AppCode.WEIXIN.getCode()+"")
+                        .setOpAppCode(Constant.AppCode.WEIXIN.getCode() + "")
                         .setCpId(cusFollow.getCpId())
         );
     }

+ 1 - 1
src/main/resources/test/bootstrap.yml

@@ -112,7 +112,7 @@ wx:
   # 公众号的appid appSecret 东科软件 公众号
   wxPublicAccountAppId: wx6bb9335b534f7b28
   wxPublicAccountAppSecret: 78a99837c113756599d1748b813ca698
-  templateId: V5Ju7-8BfDKJJm1HgH4j5km68rPs777pMVJ0_MKqR00
+  templateId: FbOkFnLo86XllRKElGwWVFkc8VAXg386PyF9wndqItE
 
   # 支付的信息
   pay: