diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java index 60c21bf2..1c1d83bc 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java @@ -13,8 +13,10 @@ import com.xhpc.common.security.service.TokenService; import com.xhpc.common.util.UserTypeUtil; import com.xhpc.payment.domain.XhpcAppUser; import com.xhpc.common.domain.XhpcRechargeOrder; +import com.xhpc.payment.domain.XhpcSettingConfig; import com.xhpc.payment.domain.XhpcUserAccountStatement; import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; +import com.xhpc.payment.service.IXhpcCommonPayment; import com.xhpc.payment.service.IXhpcRechargeOrderService; import com.xhpc.payment.service.IXhpcRefundOrderService; import com.xhpc.system.api.model.LoginUser; @@ -58,31 +60,22 @@ public class WxPaymentController { @Autowired private IXhpcRechargeOrderService iXhpcRechargeOrderService; - @Autowired private XhpcUserAccountStatementMapper xhpcUserAccountStatementMapper; - @Autowired private IXhpcRefundOrderService iXhpcRefundOrderService; - @Autowired private Environment environment; - @Autowired private PowerPileService powerPileService; @Autowired private TokenService tokenService; @Autowired private UserTypeService userTypeService; - + @Autowired + private IXhpcCommonPayment xhpcCommonPayment; private static final Logger logger = LoggerFactory.getLogger(WxPaymentController.class); - private int number; - - @PostConstruct - public void init(){ - number =1; - } @PostMapping("/payment") @ApiOperation(value = "微信支付") @@ -119,6 +112,11 @@ public class WxPaymentController { if (0.0 == amount1) { return AjaxResult.error(HttpStatus.NOT_NULL, "充值金额不能为0"); } + XhpcSettingConfig xhpcSettingConfig = xhpcCommonPayment.getXhpcSettingConfigTenantId(UserTypeUtil.OPERATION_WX_TYPE, tenantId); + if(xhpcSettingConfig ==null){ + return AjaxResult.error(HttpStatus.ALREADY_EXISTING, "支付宝充值失败,继续充值请联系客服"); + } + //生成充值订单 XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.addRechargeOrder(userId, BigDecimal.valueOf(Double.parseDouble(amount)), "1", orderNumber,userType); //附加数据(否) @@ -143,7 +141,7 @@ public class WxPaymentController { BufferedReader in = null; StringBuffer result = new StringBuffer(); try { - URL realUrl = new URL(environment.getProperty("WXPAYUNIFIEDORDER")); + URL realUrl = new URL(xhpcSettingConfig.getWxPaymentUrl()); // 打开和URL之间的连接 URLConnection conn = realUrl.openConnection(); // 设置通用的请求属性 @@ -156,7 +154,7 @@ public class WxPaymentController { conn.setDoInput(true); // 获取URLConnection对象对应的输出流 out = new PrintWriter(conn.getOutputStream()); - out.print(createXMLParam(Fee, attach, tradeType, spbillCreateIp, outTradeNo, body, timeStr, environment.getProperty("SERVERDOMAIN"), environment.getProperty("APPID"), environment.getProperty("MCHID"), environment.getProperty("KEY"), openid)); + out.print(createXMLParam(Fee, attach, tradeType, spbillCreateIp, outTradeNo, body, timeStr, xhpcSettingConfig.getWxCallbackUrl(), xhpcSettingConfig.getWxAppId(), xhpcSettingConfig.getWxMchId(), xhpcSettingConfig.getWxMchKey(), openid)); // flush输出流的缓冲 out.flush(); // 定义BufferedReader输入流来读取URL的响应 @@ -185,7 +183,7 @@ public class WxPaymentController { } } //app - Map sign = createSign(result.toString(), Double.parseDouble(amount)); + Map sign = createSign(result.toString(), Double.parseDouble(amount),xhpcSettingConfig.getWxMchKey()); return AjaxResult.success(sign); } @@ -195,7 +193,7 @@ public class WxPaymentController { * @param result xml格式字符串 * @return */ - public Map createSign(String result, Double amount) { + public Map createSign(String result, Double amount,String key) { try { Map map = WXPayUtil.xmlToMap(result); String return_code = map.get("return_code"); @@ -217,7 +215,7 @@ public class WxPaymentController { map1.put("timestamp", timeStr); map1.put("sign", map.get("sign")); map1.put("url", map.get("code_url")); - map1.put("key", environment.getProperty("KEY")); + map1.put("key", key); return map1; } } catch (Exception e) { diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/dto/MechanismDto.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/dto/MechanismDto.java index 2e18a86a..aea58ae8 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/dto/MechanismDto.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/dto/MechanismDto.java @@ -11,7 +11,7 @@ import java.util.List; @Data public class MechanismDto { - private Integer id; + private String id; private String label; diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java index 6d81d152..b83ca544 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java @@ -119,7 +119,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map map:list) { MechanismDto mechanismDto =new MechanismDto(); String code = map.get("code").toString(); - mechanismDto.setId(Integer.valueOf(code)); + mechanismDto.setId("Shen"+code); mechanismDto.setLabel(map.get("name").toString()); List mechanismCityList =new ArrayList<>(); //市 @@ -127,7 +127,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map cityMap:cityList) { MechanismDto mechanismCity =new MechanismDto(); String codeCity = cityMap.get("code").toString(); - mechanismCity.setId(Integer.valueOf(codeCity)); + mechanismCity.setId("Shi"+codeCity); mechanismCity.setLabel(cityMap.get("name").toString()); List mechanismAreaList =new ArrayList<>(); //区 @@ -135,7 +135,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map areaMap:areaList) { MechanismDto mechanismArea =new MechanismDto(); String codeArea = areaMap.get("code").toString(); - mechanismArea.setId(Integer.valueOf(codeArea)); + mechanismArea.setId("Qu"+codeArea); mechanismArea.setLabel(areaMap.get("name").toString()); List mechanismOperatorList =new ArrayList<>(); //运营商 @@ -143,7 +143,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map operatorMap:operatorList) { MechanismDto mechanismOperator =new MechanismDto(); String operatorId = operatorMap.get("operatorId").toString(); - mechanismOperator.setId(Integer.valueOf(operatorId)); + mechanismOperator.setId("Yun"+operatorId); mechanismOperator.setLabel(operatorMap.get("name").toString()); List mechanismdataList =new ArrayList<>(); //场站 @@ -151,7 +151,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map dataMap:dataList) { MechanismDto mechanismData =new MechanismDto(); String codeData = dataMap.get("chargingStationId").toString(); - mechanismData.setId(Integer.valueOf(codeData)); + mechanismData.setId(codeData); mechanismData.setLabel(dataMap.get("name").toString()); mechanismdataList.add(mechanismData); } @@ -181,7 +181,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map operatorMap:operatorList) { MechanismDto mechanismOperator =new MechanismDto(); String operatorId = operatorMap.get("operatorId").toString(); - mechanismOperator.setId(Integer.valueOf(operatorId)); + mechanismOperator.setId("Yun"+operatorId); mechanismOperator.setLabel(operatorMap.get("name").toString()); List mechanismdataList =new ArrayList<>(); //场站 @@ -189,7 +189,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map dataMap:dataList) { MechanismDto mechanismData =new MechanismDto(); String codeData = dataMap.get("chargingStationId").toString(); - mechanismData.setId(Integer.valueOf(codeData)); + mechanismData.setId(codeData); mechanismData.setLabel(dataMap.get("name").toString()); mechanismdataList.add(mechanismData); } @@ -214,7 +214,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map operatorMap:operatorList) { MechanismDto mechanismOperator =new MechanismDto(); String operatorId = operatorMap.get("operatorId").toString(); - mechanismOperator.setId(Integer.valueOf(operatorId)); + mechanismOperator.setId("Yun"+operatorId); mechanismOperator.setLabel(operatorMap.get("name").toString()); List mechanismdataList =new ArrayList<>(); //省 @@ -222,7 +222,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map map:list) { MechanismDto mechanismDto =new MechanismDto(); String code = map.get("code").toString(); - mechanismDto.setId(Integer.valueOf(code)); + mechanismDto.setId("Shen"+code); mechanismDto.setLabel(map.get("name").toString()); List mechanismCityList =new ArrayList<>(); //市 @@ -230,7 +230,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map cityMap:cityList) { MechanismDto mechanismCity =new MechanismDto(); String codeCity = cityMap.get("code").toString(); - mechanismCity.setId(Integer.valueOf(codeCity)); + mechanismCity.setId("Shi"+codeCity); mechanismCity.setLabel(cityMap.get("name").toString()); List mechanismAreaList =new ArrayList<>(); //区 @@ -238,7 +238,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map areaMap:areaList) { MechanismDto mechanismArea =new MechanismDto(); String codeArea = areaMap.get("code").toString(); - mechanismArea.setId(Integer.valueOf(codeArea)); + mechanismArea.setId("Qu"+codeArea); mechanismArea.setLabel(areaMap.get("name").toString()); List mechanismOperatorList =new ArrayList<>(); //场站 @@ -246,7 +246,7 @@ public class IMechanismServiceImpl implements IMechanismService { for (Map dataMap:dataList) { MechanismDto mechanismData =new MechanismDto(); String codeData = dataMap.get("chargingStationId").toString(); - mechanismData.setId(Integer.valueOf(codeData)); + mechanismData.setId(codeData); mechanismData.setLabel(dataMap.get("name").toString()); mechanismOperatorList.add(mechanismData); }