MrShi
5 小时以前 e50954f0708ecbbc672352102ae3b24279d40cc1
server/services/src/main/java/com/doumee/config/wx/SendWxMessage.java
@@ -5,7 +5,6 @@
import com.doumee.core.constants.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.HttpsUtil;
import com.doumee.dao.business.model.IdentityInfo;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,38 +28,5 @@
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    /**
     * 信息认证
     * @param openid
     * @param identityInfo
     * @throws WxErrorException
     */
    public  void  identityInfoMessage(String openid, IdentityInfo identityInfo){
        try{
            String accessToken = WxMiniConfig.wxMaService.getAccessToken();
            log.info("微信小程序->微信消息通知 - 认证信息  -> accessToken:{}",accessToken);
            //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取)
            String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken;
            //拼接推送的模版
            WxMsgVO wxMsgVO = new WxMsgVO();
            //用户的openid(要发送给那个用户)
            wxMsgVO.setTouser(openid);
            //订阅消息模板id
            wxMsgVO.setTemplate_id("VJho7-lf-4_WZFfOzenDnX6sOhYBJWwkLExVjBB563U");
            Map<String, TemplateData> m = new HashMap<>(4);
            m.put("thing2", new TemplateData(Constants.equalsInteger(identityInfo.getType(),Constants.ZERO)?"用工认证":Constants.equalsInteger(identityInfo.getType(),Constants.ONE)?"运货认证":"供餐认证"));
            m.put("phrase6", new TemplateData(Constants.equalsInteger(identityInfo.getAuditStatus(),Constants.TWO)?"通过":"未通过"));
            m.put("time12", new TemplateData(DateUtil.formatDate(identityInfo.getAuditTime(),"yyyy-MM-dd HH:mm")));
            wxMsgVO.setPage(mineUrl);
            wxMsgVO.setData(m);
            log.error("微信小程序->微信消息通知 认证信息:{}", JSONObject.toJSONString(wxMsgVO));
            String responseEntity  = HttpsUtil.postJson(url,JSONObject.toJSONString(wxMsgVO));
            log.error("微信小程序->微信消息通知 认证信息:{}", JSONObject.toJSONString(responseEntity));
        }catch (WxErrorException wxErrorException){
        }
    }
}