|
|
@@ -87,6 +87,7 @@ import com.fs.system.mapper.SysDictDataMapper;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.voice.utils.StringUtil;
|
|
|
import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult;
|
|
|
+import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
import com.volcengine.service.vod.IVodService;
|
|
|
import com.volcengine.service.vod.model.business.VodUrlUploadURLSet;
|
|
|
import com.volcengine.service.vod.model.request.*;
|
|
|
@@ -1911,6 +1912,47 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /** 发红包接口返回非成功时,优先透传支付层返回的 msg */
|
|
|
+ private static String resolveSendRedPacketFailMsg(R sendRedPacket) {
|
|
|
+ if (sendRedPacket == null) {
|
|
|
+ return "奖励发送失败,请联系客服";
|
|
|
+ }
|
|
|
+ Object msgObj = sendRedPacket.get("msg");
|
|
|
+ if (msgObj != null) {
|
|
|
+ String m = String.valueOf(msgObj).trim();
|
|
|
+ if (StringUtils.isNotEmpty(m) && !"success".equalsIgnoreCase(m)) {
|
|
|
+ return m;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "奖励发送失败,请联系客服";
|
|
|
+ }
|
|
|
+
|
|
|
+ private static boolean isWxAppIdMchIdNotMatch(Throwable t) {
|
|
|
+ while (t != null) {
|
|
|
+ if (t instanceof WxPayException) {
|
|
|
+ WxPayException wx = (WxPayException) t;
|
|
|
+ if ("APPID_MCHID_NOT_MATCH".equals(wx.getErrCode())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ String des = wx.getErrCodeDes();
|
|
|
+ if (des != null && des.contains("商户号和appid没有绑定关系")) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 兜底:有些场景下异常类型/字段未必能完全取到,只要 message 中包含关键字也认为是该错误
|
|
|
+ String msg = t.getMessage();
|
|
|
+ if (msg != null && (msg.contains("APPID_MCHID_NOT_MATCH") || msg.contains("商户号和appid没有绑定关系"))) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ String str = t.toString();
|
|
|
+ if (str != null && (str.contains("APPID_MCHID_NOT_MATCH") || str.contains("商户号和appid没有绑定关系"))) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ t = t.getCause();
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
private R sendRedPacketRewardToUser(FsCourseSendRewardUParam param, FsCourseWatchLog log, CourseConfig config, WxSendRedPacketParam packetParam, BigDecimal amount) {
|
|
|
|
|
|
|
|
|
@@ -1998,6 +2040,9 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
// 异常时回滚余额
|
|
|
|
|
|
rollbackBalance(balanceRollbackError);
|
|
|
+ if (isWxAppIdMchIdNotMatch(e)) {
|
|
|
+ return R.error("未绑定该小程序,请联系群主");
|
|
|
+ }
|
|
|
return R.error("奖励发送失败,请联系客服");
|
|
|
}
|
|
|
|
|
|
@@ -2038,7 +2083,11 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
} else {
|
|
|
// 登记回滚流水表
|
|
|
rollbackBalance(balanceRollbackError);
|
|
|
- return R.error("奖励发送失败,请联系客服");
|
|
|
+ String failMsg = resolveSendRedPacketFailMsg(sendRedPacket);
|
|
|
+ if (failMsg != null && (failMsg.contains("APPID_MCHID_NOT_MATCH") || failMsg.contains("商户号和appid没有绑定"))) {
|
|
|
+ return R.error("商户号异常,请联系群主");
|
|
|
+ }
|
|
|
+ return R.error(failMsg);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2082,7 +2131,11 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
|
|
|
return sendRedPacket;
|
|
|
} else {
|
|
|
- return R.error("奖励发送失败,请联系客服");
|
|
|
+ String failMsg = resolveSendRedPacketFailMsg(sendRedPacket);
|
|
|
+ if (failMsg != null && (failMsg.contains("APPID_MCHID_NOT_MATCH") || failMsg.contains("商户号和appid没有绑定"))) {
|
|
|
+ return R.error("商户号异常,请联系群主");
|
|
|
+ }
|
|
|
+ return R.error(failMsg);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2262,6 +2315,9 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
// 异常时回滚余额
|
|
|
|
|
|
rollbackBalance(balanceRollbackError);
|
|
|
+ if (isWxAppIdMchIdNotMatch(e)) {
|
|
|
+ return R.error("未绑定该小程序,请联系群主");
|
|
|
+ }
|
|
|
return R.error("奖励发送失败,请联系客服");
|
|
|
}
|
|
|
|
|
|
@@ -2308,7 +2364,11 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
} else {
|
|
|
// 发送失败,回滚余额
|
|
|
rollbackBalance(balanceRollbackError);
|
|
|
- return R.error("奖励发送失败,请联系客服");
|
|
|
+ String failMsg = resolveSendRedPacketFailMsg(sendRedPacket);
|
|
|
+ if (failMsg != null && (failMsg.contains("APPID_MCHID_NOT_MATCH") || failMsg.contains("商户号和appid没有绑定关系"))) {
|
|
|
+ return R.error("小程序未绑定,请联系群主");
|
|
|
+ }
|
|
|
+ return R.error(failMsg);
|
|
|
}
|
|
|
|
|
|
// ===================== 本次修改目的为了实时扣减公司余额=====================
|
|
|
@@ -2356,7 +2416,11 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
|
|
|
return sendRedPacket;
|
|
|
} else {
|
|
|
- return R.error("奖励发送失败,请联系客服");
|
|
|
+ String failMsg = resolveSendRedPacketFailMsg(sendRedPacket);
|
|
|
+ if (failMsg != null && (failMsg.contains("APPID_MCHID_NOT_MATCH") || failMsg.contains("商户号和appid没有绑定"))) {
|
|
|
+ return R.error("商户号异常,请联系群主");
|
|
|
+ }
|
|
|
+ return R.error(failMsg);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
return R.error(e.getMessage());
|
|
|
@@ -2454,7 +2518,11 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
R sendRedPacket = paymentService.sendRedPacket(packetParam);
|
|
|
|
|
|
if (!sendRedPacket.get("code").equals(200)) {
|
|
|
- return R.error("奖励发送失败,请联系客服");
|
|
|
+ String failMsg = resolveSendRedPacketFailMsg(sendRedPacket);
|
|
|
+ if (failMsg != null && (failMsg.contains("APPID_MCHID_NOT_MATCH") || failMsg.contains("商户号和appid没有绑定"))) {
|
|
|
+ return R.error("商户号异常,请联系群主");
|
|
|
+ }
|
|
|
+ return R.error(failMsg);
|
|
|
}
|
|
|
|
|
|
createRedPacketLog(sendRedPacket, param, amount, log);
|