公众号开发
This commit is contained in:
		@@ -5,6 +5,7 @@ import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.fasterxml.jackson.annotation.JsonFormat;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.apache.commons.lang3.builder.ToStringBuilder;
 | 
			
		||||
import org.apache.commons.lang3.builder.ToStringStyle;
 | 
			
		||||
import com.stdiet.common.annotation.Excel;
 | 
			
		||||
@@ -16,6 +17,7 @@ import com.stdiet.common.core.domain.BaseEntity;
 | 
			
		||||
 * @author wonder
 | 
			
		||||
 * @date 2020-09-24
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
public class SysOrder extends BaseEntity {
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
 | 
			
		||||
@@ -227,386 +229,9 @@ public class SysOrder extends BaseEntity {
 | 
			
		||||
    private List<SysOrderPause> orderPauseList;
 | 
			
		||||
    private Integer amountFlag;
 | 
			
		||||
 | 
			
		||||
    public Long getCusId() {
 | 
			
		||||
        return cusId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCusId(Long cusId) {
 | 
			
		||||
        this.cusId = cusId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @JsonFormat(pattern = "yyyy-MM-dd")
 | 
			
		||||
    public Date getStartTime() {
 | 
			
		||||
        return startTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BigDecimal getWeight() {
 | 
			
		||||
        return weight;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Date getPauseTime() {
 | 
			
		||||
        return pauseTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getStatus() {
 | 
			
		||||
        return status;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setStartTime(Date startTime) {
 | 
			
		||||
        this.startTime = startTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPauseTime(Date pauseTime) {
 | 
			
		||||
        this.pauseTime = pauseTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setStatus(String status) {
 | 
			
		||||
        this.status = status;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public void setWeight(BigDecimal weight) {
 | 
			
		||||
        this.weight = weight;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getServeTime() {
 | 
			
		||||
        return serveTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setServeTimeId(Long serveTimeId) {
 | 
			
		||||
        this.serveTimeId = serveTimeId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getServeTimeId() {
 | 
			
		||||
        return serveTimeId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setServeTime(String serveTime) {
 | 
			
		||||
        this.serveTime = serveTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setOperatorAssis(String operatorAssis) {
 | 
			
		||||
        this.operatorAssis = operatorAssis;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setOperatorAssisId(Long operatorAssisId) {
 | 
			
		||||
        this.operatorAssisId = operatorAssisId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getOperatorAssisId() {
 | 
			
		||||
        return operatorAssisId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getOperatorAssis() {
 | 
			
		||||
        return operatorAssis;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getReviewStatus() {
 | 
			
		||||
        return reviewStatus;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setReviewStatus(String reviewStatus) {
 | 
			
		||||
        this.reviewStatus = reviewStatus;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setOrderId(Long orderId) {
 | 
			
		||||
        this.orderId = orderId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getOrderId() {
 | 
			
		||||
        return orderId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCustomer(String customer) {
 | 
			
		||||
        this.customer = customer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getCustomer() {
 | 
			
		||||
        return customer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPhone(String phone) {
 | 
			
		||||
        this.phone = phone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getPhone() {
 | 
			
		||||
        return phone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAmount(BigDecimal amount) {
 | 
			
		||||
        this.amount = amount;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BigDecimal getAmount() {
 | 
			
		||||
        return amount;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPayTypeId(Long payTypeId) {
 | 
			
		||||
        this.payTypeId = payTypeId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getPayTypeId() {
 | 
			
		||||
        return payTypeId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPayType(String payType) {
 | 
			
		||||
        this.payType = payType;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getPayType() {
 | 
			
		||||
        return payType;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPreSaleId(Long preSaleId) {
 | 
			
		||||
        this.preSaleId = preSaleId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getPreSaleId() {
 | 
			
		||||
        return preSaleId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPreSale(String preSale) {
 | 
			
		||||
        this.preSale = preSale;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getPreSale() {
 | 
			
		||||
        return preSale;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAfterSaleId(Long afterSaleId) {
 | 
			
		||||
        this.afterSaleId = afterSaleId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getAfterSaleId() {
 | 
			
		||||
        return afterSaleId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAfterSale(String afterSale) {
 | 
			
		||||
        this.afterSale = afterSale;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getAfterSale() {
 | 
			
		||||
        return afterSale;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setNutritionistId(Long nutritionistId) {
 | 
			
		||||
        this.nutritionistId = nutritionistId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getNutritionistId() {
 | 
			
		||||
        return nutritionistId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setNutritionist(String nutritionist) {
 | 
			
		||||
        this.nutritionist = nutritionist;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getNutritionist() {
 | 
			
		||||
        return nutritionist;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setNutriAssisId(Long nutriAssisId) {
 | 
			
		||||
        this.nutriAssisId = nutriAssisId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getNutriAssisId() {
 | 
			
		||||
        return nutriAssisId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setNutriAssis(String nutriAssis) {
 | 
			
		||||
        this.nutriAssis = nutriAssis;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getNutriAssis() {
 | 
			
		||||
        return nutriAssis;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAccountId(Long accountId) {
 | 
			
		||||
        this.accountId = accountId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getAccountId() {
 | 
			
		||||
        return accountId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAccount(String account) {
 | 
			
		||||
        this.account = account;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getAccount() {
 | 
			
		||||
        return account;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPlannerId(Long plannerId) {
 | 
			
		||||
        this.plannerId = plannerId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getPlannerId() {
 | 
			
		||||
        return plannerId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPlanner(String planner) {
 | 
			
		||||
        this.planner = planner;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getPlanner() {
 | 
			
		||||
        return planner;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPlannerAssisId(Long plannerAssisId) {
 | 
			
		||||
        this.plannerAssisId = plannerAssisId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getPlannerAssisId() {
 | 
			
		||||
        return plannerAssisId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPlannerAssis(String plannerAssis) {
 | 
			
		||||
        this.plannerAssis = plannerAssis;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getPlannerAssis() {
 | 
			
		||||
        return plannerAssis;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setOperatorId(Long operatorId) {
 | 
			
		||||
        this.operatorId = operatorId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getOperatorId() {
 | 
			
		||||
        return operatorId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setOperator(String operator) {
 | 
			
		||||
        this.operator = operator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getOperator() {
 | 
			
		||||
        return operator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setRecommender(String recommender) {
 | 
			
		||||
        this.recommender = recommender;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getRecommender() {
 | 
			
		||||
        return recommender;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setOrderTime(Date orderTime) {
 | 
			
		||||
        this.orderTime = orderTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Date getOrderTime() {
 | 
			
		||||
        return orderTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getGiveServeDay() {
 | 
			
		||||
        return giveServeDay;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setGiveServeDay(Integer giveServeDay) {
 | 
			
		||||
        this.giveServeDay = giveServeDay;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<SysOrderPause> getOrderPauseList() {
 | 
			
		||||
        return orderPauseList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setOrderPauseList(List<SysOrderPause> orderPauseList) {
 | 
			
		||||
        this.orderPauseList = orderPauseList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getConditioningProjectId() {
 | 
			
		||||
        return conditioningProjectId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setConditioningProjectId(Integer conditioningProjectId) {
 | 
			
		||||
        this.conditioningProjectId = conditioningProjectId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Date getServerEndTime() {
 | 
			
		||||
        return serverEndTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setServerEndTime(Date serverEndTime) {
 | 
			
		||||
        this.serverEndTime = serverEndTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Date getBecomeFanTime() {
 | 
			
		||||
        return becomeFanTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBecomeFanTime(Date becomeFanTime) {
 | 
			
		||||
        this.becomeFanTime = becomeFanTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getServerDay() {
 | 
			
		||||
        return serverDay;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setServerDay(Integer serverDay) {
 | 
			
		||||
        this.serverDay = serverDay;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
 | 
			
		||||
                .append("orderId", getOrderId())
 | 
			
		||||
                .append("customer", getCustomer())
 | 
			
		||||
                .append("phone", getPhone())
 | 
			
		||||
                .append("amount", getAmount())
 | 
			
		||||
                .append("payTypeId", getPayTypeId())
 | 
			
		||||
                .append("payType", getPayType())
 | 
			
		||||
                .append("preSaleId", getPreSaleId())
 | 
			
		||||
                .append("createBy", getCreateBy())
 | 
			
		||||
                .append("preSale", getPreSale())
 | 
			
		||||
                .append("createTime", getCreateTime())
 | 
			
		||||
                .append("afterSaleId", getAfterSaleId())
 | 
			
		||||
                .append("updateBy", getUpdateBy())
 | 
			
		||||
                .append("afterSale", getAfterSale())
 | 
			
		||||
                .append("updateTime", getUpdateTime())
 | 
			
		||||
                .append("nutritionistId", getNutritionistId())
 | 
			
		||||
                .append("remark", getRemark())
 | 
			
		||||
                .append("nutritionist", getNutritionist())
 | 
			
		||||
                .append("nutriAssisId", getNutriAssisId())
 | 
			
		||||
                .append("nutriAssis", getNutriAssis())
 | 
			
		||||
                .append("accountId", getAccountId())
 | 
			
		||||
                .append("account", getAccount())
 | 
			
		||||
                .append("plannerId", getPlannerId())
 | 
			
		||||
                .append("planner", getPlanner())
 | 
			
		||||
                .append("plannerAssisId", getPlannerAssisId())
 | 
			
		||||
                .append("plannerAssis", getPlannerAssis())
 | 
			
		||||
                .append("operatorId", getOperatorId())
 | 
			
		||||
                .append("operator", getOperator())
 | 
			
		||||
                .append("operatorAssisId", getOperatorAssisId())
 | 
			
		||||
                .append("operatorAssis", getOperatorAssis())
 | 
			
		||||
                .append("recommender", getRecommender())
 | 
			
		||||
                .append("orderTime", getOrderTime())
 | 
			
		||||
                .append("serveTimeId", getServeTimeId())
 | 
			
		||||
                .append("serveTime", getServeTime())
 | 
			
		||||
                .append("reviewStatus", getReviewStatus())
 | 
			
		||||
                .append("status", getStatus())
 | 
			
		||||
                .append("startTime", getStartTime())
 | 
			
		||||
                .append("pauseTime", getPauseTime())
 | 
			
		||||
                .append("weight", getWeight())
 | 
			
		||||
                .toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getConditioningProject() {
 | 
			
		||||
        return conditioningProject;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setConditioningProject(String conditioningProject) {
 | 
			
		||||
        this.conditioningProject = conditioningProject;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getAmountFlag() {
 | 
			
		||||
        return amountFlag;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAmountFlag(Integer amountFlag) {
 | 
			
		||||
        this.amountFlag = amountFlag;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,39 @@
 | 
			
		||||
package com.stdiet.custom.domain;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@XStreamAlias("xml")
 | 
			
		||||
public class WxXmlData implements Serializable {
 | 
			
		||||
    @XStreamAlias("ToUserName")
 | 
			
		||||
    private String toUserName;
 | 
			
		||||
    @XStreamAlias("FromUserName")
 | 
			
		||||
    private String fromUserName;
 | 
			
		||||
    @XStreamAlias("CreateTime")
 | 
			
		||||
    private Long createTime;
 | 
			
		||||
    @XStreamAlias("MsgType")
 | 
			
		||||
    private String msgType;
 | 
			
		||||
    @XStreamAlias("Content")
 | 
			
		||||
    private String content;
 | 
			
		||||
    @XStreamAlias("MsgId")
 | 
			
		||||
    private String msgId;
 | 
			
		||||
    //
 | 
			
		||||
    @XStreamAlias("Title")
 | 
			
		||||
    private String title;
 | 
			
		||||
    @XStreamAlias("Description")
 | 
			
		||||
    private String description;
 | 
			
		||||
    @XStreamAlias("Url")
 | 
			
		||||
    private String url;
 | 
			
		||||
    /**
 | 
			
		||||
     * 订阅或者取消订阅的事件
 | 
			
		||||
     */
 | 
			
		||||
    @XStreamAlias("Event")
 | 
			
		||||
    private String event;
 | 
			
		||||
    @XStreamAlias("EventKey")
 | 
			
		||||
    private String eventkey;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,9 @@
 | 
			
		||||
package com.stdiet.custom.service;
 | 
			
		||||
 | 
			
		||||
import com.stdiet.custom.domain.WxXmlData;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
 | 
			
		||||
public interface ISysWxService {
 | 
			
		||||
    /**
 | 
			
		||||
     * 微信token验证
 | 
			
		||||
@@ -10,4 +14,6 @@ public interface ISysWxService {
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public String wxCheckAuth(String signature, String timestamp, String nonce, String echostr);
 | 
			
		||||
 | 
			
		||||
    public String autoResponse(HttpServletRequest request);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,17 @@
 | 
			
		||||
package com.stdiet.custom.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.stdiet.common.utils.StringUtils;
 | 
			
		||||
import com.stdiet.custom.domain.WxXmlData;
 | 
			
		||||
import com.stdiet.custom.service.ISysWxService;
 | 
			
		||||
import com.stdiet.custom.utils.WechatMessageUtil;
 | 
			
		||||
import com.stdiet.custom.utils.WxTokenUtils;
 | 
			
		||||
import com.thoughtworks.xstream.XStream;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
 | 
			
		||||
@Service
 | 
			
		||||
@Transactional
 | 
			
		||||
public class SysWxServiceImpl implements ISysWxService {
 | 
			
		||||
@@ -13,4 +20,39 @@ public class SysWxServiceImpl implements ISysWxService {
 | 
			
		||||
    public String wxCheckAuth(String signature, String timestamp, String nonce, String echostr) {
 | 
			
		||||
        return WxTokenUtils.checkSignature(signature, timestamp, nonce) ? echostr : null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String autoResponse(HttpServletRequest request) {
 | 
			
		||||
        try {
 | 
			
		||||
            WxXmlData wxData = WxTokenUtils.resolveXmlData(request.getInputStream());
 | 
			
		||||
 | 
			
		||||
            WxXmlData resultXmlData = new WxXmlData();
 | 
			
		||||
            resultXmlData.setToUserName(wxData.getFromUserName());  //收到的消息是谁发来的再发给谁
 | 
			
		||||
            resultXmlData.setFromUserName(wxData.getToUserName());  //
 | 
			
		||||
            if (!StringUtils.isEmpty(wxData.getEvent())) {
 | 
			
		||||
                if (wxData.getEvent().equals(WechatMessageUtil.MESSAGE_EVENT_SUBSCRIBE)) {
 | 
			
		||||
                    resultXmlData.setMsgType("text");
 | 
			
		||||
                    resultXmlData.setCreateTime(System.currentTimeMillis());
 | 
			
		||||
                    resultXmlData.setContent("欢迎来到胜唐体控,这是一条测试用的关注信息");
 | 
			
		||||
                } else if (wxData.getEvent().equals(WechatMessageUtil.MESSAGE_EVENT_UNSUBSCRIBE)) {
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
            } else if (wxData.getContent().equalsIgnoreCase("vip")) {
 | 
			
		||||
                resultXmlData.setMsgType("text");
 | 
			
		||||
                resultXmlData.setCreateTime(System.currentTimeMillis());
 | 
			
		||||
                resultXmlData.setContent("<a href=\"https://my.openwrite.cn/code/generate?blogId=18931-1576559666626-322\">点击该链接,获取博客解锁验证码</a>");
 | 
			
		||||
            } else {
 | 
			
		||||
                resultXmlData.setMsgType("text");
 | 
			
		||||
                resultXmlData.setCreateTime(System.currentTimeMillis());
 | 
			
		||||
                resultXmlData.setContent("公众号正在开发中。后期请多多关注!");
 | 
			
		||||
            }
 | 
			
		||||
            XStream xstream = new XStream();
 | 
			
		||||
            xstream.processAnnotations(WxXmlData.class);
 | 
			
		||||
            xstream.setClassLoader(WxXmlData.class.getClassLoader());
 | 
			
		||||
            return xstream.toXML(resultXmlData);  //XStream的方法,直接将对象转换成 xml数据
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,63 @@
 | 
			
		||||
package com.stdiet.custom.utils;
 | 
			
		||||
 | 
			
		||||
public class WechatMessageUtil {
 | 
			
		||||
    // 各种消息类型,除了扫带二维码事件
 | 
			
		||||
    /**
 | 
			
		||||
     * 文本消息
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_TEXT = "text";
 | 
			
		||||
    /**
 | 
			
		||||
     * 图片消息
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAtGE_IMAGE = "image";
 | 
			
		||||
    /**
 | 
			
		||||
     * 图文消息
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_NEWS = "news";
 | 
			
		||||
    /**
 | 
			
		||||
     * 语音消息
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_VOICE = "voice";
 | 
			
		||||
    /**
 | 
			
		||||
     * 视频消息
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_VIDEO = "video";
 | 
			
		||||
    /**
 | 
			
		||||
     * 小视频消息
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_SHORTVIDEO = "shortvideo";
 | 
			
		||||
    /**
 | 
			
		||||
     * 地理位置消息
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_LOCATION = "location";
 | 
			
		||||
    /**
 | 
			
		||||
     * 链接消息
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_LINK = "link";
 | 
			
		||||
    /**
 | 
			
		||||
     * 事件推送消息
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_EVENT = "event";
 | 
			
		||||
    /**
 | 
			
		||||
     * 事件推送消息中,事件类型,subscribe(订阅)
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_EVENT_SUBSCRIBE = "subscribe";
 | 
			
		||||
    /**
 | 
			
		||||
     * 事件推送消息中,事件类型,unsubscribe(取消订阅)
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_EVENT_UNSUBSCRIBE = "unsubscribe";
 | 
			
		||||
    /**
 | 
			
		||||
     * 事件推送消息中,上报地理位置事件
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_EVENT_LOCATION_UP = "LOCATION";
 | 
			
		||||
    /**
 | 
			
		||||
     * 事件推送消息中,自定义菜单事件,点击菜单拉取消息时的事件推送
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_EVENT_CLICK = "CLICK";
 | 
			
		||||
    /**
 | 
			
		||||
     * 事件推送消息中,自定义菜单事件,点击菜单跳转链接时的事件推送
 | 
			
		||||
     */
 | 
			
		||||
    public static final String MESSAGE_EVENT_VIEW = "VIEW";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,11 @@
 | 
			
		||||
package com.stdiet.custom.utils;
 | 
			
		||||
 | 
			
		||||
import com.stdiet.custom.domain.WxXmlData;
 | 
			
		||||
import com.thoughtworks.xstream.XStream;
 | 
			
		||||
import org.apache.commons.io.IOUtils;
 | 
			
		||||
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.nio.charset.StandardCharsets;
 | 
			
		||||
import java.security.MessageDigest;
 | 
			
		||||
import java.security.NoSuchAlgorithmException;
 | 
			
		||||
 | 
			
		||||
@@ -81,4 +87,21 @@ public class WxTokenUtils {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static WxXmlData resolveXmlData(InputStream in) {
 | 
			
		||||
        WxXmlData wxXmlData = null;
 | 
			
		||||
        try {
 | 
			
		||||
            String xmlData = IOUtils.toString(in, StandardCharsets.UTF_8.name());
 | 
			
		||||
            XStream xstream = new XStream();
 | 
			
		||||
            //这个必须要加 不然无法转换成WxXmlData对象
 | 
			
		||||
            xstream.setClassLoader(WxXmlData.class.getClassLoader());
 | 
			
		||||
            xstream.processAnnotations(WxXmlData.class);
 | 
			
		||||
            xstream.alias("xml", WxXmlData.class);
 | 
			
		||||
            wxXmlData = (WxXmlData) xstream.fromXML(xmlData);
 | 
			
		||||
//            log.info("【wxXmlData: {}】 ", wxXmlData);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
//            log.error("【error】{}", e.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
        return wxXmlData;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user