|  |  |  | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | 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 com.doumee.dao.business.model.Orders; | 
|---|
|  |  |  | import com.doumee.dao.business.model.WithdrawalOrders; | 
|---|
|  |  |  | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import me.chanjar.weixin.common.error.WxErrorException; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.http.ResponseEntity; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.web.client.RestTemplate; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | public class SendWxMessage { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static String goodsOrderUrl = "pages/settlementDetails/settlementDetails?goodsOrderId="; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static String mineUrl = "/pages/mine/mine"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static String orderDetail = "pages/order-details/order-details?id={id}";// 用工 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static String orderDetailFreight = "pages/freight-order/freight-order?id={id}";// 货运 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static String orderDetailFood = "pages/order-food/order-food?id={id}";// 订餐 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static String balanceUrl = "pages/balance-details/balance-details";// 余额明细 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public  void  bookingsCancel(String openid, String goodsOrderId, String accessToken, String bikeCode, Date startTime, Date endTime) throws WxErrorException { | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 信息认证 | 
|---|
|  |  |  | * @param openid | 
|---|
|  |  |  | * @param identityInfo | 
|---|
|  |  |  | * @throws WxErrorException | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public  void  identityInfoMessage(String openid, IdentityInfo identityInfo){ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | RestTemplate restTemplate = new RestTemplate(); | 
|---|
|  |  |  | 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_WZFfOzenDndgwNDIA0EvCiE6vqBnExpQ"); | 
|---|
|  |  |  | 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"))); | 
|---|
|  |  |  | m.put("thing14", new TemplateData(identityInfo.getAuditRemark())); | 
|---|
|  |  |  | wxMsgVO.setPage(mineUrl); | 
|---|
|  |  |  | wxMsgVO.setData(m); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 认证信息:{}", JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | String responseEntity  = HttpsUtil.postJson(url,JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | //                    ResponseEntity<String> responseEntity = | 
|---|
|  |  |  | //                            restTemplate.postForEntity(url, wxMsgVO, String.class); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 认证信息:{}", JSONObject.toJSONString(responseEntity)); | 
|---|
|  |  |  | }catch (WxErrorException wxErrorException){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 订单取消业务通知 | 
|---|
|  |  |  | * @param openidList | 
|---|
|  |  |  | * @param orders | 
|---|
|  |  |  | * @param cancelType 取消类型:0=平台取消;1=发单方取消;1=接单方取消 | 
|---|
|  |  |  | * @throws WxErrorException | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public  void  cancelMessage(List<String> openidList, Orders orders,Integer cancelType ){ | 
|---|
|  |  |  | RestTemplate restTemplate = new RestTemplate(); | 
|---|
|  |  |  | log.info("微信小程序->微信消息通知  -> accessToken:{}",accessToken); | 
|---|
|  |  |  | //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取) | 
|---|
|  |  |  | String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+WxMiniConfig.wxMaService.getAccessToken(); | 
|---|
|  |  |  | //拼接推送的模版 | 
|---|
|  |  |  | WxMsgVO wxMsgVo = new WxMsgVO(); | 
|---|
|  |  |  | //用户的openid(要发送给那个用户) | 
|---|
|  |  |  | wxMsgVo.setTouser(openid); | 
|---|
|  |  |  | //订阅消息模板id | 
|---|
|  |  |  | //        wxMsgVo.setTemplate_id(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.TIME_OUT_TEMPID).getCode()); | 
|---|
|  |  |  | Map<String, TemplateData> m = new HashMap<>(4); | 
|---|
|  |  |  | m.put("character_string1", new TemplateData(bikeCode)); | 
|---|
|  |  |  | //解锁时间 | 
|---|
|  |  |  | m.put("date3", new TemplateData(DateUtil.getFomartDate(startTime,"yyyy/MM/dd HH:mm"))); | 
|---|
|  |  |  | //上锁时间 | 
|---|
|  |  |  | m.put("date4", new TemplateData(DateUtil.getFomartDate(endTime,"yyyy/MM/dd HH:mm"))); | 
|---|
|  |  |  | //温馨提醒 | 
|---|
|  |  |  | m.put("thing5", new TemplateData("临时锁车已超过最大时长,已自动还车")); | 
|---|
|  |  |  | wxMsgVo.setPage(goodsOrderUrl + goodsOrderId); | 
|---|
|  |  |  | wxMsgVo.setData(m); | 
|---|
|  |  |  | ResponseEntity<String> responseEntity = | 
|---|
|  |  |  | restTemplate.postForEntity(url, wxMsgVo, String.class); | 
|---|
|  |  |  | log.info("微信小程序->微信消息通知 临时锁车超时:{}", JSONObject.toJSONString(responseEntity)); | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 - 订单取消业务  -> accessToken:{}",accessToken); | 
|---|
|  |  |  | //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取) | 
|---|
|  |  |  | String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken; | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 订单取消业务URL:{}", url); | 
|---|
|  |  |  | //拼接推送的模版 | 
|---|
|  |  |  | WxMsgVO wxMsgVO = new WxMsgVO(); | 
|---|
|  |  |  | //订阅消息模板id | 
|---|
|  |  |  | wxMsgVO.setTemplate_id("AA97cHjvlPiNO4viMkVe4JifCf9TD5b5Eb7s6El3VS8"); | 
|---|
|  |  |  | Map<String, TemplateData> m = new HashMap<>(5); | 
|---|
|  |  |  | m.put("character_string3", new TemplateData(orders.getCode())); | 
|---|
|  |  |  | m.put("thing2", new TemplateData(Constants.orderType.getName(orders.getType()))); | 
|---|
|  |  |  | m.put("thing1", new TemplateData(orders.getLocation() + (StringUtils.isNotBlank(orders.getLocationRemark())?orders.getLocationRemark():""))); | 
|---|
|  |  |  | m.put("date8", new TemplateData(DateUtil.getFomartDate(orders.getCancelTime(),"yyyy-MM-dd HH:mm:ss"))); | 
|---|
|  |  |  | m.put("thing6", new TemplateData(Constants.equalsInteger(cancelType,Constants.ZERO)?"平台取消":Constants.equalsInteger(cancelType,Constants.ONE)?"发单方取消":"接单方取消")); | 
|---|
|  |  |  | String pageUrl = Constants.equalsInteger(orders.getType(),Constants.orderType.hyd.getKey())?orderDetailFreight: | 
|---|
|  |  |  | Constants.equalsInteger(orders.getType(),Constants.orderType.scd.getKey())?orderDetailFood:orderDetail; | 
|---|
|  |  |  | pageUrl = pageUrl.replace("{id}",orders.getId().toString()); | 
|---|
|  |  |  | wxMsgVO.setPage(pageUrl); | 
|---|
|  |  |  | wxMsgVO.setData(m); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(openidList)){ | 
|---|
|  |  |  | for (String openid:openidList) { | 
|---|
|  |  |  | //用户的openid(要发送给那个用户) | 
|---|
|  |  |  | wxMsgVO.setTouser(openid); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 订单取消业务:{}", JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | String responseEntity  = HttpsUtil.postJson(url,JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | //                    ResponseEntity<String> responseEntity = | 
|---|
|  |  |  | //                            restTemplate.postForEntity(url, wxMsgVO, String.class); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 订单取消业务:{}", JSONObject.toJSONString(responseEntity)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 订单取消业务:{}", "无人员信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (WxErrorException wxErrorException){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 接单通知 | 
|---|
|  |  |  | * @param openid | 
|---|
|  |  |  | * @param orders | 
|---|
|  |  |  | * @param memberName | 
|---|
|  |  |  | * @param memberPhone | 
|---|
|  |  |  | * @throws WxErrorException | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public  void  acceptMessage(String openid, Orders orders,String memberName,String memberPhone){ | 
|---|
|  |  |  | RestTemplate restTemplate = new RestTemplate(); | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 - 接单业务  -> 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(); | 
|---|
|  |  |  | wxMsgVO.setTouser(openid); | 
|---|
|  |  |  | //订阅消息模板id | 
|---|
|  |  |  | wxMsgVO.setTemplate_id("oVjOBLcHxIlGzOMJsdInmgI5CHGXh-UTvMzQqfFOnIg"); | 
|---|
|  |  |  | Map<String, TemplateData> m = new HashMap<>(4); | 
|---|
|  |  |  | m.put("character_string3", new TemplateData(orders.getCode())); | 
|---|
|  |  |  | m.put("thing1", new TemplateData(Constants.orderType.getName(orders.getType()))); | 
|---|
|  |  |  | m.put("thing15", new TemplateData(memberName)); | 
|---|
|  |  |  | m.put("phone_number8", new TemplateData(memberPhone)); | 
|---|
|  |  |  | String pageUrl = Constants.equalsInteger(orders.getType(),Constants.orderType.hyd.getKey())?orderDetailFreight: | 
|---|
|  |  |  | Constants.equalsInteger(orders.getType(),Constants.orderType.scd.getKey())?orderDetailFood:orderDetail; | 
|---|
|  |  |  | pageUrl = pageUrl.replace("{id}",orders.getId().toString()); | 
|---|
|  |  |  | wxMsgVO.setPage(pageUrl); | 
|---|
|  |  |  | wxMsgVO.setData(m); | 
|---|
|  |  |  | //用户的openid(要发送给那个用户) | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 接单通知:{}", JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | String responseEntity  = HttpsUtil.postJson(url,JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | //                    ResponseEntity<String> responseEntity = | 
|---|
|  |  |  | //                            restTemplate.postForEntity(url, wxMsgVO, String.class); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 接单通知:{}", JSONObject.toJSONString(responseEntity)); | 
|---|
|  |  |  | }catch (WxErrorException wxErrorException){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public  void  orderUpdMessage(String openid, Orders orders){ | 
|---|
|  |  |  | RestTemplate restTemplate = new RestTemplate(); | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 - 订单变更通知  -> 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(); | 
|---|
|  |  |  | wxMsgVO.setTouser(openid); | 
|---|
|  |  |  | //订阅消息模板id | 
|---|
|  |  |  | wxMsgVO.setTemplate_id("3YSC7gouRlSjHXz4CrWOGFzPmGwEBtFj4snwdfMvKHk"); | 
|---|
|  |  |  | Map<String, TemplateData> m = new HashMap<>(3); | 
|---|
|  |  |  | m.put("character_string1", new TemplateData(orders.getCode())); | 
|---|
|  |  |  | m.put("thing3", new TemplateData("变更订单日期")); | 
|---|
|  |  |  | //变更后日期:07-23至07-25 | 
|---|
|  |  |  | m.put("thing5", new TemplateData("变更后日期:" +DateUtil.getFomartDate(orders.getStartDate(),"MM-dd") + "至" +DateUtil.getFomartDate(orders.getEndDate(),"MM-dd"))); | 
|---|
|  |  |  | String pageUrl = Constants.equalsInteger(orders.getType(),Constants.orderType.hyd.getKey())?orderDetailFreight: | 
|---|
|  |  |  | Constants.equalsInteger(orders.getType(),Constants.orderType.scd.getKey())?orderDetailFood:orderDetail; | 
|---|
|  |  |  | pageUrl = pageUrl.replace("{id}",orders.getId().toString()); | 
|---|
|  |  |  | wxMsgVO.setPage(pageUrl); | 
|---|
|  |  |  | wxMsgVO.setData(m); | 
|---|
|  |  |  | //用户的openid(要发送给那个用户) | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 订单变更通知:{}", JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | String responseEntity  = HttpsUtil.postJson(url,JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | //                    ResponseEntity<String> responseEntity = | 
|---|
|  |  |  | //                            restTemplate.postForEntity(url, wxMsgVO, String.class); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 订单变更通知:{}", JSONObject.toJSONString(responseEntity)); | 
|---|
|  |  |  | }catch (WxErrorException wxErrorException){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public  void  withdrawalMessage(String openid, WithdrawalOrders withdrawalOrders){ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | RestTemplate restTemplate = new RestTemplate(); | 
|---|
|  |  |  | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 - 提现成功通知  -> 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(); | 
|---|
|  |  |  | wxMsgVO.setTouser(openid); | 
|---|
|  |  |  | //订阅消息模板id | 
|---|
|  |  |  | wxMsgVO.setTemplate_id("fNJy4545hcrH83bP3a1vszs7XEKWjXMsrfr2XCNsql0"); | 
|---|
|  |  |  | Map<String, TemplateData> m = new HashMap<>(4); | 
|---|
|  |  |  | m.put("phrase2", new TemplateData("已打款")); | 
|---|
|  |  |  | m.put("amount1", new TemplateData((new BigDecimal(withdrawalOrders.getAmount().toString()).divide(new BigDecimal("100"))).toString())); | 
|---|
|  |  |  | m.put("time3", new TemplateData(DateUtil.getFomartDate(withdrawalOrders.getUpdateTime(),"yyyy.MM.dd HH.mm.ss"))); | 
|---|
|  |  |  | m.put("thing4", new TemplateData("打款成功,请注意查收")); | 
|---|
|  |  |  | wxMsgVO.setPage(balanceUrl); | 
|---|
|  |  |  | wxMsgVO.setData(m); | 
|---|
|  |  |  | //用户的openid(要发送给那个用户) | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 提现成功通知:{}", JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | String responseEntity  = HttpsUtil.postJson(url,JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | //                    ResponseEntity<String> responseEntity = | 
|---|
|  |  |  | //                            restTemplate.postForEntity(url, wxMsgVO, String.class); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 提现成功通知:{}", JSONObject.toJSONString(responseEntity)); | 
|---|
|  |  |  | }catch (WxErrorException wxErrorException){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public  void  revenueMessage(String openid, Orders orders){ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | RestTemplate restTemplate = new RestTemplate(); | 
|---|
|  |  |  | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 - 订单收益通知  -> 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(); | 
|---|
|  |  |  | wxMsgVO.setTouser(openid); | 
|---|
|  |  |  | //订阅消息模板id | 
|---|
|  |  |  | wxMsgVO.setTemplate_id("tDpYImlrdv-0d3euTrHbYZ1cEZvjVHTNlqHvV0tpLHg"); | 
|---|
|  |  |  | Map<String, TemplateData> m = new HashMap<>(5); | 
|---|
|  |  |  | m.put("character_string8", new TemplateData(orders.getCode())); | 
|---|
|  |  |  | m.put("phrase3", new TemplateData("已支付")); | 
|---|
|  |  |  | m.put("phrase4", new TemplateData("微信支付")); | 
|---|
|  |  |  | m.put("amount6", new TemplateData((new BigDecimal(orders.getReceiveAccount().toString()).divide(new BigDecimal("100")))+"元")); | 
|---|
|  |  |  | m.put("date7", new TemplateData(DateUtil.getFomartDate(new Date(),"yyyy-MM-dd HH:mm:ss"))); | 
|---|
|  |  |  | wxMsgVO.setPage(balanceUrl); | 
|---|
|  |  |  | wxMsgVO.setData(m); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 订单收益通知:{}", JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | //用户的openid(要发送给那个用户) | 
|---|
|  |  |  | String responseEntity  = HttpsUtil.postJson(url,JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | //                    ResponseEntity<String> responseEntity = | 
|---|
|  |  |  | //                            restTemplate.postForEntity(url, wxMsgVO, String.class); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 订单收益通知:{}", JSONObject.toJSONString(responseEntity)); | 
|---|
|  |  |  | }catch (WxErrorException wxErrorException){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public  void  autoDispatchMessage(String openid, Orders orders,double distance){ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | RestTemplate restTemplate = new RestTemplate(); | 
|---|
|  |  |  | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 - 服务派单  -> 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(); | 
|---|
|  |  |  | wxMsgVO.setTouser(openid); | 
|---|
|  |  |  | //订阅消息模板id | 
|---|
|  |  |  | wxMsgVO.setTemplate_id("1h6JYpQf-mDKV4tYQ6gGDONfx1awqtm3-y9W8vUraT4"); | 
|---|
|  |  |  | Map<String, TemplateData> m = new HashMap<>(5); | 
|---|
|  |  |  | m.put("thing2", new TemplateData(Constants.orderType.getName(orders.getType()))); | 
|---|
|  |  |  | m.put("thing3", new TemplateData(orders.getOrderContent())); | 
|---|
|  |  |  | m.put("phrase4", new TemplateData("此地距离您"+distance+"公里")); | 
|---|
|  |  |  | m.put("amount28", new TemplateData(orders.getEstimatedAccount().toString())); | 
|---|
|  |  |  | m.put("thing12", new TemplateData("工单将于"+DateUtil.getFomartDate(orders.getStartDate(),"MM-dd")+"开始")); | 
|---|
|  |  |  | String pageUrl = Constants.equalsInteger(orders.getType(),Constants.orderType.hyd.getKey())?orderDetailFreight: | 
|---|
|  |  |  | Constants.equalsInteger(orders.getType(),Constants.orderType.scd.getKey())?orderDetailFood:orderDetail; | 
|---|
|  |  |  | pageUrl = pageUrl.replace("{id}",orders.getId().toString()); | 
|---|
|  |  |  | wxMsgVO.setPage(pageUrl); | 
|---|
|  |  |  | wxMsgVO.setData(m); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 服务派单:{}", JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | //用户的openid(要发送给那个用户) | 
|---|
|  |  |  | String responseEntity  = HttpsUtil.postJson(url,JSONObject.toJSONString(wxMsgVO)); | 
|---|
|  |  |  | //                    ResponseEntity<String> responseEntity = | 
|---|
|  |  |  | //                            restTemplate.postForEntity(url, wxMsgVO, String.class); | 
|---|
|  |  |  | log.error("微信小程序->微信消息通知 服务派单:{}", JSONObject.toJSONString(responseEntity)); | 
|---|
|  |  |  | }catch (WxErrorException wxErrorException){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|