mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-11 18:59:51 +08:00
单元测试 在线支付订单、退款
This commit is contained in:
@@ -231,23 +231,32 @@ public class SpringBootTestController {
|
||||
// 生成订单
|
||||
// OrderBasicInfo orderBasicInfo = generateAnOrder();
|
||||
// System.out.println(orderBasicInfo);
|
||||
// 支付订单
|
||||
// // 支付订单
|
||||
// int a = payOrder(orderBasicInfo);
|
||||
// System.out.println(a);
|
||||
// 结算订单
|
||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode("C65033300551");
|
||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode("C46006767636");
|
||||
settleOrder(orderBasicInfo);
|
||||
// 订单退款
|
||||
BigDecimal payAmount = orderBasicInfo.getPayAmount();
|
||||
BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
||||
|
||||
BigDecimal refundAmt = payAmount.subtract(settleAmount);
|
||||
// 延时分账的,可以部分解冻
|
||||
memberAdapayRecordService.updateRefundAmountFromFreezeAmount("1234", refundAmt);
|
||||
|
||||
// 实时分账,全部解冻
|
||||
// memberAdapayRecordService.unfreezeAmountAndUpdateSpendAmount("test01", payAmount, refundAmt);
|
||||
}
|
||||
|
||||
// 生成订单
|
||||
private OrderBasicInfo generateAnOrder() throws ParseException {
|
||||
GenerateOrderDTO dto = new GenerateOrderDTO();
|
||||
PileConnectorDetailVO vo = new PileConnectorDetailVO();
|
||||
vo.setStationId("2");
|
||||
dto.setPileConnector(vo);
|
||||
|
||||
dto.setMemberId("67945248");
|
||||
dto.setMemberId("1");
|
||||
dto.setStartMode("1");
|
||||
dto.setPayMode("4");
|
||||
dto.setPileSn("88000000000001");
|
||||
@@ -261,6 +270,7 @@ public class SpringBootTestController {
|
||||
return orderBasicInfo;
|
||||
}
|
||||
|
||||
// 支付订单
|
||||
private int payOrder(OrderBasicInfo orderBasicInfo) throws Exception {
|
||||
// PayOrderDTO dto = new PayOrderDTO();
|
||||
// dto.setMemberId(orderBasicInfo.getMemberId());
|
||||
@@ -271,7 +281,7 @@ public class SpringBootTestController {
|
||||
//
|
||||
// Map<String, Object> map = orderBasicInfoService.payOrder(dto);
|
||||
// return map;
|
||||
String paymentId = "test01";
|
||||
String paymentId = "1234";
|
||||
BigDecimal amount = orderBasicInfo.getPayAmount();
|
||||
String orderCode = orderBasicInfo.getOrderCode();
|
||||
|
||||
@@ -315,7 +325,7 @@ public class SpringBootTestController {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 结算订单
|
||||
private void settleOrder(OrderBasicInfo orderBasicInfo) {
|
||||
TransactionRecordsData data = TransactionRecordsData.builder()
|
||||
.transactionCode(orderBasicInfo.getTransactionCode())
|
||||
@@ -346,7 +356,16 @@ public class SpringBootTestController {
|
||||
|
||||
.build();
|
||||
|
||||
orderBasicInfoService.settleOrder(data, orderBasicInfo);
|
||||
// orderBasicInfoService.settleOrder(data, orderBasicInfo);
|
||||
// 获取更新数据后的orderBasicInfo对象
|
||||
orderBasicInfoService.returnUpdateOrderBasicInfo(orderBasicInfo, data);
|
||||
// 获取更新数据后的orderDetail对象/更新订单详情 查询订单详情 修改订单数据
|
||||
OrderDetail orderDetail = orderBasicInfoService.returnUpdateOrderDetail(orderBasicInfo, data);
|
||||
// 更新数据库
|
||||
OrderTransactionDTO dto = new OrderTransactionDTO();
|
||||
dto.setOrderBasicInfo(orderBasicInfo);
|
||||
dto.setOrderDetail(orderDetail);
|
||||
transactionService.doUpdateOrder(dto);
|
||||
}
|
||||
|
||||
|
||||
@@ -1198,7 +1217,7 @@ public class SpringBootTestController {
|
||||
length = 17;
|
||||
byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String vinCode = BytesUtil.ascii2Str(vinCodeByteArr);
|
||||
System.out.println("桩号:" + pileSn +"申请充电VIN码:" + vinCode);
|
||||
System.out.println("桩号:" + pileSn + "申请充电VIN码:" + vinCode);
|
||||
|
||||
/**
|
||||
* 刷卡启动充电
|
||||
@@ -1234,15 +1253,15 @@ public class SpringBootTestController {
|
||||
accountBalanceByteArr = YKCUtils.getPriceByte(String.valueOf(map.get("accountBalance")), 2);
|
||||
// 鉴权成功标识 0x00 失败 0x01 成功
|
||||
authenticationFlagByteArr = Constants.oneByteArray;
|
||||
}else {
|
||||
} else {
|
||||
throw new BusinessException("", "生成vin订单失败");
|
||||
}
|
||||
}
|
||||
}catch (BusinessException e){
|
||||
} catch (BusinessException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("1");
|
||||
// log.error("VIN码启动充电鉴权 error:{}, {}", e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("2");
|
||||
transactionCode = "00000000000000000000000000000000";
|
||||
@@ -2043,7 +2062,7 @@ public class SpringBootTestController {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMemberToken(){
|
||||
public void testGetMemberToken() {
|
||||
String memberId = JWTUtils.getMemberId("eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NzY1MTY5MzgsImV4cCI6MTY3OTEwODkzOH0.4MwhZIOpnCfQloR7zEm2hwPOh2yyI2qxbBbTcv_SnZ4");
|
||||
System.out.println(memberId);
|
||||
}
|
||||
|
||||
@@ -339,4 +339,7 @@ public interface IOrderBasicInfoService {
|
||||
*/
|
||||
void retryRefundOrder(String orderCode) throws BaseAdaPayException;
|
||||
|
||||
void returnUpdateOrderBasicInfo(OrderBasicInfo orderBasicInfo, TransactionRecordsData data);
|
||||
|
||||
OrderDetail returnUpdateOrderDetail(OrderBasicInfo orderBasicInfo, TransactionRecordsData data);
|
||||
}
|
||||
|
||||
@@ -889,7 +889,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
* 返回更新后的OrderBasicInfo对象
|
||||
* 专用方法,其他地方如果要用请仔细检查
|
||||
*/
|
||||
private void returnUpdateOrderBasicInfo(OrderBasicInfo orderBasicInfo, TransactionRecordsData data) {
|
||||
public void returnUpdateOrderBasicInfo(OrderBasicInfo orderBasicInfo, TransactionRecordsData data) {
|
||||
// 订单编号
|
||||
String orderCode = orderBasicInfo.getOrderCode();
|
||||
// 消费金额就是订单总金额/交易记录传过来的消费金额
|
||||
@@ -929,7 +929,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
*
|
||||
* @return 查询并更新过数据的orderDetail
|
||||
*/
|
||||
private OrderDetail returnUpdateOrderDetail(OrderBasicInfo orderBasicInfo, TransactionRecordsData data) {
|
||||
public OrderDetail returnUpdateOrderDetail(OrderBasicInfo orderBasicInfo, TransactionRecordsData data) {
|
||||
String orderCode = orderBasicInfo.getOrderCode();
|
||||
BigDecimal orderAmount = orderBasicInfo.getOrderAmount();
|
||||
// 更新订单详情 查询订单详情 修改订单数据
|
||||
|
||||
Reference in New Issue
Block a user