111
rk
2025-08-28 99e92a155a1b21a8386b482e7aab6fef649aeffa
server/services/src/main/java/com/doumee/config/wx/SendWxMessage.java
@@ -4,6 +4,7 @@
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;
@@ -69,14 +70,15 @@
            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.getFomartDate(identityInfo.getAuditTime(),"yyyy-MM-dd HH:mm")));
            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.setPage(mineUrl);
            wxMsgVO.setData(m);
            log.info("微信小程序->微信消息通知 认证信息:{}", JSONObject.toJSONString(wxMsgVO));
            ResponseEntity<String> responseEntity =
                    restTemplate.postForEntity(url, wxMsgVO, String.class);
            log.info("微信小程序->微信消息通知 认证信息:{}", JSONObject.toJSONString(responseEntity));
            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){
        }
@@ -95,9 +97,10 @@
        RestTemplate restTemplate = new RestTemplate();
        try{
            String accessToken = WxMiniConfig.wxMaService.getAccessToken();
            log.info("微信小程序->微信消息通知 - 订单取消业务  -> accessToken:{}",accessToken);
            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
@@ -110,20 +113,21 @@
            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.replace("{id}",orders.getId().toString());
            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.info("微信小程序->微信消息通知 订单取消业务:{}", JSONObject.toJSONString(wxMsgVO));
                    ResponseEntity<String> responseEntity =
                            restTemplate.postForEntity(url, wxMsgVO, String.class);
                    log.info("微信小程序->微信消息通知 订单取消业务:{}", JSONObject.toJSONString(responseEntity));
                    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.info("微信小程序->微信消息通知 订单取消业务:{}", "无人员信息");
                log.error("微信小程序->微信消息通知 订单取消业务:{}", "无人员信息");
            }
        }catch (WxErrorException wxErrorException){
@@ -144,7 +148,7 @@
        RestTemplate restTemplate = new RestTemplate();
        try{
            String accessToken = WxMiniConfig.wxMaService.getAccessToken();
            log.info("微信小程序->微信消息通知 - 接单业务  -> accessToken:{}",accessToken);
            log.error("微信小程序->微信消息通知 - 接单业务  -> accessToken:{}",accessToken);
            //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取)
            String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken;
            //拼接推送的模版
@@ -159,14 +163,15 @@
            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.replace("{id}",orders.getId().toString());
            pageUrl = 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.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){
        }
@@ -178,7 +183,7 @@
        RestTemplate restTemplate = new RestTemplate();
        try{
            String accessToken = WxMiniConfig.wxMaService.getAccessToken();
            log.info("微信小程序->微信消息通知 - 订单变更通知  -> accessToken:{}",accessToken);
            log.error("微信小程序->微信消息通知 - 订单变更通知  -> accessToken:{}",accessToken);
            //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取)
            String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken;
            //拼接推送的模版
@@ -190,17 +195,18 @@
            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")));
            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.replace("{id}",orders.getId().toString());
            pageUrl = 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.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){
        }
@@ -214,7 +220,7 @@
        try{
            RestTemplate restTemplate = new RestTemplate();
            String accessToken = WxMiniConfig.wxMaService.getAccessToken();
            log.info("微信小程序->微信消息通知 - 提现成功通知  -> accessToken:{}",accessToken);
            log.error("微信小程序->微信消息通知 - 提现成功通知  -> accessToken:{}",accessToken);
            //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取)
            String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken;
            //拼接推送的模版
@@ -230,10 +236,11 @@
            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));
            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){
        }
@@ -244,7 +251,7 @@
        try{
            RestTemplate restTemplate = new RestTemplate();
            String accessToken = WxMiniConfig.wxMaService.getAccessToken();
            log.info("微信小程序->微信消息通知 - 订单收益通知  -> accessToken:{}",accessToken);
            log.error("微信小程序->微信消息通知 - 订单收益通知  -> accessToken:{}",accessToken);
            //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取)
            String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken;
            //拼接推送的模版
@@ -260,11 +267,12 @@
            m.put("date7", new TemplateData(DateUtil.getFomartDate(new Date(),"yyyy-MM-dd HH:mm:ss")));
            wxMsgVO.setPage(balanceUrl);
            wxMsgVO.setData(m);
            log.info("微信小程序->微信消息通知 订单收益通知:{}", JSONObject.toJSONString(wxMsgVO));
            log.error("微信小程序->微信消息通知 订单收益通知:{}", JSONObject.toJSONString(wxMsgVO));
            //用户的openid(要发送给那个用户)
            ResponseEntity<String> responseEntity =
                    restTemplate.postForEntity(url, wxMsgVO, String.class);
            log.info("微信小程序->微信消息通知 订单收益通知:{}", JSONObject.toJSONString(responseEntity));
            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){
        }
@@ -275,7 +283,7 @@
        try{
            RestTemplate restTemplate = new RestTemplate();
            String accessToken = WxMiniConfig.wxMaService.getAccessToken();
            log.info("微信小程序->微信消息通知 - 服务派单  -> accessToken:{}",accessToken);
            log.error("微信小程序->微信消息通知 - 服务派单  -> accessToken:{}",accessToken);
            //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取)
            String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken;
            //拼接推送的模版
@@ -291,14 +299,15 @@
            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.replace("{id}",orders.getId().toString());
            pageUrl = pageUrl.replace("{id}",orders.getId().toString());
            wxMsgVO.setPage(pageUrl);
            wxMsgVO.setData(m);
            log.info("微信小程序->微信消息通知 服务派单:{}", JSONObject.toJSONString(wxMsgVO));
            log.error("微信小程序->微信消息通知 服务派单:{}", JSONObject.toJSONString(wxMsgVO));
            //用户的openid(要发送给那个用户)
            ResponseEntity<String> responseEntity =
                    restTemplate.postForEntity(url, wxMsgVO, String.class);
            log.info("微信小程序->微信消息通知 服务派单:{}", JSONObject.toJSONString(responseEntity));
            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){
        }