微信消息通知更新。

This commit is contained in:
但星霖 2023-09-28 09:55:21 +08:00
parent 5e0d35a989
commit b5a09dfd71
5 changed files with 67 additions and 13 deletions

View File

@ -4,6 +4,7 @@ import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult; import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.core.domain.entity.SysUser; import com.ghy.common.core.domain.entity.SysUser;
import com.ghy.common.enums.*; import com.ghy.common.enums.*;
import com.ghy.common.utils.WechatMsgUtils;
import com.ghy.customer.domain.Customer; import com.ghy.customer.domain.Customer;
import com.ghy.customer.domain.CustomerAddress; import com.ghy.customer.domain.CustomerAddress;
import com.ghy.customer.service.CustomerAddressService; import com.ghy.customer.service.CustomerAddressService;
@ -257,6 +258,19 @@ public class OrderController extends BaseController {
orderGoodsService.insertOrderGoods(orderGoods); orderGoodsService.insertOrderGoods(orderGoods);
}); });
// 推送公众号通知数据
try{
Worker assignWorker = workerService.selectById(orderMaster.getWorkerId());
// 消息组装
Map<String, Object> params = new HashMap<>();
params.put("character string1", orderMaster.getCode());
params.put("thing2", customer.getName());
params.put("data8", com.ghy.common.utils.DateUtils.parseDateToStr("yyyy年MM月dd日 HH:mm", new Date()));
params.put("thing4", "有新订单,请及时处理!");
WechatMsgUtils.sendWeChatMsg(WechatMsgUtils.getToken(), assignWorker.getOpenId(), WxMsgEnum.TEXT, params);
}catch (Exception e){
// 暂时不做任何操作
}
return AjaxResult.success("下单成功"); return AjaxResult.success("下单成功");
} }

View File

@ -145,6 +145,16 @@
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
</dependency> </dependency>
<!-- 微信所需jar -->
<dependency>
<groupId>org.wso2.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -1,5 +1,6 @@
package com.ghy.common.config; package com.ghy.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -7,27 +8,42 @@ import org.springframework.stereotype.Component;
* 七牛云配置 * 七牛云配置
* @author clunt * @author clunt
*/ */
@Data
@Component @Component
@ConfigurationProperties(prefix = "wx") @ConfigurationProperties(prefix = "wx")
public class WxConfig { public class WxConfig {
/**
* appId
*/
public String appId; public String appId;
/**
* secret
*/
public String secret; public String secret;
public String getAppId() { /**
return appId; * 授权形式
} * get Token grant_type
*/
private String grantTypeInToken = "client_credential";
public void setAppId(String appId) { /**
this.appId = appId; * 获取用户Token url
} * get Token url
*/
private String gerTokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=";
public String getSecret() { /**
return secret; * 发送消息api
} */
private String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
public void setSecret(String secret) {
this.secret = secret; /**
} * 模版相关
* 测试模版
*/
private String textTemplateId = null;
} }

View File

@ -12,7 +12,9 @@ public enum WxMsgEnum {
/** 新订单通知 */ /** 新订单通知 */
NEW_ORDER("","gFoPAYF4J6Y_O5OzzNUbvMxTrsAS7aUWffdNH42xhzM"), NEW_ORDER("","gFoPAYF4J6Y_O5OzzNUbvMxTrsAS7aUWffdNH42xhzM"),
/** 商城端消息通知 */ /** 商城端消息通知 */
CUSTOMER_ORDER("", "JtsGFPDjYhL2GbHfKxvTJaR_lLp8xLyw8VeR01Y0JHM") CUSTOMER_ORDER("", "JtsGFPDjYhL2GbHfKxvTJaR_lLp8xLyw8VeR01Y0JHM"),
/** 测试 **/
TEXT("", "JtsGFPDjYhL2GbHfKxvTJaR_lLp8xLyw8VeR01Y0JHM"),
; ;
/** 超时消息通知 */ /** 超时消息通知 */
// OVER_TIME("","8I5BnJMfwj-Z7udhNm9Z-kdjdg4__MV5ug1x8KKsbc0"), // OVER_TIME("","8I5BnJMfwj-Z7udhNm9Z-kdjdg4__MV5ug1x8KKsbc0"),

12
pom.xml
View File

@ -332,6 +332,18 @@
<version>${wxpay.version}</version> <version>${wxpay.version}</version>
</dependency> </dependency>
<!-- 微信所需jar -->
<dependency>
<groupId>org.wso2.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.1.wso2v1</version>
</dependency>
<dependency>
<groupId>org.wso2.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1.wso2v1</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>