提交查询门店和积分返利

yy_dev
袁野 1 year ago
parent 3a0cd34915
commit 6e4cf3d490
  1. 11
      cweb/src/main/java/com/cweb/controller/TestController.java
  2. 5
      service/pom.xml
  3. 15
      service/src/main/java/com/hfkj/tts/HWYunSisService.java
  4. 65
      service/src/main/java/com/hfkj/unipush/UniPushService.java

@ -639,7 +639,11 @@ public class TestController {
public ResponseData ttsCustomDemo() { public ResponseData ttsCustomDemo() {
try { try {
return ResponseMsgUtil.success(HWYunSisService.ttsCustomDemo()); JSONObject object = new JSONObject();
object.put("storeName" , "YCY酒吧");
object.put("price" , "374.87");
return ResponseMsgUtil.success(HWYunSisService.ttsCustomDemo(object));
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
@ -661,11 +665,8 @@ public class TestController {
object.put("title" , "测试测试"); object.put("title" , "测试测试");
object.put("body" , "惠支付收款88.8元"); object.put("body" , "惠支付收款88.8元");
UniPushService.androidTemplate(object);
return ResponseMsgUtil.success("audience"); return ResponseMsgUtil.success(UniPushService.pushToSingleByCid(object));
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);

@ -383,6 +383,11 @@
<artifactId>restful-sdk</artifactId> <artifactId>restful-sdk</artifactId>
<version>1.0.0.13</version> <version>1.0.0.13</version>
</dependency> </dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.2.17</version>
</dependency>
<!--<dependency> <!--<dependency>
<groupId>com.huaweicloud</groupId> <groupId>com.huaweicloud</groupId>
<artifactId>esdk-obs-java</artifactId> <artifactId>esdk-obs-java</artifactId>

@ -1,7 +1,7 @@
package com.hfkj.tts; package com.hfkj.tts;
import com.hfkj.config.CommonSysConst; import com.alibaba.fastjson.JSONObject;
import com.huawei.sis.bean.AuthInfo; import com.huawei.sis.bean.AuthInfo;
import com.huawei.sis.bean.SisConfig; import com.huawei.sis.bean.SisConfig;
import com.huawei.sis.bean.SisConstant; import com.huawei.sis.bean.SisConstant;
@ -25,10 +25,10 @@ public class HWYunSisService {
// 项目id。登录管理控制台,鼠标移动到右上角的用户名上,在下拉列表中选择我的凭证,在项目列表中查看项目id。多项目时,展开“所属区域”,从“项目ID”列获取子项目ID。 // 项目id。登录管理控制台,鼠标移动到右上角的用户名上,在下拉列表中选择我的凭证,在项目列表中查看项目id。多项目时,展开“所属区域”,从“项目ID”列获取子项目ID。
private static String projectId = "075456f65780107f2f4ec013ff43b487"; private static String projectId = "075456f65780107f2f4ec013ff43b487";
// 待合成的文本 // 待合成的文本
private static String text = "惠支付收款 98.6元"; private static String text = "";
// 设置本地音频保存路径.可选择不保存到本地。需具体到文件,如D:/test.wav // 设置本地音频保存路径.可选择不保存到本地。需具体到文件,如D:/test.wav
private static String path = CommonSysConst.getSysConfig().getFile_url() + "/tts/test.wav"; // private static String path = CommonSysConst.getSysConfig().getFile_url()";
// private static String path = "/Volumes/work/开发/filesystem/test.mp3"; private static String path = "/Volumes/work/开发/filesystem/";
/** /**
@ -76,7 +76,7 @@ public class HWYunSisService {
/** /**
* 根据文本和api获取生成的音频数据 * 根据文本和api获取生成的音频数据
*/ */
public static Object ttsCustomDemo() { public static Object ttsCustomDemo(JSONObject object) {
try { try {
// 1. 初始化TtsCustomizationClient // 1. 初始化TtsCustomizationClient
// 定义authInfo,根据ak,sk,region, projectId. // 定义authInfo,根据ak,sk,region, projectId.
@ -86,6 +86,10 @@ public class HWYunSisService {
// 根据authInfo和config,构造TtsCustomizationClient // 根据authInfo和config,构造TtsCustomizationClient
TtsCustomizationClient tts = new TtsCustomizationClient(authInfo, config); TtsCustomizationClient tts = new TtsCustomizationClient(authInfo, config);
text = object.getString("storeName") + "收款" + object.getString("price") + "元";
path = path + object.getString("storeName") + "/" + object.getString("price") + ".mp3";
// 2. 配置请求 // 2. 配置请求
TtsCustomRequest request = new TtsCustomRequest(text); TtsCustomRequest request = new TtsCustomRequest(text);
// 设置参数,所有参数均可选,如果要保存合成音频文件,需要在request设置 // 设置参数,所有参数均可选,如果要保存合成音频文件,需要在request设置
@ -94,7 +98,6 @@ public class HWYunSisService {
// 3. 发送请求,获取响应。具体结果可通过response.getXX获取。 // 3. 发送请求,获取响应。具体结果可通过response.getXX获取。
TtsCustomResponse response = tts.getTtsResponse(request); TtsCustomResponse response = tts.getTtsResponse(request);
return JsonUtils.obj2Str(response, true); return JsonUtils.obj2Str(response, true);
} catch (SisException e) { } catch (SisException e) {

@ -6,13 +6,8 @@ import com.getui.push.v2.sdk.GtApiConfiguration;
import com.getui.push.v2.sdk.api.PushApi; import com.getui.push.v2.sdk.api.PushApi;
import com.getui.push.v2.sdk.common.ApiResult; import com.getui.push.v2.sdk.common.ApiResult;
import com.getui.push.v2.sdk.dto.req.Audience; import com.getui.push.v2.sdk.dto.req.Audience;
import com.getui.push.v2.sdk.dto.req.message.PushChannel;
import com.getui.push.v2.sdk.dto.req.message.PushDTO; import com.getui.push.v2.sdk.dto.req.message.PushDTO;
import com.getui.push.v2.sdk.dto.req.message.PushMessage; import com.getui.push.v2.sdk.dto.req.message.PushMessage;
import com.getui.push.v2.sdk.dto.req.message.android.AndroidDTO;
import com.getui.push.v2.sdk.dto.req.message.android.GTNotification;
import com.getui.push.v2.sdk.dto.req.message.android.ThirdNotification;
import com.getui.push.v2.sdk.dto.req.message.android.Ups;
import java.util.Map; import java.util.Map;
@ -31,9 +26,9 @@ public class UniPushService {
System.setProperty("http.maxConnections", "200"); System.setProperty("http.maxConnections", "200");
GtApiConfiguration apiConfiguration = new GtApiConfiguration(); GtApiConfiguration apiConfiguration = new GtApiConfiguration();
//填写应用配置 //填写应用配置
apiConfiguration.setAppId("JwvQulOIsq8kcFGey8fxo4"); apiConfiguration.setAppId("9LTgsDR5Y26MTWpN1uBhb1");
apiConfiguration.setAppKey("ERpW23I6gn8jo8NVcjP8H1"); apiConfiguration.setAppKey("GV7qmZoFh1AaqD4uDfH857");
apiConfiguration.setMasterSecret("t6HsZ4qwfK7YiBknIeaWy2"); apiConfiguration.setMasterSecret("JX9m0F92tZ5ciBtrfiJu93");
// 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
apiConfiguration.setDomain("https://restapi.getui.com/v2/"); apiConfiguration.setDomain("https://restapi.getui.com/v2/");
// 实例化ApiHelper对象,用于创建接口对象 // 实例化ApiHelper对象,用于创建接口对象
@ -51,73 +46,31 @@ public class UniPushService {
* @Param [uniPushModel] * @Param [uniPushModel]
* @Return void * @Return void
*/ */
public static void androidTemplate(JSONObject object) { public static String pushToSingleByCid(JSONObject object) {
PushApi pushApi = createClient(); PushApi pushApi = createClient();
/*设置接收人信息*/
//根据cid进行单推 //根据cid进行单推
PushDTO<Audience> pushDTO = new PushDTO<Audience>(); PushDTO<Audience> pushDTO = new PushDTO<>();
// 设置推送参数 // 设置推送参数
pushDTO.setRequestId(System.currentTimeMillis() + ""); pushDTO.setRequestId(System.currentTimeMillis() + "");
/**** 设置个推通道参数 *****/ // 设置个推通道参数
PushMessage pushMessage = new PushMessage(); PushMessage pushMessage = new PushMessage();
pushDTO.setPushMessage(pushMessage); pushDTO.setPushMessage(pushMessage);
GTNotification notification = new GTNotification(); pushMessage.setTransmission(object.getString("body"));
pushMessage.setNotification(notification);
notification.setTitle(object.getString("title"));
notification.setBody(object.getString("body"));
notification.setClickType("url");
notification.setUrl("https://www.getui.com");
/**** 设置个推通道参数,更多参数请查看文档或对象源码 *****/
/**** 设置厂商相关参数 ****/
PushChannel pushChannel = new PushChannel();
pushDTO.setPushChannel(pushChannel);
/*配置安卓厂商参数*/
AndroidDTO androidDTO = new AndroidDTO();
pushChannel.setAndroid(androidDTO);
Ups ups = new Ups();
androidDTO.setUps(ups);
ThirdNotification thirdNotification = new ThirdNotification();
ups.setNotification(thirdNotification);
thirdNotification.setTitle(object.getString("title"));
thirdNotification.setBody(object.getString("body"));
thirdNotification.setClickType("url");
thirdNotification.setUrl("https://www.getui.com");
// 两条消息的notify_id相同,新的消息会覆盖老的消息,取值范围:0-2147483647
// thirdNotification.setNotifyId("11177");
/*配置安卓厂商参数结束,更多参数请查看文档或对象源码*/
/*设置ios厂商参数*/
// IosDTO iosDTO = new IosDTO();
// pushChannel.setIos(iosDTO);
// // 相同的collapseId会覆盖之前的消息
// iosDTO.setApnsCollapseId("xxx");
// Aps aps = new Aps();
// iosDTO.setAps(aps);
// Alert alert = new Alert();
// aps.setAlert(alert);
// alert.setTitle("ios title");
// alert.setBody("ios body");
/*设置ios厂商参数结束,更多参数请查看文档或对象源码*/
/*设置接收人信息*/ /*设置接收人信息*/
Audience audience = new Audience(); Audience audience = new Audience();
pushDTO.setAudience(audience); pushDTO.setAudience(audience);
audience.addCid(object.getString("cid")); audience.addCid(object.getString("cid"));
/*设置接收人信息结束*/
/**** 设置厂商相关参数,更多参数请查看文档或对象源码 ****/
// 进行cid单推 // 进行cid单推
ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO); ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
System.out.println("===========================================" + apiResult);
if (apiResult.isSuccess()) { if (apiResult.isSuccess()) {
return apiResult.getData().toString();
// success // success
System.out.println(apiResult.getData());
} else { } else {
return "code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg();
// failed // failed
System.out.println("code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
} }
} }

Loading…
Cancel
Save