修改充值退款接口
This commit is contained in:
parent
73d0e67213
commit
aeacac3ea6
@ -435,7 +435,6 @@ public class HxpcPileOrderController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xhpcHistoryOrder.setChargeOrderId(hxpcChargeOrder.getChargeOrderId());
|
||||
xhpcHistoryOrder.setChargingStationId(hxpcChargeOrder.getChargingStationId());
|
||||
xhpcHistoryOrder.setUserId(userId);
|
||||
|
||||
@ -13,6 +13,8 @@ import com.xhpc.payment.service.IXhpcRechargeOrderService;
|
||||
import com.xhpc.payment.service.IXhpcRefundOrderService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -58,6 +60,7 @@ public class WxPaymentController {
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
|
||||
@PostMapping("/payment")
|
||||
@ApiOperation(value = "微信支付")
|
||||
public AjaxResult payment(HttpServletRequest servletRequest, @RequestBody Map<String, Object> map) throws Exception {
|
||||
@ -69,6 +72,10 @@ public class WxPaymentController {
|
||||
String amount = StringUtils.valueOf(map.get("amount"));
|
||||
if (StringUtils.isEmpty(amount)) {
|
||||
return AjaxResult.error(HttpStatus.NOT_NULL, "充值金额不能为空");
|
||||
}else{
|
||||
if(new BigDecimal(5).compareTo(new BigDecimal(amount))==1){
|
||||
return AjaxResult.error(HttpStatus.NOT_NULL, "充值金额不能少于5元");
|
||||
}
|
||||
}
|
||||
//用户信息id
|
||||
String userId = StringUtils.valueOf(map.get("userId"));
|
||||
@ -321,7 +328,7 @@ public class WxPaymentController {
|
||||
*/
|
||||
@RequestMapping("/test")
|
||||
public void test() {
|
||||
paymentCallback("wx20210728172854", "4200001199202107286896883790");
|
||||
paymentCallback("000002020210820142215119", "4200001189202108202038629329");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -353,6 +360,7 @@ public class WxPaymentController {
|
||||
xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId());
|
||||
xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount());
|
||||
xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance());
|
||||
xhpcUserAccountStatement.setCreateTime(new Date());
|
||||
xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,6 +78,7 @@ public class XhpcRefundAuditController extends BaseController {
|
||||
@Transactional
|
||||
public AjaxResult info(@RequestBody XhpcRefundAudit xhpcRefundAudit) {
|
||||
Map<String, Object> map = iXhpcRefundOrderService.info(xhpcRefundAudit.getRefundOrderId());
|
||||
|
||||
if (null == map) {
|
||||
AjaxResult.error(HttpStatus.DATA_ERROR, "退款订单不存在");
|
||||
}
|
||||
@ -167,6 +168,7 @@ public class XhpcRefundAuditController extends BaseController {
|
||||
public Object enterpriseCheckOut(@RequestBody XhpcRefundAudit xhpcRefundAudit) {
|
||||
//只有审核通过才能退款
|
||||
Map<String, Object> xhpcRefundOrder = iXhpcRefundOrderService.info(xhpcRefundAudit.getRefundOrderId());
|
||||
|
||||
if (StringUtils.isNull(xhpcRefundOrder)) {
|
||||
return AjaxResult.error(HttpStatus.DATA_ERROR, "订单不存在");
|
||||
}
|
||||
@ -183,7 +185,8 @@ public class XhpcRefundAuditController extends BaseController {
|
||||
CloseableHttpClient httpClient = null;
|
||||
try {
|
||||
//证书的地址
|
||||
ConfigListener.getConf().get("certPath");
|
||||
String certPath = ConfigListener.getConf().get("certPath");
|
||||
System.out.println("certPath:"+certPath);
|
||||
httpClient = initCert();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -242,9 +245,9 @@ public class XhpcRefundAuditController extends BaseController {
|
||||
*/
|
||||
private CloseableHttpClient initCert() throws Exception {
|
||||
String path = "apiclient_cert.p12";
|
||||
File file = new File(this.getClass().getResource("/").getPath() + path);
|
||||
//File file = new File(this.getClass().getResource("/").getPath() + path);
|
||||
//线上地址
|
||||
//File file = new File("/www/wwwroot/msjd.project2.tingsun.net/" + path);
|
||||
File file = new File("/www/wwwroot/xhpc.scxhua.com/xhpc-payment/" + path);
|
||||
// 证书密码,默认为商户ID
|
||||
String key = environment.getProperty("MCHID");
|
||||
// 指定读取证书格式为PKCS12
|
||||
@ -317,6 +320,7 @@ public class XhpcRefundAuditController extends BaseController {
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult parseXml(String result, Long id, BigDecimal amount, String userId) {
|
||||
|
||||
try {
|
||||
Map<String, String> map = WXPayUtil.xmlToMap(result);
|
||||
String result_code = map.get("result_code");
|
||||
@ -330,7 +334,7 @@ public class XhpcRefundAuditController extends BaseController {
|
||||
//减少用户余额
|
||||
XhpcAppUser xhpcAppUser = new XhpcAppUser();
|
||||
xhpcAppUser.setAppUserId(Long.parseLong(userId));
|
||||
BigDecimal surplus = BigDecimal.valueOf(Double.valueOf(balance)).subtract(amount);
|
||||
BigDecimal surplus =new BigDecimal(balance).subtract(amount);
|
||||
xhpcAppUser.setBalance(surplus);
|
||||
xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser);
|
||||
}
|
||||
|
||||
@ -34,7 +34,11 @@ public class XhpcRefundOrderController extends BaseController {
|
||||
public AjaxResult enterpriseCheckOut(@RequestBody Map<String, Object> map) {
|
||||
String amount = StringUtils.valueOf(map.get("amount"));
|
||||
if (StringUtils.isEmpty(amount)) {
|
||||
return AjaxResult.error(HttpStatus.NOT_NULL, "充值金额不能为空");
|
||||
return AjaxResult.error(HttpStatus.NOT_NULL, "退款金额不能为空");
|
||||
}else{
|
||||
if(new BigDecimal(1).compareTo(new BigDecimal(amount))==1){
|
||||
return AjaxResult.error(HttpStatus.NOT_NULL, "退款金额不能少于1元");
|
||||
}
|
||||
}
|
||||
//用户信息id
|
||||
String userId = StringUtils.valueOf(map.get("userId"));
|
||||
|
||||
@ -144,7 +144,7 @@
|
||||
<update id="updateAppUserBalance" parameterType="com.xhpc.payment.domain.XhpcAppUser">
|
||||
UPDATE xhpc_app_user
|
||||
<set>
|
||||
<if test="null != balance">balance = #{balance},</if>
|
||||
<if test="null != balance">balance = #{balance}</if>
|
||||
</set>
|
||||
WHERE app_user_id = #{appUserId}
|
||||
</update>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user