| | |
| | | @Slf4j |
| | | public class SendWxMessage { |
| | | |
| | | private static String goodsOrderUrl = "pages/settlementDetails/settlementDetails?goodsOrderId="; |
| | | |
| | | private static String identityInfoUrl = "pages/mine/mine"; |
| | | 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; |
| | |
| | | * @param identityInfo |
| | | * @throws WxErrorException |
| | | */ |
| | | public void identityInfoMessage(String openid, IdentityInfo identityInfo) throws WxErrorException { |
| | | public void identityInfoMessage(String openid, IdentityInfo identityInfo){ |
| | | try{ |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); |
| | | log.info("微信小程序->微信消息通知 - 认证信息 -> accessToken:{}",accessToken); |
| | |
| | | //订阅消息模板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("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.getFomartDate(identityInfo.getAuditTime(),"yyyy-MM-dd HH:mm"))); |
| | | m.put("thing14", new TemplateData(identityInfo.getAuditRemark())); |
| | | wxMsgVO.setPage(identityInfoUrl); |
| | | // wxMsgVO.setPage(mineUrl); |
| | | wxMsgVO.setData(m); |
| | | log.info("微信小程序->微信消息通知 认证信息:{}", JSONObject.toJSONString(wxMsgVO)); |
| | | ResponseEntity<String> responseEntity = |
| | | restTemplate.postForEntity(url, wxMsgVO, String.class); |
| | | log.info("微信小程序->微信消息通知 认证信息:{}", 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 ) throws WxErrorException { |
| | | public void cancelMessage(List<String> openidList, Orders orders,Integer cancelType ){ |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | try{ |
| | | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); |
| | | log.info("微信小程序->微信消息通知 - 订单取消业务 -> accessToken:{}",accessToken); |
| | | //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取) |
| | |
| | | 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)?"发单方取消":"接单方取消")); |
| | | //TODO 跳转地址 |
| | | wxMsgVO.setPage(""); |
| | | String pageUrl = Constants.equalsInteger(orders.getType(),Constants.orderType.hyd.getKey())?orderDetailFreight: |
| | | Constants.equalsInteger(orders.getType(),Constants.orderType.scd.getKey())?orderDetailFood:orderDetail; |
| | | 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.info("微信小程序->微信消息通知 订单取消业务:{}", JSONObject.toJSONString(wxMsgVO)); |
| | | ResponseEntity<String> responseEntity = |
| | | restTemplate.postForEntity(url, wxMsgVO, String.class); |
| | | log.info("微信小程序->微信消息通知 订单取消业务:{}", JSONObject.toJSONString(responseEntity)); |
| | |
| | | }else{ |
| | | log.info("微信小程序->微信消息通知 订单取消业务:{}", "无人员信息"); |
| | | } |
| | | }catch (WxErrorException wxErrorException){ |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public void acceptMessage(String openid, Orders orders,String memberName,String memberPhone) throws 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.info("微信小程序->微信消息通知 - 接单业务 -> accessToken:{}",accessToken); |
| | | //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取) |
| | |
| | | m.put("thing1", new TemplateData(Constants.orderType.getName(orders.getType()))); |
| | | m.put("thing15", new TemplateData(memberName)); |
| | | m.put("phone_number8", new TemplateData(memberPhone)); |
| | | //TODO 跳转地址 |
| | | wxMsgVO.setPage(""); |
| | | String pageUrl = Constants.equalsInteger(orders.getType(),Constants.orderType.hyd.getKey())?orderDetailFreight: |
| | | Constants.equalsInteger(orders.getType(),Constants.orderType.scd.getKey())?orderDetailFood:orderDetail; |
| | | pageUrl.replace("{id}",orders.getId().toString()); |
| | | wxMsgVO.setPage(pageUrl); |
| | | wxMsgVO.setData(m); |
| | | //用户的openid(要发送给那个用户) |
| | | log.info("微信小程序->微信消息通知 接单通知:{}", JSONObject.toJSONString(wxMsgVO)); |
| | | ResponseEntity<String> responseEntity = |
| | | restTemplate.postForEntity(url, wxMsgVO, String.class); |
| | | log.info("微信小程序->微信消息通知 订单取消业务:{}", JSONObject.toJSONString(responseEntity)); |
| | | log.info("微信小程序->微信消息通知 接单通知:{}", JSONObject.toJSONString(responseEntity)); |
| | | }catch (WxErrorException wxErrorException){ |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public void orderUpdMessage(String openid, Orders orders) throws WxErrorException { |
| | | public void orderUpdMessage(String openid, Orders orders){ |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | try{ |
| | | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); |
| | | log.info("微信小程序->微信消息通知 - 订单变更通知 -> accessToken:{}",accessToken); |
| | | //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取) |
| | |
| | | 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"))); |
| | | //TODO 跳转地址 |
| | | wxMsgVO.setPage(""); |
| | | String pageUrl = Constants.equalsInteger(orders.getType(),Constants.orderType.hyd.getKey())?orderDetailFreight: |
| | | Constants.equalsInteger(orders.getType(),Constants.orderType.scd.getKey())?orderDetailFood:orderDetail; |
| | | pageUrl.replace("{id}",orders.getId().toString()); |
| | | wxMsgVO.setPage(pageUrl); |
| | | wxMsgVO.setData(m); |
| | | //用户的openid(要发送给那个用户) |
| | | log.info("微信小程序->微信消息通知 订单变更通知:{}", JSONObject.toJSONString(wxMsgVO)); |
| | | ResponseEntity<String> responseEntity = |
| | | restTemplate.postForEntity(url, wxMsgVO, String.class); |
| | | log.info("微信小程序->微信消息通知 订单变更通知:{}", JSONObject.toJSONString(responseEntity)); |
| | | }catch (WxErrorException wxErrorException){ |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public void withdrawalMessage(String openid, WithdrawalOrders withdrawalOrders) throws WxErrorException { |
| | | public void withdrawalMessage(String openid, WithdrawalOrders withdrawalOrders){ |
| | | try{ |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); |
| | | log.info("微信小程序->微信消息通知 - 提现成功通知 -> accessToken:{}",accessToken); |
| | |
| | | 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("打款成功,请注意查收")); |
| | | //TODO 跳转地址 |
| | | wxMsgVO.setPage(""); |
| | | wxMsgVO.setPage(balanceUrl); |
| | | wxMsgVO.setData(m); |
| | | //用户的openid(要发送给那个用户) |
| | | log.info("微信小程序->微信消息通知 提现成功通知:{}", JSONObject.toJSONString(wxMsgVO)); |
| | | ResponseEntity<String> responseEntity = |
| | | restTemplate.postForEntity(url, wxMsgVO, String.class); |
| | | log.info("微信小程序->微信消息通知 提现成功通知:{}", JSONObject.toJSONString(responseEntity)); |
| | | }catch (WxErrorException wxErrorException){ |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | public void revenueMessage(String openid, Orders orders) throws WxErrorException { |
| | | public void revenueMessage(String openid, Orders orders){ |
| | | try{ |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); |
| | | log.info("微信小程序->微信消息通知 - 订单收益通知 -> accessToken:{}",accessToken); |
| | |
| | | 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"))); |
| | | //TODO 跳转地址 |
| | | wxMsgVO.setPage(""); |
| | | wxMsgVO.setPage(balanceUrl); |
| | | wxMsgVO.setData(m); |
| | | log.info("微信小程序->微信消息通知 订单收益通知:{}", JSONObject.toJSONString(wxMsgVO)); |
| | | //用户的openid(要发送给那个用户) |
| | | ResponseEntity<String> responseEntity = |
| | | restTemplate.postForEntity(url, wxMsgVO, String.class); |
| | | log.info("微信小程序->微信消息通知 订单收益通知:{}", JSONObject.toJSONString(responseEntity)); |
| | | }catch (WxErrorException wxErrorException){ |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | public void autoDispatchMessage(String openid, Orders orders,BigDecimal distance) throws WxErrorException { |
| | | public void autoDispatchMessage(String openid, Orders orders,double distance){ |
| | | try{ |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | String accessToken = WxMiniConfig.wxMaService.getAccessToken(); |
| | | log.info("微信小程序->微信消息通知 - 服务派单 -> accessToken:{}",accessToken); |
| | |
| | | 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")+"开始")); |
| | | //TODO 跳转地址 |
| | | wxMsgVO.setPage(""); |
| | | String pageUrl = Constants.equalsInteger(orders.getType(),Constants.orderType.hyd.getKey())?orderDetailFreight: |
| | | Constants.equalsInteger(orders.getType(),Constants.orderType.scd.getKey())?orderDetailFood:orderDetail; |
| | | pageUrl.replace("{id}",orders.getId().toString()); |
| | | wxMsgVO.setPage(pageUrl); |
| | | wxMsgVO.setData(m); |
| | | log.info("微信小程序->微信消息通知 服务派单:{}", JSONObject.toJSONString(wxMsgVO)); |
| | | //用户的openid(要发送给那个用户) |
| | | ResponseEntity<String> responseEntity = |
| | | restTemplate.postForEntity(url, wxMsgVO, String.class); |
| | | log.info("微信小程序->微信消息通知 服务派单:{}", JSONObject.toJSONString(responseEntity)); |
| | | }catch (WxErrorException wxErrorException){ |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |