fix
This commit is contained in:
@@ -9,7 +9,6 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 余额明细对象 play_balance_details_info
|
* 余额明细对象 play_balance_details_info
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import javax.annotation.Resource;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 余额明细Service业务层处理
|
* 余额明细Service业务层处理
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import com.starry.admin.modules.custom.module.vo.PlayCustomRankingQueryVo;
|
|||||||
import com.starry.admin.modules.custom.module.vo.PlayCustomRankingReturnVo;
|
import com.starry.admin.modules.custom.module.vo.PlayCustomRankingReturnVo;
|
||||||
import com.starry.admin.modules.custom.module.vo.PlayCustomUserQueryVo;
|
import com.starry.admin.modules.custom.module.vo.PlayCustomUserQueryVo;
|
||||||
import com.starry.admin.modules.custom.module.vo.PlayCustomUserReturnVo;
|
import com.starry.admin.modules.custom.module.vo.PlayCustomUserReturnVo;
|
||||||
import com.starry.admin.modules.custom.service.IPlayCustomLevelInfoService;
|
|
||||||
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
|
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
|
||||||
import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity;
|
import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity;
|
||||||
import com.starry.admin.modules.order.service.impl.PlayOrderInfoServiceImpl;
|
import com.starry.admin.modules.order.service.impl.PlayOrderInfoServiceImpl;
|
||||||
@@ -72,7 +71,7 @@ public class PlayCustomUserInfoServiceImpl extends ServiceImpl<PlayCustomUserInf
|
|||||||
return rechargeAmount;
|
return rechargeAmount;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
BigDecimal paymentAmount = BigDecimal.valueOf(entity.getDiscount()).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP).add(rechargeAmount);
|
BigDecimal paymentAmount = BigDecimal.valueOf(entity.getDiscount()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).multiply(rechargeAmount);
|
||||||
log.info("等级为{}的顾客{},充值{}元,实际应该支付{}元", entity.getName(), customId, rechargeAmount, paymentAmount);
|
log.info("等级为{}的顾客{},充值{}元,实际应该支付{}元", entity.getName(), customId, rechargeAmount, paymentAmount);
|
||||||
return paymentAmount;
|
return paymentAmount;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -279,9 +279,10 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createRechargeOrder(String orderOn, BigDecimal orderMoney, BigDecimal finalAmount, String purchaserBy) {
|
public void createRechargeOrder(String orderId, BigDecimal orderMoney, BigDecimal finalAmount, String purchaserBy) {
|
||||||
PlayOrderInfoEntity entity = new PlayOrderInfoEntity(IdUtils.getUuid(), ORDER_STATUS_3, "0", "-1");
|
PlayOrderInfoEntity entity = new PlayOrderInfoEntity(IdUtils.getUuid(), ORDER_STATUS_3, "0", "-1");
|
||||||
entity.setOrderNo(orderOn);
|
entity.setOrderNo(this.getOrderNo());
|
||||||
|
entity.setId(orderId);
|
||||||
entity.setOrderMoney(orderMoney);
|
entity.setOrderMoney(orderMoney);
|
||||||
entity.setFinalAmount(finalAmount);
|
entity.setFinalAmount(finalAmount);
|
||||||
entity.setPurchaserBy(purchaserBy);
|
entity.setPurchaserBy(purchaserBy);
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
package com.starry.admin.modules.weichat.controller;
|
package com.starry.admin.modules.weichat.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
||||||
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderResult;
|
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
|
||||||
import com.github.binarywang.wxpay.util.SignUtils;
|
|
||||||
import com.starry.admin.common.aspect.CustomUserLogin;
|
import com.starry.admin.common.aspect.CustomUserLogin;
|
||||||
import com.starry.admin.common.conf.ThreadLocalRequestDetail;
|
import com.starry.admin.common.conf.ThreadLocalRequestDetail;
|
||||||
import com.starry.admin.common.exception.CustomException;
|
import com.starry.admin.common.exception.CustomException;
|
||||||
@@ -126,6 +121,15 @@ public class WxPlayController {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
@CustomUserLogin
|
||||||
|
@GetMapping("/custom/getCustomPaymentAmount")
|
||||||
|
public R getCustomPaymentAmount(@RequestParam("money") String money) {
|
||||||
|
if (StringUtils.isEmpty(money)) {
|
||||||
|
throw new CustomException("请求参数错误,money不能为空");
|
||||||
|
}
|
||||||
|
BigDecimal paymentAmount = customUserInfoService.getCustomPaymentAmount(new BigDecimal(money), ThreadLocalRequestDetail.getCustomUserInfo().getId());
|
||||||
|
return R.ok(paymentAmount);
|
||||||
|
}
|
||||||
@CustomUserLogin
|
@CustomUserLogin
|
||||||
@GetMapping("/custom/createOrder")
|
@GetMapping("/custom/createOrder")
|
||||||
public R createOrder(@RequestParam("money") String money) {
|
public R createOrder(@RequestParam("money") String money) {
|
||||||
@@ -143,42 +147,45 @@ public class WxPlayController {
|
|||||||
// 订单总金额,单位为分
|
// 订单总金额,单位为分
|
||||||
long totalFee = getTotalFee(money);
|
long totalFee = getTotalFee(money);
|
||||||
// 创建订单信息
|
// 创建订单信息
|
||||||
String orderNo = playOrderInfoService.getOrderNo();
|
// String orderNo = playOrderInfoService.getOrderNo();
|
||||||
orderInfoService.createRechargeOrder(orderNo, new BigDecimal(totalFee * 1.0 / 100), new BigDecimal(totalFee * 1.0 / 100), customUserInfo.getId());
|
String orderId = IdUtil.fastSimpleUUID();
|
||||||
|
orderInfoService.createRechargeOrder(orderId, new BigDecimal(totalFee * 1.0 / 100), new BigDecimal(totalFee * 1.0 / 100), customUserInfo.getId());
|
||||||
|
customUserInfoService.customAccountBalanceRecharge(new BigDecimal(money), ThreadLocalRequestDetail.getCustomUserInfo().getId(), orderId);
|
||||||
|
return R.ok("充值成功");
|
||||||
|
|
||||||
WxPayService wxPayService = mpService.getWxPay();
|
// WxPayService wxPayService = mpService.getWxPay();
|
||||||
WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
|
// WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
|
||||||
request.setOpenid(customUserInfo.getOpenid());
|
// request.setOpenid(customUserInfo.getOpenid());
|
||||||
// 订单总金额,单位为分(开发阶段固定设置为支付1分钱)
|
// // 订单总金额,单位为分(开发阶段固定设置为支付1分钱)
|
||||||
request.setTotalFee(1);
|
// request.setTotalFee(1);
|
||||||
request.setOutTradeNo(orderNo);
|
// request.setOutTradeNo(orderNo);
|
||||||
request.setTradeType("JSAPI");
|
// request.setTradeType("JSAPI");
|
||||||
request.setSpbillCreateIp("101.43.206.16");
|
// request.setSpbillCreateIp("101.43.206.16");
|
||||||
request.setNotifyUrl(wxPayService.getConfig().getNotifyUrl());
|
// request.setNotifyUrl(wxPayService.getConfig().getNotifyUrl());
|
||||||
request.setBody("船票充值");
|
// request.setBody("船票充值");
|
||||||
WxPayUnifiedOrderResult orderResult;
|
// WxPayUnifiedOrderResult orderResult;
|
||||||
try {
|
// try {
|
||||||
orderResult = wxPayService.unifiedOrder(request);
|
// orderResult = wxPayService.unifiedOrder(request);
|
||||||
} catch (WxPayException e) {
|
// } catch (WxPayException e) {
|
||||||
throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
String prepayId = orderResult.getPrepayId();
|
// String prepayId = orderResult.getPrepayId();
|
||||||
//组合参数构建支付
|
// //组合参数构建支付
|
||||||
Map<String, String> paySignInfo = new HashMap<>(5);
|
// Map<String, String> paySignInfo = new HashMap<>(5);
|
||||||
String timeStamp = String.valueOf(System.currentTimeMillis());
|
// String timeStamp = String.valueOf(System.currentTimeMillis());
|
||||||
String nonceStr = "dalfhh241lnandnsklajax";
|
// String nonceStr = "dalfhh241lnandnsklajax";
|
||||||
paySignInfo.put("appId", wxPayService.getConfig().getAppId());
|
// paySignInfo.put("appId", wxPayService.getConfig().getAppId());
|
||||||
paySignInfo.put("nonceStr", nonceStr);
|
// paySignInfo.put("nonceStr", nonceStr);
|
||||||
paySignInfo.put("timeStamp", timeStamp);
|
// paySignInfo.put("timeStamp", timeStamp);
|
||||||
paySignInfo.put("signType", "MD5");
|
// paySignInfo.put("signType", "MD5");
|
||||||
paySignInfo.put("package", "prepay_id=" + prepayId);
|
// paySignInfo.put("package", "prepay_id=" + prepayId);
|
||||||
String[] signInfo = new String[0];
|
// String[] signInfo = new String[0];
|
||||||
String paySign = SignUtils.createSign(paySignInfo, "MD5", wxPayService.getConfig().getMchKey(), signInfo);
|
// String paySign = SignUtils.createSign(paySignInfo, "MD5", wxPayService.getConfig().getMchKey(), signInfo);
|
||||||
|
//
|
||||||
//组合支付参数
|
// //组合支付参数
|
||||||
JSONObject jsonObject = new JSONObject().fluentPut("appId", wxPayService.getConfig().getAppId()).fluentPut("timeStamp", timeStamp).fluentPut("nonceStr", nonceStr).fluentPut("package", "prepay_id=" + prepayId).fluentPut("signType", "MD5").fluentPut("paySign", paySign);
|
// JSONObject jsonObject = new JSONObject().fluentPut("appId", wxPayService.getConfig().getAppId()).fluentPut("timeStamp", timeStamp).fluentPut("nonceStr", nonceStr).fluentPut("package", "prepay_id=" + prepayId).fluentPut("signType", "MD5").fluentPut("paySign", paySign);
|
||||||
return R.ok(jsonObject);
|
// return R.ok(jsonObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user