2023-05-26 19:25:35 +08:00
|
|
|
|
import cn.hutool.json.JSONUtil;
|
2023-05-27 11:55:45 +08:00
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
2023-09-14 17:36:45 +08:00
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
2023-05-31 16:05:18 +08:00
|
|
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
2023-05-30 16:33:49 +08:00
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
2023-06-26 17:10:36 +08:00
|
|
|
|
import com.google.common.collect.Lists;
|
2023-05-27 16:01:27 +08:00
|
|
|
|
import com.google.common.collect.Maps;
|
2023-07-17 16:44:04 +08:00
|
|
|
|
import com.google.common.collect.Sets;
|
2023-06-12 17:38:16 +08:00
|
|
|
|
import com.google.common.primitives.Bytes;
|
2023-06-15 14:06:33 +08:00
|
|
|
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
2023-08-25 16:07:15 +08:00
|
|
|
|
import com.huifu.adapay.model.Payment;
|
2023-05-27 16:01:27 +08:00
|
|
|
|
import com.huifu.adapay.model.Refund;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.JsowellApplication;
|
2023-08-15 11:02:02 +08:00
|
|
|
|
import com.jsowell.adapay.config.AbstractAdapayConfig;
|
2023-08-21 08:52:32 +08:00
|
|
|
|
import com.jsowell.adapay.dto.QueryAcctFlowDTO;
|
2023-08-21 16:19:33 +08:00
|
|
|
|
import com.jsowell.adapay.dto.QueryPaymentConfirmDTO;
|
2023-08-21 15:37:00 +08:00
|
|
|
|
import com.jsowell.adapay.dto.SettleAccountDTO;
|
2023-08-15 11:02:02 +08:00
|
|
|
|
import com.jsowell.adapay.factory.AdapayConfigFactory;
|
2023-09-28 09:16:44 +08:00
|
|
|
|
import com.jsowell.adapay.response.PaymentConfirmResponse;
|
2023-08-21 16:19:33 +08:00
|
|
|
|
import com.jsowell.adapay.response.QueryPaymentConfirmDetailResponse;
|
2023-08-18 09:52:12 +08:00
|
|
|
|
import com.jsowell.adapay.service.AdapayService;
|
2023-08-21 13:20:17 +08:00
|
|
|
|
import com.jsowell.adapay.vo.DrawCashDetailVO;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.constant.CacheConstants;
|
|
|
|
|
|
import com.jsowell.common.constant.Constants;
|
2023-05-30 13:45:56 +08:00
|
|
|
|
import com.jsowell.common.core.domain.entity.SysDictData;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.core.domain.ykc.LoginRequestData;
|
|
|
|
|
|
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
|
|
|
|
|
import com.jsowell.common.core.redis.RedisCache;
|
2023-08-30 10:13:56 +08:00
|
|
|
|
import com.jsowell.common.enums.AcquirerEnum;
|
2023-08-01 16:16:34 +08:00
|
|
|
|
import com.jsowell.common.enums.DelFlagEnum;
|
2023-07-08 11:33:45 +08:00
|
|
|
|
import com.jsowell.common.enums.ykc.*;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.exception.BusinessException;
|
2023-05-10 08:49:01 +08:00
|
|
|
|
import com.jsowell.common.util.*;
|
2023-07-08 09:58:20 +08:00
|
|
|
|
import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil;
|
2023-05-30 14:22:34 +08:00
|
|
|
|
import com.jsowell.common.util.http.HttpUtils;
|
2023-07-08 09:58:20 +08:00
|
|
|
|
import com.jsowell.common.util.id.IdUtils;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.util.id.SnowflakeIdWorker;
|
|
|
|
|
|
import com.jsowell.common.util.ip.AddressUtils;
|
|
|
|
|
|
import com.jsowell.netty.handler.HeartbeatRequestHandler;
|
2023-07-08 09:58:20 +08:00
|
|
|
|
import com.jsowell.netty.handler.TransactionRecordsRequestHandler;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.netty.service.yunkuaichong.YKCBusinessService;
|
2023-05-26 19:25:35 +08:00
|
|
|
|
import com.jsowell.pile.domain.*;
|
2023-06-26 17:10:36 +08:00
|
|
|
|
import com.jsowell.pile.domain.ykcCommond.IssueQRCodeCommand;
|
|
|
|
|
|
import com.jsowell.pile.domain.ykcCommond.ProofreadTimeCommand;
|
2023-05-10 08:49:01 +08:00
|
|
|
|
import com.jsowell.pile.dto.*;
|
2023-06-26 17:10:36 +08:00
|
|
|
|
import com.jsowell.pile.dto.amap.GetStationInfoDTO;
|
2023-08-24 10:33:26 +08:00
|
|
|
|
import com.jsowell.pile.dto.lutongyunting.BindCouponDTO;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.pile.mapper.MemberBasicInfoMapper;
|
|
|
|
|
|
import com.jsowell.pile.mapper.PileBillingTemplateMapper;
|
2023-05-26 19:25:35 +08:00
|
|
|
|
import com.jsowell.pile.service.*;
|
2023-09-14 17:36:45 +08:00
|
|
|
|
import com.jsowell.pile.service.orderlogic.AbstractOrderLogic;
|
|
|
|
|
|
import com.jsowell.pile.service.orderlogic.OrderLogicFactory;
|
2023-08-29 16:03:43 +08:00
|
|
|
|
import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
|
|
|
|
|
|
import com.jsowell.pile.transaction.service.TransactionService;
|
|
|
|
|
|
import com.jsowell.pile.util.SnUtils;
|
2023-06-26 14:40:03 +08:00
|
|
|
|
import com.jsowell.pile.vo.base.PileInfoVO;
|
2023-07-08 11:33:45 +08:00
|
|
|
|
import com.jsowell.pile.vo.uniapp.MemberVO;
|
2023-08-30 10:13:56 +08:00
|
|
|
|
import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO;
|
2023-08-11 11:04:28 +08:00
|
|
|
|
import com.jsowell.pile.vo.web.BalanceDeductionAmountVO;
|
2023-03-07 16:55:03 +08:00
|
|
|
|
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
|
|
|
|
|
import com.jsowell.pile.vo.web.OrderListVO;
|
|
|
|
|
|
import com.jsowell.pile.vo.web.PileDetailVO;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.service.MemberService;
|
|
|
|
|
|
import com.jsowell.service.OrderService;
|
|
|
|
|
|
import com.jsowell.service.PileService;
|
2023-06-17 10:37:02 +08:00
|
|
|
|
import com.jsowell.thirdparty.amap.service.AMapService;
|
2023-05-27 15:56:26 +08:00
|
|
|
|
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
2023-05-26 16:14:45 +08:00
|
|
|
|
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
2023-05-26 19:25:35 +08:00
|
|
|
|
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
|
|
|
|
|
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
|
|
|
|
|
import com.jsowell.thirdparty.lianlian.util.GBSignUtils;
|
2023-08-23 14:13:11 +08:00
|
|
|
|
import com.jsowell.thirdparty.lutongyunting.service.LTYTService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.wxpay.common.WeChatPayParameter;
|
|
|
|
|
|
import com.jsowell.wxpay.dto.AppletTemplateMessageSendDTO;
|
|
|
|
|
|
import com.jsowell.wxpay.response.WechatPayRefundRequest;
|
|
|
|
|
|
import com.jsowell.wxpay.service.WxAppletRemoteService;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2023-07-28 14:47:26 +08:00
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import org.springframework.util.StopWatch;
|
|
|
|
|
|
|
2023-05-26 19:25:35 +08:00
|
|
|
|
import java.io.UnsupportedEncodingException;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import java.math.BigDecimal;
|
2023-06-08 11:50:06 +08:00
|
|
|
|
import java.nio.charset.StandardCharsets;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
2023-05-10 08:49:01 +08:00
|
|
|
|
import java.util.*;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
@ActiveProfiles("dev")
|
|
|
|
|
|
@SpringBootTest(classes = JsowellApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
|
|
|
|
@RunWith(SpringRunner.class)
|
|
|
|
|
|
public class SpringBootTestController {
|
|
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private SnUtils snUtils;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileService pileService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private YKCPushCommandService ykcPushCommandService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IAdapayMemberAccountService adapayMemberAccountService;
|
2023-07-13 15:27:09 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IPileMsgRecordService pileMsgRecordService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IPileStationInfoService pileStationInfoService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private YKCPushCommandService ykcPushBusinessService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private HeartbeatRequestHandler heartbeatRequestHandler;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private YKCBusinessService ykcBusinessService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileBillingTemplateMapper pileBillingTemplateMapper;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileRemoteService pileRemoteService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private MemberService memberService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private OrderService orderService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IPileBillingTemplateService pileBillingTemplateService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private MemberBasicInfoMapper memberBasicInfoMapper;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private SimCardService simCardService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IPileBasicInfoService pileBasicInfoService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private WechatPayService wechatPayService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IOrderBasicInfoService orderBasicInfoService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private WxpayCallbackRecordService wxpayCallbackRecordService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private WxAppletRemoteService wxAppletRemoteService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private RedisCache redisCache;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IPileAuthCardService pileAuthCardService;
|
2023-04-01 15:33:36 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private LianLianService lianLianService;
|
2023-05-10 08:49:01 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IMemberTransactionRecordService memberTransactionRecordService;
|
2023-05-30 15:02:57 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IMemberPlateNumberRelationService memberPlateNumberRelationService;
|
2023-06-12 17:38:16 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
static final String MAC_KEY = "53TtFpc4gdVZbF3x";
|
2023-05-10 08:49:01 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
static final String ALGORITHM_MAC = "HmacMD5";
|
2023-05-10 08:49:01 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private AdapayCallbackRecordService adapayCallbackRecordService;
|
2023-05-27 11:20:43 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IAdapayRefundRecordService adapayRefundRecordService;
|
2023-05-31 16:05:18 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private AdapayService adapayService;
|
2023-06-15 14:06:33 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private AMapService aMapService;
|
2023-06-17 10:37:02 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IPileConnectorInfoService pileConnectorInfoService;
|
2023-07-08 15:37:53 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private TransactionRecordsRequestHandler transactionRecordsRequestHandler;
|
2023-07-08 09:58:20 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IMemberBasicInfoService memberBasicInfoService;
|
2023-07-08 11:33:45 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private ClearingWithdrawInfoService clearingWithdrawInfoService;
|
2023-08-01 16:16:34 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private OrderPileOccupyService orderPileOccupyService;
|
2023-08-08 08:43:50 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private LTYTService ltytService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IPileMerchantInfoService pileMerchantInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private MemberAdapayRecordService memberAdapayRecordService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private TransactionService transactionService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private OrderPayRecordService orderPayRecordService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 单元测试,测试订单流程
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testTheOrderProcess() throws Exception {
|
|
|
|
|
|
// 生成订单
|
|
|
|
|
|
// OrderBasicInfo orderBasicInfo = generateAnOrder();
|
|
|
|
|
|
// System.out.println(orderBasicInfo);
|
|
|
|
|
|
// // 支付订单
|
|
|
|
|
|
// int a = payOrder(orderBasicInfo);
|
|
|
|
|
|
// System.out.println(a);
|
|
|
|
|
|
// 结算订单
|
|
|
|
|
|
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("1");
|
|
|
|
|
|
dto.setStartMode("1");
|
|
|
|
|
|
dto.setPayMode("4");
|
|
|
|
|
|
dto.setPileSn("88000000000001");
|
|
|
|
|
|
dto.setConnectorCode("01");
|
|
|
|
|
|
dto.setChargeAmount(new BigDecimal("10"));
|
|
|
|
|
|
// 查询充电桩的计费模板
|
|
|
|
|
|
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(dto.getPileSn());
|
|
|
|
|
|
dto.setBillingTemplate(billingTemplateVO);
|
|
|
|
|
|
OrderBasicInfo orderBasicInfo = orderBasicInfoService.saveOrder2Database(dto);
|
|
|
|
|
|
|
|
|
|
|
|
return orderBasicInfo;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 支付订单
|
|
|
|
|
|
private int payOrder(OrderBasicInfo orderBasicInfo) throws Exception {
|
|
|
|
|
|
// PayOrderDTO dto = new PayOrderDTO();
|
|
|
|
|
|
// dto.setMemberId(orderBasicInfo.getMemberId());
|
|
|
|
|
|
// dto.setOrderCode(orderBasicInfo.getOrderCode());
|
|
|
|
|
|
// dto.setStartMode(orderBasicInfo.getStartMode());
|
|
|
|
|
|
// dto.setPayMode(orderBasicInfo.getPayMode());
|
|
|
|
|
|
// dto.setPayAmount(orderBasicInfo.getPayAmount());
|
|
|
|
|
|
//
|
|
|
|
|
|
// Map<String, Object> map = orderBasicInfoService.payOrder(dto);
|
|
|
|
|
|
// return map;
|
|
|
|
|
|
String paymentId = "1234";
|
|
|
|
|
|
BigDecimal amount = orderBasicInfo.getPayAmount();
|
|
|
|
|
|
String orderCode = orderBasicInfo.getOrderCode();
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
|
json.put("paymentId", paymentId);
|
|
|
|
|
|
json.put("amount", amount);
|
|
|
|
|
|
|
|
|
|
|
|
// 记录订单支付流水
|
|
|
|
|
|
OrderPayRecord orderPayRecord = OrderPayRecord.builder()
|
|
|
|
|
|
.orderCode(orderCode)
|
|
|
|
|
|
.payMode(OrderPayRecordEnum.WECHATPAY_PAYMENT.getValue())
|
|
|
|
|
|
.payAmount(amount)
|
|
|
|
|
|
.acquirer(AcquirerEnum.ADAPAY.getValue())
|
|
|
|
|
|
.deductionRecord(json.toJSONString())
|
|
|
|
|
|
.createBy(null)
|
2023-08-31 10:30:05 +08:00
|
|
|
|
.delFlag(DelFlagEnum.NORMAL.getValue())
|
2023-08-30 11:02:18 +08:00
|
|
|
|
.build();
|
|
|
|
|
|
orderPayRecordService.batchInsert(Lists.newArrayList(orderPayRecord));
|
|
|
|
|
|
|
|
|
|
|
|
// 更新冻结金额 支付成功后全部冻结
|
|
|
|
|
|
memberAdapayRecordService.updateFreezeAmount(paymentId, amount);
|
|
|
|
|
|
|
|
|
|
|
|
// 支付订单成功
|
|
|
|
|
|
PayOrderSuccessCallbackDTO callbackDTO = PayOrderSuccessCallbackDTO.builder()
|
|
|
|
|
|
.orderCode(orderCode)
|
|
|
|
|
|
.payAmount(amount)
|
|
|
|
|
|
.payMode(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())
|
|
|
|
|
|
.acquirer(AcquirerEnum.ADAPAY.getValue())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
// 订单支付成功 支付回调
|
|
|
|
|
|
// orderBasicInfoService.payOrderSuccessCallback(callbackDTO);
|
|
|
|
|
|
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(callbackDTO.getOrderCode());
|
|
|
|
|
|
|
|
|
|
|
|
// 修改订单
|
|
|
|
|
|
orderInfo.setPayMode(callbackDTO.getPayMode());
|
|
|
|
|
|
orderInfo.setPayStatus(Constants.ONE);
|
|
|
|
|
|
orderInfo.setPayAmount(callbackDTO.getPayAmount());
|
|
|
|
|
|
orderInfo.setPayTime(new Date());
|
|
|
|
|
|
orderInfo.setChargeStartTime(new Date());
|
|
|
|
|
|
orderInfo.setOrderStatus(OrderStatusEnum.IN_THE_CHARGING.getValue());
|
|
|
|
|
|
return orderBasicInfoService.updateOrderBasicInfo(orderInfo);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 结算订单
|
|
|
|
|
|
private void settleOrder(OrderBasicInfo orderBasicInfo) {
|
|
|
|
|
|
TransactionRecordsData data = TransactionRecordsData.builder()
|
|
|
|
|
|
.transactionCode(orderBasicInfo.getTransactionCode())
|
|
|
|
|
|
.pileSn(orderBasicInfo.getPileSn())
|
|
|
|
|
|
.connectorCode(orderBasicInfo.getConnectorCode())
|
|
|
|
|
|
.startTime("2023-03-10 17:10:24")
|
|
|
|
|
|
.endTime("2023-03-10 17:10:46")
|
|
|
|
|
|
.sharpPrice("1.10000")
|
|
|
|
|
|
.sharpUsedElectricity("2.0000")
|
|
|
|
|
|
.sharpAmount("2.2000")
|
|
|
|
|
|
.peakPrice("1.20000")
|
|
|
|
|
|
.peakUsedElectricity("0")
|
|
|
|
|
|
.peakAmount("0")
|
|
|
|
|
|
.flatPrice("1.30000")
|
|
|
|
|
|
.flatUsedElectricity("0")
|
|
|
|
|
|
.flatAmount("0")
|
|
|
|
|
|
.valleyPrice("1.40000")
|
|
|
|
|
|
.valleyUsedElectricity("0")
|
|
|
|
|
|
.valleyAmount("0")
|
|
|
|
|
|
.totalElectricity("2")
|
|
|
|
|
|
.consumptionAmount("5.3000")
|
|
|
|
|
|
.vinCode("\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000")
|
|
|
|
|
|
.transactionIdentifier("01")
|
|
|
|
|
|
.transactionTime("2023-03-10 17:10:46")
|
|
|
|
|
|
.stopReasonMsg("结束充电,APP远程停止")
|
|
|
|
|
|
.logicCard("0")
|
|
|
|
|
|
.createTime(new Date())
|
|
|
|
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-14 17:36:45 +08:00
|
|
|
|
public static List<BigDecimal> calculateRefund(BigDecimal totalAmount, List<BigDecimal> payments) {
|
|
|
|
|
|
List<BigDecimal> refundList = new ArrayList<>();
|
|
|
|
|
|
BigDecimal remainingAmount = totalAmount;
|
|
|
|
|
|
|
|
|
|
|
|
for (BigDecimal payment : payments) {
|
|
|
|
|
|
if (remainingAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
|
// refundList.add(BigDecimal.ZERO);
|
|
|
|
|
|
refundList.add(payment);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
BigDecimal refundPerPayment = remainingAmount.min(payment);
|
|
|
|
|
|
// refundList.add(refundPerPayment);
|
|
|
|
|
|
refundList.add(payment.subtract(refundPerPayment));
|
|
|
|
|
|
remainingAmount = remainingAmount.subtract(refundPerPayment);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return refundList;
|
|
|
|
|
|
}
|
2023-08-30 11:02:18 +08:00
|
|
|
|
|
2023-09-14 17:36:45 +08:00
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
BigDecimal totalAmount = new BigDecimal("0.1");
|
|
|
|
|
|
List<BigDecimal> payments = Lists.newArrayList(new BigDecimal("0.97"), new BigDecimal("1.00"));
|
|
|
|
|
|
|
|
|
|
|
|
List<BigDecimal> refunds = calculateRefund(totalAmount, payments);
|
|
|
|
|
|
System.out.println("每笔单需要退还的金额: " + refunds);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 测试多笔支付情况,解冻部分金额
|
|
|
|
|
|
*/
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Test
|
|
|
|
|
|
public void calculateUnfreezeAmountTest() {
|
2023-09-14 17:36:45 +08:00
|
|
|
|
BigDecimal orderAmount = new BigDecimal("0.06");
|
2023-08-30 11:02:18 +08:00
|
|
|
|
List<OrderPayRecord> payRecordList = Lists.newArrayList();
|
|
|
|
|
|
// 第一笔支付记录
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
2023-08-31 18:35:16 +08:00
|
|
|
|
jsonObject.put("paymentId", "002212023083114213410543206907226374144");
|
2023-09-14 17:36:45 +08:00
|
|
|
|
jsonObject.put("amount", "0.97");
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject2 = new JSONObject();
|
|
|
|
|
|
jsonObject2.put("paymentId", "002212023083114213410543206907226374144");
|
|
|
|
|
|
jsonObject2.put("amount", "1");
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
|
|
|
jsonArray.add(jsonObject);
|
|
|
|
|
|
jsonArray.add(jsonObject2);
|
|
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
OrderPayRecord build = OrderPayRecord.builder()
|
2023-09-14 17:36:45 +08:00
|
|
|
|
.payAmount(new BigDecimal("1.97"))
|
|
|
|
|
|
.deductionRecord(jsonArray.toJSONString())
|
2023-08-30 11:02:18 +08:00
|
|
|
|
.build();
|
|
|
|
|
|
payRecordList.add(build);
|
|
|
|
|
|
|
2023-09-14 17:36:45 +08:00
|
|
|
|
AbstractOrderLogic orderLogic = OrderLogicFactory.getOrderLogic("1");
|
|
|
|
|
|
List<Map<String, Object>> maps = orderLogic.calculateUnfreezeAmount(orderAmount, payRecordList);
|
2023-08-30 11:02:18 +08:00
|
|
|
|
System.out.println(maps);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void unfreezeAmountAndUpdateSpendAmountTest() {
|
|
|
|
|
|
String paymentId = "123";
|
|
|
|
|
|
memberAdapayRecordService.updateRefundAmount(paymentId, new BigDecimal("5"));
|
|
|
|
|
|
// memberAdapayRecordService.updateRefundAmountFromFreezeAmount(paymentId, new BigDecimal("20"));
|
|
|
|
|
|
// BigDecimal unfreezeAmount = new BigDecimal("32");
|
|
|
|
|
|
// BigDecimal spendAmount = new BigDecimal("10");
|
|
|
|
|
|
// memberAdapayRecordService.unfreezeAmountAndUpdateSpendAmount(paymentId, unfreezeAmount, spendAmount);
|
|
|
|
|
|
// memberAdapayRecordService.updateRefundAmountFromFreezeAmount(paymentId, new BigDecimal("2"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void getFirstLevelMerchantByMerchantIdTest() {
|
|
|
|
|
|
String merchantId = "13";
|
|
|
|
|
|
PileMerchantInfo merchantInfo = pileMerchantInfoService.getFirstLevelMerchantByMerchantId(merchantId);
|
|
|
|
|
|
System.out.println(JSON.toJSONString(merchantInfo));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void queryPaymentInfoTest() throws BaseAdaPayException {
|
|
|
|
|
|
String wechatAppId = "wxbb3e0d474569481d";
|
|
|
|
|
|
String paymentId = "002212023082514501110541039779091623936";
|
|
|
|
|
|
// 在完成初始化设置情况下,调用查询方法,获取 Payment 查询结果
|
|
|
|
|
|
Map<String, Object> response = Payment.query(paymentId, wechatAppId);
|
|
|
|
|
|
System.out.println(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 手动变更银行卡信息
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void createSettleAccountRequestTest() throws BaseAdaPayException {
|
|
|
|
|
|
SettleAccountDTO dto = new SettleAccountDTO();
|
2023-09-05 08:42:05 +08:00
|
|
|
|
dto.setCardId("31050180460000002469");
|
|
|
|
|
|
dto.setCardName("上海擎昆物业管理有限公司");
|
2023-08-31 10:29:17 +08:00
|
|
|
|
dto.setTelNo("18021373333");
|
2023-09-05 08:42:05 +08:00
|
|
|
|
dto.setBankCode("01050000");
|
2023-08-30 11:02:18 +08:00
|
|
|
|
dto.setBankAcctType("1");
|
2023-09-05 08:42:05 +08:00
|
|
|
|
dto.setProvCode("0031");
|
|
|
|
|
|
dto.setAreaCode("3100");
|
|
|
|
|
|
String adapayMemberId = "ACM80899105";
|
2023-08-30 11:02:18 +08:00
|
|
|
|
String wechatAppId = "wxbb3e0d474569481d";
|
|
|
|
|
|
adapayService.createSettleAccountRequest(dto, adapayMemberId, wechatAppId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void createDeleteSettleAccountRequestTest() throws BaseAdaPayException {
|
|
|
|
|
|
String adapayMemberId = "ACM69424215";
|
|
|
|
|
|
String settleAccountId = "0498291998695360";
|
|
|
|
|
|
String wechatAppId = "wxbb3e0d474569481d";
|
|
|
|
|
|
adapayService.createDeleteSettleAccountRequest(adapayMemberId, settleAccountId, wechatAppId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void queryDrawcashDetailTest() throws BaseAdaPayException {
|
|
|
|
|
|
String orderNo = "drawcash_1692339516947";
|
|
|
|
|
|
String wechatAppId = "wxbb3e0d474569481d";
|
|
|
|
|
|
DrawCashDetailVO drawCashDetailVO = adapayService.queryDrawCashDetail(orderNo, wechatAppId);
|
|
|
|
|
|
System.out.println(drawCashDetailVO);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void queryPaymentConfirmListTest() {
|
|
|
|
|
|
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
|
|
|
|
|
|
dto.setWechatAppId("wxbb3e0d474569481d");
|
2023-09-25 16:08:30 +08:00
|
|
|
|
// dto.setPaymentId("0022120230910032226990546664907296944128");
|
|
|
|
|
|
dto.setPaymentConfirmId("0022120230910032226990546664907296944128");
|
|
|
|
|
|
QueryPaymentConfirmDetailResponse.PaymentConfirmInfo paymentConfirmInfo = adapayService.queryPaymentConfirmDetail(dto);
|
|
|
|
|
|
System.out.println(JSON.toJSONString(paymentConfirmInfo));
|
2023-08-30 11:02:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void queryAcctFlowListTest() {
|
|
|
|
|
|
QueryAcctFlowDTO dto = new QueryAcctFlowDTO();
|
|
|
|
|
|
try {
|
|
|
|
|
|
dto.setPageNo(1);
|
|
|
|
|
|
dto.setPageSize(100);
|
|
|
|
|
|
dto.setAcctType("01");
|
|
|
|
|
|
dto.setWechatAppId("wxbb3e0d474569481d");
|
|
|
|
|
|
dto.setAdapayMemberId("ACM69424215");
|
|
|
|
|
|
dto.setBeginDate("20230823");
|
|
|
|
|
|
dto.setEndDate("20230823");
|
|
|
|
|
|
adapayService.queryAcctFlowList(dto);
|
|
|
|
|
|
} catch (BaseAdaPayException e) {
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testCalculateTheBalanceDeductionAmount() {
|
|
|
|
|
|
String memberId = "123456";
|
|
|
|
|
|
BigDecimal amount = new BigDecimal("20");
|
|
|
|
|
|
|
|
|
|
|
|
List<BalanceDeductionAmountVO> resultList = Lists.newArrayList();
|
|
|
|
|
|
// 查询会员的余额充值记录 按照充值时间正序
|
|
|
|
|
|
List<MemberAdapayRecord> memberAdapayRecords = Lists.newArrayList();
|
|
|
|
|
|
memberAdapayRecords.add(MemberAdapayRecord.builder().paymentId("1").balanceAmt(new BigDecimal("50")).build());
|
|
|
|
|
|
memberAdapayRecords.add(MemberAdapayRecord.builder().paymentId("2").balanceAmt(new BigDecimal("60")).build());
|
|
|
|
|
|
memberAdapayRecords.add(MemberAdapayRecord.builder().paymentId("3").balanceAmt(new BigDecimal("10")).build());
|
|
|
|
|
|
|
|
|
|
|
|
// 定义一个临时金额等于消费金额
|
|
|
|
|
|
BigDecimal tempAmount = new BigDecimal(amount.toString());
|
|
|
|
|
|
for (MemberAdapayRecord memberAdapayRecord : memberAdapayRecords) {
|
|
|
|
|
|
// 该笔支付剩余金额 取出一笔判断是否剩余金额够支付订单消费吗
|
|
|
|
|
|
BigDecimal balanceAmt = memberAdapayRecord.getBalanceAmt();
|
|
|
|
|
|
// 该笔支付扣除金额
|
|
|
|
|
|
BigDecimal deductionAmount;
|
|
|
|
|
|
// 获取延时分账模式 延时分账的使用撤销方法退款,实时分账的使用退款方法
|
|
|
|
|
|
// AdapayCallbackRecord callbackRecord = adapayCallbackRecordService.selectByPaymentId(memberAdapayRecord.getPaymentId());
|
|
|
|
|
|
// String payMode = null;
|
|
|
|
|
|
// if (callbackRecord != null) {
|
|
|
|
|
|
// JSONObject expendJsonObject = JSON.parseObject(callbackRecord.getExpend());
|
|
|
|
|
|
// payMode = expendJsonObject.getString("payMode");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// 消费金额 - 剩余金额
|
|
|
|
|
|
tempAmount = tempAmount.subtract(balanceAmt);
|
|
|
|
|
|
if (tempAmount.compareTo(BigDecimal.ZERO) >= 0) {
|
|
|
|
|
|
// 计算以后,大于等于0,说明这笔支付剩余金额需要扣完
|
|
|
|
|
|
deductionAmount = balanceAmt;
|
|
|
|
|
|
BalanceDeductionAmountVO build = BalanceDeductionAmountVO.builder()
|
|
|
|
|
|
.memberId(memberId)
|
|
|
|
|
|
.paymentId(memberAdapayRecord.getPaymentId())
|
|
|
|
|
|
.deductionAmount(deductionAmount)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
resultList.add(build);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 如果小于0,则说明剩余的钱用不完,扣除金额等于消费金额,并结束循环
|
|
|
|
|
|
deductionAmount = balanceAmt.add(tempAmount);
|
|
|
|
|
|
BalanceDeductionAmountVO build = BalanceDeductionAmountVO.builder()
|
|
|
|
|
|
.memberId(memberId)
|
|
|
|
|
|
.paymentId(memberAdapayRecord.getPaymentId())
|
|
|
|
|
|
.deductionAmount(deductionAmount)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
resultList.add(build);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(JSON.toJSONString(resultList));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testGenerateOccupyPileOrder() {
|
|
|
|
|
|
String memberId = "67569684";
|
|
|
|
|
|
String pileSn = "88230000000135";
|
|
|
|
|
|
String connectorCode = "01";
|
|
|
|
|
|
GenerateOccupyOrderDTO dto = new GenerateOccupyOrderDTO();
|
|
|
|
|
|
dto.setMemberId(memberId);
|
|
|
|
|
|
dto.setPileSn(pileSn);
|
|
|
|
|
|
dto.setConnectorCode(connectorCode);
|
|
|
|
|
|
|
|
|
|
|
|
orderPileOccupyService.generateOccupyPileOrder(dto);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testStopOccupyPileOrder() {
|
|
|
|
|
|
String wechatAppId = "54135135";
|
|
|
|
|
|
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId);
|
|
|
|
|
|
System.out.println(JSON.toJSONString(config));
|
|
|
|
|
|
|
|
|
|
|
|
String wechatAppId2 = "wxbb3e0d474569481d";
|
|
|
|
|
|
AbstractAdapayConfig config2 = AdapayConfigFactory.getConfig(wechatAppId2);
|
|
|
|
|
|
System.out.println(JSON.toJSONString(config2));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-20 14:57:59 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询分账信息
|
|
|
|
|
|
* @throws BaseAdaPayException
|
|
|
|
|
|
*/
|
2023-08-30 11:02:18 +08:00
|
|
|
|
@Test
|
2023-09-11 16:43:26 +08:00
|
|
|
|
public void queryCreateConfirmReverse() throws BaseAdaPayException {
|
2023-09-28 09:16:44 +08:00
|
|
|
|
// 万车充小程序appId
|
2023-09-06 14:30:06 +08:00
|
|
|
|
String wechatAppId = "wxbb3e0d474569481d";
|
2023-09-28 09:16:44 +08:00
|
|
|
|
// 用于verify的汇付会员id
|
|
|
|
|
|
String verifyAdapayMemberId = "ACM69460507";
|
2023-09-11 16:43:26 +08:00
|
|
|
|
|
2023-09-28 09:16:44 +08:00
|
|
|
|
List<String> list = getList();
|
2023-09-11 16:43:26 +08:00
|
|
|
|
List<String> resultList = Lists.newArrayList();
|
2023-09-27 11:25:01 +08:00
|
|
|
|
List<QueryPaymentConfirmDetailResponse.PaymentConfirmInfo> successList= Lists.newArrayList();
|
2023-09-06 14:30:06 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
for (String s : list) {
|
2023-09-06 14:30:06 +08:00
|
|
|
|
// 查询支付确认id
|
|
|
|
|
|
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
|
|
|
|
|
|
dto.setPaymentId(s);
|
|
|
|
|
|
dto.setWechatAppId(wechatAppId);
|
|
|
|
|
|
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(dto);
|
|
|
|
|
|
if (response != null) {
|
|
|
|
|
|
List<QueryPaymentConfirmDetailResponse.PaymentConfirmInfo> confirms = response.getPaymentConfirms();
|
2023-09-08 14:26:13 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(confirms)) {
|
2023-09-11 16:43:26 +08:00
|
|
|
|
resultList.add(s);
|
2023-09-27 11:25:01 +08:00
|
|
|
|
} else {
|
2023-09-28 09:16:44 +08:00
|
|
|
|
for (QueryPaymentConfirmDetailResponse.PaymentConfirmInfo confirm : confirms) {
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(confirm.getDescription());
|
|
|
|
|
|
// 校验是不是分给正确的商户
|
|
|
|
|
|
String adapayMemberId = jsonObject.getString("adapayMemberId");
|
|
|
|
|
|
if (StringUtils.equals(adapayMemberId, verifyAdapayMemberId)) {
|
|
|
|
|
|
successList.addAll(confirms);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
resultList.add(s);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-09-06 14:30:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-08-30 11:02:18 +08:00
|
|
|
|
}
|
2023-09-11 16:43:26 +08:00
|
|
|
|
System.out.println("=================未分账:" + JSON.toJSONString(resultList));
|
2023-09-27 11:25:01 +08:00
|
|
|
|
System.out.println("=================已分账:" + JSON.toJSONString(successList));
|
2023-08-30 11:02:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-28 09:16:44 +08:00
|
|
|
|
@Test
|
|
|
|
|
|
public void test() {
|
|
|
|
|
|
String paymentId = "002212023091113071210547174455434940416";
|
|
|
|
|
|
AdapayMemberAccount adapayMemberAccount = new AdapayMemberAccount();
|
|
|
|
|
|
adapayMemberAccount.setAdapayMemberId("ACM69460507");
|
|
|
|
|
|
BigDecimal deductionAmount = new BigDecimal("19.9");
|
|
|
|
|
|
String orderCode = "C88200971107";
|
|
|
|
|
|
String wechatAppId = "wxbb3e0d474569481d";
|
|
|
|
|
|
// 延时分账,使用确认交易API
|
|
|
|
|
|
PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(paymentId,
|
|
|
|
|
|
adapayMemberAccount, deductionAmount, orderCode, wechatAppId);
|
|
|
|
|
|
System.out.println(JSON.toJSONString(paymentConfirmResponse));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-25 15:05:12 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 批量支付确认撤销
|
|
|
|
|
|
* @throws BaseAdaPayException
|
|
|
|
|
|
*/
|
2023-09-08 14:26:13 +08:00
|
|
|
|
@Test
|
2023-09-11 16:43:26 +08:00
|
|
|
|
public void testCreateConfirmReverse() throws BaseAdaPayException {
|
2023-09-08 14:26:13 +08:00
|
|
|
|
String wechatAppId = "wxbb3e0d474569481d";
|
|
|
|
|
|
List<String> list = getList();
|
2023-08-30 11:02:18 +08:00
|
|
|
|
for (String s : list) {
|
2023-09-08 14:26:13 +08:00
|
|
|
|
// 查询支付确认id
|
|
|
|
|
|
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
|
|
|
|
|
|
dto.setPaymentId(s);
|
|
|
|
|
|
dto.setWechatAppId(wechatAppId);
|
|
|
|
|
|
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(dto);
|
|
|
|
|
|
if (response != null) {
|
|
|
|
|
|
List<QueryPaymentConfirmDetailResponse.PaymentConfirmInfo> confirms = response.getPaymentConfirms();
|
2023-09-11 16:43:26 +08:00
|
|
|
|
System.out.println("支付id:" + s + ", 确认信息:" + JSON.toJSONString(confirms));
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(confirms)) {
|
|
|
|
|
|
for (QueryPaymentConfirmDetailResponse.PaymentConfirmInfo confirm : confirms) {
|
|
|
|
|
|
adapayService.createConfirmReverse(confirm.getId(), wechatAppId);
|
|
|
|
|
|
}
|
2023-09-08 14:26:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-08-30 11:02:18 +08:00
|
|
|
|
}
|
2023-09-08 14:26:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<String> getList() {
|
|
|
|
|
|
List<String> list = Lists.newArrayList();
|
2023-09-28 09:16:44 +08:00
|
|
|
|
list.add("002212023080209304810532624482967433216");
|
|
|
|
|
|
list.add("002212023080209480910532628850635452416");
|
|
|
|
|
|
list.add("002212023080210055210532633306584395776");
|
|
|
|
|
|
list.add("002212023080210373610532641294365573120");
|
|
|
|
|
|
list.add("002212023080211223110532652595735678976");
|
|
|
|
|
|
list.add("002212023080211414410532657434426290176");
|
|
|
|
|
|
list.add("002212023080212100210532664557262045184");
|
|
|
|
|
|
list.add("002212023080212095810532664539210924032");
|
|
|
|
|
|
list.add("002212023080213491410532689520353902592");
|
|
|
|
|
|
list.add("002212023080214552910532706191122325504");
|
|
|
|
|
|
list.add("002212023080215052310532708684073394176");
|
|
|
|
|
|
list.add("002212023080215473910532719321689083904");
|
|
|
|
|
|
list.add("002212023080216002610532722537476587520");
|
|
|
|
|
|
list.add("002212023080216265010532729182505263104");
|
|
|
|
|
|
list.add("002212023080216503910532735175199764480");
|
|
|
|
|
|
list.add("002212023080218432310532763544244314112");
|
|
|
|
|
|
list.add("002212023080219174810532772206388719616");
|
|
|
|
|
|
list.add("002212023080220203410532788003051888640");
|
|
|
|
|
|
list.add("002212023080222075710532815027940179968");
|
|
|
|
|
|
list.add("002212023080222471310532824906748997632");
|
|
|
|
|
|
list.add("002212023080223250110532834419384467456");
|
|
|
|
|
|
list.add("002212023080300022210532843818643652608");
|
|
|
|
|
|
list.add("002212023080300174410532847688406716416");
|
|
|
|
|
|
list.add("002212023080307131910532952274419613696");
|
|
|
|
|
|
list.add("002212023080310370610533003557404594176");
|
|
|
|
|
|
list.add("002212023080310462310533005894214828032");
|
|
|
|
|
|
list.add("002212023080312194510533029387116949504");
|
|
|
|
|
|
list.add("002212023080312251310533030763680223232");
|
|
|
|
|
|
list.add("002212023080312444610533035684332818432");
|
|
|
|
|
|
list.add("002212023080312485510533036730747838464");
|
|
|
|
|
|
list.add("002212023080313052710533040889794519040");
|
|
|
|
|
|
list.add("002212023080316074110533086748158525440");
|
|
|
|
|
|
list.add("002212023080316451210533096192530862080");
|
|
|
|
|
|
list.add("002212023080316535710533098395504259072");
|
|
|
|
|
|
list.add("002212023080317473810533111904093356032");
|
|
|
|
|
|
list.add("002212023080319090310533132392003317760");
|
|
|
|
|
|
list.add("002212023080321005510533160543205449728");
|
|
|
|
|
|
list.add("002212023080321020010533160819025924096");
|
|
|
|
|
|
list.add("002212023080321101610533162896586084352");
|
|
|
|
|
|
list.add("002212023080321320110533168370325549056");
|
|
|
|
|
|
list.add("002212023080401152510533224590910226432");
|
|
|
|
|
|
list.add("002212023080404555810533280094390910976");
|
|
|
|
|
|
list.add("002212023080408122410533329529971576832");
|
|
|
|
|
|
list.add("002212023080411564710533385998821474304");
|
|
|
|
|
|
list.add("002212023080413221010533407484810792960");
|
|
|
|
|
|
list.add("002212023080413451410533413289979002880");
|
|
|
|
|
|
list.add("002212023080414375910533426565034954752");
|
|
|
|
|
|
list.add("002212023080415515610533445175959420928");
|
|
|
|
|
|
list.add("002212023080418490410533489751169449984");
|
|
|
|
|
|
list.add("002212023080419262010533499128296812544");
|
|
|
|
|
|
list.add("002212023080420352310533516505161465856");
|
|
|
|
|
|
list.add("002212023080420390010533517415842131968");
|
|
|
|
|
|
list.add("002212023080421293310533530139375620096");
|
|
|
|
|
|
list.add("002212023080421545910533536540168704000");
|
|
|
|
|
|
list.add("002212023080422414010533548289086472192");
|
|
|
|
|
|
list.add("002212023080423430310533563732962390016");
|
|
|
|
|
|
list.add("002212023080500101210533570567592120320");
|
|
|
|
|
|
list.add("002212023080505544510533657276523376640");
|
|
|
|
|
|
list.add("002212023080505561810533657668010266624");
|
|
|
|
|
|
list.add("002212023080506131210533661918371139584");
|
|
|
|
|
|
list.add("002212023080508594710533703841853194240");
|
|
|
|
|
|
list.add("002212023080510543710533732738062241792");
|
|
|
|
|
|
list.add("002212023080511562710533748299144167424");
|
|
|
|
|
|
list.add("002212023080512021010533749740462067712");
|
|
|
|
|
|
list.add("002212023080512443910533760432203874304");
|
|
|
|
|
|
list.add("002212023080512510110533762031124295680");
|
|
|
|
|
|
list.add("002212023080513243310533770471908462592");
|
|
|
|
|
|
list.add("002212023080514004710533779590359445504");
|
|
|
|
|
|
list.add("002212023080514224810533785129733832704");
|
|
|
|
|
|
list.add("002212023080514323710533787602477273088");
|
|
|
|
|
|
list.add("002212023080514371310533788758360903680");
|
|
|
|
|
|
list.add("002212023080515104010533797175999692800");
|
|
|
|
|
|
list.add("002212023080515240410533800548910125056");
|
|
|
|
|
|
list.add("002212023080516343610533818301536440320");
|
|
|
|
|
|
list.add("002212023080516362710533818763921485824");
|
|
|
|
|
|
list.add("002212023080518440410533850881523990528");
|
|
|
|
|
|
list.add("002212023080518595410533854863581032448");
|
|
|
|
|
|
list.add("002212023080519222710533860539474182144");
|
|
|
|
|
|
list.add("002212023080519484110533867142319329280");
|
|
|
|
|
|
list.add("002212023080520024110533870665660518400");
|
|
|
|
|
|
list.add("002212023080520460010533881565299003392");
|
|
|
|
|
|
list.add("002212023080521234310533891056818343936");
|
|
|
|
|
|
list.add("002212023080521323910533893305393106944");
|
|
|
|
|
|
list.add("002212023080521512210533898015132798976");
|
|
|
|
|
|
list.add("002212023080521594510533900124874756096");
|
|
|
|
|
|
list.add("002212023080523005510533915519569809408");
|
|
|
|
|
|
list.add("002212023080523452910533926735360835584");
|
|
|
|
|
|
list.add("002212023080600142810533934030671745024");
|
|
|
|
|
|
list.add("002212023080601060210533947006192791552");
|
|
|
|
|
|
list.add("002212023080601133610533948908857888768");
|
|
|
|
|
|
list.add("002212023080606591810534035907757379584");
|
|
|
|
|
|
list.add("002212023080607060910534037632706842624");
|
|
|
|
|
|
list.add("002212023080607334510534044577691328512");
|
|
|
|
|
|
list.add("002212023080608285510534058460836171776");
|
|
|
|
|
|
list.add("002212023080608491810534063591573311488");
|
|
|
|
|
|
list.add("002212023080608561110534065324675084288");
|
|
|
|
|
|
list.add("002212023080609081610534068364209094656");
|
|
|
|
|
|
list.add("002212023080610051310534082693944651776");
|
|
|
|
|
|
list.add("002212023080610372010534090780495654912");
|
|
|
|
|
|
list.add("002212023080612581810534126253346279424");
|
|
|
|
|
|
list.add("002212023080616170610534176284240084992");
|
|
|
|
|
|
list.add("002212023080616352210534180880470585344");
|
|
|
|
|
|
list.add("002212023080616481010534184101661560832");
|
|
|
|
|
|
list.add("002212023080617041010534188127913525248");
|
|
|
|
|
|
list.add("002212023080617352510534195990543196160");
|
|
|
|
|
|
list.add("002212023080620385010534242151172390912");
|
|
|
|
|
|
list.add("002212023080621171810534251829785153536");
|
|
|
|
|
|
list.add("002212023080704262310534359813880119296");
|
|
|
|
|
|
list.add("002212023080706432810534394310708244480");
|
|
|
|
|
|
list.add("002212023080707310410534406292671545344");
|
|
|
|
|
|
list.add("002212023080711042010534459959331303424");
|
|
|
|
|
|
list.add("002212023080711143610534462545445249024");
|
|
|
|
|
|
list.add("002212023080711254910534465368567382016");
|
|
|
|
|
|
list.add("002212023080713192410534493950907236352");
|
|
|
|
|
|
list.add("002212023080713200010534494101252526080");
|
|
|
|
|
|
list.add("002212023080715331110534527617663303680");
|
|
|
|
|
|
list.add("002212023080715351510534528139980337152");
|
|
|
|
|
|
list.add("002212023080716120510534537407597457408");
|
|
|
|
|
|
list.add("002212023080717255610534555995598409728");
|
|
|
|
|
|
list.add("002212023080718241310534570662967369728");
|
|
|
|
|
|
list.add("002212023080718503510534577298047545344");
|
|
|
|
|
|
list.add("002212023080718534410534578088885956608");
|
|
|
|
|
|
list.add("002212023080719124010534582854595268608");
|
|
|
|
|
|
list.add("002212023080719274710534586656814104576");
|
|
|
|
|
|
list.add("002212023080720525210534608069813067776");
|
|
|
|
|
|
list.add("002212023080801542510534683958601048064");
|
|
|
|
|
|
list.add("002212023080808380710534785552100425728");
|
|
|
|
|
|
list.add("002212023080809160710534795114014994432");
|
|
|
|
|
|
list.add("002212023080811040110534822269050580992");
|
|
|
|
|
|
list.add("002212023080811334810534829765096157184");
|
|
|
|
|
|
list.add("002212023080811373310534830708006043648");
|
|
|
|
|
|
list.add("002212023080812352810534845284078075904");
|
|
|
|
|
|
list.add("002212023080813331210534859813536059392");
|
|
|
|
|
|
list.add("002212023080814455610534878116213346304");
|
|
|
|
|
|
list.add("002212023080816532910534910216790360064");
|
|
|
|
|
|
list.add("002212023080817383510534921566006726656");
|
|
|
|
|
|
list.add("002212023080817471010534923724588310528");
|
|
|
|
|
|
list.add("002212023080817500210534924446569517056");
|
|
|
|
|
|
list.add("002212023080818423110534937654006304768");
|
|
|
|
|
|
list.add("002212023080821424410534983008546377728");
|
|
|
|
|
|
list.add("002212023080823153910535006388962349056");
|
|
|
|
|
|
list.add("002212023080823362510535011617733234688");
|
|
|
|
|
|
list.add("002212023080901035210535033625387511808");
|
|
|
|
|
|
list.add("002212023080906044310535109334048505856");
|
|
|
|
|
|
list.add("002212023080909503410535166171638497280");
|
|
|
|
|
|
list.add("002212023080910280010535175594690818048");
|
|
|
|
|
|
list.add("002212023080912233010535204661163380736");
|
|
|
|
|
|
list.add("002212023080912395310535208782099804160");
|
|
|
|
|
|
list.add("002212023080912462610535210431823462400");
|
|
|
|
|
|
list.add("002212023080913264010535220557232308224");
|
|
|
|
|
|
list.add("002212023080916415010535269672050536448");
|
|
|
|
|
|
list.add("002212023080919111210535307260075339776");
|
|
|
|
|
|
list.add("002212023080920275910535326584028102656");
|
|
|
|
|
|
list.add("002212023080920554310535333563591184384");
|
|
|
|
|
|
list.add("002212023080921195110535339635431276544");
|
|
|
|
|
|
list.add("002212023080922470410535361583891247104");
|
|
|
|
|
|
list.add("002212023080923284810535372087431712768");
|
|
|
|
|
|
list.add("002212023080923552010535378764935278592");
|
|
|
|
|
|
list.add("002212023081002480410535422237083856896");
|
|
|
|
|
|
list.add("002212023081004241110535446422335619072");
|
|
|
|
|
|
list.add("002212023081009122910535518976624742400");
|
|
|
|
|
|
list.add("002212023081010041210535531993052758016");
|
|
|
|
|
|
list.add("002212023081010333710535539394039934976");
|
|
|
|
|
|
list.add("002212023081012312610535569042240159744");
|
|
|
|
|
|
list.add("002212023081013095510535578730189975552");
|
|
|
|
|
|
list.add("002212023081014080510535593367799873536");
|
|
|
|
|
|
list.add("002212023081014101610535593917740236800");
|
|
|
|
|
|
list.add("002212023081015242410535612574518628352");
|
|
|
|
|
|
list.add("002212023081016184610535626255337705472");
|
|
|
|
|
|
list.add("002212023081016343210535630223471083520");
|
|
|
|
|
|
list.add("002212023081016412510535631956416057344");
|
|
|
|
|
|
list.add("002212023081017103910535639311193886720");
|
|
|
|
|
|
list.add("002212023081017573810535651137062850560");
|
|
|
|
|
|
list.add("002212023081018303910535659446015197184");
|
|
|
|
|
|
list.add("002212023081018521910535664898486472704");
|
|
|
|
|
|
list.add("002212023081019145710535670591067586560");
|
|
|
|
|
|
list.add("002212023081019273710535673778903179264");
|
|
|
|
|
|
list.add("002212023081019332210535675228421111808");
|
|
|
|
|
|
list.add("002212023081020083810535684101953368064");
|
|
|
|
|
|
list.add("002212023081020254110535688393728798720");
|
|
|
|
|
|
list.add("002212023081020270110535688726536040448");
|
|
|
|
|
|
list.add("002212023081020544310535695698233823232");
|
|
|
|
|
|
list.add("002212023081021262110535703658870648832");
|
|
|
|
|
|
list.add("002212023081021275910535704069260722176");
|
|
|
|
|
|
list.add("002212023081022021110535712677017079808");
|
|
|
|
|
|
list.add("002212023081022101210535714696941965312");
|
|
|
|
|
|
list.add("002212023081022265910535718919588274176");
|
|
|
|
|
|
list.add("002212023081023250610535733546606936064");
|
|
|
|
|
|
list.add("002212023081023281310535734327745523712");
|
|
|
|
|
|
list.add("002212023081100385310535752112508399616");
|
|
|
|
|
|
list.add("002212023081101440710535768529232977920");
|
|
|
|
|
|
list.add("002212023081102175010535777016355209216");
|
|
|
|
|
|
list.add("002212023081103312510535795533792133120");
|
|
|
|
|
|
list.add("002212023081109074710535880179831459840");
|
|
|
|
|
|
list.add("002212023081110453310535904786147696640");
|
|
|
|
|
|
list.add("002212023081111213210535913840780414976");
|
|
|
|
|
|
list.add("002212023081113331010535946967512436736");
|
|
|
|
|
|
list.add("002212023081113545210535952429178572800");
|
|
|
|
|
|
list.add("002212023081114564710535968011643416576");
|
|
|
|
|
|
list.add("002212023081114591110535968613017997312");
|
|
|
|
|
|
list.add("002212023081115281410535975926873100288");
|
|
|
|
|
|
list.add("002212023081115522310535982000889413632");
|
|
|
|
|
|
list.add("002212023081116000510535983942119763968");
|
|
|
|
|
|
list.add("002212023081116021410535984482737639424");
|
|
|
|
|
|
list.add("002212023081116045810535985170092933120");
|
|
|
|
|
|
list.add("002212023081116443710535995147764936704");
|
|
|
|
|
|
list.add("002212023081116455110535995459850514432");
|
|
|
|
|
|
list.add("002212023081116483410535996140458790912");
|
|
|
|
|
|
list.add("002212023081116495210535996468065898496");
|
|
|
|
|
|
list.add("002212023081117162910536003168982159360");
|
|
|
|
|
|
list.add("002212023081117231210536004859271761920");
|
|
|
|
|
|
list.add("002212023081117412110536009424213823488");
|
|
|
|
|
|
list.add("002212023081117442810536010209508999168");
|
|
|
|
|
|
list.add("002212023081117521810536012179033391104");
|
|
|
|
|
|
list.add("002212023081118190410536018915653996544");
|
|
|
|
|
|
list.add("002212023081118354310536023104910098432");
|
|
|
|
|
|
list.add("002212023081119190010536033999630004224");
|
|
|
|
|
|
list.add("002212023081119413310536039672279007232");
|
|
|
|
|
|
list.add("002212023081120053210536045710980460544");
|
|
|
|
|
|
list.add("002212023081120070310536046091648552960");
|
|
|
|
|
|
list.add("002212023081120080110536046336742428672");
|
|
|
|
|
|
list.add("002212023081120125110536047551743045632");
|
|
|
|
|
|
list.add("002212023081120183710536049002654633984");
|
|
|
|
|
|
list.add("002212023081120272010536051196078739456");
|
|
|
|
|
|
list.add("002212023081120354910536053330275364864");
|
|
|
|
|
|
list.add("002212023081120524410536057589623853056");
|
|
|
|
|
|
list.add("002212023081121053910536060836852838400");
|
|
|
|
|
|
list.add("002212023081121125910536062682579853312");
|
|
|
|
|
|
list.add("002212023081121180710536063974776225792");
|
|
|
|
|
|
list.add("002212023081121391610536069300187451392");
|
|
|
|
|
|
list.add("002212023081121443610536070641430102016");
|
|
|
|
|
|
list.add("002212023081121550410536073274983108608");
|
|
|
|
|
|
list.add("002212023081122025510536075249151037440");
|
|
|
|
|
|
list.add("002212023081122103610536077185673408512");
|
|
|
|
|
|
list.add("002212023081123092910536092000987136000");
|
|
|
|
|
|
list.add("002212023081123483010536101821032267776");
|
|
|
|
|
|
list.add("002212023081202380910536144516784746496");
|
|
|
|
|
|
list.add("002212023081202511410536147808900395008");
|
|
|
|
|
|
list.add("002212023081203222410536155652040146944");
|
|
|
|
|
|
list.add("002212023081203244510536156243971092480");
|
|
|
|
|
|
list.add("002212023081203313410536157958555631616");
|
|
|
|
|
|
list.add("002212023081204351810536173998358286336");
|
|
|
|
|
|
list.add("002212023081204580410536179728367529984");
|
|
|
|
|
|
list.add("002212023081205483910536192454555152384");
|
|
|
|
|
|
list.add("002212023081207095310536212899296804864");
|
|
|
|
|
|
list.add("002212023081208191510536230355565535232");
|
|
|
|
|
|
list.add("002212023081209040310536241630499635200");
|
|
|
|
|
|
list.add("002212023081209171810536244964435611648");
|
|
|
|
|
|
list.add("002212023081209301410536248221211836416");
|
|
|
|
|
|
list.add("002212023081210214510536261182496194560");
|
|
|
|
|
|
list.add("002212023081210234510536261686956544000");
|
|
|
|
|
|
list.add("002212023081210313510536263656718897152");
|
|
|
|
|
|
list.add("002212023081210324110536263934321930240");
|
|
|
|
|
|
list.add("002212023081210343710536264422835109888");
|
|
|
|
|
|
list.add("002212023081210375910536265270789136384");
|
|
|
|
|
|
list.add("002212023081211100010536273324714274816");
|
|
|
|
|
|
list.add("002212023081211113610536273730510942208");
|
|
|
|
|
|
list.add("002212023081211241310536276906020745216");
|
|
|
|
|
|
list.add("002212023081211334710536279312014499840");
|
|
|
|
|
|
list.add("002212023081211350810536279651257221120");
|
|
|
|
|
|
list.add("002212023081212075510536287902803755008");
|
|
|
|
|
|
list.add("002212023081212595510536300986994159616");
|
|
|
|
|
|
list.add("002212023081213194710536305988186398720");
|
|
|
|
|
|
list.add("002212023081213445810536312324219461632");
|
|
|
|
|
|
list.add("002212023081214063410536317760480890880");
|
|
|
|
|
|
list.add("002212023081214261510536322715669417984");
|
|
|
|
|
|
list.add("002212023081215195610536336223685033984");
|
|
|
|
|
|
list.add("002212023081215345210536339980542377984");
|
|
|
|
|
|
list.add("002212023081215520710536344323890970624");
|
|
|
|
|
|
list.add("002212023081216143210536349963682152448");
|
|
|
|
|
|
list.add("002212023081216173810536350743720165376");
|
|
|
|
|
|
list.add("002212023081216231810536352169713197056");
|
|
|
|
|
|
list.add("002212023081216400010536356373478572032");
|
|
|
|
|
|
list.add("002212023081217225710536367180442923008");
|
|
|
|
|
|
list.add("002212023081217423910536372141053689856");
|
|
|
|
|
|
list.add("002212023081217452410536372833861840896");
|
|
|
|
|
|
list.add("002212023081217534910536374951258804224");
|
|
|
|
|
|
list.add("002212023081218341010536385104585207808");
|
|
|
|
|
|
list.add("002212023081218464810536388284103938048");
|
|
|
|
|
|
list.add("002212023081219125610536394860567121920");
|
|
|
|
|
|
list.add("002212023081219301710536399228213284864");
|
|
|
|
|
|
list.add("002212023081219554010536405613638225920");
|
|
|
|
|
|
list.add("002212023081220222410536412341014024192");
|
|
|
|
|
|
list.add("002212023081220345210536415479007727616");
|
|
|
|
|
|
list.add("002212023081221114410536424755682758656");
|
|
|
|
|
|
list.add("002212023081221211610536427157100003328");
|
|
|
|
|
|
list.add("002212023081222120510536439945480556544");
|
|
|
|
|
|
list.add("002212023081222183410536441576339165184");
|
|
|
|
|
|
list.add("002212023081222341810536445536972877824");
|
|
|
|
|
|
list.add("002212023081222372010536446301520416768");
|
|
|
|
|
|
list.add("002212023081223264710536458744159088640");
|
|
|
|
|
|
list.add("002212023081223310910536459844898426880");
|
|
|
|
|
|
list.add("002212023081304373010536536938041880576");
|
|
|
|
|
|
list.add("002212023081304425610536538306430816256");
|
|
|
|
|
|
list.add("002212023081304471810536539405305409536");
|
|
|
|
|
|
list.add("002212023081306095110536560179961999360");
|
|
|
|
|
|
list.add("002212023081306251910536564071806717952");
|
|
|
|
|
|
list.add("002212023081306503110536570412168302592");
|
|
|
|
|
|
list.add("002212023081309250210536609298692956160");
|
|
|
|
|
|
list.add("002212023081309352310536611902223101952");
|
|
|
|
|
|
list.add("002212023081309424710536613766024200192");
|
|
|
|
|
|
list.add("002212023081310285810536625386195931136");
|
|
|
|
|
|
list.add("002212023081310422410536628769162153984");
|
|
|
|
|
|
list.add("002212023081310484310536630358372413440");
|
|
|
|
|
|
list.add("002212023081311113710536636122640199680");
|
|
|
|
|
|
list.add("002212023081311170310536637489162391552");
|
|
|
|
|
|
list.add("002212023081311353510536642153020145664");
|
|
|
|
|
|
list.add("002212023081311471010536645067840729088");
|
|
|
|
|
|
list.add("002212023081312013810536648710305939456");
|
|
|
|
|
|
list.add("002212023081312020110536648804723740672");
|
|
|
|
|
|
list.add("002212023081312582310536662991423913984");
|
|
|
|
|
|
list.add("002212023081313111410536666224758771712");
|
|
|
|
|
|
list.add("002212023081313385710536673196962369536");
|
|
|
|
|
|
list.add("002212023081313392410536673310117359616");
|
|
|
|
|
|
list.add("002212023081313445810536674712882171904");
|
|
|
|
|
|
list.add("002212023081314282310536685638331760640");
|
|
|
|
|
|
list.add("002212023081314394510536688498932695040");
|
|
|
|
|
|
list.add("002212023081315275210536700610158424064");
|
|
|
|
|
|
list.add("002212023081318004210536739068757454848");
|
|
|
|
|
|
list.add("002212023081318033910536739813256253440");
|
|
|
|
|
|
list.add("002212023081318074310536740834154008576");
|
|
|
|
|
|
list.add("002212023081318302410536746546335834112");
|
|
|
|
|
|
list.add("002212023081318460010536750469486469120");
|
|
|
|
|
|
list.add("002212023081319090010536756259956625408");
|
|
|
|
|
|
list.add("002212023081319101910536756588674039808");
|
|
|
|
|
|
list.add("002212023081319582610536768700992344064");
|
|
|
|
|
|
list.add("002212023081320195510536774106464571392");
|
|
|
|
|
|
list.add("002212023081320503110536781805784383488");
|
|
|
|
|
|
list.add("002212023081320573110536783568511942656");
|
|
|
|
|
|
list.add("002212023081321025110536784908047417344");
|
|
|
|
|
|
list.add("002212023081322570110536813642252042240");
|
|
|
|
|
|
list.add("002212023081323084110536816576427536384");
|
|
|
|
|
|
list.add("002212023081400442110536840652674715648");
|
|
|
|
|
|
list.add("002212023081408310010536958090217705472");
|
|
|
|
|
|
list.add("002212023081413253710537032231247040512");
|
|
|
|
|
|
list.add("002212023081414224810537046621496324096");
|
|
|
|
|
|
list.add("002212023081414443210537052091410698240");
|
|
|
|
|
|
list.add("002212023081414482510537053068845481984");
|
|
|
|
|
|
list.add("002212023081414520610537053994173763584");
|
|
|
|
|
|
list.add("002212023081415571710537070397476372480");
|
|
|
|
|
|
list.add("002212023081417134510537089641443221504");
|
|
|
|
|
|
list.add("002212023081418090610537103572601483264");
|
|
|
|
|
|
list.add("002212023081419191010537121204464701440");
|
|
|
|
|
|
list.add("002212023081419244810537122621685018624");
|
|
|
|
|
|
list.add("002212023081419375010537125903648206848");
|
|
|
|
|
|
list.add("002212023081419555110537130435188781056");
|
|
|
|
|
|
list.add("002212023081420061210537133040388878336");
|
|
|
|
|
|
list.add("002212023081420145910537135252850683904");
|
|
|
|
|
|
list.add("002212023081420395310537141516677828608");
|
|
|
|
|
|
list.add("002212023081420460310537143070169313280");
|
|
|
|
|
|
list.add("002212023081511244510537364200278503424");
|
|
|
|
|
|
list.add("002212023081511380010537367534449610752");
|
|
|
|
|
|
list.add("002212023081511450110537369303817904128");
|
|
|
|
|
|
list.add("002212023081512085610537375322261344256");
|
|
|
|
|
|
list.add("002212023081512200110537378110166192128");
|
|
|
|
|
|
list.add("002212023081513535610537401744796233728");
|
|
|
|
|
|
list.add("002212023081514144510537406985096294400");
|
|
|
|
|
|
list.add("002212023081514151510537407108244754432");
|
|
|
|
|
|
list.add("002212023081515014410537418806001971200");
|
|
|
|
|
|
list.add("002212023081515355510537427411438710784");
|
|
|
|
|
|
list.add("002212023081515584410537433152302428160");
|
|
|
|
|
|
list.add("002212023081515591510537433283662336000");
|
|
|
|
|
|
list.add("002212023081516363410537442671929667584");
|
|
|
|
|
|
list.add("002212023081517085010537450792706560000");
|
|
|
|
|
|
list.add("002212023081517445210537459862744764416");
|
|
|
|
|
|
list.add("002212023081517524310537461837080743936");
|
|
|
|
|
|
list.add("002212023081517581810537463243549016064");
|
|
|
|
|
|
list.add("002212023081518303310537471356211744768");
|
|
|
|
|
|
list.add("002212023081518435810537474733931036672");
|
|
|
|
|
|
list.add("002212023081519275010537485772248469504");
|
|
|
|
|
|
list.add("002212023081519310710537486599821967360");
|
|
|
|
|
|
list.add("002212023081519352810537487695998136320");
|
|
|
|
|
|
list.add("002212023081519560910537492900934217728");
|
|
|
|
|
|
list.add("002212023081520143110537497521369165824");
|
|
|
|
|
|
list.add("002212023081522385410537533859322548224");
|
|
|
|
|
|
list.add("002212023081523161210537543244876533760");
|
|
|
|
|
|
list.add("002212023081606132710537648247452282880");
|
|
|
|
|
|
list.add("002212023081607563310537674196242288640");
|
|
|
|
|
|
list.add("002212023081608573410537689551904083968");
|
|
|
|
|
|
list.add("002212023081609314410537698147643408384");
|
|
|
|
|
|
list.add("002212023081611264210537727082197757952");
|
|
|
|
|
|
list.add("002212023081612180110537739993872257024");
|
|
|
|
|
|
list.add("002212023081613261410537757161648451584");
|
|
|
|
|
|
list.add("002212023081613324810537758815530438656");
|
|
|
|
|
|
list.add("002212023081613332010537758948456321024");
|
|
|
|
|
|
list.add("002212023081615102410537783375251034112");
|
|
|
|
|
|
list.add("002212023081615155010537784742309068800");
|
|
|
|
|
|
list.add("002212023081615205610537786025702756352");
|
|
|
|
|
|
list.add("002212023081615423810537791487488454656");
|
|
|
|
|
|
list.add("002212023081616003810537796018679762944");
|
|
|
|
|
|
list.add("002212023081616371310537805224568500224");
|
|
|
|
|
|
list.add("002212023081616463010537807559550320640");
|
|
|
|
|
|
list.add("002212023081618175410537830562149425152");
|
|
|
|
|
|
list.add("002212023081618490110537838392130482176");
|
|
|
|
|
|
list.add("002212023081620302010537863890661953536");
|
|
|
|
|
|
list.add("002212023081623284210537908776792244224");
|
|
|
|
|
|
list.add("002212023081714084910538130267692662784");
|
|
|
|
|
|
list.add("002212023081714374110538137529223925760");
|
|
|
|
|
|
list.add("002212023081715281610538150261655592960");
|
|
|
|
|
|
list.add("002212023081715501110538155776214872064");
|
|
|
|
|
|
list.add("002212023081717080810538175393304428544");
|
|
|
|
|
|
list.add("002212023081717165110538177585892978688");
|
|
|
|
|
|
list.add("002212023081717181710538177947907018752");
|
|
|
|
|
|
list.add("002212023081717295010538180853137821696");
|
|
|
|
|
|
list.add("002212023081717322510538181503738630144");
|
|
|
|
|
|
list.add("002212023081718034010538189366450900992");
|
|
|
|
|
|
list.add("002212023081719470410538215391914283008");
|
|
|
|
|
|
list.add("002212023081719530910538216921602260992");
|
|
|
|
|
|
list.add("002212023081720025710538219388484026368");
|
|
|
|
|
|
list.add("002212023081722140210538252374003314688");
|
|
|
|
|
|
|
2023-09-08 14:26:13 +08:00
|
|
|
|
return list;
|
2023-08-30 11:02:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testClearingWithdraw() {
|
|
|
|
|
|
// 保存提现记录
|
|
|
|
|
|
ClearingWithdrawInfo record = new ClearingWithdrawInfo();
|
|
|
|
|
|
record.setWithdrawCode("132321354");
|
|
|
|
|
|
record.setWithdrawStatus(Constants.ZERO);
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
record.setApplicationTime(now);
|
|
|
|
|
|
record.setCreateTime(now);
|
|
|
|
|
|
record.setDelFlag(DelFlagEnum.NORMAL.getValue());
|
|
|
|
|
|
clearingWithdrawInfoService.insertOrUpdate(record);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testGetPileTypeNum() {
|
|
|
|
|
|
Long stationId = 1L;
|
|
|
|
|
|
pileConnectorInfoService.getPileTypeNum(stationId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testUpdateStatus() {
|
|
|
|
|
|
String pileConnectorCode = "8800000000012601";
|
|
|
|
|
|
String status = "0";
|
|
|
|
|
|
pileConnectorInfoService.updateConnectorStatus(pileConnectorCode, status);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testRedisSet() {
|
|
|
|
|
|
String redisKey = "push_station_connector";
|
|
|
|
|
|
redisCache.setCacheSet(redisKey, Sets.newHashSet("1"));
|
|
|
|
|
|
|
|
|
|
|
|
redisCache.setCacheSet(redisKey, Sets.newHashSet("3"));
|
|
|
|
|
|
|
|
|
|
|
|
redisCache.setCacheSet(redisKey, Sets.newHashSet("5"));
|
|
|
|
|
|
|
|
|
|
|
|
redisCache.setCacheSet(redisKey, Sets.newHashSet("1"));
|
|
|
|
|
|
|
|
|
|
|
|
redisCache.setCacheSet(redisKey, Sets.newHashSet("1"));
|
|
|
|
|
|
|
|
|
|
|
|
redisCache.setCacheSet(redisKey, Sets.newHashSet("7"));
|
|
|
|
|
|
|
|
|
|
|
|
redisCache.setCacheSet(redisKey, Sets.newHashSet("3"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set<Object> cacheSet = redisCache.getCacheSet(redisKey);
|
|
|
|
|
|
System.out.println(cacheSet);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testSettleOrder() {
|
|
|
|
|
|
Map<String, BigDecimal> returnAmountMap = Maps.newHashMap();
|
|
|
|
|
|
returnAmountMap.put("returnPrincipal", new BigDecimal("16.8700"));
|
|
|
|
|
|
// 更新会员钱包
|
|
|
|
|
|
BigDecimal returnPrincipal = returnAmountMap.get("returnPrincipal");
|
|
|
|
|
|
// if (returnPrincipal != null && principalPayRecord != null) {
|
|
|
|
|
|
// principalPayRecord.setRefundAmount(returnPrincipal);
|
|
|
|
|
|
// updatePayRecordList.add(principalPayRecord);
|
|
|
|
|
|
// }
|
|
|
|
|
|
BigDecimal returnGift = returnAmountMap.get("returnGift");
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(returnPrincipal);
|
|
|
|
|
|
// if (returnGift != null && giftPayRecord != null) {
|
|
|
|
|
|
// giftPayRecord.setRefundAmount(returnGift);
|
|
|
|
|
|
// updatePayRecordList.add(giftPayRecord);
|
|
|
|
|
|
// // 支付的赠送金额-退回的赠送金额 = 实际使用赠送金额消费的部分
|
|
|
|
|
|
// virtualAmount = giftPay.subtract(returnGift);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// UpdateMemberBalanceDTO updateMemberBalanceDTO = UpdateMemberBalanceDTO.builder()
|
|
|
|
|
|
// .memberId(orderBasicInfo.getMemberId())
|
|
|
|
|
|
// .type(MemberWalletEnum.TYPE_IN.getValue()) // 进账
|
|
|
|
|
|
// .subType(MemberWalletEnum.SUBTYPE_ORDER_SETTLEMENT_REFUND.getValue()) // 订单结算退款
|
|
|
|
|
|
// .updatePrincipalBalance(returnPrincipal)
|
|
|
|
|
|
// .updateGiftBalance(returnGift)
|
|
|
|
|
|
// .relatedOrderCode(orderBasicInfo.getOrderCode())
|
|
|
|
|
|
// .build();
|
|
|
|
|
|
// memberBasicInfoService.updateMemberBalance(updateMemberBalanceDTO);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testVin() {
|
|
|
|
|
|
String vinCode = "tango";
|
|
|
|
|
|
MemberPlateNumberRelation memberPlateInfoByVinCode = memberPlateNumberRelationService.getMemberPlateInfoByVinCode(vinCode);
|
|
|
|
|
|
System.out.println(memberPlateInfoByVinCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testParking() throws UnsupportedEncodingException {
|
|
|
|
|
|
// GetTokenDTO dto = new GetTokenDTO();
|
|
|
|
|
|
// dto.setAppId("I2qa3hdr116100dc");
|
|
|
|
|
|
// dto.setSecretKey("2qa3hdr13754a8e");
|
|
|
|
|
|
// String token = ltytService.getToken(dto);
|
|
|
|
|
|
// System.out.println(token);
|
|
|
|
|
|
|
|
|
|
|
|
BindCouponDTO dto = new BindCouponDTO();
|
|
|
|
|
|
dto.setAppId("I2qa3hdr116100dc");
|
|
|
|
|
|
dto.setSecretKey("2qa3hdr13754a8e");
|
|
|
|
|
|
dto.setMerchantId("3prv98bm8db70a9");
|
|
|
|
|
|
dto.setCouponId("3prvd0q7a4817bf");
|
|
|
|
|
|
dto.setPlateNumber("贵A12345");
|
|
|
|
|
|
dto.setPlateColor(1);
|
|
|
|
|
|
String s = ltytService.bindCoupon(dto);
|
|
|
|
|
|
System.out.println(s);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testUpdateConnectorStatus() {
|
|
|
|
|
|
String pileConnectorCode = "8800000000000101";
|
|
|
|
|
|
String status = PileConnectorStatusEnum.FREE.getValue();
|
|
|
|
|
|
pileConnectorInfoService.updateConnectorStatus(pileConnectorCode, status);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testOrder() throws Exception {
|
|
|
|
|
|
// 通过vin码查询数据库绑定用户信息
|
|
|
|
|
|
MemberPlateNumberRelation plateInfo = memberPlateNumberRelationService.getMemberPlateInfoByVinCode("LNBSCC4H1LT107646");
|
|
|
|
|
|
GenerateOrderDTO dto = new GenerateOrderDTO();
|
|
|
|
|
|
dto.setMemberPlateNumberRelation(plateInfo);
|
|
|
|
|
|
dto.setPileSn("88000000000126");
|
|
|
|
|
|
dto.setConnectorCode("01");
|
|
|
|
|
|
dto.setStartMode(StartModeEnum.VIN_CODE.getValue());
|
|
|
|
|
|
dto.setMemberId(plateInfo.getMemberId());
|
|
|
|
|
|
// 通过memberId获取账户余额
|
|
|
|
|
|
MemberVO memberVO = memberBasicInfoService.queryMemberInfoByMemberId(dto.getMemberId());
|
|
|
|
|
|
if (memberVO == null) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_GET_MEMBER_ACCOUNT_AMOUNT_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
BigDecimal totalAccountAmount = memberVO.getTotalAccountAmount();
|
|
|
|
|
|
if (totalAccountAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_BALANCE_IS_INSUFFICIENT);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dto.setChargeAmount(totalAccountAmount); // 充电金额
|
|
|
|
|
|
dto.setPayMode(OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue()); // 1-余额支付
|
|
|
|
|
|
|
|
|
|
|
|
OrderBasicInfo basicInfo = orderBasicInfoService.generateOrder(dto);
|
|
|
|
|
|
|
|
|
|
|
|
// 支付订单
|
|
|
|
|
|
PayOrderDTO payOrderDTO = new PayOrderDTO();
|
|
|
|
|
|
payOrderDTO.setOrderCode(basicInfo.getOrderCode());
|
|
|
|
|
|
payOrderDTO.setPayAmount(totalAccountAmount);
|
|
|
|
|
|
payOrderDTO.setPayMode(dto.getPayMode());
|
|
|
|
|
|
payOrderDTO.setMemberId(dto.getMemberId());
|
|
|
|
|
|
// payOrderDTO.setCode();
|
|
|
|
|
|
// payOrderDTO.setLockValue();
|
|
|
|
|
|
// payOrderDTO.setOrderBasicInfo(basicInfo);
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = orderBasicInfoService.payOrder(payOrderDTO);
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(map);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testTransactionRecord() {
|
|
|
|
|
|
// 获取消息体
|
|
|
|
|
|
String msg = "8823000000123302230707215317078588230000001233020000341507071763023615070717b02a0200a00f0000000000003016000090dc010000000000000000000000000020c50100000000000000000000000000888a0100000000000000000000000000b0220749005032074900a00f000000000000e01500004c4e425343433448314c543130373634360563023615070717450000000000000000";
|
|
|
|
|
|
byte[] msgBody = BytesUtil.str2Bcd(msg);
|
|
|
|
|
|
|
|
|
|
|
|
int startIndex = 0;
|
|
|
|
|
|
int length = 16;
|
|
|
|
|
|
|
|
|
|
|
|
// 交易流水号
|
|
|
|
|
|
byte[] orderCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String transactionCode = BytesUtil.bcd2Str(orderCodeByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// 桩编码
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 7;
|
|
|
|
|
|
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// 枪号
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 1;
|
|
|
|
|
|
byte[] connectorCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String connectorCode = BytesUtil.bcd2Str(connectorCodeByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 开始时间 CP56Time2a 格式
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 7;
|
|
|
|
|
|
byte[] startTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
// String binary = BytesUtil.binary(startTimeByteArr, 16);
|
|
|
|
|
|
Date startDate = Cp56Time2aUtil.byte2Hdate(startTimeByteArr);
|
|
|
|
|
|
String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, startDate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 结束时间 CP56Time2a 格式
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] endTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
Date endDate = Cp56Time2aUtil.byte2Hdate(endTimeByteArr);
|
|
|
|
|
|
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, endDate);
|
|
|
|
|
|
|
|
|
|
|
|
// 尖单价 精确到小数点后五位(尖电费+尖服务费,见费率帧)
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 4;
|
|
|
|
|
|
byte[] sharpPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String sharpPrice = YKCUtils.convertDecimalPoint(sharpPriceByteArr, 5);
|
|
|
|
|
|
|
|
|
|
|
|
// 尖电量 精确到小数点后四位
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 4;
|
|
|
|
|
|
byte[] sharpUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String sharpUsedElectricity = YKCUtils.convertDecimalPoint(sharpUsedElectricityByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 计损尖电量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] sharpPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String sharpPlanLossElectricity = YKCUtils.convertDecimalPoint(sharpPlanLossElectricityByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 尖金额
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] sharpAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String sharpAmount = YKCUtils.convertDecimalPoint(sharpAmountByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 峰单价 精确到小数点后五位(峰电费+峰服务费)
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] peakPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String peakPrice = YKCUtils.convertDecimalPoint(peakPriceByteArr, 5);
|
|
|
|
|
|
|
|
|
|
|
|
// 峰电量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] peakUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String peakUsedElectricity = YKCUtils.convertDecimalPoint(peakUsedElectricityByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 计损峰电量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] peakPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String peakPlanLossElectricity = YKCUtils.convertDecimalPoint(peakPlanLossElectricityByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 峰金额
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] peakAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String peakAmount = YKCUtils.convertDecimalPoint(peakAmountByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 平单价 精确到小数点后五位(平电费+平服务费)
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] flatPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String flatPrice = YKCUtils.convertDecimalPoint(flatPriceByteArr, 5);
|
|
|
|
|
|
|
|
|
|
|
|
// 平电量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] flatUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String flatUsedElectricity = YKCUtils.convertDecimalPoint(flatUsedElectricityByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 计损平电量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] flatPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String flatPlanLossElectricity = YKCUtils.convertDecimalPoint(flatPlanLossElectricityByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 平金额
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] flatAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String flatAmount = YKCUtils.convertDecimalPoint(flatAmountByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 谷单价 精确到小数点后五位(谷电费+谷 服务费)
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] valleyPriceByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String valleyPrice = YKCUtils.convertDecimalPoint(valleyPriceByteArr, 5);
|
|
|
|
|
|
|
|
|
|
|
|
// 谷电量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] valleyUsedElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String valleyUsedElectricity = YKCUtils.convertDecimalPoint(valleyUsedElectricityByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 计损谷电量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] valleyPlanLossElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String valleyPlanLossElectricity = YKCUtils.convertDecimalPoint(valleyPlanLossElectricityByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 谷金额
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] valleyAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String valleyAmount = YKCUtils.convertDecimalPoint(valleyAmountByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 电表总起值
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 5;
|
|
|
|
|
|
byte[] ammeterTotalStartByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String ammeterTotalStart = YKCUtils.convertDecimalPoint(ammeterTotalStartByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 电表总止值
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] ammeterTotalEndByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String ammeterTotalEnd = YKCUtils.convertDecimalPoint(ammeterTotalEndByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 总电量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 4;
|
|
|
|
|
|
byte[] totalElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String totalElectricity = YKCUtils.convertDecimalPoint(totalElectricityByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 计损总电量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] planLossTotalElectricityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String planLossTotalElectricity = YKCUtils.convertDecimalPoint(planLossTotalElectricityByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// 消费金额 精确到小数点后四位,包含电费、 服务费
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] consumptionAmountByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String consumptionAmount = YKCUtils.convertDecimalPoint(consumptionAmountByteArr, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// VIN 码 VIN 码,此处 VIN 码和充电时 VIN 码不同, 正序直接上传, 无需补 0 和反序
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 17;
|
|
|
|
|
|
byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String vinCode = BytesUtil.ascii2Str(vinCodeByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 交易标识
|
|
|
|
|
|
* 0x01: app 启动
|
|
|
|
|
|
* 0x02:卡启动
|
|
|
|
|
|
* 0x04:离线卡启动
|
|
|
|
|
|
* 0x05: vin 码启动充电
|
|
|
|
|
|
*/
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 1;
|
|
|
|
|
|
byte[] transactionIdentifierByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String transactionIdentifier = BytesUtil.bcd2Str(transactionIdentifierByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// 交易时间 CP56Time2a 格式
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 7;
|
|
|
|
|
|
byte[] transactionTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
Date transactionDate = Cp56Time2aUtil.byte2Hdate(transactionTimeByteArr);
|
|
|
|
|
|
String transactionTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, transactionDate);
|
|
|
|
|
|
|
|
|
|
|
|
// 停止原因
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 1;
|
|
|
|
|
|
byte[] stopReasonByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String stopReason = BytesUtil.bin2HexStr(stopReasonByteArr);
|
|
|
|
|
|
String stopReasonMsg = YKCChargingStopReasonEnum.getMsgByCode(Integer.parseInt(stopReason, 16));
|
|
|
|
|
|
|
|
|
|
|
|
// 物理卡号 不足 8 位补 0
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 8;
|
|
|
|
|
|
byte[] cardNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
// byte[] logicCardNum = BytesUtil.checkLengthAndBehindAppendZero(cardNumByteArr, 16);
|
|
|
|
|
|
String logicCard = BytesUtil.binary(cardNumByteArr, 16);
|
|
|
|
|
|
// log.info("桩号:{}发送交易记录物理卡号:{}", pileSn, logicCard);
|
|
|
|
|
|
//
|
|
|
|
|
|
// log.info("[===交易记录===]交易流水号:{}, 桩编号:{}, 枪号:{}, 开始时间:{}, 结束时间:{}, 尖单价:{}, 尖电量:{}, 计损尖电量:{}, 尖金额:{}, " +
|
|
|
|
|
|
// "峰单价:{}, 峰电量:{}, 计损峰电量:{}, 峰金额:{}, 平单价:{}, 平电量:{}, 计损平电量:{}, 平金额:{}, " +
|
|
|
|
|
|
// "谷单价:{}, 谷电量:{}, 计损谷电量:{}, 谷金额:{}, 电表总起值:{}, 电表总止值:{}, 总电量:{}, 计损总电量:{}, 消费金额:{}, " +
|
|
|
|
|
|
// "电动汽车唯一标识:{}, 交易标识:{}, 交易日期、时间:{}, 停止原因码:{}, 停止原因描述:{}, 物理卡号:{}",
|
|
|
|
|
|
// transactionCode, pileSn, connectorCode, startTime, endTime, sharpPrice, sharpUsedElectricity, sharpPlanLossElectricity, sharpAmount,
|
|
|
|
|
|
// peakPrice, peakUsedElectricity, peakPlanLossElectricity, peakAmount, flatPrice, flatUsedElectricity, flatPlanLossElectricity, flatAmount,
|
|
|
|
|
|
// valleyPrice, valleyUsedElectricity, valleyPlanLossElectricity, valleyAmount, ammeterTotalStart, ammeterTotalEnd, totalElectricity, planLossTotalElectricity,
|
|
|
|
|
|
// consumptionAmount, vinCode, transactionIdentifier, transactionTime, stopReason, stopReasonMsg, logicCard);
|
|
|
|
|
|
|
|
|
|
|
|
// 交易记录封装到对象里
|
|
|
|
|
|
TransactionRecordsData data = TransactionRecordsData.builder()
|
|
|
|
|
|
// .orderCode(transactionCode)
|
|
|
|
|
|
.transactionCode(transactionCode)
|
|
|
|
|
|
.pileSn(pileSn)
|
|
|
|
|
|
.connectorCode(connectorCode)
|
|
|
|
|
|
.startTime(startTime)
|
|
|
|
|
|
.endTime(endTime)
|
|
|
|
|
|
.sharpPrice(sharpPrice)
|
|
|
|
|
|
.sharpUsedElectricity(sharpUsedElectricity)
|
|
|
|
|
|
.sharpPlanLossElectricity(sharpPlanLossElectricity)
|
|
|
|
|
|
.sharpAmount(sharpAmount)
|
|
|
|
|
|
.peakPrice(peakPrice)
|
|
|
|
|
|
.peakUsedElectricity(peakUsedElectricity)
|
|
|
|
|
|
.peakPlanLossElectricity(peakPlanLossElectricity)
|
|
|
|
|
|
.peakAmount(peakAmount)
|
|
|
|
|
|
.flatPrice(flatPrice)
|
|
|
|
|
|
.flatUsedElectricity(flatUsedElectricity)
|
|
|
|
|
|
.flatPlanLossElectricity(flatPlanLossElectricity)
|
|
|
|
|
|
.flatAmount(flatAmount)
|
|
|
|
|
|
.valleyPrice(valleyPrice)
|
|
|
|
|
|
.valleyUsedElectricity(valleyUsedElectricity)
|
|
|
|
|
|
.valleyPlanLossElectricity(valleyPlanLossElectricity)
|
|
|
|
|
|
.valleyAmount(valleyAmount)
|
|
|
|
|
|
.ammeterTotalStart(ammeterTotalStart)
|
|
|
|
|
|
.ammeterTotalEnd(ammeterTotalEnd)
|
|
|
|
|
|
.totalElectricity(totalElectricity)
|
|
|
|
|
|
.planLossTotalElectricity(planLossTotalElectricity)
|
|
|
|
|
|
.consumptionAmount(consumptionAmount)
|
|
|
|
|
|
.vinCode(vinCode)
|
|
|
|
|
|
.transactionIdentifier(transactionIdentifier)
|
|
|
|
|
|
.transactionTime(transactionTime)
|
|
|
|
|
|
.stopReasonMsg(stopReasonMsg)
|
|
|
|
|
|
.logicCard(logicCard)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
// boolean flag = !StringUtils.equals("0000000000000000", "a511101970000000");
|
|
|
|
|
|
// System.out.println(flag);
|
|
|
|
|
|
|
|
|
|
|
|
// 处理订单加锁
|
|
|
|
|
|
String lockKey = "settle_order_" + transactionCode;
|
|
|
|
|
|
String uuid = IdUtils.fastUUID();
|
|
|
|
|
|
try {
|
|
|
|
|
|
// redis锁
|
|
|
|
|
|
Boolean isLock = redisCache.lock(lockKey, uuid, 1500);
|
|
|
|
|
|
if (isLock) {
|
|
|
|
|
|
// transactionRecordsRequestHandler.processOrder(data);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
System.out.println("处理订单发生异常: " + e);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
if (uuid.equals(redisCache.getCacheObject(lockKey).toString())) {
|
|
|
|
|
|
redisCache.unLock(lockKey);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testFault() {
|
|
|
|
|
|
StringBuffer sb = new StringBuffer("0100");
|
|
|
|
|
|
String lowOrder = sb.substring(0, 2);
|
|
|
|
|
|
String highOrder = sb.substring(2, 4);
|
|
|
|
|
|
|
|
|
|
|
|
// String hardwareFault = highOrder + lowOrder;
|
|
|
|
|
|
byte[] hardwareFaultByteArr = BytesUtil.str2Bcd(highOrder + lowOrder);
|
|
|
|
|
|
String binStr = BytesUtil.bytes2BinStr(hardwareFaultByteArr);
|
|
|
|
|
|
// log.info("binStr:{}", binStr); // 0000 0000 0000 0001
|
|
|
|
|
|
int faultCode = 0;
|
|
|
|
|
|
for (int i = 0; i < binStr.length(); i++) {
|
|
|
|
|
|
if (binStr.charAt(i) == '1') {
|
|
|
|
|
|
faultCode = 15 - i;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
String faultReason = YKCPileFaultReasonEnum.getValueByCode(faultCode);
|
|
|
|
|
|
System.out.println(faultReason);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testQueryCorpMember() {
|
|
|
|
|
|
List<AdapayMemberAccount> accountList = adapayMemberAccountService.selectAdapayMemberAccountList(new AdapayMemberAccount());
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(accountList)) {
|
|
|
|
|
|
Long[] ids = accountList.stream().map(AdapayMemberAccount::getId).toArray(Long[]::new);
|
|
|
|
|
|
adapayMemberAccountService.deleteAdapayMemberAccountByIds(ids);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// Map<String, Object> map = adapayMemberService.selectAdapayMember("5");
|
|
|
|
|
|
//
|
|
|
|
|
|
// String adapayMemberId = "ACM29562569";
|
|
|
|
|
|
// AdapayCorpMemberVO adapayCorpMemberVO = adapayMemberService.queryCorpAdapayMemberInfo(adapayMemberId);
|
|
|
|
|
|
// System.out.println(adapayCorpMemberVO);
|
|
|
|
|
|
//
|
|
|
|
|
|
//
|
|
|
|
|
|
// } catch (BaseAdaPayException e) {
|
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testGetPileListByStationIdList() {
|
|
|
|
|
|
|
|
|
|
|
|
// List<String> stationIdList = Lists.newArrayList("2");
|
|
|
|
|
|
// Map<String, List<AMapEquipmentInfo>> pileListByStationIdList = aMapService.getPileListByStationIdList(stationIdList);
|
|
|
|
|
|
// System.out.println(pileListByStationIdList);
|
|
|
|
|
|
|
|
|
|
|
|
GetStationInfoDTO dto = new GetStationInfoDTO();
|
|
|
|
|
|
dto.setType("page");
|
|
|
|
|
|
aMapService.getStationInfosV2(dto);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testMultiSave() {
|
|
|
|
|
|
String prefix = "test_multi_save:";
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> redisMap = Maps.newHashMap();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 1000; i++) {
|
|
|
|
|
|
redisMap.put(prefix + i, PileInfoVO.builder().pileSn(i + "").build());
|
|
|
|
|
|
}
|
|
|
|
|
|
redisCache.multiSave(redisMap, 60);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testBillingTemplate() {
|
|
|
|
|
|
pileBillingTemplateService.queryStationBillingTemplateListForUniApp("2");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testQueryAdapayMemberInfo() {
|
|
|
|
|
|
String adapayMemberId = "AM25703321";
|
|
|
|
|
|
String settleAccountId = "0489089447022976";
|
|
|
|
|
|
try {
|
|
|
|
|
|
// adapayMemberService.queryAdapayMemberInfo(adapayMemberId);
|
|
|
|
|
|
|
|
|
|
|
|
adapayService.queryAdapaySettleAccount(adapayMemberId, settleAccountId, "");
|
|
|
|
|
|
} catch (BaseAdaPayException e) {
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testSaveAdapayCallbackRecord() throws JsonProcessingException {
|
|
|
|
|
|
String data = "{\n" +
|
|
|
|
|
|
" \"object\": \"refund\",\n" +
|
|
|
|
|
|
" \"status\": \"succeeded\",\n" +
|
|
|
|
|
|
" \"prod_mode\": \"true\",\n" +
|
|
|
|
|
|
" \"id\": \"0022120230531111946980509821471137853440\",\n" +
|
|
|
|
|
|
" \"refund_order_no\": \"823725974557265920\",\n" +
|
|
|
|
|
|
" \"payment_id\": \"002212023053110524210509814658135928832\",\n" +
|
|
|
|
|
|
" \"payment_order_no\": \"C27262970851\",\n" +
|
|
|
|
|
|
" \"refund_amt\": \"7.82\",\n" +
|
|
|
|
|
|
" \"fee_amt\": \"0.04\",\n" +
|
|
|
|
|
|
" \"channel_no\": \"2023053121R064uj\",\n" +
|
|
|
|
|
|
" \"created_time\": \"1685503187000\",\n" +
|
|
|
|
|
|
" \"succeed_time\": \"1685503199000\",\n" +
|
|
|
|
|
|
" \"app_id\": \"app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa\",\n" +
|
|
|
|
|
|
" \"reason\": \"\",\n" +
|
|
|
|
|
|
" \"notify_url\": \"https://api.jsowellcloud.com/uniapp/pay/adapayRefundCallback\"\n" +
|
|
|
|
|
|
"}";
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
|
|
|
|
|
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
|
|
|
AdapayRefundRecord adapayRefundRecord = mapper.readValue(jsonObject.toJSONString(), AdapayRefundRecord.class);
|
|
|
|
|
|
adapayRefundRecord.setRefundId(jsonObject.getString("id"));
|
|
|
|
|
|
// 保存到数据库
|
|
|
|
|
|
adapayRefundRecordService.insertAdapayRefundRecord(adapayRefundRecord);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testQueryCallback() {
|
|
|
|
|
|
AdapayCallbackRecord aaaa = adapayCallbackRecordService.selectByOrderCode("aaaa");
|
|
|
|
|
|
System.out.println(aaaa);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testAdapayRefund() {
|
|
|
|
|
|
// 创建汇付退款对象 在完成初始化设置情况下,调用方法,获取 Refund对象
|
|
|
|
|
|
try {
|
|
|
|
|
|
String id = "002212023052710075810508353847861903360";
|
|
|
|
|
|
String refundAmount = "0.01";
|
|
|
|
|
|
Map<String, Object> refundParams = Maps.newHashMap();
|
|
|
|
|
|
refundParams.put("refund_amt", AdapayUtil.formatAmount(refundAmount));
|
|
|
|
|
|
refundParams.put("refund_order_no", SnowflakeIdWorker.getSnowflakeId());
|
|
|
|
|
|
refundParams.put("notify_url", "https://api.jsowellcloud.com/uniapp/pay/adapayRefundCallback");
|
|
|
|
|
|
Map<String, Object> response = Refund.create(id, refundParams);
|
|
|
|
|
|
System.out.println(JSON.toJSONString(response));
|
|
|
|
|
|
// if (response != null && !response.isEmpty()) {
|
|
|
|
|
|
// JSONObject jsonObject = JSONObject.parseObject(response.get("expend").toString());
|
|
|
|
|
|
// JSONObject pay_info = jsonObject.getJSONObject("pay_info");
|
|
|
|
|
|
// Map<String, Object> resultMap = JSONObject.parseObject(pay_info.toJSONString(), new TypeReference<Map<String, Object>>() {});
|
|
|
|
|
|
// }
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
System.out.println(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testSaveCallback() throws JsonProcessingException {
|
|
|
|
|
|
String data = "{\"app_id\":\"app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa\",\"created_time\":\"20230530132956\",\"description\":\"{\\\"orderCode\\\":\\\"C29505932783\\\",\\\"type\\\":\\\"order\\\"}\",\"end_time\":\"20230530133027\",\"expend\":{\"bank_type\":\"OTHERS\",\"open_id\":\"o8jhot6PJF93EPhNISsXi28dKdS8\",\"sub_open_id\":\"o4REX5MprZfTaLnVNxfdOY-wnwGI\"},\"fee_amt\":\"0.11\",\"id\":\"002212023053013295610509491838664794112\",\"order_no\":\"C29505932783\",\"out_trans_id\":\"4200001855202305308670391485\",\"party_order_id\":\"02212305304859640306711\",\"pay_amt\":\"20.00\",\"pay_channel\":\"wx_lite\",\"real_amt\":\"20.00\",\"share_eq\":\"Y\",\"status\":\"succeeded\",\"wx_user_id\":\"\"}";
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
|
|
|
|
|
|
AdapayCallbackRecord adapayCallbackRecord = mapper.readValue(jsonObject.toJSONString(), AdapayCallbackRecord.class);
|
|
|
|
|
|
adapayCallbackRecord.setExpend(jsonObject.getString("expend"));
|
|
|
|
|
|
adapayCallbackRecord.setPaymentId(jsonObject.getString("id"));
|
|
|
|
|
|
adapayCallbackRecordService.saveAdapayCallbackRecord(adapayCallbackRecord);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testAMap() throws Exception {
|
|
|
|
|
|
String pileConnectorCode = "8800000000012601";
|
|
|
|
|
|
// String s = aMapService.pushChargingDeviceDynamics(pileConnectorCode);
|
|
|
|
|
|
GetStationInfoDTO dto = new GetStationInfoDTO();
|
|
|
|
|
|
dto.setType("page");
|
|
|
|
|
|
aMapService.getStationInfos(dto);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testVinCode() {
|
|
|
|
|
|
String msg = "880000000000210203000000000000000000000000000000000000000000000000004C5257594743454B584D43303437313434";
|
|
|
|
|
|
// 获取消息体
|
|
|
|
|
|
byte[] msgBody = BytesUtil.str2Bcd(msg);
|
|
|
|
|
|
|
|
|
|
|
|
int startIndex = 0;
|
|
|
|
|
|
int length = 7;
|
|
|
|
|
|
|
|
|
|
|
|
// 桩编码
|
|
|
|
|
|
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String pileSn = BytesUtil.binary(pileSnByteArr, 16);
|
|
|
|
|
|
|
|
|
|
|
|
// 保存时间
|
|
|
|
|
|
// saveLastTime(pileSn);
|
|
|
|
|
|
|
|
|
|
|
|
// 枪号
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 1;
|
|
|
|
|
|
byte[] connectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String connectorCode = BytesUtil.bcd2Str(connectorNumByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// 启动方式
|
|
|
|
|
|
// 0x01 表示通过刷卡启动充电
|
|
|
|
|
|
// 0x02 表求通过帐号启动充电 (暂不支持)
|
|
|
|
|
|
// 0x03 表示vin码启动充电
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] startModeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String startMode = BytesUtil.bcd2Str(startModeByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// 是否需要密码 0x00 不需要 0x01 需要
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] needPasswordFlagByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String needPasswordFlag = BytesUtil.bcd2Str(needPasswordFlagByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// 物理卡号 不足 8 位补 0
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 8;
|
|
|
|
|
|
byte[] cardNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String physicsCard = BytesUtil.binary(cardNumByteArr, 16);
|
|
|
|
|
|
|
|
|
|
|
|
// 输入密码 对用户输入的密码进行16 位MD5 加密,采用小写上传
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 16;
|
|
|
|
|
|
byte[] inputPasswordByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
// VIN码
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 17;
|
|
|
|
|
|
byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String vinCode = BytesUtil.ascii2Str(vinCodeByteArr);
|
|
|
|
|
|
System.out.println("桩号:" + pileSn + "申请充电VIN码:" + vinCode);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 刷卡启动充电
|
|
|
|
|
|
*/
|
|
|
|
|
|
String logicCard = "";
|
|
|
|
|
|
byte[] authenticationFlagByteArr = Constants.zeroByteArray; // 鉴权成功标识
|
|
|
|
|
|
byte[] accountBalanceByteArr = Constants.zeroByteArray; // 账户余额
|
|
|
|
|
|
String transactionCode = "";
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
/**
|
|
|
|
|
|
* VIN码启动充电
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (StringUtils.equals("03", startMode)) {
|
|
|
|
|
|
// 通过vin码查询数据库绑定用户信息
|
|
|
|
|
|
MemberPlateNumberRelation plateInfo = memberPlateNumberRelationService.getMemberPlateInfoByVinCode(vinCode);
|
|
|
|
|
|
if (plateInfo == null) {
|
|
|
|
|
|
throw new BusinessException("", "未查到绑定用户信息");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!StringUtils.equals("1", plateInfo.getVinStatus())) {
|
|
|
|
|
|
// 1- 正常使用
|
|
|
|
|
|
throw new BusinessException("", "vin状态不正确");
|
|
|
|
|
|
}
|
|
|
|
|
|
// vin码生成订单 vin启动充电
|
|
|
|
|
|
GenerateOrderDTO dto = new GenerateOrderDTO();
|
|
|
|
|
|
dto.setMemberPlateNumberRelation(plateInfo);
|
|
|
|
|
|
dto.setPileSn(pileSn);
|
|
|
|
|
|
dto.setConnectorCode(connectorCode);
|
|
|
|
|
|
dto.setStartMode(StartModeEnum.VIN_CODE.getValue());
|
|
|
|
|
|
Map<String, Object> map = orderBasicInfoService.generateOrderByCard(dto);
|
|
|
|
|
|
if (map != null) {
|
|
|
|
|
|
transactionCode = (String) map.get("transactionCode");
|
|
|
|
|
|
accountBalanceByteArr = YKCUtils.getPriceByte(String.valueOf(map.get("accountBalance")), 2);
|
|
|
|
|
|
// 鉴权成功标识 0x00 失败 0x01 成功
|
|
|
|
|
|
authenticationFlagByteArr = Constants.oneByteArray;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
throw new BusinessException("", "生成vin订单失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (BusinessException e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
System.out.println("1");
|
|
|
|
|
|
// log.error("VIN码启动充电鉴权 error:{}, {}", e.getCode(), e.getMessage());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
System.out.println("2");
|
|
|
|
|
|
transactionCode = "00000000000000000000000000000000";
|
|
|
|
|
|
accountBalanceByteArr = BytesUtil.checkLengthAndBehindAppendZero(accountBalanceByteArr, 8);
|
|
|
|
|
|
authenticationFlagByteArr = Constants.zeroByteArray;
|
|
|
|
|
|
// log.error("VIN码启动充电鉴权 error", e);
|
|
|
|
|
|
}
|
|
|
|
|
|
byte[] serialNumByteArr = BytesUtil.str2Bcd(transactionCode);
|
|
|
|
|
|
|
|
|
|
|
|
byte[] defeatReasonByteArr = Constants.zeroByteArray;
|
|
|
|
|
|
|
|
|
|
|
|
// 不足位数的值补零
|
|
|
|
|
|
// cardNumByteArr = BytesUtil.checkLengthAndBehindAppendZero(cardNumByteArr, 16);
|
|
|
|
|
|
// serialNumByteArr = BytesUtil.checkLengthAndBehindAppendZero(serialNumByteArr, 32);
|
|
|
|
|
|
// pileSnByteArr = BytesUtil.checkLengthAndBehindAppendZero(pileSnByteArr, 14);
|
|
|
|
|
|
// accountBalanceByteArr = BytesUtil.checkLengthAndBehindAppendZero(accountBalanceByteArr, 8);
|
|
|
|
|
|
|
|
|
|
|
|
// 拼装消息体
|
|
|
|
|
|
byte[] msgBodyByteArr = Bytes.concat(serialNumByteArr, pileSnByteArr, connectorNumByteArr, cardNumByteArr, accountBalanceByteArr,
|
|
|
|
|
|
authenticationFlagByteArr, defeatReasonByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
String s = BytesUtil.bin2HexStr(msgBodyByteArr);
|
|
|
|
|
|
System.out.println(s);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testGenerateLianlianToken() throws UnsupportedEncodingException {
|
|
|
|
|
|
String OperatorID = "425010765";
|
|
|
|
|
|
String OperatorSecret = "123123123123aaaa"; // 1234567890abcdef
|
|
|
|
|
|
|
|
|
|
|
|
//请求dataX
|
|
|
|
|
|
Map<String, String> data = new HashMap<>();
|
|
|
|
|
|
data.put("OperatorID", OperatorID);
|
|
|
|
|
|
data.put("OperatorSecret", OperatorSecret);
|
|
|
|
|
|
String dataJson = JSONUtil.toJsonStr(data);
|
|
|
|
|
|
|
|
|
|
|
|
//加密
|
|
|
|
|
|
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes(StandardCharsets.UTF_8),
|
|
|
|
|
|
OperatorSecret.getBytes(), OperatorSecret.getBytes());
|
|
|
|
|
|
String strData = Encodes.encodeBase64(encryptText);
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> request = new LinkedHashMap<>();
|
|
|
|
|
|
request.put("OperatorID", OperatorID);
|
|
|
|
|
|
request.put("Data", strData);
|
|
|
|
|
|
request.put("TimeStamp", System.currentTimeMillis() + "");
|
|
|
|
|
|
request.put("Seq", "0001");
|
|
|
|
|
|
|
|
|
|
|
|
//生成签名
|
|
|
|
|
|
String sig = GBSignUtils.sign(request, OperatorSecret);
|
|
|
|
|
|
request.put("Sig", sig);
|
|
|
|
|
|
String tokenRequest = JSONUtil.toJsonStr(request);
|
|
|
|
|
|
|
|
|
|
|
|
CommonParamsDTO dto = JSONObject.parseObject(tokenRequest, CommonParamsDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
lianLianService.generateToken(dto);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testupdateElecAmount() {
|
|
|
|
|
|
// orderBasicInfoService.updateElecAmount();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testSelectSomeStatusCardInfo() {
|
|
|
|
|
|
PileAuthCard pileAuthCard = pileAuthCardService.selectCardInfoByLogicCard("1111111111111111");
|
|
|
|
|
|
System.out.println(pileAuthCard);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testLianLian() throws UnsupportedEncodingException {
|
|
|
|
|
|
// 获取令牌
|
|
|
|
|
|
// LianLianGetTokenDTO dto = new LianLianGetTokenDTO();
|
|
|
|
|
|
// dto.setOperatorId("MA1JLFUU8");
|
|
|
|
|
|
// dto.setOperatorSecret("Nh62XxlIR5OjAzFj");
|
|
|
|
|
|
// String token = lianLianService.getToken("", "MA1JLFUU8", "fGwLsxW1HdzLw7jp");
|
|
|
|
|
|
// System.out.println("token:" + token);
|
|
|
|
|
|
|
|
|
|
|
|
String operatorId = "425010765";
|
|
|
|
|
|
String operatorSecret = "3DSBTWHVIC6KVCKI";
|
|
|
|
|
|
// 请求data
|
|
|
|
|
|
// Map<String, String> data = new HashMap<>();
|
|
|
|
|
|
// data.put("OperatorID", operatorId);
|
|
|
|
|
|
// data.put("OperatorSecret", operatorSecret);
|
|
|
|
|
|
// String dataJson = JSONUtil.toJsonStr(data);
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
|
// json.put("StationIDs", com.google.common.collect.Lists.newArrayList("1", "2"));
|
|
|
|
|
|
json.put("LastQueryTime", "2023-05-29 10:00:00");
|
|
|
|
|
|
json.put("PageNo", 1);
|
|
|
|
|
|
json.put("PageSize", 10);
|
|
|
|
|
|
|
|
|
|
|
|
String dataJson = JSONObject.toJSONString(json);
|
|
|
|
|
|
// 加密
|
|
|
|
|
|
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes(StandardCharsets.UTF_8),
|
|
|
|
|
|
operatorSecret.getBytes(), operatorSecret.getBytes());
|
|
|
|
|
|
String strData = Encodes.encodeBase64(encryptText);
|
|
|
|
|
|
String timeStamp = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date());
|
|
|
|
|
|
Map<String, String> request = new LinkedHashMap<>();
|
|
|
|
|
|
request.put("OperatorID", operatorId);
|
|
|
|
|
|
request.put("Data", strData);
|
|
|
|
|
|
request.put("TimeStamp", timeStamp);
|
|
|
|
|
|
request.put("Seq", "0001");
|
|
|
|
|
|
|
|
|
|
|
|
// 生成签名
|
|
|
|
|
|
String sig = GBSignUtils.sign(request, operatorSecret);
|
|
|
|
|
|
request.put("Sig", sig);
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(request);
|
|
|
|
|
|
System.out.println(jsonObject);
|
|
|
|
|
|
// CommonParamsDTO dto = new CommonParamsDTO();
|
|
|
|
|
|
// dto.setOperatorID(operatorId);
|
|
|
|
|
|
// dto.setData(strData);
|
|
|
|
|
|
// dto.setTimeStamp(timeStamp);
|
|
|
|
|
|
// dto.setSeq("0001");
|
|
|
|
|
|
// dto.setSig(sig);
|
|
|
|
|
|
// Map<String, String> map = lianLianService.generateToken(dto);
|
|
|
|
|
|
QueryStationInfoDTO dto = new QueryStationInfoDTO();
|
|
|
|
|
|
dto.setOperatorId(operatorId);
|
|
|
|
|
|
Map<String, String> map = lianLianService.query_stations_info(dto);
|
|
|
|
|
|
// String data1 = map.get("Data");
|
|
|
|
|
|
// 解密data
|
|
|
|
|
|
// String data1 = "JudlP17tnYuQc2zwOzmjJAb9hgghIymefG5v3ZzSOlPDh5+bJHIedsYzKMD56tHlmlg6Cb7vG+o6KjMSSpn1fyqBH3UVaEFF7uEc+lOuEc9c1vUzq20vBQ7N3EpDKqVBKjZbOezMsKYaCX7Br8XTsCYT8VCQui/np3cn+phi3VC+0s1coNxBX7xoEDZ7iuPjPoSWL7g3J0uOw2SoGaIdBQG3eTxaZJ5L+vBmuDF0pEXgazTMnuKml1mx1QHkig2F7h/ILT0VEKVXWMmmogYgiBk5ItO0DyzRl+ASb184gOhYGo82GJmWRiXrAXmceCiSNvTGg6aL26imIGKkJNfOx9/9mTqjGvy6kzxvWJ29PBU=";
|
|
|
|
|
|
// byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data1),
|
|
|
|
|
|
// operatorSecret.getBytes(), operatorSecret.getBytes());
|
|
|
|
|
|
// String dataStr = new String(plainText, "UTF-8");
|
|
|
|
|
|
// Map<String, String> resultMap = (Map<String, String>) JSON.parse(dataStr);
|
|
|
|
|
|
//
|
|
|
|
|
|
// String token = resultMap.get("AccessToken");
|
|
|
|
|
|
//
|
|
|
|
|
|
// System.out.println("解密后token:" + token);
|
|
|
|
|
|
|
|
|
|
|
|
// LianLianPushStationInfoDTO dto1 = LianLianPushStationInfoDTO.builder()
|
|
|
|
|
|
// .OperatorID("MA1JLFUU8")
|
|
|
|
|
|
// .DataSecret("HVicnbRZbhPdIdpF")
|
|
|
|
|
|
// .DataSecretIV("JNvcjSOn1vhrE11M")
|
|
|
|
|
|
// .SigSecret("53TtFpc4gdVZbF3x")
|
|
|
|
|
|
// // .token(token)
|
|
|
|
|
|
// .stationId(2L)
|
|
|
|
|
|
//
|
|
|
|
|
|
// .build();
|
|
|
|
|
|
// lianLianService.pushStationInfo(dto1);
|
|
|
|
|
|
|
|
|
|
|
|
// 推送订单状态
|
|
|
|
|
|
// lianLianService.pushConnectorStatus("8800000000000101", "1");
|
|
|
|
|
|
|
|
|
|
|
|
// 推送订单信息
|
|
|
|
|
|
// lianLianService.pushOrderInfo("C27680791529");
|
|
|
|
|
|
|
|
|
|
|
|
// 推送启动充电结果
|
|
|
|
|
|
// lianLianService.pushStartChargeResult("C27680791529");
|
|
|
|
|
|
|
|
|
|
|
|
// 推送充电状态
|
|
|
|
|
|
// lianLianService.pushChargeStatus("C27680791529");
|
|
|
|
|
|
|
|
|
|
|
|
// 推送停止充电结果
|
|
|
|
|
|
// lianLianService.pushStopChargeResult("C27680791529");
|
|
|
|
|
|
|
|
|
|
|
|
// 推送充电订单信息
|
|
|
|
|
|
// lianLianService.pushChargeOrderInfo("C27680791529");
|
|
|
|
|
|
|
|
|
|
|
|
// 推送订单结算信息
|
|
|
|
|
|
// lianLianService.pushOrderSettlementInfo("C27680791529");
|
|
|
|
|
|
|
|
|
|
|
|
// 查询订单结算信息
|
|
|
|
|
|
// lianLianService.queryOrderSettlementInfo("C27680791529");
|
|
|
|
|
|
|
|
|
|
|
|
// 推送订单对账结果信息
|
|
|
|
|
|
// lianLianService.pushOrderReconciliationInfo("C27680791529");
|
|
|
|
|
|
|
|
|
|
|
|
// 测试生成、解密令牌
|
|
|
|
|
|
// long ttlMillis = 60 * 60 * 24 * 1000;
|
|
|
|
|
|
// String token = JWTUtils.createToken(operatorId, operatorSecret, ttlMillis);
|
|
|
|
|
|
// System.out.println(JWTUtils.checkThirdPartyToken(token));
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject1 = new JSONObject(map);
|
|
|
|
|
|
jsonObject1.put("OperatorID", "425010765");
|
|
|
|
|
|
jsonObject1.put("Data", "Ntu99RpveEOm2VUNq6RpD7OuOPXRbNxMOPmaBl67nkLk0nD/VmhipdSpq/Qfswhe1o55YMT+3Z7e6xe3fiJA3cZcvetxOEUF6sjvKLRq2rU=");
|
|
|
|
|
|
jsonObject1.put("TimeStamp", "20230530090132");
|
|
|
|
|
|
jsonObject1.put("Seq", "0001");
|
|
|
|
|
|
jsonObject1.put("Sig", "1568D2D35B245A0205B33D0EF92E7981");
|
|
|
|
|
|
|
|
|
|
|
|
String jsonString = JSONObject.toJSONString(jsonObject1);
|
|
|
|
|
|
|
|
|
|
|
|
String result = HttpUtils.sendPostContentType("http://localhost:8080/LianLian/v1/query_stations_info", jsonString, "application/json");
|
|
|
|
|
|
JSONObject object = JSONObject.parseObject(result);
|
|
|
|
|
|
String data1 = (String) object.get("data");
|
|
|
|
|
|
// 解密data
|
|
|
|
|
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data1),
|
|
|
|
|
|
operatorSecret.getBytes(), operatorSecret.getBytes());
|
|
|
|
|
|
String dataStr = new String(plainText, "UTF-8");
|
|
|
|
|
|
Map<String, String> resultMap = (Map<String, String>) JSON.parse(dataStr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testRefundForBalance() {
|
|
|
|
|
|
BigDecimal refundAmount = new BigDecimal("2");
|
|
|
|
|
|
// 退款金额 元转分 123
|
|
|
|
|
|
int refundTotalCents = refundAmount.multiply(new BigDecimal(100)).intValue();
|
|
|
|
|
|
|
|
|
|
|
|
// 查询用户充值余额订单 过滤掉已经退款的充值订单 refundableOrder
|
|
|
|
|
|
List<RefundableWxPayOrderData> recordList = Lists.newArrayList();
|
|
|
|
|
|
// recordList.add(RefundableWxPayOrderData.builder().outTradeNo("1").transactionId("1").payerAmount(new BigDecimal("1000")).refundableAmount(new BigDecimal("0")).build());
|
|
|
|
|
|
// recordList.add(RefundableWxPayOrderData.builder().outTradeNo("2").transactionId("2").payerAmount(new BigDecimal("1000")).refundableAmount(new BigDecimal("0")).build());
|
|
|
|
|
|
recordList.add(RefundableWxPayOrderData.builder().outTradeNo("3").transactionId("3").payerAmount(new BigDecimal("500")).refundableAmount(new BigDecimal("300")).build());
|
|
|
|
|
|
|
|
|
|
|
|
// 也许需要多笔支付订单才够退款
|
|
|
|
|
|
List<WechatPayRefundRequest> requestList = com.google.common.collect.Lists.newArrayList();
|
|
|
|
|
|
WechatPayRefundRequest request;
|
|
|
|
|
|
for (RefundableWxPayOrderData record : recordList) {
|
|
|
|
|
|
int refundableTotal = record.getRefundableAmount().intValue(); // 该笔支付订单的可退金额,单位分
|
|
|
|
|
|
int payerTotal = record.getPayerAmount().intValue(); // 该笔支付订单的支付金额,单位分
|
|
|
|
|
|
// 用户申请退款金额-可退金额
|
|
|
|
|
|
refundTotalCents = refundTotalCents - refundableTotal; // 123 - 100
|
|
|
|
|
|
request = new WechatPayRefundRequest();
|
|
|
|
|
|
request.setTransaction_id(record.getTransactionId()); // 微信支付单号
|
|
|
|
|
|
request.setOut_trade_no(record.getOutTradeNo()); // 商户订单号
|
|
|
|
|
|
request.setOut_refund_no(SnowflakeIdWorker.getSnowflakeId()); // 商户退款单号
|
|
|
|
|
|
request.setNotify_url(WeChatPayParameter.refundNotifyUrl); // 回调接口
|
|
|
|
|
|
request.setReason("用户余额退款");
|
|
|
|
|
|
request.setFunds_account("AVAILABLE");
|
|
|
|
|
|
if (refundTotalCents > 0) {
|
|
|
|
|
|
// 如果大于0说明,这笔单退完也不够
|
|
|
|
|
|
WechatPayRefundRequest.Amount amount = new WechatPayRefundRequest.Amount();
|
|
|
|
|
|
amount.setRefund(refundableTotal); // 退款金额
|
|
|
|
|
|
amount.setTotal(payerTotal); // 原订单金额
|
|
|
|
|
|
request.setAmount(amount);
|
|
|
|
|
|
requestList.add(request);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 如果小于0,这笔单退一部分
|
|
|
|
|
|
// 生成退款单号
|
|
|
|
|
|
WechatPayRefundRequest.Amount amount = new WechatPayRefundRequest.Amount();
|
|
|
|
|
|
// 部分退
|
|
|
|
|
|
int i = refundableTotal + refundTotalCents;
|
|
|
|
|
|
amount.setRefund(i); // 退款金额
|
|
|
|
|
|
amount.setTotal(payerTotal); // 原订单金额
|
|
|
|
|
|
request.setAmount(amount);
|
|
|
|
|
|
requestList.add(request);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(requestList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testCloseStartFailedOrder() {
|
|
|
|
|
|
String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addDays(new Date(), -2));
|
|
|
|
|
|
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
|
|
|
|
|
|
orderBasicInfoService.closeStartFailedOrder(startTime, endTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testRedisSaveRealTimeData() {
|
|
|
|
|
|
String pileSn = "88000000000001";
|
|
|
|
|
|
String connectorCode = "01";
|
|
|
|
|
|
String orderCode = "88000000000001012211161342359448";
|
|
|
|
|
|
|
|
|
|
|
|
String pileConnectorCode = pileSn + connectorCode;
|
|
|
|
|
|
String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + pileConnectorCode + "_" + orderCode;
|
|
|
|
|
|
|
|
|
|
|
|
// for (int i = 0; i < 10; i++) {
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// Thread.sleep(10000);
|
|
|
|
|
|
// } catch (InterruptedException e) {
|
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// Date now = new Date();
|
|
|
|
|
|
// redisCache.hset(redisKey, DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", now), i + ":" + DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", now));
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
orderBasicInfoService.getChargingRealTimeData(orderCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testuniformMessageSend() {
|
|
|
|
|
|
AppletTemplateMessageSendDTO appletTemplateMessageSendDTO = new AppletTemplateMessageSendDTO();
|
|
|
|
|
|
// String openId = wxAppletRemoteService.getOpenIdByCode("0537u2100jTXsP1Y0Y300j426t47u210");
|
|
|
|
|
|
// System.out.println("openId:" + openId);
|
|
|
|
|
|
|
|
|
|
|
|
appletTemplateMessageSendDTO.setTouser("o4REX5MprZfTaLnVNxfdOY-wnwGI"); // openid
|
|
|
|
|
|
|
|
|
|
|
|
String templateId = "UyBPbADlZfsCj89rh_xvfZGlxTW5J5KURpZtt9CNFrY";
|
|
|
|
|
|
appletTemplateMessageSendDTO.setTemplate_id(templateId);
|
|
|
|
|
|
// appletTemplateMessageSendDTO.setPage("跳转的页面");
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
map.put("amount17", ImmutableMap.of("value", "¥100")); // 结束时间
|
|
|
|
|
|
map.put("time3", ImmutableMap.of("value", "2022-12-30")); // 结束时间
|
|
|
|
|
|
map.put("thing7", ImmutableMap.of("value", "thing7")); // 结束原因
|
|
|
|
|
|
|
|
|
|
|
|
// map.put("thing5", ImmutableMap.of("value", "thing5")); // 结束原因
|
|
|
|
|
|
// map.put("time2", ImmutableMap.of("value", "time2")); // 结束原因
|
|
|
|
|
|
appletTemplateMessageSendDTO.setData(map);
|
|
|
|
|
|
|
|
|
|
|
|
wxAppletRemoteService.uniformMessageSend(appletTemplateMessageSendDTO);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testWeChatRefund() {
|
|
|
|
|
|
ApplyRefundDTO dto = new ApplyRefundDTO();
|
|
|
|
|
|
dto.setRefundType("2");
|
|
|
|
|
|
dto.setMemberId("82100864");
|
|
|
|
|
|
dto.setRefundAmount(new BigDecimal("1.23"));
|
|
|
|
|
|
orderBasicInfoService.weChatRefund(dto);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testSelectBalanceRechargeRecord() {
|
|
|
|
|
|
List<WxpayCallbackRecord> list = wxpayCallbackRecordService.queryBalanceRechargeRecordOfTheLatestYear("82100864");
|
|
|
|
|
|
System.out.println(list);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testSelectOrderBasicInfoList() {
|
|
|
|
|
|
QueryOrderDTO orderBasicInfo = new QueryOrderDTO();
|
|
|
|
|
|
orderBasicInfo.setPileSn("88000000000001");
|
|
|
|
|
|
orderBasicInfo.setOrderStatus(OrderStatusEnum.IN_THE_CHARGING.getValue());
|
|
|
|
|
|
List<OrderListVO> orderListVOS = orderBasicInfoService.selectOrderBasicInfoList(orderBasicInfo);
|
|
|
|
|
|
System.out.println(orderListVOS);
|
|
|
|
|
|
for (OrderListVO orderListVO : orderListVOS) {
|
|
|
|
|
|
if (StringUtils.equals(orderListVO.getOrderStatus(), OrderStatusEnum.IN_THE_CHARGING.getValue())) {
|
|
|
|
|
|
// 修改数据库订单状态
|
|
|
|
|
|
OrderBasicInfo info = OrderBasicInfo.builder()
|
|
|
|
|
|
.id(Long.parseLong(orderListVO.getId()))
|
|
|
|
|
|
.orderStatus(OrderStatusEnum.ABNORMAL.getValue())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
orderBasicInfoService.updateOrderBasicInfo(info);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testWechatRefund() throws JsonProcessingException {
|
|
|
|
|
|
WechatPayRefundRequest request = new WechatPayRefundRequest();
|
|
|
|
|
|
request.setTransaction_id("4200001656202212302746036536"); // 微信支付单号
|
|
|
|
|
|
request.setOut_trade_no("768677222373363712"); // 商户订单号
|
|
|
|
|
|
// 生成退款单号
|
|
|
|
|
|
request.setOut_refund_no(SnowflakeIdWorker.getSnowflakeId()); // 商户退款单号
|
|
|
|
|
|
request.setNotify_url(WeChatPayParameter.refundNotifyUrl); // 回调接口
|
|
|
|
|
|
WechatPayRefundRequest.Amount amount = new WechatPayRefundRequest.Amount();
|
|
|
|
|
|
amount.setRefund(10 * 100); // 退款金额
|
|
|
|
|
|
amount.setTotal(10 * 100); // 原订单金额
|
|
|
|
|
|
request.setAmount(amount);
|
|
|
|
|
|
request.setReason("结算退款");
|
|
|
|
|
|
request.setFunds_account("AVAILABLE");
|
|
|
|
|
|
|
|
|
|
|
|
wechatPayService.ApplyForWechatPayRefundV3(request);
|
|
|
|
|
|
|
|
|
|
|
|
// 退款方法
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testUpdatePileSimInfo() {
|
|
|
|
|
|
String pileSn = "88000000000001";
|
|
|
|
|
|
String iccid = "89860402102091089943";
|
|
|
|
|
|
pileBasicInfoService.updatePileSimInfo(pileSn, iccid);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testPay() {
|
|
|
|
|
|
String code = "081zIoGa11GamE0iVVIa1aaJ4G0zIoGE";
|
|
|
|
|
|
String openId = memberService.getOpenIdByCode(code);
|
|
|
|
|
|
Map<String, Object> pay = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
WeixinPayDTO dto = new WeixinPayDTO();
|
|
|
|
|
|
dto.setOpenId(openId);
|
|
|
|
|
|
dto.setAmount("0.01");
|
|
|
|
|
|
pay = orderService.weixinPayV3(dto);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
System.out.println(JSONObject.toJSONString(pay));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testMemberRegisterAndLogin() throws BaseAdaPayException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testMemberBasicInfoMapper() {
|
|
|
|
|
|
// String memberId = "21772870";
|
|
|
|
|
|
// BigDecimal principalBalance = new BigDecimal("-10");
|
|
|
|
|
|
// BigDecimal giftBalance = new BigDecimal("-110");
|
|
|
|
|
|
// Integer version = 2;
|
|
|
|
|
|
// int i = memberBasicInfoMapper.updateMemberBalance(memberId, principalBalance, giftBalance, version);
|
|
|
|
|
|
// if (i == 1) {
|
|
|
|
|
|
// System.out.println("更新余额成功");
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// System.out.println("更新余额失败");
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> refundParams = new HashMap<>(2);
|
|
|
|
|
|
refundParams.put("payment_id", "002212023071011321210524320114191904768");
|
|
|
|
|
|
// refundParams.put("refund_id", refund_id);
|
|
|
|
|
|
// refundParams.put("refund_order_no", refund_order_no);
|
|
|
|
|
|
try {
|
|
|
|
|
|
Map<String, Object> refund = Refund.query(refundParams);
|
|
|
|
|
|
System.out.println(refund);
|
|
|
|
|
|
} catch (BaseAdaPayException e) {
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testGenerateBillingTemplateMsgBody() {
|
|
|
|
|
|
String pileSn = "88000000000001";
|
|
|
|
|
|
// 根据桩号查询计费模板
|
|
|
|
|
|
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
|
|
|
|
|
|
|
|
|
|
|
|
byte[] messageBody = pileBillingTemplateService.generateBillingTemplateMsgBody(pileSn, billingTemplateVO);
|
|
|
|
|
|
System.out.println(BytesUtil.binary(messageBody, 16));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testAnalysisPileParameter() {
|
|
|
|
|
|
BasicPileDTO dto = new BasicPileDTO();
|
|
|
|
|
|
// 3个都不传的情况
|
|
|
|
|
|
try {
|
|
|
|
|
|
System.out.println("3个都不传的情况");
|
|
|
|
|
|
dto.setPileSn("");
|
|
|
|
|
|
dto.setConnectorCode("");
|
|
|
|
|
|
dto.setPileConnectorCode("");
|
|
|
|
|
|
// orderService.analysisPileParameter(dto);
|
|
|
|
|
|
System.out.println("数据正确");
|
|
|
|
|
|
} catch (BusinessException e) {
|
|
|
|
|
|
System.out.println(e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
System.out.println();
|
|
|
|
|
|
|
|
|
|
|
|
// 只传sn的情况
|
|
|
|
|
|
try {
|
|
|
|
|
|
System.out.println("只传sn的情况");
|
|
|
|
|
|
dto.setConnectorCode("");
|
|
|
|
|
|
dto.setPileConnectorCode("");
|
|
|
|
|
|
dto.setPileSn("88000000000001");
|
|
|
|
|
|
// orderService.analysisPileParameter(dto);
|
|
|
|
|
|
System.out.println("数据正确");
|
|
|
|
|
|
} catch (BusinessException e) {
|
|
|
|
|
|
System.out.println(e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
System.out.println();
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
try {
|
|
|
|
|
|
System.out.println("只穿枪口号的情况");
|
|
|
|
|
|
dto.setConnectorCode("01");
|
|
|
|
|
|
dto.setPileConnectorCode("");
|
|
|
|
|
|
dto.setPileSn("");
|
|
|
|
|
|
// orderService.analysisPileParameter(dto);
|
|
|
|
|
|
System.out.println("数据正确");
|
|
|
|
|
|
} catch (BusinessException e) {
|
|
|
|
|
|
System.out.println(e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
System.out.println();
|
|
|
|
|
|
|
|
|
|
|
|
// 只传充电桩枪口编号的情况
|
|
|
|
|
|
try {
|
|
|
|
|
|
System.out.println("只传充电桩枪口编号的情况");
|
|
|
|
|
|
dto.setPileConnectorCode("8800000000000101");
|
|
|
|
|
|
dto.setConnectorCode("");
|
|
|
|
|
|
dto.setPileSn("");
|
|
|
|
|
|
// orderService.analysisPileParameter(dto);
|
|
|
|
|
|
System.out.println("数据正确");
|
|
|
|
|
|
} catch (BusinessException e) {
|
|
|
|
|
|
System.out.println(e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
System.out.println();
|
|
|
|
|
|
System.out.println("传充电桩枪sn+枪口号的情况");
|
|
|
|
|
|
dto.setPileConnectorCode("");
|
|
|
|
|
|
dto.setConnectorCode("01");
|
|
|
|
|
|
dto.setPileSn("88000000000001");
|
|
|
|
|
|
// orderService.analysisPileParameter(dto);
|
|
|
|
|
|
System.out.println("数据正确");
|
|
|
|
|
|
} catch (BusinessException e) {
|
|
|
|
|
|
System.out.println(e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testImportBillingTemplate() {
|
|
|
|
|
|
ImportBillingTemplateDTO dto = new ImportBillingTemplateDTO();
|
|
|
|
|
|
dto.setBillingTemplateId("1");
|
|
|
|
|
|
// 查询公共计费模板是否存在
|
|
|
|
|
|
PileBillingTemplate pileBillingTemplate = pileBillingTemplateMapper.selectPileBillingTemplateById(Long.valueOf(dto.getBillingTemplateId()));
|
|
|
|
|
|
if (pileBillingTemplate == null) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
List<PileBillingDetail> billingDetailList = pileBillingTemplate.getPileBillingDetailList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testProcess() {
|
|
|
|
|
|
// 62 68
|
|
|
|
|
|
String msgString = "680da300000388000000000001010020d06840a40000130000000000000000000000000000000088000000000001010202000000000000000000000000000000000000000000000000000000000000000000001516";
|
|
|
|
|
|
byte[] msg = BytesUtil.str2Bcd(msgString);
|
|
|
|
|
|
boolean b = YKCUtils.checkMsg(msg);
|
|
|
|
|
|
// ykcBusinessService.process(msg, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testHeartbeat() {
|
|
|
|
|
|
// heartbeatRequestHandler.updateStatus("88000000000001", "01", "0");
|
|
|
|
|
|
|
|
|
|
|
|
// heartbeatRequestHandler.updateStatus("88000000000001", "02", "0");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testPush() {
|
|
|
|
|
|
byte[] msg = new byte[]{};
|
|
|
|
|
|
String pileSn = "88000000000001";
|
|
|
|
|
|
// ykcPushBusinessService.push(msg, pileSn, YKCFrameTypeCode.READ_REAL_TIME_MONITOR_DATA_CODE);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void TestMapUtils() {
|
|
|
|
|
|
String address = "淀山湖镇黄浦江南路278号";
|
|
|
|
|
|
String areaCode = "320000,320500,320583";
|
|
|
|
|
|
Map<String, String> longitudeAndLatitude = AddressUtils.getLongitudeAndLatitude(areaCode, address);
|
|
|
|
|
|
System.out.println(longitudeAndLatitude);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testCreatePile() {
|
|
|
|
|
|
BatchCreatePileDTO dto = BatchCreatePileDTO.builder()
|
|
|
|
|
|
.merchantId("1")
|
|
|
|
|
|
.stationId("1")
|
|
|
|
|
|
.softwareProtocol("1")
|
|
|
|
|
|
// .connectorNum(1)
|
|
|
|
|
|
// .num(10)
|
|
|
|
|
|
// .productionDate(new Date())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
pileService.batchCreatePile(dto);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testGetIncre() {
|
|
|
|
|
|
StopWatch stopWatch = new StopWatch();
|
|
|
|
|
|
|
|
|
|
|
|
// 生成100个
|
|
|
|
|
|
stopWatch.start("生成100个sn号");
|
|
|
|
|
|
List<String> list2 = snUtils.generateSN(1);
|
|
|
|
|
|
stopWatch.stop();
|
|
|
|
|
|
System.out.println(list2);
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(stopWatch.getLastTaskTimeMillis());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testDict() {
|
|
|
|
|
|
// String dictValue = DictUtils.getDictValue("query_pile_info", "url");
|
|
|
|
|
|
// String station_type = DictUtils.getDictLabel("station_type", "1");
|
|
|
|
|
|
// System.out.println(station_type);
|
|
|
|
|
|
// System.out.println("123");
|
|
|
|
|
|
|
|
|
|
|
|
List<SysDictData> adapay_station = DictUtils.getDictCache("adapay_station");
|
|
|
|
|
|
List<String> stationIdList = com.google.common.collect.Lists.newArrayList();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(adapay_station)) {
|
|
|
|
|
|
for (SysDictData sysDictData : adapay_station) {
|
|
|
|
|
|
stationIdList.add(sysDictData.getDictValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
System.out.println(stationIdList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testSelectByMerchantId() {
|
|
|
|
|
|
List<PileStationInfo> list = pileStationInfoService.selectStationListByMerchantId(Long.valueOf(Constants.ONE));
|
|
|
|
|
|
System.out.println(list);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testStr2Bcd() {
|
|
|
|
|
|
String logicCardNum = "00000000";
|
|
|
|
|
|
byte[] logicCardNumByteArr = BytesUtil.str2Bcd(logicCardNum);
|
|
|
|
|
|
System.out.println(Arrays.toString(logicCardNumByteArr));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testBigDecimalMultiply() {
|
|
|
|
|
|
BigDecimal a = new BigDecimal("216.5");
|
|
|
|
|
|
BigDecimal b = new BigDecimal("11.5");
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal result = a.multiply(b).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
System.out.println(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testRemoteUpdate() {
|
|
|
|
|
|
ArrayList<String> list = new ArrayList<>();
|
|
|
|
|
|
list.add("88000000000001");
|
|
|
|
|
|
// pileRemoteService.updateFirmware(list);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testGetUserPhoneNum() {
|
|
|
|
|
|
String code = "0e5394cfa4eb41c6181ed257f2368a86dfe4ebdac0a4fac85df63657637e6cc3";
|
|
|
|
|
|
wxAppletRemoteService.getMobileNumberByCode(code);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testDistance() {
|
|
|
|
|
|
QueryStationDTO dto = new QueryStationDTO();
|
|
|
|
|
|
dto.setStationLat("123.2222");
|
|
|
|
|
|
dto.setStationLng("55.6232");
|
|
|
|
|
|
|
|
|
|
|
|
// pileStationInfoService.uniAppQueryStationInfos(dto);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生成英文字母随机数 RandomStringUtils.randomAlphabetic(10);
|
|
|
|
|
|
* 生成数字随机数 RandomStringUtils.randomNumeric(10);
|
|
|
|
|
|
* 字母+数字结合 RandomStringUtils.randomAlphanumeric(10);
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void Test() throws ParseException {
|
2023-03-04 16:29:55 +08:00
|
|
|
|
/*String s = RandomStringUtils.randomAlphanumeric(32);
|
|
|
|
|
|
System.out.println(s); // PuLe4Tyyg1jSFNPhF5d2Ts9ejRn6E8KQ
|
|
|
|
|
|
String str = "JS160829";
|
|
|
|
|
|
System.out.println(Md5Utils.hash(str).toUpperCase(Locale.ROOT));
|
|
|
|
|
|
*/
|
2023-08-30 11:02:18 +08:00
|
|
|
|
String s = RandomStringUtils.randomAlphanumeric(43).toUpperCase(Locale.ROOT);
|
|
|
|
|
|
System.out.println(s);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
Date startTimeDate = sdf.parse("2022-11-26 10:44:11");
|
|
|
|
|
|
Date endTimeDate = sdf.parse("2022-11-27 12:45:11");
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-30 11:02:18 +08:00
|
|
|
|
System.out.println(DateUtils.getDatePoor(endTimeDate, startTimeDate)); // 1天2小时1分钟
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*String stra = "sp_mchid=1632405339&sub_mchid=1632405339&out_trade_no=1217752501201407033233368318&sp_appid=wxbb3e0d474569481d&sub_appid=wxbb3e0d474569481d" +
|
|
|
|
|
|
"bbac689f4654b209de4d6944808ec80b";
|
|
|
|
|
|
System.out.println(Md5Utils.hash(stra).toUpperCase(Locale.ROOT));*/
|
2023-08-30 11:02:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testSimCard() throws ParseException {
|
|
|
|
|
|
ArrayList<String> list = Lists.newArrayList();
|
|
|
|
|
|
Collections.addAll(list, "898607B9102090253556", "898607B9102090253560");
|
|
|
|
|
|
// String s = list.toString().replaceAll("(?:\\[|null|\\]| +)", "");
|
|
|
|
|
|
// System.out.println(s);
|
|
|
|
|
|
// List<SimCardVO> simCardVOList = simCardService.selectSimCardInfoByIccId(list);
|
|
|
|
|
|
// System.out.println(simCardVOList.toString());
|
|
|
|
|
|
|
|
|
|
|
|
// simCardService.XunZhongSimRenewal(list, 12);
|
|
|
|
|
|
// System.out.println(s);
|
|
|
|
|
|
|
|
|
|
|
|
// SimCardVO simCardVO = simCardService.searchByLoop("898607B9102090253556");
|
|
|
|
|
|
//
|
|
|
|
|
|
// System.out.println(simCardVO.toString());
|
|
|
|
|
|
|
|
|
|
|
|
simCardService.WuLianSimRenew(list, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testRefund() {
|
|
|
|
|
|
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode("88000000000001012212171045412218");
|
|
|
|
|
|
orderInfo.setReason("充电异常中止,急停开入");
|
|
|
|
|
|
|
|
|
|
|
|
TransactionRecordsData data = TransactionRecordsData.builder()
|
|
|
|
|
|
.transactionCode("88000000000001012212171045412218")
|
|
|
|
|
|
.consumptionAmount(String.valueOf(0.00))
|
|
|
|
|
|
.stopReasonMsg(orderInfo.getReason())
|
|
|
|
|
|
.totalElectricity("0")
|
|
|
|
|
|
.sharpUsedElectricity("0")
|
|
|
|
|
|
.peakUsedElectricity("0")
|
|
|
|
|
|
.flatUsedElectricity("0")
|
|
|
|
|
|
.valleyUsedElectricity("0")
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
2023-09-01 15:45:04 +08:00
|
|
|
|
// orderBasicInfoService.settleOrder(data, orderInfo);
|
2023-08-30 11:02:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testLoginHandler() {
|
|
|
|
|
|
String msg = "8800000000001001010f63362d333000000000898604b319227036282200";
|
|
|
|
|
|
byte[] msgBody = BytesUtil.str2Bcd(msg);
|
|
|
|
|
|
|
|
|
|
|
|
int startIndex = 0;
|
|
|
|
|
|
int length = 7;
|
|
|
|
|
|
|
|
|
|
|
|
// 桩编码
|
|
|
|
|
|
byte[] pileSnByte = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String pileSn = BytesUtil.binary(pileSnByte, 16);
|
|
|
|
|
|
// log.info("桩号:{}", pileSn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 桩类型 0 表示直流桩, 1 表示交流桩
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 1;
|
|
|
|
|
|
byte[] pileTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String pileType = BytesUtil.bcd2Str(pileTypeByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// 充电枪数量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] connectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String connectorNum = BytesUtil.bcd2Str(connectorNumByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// 通信协议版本 版本号乘 10,v1.0 表示 0x0A
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] communicationVersionByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
// int i = Integer.parseInt(BytesUtil.bcd2Str(communicationVersionByteArr)); // 0F --> 15
|
|
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(BytesUtil.bcd2Str(communicationVersionByteArr));
|
|
|
|
|
|
BigDecimal communicationVersionTemp = bigDecimal.divide(new BigDecimal(10));
|
|
|
|
|
|
String communicationVersion = "v" + communicationVersionTemp;
|
|
|
|
|
|
|
|
|
|
|
|
// 程序版本
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 8;
|
|
|
|
|
|
byte[] programVersionByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String programVersion = BytesUtil.bcd2Str(programVersionByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// 网络连接类型 0x00 SIM 卡 0x01 LAN 0x02 WAN 0x03 其他
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 1;
|
|
|
|
|
|
byte[] internetConnectionTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String internetConnection = BytesUtil.bcd2Str(internetConnectionTypeByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// sim卡
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 10;
|
|
|
|
|
|
byte[] simCardNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String iccid = BytesUtil.bin2HexStr(simCardNumByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// 运营商 0x00 移动 0x02 电信 0x03 联通 0x04 其他
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 1;
|
|
|
|
|
|
byte[] businessTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String business = BytesUtil.bcd2Str(businessTypeByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
LoginRequestData loginRequestData = LoginRequestData.builder()
|
|
|
|
|
|
.pileSn(pileSn)
|
|
|
|
|
|
.pileType(pileType)
|
|
|
|
|
|
.connectorNum(connectorNum)
|
|
|
|
|
|
.communicationVersion(communicationVersion)
|
|
|
|
|
|
.programVersion(programVersion)
|
|
|
|
|
|
.internetConnection(internetConnection)
|
|
|
|
|
|
.iccid(iccid)
|
|
|
|
|
|
.business(business)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
// 结果(默认 0x01:登录失败)
|
|
|
|
|
|
byte[] flag = Constants.oneByteArray;
|
|
|
|
|
|
|
|
|
|
|
|
// 通过桩编码SN查询数据库,如果有数据,则登录成功,否则登录失败
|
|
|
|
|
|
QueryPileDTO dto = new QueryPileDTO();
|
|
|
|
|
|
dto.setPileSn(pileSn);
|
|
|
|
|
|
List<PileDetailVO> list = pileBasicInfoService.queryPileInfos(dto);
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
|
|
flag = Constants.zeroByteArray;
|
|
|
|
|
|
// 登录成功,保存桩号和channel的关系
|
|
|
|
|
|
|
|
|
|
|
|
// PileChannelEntity.put(pileSn, channel);
|
|
|
|
|
|
// 更改桩和该桩下的枪口状态分别为 在线、空闲
|
|
|
|
|
|
// pileBasicInfoService.updatePileStatus(pileSn, PileStatusEnum.ON_LINE.getValue());
|
|
|
|
|
|
// pileConnectorInfoService.updateConnectorStatusByPileSn(pileSn, PileConnectorDataBaseStatusEnum.FREE.getValue());
|
|
|
|
|
|
|
|
|
|
|
|
// 对时
|
|
|
|
|
|
ProofreadTimeCommand command = ProofreadTimeCommand.builder().pileSn(pileSn).build();
|
|
|
|
|
|
ykcPushCommandService.pushProofreadTimeCommand(command);
|
|
|
|
|
|
|
|
|
|
|
|
// 公共方法修改状态
|
|
|
|
|
|
pileBasicInfoService.updateStatus(BytesUtil.bcd2Str(new byte[]{0x01}), pileSn, null, null, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 下发二维码
|
|
|
|
|
|
IssueQRCodeCommand issueQRCodeCommand = IssueQRCodeCommand.builder().pileSn(pileSn).build();
|
|
|
|
|
|
ykcPushCommandService.pushIssueQRCodeCommand(issueQRCodeCommand);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 充电桩使用的sim卡,把信息存库
|
|
|
|
|
|
if (StringUtils.equals("00", internetConnection)) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
pileBasicInfoService.updatePileSimInfo(pileSn, iccid);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// log.error("更新充电桩sim卡信息失败", e);
|
|
|
|
|
|
System.out.println(e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 保存报文
|
|
|
|
|
|
String jsonMsg = JSONObject.toJSONString(loginRequestData);
|
|
|
|
|
|
// pileMsgRecordService.save(pileSn, pileSn, type, jsonMsg, ykcDataProtocol.getHEXString());
|
|
|
|
|
|
|
|
|
|
|
|
// // 消息体
|
|
|
|
|
|
// byte[] messageBody = Bytes.concat(pileSnByte, flag);
|
|
|
|
|
|
// return getResult(ykcDataProtocol, messageBody);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
public void testGetMemberToken() {
|
|
|
|
|
|
String memberId = JWTUtils.getMemberId("eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NzY1MTY5MzgsImV4cCI6MTY3OTEwODkzOH0.4MwhZIOpnCfQloR7zEm2hwPOh2yyI2qxbBbTcv_SnZ4");
|
|
|
|
|
|
System.out.println(memberId);
|
|
|
|
|
|
}
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
}
|