This commit is contained in:
hucs
2024-07-29 13:15:16 +08:00
parent e33a01042d
commit 97613cca71
3 changed files with 50 additions and 7 deletions

View File

@@ -63,12 +63,12 @@ public class WxPlayController {
private WxCustomMpService mpService;
@GetMapping("/test")
public String test() {
SysTenantEntity tenant = tenantService.getById("7f7ecd75fd29464db2867982f88e8ef0");
tenantService.initRole(tenant);
return WxPayNotifyResponse.success("成功");
}
//@GetMapping("/test")
//public String test() {
// SysTenantEntity tenant = tenantService.getById("7f7ecd75fd29464db2867982f88e8ef0");
// tenantService.initRole(tenant);
// return WxPayNotifyResponse.success("成功");
//}
/**
* 微信支付-微信回调地址https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_7&index=8
@@ -121,11 +121,21 @@ public class WxPlayController {
//修改账户余额
customUserInfoService.customAccountBalanceRecharge(orderInfoEntity.getOrderMoney(), orderInfoEntity.getPurchaserBy(), orderInfoEntity.getId());
log.info("*********支付处理完成");
// 推送通知
mpService.sendBalanceMessage(orderInfoEntity);
} catch (Exception e) {
log.error("订单回调业务处理异常,xmlData={}", xmlData);
}
}
@GetMapping("/test")
public R test() {
PlayOrderInfoEntity orderInfo = playOrderInfoService.getById("0e3e7d7ec69a");
mpService.sendBalanceMessage(orderInfo);
return R.ok(true);
}
@CustomUserLogin
@GetMapping("/custom/getCustomPaymentAmount")

View File

@@ -6,16 +6,24 @@ import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import com.starry.admin.common.exception.CustomException;
import com.starry.admin.common.play.wx.WeChatConstants;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity;
import com.starry.admin.modules.platform.entity.SysTenantEntity;
import com.starry.admin.modules.platform.service.impl.SysTenantServiceImpl;
import com.starry.admin.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
import me.chanjar.weixin.mp.config.impl.WxMpMapConfigImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* @author admin
@@ -29,6 +37,8 @@ public class WxCustomMpService {
@Resource
private SysTenantServiceImpl tenantService;
@Resource
private IPlayCustomUserInfoService customUserInfoService;
public WxMpService proxyWxMpService() {
@@ -75,4 +85,28 @@ public class WxCustomMpService {
}
public void sendBalanceMessage(PlayOrderInfoEntity order) {
PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(order.getPurchaserBy());
String touser = customUserInfo.getOpenid();
String template_id = "o4ayi85cdrgn8iU_O_lm_c_7uhdYUd4m0o5P0wTHdaY";
String tenantKey = tenantService.selectSysTenantByTenantId(order.getTenantId()).getTenantKey();
String url = "http://" + tenantKey + ".july.hucs.top/user/";
WxMpTemplateMessage templateMessage = new WxMpTemplateMessage();
templateMessage.setTemplateId(template_id);
templateMessage.setToUser(touser);
templateMessage.setUrl(url);
List<WxMpTemplateData> data = new ArrayList<>();
data.add(new WxMpTemplateData("thing18", "陪陪船票"));
data.add(new WxMpTemplateData("amount4", order.getOrderMoney().toString()));
data.add(new WxMpTemplateData("phrase5", "船票充值"));
data.add(new WxMpTemplateData("amount10", customUserInfo.getAccountBalance().toString()));
templateMessage.setData(data);
try {
proxyWxMpService().getTemplateMsgService().sendTemplateMsg(templateMessage);
} catch (WxErrorException e) {
log.error(e.getMessage(), e);
}
}
}