|
|
@@ -17,14 +17,12 @@ import org.springblade.core.tenant.annotation.NonDS;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.purchase.sales.entity.Biding;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@NonDS
|
|
|
@ApiIgnore()
|
|
|
@@ -35,15 +33,18 @@ public class WechatClient implements IWechatClient {
|
|
|
//公众号的appId以及secret
|
|
|
private static final String appId = "wxf077390a6ec17f23";
|
|
|
private static final String appSecret = "50e84930675a0c06057d45a6d64ec548";
|
|
|
+ // 小程序的appId以及appSecret
|
|
|
+ private static final String APP_ID = "wx0a0feca24b695636";
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 发送模板消息
|
|
|
*
|
|
|
* @param unionId 接收此消息的openId
|
|
|
- * @param biding
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public String newsPush(String unionId, Biding biding) {
|
|
|
+ public String newsPush(String unionId, String contractNo, String keyword3, String keyword4, String keyword5) {
|
|
|
//获得token
|
|
|
Map<String,String> tokenMap = this.getToken();
|
|
|
//获得用户列表
|
|
|
@@ -65,17 +66,17 @@ public class WechatClient implements IWechatClient {
|
|
|
List<WxMpTemplateData> data = Arrays.asList(
|
|
|
new WxMpTemplateData("first", "[提醒]您有新的竞价消息,请尽快报价,过期作废"),
|
|
|
new WxMpTemplateData("keyword1", "发布"),
|
|
|
- new WxMpTemplateData("keyword2", biding.getContractNo()),
|
|
|
- new WxMpTemplateData("keyword3", biding.getDepartureHarbor() + "至" + biding.getObjectiveHarbor()),
|
|
|
- new WxMpTemplateData("keyword4", biding.getCargoInformation()),
|
|
|
- new WxMpTemplateData("keyword5", biding.getLoadingTime().toString()),
|
|
|
- new WxMpTemplateData("remark", biding.getRemark())
|
|
|
+ new WxMpTemplateData("keyword2", contractNo),
|
|
|
+ new WxMpTemplateData("keyword3", keyword3),
|
|
|
+ new WxMpTemplateData("keyword4", keyword4),
|
|
|
+ new WxMpTemplateData("keyword5", keyword5),
|
|
|
+ new WxMpTemplateData("remark", "感谢您的使用。")
|
|
|
);
|
|
|
//2,推送消息
|
|
|
WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
|
|
|
.toUser(openid)//要推送的用户openid
|
|
|
.templateId("Ad7zPbJWk4P44J2muNTDJCHwbxr5trgfPeHLq4oklRE")//模版id
|
|
|
- .url("https://www.baidu.com/")//点击模版消息要访问的网址
|
|
|
+ .miniProgram(new WxMpTemplateMessage.MiniProgram(APP_ID, "pages/index"))
|
|
|
.data(data)
|
|
|
.build();
|
|
|
try {
|
|
|
@@ -99,6 +100,7 @@ public class WechatClient implements IWechatClient {
|
|
|
try {
|
|
|
String response = HttpUtil.get(requestUrl);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
|
|
+ log.info("token======>"+jsonObject);
|
|
|
if (ObjectUtil.isEmpty(jsonObject.get("errcode"))){
|
|
|
String accessToken = String.valueOf(jsonObject.get("access_token"));
|
|
|
if (ObjectUtil.isEmpty(accessToken)){
|