From c6a6f44907b37efe3f2e21b9d8f9350897fa92c0 Mon Sep 17 00:00:00 2001 From: xin <1099200748@qq.com> Date: Mon, 07 Jul 2025 16:41:20 +0800 Subject: [PATCH] 小程序:提交订单(完善) --- oying-system/src/main/java/com/oying/modules/hwc/service/impl/SwiftPassServiceImpl.java | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) diff --git a/oying-system/src/main/java/com/oying/modules/hwc/service/impl/SwiftPassServiceImpl.java b/oying-system/src/main/java/com/oying/modules/hwc/service/impl/SwiftPassServiceImpl.java index bc39419..e300f79 100644 --- a/oying-system/src/main/java/com/oying/modules/hwc/service/impl/SwiftPassServiceImpl.java +++ b/oying-system/src/main/java/com/oying/modules/hwc/service/impl/SwiftPassServiceImpl.java @@ -8,8 +8,10 @@ import com.oying.modules.hwc.utils.SignUtils; import com.oying.modules.hwc.utils.XmlUtils; import com.oying.modules.security.config.SwiftPassProperties; +import com.oying.modules.security.config.WeiXinProperties; import com.oying.modules.sh.service.OrderReturnService; import com.oying.modules.sh.service.OrderService; +import com.oying.utils.CloseUtil; import com.oying.utils.enums.PayTypeEnum; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -22,7 +24,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -49,11 +50,12 @@ private final SwiftPassProperties properties; private final OrderService orderService; private final OrderReturnService returnService; + private final WeiXinProperties weiXinProperties; @Override @Transactional(rollbackFor = Exception.class) - public HwcResponse pay(String ip, Integer total, String timeExpire, String description, String openId, - String orderNum, PayTypeEnum status) throws IOException { + public HwcResponse pay(String ip, String total, String timeExpire, String description, String openId, + String orderNum, PayTypeEnum status) { SortedMap<String, String> map = new TreeMap<>(); map.put("service", service_pay); map.put("version", version); @@ -64,8 +66,8 @@ map.put("out_trade_no", orderNum); map.put("body", description); map.put("sub_openid", openId); - map.put("sub_appid", properties.getAppId()); - map.put("total_fee", String.valueOf(total)); + map.put("sub_appid", weiXinProperties.getAppId()); + map.put("total_fee", total); map.put("mch_create_ip", ip); map.put("notify_url", properties.getNotifyUrl()); map.put("time_expire", timeExpire); @@ -116,15 +118,15 @@ throw new BadRequestException("操作失败"); } } catch (Exception e) { - log.error("请求参数:{}", params); - log.error("返回参数:{}", resultMap); - throw new BadRequestException("系统异常:" + e.getMessage()); + log.error("汇旺财下单错误请求参数:{}", params); + log.error("汇旺财下单错误返回参数:{}", resultMap); + throw new BadRequestException("汇旺财下单错误:" + e.getMessage()); } finally { if (response != null) { - response.close(); + CloseUtil.close(response); } if (client != null) { - client.close(); + CloseUtil.close(client); } } } -- Gitblit v1.9.3