Duan_xu 2 роки тому
батько
коміт
a08138f473

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

@@ -283,6 +283,12 @@ public interface OrderClubMapper {
      */
     String getOrderNo(Integer orderId);
 
+    OrderVo getOrderMess(Integer orderId);
+
+    OrderVo getcartNess(Integer userId);
+
+    List<Integer> userIds();
+
     /**
      * 保存分享码使用记录
      */

+ 14 - 0
src/main/java/com/caimei365/order/model/vo/OrderVo.java

@@ -324,4 +324,18 @@ public class OrderVo implements Serializable {
      * 收款款项二级类别1.上架费2.订单返佣3.认证通会员4.认证通企划
      */
     private Integer newReceiptType;
+    /**
+     * 商品名称
+     */
+    private String proName;
+    /**
+     * 商品数量
+     */
+    private Integer proCount;
+    /**
+     *   下单人电话
+     */
+  private String mobile;
+
+
 }

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

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.caimei365.order.components.ProductService;
 import com.caimei365.order.mapper.BaseMapper;
 import com.caimei365.order.mapper.CartClubMapper;
+import com.caimei365.order.mapper.OrderClubMapper;
 import com.caimei365.order.mapper.OrderCommonMapper;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.CartDto;
@@ -12,13 +13,16 @@ import com.caimei365.order.model.dto.InvoiceDto;
 import com.caimei365.order.model.po.CartPo;
 import com.caimei365.order.model.vo.*;
 import com.caimei365.order.service.CartClubService;
+import com.caimei365.order.service.RemoteCallService;
 import com.caimei365.order.utils.MathUtil;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.AtomicDouble;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
+import redis.clients.jedis.Jedis;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
@@ -53,7 +57,13 @@ public class CartClubServiceImpl implements CartClubService {
     @Resource
     private OrderCommonMapper orderCommonMapper;
     @Resource
+    private OrderClubMapper orderClubMapper;
+    @Resource
     private ProductService productService;
+    @Resource
+    private RemoteCallService remoteCallService;
+    @Value("${spring.cloud.config.profile}")
+    private String profile;
 
     /**
      * 购物车列表详细数据
@@ -1942,4 +1952,42 @@ 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("------------推送购物车相关短信-结束----------------------->");
+    }
+
 }

+ 45 - 1
src/main/java/com/caimei365/order/service/impl/OrderClubServiceImpl.java

@@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpHeaders;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -34,6 +35,9 @@ 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;
 
 /**
  * Description
@@ -374,6 +378,7 @@ public class OrderClubServiceImpl implements OrderClubService {
             order.setStatus(31);
             order.setReceiptStatus(3);
         }
+        Integer count=0;
         log.info("********************下单微信公众号消息推送***************************");
         if (0 == order.getSecondHandOrderFlag() && 0 == order.getRebateFlag() && !orderClubMapper.getProductOrder(order.getOrderId()).contains(6060) && order.getOrderType() != 0) {
             log.info("*******" + order.getSecondHandOrderFlag() + "**********" + order.getRebateFlag());
@@ -400,6 +405,7 @@ public class OrderClubServiceImpl implements OrderClubService {
             for (String openid : openidList) {
                 // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接)
                 weChatService.sendTemplateMsgs(accessToken, openid, associateTitle, name,orderno, money, remarkText, pagePath);
+                count++;
             }
         } catch (Exception e) {
             log.error("【订单发货通知】获取微信公众号access_token异常!", e);
@@ -415,7 +421,46 @@ public class OrderClubServiceImpl implements OrderClubService {
             messageCenter.setContent(null);
             messageCenter.setTime(curDateStr);
             orderClubMapper.addMessageCenter(messageCenter);
+
+
+            log.info(">>>>>>>>>>>>>>>>>>>>>>"+orderId);
+            log.info("********************确认订单短信消息推送***************************");
+            if(count<=0){
+            ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
+            executorService.schedule(new Runnable() {
+                @Override
+                public void run() {
+//                String orderno = orderClubMapper.getOrderNo(orderId);
+                    OrderVo orderVo=orderClubMapper.getOrderMess(orderId);
+
+                    String bindMobile = baseMapper.getBindMobileByUserId(order.getUserId());
+                    log.info(">>>>>>>>>>>>>>>>>>>>>>"+orderId);
+
+                    log.info(">>>>>>>>>>>>>>>>>>>>>>"+orderVo.getProCount());
+                    String name=orderVo.getProName();
+                    if (name.length() > 10) {
+                        name = StringUtils.strip(name.substring(0, 11));
+                        name += "...";
+                    }
+                    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或使用微信小程序“采美采购商城”查看并支付订单。";
+                        boolean sendSms = remoteCallService.getSendSms(2, orderVo.getMobile(), content);
+                        if (!sendSms) {
+                            log.info("》》》》》》》》》》》》》》》》购买会员短信推送失败");
+                        }else {
+                            log.info("》》》》》》》》》》》》》》》》购买会员短信推送成功");
+                        }
+                    }
+                }
+            }, 300000, TimeUnit.MILLISECONDS);
+            }else {log.info("》》》》》推送了微信公众号");}
+
+
         }
+
+
+
         order.setUpdateDate(curDateStr);
         order.setConfirmTime(curDateStr);
         //确认订单状态
@@ -423,7 +468,6 @@ public class OrderClubServiceImpl implements OrderClubService {
         // 更新订单状态
         orderClubMapper.updateOrderStatus(order);
 
-
         return ResponseJson.success("确认订单成功!", null);
     }
 

+ 1 - 0
src/main/java/com/caimei365/order/service/impl/RemoteCallServiceImpl.java

@@ -75,6 +75,7 @@ public class RemoteCallServiceImpl implements RemoteCallService {
             list.add("15814011616");
             list.add("13100721916");
             list.add("15113936829");
+            list.add("18175515644");
             if ("prod".equals(profile) || list.contains(mobile)) {
                 if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
                     String regex = "^(1[3-9]\\d{9}$)";

+ 2 - 0
src/main/java/com/caimei365/order/task/DelayedSplittingTask.java

@@ -39,4 +39,6 @@ public class DelayedSplittingTask {
     public void couponCheck() {
         payOrderService.couponCheck();
     }
+
+
 }

+ 24 - 0
src/main/resources/mapper/OrderClubMapper.xml

@@ -544,6 +544,30 @@
         WHERE cmp.orderId=#{orderId}
     </select>
 
+    <select id="getOrderMess" resultType="com.caimei365.order.model.vo.OrderVo">
+        SELECT DISTINCT p.`name` AS proName,cm.payFlag AS payFlag,cm.onlinePayFlag AS onlinePayFlag,COUNT(p.name)AS proCount,u.`mobile`AS mobile,cm.orderNo AS orderNo
+        FROM `cm_order` cm
+         LEFT JOIN cm_order_product cmp ON cm.orderID = cmp.orderID
+         LEFT JOIN  product p ON p.productID=cmp.productID
+         LEFT JOIN `user` u ON u.`userID` = cm.userId
+        WHERE cm.orderId=#{orderId}
+    </select>
+
+    <select id="getcartNess" resultType="com.caimei365.order.model.vo.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
+        FROM `cm_order` cm
+        LEFT JOIN cm_order_product cmp ON cm.orderID = cmp.orderID
+        LEFT JOIN  product p ON p.productID=cmp.productID
+        LEFT JOIN `user` u ON u.`userID` = cm.userId
+        WHERE cm.userID=#{userID}
+    </select>
+
+    <select id="userIds" resultType="java.lang.Integer">
+        SELECT  DISTINCT userID FROM cm_cart
+        WHERE
+            YEAR(`addTime`)>YEAR(NOW())-3 AND userID IS NOT NULL
+    </select>
+
     <select id="getClubCouponById" resultType="com.caimei365.order.model.vo.CouponVo">
         SELECT
         a.id AS clubCouponId,