Browse Source

小需求优化V1.3.13

kaick 1 year ago
parent
commit
ae4194db76

+ 9 - 0
src/main/java/com/caimei365/order/feign/ToolsFeign.java

@@ -1,8 +1,11 @@
 package com.caimei365.order.feign;
 
+import com.caimei365.order.utils.ResponseJson;
+import com.caimei365.order.utils.message.MessageModel;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
 /**
@@ -33,4 +36,10 @@ public interface ToolsFeign {
      */
     @GetMapping("/tools/query/logistics")
     String getLogisticsByNumber(@RequestParam String number, @RequestParam String companyCode, @RequestParam String mobile);
+
+    /**
+     * 请求发消息
+     */
+    @PostMapping("/tools/message/send")
+    ResponseJson sendCommonMessage(@RequestBody MessageModel messageModel);
 }

+ 2 - 0
src/main/java/com/caimei365/order/mapper/BaseMapper.java

@@ -392,4 +392,6 @@ public interface BaseMapper {
     List<BalanceRecordPo> findShopOrderBalanceRecord(Integer shopOrderId);
 
     Integer findShopIdByProduct(Integer couponId);
+
+    String getWechatHeheOpenId(Integer userId);
 }

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

@@ -32,6 +32,10 @@ public class OrderVo implements Serializable {
      * 订单编号
      */
     private String orderNo;
+    /**
+     * 商品名称
+     */
+    private String productName;
     /**
      * 用户Id
      */

+ 32 - 2
src/main/java/com/caimei365/order/service/impl/OrderRefundServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei365.order.components.OnlinePostFormUtil;
 import com.caimei365.order.constant.Constant;
+import com.caimei365.order.feign.ToolsFeign;
 import com.caimei365.order.mapper.BaseMapper;
 import com.caimei365.order.mapper.OrderRefundMapper;
 import com.caimei365.order.mapper.PayOrderMapper;
@@ -12,13 +13,19 @@ import com.caimei365.order.model.enums.AccountPayOrderType;
 import com.caimei365.order.model.po.*;
 import com.caimei365.order.model.vo.*;
 import com.caimei365.order.service.OrderRefundService;
+import com.caimei365.order.service.RemoteCallService;
 import com.caimei365.order.utils.MathUtil;
 import com.caimei365.order.utils.helipay.Disguiser;
 import com.caimei365.order.utils.helipay.HttpClientService;
 import com.caimei365.order.utils.helipay.MessageHandle;
 import com.caimei365.order.utils.helipay.MyBeanUtils;
+import com.caimei365.order.utils.message.InsideMessage;
+import com.caimei365.order.utils.message.MessageModel;
+import com.caimei365.order.utils.message.MqInfo;
+import com.caimei365.order.utils.message.enums.MessageType;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.httpclient.HttpStatus;
+import org.aspectj.bridge.MessageUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -42,8 +49,10 @@ public class OrderRefundServiceImpl implements OrderRefundService {
     private PayOrderMapper payOrderMapper;
     @Resource
     private BaseMapper baseMapper;
-
-
+    @Resource
+    private RemoteCallService remoteCallService;
+    @Resource
+    private ToolsFeign toolsFeign;
     @Override
     @Transactional(rollbackFor = Exception.class)
     public ResponseJson refundShopOrder(Integer shopOrderId) throws Exception {
@@ -157,6 +166,27 @@ public class OrderRefundServiceImpl implements OrderRefundService {
         }
         // 修改user信息
         refundMapper.updateUser(user);
+        //发送短信 【全部退款,推送短信】
+        if(2==order.getOrderType()){
+            String content = "【颜选美学】订单("+order.getProductName()+"...等1件商品)已全部退款成功,退款金额¥"+cmReturnedPurchase.getReturnedPurchaseFee()+"。您可使用微信小程序“颜选美学”查看订单。退订回T";
+            boolean sendSms = remoteCallService.getSendSms(1, 0, order.getMobile().substring(1), content);
+            if (!sendSms) {
+                log.info("【颜选美学】订单退款推送失败!orderId>>>>" + order.getOrderId());
+            }
+            //站内信
+            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(1)
+                            .orderMessageType(3)
+                            .content("您的订单已全部退款/货成功!退款金额 ¥"+cmReturnedPurchase.getReturnedPurchaseFee()+",到账时间可能存在延迟,具体以支付方通知为准。")
+                            .orderId(order.getOrderId())
+                            .thisId(order.getUserId())
+                    );
+            toolsFeign.sendCommonMessage(insideMessageMessageModel);
+        }
         return ResponseJson.success();
     }
 

+ 46 - 1
src/main/java/com/caimei365/order/service/impl/ShipServiceImpl.java

@@ -6,6 +6,7 @@ import com.caimei365.order.components.OrderCommonService;
 import com.caimei365.order.components.OssService;
 import com.caimei365.order.components.ProductService;
 import com.caimei365.order.components.WeChatService;
+import com.caimei365.order.feign.ToolsFeign;
 import com.caimei365.order.mapper.*;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.*;
@@ -13,9 +14,15 @@ import com.caimei365.order.model.po.*;
 import com.caimei365.order.model.vo.*;
 import com.caimei365.order.service.RemoteCallService;
 import com.caimei365.order.service.ShipService;
+import com.caimei365.order.utils.DateUtils;
 import com.caimei365.order.utils.ImageUtil;
 import com.caimei365.order.utils.MathUtil;
 import com.caimei365.order.utils.OSSUtils;
+import com.caimei365.order.utils.message.InsideMessage;
+import com.caimei365.order.utils.message.MessageModel;
+import com.caimei365.order.utils.message.MqInfo;
+import com.caimei365.order.utils.message.WechatTemplateMessage;
+import com.caimei365.order.utils.message.enums.MessageType;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.google.common.util.concurrent.AtomicDouble;
@@ -23,6 +30,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.commons.lang.StringUtils;
+import org.aspectj.bridge.MessageUtil;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpHeaders;
 import org.springframework.stereotype.Service;
@@ -84,7 +92,8 @@ public class ShipServiceImpl implements ShipService {
     private CmReportingMemberMapper cmReportingMemberMapper;
     @Resource
     private WeChatService weChatService;
-
+    @Resource
+    private ToolsFeign toolsFeign;
     /**
      * 供应商订单列表
      *
@@ -581,6 +590,42 @@ public class ShipServiceImpl implements ShipService {
             logisticsInformation.setUpdateDate(date);
             // 保存 物流跟踪信息
             shipMapper.insertLogisticsInformation(logisticsInformation);
+            if(2==shopOrder.getOrderType()){
+                String openId = baseMapper.getWechatHeheOpenId(shopOrder.getUserId());
+                //微信模板消息
+                Map<String,Object> keyWords = new HashMap<>();
+                keyWords.put("character_string3",shopOrder.getOrderNo());
+                keyWords.put("time10",DateUtils.formatDate(date, "yyyy-MM-dd HH:mm"));
+                keyWords.put("thing9",logisticsCompanyName);
+                keyWords.put("character_string8",number);
+                MessageModel<WechatTemplateMessage> wechatTemplateMessageMessageModel = new MessageModel<WechatTemplateMessage>()
+                        .code(MessageType.WECHAT_TEMPLATE_MESSAGE)
+                        .mqInfo(new MqInfo().topic("MessageLine").delay(3).async(1))
+                        .info(new WechatTemplateMessage()
+                                .type("2")
+                                .templateType("2")
+                                .first("订单发货通知")
+                                .openId(openId)
+                                .appid("wx2c3b0a7f343235b1")
+                                .templateId("0Ruf-Ypu0Eahk0vY9orVN0-QqE0auk2N89LqjtGq4p8")
+                                .mapKeyWords(keyWords)
+                                .remark("您购买的商品已发货,收到货后请记得确认收货哟~")
+                                .pagePath("pages/views/order/order-detail?orderId="+shopOrder.getOrderId()));
+                toolsFeign.sendCommonMessage(wechatTemplateMessageMessageModel);
+                //站内信
+                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(1)
+                                .orderMessageType(5)
+                                .content("您的订单已发货,请您留意物流变化!")
+                                .orderId(shopOrder.getOrderId())
+                                .thisId(shopOrder.getUserId())
+                        );
+                toolsFeign.sendCommonMessage(insideMessageMessageModel);
+            }
         }
 
         /*

+ 74 - 0
src/main/java/com/caimei365/order/utils/message/EmailMessage.java

@@ -0,0 +1,74 @@
+package com.caimei365.order.utils.message;
+
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Email;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@Accessors(fluent = true)
+@NoArgsConstructor
+@ToString
+public class EmailMessage {
+    /**
+     * 邮件主题
+     */
+    @NotNull
+    private String subject;
+    /**
+     * 收件人地址
+     */
+    @NotNull
+    @Email
+    private String receiverAddress;
+    /**
+     * 内容
+     */
+    @NotNull
+    private String emailMessageContent;
+    /**
+     * 抄送地址
+     */
+    private String[] cc;
+
+    public EmailMessage cc(String cc) {
+        this.cc = new String[]{cc};
+        return this;
+    }
+
+    public String getSubject() {
+        return subject;
+    }
+
+    public void setSubject(String subject) {
+        this.subject = subject;
+    }
+
+    public String getReceiverAddress() {
+        return receiverAddress;
+    }
+
+    public void setReceiverAddress(String receiverAddress) {
+        this.receiverAddress = receiverAddress;
+    }
+
+    public String getEmailMessageContent() {
+        return emailMessageContent;
+    }
+
+    public void setEmailMessageContent(String emailMessageContent) {
+        this.emailMessageContent = emailMessageContent;
+    }
+
+    public String[] getCc() {
+        return cc;
+    }
+
+    public void setCc(String[] cc) {
+        this.cc = cc;
+    }
+}

+ 373 - 0
src/main/java/com/caimei365/order/utils/message/InsideMessage.java

@@ -0,0 +1,373 @@
+package com.caimei365.order.utils.message;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @author Administrator
+ * 站内信model
+ */
+@Data
+@Accessors(fluent = true)
+public class InsideMessage implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 消息id
+     */
+    private Integer id;
+    /**
+     * 供应商id
+     */
+    private Integer shopId;
+    /**
+     * 机构id
+     */
+    private Integer clubId;
+    /**
+     * 订单ID
+     */
+    private Integer orderId;
+    /**
+     * 用户类型1.机构2.供应商
+     */
+    private Integer userType;
+    /**
+     * 消息类型1.交易物流2.账户通知3.服务通知4.优惠促销
+     */
+    private Integer messageType;
+    /**
+     * 消息内容
+     */
+    private String content;
+    /**
+     * 失败原因
+     */
+    private String reasonContent;
+    /**
+     * 操作完成时间
+     */
+    private String time;
+    /**
+     * 账户通知类型 1.注册成功通知 2.购买超级会员成功 3.超级会员到期提醒 4.超级会员到期提醒 5.升级资质机构成功 6.升级资质机构失败 7.成为机构运营人员通知
+     */
+    private Integer accountType;
+    /**
+     * 优惠券类型 1.优惠券待领取通知 2.优惠券过期通知
+     */
+    private Integer couponType;
+    /**
+     * 优惠券金额
+     */
+    private Double couponFee;
+    /**
+     * 主图
+     */
+    private String mainImage;
+    /**
+     * 是否能走线上支付 0可以 1不可以 只能线下
+     */
+    private Integer onlinePayFlag;
+    /**
+     * 商品名称
+     */
+    private String productName;
+    /**
+     * 供应商消息类型 1,账号审核通知,2.成为公司运营人员通知,3.商品上架审核通知,4.新品展示审核通知,5.上架费到期通知 6.商品资质到期通知
+     */
+    private Integer shopMessType;
+    /**
+     * 供应商服务消息类型 1.上架费
+     */
+    private Integer shopTieredType;
+    /**
+     * 交易物流1.下单成功通知  2.订单支付完成 3.退款/货成功通知 4.订单取消通知 5.订单发货通知 6.自动收货通知
+     */
+    private Integer orderMessageType;
+    /**
+     * 0.未读 , 1.已读
+     */
+    private Integer saved;
+    /**
+     * 优惠券类型 1.优惠券待领取通知 2.优惠券过期通知
+     */
+    private Integer couponMessageType;
+    /**
+     * 商品记录数
+     */
+    private Integer productCount;
+    /**
+     * 退货退款类型:1部分退、2全部退
+     */
+    private Integer refundType;
+
+    /**
+     * 订单状态
+     */
+    private Integer status;
+    /**
+     * 商品ID
+     */
+    private Integer productId;
+
+    /**
+     * 供应商公司名称
+     */
+    private String shopName;
+
+    /** 手机号 */
+    private String mobile;
+
+    /** 名称 */
+    private String name;
+
+    /** 用户名称 */
+    private String userName;
+
+    /** 前用户名称 */
+    private String superUserName;
+
+    /** 当前id */
+    private Integer thisId;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(Integer shopId) {
+        this.shopId = shopId;
+    }
+
+    public Integer getClubId() {
+        return clubId;
+    }
+
+    public void setClubId(Integer clubId) {
+        this.clubId = clubId;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public Integer getUserType() {
+        return userType;
+    }
+
+    public void setUserType(Integer userType) {
+        this.userType = userType;
+    }
+
+    public Integer getMessageType() {
+        return messageType;
+    }
+
+    public void setMessageType(Integer messageType) {
+        this.messageType = messageType;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getReasonContent() {
+        return reasonContent;
+    }
+
+    public void setReasonContent(String reasonContent) {
+        this.reasonContent = reasonContent;
+    }
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+
+    public Integer getAccountType() {
+        return accountType;
+    }
+
+    public void setAccountType(Integer accountType) {
+        this.accountType = accountType;
+    }
+
+    public Integer getCouponType() {
+        return couponType;
+    }
+
+    public void setCouponType(Integer couponType) {
+        this.couponType = couponType;
+    }
+
+    public Double getCouponFee() {
+        return couponFee;
+    }
+
+    public void setCouponFee(Double couponFee) {
+        this.couponFee = couponFee;
+    }
+
+    public String getMainImage() {
+        return mainImage;
+    }
+
+    public void setMainImage(String mainImage) {
+        this.mainImage = mainImage;
+    }
+
+    public Integer getOnlinePayFlag() {
+        return onlinePayFlag;
+    }
+
+    public void setOnlinePayFlag(Integer onlinePayFlag) {
+        this.onlinePayFlag = onlinePayFlag;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    public Integer getShopMessType() {
+        return shopMessType;
+    }
+
+    public void setShopMessType(Integer shopMessType) {
+        this.shopMessType = shopMessType;
+    }
+
+    public Integer getShopTieredType() {
+        return shopTieredType;
+    }
+
+    public void setShopTieredType(Integer shopTieredType) {
+        this.shopTieredType = shopTieredType;
+    }
+
+    public Integer getOrderMessageType() {
+        return orderMessageType;
+    }
+
+    public void setOrderMessageType(Integer orderMessageType) {
+        this.orderMessageType = orderMessageType;
+    }
+
+    public Integer getSaved() {
+        return saved;
+    }
+
+    public void setSaved(Integer saved) {
+        this.saved = saved;
+    }
+
+    public Integer getCouponMessageType() {
+        return couponMessageType;
+    }
+
+    public void setCouponMessageType(Integer couponMessageType) {
+        this.couponMessageType = couponMessageType;
+    }
+
+    public Integer getProductCount() {
+        return productCount;
+    }
+
+    public void setProductCount(Integer productCount) {
+        this.productCount = productCount;
+    }
+
+    public Integer getRefundType() {
+        return refundType;
+    }
+
+    public void setRefundType(Integer refundType) {
+        this.refundType = refundType;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public String getShopName() {
+        return shopName;
+    }
+
+    public void setShopName(String shopName) {
+        this.shopName = shopName;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getSuperUserName() {
+        return superUserName;
+    }
+
+    public void setSuperUserName(String superUserName) {
+        this.superUserName = superUserName;
+    }
+
+    public Integer getThisId() {
+        return thisId;
+    }
+
+    public void setThisId(Integer thisId) {
+        this.thisId = thisId;
+    }
+}

+ 44 - 0
src/main/java/com/caimei365/order/utils/message/MessageModel.java

@@ -0,0 +1,44 @@
+package com.caimei365.order.utils.message;
+
+import com.caimei365.order.utils.message.enums.MessageType;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+/**
+ * @author Administrator
+ */
+@Data
+@Accessors(fluent = true)
+@NoArgsConstructor
+public class MessageModel<T> {
+    private MessageType code;
+
+    private MqInfo mqInfo;
+
+    private T info;
+
+    public MessageType getCode() {
+        return code;
+    }
+
+    public void setCode(MessageType code) {
+        this.code = code;
+    }
+
+    public MqInfo getMqInfo() {
+        return mqInfo;
+    }
+
+    public void setMqInfo(MqInfo mqInfo) {
+        this.mqInfo = mqInfo;
+    }
+
+    public T getInfo() {
+        return info;
+    }
+
+    public void setInfo(T info) {
+        this.info = info;
+    }
+}

+ 65 - 0
src/main/java/com/caimei365/order/utils/message/MqInfo.java

@@ -0,0 +1,65 @@
+package com.caimei365.order.utils.message;
+
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Range;
+
+
+@Data
+@Accessors(fluent = true)
+public class MqInfo {
+    /**
+     * 异步消息(可选):1是,0否
+     */
+    @Range(min = 0, max = 1)
+    private Integer async;
+
+    /**
+     * 1-18,0否,对应时间依次:1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h
+     */
+    @Range(min = 0, max = 18)
+    private Integer delay;
+
+    /**
+     * 消息主题
+     */
+    private String topic;
+
+    /**
+     * 消息标签(可选)
+     */
+    private String tag;
+
+    public Integer getAsync() {
+        return async;
+    }
+
+    public void setAsync(Integer async) {
+        this.async = async;
+    }
+
+    public Integer getDelay() {
+        return delay;
+    }
+
+    public void setDelay(Integer delay) {
+        this.delay = delay;
+    }
+
+    public String getTopic() {
+        return topic;
+    }
+
+    public void setTopic(String topic) {
+        this.topic = topic;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public void setTag(String tag) {
+        this.tag = tag;
+    }
+}

+ 53 - 0
src/main/java/com/caimei365/order/utils/message/SmsMessage.java

@@ -0,0 +1,53 @@
+package com.caimei365.order.utils.message;
+
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@Accessors(fluent = true)
+@NoArgsConstructor
+public class SmsMessage {
+    /**
+     * 短信类型:1通知短信,2验证码短信,3营销短信
+     */
+    @NotNull
+    private Integer type;
+    /**
+     *  手机号   接收的手机号;多个手机号使用英文逗号间隔,一次不要超过1000个;
+     */
+    @NotNull
+    private String mobile ;
+    /**
+     * 短信内容
+     */
+    @NotNull
+    private String smsMessageContent;
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getSmsMessageContent() {
+        return smsMessageContent;
+    }
+
+    public void setSmsMessageContent(String smsMessageContent) {
+        this.smsMessageContent = smsMessageContent;
+    }
+}

+ 266 - 0
src/main/java/com/caimei365/order/utils/message/WechatTemplateMessage.java

@@ -0,0 +1,266 @@
+package com.caimei365.order.utils.message;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Data
+@Accessors(fluent = true)
+@AllArgsConstructor
+@NoArgsConstructor
+public class WechatTemplateMessage {
+    /**
+     *  {
+     *            "touser":"OPENID",
+     *            "template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY",
+     *            "url":"http://weixin.qq.com/download",
+     *            "miniprogram":{
+     *              "appid":"xiaochengxuappid12345",
+     *              "pagepath":"index?foo=bar"
+     *            },
+     *            "client_msg_id":"MSG_000001",
+     *            "data":{
+     *                    "first": {
+     *                        "value":"恭喜你购买成功!",
+     *                        "color":"#173177"
+     *                    },
+     *                    "keyword1":{
+     *                        "value":"巧克力",
+     *                        "color":"#173177"
+     *                    },
+     *                    "keyword2": {
+     *                        "value":"39.8元",
+     *                        "color":"#173177"
+     *                    },
+     *                    "keyword3": {
+     *                        "value":"2014年9月22日",
+     *                        "color":"#173177"
+     *                    },
+     *                    "remark":{
+     *                        "value":"欢迎再次购买!",
+     *                        "color":"#173177"
+     *                    }
+     *            }
+     *        }
+     */
+
+    /**
+     * 推送内容抬头
+     */
+    @NotNull
+    private JSONObject first;
+    /**
+     * 推送内容
+     */
+    @NotNull
+    private List<JSONObject> keyWords;
+    /**
+     * 推送内容页尾
+     */
+    @NotNull
+    private JSONObject remark;
+    /**
+     * 模板消息的公众号
+     */
+    private String type;
+    /**
+     * 所需跳转到的小程序appid(该小程序 appid 必须与发模板消息的公众号是绑定关联关系,暂不支持小游戏)
+     */
+    private String appid;
+
+    /**
+     * 接收者openid
+     */
+    @NotNull
+    private String openId;
+    /**
+     * 模板ID
+     */
+    @NotNull
+    private String templateId;
+
+    private String templateType;
+    /**
+     * 模板跳转链接
+     */
+    private String url;
+    /**
+     * 所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar),要求该小程序已发布,暂不支持小游戏
+     */
+    private String pagePath;
+
+
+    /**
+     * 跳小程序所需数据,不需跳小程序可不用传该数据
+     */
+    private JSONObject miniProgram;
+    /**
+     * 模板数据
+     */
+    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;
+    }
+
+    public void setFirst(JSONObject first) {
+        this.first = first;
+    }
+
+    public List<JSONObject> getKeyWords() {
+        return keyWords;
+    }
+
+
+    public JSONObject getRemark() {
+        return remark;
+    }
+
+    public void setRemark(JSONObject remark) {
+        this.remark = remark;
+    }
+
+    public String getAppid() {
+        return appid;
+    }
+
+    public void setAppid(String appid) {
+        this.appid = appid;
+    }
+
+    public String getOpenId() {
+        return openId;
+    }
+
+    public void setOpenId(String openId) {
+        this.openId = openId;
+    }
+
+    public String getTemplateId() {
+        return templateId;
+    }
+
+    public void setTemplateId(String templateId) {
+        this.templateId = templateId;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getPagePath() {
+        return pagePath;
+    }
+
+    public void setPagePath(String pagePath) {
+        this.pagePath = pagePath;
+    }
+
+    public WechatTemplateMessage first(String title) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("value", title);
+        this.setFirst(jsonObject);
+        return this;
+    }
+
+    public WechatTemplateMessage keyWords(List<String> words) {
+        List<JSONObject> collect = new ArrayList<>();
+        words.forEach(w -> {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("value", w);
+            collect.add(jsonObject);
+        });
+        this.setKeyWords(collect);
+        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;
+    }
+
+    public WechatTemplateMessage remark(String r) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("value", r);
+        this.setRemark(jsonObject);
+        return this;
+    }
+
+    public JSONObject getMiniProgram() {
+        return miniProgram;
+    }
+
+    private void setMiniProgram(JSONObject miniProgram) {
+        this.miniProgram = miniProgram;
+    }
+
+    private JSONObject getData() {
+        return data;
+    }
+
+    private void setData(JSONObject data) {
+        this.data = data;
+    }
+
+    public String getJson() {
+        JSONObject json = new JSONObject();
+        json.put("touser", openId);
+        json.put("template_id", templateId);
+        json.put("url", url);
+
+        JSONObject miniProgram = new JSONObject();
+        miniProgram.put("appid", appid);
+        miniProgram.put("pagepath", pagePath);
+        json.put("miniprogram", miniProgram);
+
+        JSONObject data = new JSONObject();
+        data.put("first", first);
+        if (!keyWords.isEmpty()) {
+            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();
+    }
+}

+ 41 - 0
src/main/java/com/caimei365/order/utils/message/enums/MessageType.java

@@ -0,0 +1,41 @@
+package com.caimei365.order.utils.message.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.ToString;
+
+/**
+ * @author Administrator
+ */
+
+@ToString
+@AllArgsConstructor
+public enum MessageType {
+    /**
+     * 1.微信模板消息
+     * 2.站内消息
+     * 3.邮件
+     * 4.短信
+     */
+    WECHAT_TEMPLATE_MESSAGE(1, "微信模板消息"),
+    WEB_INSIDE_MESSAGE(2, "站内消息"),
+    EMAILS(3, "邮件"),
+    SYS_MESSAGE(4, "短信");
+    private Integer code;
+    private String description;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+}

+ 36 - 0
src/main/java/com/caimei365/order/utils/message/enums/SmsMessageType.java

@@ -0,0 +1,36 @@
+package com.caimei365.order.utils.message.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.ToString;
+
+@ToString
+@AllArgsConstructor
+public enum SmsMessageType {
+    /**
+     * 1通知短信
+     * 2验证码短信
+     * 3营销短信
+     */
+    NOTIFICATION_SMS(1, "通知短信"),
+    CHECK_CODE_SMS(2, "验证码短信"),
+    SALES_SMS(3, "营销短信");
+
+    private Integer code;
+    private String description;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+}

+ 9 - 0
src/main/resources/mapper/BaseMapper.xml

@@ -541,4 +541,13 @@
         WHERE ccp.couponId = #{couponId}
         limit 1
     </select>
+    <select id="getWechatHeheOpenId" resultType="string">
+        SELECT wu.heheOpenid
+        FROM wechat_user wu
+                 left join wx_union wxu on wxu.unionId = wu.unionId
+                 left join cm_hehe_user chu on chu.openId = wxu.heheOpenid
+        WHERE chu.userId = #{userId}
+        limit 1
+    </select>
+
 </mapper>

+ 4 - 1
src/main/resources/mapper/OrderRefundMapper.xml

@@ -160,9 +160,12 @@
     </select>
 
     <select id="findOrder" resultType="com.caimei365.order.model.vo.OrderVo">
-        select secondHandOrderFlag, status, co.orderId, co.userId, co.payTotalFee, cso.couponAmount, cso.couponClubId
+        select secondHandOrderFlag, co.status, co.orderId, co.userId, co.payTotalFee, cso.couponAmount, cso.couponClubId,co.orderType,u.`bindMobile`AS  mobile,cop.name as productName
         from cm_order co
                  left join cm_shop_order cso on co.orderId = cso.orderId
+                 LEFT JOIN `user` u ON u.`userID` = co.userId
+                 left join cm_order_product cop on cop.orderID=co.orderID
+
         where cso.shopOrderID = #{shopOrderId}
     </select>