提交查询门店和积分返利

yy_dev
袁野 1 year ago
parent 6b02c081a3
commit 7bb5caaf5d
  1. 92
      cweb/src/main/java/com/cweb/controller/BsStoreCidController.java
  2. 14
      cweb/src/main/java/com/cweb/controller/TestController.java
  3. 24
      cweb/src/main/resources/dev/logback.xml
  4. 5
      service/pom.xml
  5. 55
      service/src/main/java/com/hfkj/service/BsStoreCidService.java
  6. 96
      service/src/main/java/com/hfkj/service/impl/BsStoreCidServiceImpl.java
  7. 36
      service/src/main/java/com/hfkj/tts/HWYunSisService.java
  8. 12
      service/src/main/java/com/hfkj/unipush/UniPushService.java
  9. 3
      service/src/main/resources/dev/commonConfig.properties

@ -0,0 +1,92 @@
package com.cweb.controller;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsStore;
import com.hfkj.entity.BsStoreCid;
import com.hfkj.model.ResponseData;
import com.hfkj.service.BsStoreCidService;
import com.hfkj.service.BsStoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @author sum1dream
*/
@Controller
@RequestMapping(value = "/storeCid")
@Api(value = "门店CID")
public class BsStoreCidController {
private static Logger log = LoggerFactory.getLogger(BsStoreCidController.class);
@Resource
private BsStoreCidService bsStoreCidService;
@Resource
private BsStoreService bsStoreService;
@RequestMapping(value="/connectStoreCid",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "连接门店和CID")
public ResponseData connectStoreCid(@RequestBody BsStoreCid storeCid) {
try {
if (storeCid == null
|| storeCid.getCid() == null
|| storeCid.getStoreId() == null
) {
log.error("configStore error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
BsStore store = bsStoreService.getStoreById(storeCid.getStoreId());
if (store == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前门店不存在!");
}
Map<String , Object> map = new HashMap<>();
map.put("storeId" , storeCid.getStoreId());
BsStoreCid bsStoreCid = bsStoreCidService.findByMap(map);
if (bsStoreCid == null) {
bsStoreCid = new BsStoreCid();
bsStoreCid.setCid(storeCid.getCid());
bsStoreCid.setStoreId(store.getId());
bsStoreCid.setStoreNo(store.getStoreNo());
bsStoreCid.setStoreName(store.getName());
bsStoreCid.setCreateTime(new Date());
bsStoreCid.setUpdateTime(new Date());
bsStoreCidService.insertStoreCid(bsStoreCid);
} else {
bsStoreCid.setCid(storeCid.getCid());
bsStoreCid.setUpdateTime(new Date());
bsStoreCidService.editStoreCid(bsStoreCid);
}
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -28,7 +28,6 @@ import com.hfkj.sysenum.PlatformTypeEnum;
import com.hfkj.sysenum.StoreCreateTypeEnum;
import com.hfkj.sysenum.StoreStatusEnum;
import com.hfkj.tts.HWYunSisService;
import com.hfkj.unipush.UniPushService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils;
@ -96,6 +95,9 @@ public class TestController {
@Resource
private LaKaLaWalletService laKaLaWalletService;
@Resource
private BsStoreCidService bsStoreCidService;
@RequestMapping(value="/refreshMerStatus",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "refreshMerStatus")
@ -640,7 +642,6 @@ public class TestController {
try {
JSONObject object = new JSONObject();
object.put("storeName" , "YCY酒吧");
object.put("price" , "374.87");
return ResponseMsgUtil.success(HWYunSisService.ttsCustomDemo(object));
@ -661,12 +662,11 @@ public class TestController {
JSONObject object = new JSONObject();
object.put("cid" , cid);
object.put("title" , "测试测试");
object.put("body" , "惠支付收款88.8元");
object.put("storeId" , 136);
object.put("price" , "283.82");
bsStoreCidService.storePush(object);
return ResponseMsgUtil.success(UniPushService.pushToSingleByCid(object));
return ResponseMsgUtil.success("成功");
} catch (Exception e) {
log.error(e.getMessage(), e);

@ -112,4 +112,28 @@
<appender-ref ref="hsglog" />
</logger>
<appender name="PushLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/PushLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/PushLog/PushLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="com.hfkj.tts.HWYunSisService" level="INFO">
<appender-ref ref="PushLog" />
</logger>
<logger name="com.hfkj.unipush.UniPushService" level="INFO">
<appender-ref ref="PushLog" />
</logger>
</configuration>

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

@ -0,0 +1,55 @@
package com.hfkj.service;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.entity.BsStoreCid;
import java.util.Map;
/**
* @author sum1dream
*/
public interface BsStoreCidService {
/**
* @Author Sum1Dream
* @Name insertStoreCid
* @Description // 新增门店cid内容
* @Date 15:14 2023/6/14
* @Param [storeCid]
* @Return void
*/
void insertStoreCid(BsStoreCid storeCid);
/**
* @Author Sum1Dream
* @Name editStoreCid
* @Description // 编辑门店cid内容
* @Date 15:15 2023/6/14
* @Param [storeCid]
* @Return void
*/
void editStoreCid(BsStoreCid storeCid);
/**
* @Author Sum1Dream
* @Name findByMap
* @Description // 查询门店CID内容
* @Date 15:40 2023/6/14
* @Param [map]
* @Return com.hfkj.entity.BsStoreCid
*/
BsStoreCid findByMap(Map<String , Object> map);
/**
* @Author Sum1Dream
* @Name storePush
* @Description // 门店语音推送
* @Date 16:11 2023/6/14
* @Param [object]
* @Return void
*/
void storePush(JSONObject object);
}

@ -0,0 +1,96 @@
package com.hfkj.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.dao.BsStoreCidMapper;
import com.hfkj.entity.BsStoreCid;
import com.hfkj.entity.BsStoreCidExample;
import com.hfkj.service.BsStoreCidService;
import com.hfkj.tts.HWYunSisService;
import com.hfkj.unipush.UniPushService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author sum1dream
*/
@Service("bsStoreCidService")
public class BsStoreCidServiceImpl implements BsStoreCidService {
@Resource
private BsStoreCidMapper bsStoreCidMapper;
@Override
public void insertStoreCid(BsStoreCid storeCid) {
bsStoreCidMapper.insert(storeCid);
}
@Override
public void editStoreCid(BsStoreCid storeCid) {
bsStoreCidMapper.updateByPrimaryKey(storeCid);
}
@Override
public BsStoreCid findByMap(Map<String, Object> map) {
BsStoreCidExample example = new BsStoreCidExample();
BsStoreCidExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map, "storeId") != null) {
criteria.andStoreIdEqualTo(MapUtils.getLong(map, "storeId"));
}
if (MapUtils.getLong(map, "storeNo") != null) {
criteria.andStoreNoEqualTo(MapUtils.getLong(map, "storeNo"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "storeName"))) {
criteria.andStoreNameLike("%"+MapUtils.getString(map, "storeName")+"%");
}
List<BsStoreCid> list = bsStoreCidMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override
public void storePush(JSONObject object) {
if (object == null ||
object.getBigDecimal("price") == null ||
object.getLong("storeId") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
Map<String, Object> map = new HashMap<>();
map.put("storeId", object.getLong("storeId"));
BsStoreCid bsStoreCid = findByMap(map);
if (bsStoreCid == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "不存在推送关系");
}
// 获取语音播报地址
String auditPath = HWYunSisService.ttsCustomDemo(object);
if (auditPath == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "生成语音失败");
}
object.put("cid", bsStoreCid.getCid());
object.put("body", auditPath);
UniPushService.pushToSingleByCid(object);
}
}

@ -1,7 +1,9 @@
package com.hfkj.tts;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.config.CommonSysConst;
import com.huawei.sis.bean.AuthInfo;
import com.huawei.sis.bean.SisConfig;
import com.huawei.sis.bean.SisConstant;
@ -9,11 +11,16 @@ import com.huawei.sis.bean.request.TtsCustomRequest;
import com.huawei.sis.bean.response.TtsCustomResponse;
import com.huawei.sis.client.TtsCustomizationClient;
import com.huawei.sis.exception.SisException;
import com.huawei.sis.util.JsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
public class HWYunSisService {
private static Logger log = LoggerFactory.getLogger(HWYunSisService.class);
private static final int DEFAULT_PITCH = 0;
private static final int DEFAULT_SPEED = -100;
private static final int DEFAULT_VOLUME = 50;
@ -26,9 +33,8 @@ public class HWYunSisService {
private static String projectId = "075456f65780107f2f4ec013ff43b487";
// 待合成的文本
private static String text = "";
// 设置本地音频保存路径.可选择不保存到本地。需具体到文件,如D:/test.wav
// private static String path = CommonSysConst.getSysConfig().getFile_url()";
private static String path = "/Volumes/work/开发/filesystem/";
// 设置本地音频保存路径.可选择不保存到本地
private static String path = "";
/**
@ -76,8 +82,10 @@ public class HWYunSisService {
/**
* 根据文本和api获取生成的音频数据
*/
public static Object ttsCustomDemo(JSONObject object) {
public static String ttsCustomDemo(JSONObject object) {
try {
log.info("========= START 华为云生成音频数据 START ===========");
// 1. 初始化TtsCustomizationClient
// 定义authInfo,根据ak,sk,region, projectId.
AuthInfo authInfo = new AuthInfo(ak, sk, region, projectId);
@ -86,10 +94,14 @@ public class HWYunSisService {
// 根据authInfo和config,构造TtsCustomizationClient
TtsCustomizationClient tts = new TtsCustomizationClient(authInfo, config);
text = object.getString("storeName") + "收款" + object.getString("price") + "元";
text = "惠支付收款" + object.getString("price") + "元";
path = path + object.getString("storeName") + "/" + object.getString("price") + ".mp3";
path = CommonSysConst.getSysConfig().getFilesystem() + "/tts/" + object.getString("price") + ".mp3";
File file = new File(path);
if (file.exists()) {
return path;
}
// 2. 配置请求
TtsCustomRequest request = new TtsCustomRequest(text);
// 设置参数,所有参数均可选,如果要保存合成音频文件,需要在request设置
@ -98,13 +110,21 @@ public class HWYunSisService {
// 3. 发送请求,获取响应。具体结果可通过response.getXX获取。
TtsCustomResponse response = tts.getTtsResponse(request);
return JsonUtils.obj2Str(response, true);
log.info("华为云-参数: " + JSON.toJSONString(response));
if (response.getResult().getData() != null) {
return response.getSavePath();
}
return null;
} catch (SisException e) {
e.printStackTrace();
System.out.println("error_code:" + e.getErrorCode() + "\nerror_msg:" + e.getErrorMsg());
return null;
} finally {
log.info("========= END 聚合主扫接口 END ===========");
}
}

@ -1,5 +1,6 @@
package com.hfkj.unipush;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.getui.push.v2.sdk.ApiHelper;
import com.getui.push.v2.sdk.GtApiConfiguration;
@ -8,6 +9,8 @@ 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.message.PushDTO;
import com.getui.push.v2.sdk.dto.req.message.PushMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
@ -15,7 +18,7 @@ import java.util.Map;
* @author sum1dream
*/
public class UniPushService {
private static Logger log = LoggerFactory.getLogger(UniPushService.class);
/**
* 创建请求
@ -48,6 +51,8 @@ public class UniPushService {
*/
public static String pushToSingleByCid(JSONObject object) {
log.info("========= START 个推手机端推送 START ===========");
PushApi pushApi = createClient();
//根据cid进行单推
@ -62,9 +67,12 @@ public class UniPushService {
Audience audience = new Audience();
pushDTO.setAudience(audience);
audience.addCid(object.getString("cid"));
log.info("个推-请求参数: " + JSON.toJSONString(pushDTO));
// 进行cid单推
ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
log.info("个推-返回参数: " + JSON.toJSONString(apiResult));
log.info("========= END 个推手机端推送 END ===========");
if (apiResult.isSuccess()) {
return apiResult.getData().toString();
// success

@ -51,7 +51,8 @@ lkl_saas_private_key="MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKnlpXdmJc
wechat_pay_notify_url=https://gratia-pay.dctpay.com/crest/weiXinNotify/jsapiPay
file_url=/home/project/gratia-pay/file
filesystem=/home/project/gratia-pay/filesystem
#filesystem=/home/project/gratia-pay/filesystem
filesystem=/Volumes/work/filesystem
domainName=https://gratia-pay.dctpay.com
hsg_domain_name=https://hsgcs.dctpay.com/

Loading…
Cancel
Save