Commit 8a8f2d45 authored by shiyu's avatar shiyu

模板消息

parent 9cd801c2
...@@ -152,6 +152,20 @@ public class AuctionRecordServiceImpl implements AuctionRecordService { ...@@ -152,6 +152,20 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
auctionConfigDao.updateRealEndTime(itemId, newRealEndTime); auctionConfigDao.updateRealEndTime(itemId, newRealEndTime);
logger.info("商品id:{}, 用户id:{}, 本次出价时间: {}, 原先截拍时间为:{}, 延长截拍时间为{}", itemId, dto.getUserId(), now, endTime, newRealEndTime); logger.info("商品id:{}, 用户id:{}, 本次出价时间: {}, 原先截拍时间为:{}, 延长截拍时间为{}", itemId, dto.getUserId(), now, endTime, newRealEndTime);
} }
//发送消息通知对应的分销商有用户出价
SupplierItem supplierItem = supplierItemDao.findById(dto.getItemId());
String openId = sendMsgService.getOpenIdByUserId(distributorShareRecord.getDistributorId());
if (com.xxdxxs.utils.StringUtils.hasLength(openId)) {
AuctionOfferNoticeMsg auctionOfferNoticeMsg = new AuctionOfferNoticeMsg();
auctionOfferNoticeMsg.setOpenId(openId);
auctionOfferNoticeMsg.setItemName(supplierItem.getName());
auctionOfferNoticeMsg.setCurrentPrice(PriceUtil.convertPriceFenToYuan(price));
sendMsgService.offerNoticeToDistributorMsg(auctionOfferNoticeMsg);
} else {
logger.info(">>>>> 分销商id :{}, 获取openid失败,无法通知分销商有用户出价 <<<<<", distributorShareRecord.getDistributorId());
}
return Result.success(); return Result.success();
} else { } else {
return Result.failed("出价者较多,请刷新出价记录"); return Result.failed("出价者较多,请刷新出价记录");
......
...@@ -240,6 +240,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { ...@@ -240,6 +240,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
distributorProfit.setIsValid(false); distributorProfit.setIsValid(false);
distributorProfitDao.insert(distributorProfit); distributorProfitDao.insert(distributorProfit);
SupplierItem supplierItem = supplierItemDao.findById(dto.getItemId());
//查询参与出价的所有用户所对应的分销商,可以评分成交额的3%的利润 //查询参与出价的所有用户所对应的分销商,可以评分成交额的3%的利润
List<AuctionRecord> auctionRecordList = auctionRecordDao.findByItemId(dto.getItemId()); List<AuctionRecord> auctionRecordList = auctionRecordDao.findByItemId(dto.getItemId());
List<AuctionRecord> filterRecordList = auctionRecordList.stream() List<AuctionRecord> filterRecordList = auctionRecordList.stream()
...@@ -261,28 +262,37 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { ...@@ -261,28 +262,37 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
averageProfitRecord.setCreateTime(new Date()); averageProfitRecord.setCreateTime(new Date());
averageProfitRecord.setIsValid(false); averageProfitRecord.setIsValid(false);
distributorProfitDao.insert(averageProfitRecord); distributorProfitDao.insert(averageProfitRecord);
//通知每一个分享参与出价的分销商
String userOpenId = sendMsgService.getOpenIdByUserId(auctionRecord.getUserId());
if (com.xxdxxs.utils.StringUtils.hasLength(userOpenId)) {
AuctionOfferNoticeMsg auctionOfferNoticeMsg = new AuctionOfferNoticeMsg();
auctionOfferNoticeMsg.setCurrentPrice(PriceUtil.convertPriceFenToYuan(auctionRecord.getPrice()));
auctionOfferNoticeMsg.setOpenId(userOpenId);
auctionOfferNoticeMsg.setItemName(supplierItem.getName());
auctionOfferNoticeMsg.setCurrentPrice(PriceUtil.convertPriceFenToYuan(distributionOrder.getAmount()));
auctionOfferNoticeMsg.setAuctionEndTime(auctionConfig.getRealEndTime());
sendMsgService.auctionSuccessForDistributorsMsg(auctionOfferNoticeMsg);
} else {
logger.info(">>>>> 分销商id :{}, 获取openid失败,无法通知参与分享的分销商拍品成交的信息 <<<<<", distributionOrder.getSellerId());
}
} }
//把该拍卖配置信息改为已处理 //把该拍卖配置信息改为已处理
auctionConfigDao.setDeal(dto.getItemId()); auctionConfigDao.setDeal(dto.getItemId());
//发送中拍信息给用户 //发送中拍信息给用户
String userOpenId = sendMsgService.getOpenIdByUserId(auctionRecord.getUserId()); String userOpenId = sendMsgService.getOpenIdByUserId(auctionRecord.getUserId());
if (com.xxdxxs.utils.StringUtils.hasLength(userOpenId)) { if (com.xxdxxs.utils.StringUtils.hasLength(userOpenId)) {
SupplierItem supplierItem = supplierItemDao.findById(distributionOrder.getItemId());
AuctionOfferNoticeMsg auctionOfferNoticeMsg = new AuctionOfferNoticeMsg(); AuctionOfferNoticeMsg auctionOfferNoticeMsg = new AuctionOfferNoticeMsg();
auctionOfferNoticeMsg.setCurrentPrice(PriceUtil.convertPriceFenToYuan(auctionRecord.getPrice())); auctionOfferNoticeMsg.setCurrentPrice(PriceUtil.convertPriceFenToYuan(auctionRecord.getPrice()));
auctionOfferNoticeMsg.setOpenId(userOpenId); auctionOfferNoticeMsg.setOpenId(userOpenId);
auctionOfferNoticeMsg.setItemName(supplierItem.getName()); auctionOfferNoticeMsg.setItemName(supplierItem.getName());
auctionOfferNoticeMsg.setDistributionOrderId(distributionOrderId); auctionOfferNoticeMsg.setDistributionOrderId(distributionOrderId);
Instant instant = now.toInstant().plus(Duration.ofHours(24));
Instant instant = now.toInstant(); Date payEndTime = Date.from(instant);
auctionOfferNoticeMsg.setPayEndTime(payEndTime);
// auctionOfferNoticeMsg.setPayEndTime(); sendMsgService.auctionSuccessMsg(auctionOfferNoticeMsg);
// sendMsgService.auctionSuccessMsg(signedNoticeMsg);
} else { } else {
logger.info(">>>>> 分销商id :{}, 获取openid失败,无法发送模板信息 <<<<<", distributionOrder.getSellerId()); logger.info(">>>>> 分销商id :{}, 获取openid失败,无法发送模板信息 <<<<<", distributionOrder.getSellerId());
} }
return Result.success(map); return Result.success(map);
} else { } else {
return Result.failed("稍后再试"); return Result.failed("稍后再试");
......
...@@ -307,7 +307,7 @@ public class SendMsgServiceImpl implements SendMsgService { ...@@ -307,7 +307,7 @@ public class SendMsgServiceImpl implements SendMsgService {
} }
@Override @Override
public Result auctionSuccessForDistributorMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) { public Result auctionSuccessForDistributorsMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) {
try { try {
String openId = auctionOfferNoticeMsg.getOpenId(); String openId = auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken(); String token = officialAccountApi.getAccessToken();
...@@ -458,6 +458,54 @@ public class SendMsgServiceImpl implements SendMsgService { ...@@ -458,6 +458,54 @@ public class SendMsgServiceImpl implements SendMsgService {
return Result.failed(); return Result.failed();
} }
@Override
public Result offerNoticeToDistributorMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) {
try {
String openId = auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken();
String url = SEND_MSG_URL + "?access_token=" + token;
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
Map<String, Object> map = new HashMap<>();
map.put("touser", openId);
map.put("template_id", "WJkhzyY0_7AYqh19_ujK99S_pVfRkKpLLpt5Y5XsKeM");
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(AUCTION_MSG_URL);
stringBuffer.append("?itemId=" + auctionOfferNoticeMsg.getItemId());
if (StringUtils.hasLength(auctionOfferNoticeMsg.getShareRecordId())) {
stringBuffer.append("&shareRecordId=" + auctionOfferNoticeMsg.getShareRecordId());
}
miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap);
Map<String, Object> paramMap = new LinkedHashMap<>();
paramMap.put("thing2", new HashMap() {{
put("value", auctionOfferNoticeMsg.getItemName().substring(0, 20));
}});
paramMap.put("thing3", new HashMap() {{
put("value", "有用户新出价"+ auctionOfferNoticeMsg.getCurrentPrice() + "元");
}});
map.put("data", paramMap);
logger.info("============ 出价通知对应分销商模板消息内容 : {}", JsonUtils.fromMap(map));
okHttpUtil.addParams(map);
okHttpUtil.post(true);
String responseStr = okHttpUtil.async();
logger.info("openid : {}, 发送出价通知对应分销商模板消息 response :{}", openId, responseStr);
String errorCode = JsonUtils.getValueByPath(responseStr, "errcode");
String errmsg = JsonUtils.getValueByPath(responseStr, "errmsg");
if (!"0".equals(errorCode)) {
logger.error("openid : {}, 发送出价通知对应分销商模板消息, errorCode : {}, errmsg : {} ", openId, errorCode, errmsg);
return Result.failed();
}
logger.info("=============发送出价通知对应分销商模板消息 成功 ===========");
return Result.success();
} catch (Exception e) {
e.printStackTrace();
}
return Result.failed();
}
@Override @Override
public String getOpenIdByUserId(long userId) { public String getOpenIdByUserId(long userId) {
//先查询寄售单用户信息 //先查询寄售单用户信息
......
...@@ -44,7 +44,7 @@ public interface SendMsgService { ...@@ -44,7 +44,7 @@ public interface SendMsgService {
* @param auctionOfferNoticeMsg * @param auctionOfferNoticeMsg
* @return * @return
*/ */
Result auctionSuccessForDistributorMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg); Result auctionSuccessForDistributorsMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg);
/** /**
* 竞拍快结束通知 * 竞拍快结束通知
...@@ -63,5 +63,13 @@ public interface SendMsgService { ...@@ -63,5 +63,13 @@ public interface SendMsgService {
Result auctionEndMsg( AuctionOfferNoticeMsg auctionOfferNoticeMsg); Result auctionEndMsg( AuctionOfferNoticeMsg auctionOfferNoticeMsg);
/**
* 用户出价通知对应分销商
* @param auctionOfferNoticeMsg
* @return
*/
Result offerNoticeToDistributorMsg( AuctionOfferNoticeMsg auctionOfferNoticeMsg);
String getOpenIdByUserId(long userId); String getOpenIdByUserId(long userId);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment