修改微信支付配置

This commit is contained in:
yuyang 2022-01-10 10:50:05 +08:00
parent e70cc61941
commit e675e8e795
3 changed files with 27 additions and 29 deletions

View File

@ -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<String, String> sign = createSign(result.toString(), Double.parseDouble(amount));
Map<String, String> 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<String, String> createSign(String result, Double amount) {
public Map<String, String> createSign(String result, Double amount,String key) {
try {
Map<String, String> 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) {

View File

@ -11,7 +11,7 @@ import java.util.List;
@Data
public class MechanismDto {
private Integer id;
private String id;
private String label;

View File

@ -119,7 +119,7 @@ public class IMechanismServiceImpl implements IMechanismService {
for (Map<String, Object> 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<MechanismDto> mechanismCityList =new ArrayList<>();
//
@ -127,7 +127,7 @@ public class IMechanismServiceImpl implements IMechanismService {
for (Map<String, Object> 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<MechanismDto> mechanismAreaList =new ArrayList<>();
//
@ -135,7 +135,7 @@ public class IMechanismServiceImpl implements IMechanismService {
for (Map<String, Object> 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<MechanismDto> mechanismOperatorList =new ArrayList<>();
//运营商
@ -143,7 +143,7 @@ public class IMechanismServiceImpl implements IMechanismService {
for (Map<String, Object> 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<MechanismDto> mechanismdataList =new ArrayList<>();
//场站
@ -151,7 +151,7 @@ public class IMechanismServiceImpl implements IMechanismService {
for (Map<String, Object> 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<String, Object> 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<MechanismDto> mechanismdataList =new ArrayList<>();
//场站
@ -189,7 +189,7 @@ public class IMechanismServiceImpl implements IMechanismService {
for (Map<String, Object> 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<String, Object> 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<MechanismDto> mechanismdataList =new ArrayList<>();
//
@ -222,7 +222,7 @@ public class IMechanismServiceImpl implements IMechanismService {
for (Map<String, Object> 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<MechanismDto> mechanismCityList =new ArrayList<>();
//
@ -230,7 +230,7 @@ public class IMechanismServiceImpl implements IMechanismService {
for (Map<String, Object> 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<MechanismDto> mechanismAreaList =new ArrayList<>();
//
@ -238,7 +238,7 @@ public class IMechanismServiceImpl implements IMechanismService {
for (Map<String, Object> 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<MechanismDto> mechanismOperatorList =new ArrayList<>();
//场站
@ -246,7 +246,7 @@ public class IMechanismServiceImpl implements IMechanismService {
for (Map<String, Object> 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);
}