ソースを参照

小需求优化V1.3.13

kaick 1 年間 前
コミット
527b5e4d52

+ 12 - 5
src/main/java/com/caimei365/tools/mapper/HeheMapper.java

@@ -1,9 +1,11 @@
 package com.caimei365.tools.mapper;
 
 import com.caimei365.tools.model.bo.*;
+import com.caimei365.tools.model.po.OrderVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -21,17 +23,17 @@ public interface HeheMapper {
     List<HeheCouponBo> getNewHeheCoupons();
 
     /**
-     * 查询呵呵商城所有用户的手机号
+     * 查询颜选美学商城所有用户的手机号
      */
     List<String> getHeheUserMobiles();
 
     /**
-     * 查询呵呵用户手机号
+     * 查询颜选美学用户手机号
      */
     String findHeheMobile(String userId);
 
     /**
-     * 查询呵呵商城即将超时的拼团中的拼团
+     * 查询颜选美学商城即将超时的拼团中的拼团
      * @return
      */
     List<HeheCollageBo> findEndSoonCollage();
@@ -51,7 +53,7 @@ public interface HeheMapper {
     void cancelOrder(@Param("orderId") Integer orderId, @Param("reason") String reason);
 
     /**
-     * 查询所有呵呵商城用户
+     * 查询所有颜选美学商城用户
      * @return
      */
     List<HeheUserBo> getAllHeheUser();
@@ -78,7 +80,7 @@ public interface HeheMapper {
     void completeCollage(Integer collageId);
 
     /**
-     * 查询呵呵商城已超时的拼主未支付的拼团
+     * 查询颜选美学商城已超时的拼主未支付的拼团
      * @return
      */
     List<HeheCollageBo> findEndCollage();
@@ -93,4 +95,9 @@ public interface HeheMapper {
      * 根据拼团id查询已支付的拼团成员手机号
      */
     List<String> getMobilesByCollageId(Integer collageId);
+
+    List<OrderVo> getOrderMinuteList(Integer minute);
+
+    List<String> findUserIdByUserYear(Integer num);
+
 }

+ 4 - 0
src/main/java/com/caimei365/tools/model/bo/HeheCouponBo.java

@@ -34,4 +34,8 @@ public class HeheCouponBo implements Serializable {
      * 专享券对应的用户id,以,隔开
      */
     private String userIds;
+    /**
+     * 用户id
+     */
+    private String userId;
 }

+ 50 - 2
src/main/java/com/caimei365/tools/model/dto/message/WechatTemplateMessage.java

@@ -5,11 +5,15 @@ import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 
 import javax.validation.constraints.NotNull;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
+@Slf4j
 @Data
 @Accessors(fluent = true)
 @AllArgsConstructor
@@ -65,6 +69,10 @@ public class WechatTemplateMessage {
      */
     @NotNull
     private JSONObject remark;
+    /**
+     * 模板消息的公众号:为空或1 caimei,2 hehe
+     */
+    private String type;
     /**
      * 所需跳转到的小程序appid(该小程序 appid 必须与发模板消息的公众号是绑定关联关系,暂不支持小游戏)
      */
@@ -80,6 +88,10 @@ public class WechatTemplateMessage {
      */
     @NotNull
     private String templateId;
+    /**
+     * 模板type:1模板消息,2类目模板消息
+     */
+    private String templateType;
     /**
      * 模板跳转链接
      */
@@ -100,6 +112,22 @@ public class WechatTemplateMessage {
     private JSONObject data;
     private JSONObject json;
 
+    public String getTemplateType() {
+        return templateType;
+    }
+
+    public void setTemplateType(String templateType) {
+        this.templateType = templateType;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
     public JSONObject getFirst() {
         return first;
     }
@@ -179,6 +207,19 @@ public class WechatTemplateMessage {
         return this;
     }
 
+    public WechatTemplateMessage mapKeyWords(Map<String,Object> words) {
+        List<JSONObject> collect = new ArrayList<>();
+        words.forEach((key, value) -> {
+            JSONObject jsonValue = new JSONObject();
+            jsonValue.put("value",value);
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put(key, jsonValue);
+            collect.add(jsonObject);
+        });
+        this.setKeyWords(collect);
+        return this;
+    }
+
     public void setKeyWords(List<JSONObject> keyWords) {
         this.keyWords = keyWords;
     }
@@ -219,13 +260,20 @@ public class WechatTemplateMessage {
 
         JSONObject data = new JSONObject();
         data.put("first", first);
-        if (!keyWords.isEmpty()) {
+        data.put("remark", remark);
+        keyWords.add(data);
+        if ("2".equals(templateType)) {          //类目模板消息 mapKeyWords
+            String jsonData = StringUtils.join(keyWords, ",");
+            if(jsonData.contains("},{")){
+                jsonData = jsonData.replace("},{", ",");
+            }
+            data=JSONObject.parseObject(jsonData);
+        } else {                                 //模板消息 keyWords
             for (int i = 0; i < keyWords.size(); i++) {
                 String key = "keyword" + (i + 1);
                 data.put(key, keyWords.get(i));
             }
         }
-        data.put("remark", remark);
         json.put("data", data);
         return json.toJSONString();
     }

+ 65 - 0
src/main/java/com/caimei365/tools/model/dto/message/enums/WechatType.java

@@ -0,0 +1,65 @@
+package com.caimei365.tools.model.dto.message.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.ToString;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+
+
+/**
+ * @auther: Kaick
+ * @date: 2023/11/28 17:06
+ */
+@Slf4j
+@ToString
+@AllArgsConstructor
+public enum WechatType {
+
+    CAIMEI("wx91c4152b60ca91a3", "a563dd2c07c9c815a4e697c8b6cb73dc","1", "采美公众号"),
+    HEHE("wx778caddd81b66a2f", "eb5987c766198f45d7f2c489b5fd5100", "2","颜选美学公众号");
+    private String APPID;
+    private String APPSECRET;
+    private String TYPE;
+    private String description;
+
+    public static WechatType initWechatType(String type) {
+        log.info("微信公众号>>>" + type);
+        WechatType wechatType;
+        if (StringUtils.equals("2", type) ) {
+            wechatType = WechatType.HEHE;
+        } else {
+            wechatType = WechatType.CAIMEI;
+        }
+        return wechatType;
+    }
+    public String getTYPE() {
+        return TYPE;
+    }
+
+    public void setTYPE(String TYPE) {
+        this.TYPE = TYPE;
+    }
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getAPPID() {
+        return APPID;
+    }
+
+    public void setAPPID(String APPID) {
+        this.APPID = APPID;
+    }
+
+    public String getAPPSECRET() {
+        return APPSECRET;
+    }
+
+    public void setAPPSECRET(String APPSECRET) {
+        this.APPSECRET = APPSECRET;
+    }
+}

+ 4 - 0
src/main/java/com/caimei365/tools/model/po/MessageCenterPo.java

@@ -105,6 +105,10 @@ public class MessageCenterPo implements Serializable {
      * 商品ID
      */
     private Integer productId;
+    /**
+     * 当前ID
+     */
+    private Integer thisId;
 
     /**
      * 供应商公司名称

+ 5 - 1
src/main/java/com/caimei365/tools/model/po/OrderVo.java

@@ -23,7 +23,7 @@ public class OrderVo implements Serializable {
      */
     private Integer orderId;
     /**
-     * 订单来源:1WWW、2CRM、4客服[适用后台下单]、5外单[适用后台下单]、6小程序[采美,星范]、7呵呵商城小程序、8维沙小程序
+     * 订单来源:1WWW、2CRM、4客服[适用后台下单]、5外单[适用后台下单]、6小程序[采美,星范]、7颜选美学商城小程序、8维沙小程序
      */
     private Integer orderSource;
     /**
@@ -50,6 +50,10 @@ public class OrderVo implements Serializable {
      * 机构名称(协销订单列表用)
      */
     private String clubName;
+    /**
+     * 机构名称(协销订单列表用)
+     */
+    private String productName;
     /**
      * 超级会员标识,1是,不是
      */

+ 101 - 10
src/main/java/com/caimei365/tools/task/HeheTask.java

@@ -1,11 +1,18 @@
 package com.caimei365.tools.task;
 
+import com.alibaba.fastjson.JSONObject;
 import com.caimei365.tools.mapper.BaseMapper;
 import com.caimei365.tools.mapper.HeheMapper;
 import com.caimei365.tools.model.bo.CouponBo;
 import com.caimei365.tools.model.bo.HeheCollageBo;
 import com.caimei365.tools.model.bo.HeheCouponBo;
 import com.caimei365.tools.model.bo.HeheUserBo;
+import com.caimei365.tools.model.dto.message.InsideMessage;
+import com.caimei365.tools.model.dto.message.MessageModel;
+import com.caimei365.tools.model.dto.message.MqInfo;
+import com.caimei365.tools.model.dto.message.enums.MessageType;
+import com.caimei365.tools.model.po.OrderVo;
+import com.caimei365.tools.service.MessageSender;
 import com.caimei365.tools.utils.CodeUtil;
 import com.caimei365.tools.utils.DateUtils;
 import com.caimei365.tools.utils.SmsUtil;
@@ -14,13 +21,12 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -39,18 +45,19 @@ public class HeheTask {
     private BaseMapper baseMapper;
     @Resource
     private HeheMapper heheMapper;
+    @Resource
+    private MessageSender messageSender;
     @Value("${spring.cloud.config.profile}")
     private String profile;
-
     /**
      * 每隔半小时检查这半小时内生效的优惠券,并给对应用户发送短信
      */
     @Scheduled(cron = "0 0/30 * * * ?")
     public void couponOpen() {
-        log.info("呵呵商城定时发送短信");
+        log.info("颜选美学商城定时发送短信");
         // 查询半小时内生效的活动券及专享券
         List<HeheCouponBo> couponList = heheMapper.getNewHeheCoupons();
-        // 查询呵呵商城所有用户的手机号
+        // 查询颜选美学商城所有用户的手机号
         List<String> mobileList = heheMapper.getHeheUserMobiles();
         AtomicInteger a = new AtomicInteger();
         AtomicInteger b = new AtomicInteger();
@@ -63,41 +70,62 @@ public class HeheTask {
         couponList.forEach(coupon->{
             Double couponAmount = coupon.getCouponAmount();
             AtomicReference<String> content = new AtomicReference<>("");
+            List<String> userIdByUserYear = heheMapper.findUserIdByUserYear(3);
+            String insideContent;
+            int type;
             if (1 == coupon.getCouponType()) {
                 // 活动券,给所有注册用户发送短信
+                type=0;
+                insideContent=couponAmount+"元优惠券已派送到您的领券中心,快去领取下单吧。";
                 mobileList.forEach(mobile -> {
                     if (StringUtils.isBlank(mobile) || mobile.length() != 11) {
-                        log.info("【呵呵短信】,手机号异常,mobile>>>>>" + mobile);
+                        log.info("【颜选美学短信】,手机号异常,mobile>>>>>" + mobile);
                     } else {
                         // 正式环境或指定手机号
                         if ("prod".equals(profile) || list.contains(mobile)) {
                             content.set(couponAmount + "元优惠券已派送到您的领券中心,请赶紧登录颜选美学小程序领取下单吧。退订回T");
                             String result = SmsUtil.sendSms(3, mobile, content.get());
-                            log.info("【呵呵短信】,result>>>>>>" + result);
+                            log.info("【颜选美学短信】,result>>>>>>" + result);
                             a.getAndIncrement();
                         }
                     }
                 });
             } else {
                 // 专享券
+                type=2;
+                insideContent=couponAmount+"为了感谢您长久以来的支持,现已派送" + couponAmount + "元优惠券到您的领券中心,快去领取下单吧。";
                 String userIds = coupon.getUserIds();
                 String[] userIdArr = userIds.split(",");
                 for (int i = 0; i < userIdArr.length; i++) {
                     // 查询用户手机号
                     String mobile = heheMapper.findHeheMobile(userIdArr[i]);
                     if (StringUtils.isBlank(mobile) || mobile.length() != 11) {
-                        log.info("【呵呵短信】,手机号异常,mobile>>>>>" + mobile);
+                        log.info("【颜选美学短信】,手机号异常,mobile>>>>>" + mobile);
                     } else {
                         // 正式环境或指定手机号
                         if ("prod".equals(profile) || list.contains(mobile)) {
                             content.set("为了感谢您长久以来的支持,现已派送" + couponAmount + "元优惠券到您的领券中心,请赶紧登录颜选美学小程序领取下单吧。退订回T");
                             String result = SmsUtil.sendSms(3, mobile, content.get());
-                            log.info("【呵呵短信】,result>>>>>>" + result);
+                            log.info("【颜选美学短信】,result>>>>>>" + result);
                             b.getAndIncrement();
                         }
                     }
                 }
             }
+            for (String userId : userIdByUserYear) {
+                //站内信 【活动卷/专享卷】
+                MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
+                insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+                        .mqInfo(new MqInfo().topic("MessageLine").delay(3).async(1))
+                        .info(new InsideMessage()
+                                .userType(4)
+                                .messageType(4)
+                                .couponType(type)
+                                .content(insideContent)
+                                .thisId(Integer.valueOf(userId))
+                        );
+                messageSender.messageSend(insideMessageMessageModel);
+            }
         });
         baseMapper.updateSmsSendCount(15, a.get());
         baseMapper.updateSmsSendCount(16, b.get());
@@ -165,6 +193,18 @@ public class HeheTask {
                     //7天后优惠券即将过期推送
                     content.set("您有优惠券即将过期,请赶紧登录颜选美学小程序领取下单吧。退订回T");
                     String result = SmsUtil.sendSms(3, mobile, content.get());
+                    //站内信 【7天后优惠券即将过期推送】
+                    MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
+                    insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+                            .mqInfo(new MqInfo().topic("MessageLine").delay(3).async(1))
+                            .info(new InsideMessage()
+                                    .userType(4)
+                                    .messageType(4)
+                                    .couponMessageType(2)
+                                    .content("您有"+coupon.getCouponAmount()+"元优惠券将于7日后过期,快去使用吧。")
+                                    .thisId(userId)
+                            );
+                    messageSender.messageSend(insideMessageMessageModel);
                     a++;
                     continue A;
                 }
@@ -172,6 +212,18 @@ public class HeheTask {
                     //当天优惠券即将过期推送
                     content.set("您有优惠券今日将过期,请赶紧登录颜选美学小程序领取下单吧。退订回T");
                     String result = SmsUtil.sendSms(3, mobile, content.get());
+                    //站内信 【当天优惠券即将过期推送】
+                    MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
+                    insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+                            .mqInfo(new MqInfo().topic("MessageLine").delay(3).async(1))
+                            .info(new InsideMessage()
+                                    .userType(4)
+                                    .messageType(4)
+                                    .couponMessageType(2)
+                                    .content("您有"+coupon.getCouponAmount()+"元优惠券今日将过期,快去使用吧。")
+                                    .thisId(userId)
+                            );
+                    messageSender.messageSend(insideMessageMessageModel);
                     b++;
                     continue A;
                 }
@@ -184,6 +236,18 @@ public class HeheTask {
                         //离失效日只剩7天还没领取
                         content.set("您有优惠券尚未领取,优惠券即将失效,请赶紧登录颜选美学小程序领取下单吧。退订回T");
                         String result = SmsUtil.sendSms(3, mobile, content.get());
+                        //站内信 【离失效日只剩7天还没领取】
+                        MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
+                        insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+                                .mqInfo(new MqInfo().topic("MessageLine").delay(3).async(1))
+                                .info(new InsideMessage()
+                                        .userType(4)
+                                        .messageType(4)
+                                        .couponMessageType(1)
+                                        .content("您有"+coupon.getCouponAmount()+"元优惠券尚未领取,优惠券即将失效,快去领取下单吧。")
+                                        .thisId(userId)
+                                );
+                        messageSender.messageSend(insideMessageMessageModel);
                         c++;
                         continue A;
                     }
@@ -195,6 +259,33 @@ public class HeheTask {
         baseMapper.updateSmsSendCount(22, c);
     }
 
+    /**
+     * 用户下单后,5分钟内没有线上支付 推送短信,定时查询一次
+     */
+    @Scheduled(cron = "0 */5 * * * ?")
+    public void waitPay() {
+        log.info("******************** 用户下单后,5分钟内没有线上支付 推送短信 start *******************");
+        List<OrderVo> orderList = heheMapper.getOrderMinuteList(5);
+        orderList.forEach((order) -> {
+            String name = order.getProductName();
+            if (name.length() > 10) {
+                name = name.substring(0, 10);
+            }
+            String content = "【颜选美学】您已成功下单“" + name + "...”等" + order.getProductCount() + "件商品,订单编号:" + order.getOrderNo() + ",订单等待支付,支付完成后采美将尽快安排发货。您可使用微信小程序“颜选美学”查看并支付订单。";
+            //发送短信 【用户下单后,5分钟内没有线上支付,推送短信】
+            String result = SmsUtil.sendSms(3, order.getMobile().substring(1), content);
+            JSONObject json = (JSONObject) JSONObject.parse(result);
+            log.info("发送结果:" + result + ",短信内容:" + content);
+            if (null != json && json.getInteger("code") == 0) {
+                log.info(order.getMobile() + "发送成功");
+            } else {
+                log.error(order.getMobile() + "发送失败");
+            }
+        });
+        log.info("******************** 用户下单后,5分钟内没有线上支付 推送短信 end *******************");
+    }
+
+
     /**
      * 生成短链接
      *

+ 23 - 6
src/main/java/com/caimei365/tools/task/ShopMessTask.java

@@ -200,15 +200,22 @@ public class ShopMessTask {
             OrderVo orderVo = orderClubMapper.getcartNess(userIds);
             if (orderVo.getProName() != null) {
                 String name = orderVo.getProName();
-
                 if (name.length() > 10) {
                     name = StringUtils.strip(name.substring(0, 11));
                     name += "...";
                 }
-
                 if (orderVo.getMobile() != null) {
-                    String content = "有件商品" + name + "在您购物车内已经待了很久啦,快戳采美网站链接www.caimei365.com或微信搜索“采美采购商城”小程序登录采美平台去购物车看看吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-                    String result = SmsUtil.sendSms(3, orderVo.getMobile(), content);
+                    String content;
+                    String mobile;
+                    if (6 == orderVo.getUserIdentity()) {
+                        mobile= orderVo.getMobile().substring(1);
+                        content = "【颜选美学】有件商品" + name + "在您购物车内已经待了很久啦,快去微信搜索“颜选美学”小程序登录查看吧。关注公众号“颜选美学”获取更多优惠和精彩资讯。退订回T";
+                    } else {
+                        mobile= orderVo.getMobile();
+                        content = "有件商品" + name + "在您购物车内已经待了很久啦,快戳采美网站链接www.caimei365.com或微信搜索“采美采购商城”小程序登录采美平台去购物车看看吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
+                    }
+                    //发送短信 【购物车】
+                    String result = SmsUtil.sendSms(3, mobile, content);
                     JSONObject json = (JSONObject) JSONObject.parse(result);
                     log.info("发送结果:" + result + ",短信内容:" + content);
                     if (null != json && json.getInteger("code") == 0) {
@@ -327,7 +334,12 @@ public class ShopMessTask {
             if (num == 0) {
                 MessageCenterPo messageCenter = new MessageCenterPo();
                 //推送信息中心-交易物流-待确认超时
-                messageCenter.clubId(order.getClubId()).userType(1).messageType(1).orderId(order.getOrderId()).orderMessageType(4)
+                if (6 == order.getUserIdentity()) {
+                    messageCenter.thisId(order.getUserId()).userType(4);
+                }else {
+                    messageCenter.clubId(order.getClubId()).userType(1);
+                }
+                messageCenter.messageType(1).orderId(order.getOrderId()).orderMessageType(4)
                         .content("您的订单因超时未付款,系统已自动取消订单!").time(current);
                 messageCenterMapper.addMessageCenter(messageCenter);
             }
@@ -378,7 +390,12 @@ public class ShopMessTask {
             if (num == 0) {
                 MessageCenterPo messageCenter = new MessageCenterPo();
                 //推送信息中心-账户通知
-                messageCenter.clubId(order.getClubId()).userType(1).messageType(1).orderId(order.getOrderId())
+                if (6 == order.getUserIdentity()) {
+                    messageCenter.thisId(order.getUserId()).userType(4);
+                }else {
+                    messageCenter.clubId(order.getClubId()).userType(1);
+                }
+                messageCenter.messageType(1).orderId(order.getOrderId())
                         .orderMessageType(6).content("您的订单因超时已被系统自动确认收货!").time(current);
                 messageCenterMapper.addMessageCenter(messageCenter);
             }

+ 3 - 3
src/main/java/com/caimei365/tools/task/StatisticsTask.java

@@ -116,7 +116,7 @@ public class StatisticsTask {
                 Integer count = Integer.valueOf(map.get("count").toString()) ;
                 String pageLabel = baseMapper.getBehaviorRecordYesterdayPageLabel(spId, null, dateStr);
                 String openId = baseMapper.getWechatOpenId((String) map.get("unionId"));
-                //站内信
+                //站内信 【协销前一天机构访问记录】
                 MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
                 insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
                         .mqInfo(new MqInfo().topic("MessageLine").delay(3).async(0))
@@ -130,14 +130,14 @@ public class StatisticsTask {
                                 .thisId(spId)
                         );
                 messageSender.messageSend(insideMessageMessageModel);
-                //微信模板消息
+                //微信模板消息 【协销前一天机构访问记录】
                 ArrayList<String> keyWords = new ArrayList<>();
                 keyWords.add(name+"...等"+Integer.valueOf(String.valueOf(count))+"家机构客户");
                 keyWords.add(pageLabel);
                 keyWords.add(dateStr);
                 MessageModel<WechatTemplateMessage> wechatTemplateMessageMessageModel = new MessageModel<WechatTemplateMessage>()
                         .code(MessageType.WECHAT_TEMPLATE_MESSAGE)
-                        .mqInfo(new MqInfo().topic("MessageLine").delay(3).async(0))
+                        .mqInfo(new MqInfo().topic("MessageLine").delay(3).async(1))
                         .info(new WechatTemplateMessage()
                                 .first("")
                                 .openId(openId)

+ 1 - 1
src/main/java/com/caimei365/tools/utils/CodeUtil.java

@@ -85,7 +85,7 @@ public class CodeUtil {
 
     /**
      * 生成主订单编号
-     * @param orderSource 订单来源:1WWW、2CRM、4客服[适用后台下单]、5外单[适用后台下单]、6小程序[采美,星范]、7呵呵商城小程序、8维沙小程序
+     * @param orderSource 订单来源:1WWW、2CRM、4客服[适用后台下单]、5外单[适用后台下单]、6小程序[采美,星范]、7颜选美学商城小程序、8维沙小程序
      * @return 主订单编号
      */
     public static String generateOrderNo(Integer orderSource) {

+ 11 - 4
src/main/java/com/caimei365/tools/utils/WeChatUtil.java

@@ -3,10 +3,16 @@ package com.caimei365.tools.utils;
 import com.alibaba.fastjson.JSONObject;
 
 import com.caimei365.tools.model.dto.message.WechatTemplateMessage;
+import com.caimei365.tools.model.dto.message.enums.WechatType;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
 
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.HashMap;
 import java.util.Map;
 
 @Component
@@ -14,7 +20,8 @@ import java.util.Map;
 public class WeChatUtil {
     public void sendMessage(WechatTemplateMessage wechatTemplateMessage){
         try {
-            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + getAccessToken();
+            WechatType wechatType = WechatType.initWechatType(wechatTemplateMessage.getType());
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + getAccessToken(wechatType);
             // 发送请求
             String json = wechatTemplateMessage.getJson();
             log.info("微信发消息的-------------------------->"+json);
@@ -25,10 +32,10 @@ public class WeChatUtil {
         }
     }
 
-    public String getAccessToken() throws Exception {
+    public static String getAccessToken(WechatType wechatType) 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");
+        link = link.replace("APPID", wechatType.getAPPID());
+        link = link.replace("APPSECRET", wechatType.getAPPSECRET());
         String result = RequestUtil.sendGet(link);
         log.info("微信公众号获取access_token>>>" + result);
         Map<String, Object> map = JSONObject.parseObject(result, Map.class);

+ 24 - 6
src/main/resources/mapper/HeheMapper.xml

@@ -26,7 +26,7 @@
         where id = #{collageId}
     </update>
     <select id="getNewHeheCoupons" resultType="com.caimei365.tools.model.bo.HeheCouponBo">
-        select chc.id as couponId, couponAmount, couponType,if(chc.couponType = 2,group_concat(chcu.userId),null) as userIds
+        select chc.id as couponId, couponAmount, couponType,if(chc.couponType = 2,group_concat(chcu.userId),null) as userIds,chcu.userId
         from cm_hehe_coupon chc
         left join cm_hehe_coupon_user chcu on chc.id = chcu.couponId
         where timestampdiff(minute, startTime, NOW()) <![CDATA[ < ]]> 30
@@ -161,10 +161,28 @@
           and status = 0
     </select>
     <select id="getMobilesByCollageId" resultType="java.lang.String">
-        select chu.mobile from cm_hehe_collage_member chcm
-                                   left join cm_order co on chcm.orderId = co.orderID
-                                   left join cm_hehe_user chu on chcm.userId = chu.userId
-        where collageId = #{collageId} and co.receiptStatus = 3
+        select chu.mobile
+        from cm_hehe_collage_member chcm
+                 left join cm_order co on chcm.orderId = co.orderID
+                 left join cm_hehe_user chu on chcm.userId = chu.userId
+        where collageId = #{collageId}
+          and co.receiptStatus = 3
+    </select>
+    <select id="getOrderMinuteList" resultType="com.caimei365.tools.model.po.OrderVo">
+        select co.orderNo,cop.name as productName,co.productCount,co.payableAmount,co.orderTime,co.shopOrderIDs,co.orderID,co.userID,co.payTime,
+               u.`bindMobile`AS mobile
+        from cm_order co
+        LEFT JOIN `user` u ON u.`userID` = co.userId
+        left join cm_order_product cop on cop.orderID=co.orderID
+        where 1=1
+        and co.delFlag = '0' AND co.orderType = 2 and receiptStatus!=3
+        and co.orderTime >=  DATE_SUB(NOW(), INTERVAL #{minute} MINUTE)
+        GROUP BY co.orderID
+    </select>
+    <select id="findUserIdByUserYear" resultType="String">
+        select chu.userId
+        from cm_hehe_user chu
+                 left join user u on u.userID = chu.userID
+        where u.loginTime >= DATE_SUB(NOW(), INTERVAL #{num} YEAR)
     </select>
-
 </mapper>

+ 2 - 2
src/main/resources/mapper/MessageCenter.xml

@@ -2,9 +2,9 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.tools.mapper.MessageCenterMapper">
     <insert id="addMessageCenter">
-        INSERT INTO message_center (shopID, clubID, userType, messageType, content, time, accountType, couponType, orderID, orderMessageType,
+        INSERT INTO message_center (thisId,shopID, clubID, userType, messageType, content, time, accountType, couponType, orderID, orderMessageType,
                                     couponFee, couponMessageType, ShopMessType, ShopTieredType, reasonContent)
-        VALUES (#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content}, now(), #{accountType}, #{couponType},#{orderId},#{orderMessageType},
+        VALUES (#{thisId},#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content}, now(), #{accountType}, #{couponType},#{orderId},#{orderMessageType},
                 #{couponFee}, #{couponMessageType}, #{shopMessType}, #{shopTieredType}, #{reasonContent})
     </insert>
     <insert id="sendInsideMessage">

+ 7 - 3
src/main/resources/mapper/OrderClubMapper.xml

@@ -9,7 +9,7 @@
     </select>
 
     <select id="getcartNess" resultType="com.caimei365.tools.model.po.OrderVo">
-        SELECT DISTINCT p.`name` AS proName,cm.payFlag AS payFlag,cm.onlinePayFlag AS onlinePayFlag,COUNT(p.name)AS proCount,u.`bindMobile`AS mobile,cm.orderNo AS orderNo
+        SELECT DISTINCT p.`name` AS proName,cm.payFlag AS payFlag,cm.onlinePayFlag AS onlinePayFlag,COUNT(p.name)AS proCount,u.`bindMobile`AS mobile,cm.orderNo AS orderNo,u.userIdentity
         FROM `cm_order` cm
                  LEFT JOIN cm_order_product cmp ON cm.orderID = cmp.orderID
                  LEFT JOIN  product p ON p.productID=cmp.productID
@@ -18,7 +18,9 @@
     </select>
 
     <select id="oredrStatus" resultType="com.caimei365.tools.model.po.OrderVo">
-        SELECT orderTime,clubID,orderID FROM cm_order WHERE `status`=0
+        SELECT co.orderTime,co.clubID,co.orderID,u.`userID`,u.userIdentity FROM cm_order co
+        LEFT JOIN `user` u ON u.`userID` = co.userId
+        WHERE `status`=0
     </select>
 
     <select id="cmorderconfig" resultType="java.lang.Integer">
@@ -26,7 +28,9 @@
     </select>
 
     <select id="cmorderConfigStatus" resultType="com.caimei365.tools.model.po.OrderVo">
-        SELECT * FROM cm_order WHERE `receiptStatus`=1 AND sendOutStatus=1 AND payStatus!=1
+        SELECT co.* ,u.`userID`,u.userIdentity FROM cm_order co
+        LEFT JOIN `user` u ON u.`userID` = co.userId
+        WHERE co.`receiptStatus`=1 AND co.sendOutStatus=1 AND co.payStatus!=1
     </select>
 
     <select id="cmorderStatus" resultType="com.caimei365.tools.model.po.OrderVo">