Commit 23eea9a7 authored by shiyu's avatar shiyu

发送模板消息

parent c2316d0f
......@@ -17,8 +17,11 @@ dts:
get-access-token-url: https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s
#公众号消息点击后跳转到小程序页面的链接
#寄售业务,公众号消息点击后跳转到小程序页面的链接
msg-url: pages/consignNodeDetail/index
#分销业务,公众号消息点击后跳转到小程序页面的链接
distribution-msg-url: pages/saleOrderDetail/index
# 商户证书文件路径
# 请参考“商户证书”一节 https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=4_3
key-path: xxxxx
......@@ -29,6 +32,12 @@ dts:
officialaccount-key: noeN1amYRvzrVmE2GnC5VnsIfgPEmv6bhX54wJOARlM
get-officialaccount-accesstoken-url: https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s
officialaccount-templetId: WJkhzyY0_7AYqh19_ujK9yZhj4HohF8ETJvG5NYA9A8
#分销单支付成功通知模板
pay-templetId: X38RkH7DtKNDHUMa2P6XXqrEmkHIEvbpTWTr7Mkf2fM
#分销单发货成功通知模板
delivery-templetId: 8apEOIXxlLHrEQ20a-o_PHXogGtgKHu25zHzFg3RPeI
#分销订单确认收货通知模板
signed-templetId: k2dPOA4wvLPGf_4z76sGoA2KXHQWGEWpYT_imXlOpJI
#微信支付配置
wx-pay:
......
......@@ -11,6 +11,8 @@ dts:
#公众号消息点击后跳转到小程序页面的链接
msg-url: pages/consignNodeDetail/index
#分销业务,公众号消息点击后跳转到小程序页面的链接
distribution-msg-url: pages/saleOrderDetail/index
# 商户证书文件路径
# 请参考“商户证书”一节 https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=4_3
key-path: xxxxx
......@@ -21,6 +23,12 @@ dts:
officialaccount-key: noeN1amYRvzrVmE2GnC5VnsIfgPEmv6bhX54wJOARlM
get-officialaccount-accesstoken-url: https://api.weixin.qq.com/cgi-bin/stable_token
officialaccount-templetId: WJkhzyY0_7AYqh19_ujK9yZhj4HohF8ETJvG5NYA9A8
#分销单支付成功通知模板
pay-templetId: X38RkH7DtKNDHUMa2P6XXqrEmkHIEvbpTWTr7Mkf2fM
#分销单发货成功通知模板
delivery-templetId: 8apEOIXxlLHrEQ20a-o_PHXogGtgKHu25zHzFg3RPeI
#分销订单确认收货通知模板
signed-templetId: k2dPOA4wvLPGf_4z76sGoA2KXHQWGEWpYT_imXlOpJI
#微信支付配置
wx-pay:
......
......@@ -72,7 +72,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution"
targetProject="ch-dao/src/main/java"/>
<table tableName="shop_white_list" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<table tableName="supplier_item" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table>
......
......@@ -4,9 +4,11 @@ import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.core.notification.RequestParam;
import com.wechat.pay.java.service.payments.model.Transaction;
import com.wwdz.ch.core.api.OfficialAccountApi;
import com.wwdz.ch.core.api.wxpay.WxPayServiceApi;
import com.wwdz.ch.core.consts.DistributionEnum;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.PriceUtil;
import com.wwdz.ch.core.util.RedisUtils;
import com.wwdz.ch.core.util.TimeUtil;
import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
......@@ -16,8 +18,11 @@ import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.wwdz.ch.db.domain.distribution.DistributorProfit;
import com.wwdz.ch.db.domain.distribution.SupplierItem;
import com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto;
import com.wwdz.ch.wx.entity.PayNoticeMsg;
import com.wwdz.ch.wx.service.distribution.SendMsgService;
import com.wwdz.ch.wx.service.distribution.SupplierItemService;
import com.xxdxxs.utils.JsonUtils;
import com.xxdxxs.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -65,6 +70,12 @@ public class WxPayCallbackController {
@Autowired
SupplierItemService supplierItemService;
@Autowired
OfficialAccountApi officialAccountApi;
@Autowired
SendMsgService sendMsgService;
@RequestMapping(value ="/getPayNotify")
public synchronized String payNotify(HttpServletRequest request) throws IOException {
logger.info("------------------ 收到微信支付回调通知 ------------------");
......@@ -130,6 +141,8 @@ public class WxPayCallbackController {
}
}
}
returnMap.put("code", "SUCCESS");
returnMap.put("message", "成功");
return JsonUtils.from(returnMap);
......@@ -189,6 +202,24 @@ public class WxPayCallbackController {
//更新库存
supplierItemService.reduceStock(distributionOrder.getItemId(), distributionOrder.getItemNum());
logger.info(">>>>>>>>>>>> 微信支付回调通知处理成功,更新订单状态和商品库存 <<<<<<<<<<<<");
//用户支付成功,发送模板信息通知分销商
try {
String openId = sendMsgService.getOpenIdByUserId(distributionOrder.getSellerId());
if (StringUtils.hasLength(openId)) {
PayNoticeMsg payNoticeMsg = new PayNoticeMsg();
payNoticeMsg.setDistributionOrderId(distributionOrderId);
payNoticeMsg.setItemName(supplierItem.getName());
payNoticeMsg.setItemNum(distributionOrder.getItemNum());
payNoticeMsg.setAmount(PriceUtil.convertPriceFenToYuan(distributionOrder.getAmount()));
payNoticeMsg.setPayTime(TimeUtil.wxTimeConvert(payTime));
sendMsgService.sendPayTempletMsg(openId, payNoticeMsg);
} else {
logger.info(">>>>> 分销商id :{}, 获取openid失败 <<<<<", distributionOrder.getSellerId());
}
} catch (Exception e) {
logger.info("用户支付成功,向分销商发送模板信息失败:{}", e);
}
return Result.success();
} catch (Exception e) {
logger.info(">>>>>>>>>>>> 微信支付回调通知处理失败 error :{}", e);
......
......@@ -42,7 +42,8 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
"/officialAccountCallback/**","/wxPayCallback/**",
"/imCallback/**", "/wx/category/**",
"/wx/consignSale/**", "/wx/item/**",
"/wx/returnOrder/**", "/wx/supplierItem/**", "/wx/shareRecord/**", "/wx/distributionOrder/**", "/wx/selfPage/**"
"/wx/returnOrder/**"
, "/wx/supplierItem/**", "/wx/shareRecord/**", "/wx/distributionOrder/**", "/wx/selfPage/**"
/* "/wx/officialAccount/**",
"/wx/item/**",
"/wx/aiAssistant/**",
......
package com.wwdz.ch.wx.entity;
import com.wwdz.ch.core.entity.AbstractSubscribeMsg;
import com.xxdxxs.entity.Entity;
import com.xxdxxs.utils.DateUtils;
import lombok.Data;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 发货通知消息
*/
@Data
public class DeliveryNoticeMsg implements Entity, AbstractSubscribeMsg {
private String templetId;
/**
* 分销订单号
*/
private String distributionOrderId;
/**
* 商品名称
*/
private String itemName;
/**
* 快递单号
*/
private String waybill;
/**
* 收货地址
*/
private String address;
/**
* 发货时间
*/
private Date deliveryTime;
@Override
public Map<String, Object> getTempletParam() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("character_string3", new HashMap(){{put("value", distributionOrderId);}});
map.put("thing14", new HashMap(){{put("value", itemName);}});
map.put("character_string8", new HashMap(){{put("value", waybill);}});
map.put("thing17", new HashMap(){{put("value", address);}});
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss", Locale.CHINESE);
String formattedDate = sdf.format(deliveryTime);
map.put("time10", new HashMap(){{put("value", formattedDate);}});
return map;
}
@Override
public String getTempletId() {
return templetId;
}
}
package com.wwdz.ch.wx.entity;
import com.wwdz.ch.core.entity.AbstractSubscribeMsg;
import com.xxdxxs.entity.Entity;
import com.xxdxxs.utils.DateUtils;
import lombok.Data;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 支付通知消息
*/
@Data
public class PayNoticeMsg implements Entity, AbstractSubscribeMsg {
private String templetId;
/**
* 分销订单号
*/
private String distributionOrderId;
/**
* 商品名称
*/
private String itemName;
/**
* 商品数量
*/
private Integer itemNum;
/**
* 订单金额
*/
private String amount;
/**
* 支付时间
*/
private String payTime;
@Override
public Map<String, Object> getTempletParam() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("character_string2", new HashMap(){{put("value", distributionOrderId);}});
map.put("thing6", new HashMap(){{put("value", itemName);}});
map.put("number8", new HashMap(){{put("value", itemNum);}});
map.put("amount12", new HashMap(){{put("value", amount);}});
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss", Locale.CHINESE);
String formattedDate = sdf.format(DateUtils.parseString(payTime));
map.put("time14", new HashMap(){{put("value", formattedDate);}});
return map;
}
@Override
public String getTempletId() {
return templetId;
}
}
package com.wwdz.ch.wx.entity;
import com.wwdz.ch.core.entity.AbstractSubscribeMsg;
import com.xxdxxs.entity.Entity;
import com.xxdxxs.utils.DateUtils;
import lombok.Data;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 确认收货通知消息
*/
@Data
public class SignedNoticeMsg implements Entity, AbstractSubscribeMsg {
private String templetId;
/**
* 分销订单号
*/
private String distributionOrderId;
/**
* 商品名称
*/
private String itemName;
/**
* 付款金额
*/
private String amount;
/**
* 签收时间
*/
private Date signedTime;
@Override
public Map<String, Object> getTempletParam() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("character_string5", new HashMap(){{put("value", distributionOrderId);}});
map.put("thing1", new HashMap(){{put("value", itemName);}});
map.put("amount2", new HashMap(){{put("value", amount);}});
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss", Locale.CHINESE);
String formattedDate = sdf.format(signedTime);
map.put("time4", new HashMap(){{put("value", formattedDate);}});
return map;
}
@Override
public String getTempletId() {
return templetId;
}
}
......@@ -21,9 +21,14 @@ import com.wwdz.ch.db.domain.distribution.SupplierItem;
import com.wwdz.ch.db.dto.request.ConsignSaleRequestDto;
import com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto;
import com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto;
import com.wwdz.ch.wx.entity.DeliveryNoticeMsg;
import com.wwdz.ch.wx.entity.PayNoticeMsg;
import com.wwdz.ch.wx.entity.SignedNoticeMsg;
import com.wwdz.ch.wx.entity.vo.distribution.DistributionOrderDetailVo;
import com.wwdz.ch.wx.entity.vo.distribution.DistributionOrderVo;
import com.wwdz.ch.wx.service.distribution.DistributionOrderService;
import com.wwdz.ch.wx.service.distribution.SendMsgService;
import com.xxdxxs.utils.DateUtils;
import com.xxdxxs.utils.EntityMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -67,6 +72,9 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
@Autowired
DistributorProfitDao distributorProfitDao;
@Autowired
SendMsgService sendMsgService;
@Override
public Result createDistributionOrder(DistributionOrderRequestDto dto) {
try {
......@@ -178,6 +186,26 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
public Result confirmSigned(DistributionOrderRequestDto dto) {
try {
distributionOrderDao.updateState(dto.getDistributionOrderId(), DistributionEnum.DistributionOrderStateEnum.FINISH.getCode());
String distributionOrderId = dto.getDistributionOrderId();
DistributionOrder distributionOrder = distributionOrderDao.findById(distributionOrderId);
//用户确认收货,发送模板信息通知分销商
try {
SignedNoticeMsg signedNoticeMsg = new SignedNoticeMsg();
signedNoticeMsg.setDistributionOrderId(distributionOrderId);
signedNoticeMsg.setAmount(PriceUtil.convertPriceFenToYuan(distributionOrder.getAmount()));
SupplierItem supplierItem = supplierItemDao.findById(distributionOrder.getItemId());
signedNoticeMsg.setItemName(supplierItem.getName());
signedNoticeMsg.setSignedTime(new Date());
//发送给卖家
String sellerOpenId = sendMsgService.getOpenIdByUserId(distributionOrder.getSellerId());
if (com.xxdxxs.utils.StringUtils.hasLength(sellerOpenId)) {
sendMsgService.sendSignedTempletMsg(sellerOpenId, signedNoticeMsg);
} else {
logger.info(">>>>> 分销商id :{}, 获取openid失败,无法发送模板信息 <<<<<", distributionOrder.getSellerId());
}
} catch (Exception e) {
logger.info("分销订单发货通知模板信息发送失败:{}", e);
}
return Result.success();
} catch (Exception e) {
logger.info("用户确认收货失败 error: {}", e);
......@@ -193,13 +221,40 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
if (distributionOrder.getState() != DistributionEnum.DistributionOrderStateEnum.PRE_SEND.getCode()) {
return Result.failed("订单状态错误,不能发货");
}
Date now = new Date();
DistributionOrder orderUpdateDto = new DistributionOrder();
orderUpdateDto.setDistributionOrderId(distributionOrderId);
orderUpdateDto.setLogisticsCode(dto.getLogisticsCode());
orderUpdateDto.setWaybill(dto.getWaybill());
orderUpdateDto.setDeliveryTime(new Date());
orderUpdateDto.setDeliveryTime(now);
orderUpdateDto.setState(DistributionEnum.DistributionOrderStateEnum.PRE_SIGNED.getCode());
distributionOrderDao.update(orderUpdateDto);
//发货成功,发送模板信息通知分销商和用户
try {
DeliveryNoticeMsg deliveryNoticeMsg = new DeliveryNoticeMsg();
deliveryNoticeMsg.setDistributionOrderId(distributionOrderId);
deliveryNoticeMsg.setWaybill(dto.getWaybill());
deliveryNoticeMsg.setAddress(distributionOrder.getReceiverName() + " " + distributionOrder.getReceiverPhone() + " " + distributionOrder.getReceiverAddress());
SupplierItem supplierItem = supplierItemDao.findById(distributionOrder.getItemId());
deliveryNoticeMsg.setItemName(supplierItem.getName());
deliveryNoticeMsg.setDeliveryTime(now);
//发送给卖家
String sellerOpenId = sendMsgService.getOpenIdByUserId(distributionOrder.getSellerId());
if (com.xxdxxs.utils.StringUtils.hasLength(sellerOpenId)) {
sendMsgService.sendDeliveryTempletMsg(sellerOpenId, deliveryNoticeMsg);
} else {
logger.info(">>>>> 分销商id :{}, 获取openid失败 <<<<<", distributionOrder.getSellerId());
}
//发送给买家
if (com.xxdxxs.utils.StringUtils.hasLength(distributionOrder.getBuyerOpenid())) {
sendMsgService.sendDeliveryTempletMsg(distributionOrder.getBuyerOpenid(), deliveryNoticeMsg);
} else {
logger.info(">>>>> 买家openid为空, 发送消息失败 <<<<<");
}
} catch (Exception e) {
logger.info("分销订单发货通知模板信息发送失败:{}", e);
}
return Result.success();
} catch (Exception e) {
logger.info("发货失败 error: {}", e);
......
package com.wwdz.ch.wx.impl.distribution;
import com.wwdz.ch.core.api.OfficialAccountApi;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.OkHttpUtil;
import com.wwdz.ch.db.dao.OfficialAccountSubscribeRecordDao;
import com.wwdz.ch.db.dao.UserDao;
import com.wwdz.ch.db.domain.OfficialAccountSubscribeRecord;
import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.wx.entity.DeliveryNoticeMsg;
import com.wwdz.ch.wx.entity.PayNoticeMsg;
import com.wwdz.ch.wx.entity.SignedNoticeMsg;
import com.wwdz.ch.wx.service.distribution.SendMsgService;
import com.xxdxxs.utils.JsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* 发送模板消息
*/
@Service
public class SendMsgServiceImpl implements SendMsgService {
private static final Logger logger = LoggerFactory.getLogger(SendMsgServiceImpl.class);
private final static String SEND_MSG_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send";
@Value("${dts.wx.pay-templetId}")
private String PAY_TEMPLETID;
@Value("${dts.wx.delivery-templetId}")
private String DELIVERY_TEMPLETID;
@Value("${dts.wx.signed-templetId}")
private String SIGNED_TEMPLETID;
@Value("${dts.wx.app-id}")
private String APPLET_APPID;
@Value("${dts.wx.distribution-msg-url}")
private String DISTRIBUTION_MSG_URL;
@Autowired
OfficialAccountApi officialAccountApi;
@Autowired
UserDao userDao;
@Autowired
OfficialAccountSubscribeRecordDao officialAccountSubscribeRecordDao;
@Override
public Result sendPayTempletMsg(String openId, PayNoticeMsg payNoticeMsg) {
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", PAY_TEMPLETID);
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(DISTRIBUTION_MSG_URL);
stringBuffer.append("?orderId=" + payNoticeMsg.getDistributionOrderId());
miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap);
map.put("data", payNoticeMsg.getTempletParam());
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();
}
@Override
public Result sendDeliveryTempletMsg(String openId, DeliveryNoticeMsg deliveryNoticeMsg) {
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", DELIVERY_TEMPLETID);
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(DISTRIBUTION_MSG_URL);
stringBuffer.append("?orderId=" + deliveryNoticeMsg.getDistributionOrderId());
miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap);
map.put("data", deliveryNoticeMsg.getTempletParam());
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();
}
@Override
public Result sendSignedTempletMsg(String openId, SignedNoticeMsg signedNoticeMsg) {
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", SIGNED_TEMPLETID);
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(DISTRIBUTION_MSG_URL);
stringBuffer.append("?orderId=" + signedNoticeMsg.getDistributionOrderId());
miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap);
map.put("data", signedNoticeMsg.getTempletParam());
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();
}
@Override
public String getOpenIdByUserId(long userId) {
//先查询寄售单用户信息
User user = userDao.queryById(userId);
String unionId = user.getWeixinUnionid();
OfficialAccountSubscribeRecord officialAccountSubscribeRecord = officialAccountSubscribeRecordDao.findOne(unionId);
//没有订阅
if (officialAccountSubscribeRecord == null || officialAccountSubscribeRecord.getEnabled().intValue() == 0) {
logger.info(">>>>>>>>>> 用户 unionId = {} ,尚未订阅公众号,无法推送消息 <<<<<<<<<<<");
return null;
}
String openId = officialAccountSubscribeRecord.getOpenid();
return openId;
}
}
package com.wwdz.ch.wx.service.distribution;
import com.wwdz.ch.core.entity.AbstractSubscribeMsg;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.entity.DeliveryNoticeMsg;
import com.wwdz.ch.wx.entity.PayNoticeMsg;
import com.wwdz.ch.wx.entity.SignedNoticeMsg;
public interface SendMsgService {
Result sendPayTempletMsg(String openId, PayNoticeMsg payNoticeMsg);
Result sendDeliveryTempletMsg(String openId, DeliveryNoticeMsg deliveryNoticeMsg);
Result sendSignedTempletMsg(String openId, SignedNoticeMsg signedNoticeMsg);
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