huangzhiguo 1 год назад
Родитель
Сommit
dc8b7ba577

+ 9 - 0
src/main/java/com/caimei/modules/project/model/ServiceProviderModel.java

@@ -12,6 +12,7 @@ public class ServiceProviderModel extends DataEntity<ServiceProviderModel> {
     private Integer userID;
     private String contractMobile;
     private Integer mainServiceProviderID;
+    private String unionId;
     private Integer teamFlag;  //协销小组编辑页面回显标记,后台取数据的时候给1
 
     public String getContractMobile() {
@@ -46,6 +47,14 @@ public class ServiceProviderModel extends DataEntity<ServiceProviderModel> {
         this.mainServiceProviderID = mainServiceProviderID;
     }
 
+    public String getUnionId() {
+        return unionId;
+    }
+
+    public void setUnionId(String unionId) {
+        this.unionId = unionId;
+    }
+
     public Integer getTeamFlag() {
         return teamFlag;
     }

+ 8 - 2
src/main/java/com/caimei/modules/user/service/ClubPortraitService.java

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.text.NumberFormat;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -65,8 +66,13 @@ public class ClubPortraitService {
                 clubStatistics.setSex(clubRemarksInfo.getCustomerGender() != null ? clubRemarksInfo.getGroupAddition() : null);
                 clubStatistics.setAge(StringUtils.isNotBlank(clubRemarksInfo.getCustomerAge()) ? clubRemarksInfo.getCustomerAge() : null);
                 clubStatistics.setFillTime(dateFormat.format(clubRemarksInfo.getAddTime()));
-                clubStatistics.setFirstTime(dateFormat.format(clubRemarksInfo.getFirstTime() != null ? clubRemarksInfo.getFirstTime() : null));
-                clubStatistics.setRecentlyTime(dateFormat.format(clubRemarksInfo.getRecentlyTime() != null ? clubRemarksInfo.getRecentlyTime() : null));
+                try {
+                    clubStatistics.setFirstTime(StringUtils.isNotBlank(clubRemarksInfo.getFirstTime()) ? dateFormat.format(dateFormat.parse(clubRemarksInfo.getFirstTime())) : null);
+                    clubStatistics.setRecentlyTime(StringUtils.isNotBlank(clubRemarksInfo.getRecentlyTime()) ? dateFormat.format(dateFormat.parse(clubRemarksInfo.getRecentlyTime())) : null);
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+
             }
         }
         return clubStatistics;

+ 97 - 0
src/main/java/com/caimei/modules/user/service/WebChatUserService.java

@@ -0,0 +1,97 @@
+package com.caimei.modules.user.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.caimei.modules.utils.RequestUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : hzg
+ * @date : 2023/11/16
+ */
+@Slf4j
+@Service
+public class WebChatUserService {
+
+
+    /**
+     * 分配协销消息
+     *
+     * @param title      消息抬头
+     * @param keyWord1
+     * @param keyWord2
+     * @param keyWord3
+     * @param keyWord4
+     * @param Remark     消息下备注
+     * @param path       跳转链接
+     * @param openId     公众号openId
+     * @param templateId 模板Id
+     */
+    public void sendChoseServiceMessage(String title, String keyWord1, String keyWord2, String keyWord3, String keyWord4, String Remark, String path, String openId, String templateId) {
+        JSONObject first = new JSONObject();
+        first.put("value", title);
+        JSONObject keyword1 = new JSONObject();
+        keyword1.put("value", keyWord1);
+        JSONObject keyword2 = new JSONObject();
+        keyword2.put("value", keyWord2);
+        JSONObject keyword3 = new JSONObject();
+        keyword3.put("value", keyWord3);
+        JSONObject keyword4 = new JSONObject();
+        keyword4.put("value", keyWord4);
+        JSONObject remark = new JSONObject();
+        remark.put("value", Remark);
+
+        JSONObject data = new JSONObject();
+        data.put("first", first);
+        data.put("keyword1", keyword1);
+        data.put("keyword2", keyword2);
+        data.put("keyword3", keyword3);
+        data.put("keyword4", keyword4);
+        data.put("remark", remark);
+
+        JSONObject miniProgram = new JSONObject();
+        miniProgram.put("appid", "wxf3cd4ae0cdd11c36");
+        miniProgram.put("pagepath", path);
+
+        JSONObject json = new JSONObject(new LinkedHashMap());
+        json.put("touser", openId);
+        json.put("template_id", templateId);
+        json.put("url", "https://www.caimei365.com/");
+        json.put("miniprogram", miniProgram);
+        json.put("data", data);
+        // json 字符串
+        String jsonString = json.toJSONString();
+        log.info(">>>>>>>>推送微信模板消息:" + jsonString);
+        try {
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + getAccessToken();
+            // 发送请求
+            String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
+            log.info(">>>>>>>>推送结果:" + result);
+        } catch (Exception e) {
+            log.info("推送微信模板消息失败:" + e);
+        }
+    }
+
+
+    /**
+     * 微信公众号获取access_token
+     *
+     * @return access_token
+     */
+    public String getAccessToken() throws Exception {
+        String link = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
+        link = link.replace("APPID", "wx91c4152b60ca91a3");
+        link = link.replace("APPSECRET", "a563dd2c07c9c815a4e697c8b6cb73dc");
+        String result = RequestUtil.sendGet(link);
+        log.info("微信公众号获取access_token>>>" + link);
+        log.info("微信公众号获取access_token>>>" + result);
+        Map<String, Object> map = JSONObject.parseObject(result, Map.class);
+        return (String) map.get("access_token");
+    }
+}

+ 24 - 1
src/main/java/com/caimei/modules/user/web/newUser/SpController.java

@@ -6,12 +6,14 @@ import com.caimei.constants.UserIdentity;
 import com.caimei.constants.UserType;
 import com.caimei.modules.bulkpurchase.entity.CmClub;
 import com.caimei.modules.bulkpurchase.service.CmClubService;
+import com.caimei.modules.order.dao.NewShopOrderDao;
 import com.caimei.modules.project.dao.ClubDao;
 import com.caimei.modules.project.dao.ServiceProviderDao;
 import com.caimei.modules.project.model.ClubModel;
 import com.caimei.modules.project.model.ServiceProviderModel;
 import com.caimei.modules.sys.utils.SMSUtils;
 import com.caimei.modules.sys.utils.ValidateUtils;
+import com.caimei.modules.user.service.WebChatUserService;
 import com.caimei.modules.user.aop.OperationLogAnnotation;
 import com.caimei.modules.user.dao.NewCmClubDao;
 import com.caimei.modules.user.entity.*;
@@ -76,6 +78,10 @@ public class SpController extends BaseController {
     private NewCmClubService newCmClubService;
     @Resource
     private NewCmClubDao newCmClubDao;
+    @Resource
+    private NewShopOrderDao newShopOrderDao;
+    @Resource
+    private WebChatUserService webChatUserService;
 
     @ModelAttribute
     public NewCmSp get(@RequestParam(required = false) String id) {
@@ -243,7 +249,24 @@ public class SpController extends BaseController {
                                 MessageUtil.sendMessage(insideMessageMessageModel);
                                 SMSUtils.sendSms(4, oldServiceprovider.getContractMobile(), "【采美365】系统已将你的机构客户进行回收,你已无权管理该客户。机构名称【" + newCmClub.getName() + "】,联系人【"+ newCmClub.getLinkMan() +"】,手机号【"+ newCmClub.getContractMobile() +"】。");
                             }
-
+                            // 分配协销发送微信模板消息
+                            List<String> openidList = newShopOrderDao.getOpenidListByPermission(serviceProvider.getUnionId());
+                            if (null != openidList && openidList.size() > 0) {
+                                for (String openId : openidList) {
+                                    if (StringUtils.isNotBlank(openId)) {
+                                        String title = "你有一个新机构客户,请及时跟进。";
+                                        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                                        String keyWord1 = newCmClub.getLinkMan();
+                                        String keyWord2 = newCmClub.getContractMobile();
+                                        String keyWord3 = StringUtils.isNotBlank(newCmClub.getAddress()) ? newCmClub.getAddress() : "暂无";
+                                        String keyWord4 = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
+                                        String remark = "点击查看详情,了解更多客户信息。";
+                                        String path = "pages/seller/club/list?type=wechat";
+                                        String templateId = "o1nMAIsHAFr0VOu0qEbI1rEFDS14hl40UXbt52I5row";
+                                        webChatUserService.sendChoseServiceMessage(title, keyWord1, keyWord2, keyWord3, keyWord4, remark, path, openId, templateId);
+                                    }
+                                }
+                            }
                         }
                     } else {
                         map.put("success", false);

+ 5 - 5
src/main/resources/mappings/modules/order/CmDiscernReceiptMapper.xml

@@ -1137,7 +1137,7 @@
 		and cdr.delFlag = '0' and cdr.receiptStatus = '3' and cdr.payWay != '3'
 	</select>
     <select id="findShoOrderIDReceipt" resultType="double">
-        select sum(associateAmount) from cm_receipt_order_relation cror
+        select ifnull(sum(cror.associateAmount), 0) as associateAmount from cm_receipt_order_relation cror
                                              left join cm_discern_receipt cdr on cror.receiptID = cdr.id
         where cror.shopOrderID = #{shopOrderID} and cror.delFlag = '0' and cror.relationType = '2'
           and cdr.delFlag = '0' and cdr.receiptStatus = '3' and cdr.payWay = '2'
@@ -1146,17 +1146,17 @@
     <select id="findShopReceipt" resultType="java.lang.Double">
         SELECT ifnull(SUM(associateAmount), 0) as associateAmount FROM (
              SELECT
-                 SUM(associateAmount) AS associateAmount
+                 SUM(cror.associateAmount) AS associateAmount
              FROM cm_receipt_order_relation cror
                       LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
-             WHERE relationType = 2 AND orderId = #{orderID}
+             WHERE cror.relationType = 2 AND cror.orderId = #{orderID}
                AND cror.delFlag = '0' AND cror.relationType = '2' AND cdr.delFlag = '0'
              UNION
              SELECT
-                 SUM(associateAmount) AS associateAmount
+                 SUM(cror.associateAmount) AS associateAmount
              FROM cm_receipt_order_relation cror
                       LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
-             WHERE relationType = 1 AND orderId = #{shopOrderID}
+             WHERE cror.relationType = 1 AND cror.orderId = #{shopOrderID}
                AND cror.delFlag = '0' AND cror.relationType = '2' AND cdr.delFlag = '0'
          ) AS d
     </select>

+ 2 - 2
src/main/resources/mappings/modules/user/CmPortraitMapper.xml

@@ -90,8 +90,8 @@
     <select id="getClubRemarksInfo" resultType="com.caimei.modules.user.entity.CmClubRemarks">
         SELECT id, communicationSituation, communicationMethods,
                customerSource, customerGender, customerAge, groupAddition,addTime,
-               (SELECT ADDTIME FROM cm_club_remarks WHERE clubId = 7719 ORDER BY ADDTIME ASC LIMIT 1) AS firstTime,
-               (SELECT ADDTIME FROM cm_club_remarks WHERE clubId = 7719 ORDER BY ADDTIME DESC LIMIT 1) AS recentlyTime
+               (SELECT ADDTIME FROM cm_club_remarks WHERE clubId = #{clubID} ORDER BY ADDTIME ASC LIMIT 1) AS firstTime,
+               (SELECT ADDTIME FROM cm_club_remarks WHERE clubId = #{clubID} ORDER BY ADDTIME DESC LIMIT 1) AS recentlyTime
         FROM cm_club_remarks WHERE clubId = #{clubID} ORDER BY ADDTIME DESC LIMIT 1
     </select>
 

+ 4 - 4
src/main/resources/mappings/modules/user/NewCmClubMapper.xml

@@ -101,8 +101,8 @@
         <include refid="otherColumns"/>,u.userPermission,u.source, covs.activeState,covs.customerValue,u.loginTime
         FROM club a
         <include refid="newCmClubJoins"/>
-        left join cm_provider_record cpr on a.clubId = cpr.clubId
-        LEFT JOIN clubchangesprecord ccs ON ccs.clubId = a.clubId
+        LEFT JOIN (SELECT DISTINCT clubId, createTime FROM cm_provider_record GROUP BY clubId ORDER BY id DESC ) cpr ON a.clubId = cpr.clubId
+        LEFT JOIN (SELECT DISTINCT clubID, checkTime FROM clubchangesprecord WHERE checkStatus = 1 GROUP BY clubID ORDER BY clubChangeSpRecordID DESC )ccs ON ccs.clubId = a.clubId
         LEFT JOIN (SELECT userID, activeState, customerValue FROM cm_organ_value_system WHERE stage = 0 AND delType = 1) covs ON a.userID = covs.userID
         <where>
             (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4 AND u.userIdentity != 8
@@ -152,11 +152,11 @@
                 AND (u.registerTime &lt; #{endTime} OR u.registerTime = #{endTime})
             </if>
             <if test="allocationStartTime != null and allocationStartTime != ''">
-                AND (ccs.checkStatus = 1 AND ccs.checkTime <![CDATA[ >= ]]> #{allocationStartTime}
+                AND (ccs.checkTime <![CDATA[ >= ]]> #{allocationStartTime}
                 OR cpr.createTime <![CDATA[ >= ]]> #{allocationStartTime})
             </if>
             <if test="allocationEndTime != null and allocationEndTime != ''">
-                AND (ccs.checkStatus = 1 AND ccs.checkTime <![CDATA[ <= ]]> #{allocationEndTime}
+                AND (ccs.checkTime <![CDATA[ <= ]]> #{allocationEndTime}
                 OR cpr.createTime <![CDATA[ <= ]]> #{allocationEndTime})
             </if>
             <if test="startLoginTime != null and startLoginTime != ''">

+ 4 - 4
src/main/webapp/static/modules/cmClubPortrait/cmClubPortrait.css

@@ -41,7 +41,7 @@
     text-align: center;
 }
 .flex-header-main .flex-header-th.last{
-    width: 36%;
+    width: 20%;
     text-align: left;
     padding-left: 20px;
     box-sizing: border-box;
@@ -64,7 +64,7 @@
     text-overflow: ellipsis;
 }
 .flex-header-main .flex-header-td.last{
-    width: 36%;
+    width: 20%;
     text-align: left;
     padding-left: 20px;
     box-sizing: border-box;
@@ -155,7 +155,7 @@
 }
 .flex-content .flex-box{
     width: 700px;
-    height: 400px;
+    min-height: 400px;
     border:1px solid rgba(192,192,192,0.4);
     margin-left: 15px;
     margin-top: 15px;
@@ -166,7 +166,7 @@
 }
 .flex-content .flex-box.box1{
     width: 1415px;
-    height: 150px;
+    min-height: 100px;
     margin-top: 0;
 }
 .flex-box .box-title{