调整退款

This commit is contained in:
邱贞招 2024-12-30 20:35:09 +08:00
parent 4024a94338
commit 64de90a7f6
3 changed files with 14 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import com.ruoyi.common.pay.tm.vo.RefundInfo;
import com.ruoyi.common.pay.tm.vo.TmTradeInfo;
import com.ruoyi.common.pay.wx.Payable;
import com.ruoyi.common.pay.wx.RefundAble;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.http.HttpUtils;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
import org.slf4j.Logger;
@ -58,9 +59,11 @@ public class TmPayService {
String response = doPost(channel.getHttpUrl() + "/open/Pay/refund", body,channel);
if (com.ruoyi.common.utils.StringUtils.hasText(response)) {
JSONObject jsonResponse = JSON.parseObject(response);
if (jsonResponse.getInteger("errCode") == 0 && "退款成功".equals(jsonResponse.getString("errMsg"))) {
JSONObject tradeInfo = jsonResponse.getJSONObject("refundInfo");
return tradeInfo.toJavaObject(RefundInfo.class);
if (jsonResponse.getInteger("errCode") == 0) {
JSONObject refundInfo = jsonResponse.getJSONObject("refundInfo");
ServiceUtil.assertion(refundInfo == null, "退款失败");
ServiceUtil.assertion(refundInfo.getInteger("refundStatus") != 1, "退款失败:%s", refundInfo.getString("refundMessage"));
return refundInfo.toJavaObject(RefundInfo.class);
} else {
throw new ServiceException("退款失败: " + jsonResponse.getString("errMsg"));
}

View File

@ -28,4 +28,10 @@ public class ServiceUtil {
throw new ServiceException(msg, code);
}
}
public static void assertion(boolean flag, String format, Object ...args) {
if (flag) {
throw new ServiceException(String.format(format, args), 500);
}
}
}

View File

@ -274,16 +274,16 @@ public class SysLoginService
asUser.setCreateTime(DateUtils.getNowDate());
if(type.equals(Constants.CUSTOM_LOGIN_WX)){
asUser.setWxOpenid(openId);
asUser.setAppId(dept.getAppid());
}else{
asUser.setAliOpenid(openId);
asUser.setAppId("2021005106675341");
}
asUser.setAreaId(areaId);
if(dept.getIsUsePlatformApp().equals("true")){
asUser.setAppName("创享电动车");
asUser.setAppId("2021005106675341");
}else{
asUser.setAppName(dept.getAppName());
asUser.setAppId("2021005106675341");
}
log.info("【微信登录/wxlogin】用户不存在自动注册用户【{}】", JSON.toJSON(asUser));
int i = asUserService.insertUser(asUser);