提交查询门店和积分返利

yy_dev
袁野 1 year ago
parent 0b71573faf
commit 206518bfb0
  1. 8
      cweb/src/main/java/com/cweb/controller/TestController.java
  2. 16
      service/src/main/java/com/hfkj/common/Base64Util.java
  3. 30
      service/src/main/java/com/hfkj/service/impl/BsStoreCidServiceImpl.java
  4. 5
      service/src/main/java/com/hfkj/tts/HWYunSisService.java
  5. 38
      service/src/main/java/com/hfkj/unipush/UniPushService.java

@ -656,16 +656,18 @@ public class TestController {
@RequestMapping(value="/uniPush",method = RequestMethod.GET) @RequestMapping(value="/uniPush",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "uniPush") @ApiOperation(value = "uniPush")
public ResponseData uniPush(@RequestParam(name = "cid", required = true) String cid) { public ResponseData uniPush(@RequestParam(name = "storeId", required = true) Long storeId,@RequestParam(name = "price", required = true) BigDecimal price) {
try { try {
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
object.put("storeId" , 136); object.put("price", price);
object.put("price" , "283.82"); object.put("storeId", storeId);
bsStoreCidService.storePush(object); bsStoreCidService.storePush(object);
return ResponseMsgUtil.success("成功"); return ResponseMsgUtil.success("成功");
} catch (Exception e) { } catch (Exception e) {

@ -1,6 +1,11 @@
package com.hfkj.common; package com.hfkj.common;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.IDGenerator;
import java.util.Base64; import java.util.Base64;
import java.util.Date;
import java.util.Random;
public class Base64Util { public class Base64Util {
/** /**
@ -17,6 +22,17 @@ public class Base64Util {
return safeBase64Str.replaceAll("\\s*", ""); return safeBase64Str.replaceAll("\\s*", "");
} }
public static String generateOrderNo(){
try {
// 5位随机数 + 1位线程生成数
String randomNum = (new Random().nextInt(8999) + 1000) + IDGenerator.nextId(1);
// 生成订单号
return DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + randomNum;
} catch (Exception e) {
return null;
}
}
/** /**
* @param safeBase64Str * @param safeBase64Str
* @return str * @return str

@ -1,9 +1,11 @@
package com.hfkj.service.impl; package com.hfkj.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.Base64Util;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.config.CommonSysConst;
import com.hfkj.dao.BsStoreCidMapper; import com.hfkj.dao.BsStoreCidMapper;
import com.hfkj.dao.BsStorePushRecordMapper; import com.hfkj.dao.BsStorePushRecordMapper;
import com.hfkj.entity.BsStoreCid; import com.hfkj.entity.BsStoreCid;
@ -20,6 +22,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -92,6 +95,7 @@ public class BsStoreCidServiceImpl implements BsStoreCidService {
if (bsStoreCid == null) { if (bsStoreCid == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "不存在推送关系"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "不存在推送关系");
} }
// 获取语音播报地址 // 获取语音播报地址
String auditPath = HWYunSisService.ttsCustomDemo(object); String auditPath = HWYunSisService.ttsCustomDemo(object);
@ -99,9 +103,22 @@ public class BsStoreCidServiceImpl implements BsStoreCidService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "生成语音失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "生成语音失败");
} }
String taskNo = Base64Util.generateOrderNo();
object.put("taskNo", taskNo);
object.put("cid", bsStoreCid.getCid()); object.put("cid", bsStoreCid.getCid());
object.put("body", auditPath); String msg = CommonSysConst.getSysConfig().getDomainName() + auditPath + "!@#PUSH#@!" + taskNo;
UniPushService.pushToSingleByCid(object); object.put("body", msg);
if (UniPushService.pushToSingleByCid(object)) {
BsStorePushRecord storePushRecord = new BsStorePushRecord();
storePushRecord.setStoreId(object.getLong("storeId"));
storePushRecord.setCreateTime(new Date());
storePushRecord.setUpdateTime(new Date());
storePushRecord.setStatus(2);
storePushRecord.setExt1(taskNo);
storePushRecord.setVoiceUrl(msg);
insertStorePushRecord(storePushRecord);
}
} catch (Exception e) { } catch (Exception e) {
@ -110,6 +127,8 @@ public class BsStoreCidServiceImpl implements BsStoreCidService {
} }
private void getPushRecord(Long storeId) { private void getPushRecord(Long storeId) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
@ -130,6 +149,7 @@ public class BsStoreCidServiceImpl implements BsStoreCidService {
if (storePushRecord != null) { if (storePushRecord != null) {
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
object.put("cid", bsStoreCid.getCid()); object.put("cid", bsStoreCid.getCid());
object.put("storeId", bsStoreCid.getCid());
object.put("body", storePushRecord.getVoiceUrl()); object.put("body", storePushRecord.getVoiceUrl());
UniPushService.pushToSingleByCid(object); UniPushService.pushToSingleByCid(object);
} }
@ -144,8 +164,10 @@ public class BsStoreCidServiceImpl implements BsStoreCidService {
pushMap.put("status" , 2); pushMap.put("status" , 2);
BsStorePushRecord storePushRecord = findPushRecordByMap(pushMap); BsStorePushRecord storePushRecord = findPushRecordByMap(pushMap);
storePushRecord.setStatus(1); if (storePushRecord != null) {
storePushRecordMapper.updateByPrimaryKey(storePushRecord); storePushRecord.setStatus(1);
storePushRecordMapper.updateByPrimaryKey(storePushRecord);
}
getPushRecord(storeId); getPushRecord(storeId);
} }

@ -100,7 +100,8 @@ public class HWYunSisService {
File file = new File(path); File file = new File(path);
if (file.exists()) { if (file.exists()) {
return path; log.info("返回服务器语音内容 " + JSON.toJSONString(path));
return "/filesystem/tts/" + object.getString("price") + ".mp3";
} }
// 2. 配置请求 // 2. 配置请求
TtsCustomRequest request = new TtsCustomRequest(text); TtsCustomRequest request = new TtsCustomRequest(text);
@ -113,7 +114,7 @@ public class HWYunSisService {
log.info("华为云-参数: " + JSON.toJSONString(response)); log.info("华为云-参数: " + JSON.toJSONString(response));
if (response.getResult().getData() != null) { if (response.getResult().getData() != null) {
return response.getSavePath(); return "/filesystem/tts/" + object.getString("price") + ".mp3";
} }
return null; return null;

@ -9,18 +9,10 @@ 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.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.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.IDGenerator;
import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsStorePushRecord;
import com.hfkj.service.BsStoreCidService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Random;
/** /**
* @author sum1dream * @author sum1dream
@ -28,9 +20,6 @@ import java.util.Random;
public class UniPushService { public class UniPushService {
private static Logger log = LoggerFactory.getLogger(UniPushService.class); private static Logger log = LoggerFactory.getLogger(UniPushService.class);
@Resource
private static BsStoreCidService bsStoreCidService;
/** /**
* 创建请求 * 创建请求
* @return * @return
@ -60,10 +49,11 @@ public class UniPushService {
* @Param [uniPushModel] * @Param [uniPushModel]
* @Return void * @Return void
*/ */
public static void pushToSingleByCid(JSONObject object) { public static Boolean pushToSingleByCid(JSONObject object) {
log.info("========= START 个推手机端推送 START ==========="); log.info("========= START 个推手机端推送 START ===========");
PushApi pushApi = createClient(); PushApi pushApi = createClient();
//根据cid进行单推 //根据cid进行单推
@ -85,28 +75,12 @@ public class UniPushService {
log.info("========= END 个推手机端推送 END ==========="); log.info("========= END 个推手机端推送 END ===========");
if (apiResult.isSuccess()) { if (apiResult.isSuccess()) {
if (apiResult.getData().toString().contains("successed_online")) { return apiResult.getData().toString().contains("successed_online");
BsStorePushRecord storePushRecord = new BsStorePushRecord(); } else {
storePushRecord.setStoreId(object.getLong("storeid")); return false;
storePushRecord.setCreateTime(new Date());
storePushRecord.setUpdateTime(new Date());
storePushRecord.setStatus(2);
storePushRecord.setExt1(generateOrderNo());
storePushRecord.setVoiceUrl(CommonSysConst.getSysConfig().getDomainName() + object.getString("body") + "!@#PUSH#@!" + storePushRecord.getExt1());
bsStoreCidService.insertStorePushRecord(storePushRecord);
}
} }
} }
public static String generateOrderNo(){
try {
// 5位随机数 + 1位线程生成数
String randomNum = (new Random().nextInt(8999) + 1000) + IDGenerator.nextId(1);
// 生成订单号
return DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + randomNum;
} catch (Exception e) {
return null;
}
}
} }

Loading…
Cancel
Save