Duan_xu hace 2 años
padre
commit
49e3e5b261

+ 99 - 0
src/main/java/com/caimei365/order/components/WeChatService.java

@@ -516,4 +516,103 @@ public class WeChatService {
             log.error("推送微信模板消息失败:", e);
         }
     }
+
+    /**
+     * 续费会员消息推送
+     * @param accessToken 微信公众号
+     * @param openid 公众号的openid
+     * @param title 标题
+     * @param name 商品名称
+     * @param remarkText 备注
+     * @param pagePath 跳转链接
+     */
+    public void sendTempl(String accessToken, String openid, String title, String name,String type,String date,String remarkText, String pagePath) {
+        JSONObject first = new JSONObject();
+        first.put("value", title);
+        JSONObject keyword1 = new JSONObject();
+        keyword1.put("value", name);
+        JSONObject keyword2 = new JSONObject();
+        keyword2.put("value", date);
+        JSONObject keyword3 = new JSONObject();
+        keyword2.put("value", "会员剩余天数:30天");
+        JSONObject remark = new JSONObject();
+        remark.put("value", remarkText);
+
+        JSONObject data = new JSONObject();
+        data.put("first", first);
+        data.put("keyword1", keyword1);
+        data.put("keyword2", keyword2);
+        data.put("remark", remark);
+
+        JSONObject miniProgram = new JSONObject();
+        miniProgram.put("appid", miniAppId);
+        miniProgram.put("pagepath", pagePath);
+
+        JSONObject json = new JSONObject(new LinkedHashMap());
+        json.put("touser",openid);
+        json.put("template_id","QHsM0AhlgGaX6kJ6vFm1wAKIkNjnZdWPjFGOKopLbsM");
+        json.put("url","https://www.caimei365.com/");
+        json.put("miniprogram", miniProgram);
+        json.put("data", data);
+        // json 字符串
+        String jsonString = json.toJSONString();
+        log.info(">>>>>>>>推送微信模板消息:" + jsonString);
+        try {
+            // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
+//            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+accessToken;
+            // 发送请求
+            String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
+            log.info(">>>>>>>>推送结果:" + result);
+        } catch (Exception e) {
+            log.error("推送微信模板消息失败:", e);
+        }
+    }
+
+
+    /**
+     * 续费会员消息推送
+     */
+    public void sendTemplss(String accessToken, String openid,String Time, String pagePath) {
+        JSONObject first = new JSONObject();
+        first.put("value", "恭喜您成功续费采美超级会员");
+        JSONObject keyword1 = new JSONObject();
+        keyword1.put("value", "超级会员");
+        JSONObject keyword2 = new JSONObject();
+        keyword2.put("value", Time);
+        JSONObject remark = new JSONObject();
+        remark.put("value", "如在使用中有任何疑问,请在小程序内联系在线客服");
+
+        JSONObject data = new JSONObject();
+        data.put("first", first);
+        data.put("keyword1", keyword1);
+        data.put("keyword2", keyword2);
+        data.put("remark", remark);
+
+        JSONObject miniProgram = new JSONObject();
+        miniProgram.put("appid", miniAppId);
+        miniProgram.put("pagepath", pagePath);
+
+        JSONObject json = new JSONObject(new LinkedHashMap());
+        json.put("touser",openid);
+        json.put("template_id","QHsM0AhlgGaX6kJ6vFm1wAKIkNjnZdWPjFGOKopLbsM");
+        json.put("url","https://www.caimei365.com/");
+        json.put("miniprogram", miniProgram);
+        json.put("data", data);
+        // json 字符串
+        String jsonString = json.toJSONString();
+        log.info(">>>>>>>>推送微信模板消息:" + jsonString);
+        try {
+            // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
+//            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+accessToken;
+            // 发送请求
+            String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
+            log.info(">>>>>>>>推送结果:" + result);
+        } catch (Exception e) {
+            log.error("推送微信模板消息失败:", e);
+        }
+    }
+
+
 }

+ 4 - 0
src/main/java/com/caimei365/order/mapper/OrderClubMapper.java

@@ -334,4 +334,8 @@ public interface OrderClubMapper {
     void insertCouponRecord(CouponRecordPo couponRecordPo);
 
     void addMessageCenter(MessageCenter messageCenter);
+
+    Integer getVipHistoryCount(Integer userId);
+
+    Integer clubIdCule(Integer userId);
 }

+ 4 - 0
src/main/java/com/caimei365/order/model/vo/MessageCenter.java

@@ -37,6 +37,10 @@ public class MessageCenter implements Serializable {
      * 消息内容
      */
     private String content;
+    /**
+     * 账户通知类型 1.注册成功通知 2.购买超级会员成功 3.超级会员到期提醒 4.超级会员到期提醒 5.升级资质机构成功 6.升级资质机构失败 7.成为机构运营人员通知
+     */
+    private Integer accountType;
     /**
      * 操作完成时间
      */

+ 0 - 38
src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -1952,42 +1952,4 @@ public class CartClubServiceImpl implements CartClubService {
         return ResponseJson.success(map);
     }
 
-    @Scheduled(cron = "0 0 10 15 * ?")
-    public void gwc() {
-        log.info("------------开始推送购物车相关短信------------------------>");
-        Jedis jedis = new Jedis("172.31.165.23", 6379);
-        if (jedis == null) {
-            Jedis jedisno = new Jedis("192.168.2.100", 6379);
-            if (jedisno == null) {
-                Jedis jedisto = new Jedis("172.31.165.27", 6379);
-            }
-        }
-        List<Integer> userId = orderClubMapper.userIds();
-      userId.forEach(userIds -> {
-            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 shortLink = remoteCallService.getShortLink(8, 2, "https://www.caimei365.com");
-                  String content = "【采美365】您已成功下单“"+ name +"在您购物车内已经待了很久啦,快戳采美网站链接www.caimei365.com或微信搜索“采美采购商城”小程序登录采美平台去购物车看看吧。关注公众号“采美网”获取更多优惠和精彩资讯。";
-                  boolean sendSms = remoteCallService.getSendSms(2, orderVo.getMobile(), content);
-                  if (!sendSms) {
-                      log.info("------------推送购物车相关短信-结束----------------------->");
-                      log.info("》》》》》》》》》》》》》》》》购买会员短信推送失败");
-                  }else {
-                      log.info("------------推送购物车相关短信-结束----------------------->");
-                      log.info("》》》》》》》》》》》》》》》》购买会员短信推送成功");
-                  }
-              }
-          }
-          });
-
-        log.info("------------推送购物车相关短信-结束----------------------->");
-    }
-
 }

+ 73 - 0
src/main/java/com/caimei365/order/service/impl/HeliPayNonOrderServiceImpl.java

@@ -801,6 +801,79 @@ public class HeliPayNonOrderServiceImpl implements HeliPayNonOrderService {
         //修改分账付款状态
         payOrderMapper.updateSplitAccountByPay(mbOrderId);
         //已支付推送
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String current = dateFormat.format(new Date());
+        //1.日期格式
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+        String endTime = sdf.format(dbUserVip.getEndTime());
+        //2.会员有效期(月)
+        Long s = (dbUserVip.getEndTime().getTime() - dbUserVip.getBeginTime().getTime()) / 24 / 60 / 60 / 30 / 1000;
+        //2.会员有效期(日)
+        Long t = (dbUserVip.getEndTime().getTime() - dbUserVip.getBeginTime().getTime()) / 24 / 60 / 60 / 1000;
+        Integer count =orderClubMapper.getVipHistoryCount(userId);
+        //推送信息中心-账户通知
+        Integer clubId = orderClubMapper.clubIdCule(userId);
+        if (clubId != null) {
+            //3.输出间隔天数         getTime获取的是毫秒
+            log.info("输出间隔月份----------->"+ s);
+            MessageCenter messageCenter = new MessageCenter();
+            messageCenter.setShopID(null);
+            messageCenter.setClubID(clubId);
+            messageCenter.setUserType(1);
+            messageCenter.setMessageType(2);
+            messageCenter.setAccountType(2);
+            messageCenter.setContent(s + "个月");
+            messageCenter.setTime(current);
+            orderClubMapper.addMessageCenter(messageCenter);
+        }
+        if(count==0){
+            String name = "0";
+            try {
+                log.info("***********会员办理微信公众号推送************");
+                String accessToken = weChatService.getAccessToken();
+                List<String> openidList = orderClubMapper.getOpenidListByPermission(orderClubMapper.FromUnionId(userId));
+                name = "恭喜成为采美商城超级会员";
+                String time="超级会员("+s+"个月)";
+                String dates=s+"天";
+                Double money =  amount;
+                String remarkText = "如在使用中有任何疑问,请在小程序内联系在线客服";
+                // 跳转到【小程序付款-选择支付方式页面】
+                String pagePath = "/pages/user/member/member";
+                // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
+
+                for (String openid : openidList) {
+                    weChatService.sendTempl(accessToken, openid, name, time, money.toString(), dates, remarkText, pagePath);
+                    log.error("获取openid>>>>>" + openid);
+                }
+
+            } catch (Exception e) {
+                log.error("【订单下单通知】获取微信公众号access_token异常!", e);
+            }
+        }else {
+            String name = "0";
+            SimpleDateFormat dnf=new SimpleDateFormat("yyyy年MM月dd日");
+
+            try {
+                log.info("***********会员续费微信公众号推送************");
+                String accessToken = weChatService.getAccessToken();
+                List<String> openidList = orderClubMapper.getOpenidListByPermission(orderClubMapper.FromUnionId(userId));
+                name = "恭喜您成功续费采美超级会员";
+                String type="超级会员";
+                String dates=dnf.format(dbUserVip.getEndTime());
+                String remarkText = "如在使用中有任何疑问,请在小程序内联系在线客服";
+                // 跳转到【小程序付款-选择支付方式页面】
+                String pagePath = "/pages/user/member/member";
+                // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
+
+                for (String openid : openidList) {
+                    weChatService.sendTemplss(accessToken, openid,dates,pagePath);
+                }
+            } catch (Exception e) {
+                log.error("【订单下单通知】获取微信公众号access_token异常!", e);
+            }
+        }
+
+
         boolean smsPushFlag = !orderRequestNo.contains("BETA") && !orderRequestNo.contains("DEV");
         String bindMobile = baseMapper.getBindMobileByUserId(userId);
         if (smsPushFlag && StringUtils.isNotBlank(bindMobile)) {

+ 3 - 5
src/main/java/com/caimei365/order/service/impl/OrderClubServiceImpl.java

@@ -35,9 +35,7 @@ import javax.annotation.Resource;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
 
 /**
  * Description
@@ -423,7 +421,7 @@ public class OrderClubServiceImpl implements OrderClubService {
             log.info(">>>>>>>>>>>>>>>>>>>>>>"+orderId);
             log.info("********************确认订单短信消息推送***************************");
             if(count<=0){
-            ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
+                   ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(2);
             executorService.schedule(new Runnable() {
                 @Override
                 public void run() {
@@ -441,7 +439,7 @@ public class OrderClubServiceImpl implements OrderClubService {
                     }
                     if(orderVo.getPayFlag()==1 && orderVo.getOnlinePayFlag()==0){
                         String shortLink = remoteCallService.getShortLink(8, 2, "https://www.caimei365.com");
-                        String content = "【采美365】您已成功下单“"+ name +"”等"+orderVo.getProCount()+"件商品,订单编号:"+orderVo.getOrderNo()+"订单等待支付,支付完成后采美将尽快安排发货。您可点击采美网址www.caimei365.com或使用微信小程序“采美采购商城”查看并支付订单。";
+                        String content = "您已成功下单“"+ name +"”等"+orderVo.getProCount()+"件商品,订单编号:"+orderVo.getOrderNo()+"订单等待支付,支付完成后采美将尽快安排发货。您可点击采美网址www.caimei365.com或使用微信小程序“采美采购商城”查看并支付订单。";
                         boolean sendSms = remoteCallService.getSendSms(2, orderVo.getMobile(), content);
                         if (!sendSms) {
                             log.info("》》》》》》》》》》》》》》》》购买会员短信推送失败");

+ 14 - 0
src/main/java/com/caimei365/order/service/impl/ShipServiceImpl.java

@@ -638,6 +638,20 @@ public class ShipServiceImpl implements ShipService {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return ResponseJson.error("物流信息参数异常!", null);
             }
+
+            //推送信息中心-交易物流
+            String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
+            MessageCenter messageCenter=new MessageCenter();
+            messageCenter.setShopID(logisticsBatch.getShopId());
+            messageCenter.setClubID(null);
+            messageCenter.setUserType(2);
+            messageCenter.setMessageType(1);
+            messageCenter.setOrderMessageType(5);
+            messageCenter.setOrderID(logisticsBatch.getOrderId());
+            messageCenter.setContent(null);
+            messageCenter.setTime(curDateStr);
+            orderClubMapper.addMessageCenter(messageCenter);
+
             LogisticsInformationPo logisticsInformation = new LogisticsInformationPo();
             logisticsInformation.setLogisticsBatchId(logisticsBatch.getId());
             logisticsInformation.setType("1");

+ 12 - 2
src/main/resources/mapper/OrderClubMapper.xml

@@ -626,8 +626,18 @@
 
 
     <insert id="addMessageCenter">
-        INSERT INTO message_center (shopID, clubID, userType, messageType, content,time,orderMessageType,orderID)
-        VALUES (#{shopID}, #{clubID}, #{userType}, #{messageType}, #{content},#{time},#{orderMessageType},#{orderID})
+        INSERT INTO message_center (shopID, clubID, userType, messageType, content,time,orderMessageType,orderID,accountType)
+        VALUES (#{shopID}, #{clubID}, #{userType}, #{messageType}, #{content},#{time},#{orderMessageType},#{orderID},#{accountType})
     </insert>
 
+    <select id="getVipHistoryCount" resultType="java.lang.Integer">
+        SELECT count(1)
+        FROM cm_svip_history
+        WHERE  userId = #{userId}
+    </select>
+
+    <select id="clubIdCule" resultType="java.lang.Integer">
+        SELECT clubID FROM `user` WHERE userId=#{userId}
+    </select>
+
 </mapper>