2023-03-04 16:29:55 +08:00
|
|
|
|
package com.jsowell.service;
|
|
|
|
|
|
|
2023-05-27 09:36:07 +08:00
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
2023-07-10 15:14:58 +08:00
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
2023-05-20 10:53: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.github.pagehelper.PageHelper;
|
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
2023-04-14 15:22:27 +08:00
|
|
|
|
import com.google.common.collect.Sets;
|
2023-05-20 10:53:49 +08:00
|
|
|
|
import com.huifu.adapay.core.AdapayCore;
|
|
|
|
|
|
import com.huifu.adapay.core.util.AdapaySign;
|
2023-08-17 16:10:31 +08:00
|
|
|
|
import com.jsowell.adapay.response.PaymentReverseResponse;
|
2023-08-23 16:26:02 +08:00
|
|
|
|
import com.jsowell.common.constant.CacheConstants;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.constant.Constants;
|
2023-03-16 15:23:01 +08:00
|
|
|
|
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
2023-03-16 15:23:01 +08:00
|
|
|
|
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.core.page.PageResponse;
|
2023-08-23 16:26:02 +08:00
|
|
|
|
import com.jsowell.common.core.redis.RedisCache;
|
2023-07-13 16:53:14 +08:00
|
|
|
|
import com.jsowell.common.enums.AcquirerEnum;
|
2023-08-31 10:30:05 +08:00
|
|
|
|
import com.jsowell.common.enums.DelFlagEnum;
|
2023-04-15 17:01:27 +08:00
|
|
|
|
import com.jsowell.common.enums.InvoiceRecordEnum;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.enums.MemberWalletEnum;
|
2023-07-10 16:53:16 +08:00
|
|
|
|
import com.jsowell.common.enums.adapay.AdapayEventEnum;
|
2023-08-29 16:40:20 +08:00
|
|
|
|
import com.jsowell.common.enums.uniapp.OccupyOrderPayStatusEnum;
|
|
|
|
|
|
import com.jsowell.common.enums.uniapp.OccupyOrderStatusEnum;
|
2023-05-20 10:53:49 +08:00
|
|
|
|
import com.jsowell.common.enums.ykc.*;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.exception.BusinessException;
|
2023-07-08 09:45:44 +08:00
|
|
|
|
import com.jsowell.common.util.DateUtils;
|
|
|
|
|
|
import com.jsowell.common.util.SecurityUtils;
|
|
|
|
|
|
import com.jsowell.common.util.StringUtils;
|
2023-03-08 10:00:13 +08:00
|
|
|
|
import com.jsowell.common.util.bean.BeanUtils;
|
2023-05-20 10:53:49 +08:00
|
|
|
|
import com.jsowell.pile.domain.*;
|
|
|
|
|
|
import com.jsowell.pile.dto.*;
|
|
|
|
|
|
import com.jsowell.pile.service.*;
|
2023-09-01 11:41:37 +08:00
|
|
|
|
import com.jsowell.pile.service.orderlogic.AbstractOrderLogic;
|
|
|
|
|
|
import com.jsowell.pile.service.orderlogic.OrderLogicFactory;
|
2023-05-12 15:03:29 +08:00
|
|
|
|
import com.jsowell.pile.vo.base.OrderAmountDetailVO;
|
|
|
|
|
|
import com.jsowell.pile.vo.base.OrderPeriodAmountVO;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.pile.vo.base.PileInfoVO;
|
2023-05-20 10:53:49 +08:00
|
|
|
|
import com.jsowell.pile.vo.base.StationInfoVO;
|
2023-07-05 13:47:35 +08:00
|
|
|
|
import com.jsowell.pile.vo.uniapp.*;
|
2023-07-13 16:56:45 +08:00
|
|
|
|
import com.jsowell.pile.vo.web.OrderDetailInfoVO;
|
|
|
|
|
|
import com.jsowell.pile.vo.web.PileStationVO;
|
|
|
|
|
|
import com.jsowell.pile.vo.web.PlatformTesterVO;
|
|
|
|
|
|
import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.wxpay.response.WechatPayNotifyParameter;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
2023-08-18 09:52:12 +08:00
|
|
|
|
import javax.annotation.Resource;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
import java.text.ParseException;
|
2023-04-11 16:13:06 +08:00
|
|
|
|
import java.time.LocalDateTime;
|
2023-05-20 10:53:49 +08:00
|
|
|
|
import java.util.*;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class OrderService {
|
|
|
|
|
|
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IOrderBasicInfoService orderBasicInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileRemoteService pileRemoteService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileService pileService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private MemberService memberService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IMemberBasicInfoService memberBasicInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2023-08-28 11:17:06 +08:00
|
|
|
|
private OrderPayRecordService orderPayRecordService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private WechatPayService wechatPayService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private WxpayCallbackRecordService wxpayCallbackRecordService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IMemberTransactionRecordService memberTransactionRecordService;
|
|
|
|
|
|
|
2023-03-09 13:34:22 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IPileStationInfoService pileStationInfoService;
|
|
|
|
|
|
|
2023-04-11 16:13:06 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IOrderInvoiceRecordService orderInvoiceRecordService;
|
|
|
|
|
|
|
2023-04-21 09:35:42 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IPileStationWhitelistService pileStationWhitelistService;
|
|
|
|
|
|
|
2023-05-20 10:53:49 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private AdapayCallbackRecordService adapayCallbackRecordService;
|
|
|
|
|
|
|
2023-05-23 10:52:58 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IMemberInvoiceTitleService memberInvoiceTitleService;
|
|
|
|
|
|
|
2023-05-31 16:05:18 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IAdapayRefundRecordService adapayRefundRecordService;
|
|
|
|
|
|
|
2023-06-09 16:13:22 +08:00
|
|
|
|
@Autowired
|
2023-06-15 14:40:11 +08:00
|
|
|
|
private IAdapayMemberAccountService adapayMemberAccountService;
|
2023-06-09 16:13:22 +08:00
|
|
|
|
|
2023-08-08 14:16:05 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private ClearingWithdrawInfoService clearingWithdrawInfoService;
|
|
|
|
|
|
|
2023-08-10 14:41:23 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private MemberAdapayRecordService memberAdapayRecordService;
|
|
|
|
|
|
|
2023-08-18 09:52:12 +08:00
|
|
|
|
@Resource
|
|
|
|
|
|
private OrderPileOccupyService orderPileOccupyService;
|
|
|
|
|
|
|
2023-09-01 11:36:31 +08:00
|
|
|
|
@Resource
|
|
|
|
|
|
private IPileMerchantInfoService pileMerchantInfoService;
|
|
|
|
|
|
|
2023-08-23 16:26:02 +08:00
|
|
|
|
@Resource
|
|
|
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 生成订单
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-03-29 08:21:12 +08:00
|
|
|
|
public String generateOrder(GenerateOrderDTO dto) throws ParseException {
|
2023-07-08 11:03:43 +08:00
|
|
|
|
OrderBasicInfo basicInfo = orderBasicInfoService.generateOrder(dto);
|
|
|
|
|
|
if (basicInfo != null) {
|
|
|
|
|
|
return basicInfo.getOrderCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-01 14:51:39 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 生成订单
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String generateOrderV2(GenerateOrderDTO dto) throws ParseException {
|
|
|
|
|
|
// 新逻辑
|
|
|
|
|
|
String delayMode = pileMerchantInfoService.getDelayModeByWechatAppId(dto.getAppId());
|
|
|
|
|
|
AbstractOrderLogic orderLogic = OrderLogicFactory.getOrderLogic(delayMode);
|
|
|
|
|
|
OrderBasicInfo orderBasicInfo = orderLogic.generateOrder(dto);
|
|
|
|
|
|
if (orderBasicInfo != null) {
|
|
|
|
|
|
return orderBasicInfo.getOrderCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 订单支付
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Map<String, Object> payOrder(PayOrderDTO dto) throws Exception {
|
2023-08-10 14:41:23 +08:00
|
|
|
|
return orderBasicInfoService.payOrder(dto);
|
2023-03-30 15:35:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-12 08:33:45 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 订单支付
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Map<String, Object> payOrderV2(PayOrderDTO dto) {
|
|
|
|
|
|
String mode = pileMerchantInfoService.getDelayModeByWechatAppId(dto.getWechatAppId());
|
|
|
|
|
|
// 获取处理逻辑
|
|
|
|
|
|
AbstractOrderLogic orderLogic = OrderLogicFactory.getOrderLogic(mode);
|
|
|
|
|
|
Map<String, Object> map = orderLogic.payOrder(dto);
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 结算订单
|
|
|
|
|
|
* endCharging
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param dto 结算订单参数
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void settleOrderForWeb(SettleOrderDTO dto) {
|
2023-07-08 09:44:05 +08:00
|
|
|
|
orderBasicInfoService.analysisPileParameter(dto);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
// 查询订单详情,验证订单中的桩编号是否正确
|
|
|
|
|
|
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
|
|
|
|
|
if (orderBasicInfo == null) {
|
2023-08-18 09:52:12 +08:00
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_INFO_IS_NULL);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (!(StringUtils.equals(orderBasicInfo.getPileSn(), dto.getPileSn())
|
|
|
|
|
|
&& StringUtils.equals(orderBasicInfo.getConnectorCode(), dto.getConnectorCode()))) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_PILE_MAPPING_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
// push远程停机指令
|
|
|
|
|
|
pileRemoteService.remoteStopCharging(dto.getPileSn(), dto.getConnectorCode());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通过会员Id查询订单列表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param memberId 会员Id
|
|
|
|
|
|
* @return 订单信息集合
|
|
|
|
|
|
*/
|
|
|
|
|
|
public PageResponse getListByMemberIdAndOrderStatus(String memberId, UniAppQueryOrderDTO dto) throws ParseException {
|
|
|
|
|
|
String orderStatus = dto.getOrderStatus();
|
|
|
|
|
|
if (StringUtils.isBlank(orderStatus)) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
ArrayList<String> orderStatusList = Lists.newArrayList();
|
|
|
|
|
|
if (StringUtils.equals("2", orderStatus)) {
|
|
|
|
|
|
// 查未完成订单
|
|
|
|
|
|
CollectionUtils.addAll(orderStatusList, "0", "1", "2", "3", "4", "5");
|
|
|
|
|
|
} else if (StringUtils.equals("3", orderStatus)) {
|
|
|
|
|
|
// 查已完成订单
|
|
|
|
|
|
orderStatusList.add("6");
|
2023-06-13 13:11:11 +08:00
|
|
|
|
}else if (StringUtils.equals("4", orderStatus)) {
|
|
|
|
|
|
// 查询正在进行中的订单
|
|
|
|
|
|
orderStatusList.add("1");
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 分页
|
|
|
|
|
|
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
|
|
|
|
|
|
List<OrderVO> list = orderBasicInfoService.getListByMemberIdAndOrderStatus(memberId, orderStatusList);
|
|
|
|
|
|
|
|
|
|
|
|
PageInfo<OrderVO> pageInfo = new PageInfo<>(list);
|
|
|
|
|
|
|
|
|
|
|
|
for (OrderVO orderVO : pageInfo.getList()) {
|
|
|
|
|
|
orderVO.setPileConnectorCode(orderVO.getPileSn() + orderVO.getConnectorCode());
|
2023-03-15 14:56:40 +08:00
|
|
|
|
String chargingTime = "0分钟";
|
|
|
|
|
|
if (orderVO.getStartTime() != null) {
|
2023-03-15 14:32:12 +08:00
|
|
|
|
Date startTimeDate = DateUtils.parseDate(orderVO.getStartTime());
|
2023-03-15 15:05:58 +08:00
|
|
|
|
Date endTimeDate;
|
2023-03-15 14:56:40 +08:00
|
|
|
|
if (orderVO.getEndTime() != null) {
|
|
|
|
|
|
endTimeDate = DateUtils.parseDate(orderVO.getEndTime());
|
2023-03-15 15:05:58 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
endTimeDate = new Date();
|
2023-03-15 14:56:40 +08:00
|
|
|
|
}
|
2023-03-15 14:32:12 +08:00
|
|
|
|
// 计算出两个时间差
|
2023-03-15 14:56:40 +08:00
|
|
|
|
chargingTime = DateUtils.getDatePoor(endTimeDate, startTimeDate);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
2023-03-15 14:56:40 +08:00
|
|
|
|
orderVO.setChargingTime(chargingTime);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 返回结果集
|
|
|
|
|
|
PageResponse pageResponse = PageResponse.builder()
|
|
|
|
|
|
.pageNum(dto.getPageNum())
|
|
|
|
|
|
.pageSize(dto.getPageSize())
|
|
|
|
|
|
.list(pageInfo.getList())
|
|
|
|
|
|
.pages(pageInfo.getPages())
|
|
|
|
|
|
.total(pageInfo.getTotal())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
return pageResponse;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 微信支付v3
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Map<String, Object> weixinPayV3(WeixinPayDTO dto) throws Exception {
|
|
|
|
|
|
return wechatPayService.weixinPayV3(dto);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 用户停止充电
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void stopCharging(StopChargingDTO dto) {
|
|
|
|
|
|
// 查订单
|
|
|
|
|
|
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
|
|
|
|
|
if (orderInfo == null) {
|
2023-08-18 09:52:12 +08:00
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_INFO_IS_NULL);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
2023-07-20 15:08:51 +08:00
|
|
|
|
// 判断订单状态是不是已经结算了
|
|
|
|
|
|
if (StringUtils.equals(orderInfo.getOrderStatus(), OrderStatusEnum.ORDER_COMPLETE.getValue())) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_COMPLETE_ERROR);
|
|
|
|
|
|
}
|
2023-03-04 16:29:55 +08:00
|
|
|
|
// 校验订单中的会员与操作会员是否一致
|
|
|
|
|
|
if (!StringUtils.equals(orderInfo.getMemberId(), dto.getMemberId())) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_MEMBER_NOT_MATCH_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 发送停止指令
|
|
|
|
|
|
pileRemoteService.remoteStopCharging(orderInfo.getPileSn(), orderInfo.getConnectorCode());
|
|
|
|
|
|
log.info("订单号:{}发送停机指令成功", dto.getOrderCode());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 微信支付回调
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @param body
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
2023-08-28 15:30:24 +08:00
|
|
|
|
// public void wechatPayCallback(HttpServletRequest request, WechatPayNotifyParameter body) throws Exception {
|
|
|
|
|
|
// // 获取微信支付成功返回的信息
|
|
|
|
|
|
// Map<String, Object> map = wechatPayService.wechatPayCallbackInfo(request, body);
|
|
|
|
|
|
// String type = (String) map.get("type");
|
|
|
|
|
|
// BigDecimal amount = (BigDecimal) map.get("amount"); // 微信给的amount单位是分
|
|
|
|
|
|
// amount = amount.divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP); // 转换为元
|
|
|
|
|
|
//
|
|
|
|
|
|
// String orderCode = (String) map.get("orderCode");
|
|
|
|
|
|
// String memberId = (String) map.get("memberId");
|
|
|
|
|
|
// if (StringUtils.equals(type, ScenarioEnum.ORDER.getValue())) { // 1-订单支付
|
|
|
|
|
|
// // 支付订单成功
|
|
|
|
|
|
// // orderCode = (String) map.get("orderCode");
|
|
|
|
|
|
// PayOrderSuccessCallbackDTO callbackDTO = PayOrderSuccessCallbackDTO.builder()
|
|
|
|
|
|
// .orderCode(orderCode)
|
|
|
|
|
|
// .payAmount(amount)
|
|
|
|
|
|
// .payMode(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())
|
|
|
|
|
|
// .acquirer(AcquirerEnum.WECHAT_PAY.getValue())
|
|
|
|
|
|
// .build();
|
|
|
|
|
|
// // 订单支付成功 支付回调
|
|
|
|
|
|
// orderBasicInfoService.payOrderSuccessCallback(callbackDTO);
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 记录订单支付流水
|
|
|
|
|
|
// // OrderPayRecord orderPayRecord = OrderPayRecord.builder()
|
|
|
|
|
|
// // .orderCode(orderCode)
|
|
|
|
|
|
// // .payMode(OrderPayRecordEnum.WECHATPAY_PAYMENT.getValue())
|
|
|
|
|
|
// // .payAmount(amount)
|
|
|
|
|
|
// // .acquirer(AcquirerEnum.WECHAT_PAY.getValue())
|
|
|
|
|
|
// // .createBy(null)
|
|
|
|
|
|
// // .build();
|
|
|
|
|
|
// // orderPayRecordService.batchInsert(Lists.newArrayList(orderPayRecord));
|
|
|
|
|
|
// } else if (StringUtils.equals(type, ScenarioEnum.BALANCE.getValue())) { // 2-充值余额
|
|
|
|
|
|
// // 充值余额成功
|
|
|
|
|
|
// // memberId = (String) map.get("memberId");
|
|
|
|
|
|
// UpdateMemberBalanceDTO dto = new UpdateMemberBalanceDTO();
|
|
|
|
|
|
// dto.setMemberId(memberId);
|
|
|
|
|
|
// dto.setType(MemberWalletEnum.TYPE_IN.getValue());
|
|
|
|
|
|
// dto.setSubType(MemberWalletEnum.SUBTYPE_TOP_UP.getValue());
|
|
|
|
|
|
// dto.setUpdatePrincipalBalance(amount);
|
|
|
|
|
|
// memberBasicInfoService.updateMemberBalance(dto);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 微信支付订单 记录会员交易流水
|
|
|
|
|
|
// MemberTransactionRecord record = MemberTransactionRecord.builder()
|
|
|
|
|
|
// .orderCode(orderCode)
|
|
|
|
|
|
// .scenarioType(type)
|
|
|
|
|
|
// .memberId(memberId)
|
|
|
|
|
|
// .actionType(ActionTypeEnum.FORWARD.getValue())
|
|
|
|
|
|
// .payMode(PayModeEnum.PAYMENT_OF_WECHATPAY.getValue())
|
|
|
|
|
|
// .paymentInstitutions(PaymentInstitutionsEnum.WECHAT_PAY.getValue())
|
|
|
|
|
|
// .amount(amount) // 单位元
|
|
|
|
|
|
// .outTradeNo(String.valueOf(map.get("out_trade_no")))
|
|
|
|
|
|
// .transactionId(String.valueOf(map.get("transaction_id")))
|
|
|
|
|
|
// .build();
|
|
|
|
|
|
// memberTransactionRecordService.insertSelective(record);
|
|
|
|
|
|
// }
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-07-27 15:08:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 微信退款
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
2023-07-27 16:44:18 +08:00
|
|
|
|
public void weChatRefund(ApplyRefundDTO dto) {
|
2023-03-04 16:29:55 +08:00
|
|
|
|
log.info("微信退款接口 param:{}", JSONObject.toJSONString(dto));
|
|
|
|
|
|
orderBasicInfoService.weChatRefund(dto);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-27 15:08:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 汇付退款
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
2023-08-23 16:46:07 +08:00
|
|
|
|
public void adapayRefund(ApplyRefundDTO dto){
|
2023-05-27 14:59:23 +08:00
|
|
|
|
log.info("汇付退款 param:{}", JSON.toJSONString(dto));
|
2023-05-27 15:24:56 +08:00
|
|
|
|
// 退款有两种情况 1-订单结算退款 2-用户余额退款
|
|
|
|
|
|
String refundType = dto.getRefundType();
|
|
|
|
|
|
if (StringUtils.equals(refundType, "1")) {
|
2023-07-27 17:05:50 +08:00
|
|
|
|
orderBasicInfoService.refundOrderWithAdapay(dto);
|
2023-05-27 15:24:56 +08:00
|
|
|
|
} else if (StringUtils.equals(refundType, "2")) {
|
2023-07-27 17:05:50 +08:00
|
|
|
|
orderBasicInfoService.refundBalanceWithAdapay(dto);
|
2023-05-27 15:24:56 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
log.warn("没有找到退款处理逻辑");
|
|
|
|
|
|
}
|
2023-05-27 14:59:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询订单详情信息
|
|
|
|
|
|
* @param orderCode 订单编号
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public OrderDetailInfoVO queryOrderDetailInfo(String orderCode) {
|
|
|
|
|
|
OrderDetailInfoVO vo = new OrderDetailInfoVO();
|
|
|
|
|
|
|
|
|
|
|
|
// 订单信息
|
|
|
|
|
|
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
|
|
|
|
|
if (orderBasicInfo == null) {
|
|
|
|
|
|
return vo;
|
|
|
|
|
|
}
|
|
|
|
|
|
OrderDetailInfoVO.OrderInfo order = new OrderDetailInfoVO.OrderInfo();
|
|
|
|
|
|
order.setOrderCode(orderBasicInfo.getOrderCode());
|
2023-03-17 16:03:16 +08:00
|
|
|
|
order.setTransactionCode(orderBasicInfo.getTransactionCode());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
order.setOrderStatus(orderBasicInfo.getOrderStatus());
|
2023-03-30 08:56:10 +08:00
|
|
|
|
order.setLogicCard(orderBasicInfo.getLogicCard());
|
2023-03-16 17:15:44 +08:00
|
|
|
|
String describe = orderBasicInfoService.transformOrderStatusDescribe(orderBasicInfo.getOrderStatus(), orderBasicInfo.getPayStatus());
|
|
|
|
|
|
order.setOrderStatusDescribe(describe);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
order.setStartTime(DateUtils.formatDateTime(orderBasicInfo.getChargeStartTime()));
|
|
|
|
|
|
order.setEndTime(DateUtils.formatDateTime(orderBasicInfo.getChargeEndTime()));
|
|
|
|
|
|
order.setCreateTime(DateUtils.formatDateTime(orderBasicInfo.getCreateTime()));
|
|
|
|
|
|
order.setStopReasonMsg(orderBasicInfo.getReason());
|
|
|
|
|
|
order.setStartSOC(orderBasicInfo.getStartSOC());
|
|
|
|
|
|
order.setEndSOC(orderBasicInfo.getEndSOC());
|
2023-08-31 11:21:41 +08:00
|
|
|
|
order.setSettleAmount(String.valueOf(orderBasicInfo.getSettleAmount()));
|
2023-08-22 15:57:39 +08:00
|
|
|
|
order.setSettlementTime(DateUtils.formatDateTime(orderBasicInfo.getSettlementTime()));
|
2023-03-04 16:29:55 +08:00
|
|
|
|
vo.setOrderInfo(order);
|
|
|
|
|
|
|
|
|
|
|
|
// 设备信息
|
|
|
|
|
|
PileInfoVO pileInfoVO = pileService.selectPileInfoBySn(orderBasicInfo.getPileSn());
|
|
|
|
|
|
vo.setPileInfo(pileInfoVO);
|
|
|
|
|
|
|
|
|
|
|
|
// 枪口实时数据信息
|
|
|
|
|
|
String pileConnectorCode = orderBasicInfo.getPileSn() + orderBasicInfo.getConnectorCode();
|
|
|
|
|
|
QueryConnectorListDTO dto = new QueryConnectorListDTO();
|
|
|
|
|
|
dto.setConnectorCodeList(Lists.newArrayList(pileConnectorCode));
|
2023-03-14 09:19:47 +08:00
|
|
|
|
List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(chargingRealTimeDataList)) {
|
2023-03-17 16:03:16 +08:00
|
|
|
|
List<OrderDetailInfoVO.PileMonitorData> infoList = Lists.newArrayList();
|
2023-03-04 16:29:55 +08:00
|
|
|
|
for (RealTimeMonitorData realTimeMonitorData : chargingRealTimeDataList) {
|
2023-03-17 16:03:16 +08:00
|
|
|
|
OrderDetailInfoVO.PileMonitorData info = new OrderDetailInfoVO.PileMonitorData();
|
2023-03-04 16:29:55 +08:00
|
|
|
|
info.setInstantCurrent(realTimeMonitorData.getOutputCurrent()); // 电流
|
|
|
|
|
|
info.setInstantVoltage(realTimeMonitorData.getOutputVoltage()); // 电压
|
|
|
|
|
|
info.setInstantPower(realTimeMonitorData.getOutputPower()); // 功率
|
|
|
|
|
|
info.setSOC(realTimeMonitorData.getSOC());
|
|
|
|
|
|
info.setTime(realTimeMonitorData.getDateTime()); // 时间
|
|
|
|
|
|
infoList.add(info);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 监控信息
|
|
|
|
|
|
OrderDetailInfoVO.OrderRealTimeInfo realTimeInfo = new OrderDetailInfoVO.OrderRealTimeInfo();
|
|
|
|
|
|
RealTimeMonitorData realTimeMonitorData = chargingRealTimeDataList.get(0);
|
|
|
|
|
|
realTimeInfo.setOrderAmount(realTimeMonitorData.getChargingAmount());
|
|
|
|
|
|
realTimeInfo.setChargedDegree(realTimeMonitorData.getChargingDegree());
|
|
|
|
|
|
realTimeInfo.setChargingTime(realTimeMonitorData.getSumChargingTime());
|
2023-08-31 10:29:17 +08:00
|
|
|
|
realTimeInfo.setTime(realTimeMonitorData.getDateTime());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
vo.setOrderRealTimeInfo(realTimeInfo);
|
|
|
|
|
|
|
|
|
|
|
|
// 根据时间进行正序排序
|
|
|
|
|
|
infoList = infoList.stream()
|
2023-03-17 16:03:16 +08:00
|
|
|
|
.sorted(Comparator.comparing(OrderDetailInfoVO.PileMonitorData::getTime))
|
2023-03-04 16:29:55 +08:00
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
vo.setRealTimeMonitorDataList(infoList);
|
2023-03-17 16:03:16 +08:00
|
|
|
|
|
|
|
|
|
|
// 最后一次实时数据
|
|
|
|
|
|
vo.setLastMonitorData(chargingRealTimeDataList.get(0));
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 支付流水
|
2023-08-22 09:42:30 +08:00
|
|
|
|
List<OrderDetailInfoVO.PayRecord> payRecords = orderPayRecordService.selectOrderPayInfoList(orderCode);
|
|
|
|
|
|
vo.setPayRecordList(payRecords);
|
|
|
|
|
|
/*List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderCode);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(orderPayRecordList)) {
|
|
|
|
|
|
List<OrderDetailInfoVO.PayRecord> payRecordList = Lists.newArrayList();
|
2023-06-13 13:25:35 +08:00
|
|
|
|
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
|
|
|
|
|
OrderDetailInfoVO.PayRecord payInfo = new OrderDetailInfoVO.PayRecord();
|
|
|
|
|
|
// 余额支付如果是由本金和赠送一起支付的,合并为一个
|
|
|
|
|
|
BigDecimal bigDecimal = orderPayRecordList.stream()
|
|
|
|
|
|
.map(OrderPayRecord::getPayAmount)
|
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
payInfo.setPayAmount(bigDecimal.toString());
|
|
|
|
|
|
payInfo.setPayStatus(orderBasicInfo.getPayStatus());
|
|
|
|
|
|
payInfo.setPayTime(DateUtils.formatDateTime(orderBasicInfo.getPayTime()));
|
|
|
|
|
|
if (orderPayRecord.getRefundAmount() != null) {
|
|
|
|
|
|
payInfo.setRefundAmount(orderPayRecord.getRefundAmount().toString());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
2023-06-13 13:25:35 +08:00
|
|
|
|
String payMode = orderPayRecord.getPayMode();
|
|
|
|
|
|
if (StringUtils.equals(payMode, OrderPayRecordEnum.PRINCIPAL_BALANCE_PAYMENT.getValue())
|
|
|
|
|
|
|| StringUtils.equals(payMode, OrderPayRecordEnum.GIFT_BALANCE_PAYMENT.getValue())) {
|
|
|
|
|
|
// 使用余额支付
|
|
|
|
|
|
payInfo.setPayMode(OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue());
|
|
|
|
|
|
payInfo.setPayModeDesc(OrderPayModeEnum.PAYMENT_OF_BALANCE.getLabel());
|
|
|
|
|
|
} else if (StringUtils.equals(payMode, OrderPayRecordEnum.WECHATPAY_PAYMENT.getValue())){
|
|
|
|
|
|
// 使用微信支付
|
|
|
|
|
|
payInfo.setPayMode(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue());
|
|
|
|
|
|
payInfo.setPayModeDesc(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getLabel());
|
2023-07-07 11:22:10 +08:00
|
|
|
|
|
|
|
|
|
|
// 判断是微信支付还是汇付支付
|
2023-07-08 11:42:33 +08:00
|
|
|
|
MemberTransactionRecord record = memberTransactionRecordService.selectByOrderCode(orderCode, ActionTypeEnum.FORWARD.getValue());
|
2023-07-07 11:22:10 +08:00
|
|
|
|
if (record != null) {
|
|
|
|
|
|
String paymentInstitutions = record.getPaymentInstitutions();
|
|
|
|
|
|
if (StringUtils.equals(paymentInstitutions, PaymentInstitutionsEnum.WECHAT_PAY.getValue())) {
|
|
|
|
|
|
// 查微信支付回调记录
|
|
|
|
|
|
WxpayCallbackRecord wxpayCallbackRecord = wxpayCallbackRecordService.selectByOrderCode(orderCode);
|
|
|
|
|
|
if (wxpayCallbackRecord != null) {
|
|
|
|
|
|
payInfo.setOutTradeNo(wxpayCallbackRecord.getOutTradeNo());
|
|
|
|
|
|
payInfo.setTransactionId(wxpayCallbackRecord.getTransactionId());
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (StringUtils.equals(paymentInstitutions, PaymentInstitutionsEnum.ADAPAY.getValue())) {
|
|
|
|
|
|
// 查询汇付支付回调
|
|
|
|
|
|
AdapayCallbackRecord adapayCallbackRecord = adapayCallbackRecordService.selectByOrderCode(orderCode);
|
|
|
|
|
|
if (adapayCallbackRecord != null) {
|
|
|
|
|
|
payInfo.setOutTradeNo(adapayCallbackRecord.getPaymentId());
|
|
|
|
|
|
payInfo.setTransactionId(adapayCallbackRecord.getOutTransId());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-13 13:25:35 +08:00
|
|
|
|
// 查微信支付回调记录
|
|
|
|
|
|
WxpayCallbackRecord wxpayCallbackRecord = wxpayCallbackRecordService.selectByOrderCode(orderCode);
|
|
|
|
|
|
if (wxpayCallbackRecord != null) {
|
|
|
|
|
|
payInfo.setOutTradeNo(wxpayCallbackRecord.getOutTradeNo());
|
|
|
|
|
|
payInfo.setTransactionId(wxpayCallbackRecord.getTransactionId());
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (StringUtils.equals(payMode, OrderPayRecordEnum.WHITELIST_PAYMENT.getValue())){
|
|
|
|
|
|
// 使用白名单支付
|
|
|
|
|
|
payInfo.setPayMode(OrderPayModeEnum.PAYMENT_OF_WHITELIST.getValue());
|
|
|
|
|
|
payInfo.setPayModeDesc(OrderPayModeEnum.PAYMENT_OF_WHITELIST.getLabel());
|
|
|
|
|
|
}
|
|
|
|
|
|
payRecordList.add(payInfo);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
vo.setPayRecordList(payRecordList);
|
2023-08-22 09:42:30 +08:00
|
|
|
|
}*/
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-08-17 16:10:31 +08:00
|
|
|
|
// 查询退款明细
|
|
|
|
|
|
List<OrderDetailInfoVO.OrderRefundInfo> orderRefundInfoList = Lists.newArrayList();
|
|
|
|
|
|
List<PaymentReverseResponse> paymentReverseResponses = orderBasicInfoService.queryOrderAdapayRefund(orderBasicInfo);
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(paymentReverseResponses)) {
|
|
|
|
|
|
OrderDetailInfoVO.OrderRefundInfo refundInfo;
|
|
|
|
|
|
for (PaymentReverseResponse reverseResponse : paymentReverseResponses) {
|
|
|
|
|
|
refundInfo = new OrderDetailInfoVO.OrderRefundInfo();
|
|
|
|
|
|
refundInfo.setReverseId(reverseResponse.getId());
|
|
|
|
|
|
refundInfo.setPaymentId(reverseResponse.getPayment_id());
|
|
|
|
|
|
refundInfo.setReverseAmt(reverseResponse.getReverse_amt());
|
|
|
|
|
|
LocalDateTime createdTime = DateUtils.timestampToDatetime(Long.parseLong(reverseResponse.getCreated_time()));
|
|
|
|
|
|
refundInfo.setCreatedTime(DateUtils.formatDateTime(createdTime));
|
|
|
|
|
|
LocalDateTime succeedTime = DateUtils.timestampToDatetime(Long.parseLong(reverseResponse.getSucceed_time()));
|
|
|
|
|
|
refundInfo.setSucceedTime(DateUtils.formatDateTime(succeedTime));
|
|
|
|
|
|
orderRefundInfoList.add(refundInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
vo.setOrderRefundInfoList(orderRefundInfoList);
|
|
|
|
|
|
|
2023-03-08 10:00:13 +08:00
|
|
|
|
// 查订单明细
|
|
|
|
|
|
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
|
|
|
|
|
if (orderDetail != null) {
|
2023-05-12 15:03:29 +08:00
|
|
|
|
OrderAmountDetailVO billingDetails = new OrderAmountDetailVO();
|
2023-03-08 10:00:13 +08:00
|
|
|
|
BeanUtils.copyBeanProp(billingDetails, orderDetail);
|
|
|
|
|
|
vo.setBillingDetails(billingDetails);
|
2023-05-05 16:46:43 +08:00
|
|
|
|
|
2023-05-12 15:03:29 +08:00
|
|
|
|
List<OrderPeriodAmountVO> orderPeriodAmountVOS = orderBasicInfoService.transformPeriodAmountByOrderDetail(orderDetail);
|
|
|
|
|
|
vo.setChargeDetails(orderPeriodAmountVOS);
|
2023-03-08 10:00:13 +08:00
|
|
|
|
}
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
// 用户信息
|
|
|
|
|
|
MemberVO memberVO = memberService.getMemberInfoByMemberId(orderBasicInfo.getMemberId());
|
|
|
|
|
|
vo.setMemberInfo(memberVO);
|
|
|
|
|
|
|
2023-05-10 16:03:11 +08:00
|
|
|
|
try {
|
|
|
|
|
|
// 因为原来的数据在redis中是永久保存,所以这里做下查询详情的时候,发现已经是完成的订单,redis数据存到表中
|
|
|
|
|
|
if (StringUtils.equals(orderBasicInfo.getOrderStatus(), OrderStatusEnum.ORDER_COMPLETE.getValue())) {
|
|
|
|
|
|
// 如果是已完成的订单,把redis中的实时数据存到表中
|
|
|
|
|
|
orderBasicInfoService.realTimeMonitorDataRedis2DB(orderBasicInfo.getTransactionCode(), orderBasicInfo.getOrderCode());
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("后管查询订单详情时把redis中的实时数据存到表发生异常", e);
|
|
|
|
|
|
}
|
2023-03-04 16:29:55 +08:00
|
|
|
|
return vo;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-27 15:08:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 微信支付退款回调
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @param body
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
2023-03-04 16:29:55 +08:00
|
|
|
|
public void wechatPayRefundCallback(HttpServletRequest request, WechatPayNotifyParameter body) throws Exception {
|
|
|
|
|
|
// 获取微信退款成功返回的信息
|
|
|
|
|
|
Map<String, Object> map = wechatPayService.wechatPayRefundCallbackInfo(request, body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取小程序订单详情
|
|
|
|
|
|
* @param orderCode
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public UniAppOrderVO getUniAppOrderDetail(String orderCode) {
|
|
|
|
|
|
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
|
|
|
|
|
if (orderBasicInfo == null) {
|
2023-08-18 09:52:12 +08:00
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_INFO_IS_NULL);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
UniAppOrderVO vo = new UniAppOrderVO();
|
|
|
|
|
|
vo.setOrderCode(orderBasicInfo.getOrderCode());
|
|
|
|
|
|
vo.setPileSn(orderBasicInfo.getPileSn());
|
|
|
|
|
|
vo.setConnectorCode(orderBasicInfo.getConnectorCode());
|
|
|
|
|
|
vo.setPileConnectorCode(orderBasicInfo.getPileSn() + orderBasicInfo.getConnectorCode());
|
|
|
|
|
|
String orderStatus = orderBasicInfo.getOrderStatus();
|
|
|
|
|
|
vo.setOrderStatus(orderStatus);
|
2023-03-14 09:19:47 +08:00
|
|
|
|
if (Objects.nonNull(orderBasicInfo.getChargeStartTime())) {
|
|
|
|
|
|
vo.setStartChargingTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime()));
|
|
|
|
|
|
}
|
2023-03-09 13:34:22 +08:00
|
|
|
|
Date chargeEndTime = orderBasicInfo.getChargeEndTime();
|
|
|
|
|
|
if (Objects.nonNull(chargeEndTime)) {
|
|
|
|
|
|
vo.setEndChargingTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeEndTime));
|
|
|
|
|
|
}
|
|
|
|
|
|
PileStationVO stationInfo = pileStationInfoService.getStationInfo(orderBasicInfo.getStationId());
|
|
|
|
|
|
vo.setStationName(stationInfo.getStationName());
|
|
|
|
|
|
vo.setReason(orderBasicInfo.getReason());
|
|
|
|
|
|
vo.setOrderAmount(String.valueOf(orderBasicInfo.getOrderAmount()));
|
|
|
|
|
|
vo.setPayAmount(String.valueOf(orderBasicInfo.getPayAmount()));
|
2023-04-24 10:33:55 +08:00
|
|
|
|
vo.setPayMode(orderBasicInfo.getPayMode());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
// 订单状态描述
|
2023-03-16 17:09:35 +08:00
|
|
|
|
String orderStatusDescribe = orderBasicInfoService.transformOrderStatusDescribe(orderStatus, orderBasicInfo.getPayStatus());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
vo.setOrderStatusDescribe(orderStatusDescribe);
|
|
|
|
|
|
|
|
|
|
|
|
// 获取充电桩枪口信息
|
|
|
|
|
|
PileConnectorDetailVO pileConnectorDetailVO = pileService.queryPileConnectorDetail(vo.getPileConnectorCode());
|
|
|
|
|
|
if (pileConnectorDetailVO != null) {
|
|
|
|
|
|
vo.setPileConnectorStatus(pileConnectorDetailVO.getConnectorStatus());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取订单充电数据
|
2023-03-14 09:19:47 +08:00
|
|
|
|
List<RealTimeMonitorData> monitorDataList = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(monitorDataList)) {
|
|
|
|
|
|
List<UniAppOrderVO.ChargingData> chargingDataList = Lists.newArrayList();
|
|
|
|
|
|
UniAppOrderVO.ChargingData data = null;
|
|
|
|
|
|
for (int i = 0; i < monitorDataList.size(); i++) {
|
|
|
|
|
|
RealTimeMonitorData monitorData = monitorDataList.get(i);
|
|
|
|
|
|
data = new UniAppOrderVO.ChargingData();
|
|
|
|
|
|
data.setDateTime(monitorData.getDateTime());
|
|
|
|
|
|
String outputVoltage = monitorData.getOutputVoltage();
|
|
|
|
|
|
data.setOutputVoltage(outputVoltage);
|
|
|
|
|
|
String outputCurrent = monitorData.getOutputCurrent();
|
|
|
|
|
|
data.setOutputCurrent(outputCurrent);
|
|
|
|
|
|
BigDecimal power = new BigDecimal(outputCurrent).multiply(new BigDecimal(outputVoltage))
|
|
|
|
|
|
.divide(new BigDecimal("1000"), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
data.setPower(power.toString());
|
|
|
|
|
|
data.setSOC(monitorData.getSOC());
|
|
|
|
|
|
data.setBatteryMaxTemperature(monitorData.getBatteryMaxTemperature());
|
|
|
|
|
|
chargingDataList.add(data);
|
|
|
|
|
|
// vo中的实时数据,最新一条就取monitorDataList第一个
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
|
vo.setBatteryMaxTemperature(data.getBatteryMaxTemperature());
|
|
|
|
|
|
vo.setOutputPower(data.getPower());
|
|
|
|
|
|
vo.setOutputCurrent(data.getOutputCurrent());
|
|
|
|
|
|
vo.setOutputVoltage(data.getOutputVoltage());
|
|
|
|
|
|
vo.setSOC(data.getSOC());
|
|
|
|
|
|
BigDecimal chargingAmount = new BigDecimal(monitorData.getChargingAmount()).setScale(2, BigDecimal.ROUND_HALF_UP); // 充电金额
|
|
|
|
|
|
vo.setChargingAmount(chargingAmount.toString());
|
|
|
|
|
|
BigDecimal chargingDegree = new BigDecimal(monitorData.getChargingDegree()).setScale(2, BigDecimal.ROUND_HALF_UP); // 充电度数
|
|
|
|
|
|
vo.setChargingDegree(chargingDegree.toString());
|
|
|
|
|
|
vo.setSumChargingTime(monitorData.getSumChargingTime());
|
|
|
|
|
|
vo.setTimeRemaining(monitorData.getTimeRemaining());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// monitorDataList是按照时间倒序的,chargingDataList需要按照时间正序
|
|
|
|
|
|
Collections.reverse(chargingDataList);
|
|
|
|
|
|
vo.setChargingDataList(chargingDataList);
|
|
|
|
|
|
}
|
2023-03-08 15:56:46 +08:00
|
|
|
|
|
|
|
|
|
|
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
|
|
|
|
|
if (orderDetail != null) {
|
2023-05-12 15:03:29 +08:00
|
|
|
|
OrderAmountDetailVO billingDetails = new OrderAmountDetailVO();
|
2023-03-08 15:56:46 +08:00
|
|
|
|
BeanUtils.copyBeanProp(billingDetails, orderDetail);
|
|
|
|
|
|
vo.setBillingDetails(billingDetails);
|
2023-05-10 16:03:11 +08:00
|
|
|
|
}
|
2023-04-08 14:20:19 +08:00
|
|
|
|
|
2023-05-10 16:03:11 +08:00
|
|
|
|
try {
|
|
|
|
|
|
// 因为原来的数据在redis中是永久保存,所以这里做下查询详情的时候,发现已经是完成的订单,redis数据存到表中
|
|
|
|
|
|
if (StringUtils.equals(orderBasicInfo.getOrderStatus(), OrderStatusEnum.ORDER_COMPLETE.getValue())) {
|
|
|
|
|
|
// 如果是已完成的订单,把redis中的实时数据存到表中
|
|
|
|
|
|
orderBasicInfoService.realTimeMonitorDataRedis2DB(orderBasicInfo.getTransactionCode(), orderBasicInfo.getOrderCode());
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("后管查询订单详情时把redis中的实时数据存到表发生异常", e);
|
2023-03-08 15:56:46 +08:00
|
|
|
|
}
|
2023-03-04 16:29:55 +08:00
|
|
|
|
return vo;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-27 15:08:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 小程序订单详情V2
|
|
|
|
|
|
* @param orderCode
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-07-12 15:06:33 +08:00
|
|
|
|
public UniAppOrderDetailVO getUniAppOrderDetailV2(String orderCode) {
|
|
|
|
|
|
UniAppOrderDetailVO resultVO = new UniAppOrderDetailVO();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resultVO;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 根据订单号查询充电桩启动状态
|
|
|
|
|
|
* @param orderCode
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String selectPileStarterStatus(String orderCode) {
|
2023-03-14 09:19:47 +08:00
|
|
|
|
OrderBasicInfo orderInfoByOrderCode = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
|
|
|
|
|
if (orderInfoByOrderCode == null) {
|
|
|
|
|
|
return Constants.ZERO;
|
|
|
|
|
|
}
|
|
|
|
|
|
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfoByOrderCode.getTransactionCode());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
// 只有充电桩上传的实时数据中的状态为充电,才能查到实时数据列表
|
|
|
|
|
|
return CollectionUtils.isNotEmpty(chargingRealTimeData) ? Constants.ONE : Constants.ZERO;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-27 15:08:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 关闭支付未启动的订单
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
2023-03-04 16:29:55 +08:00
|
|
|
|
public void closeStartFailedOrder(QueryOrderDTO dto) {
|
|
|
|
|
|
orderBasicInfoService.closeStartFailedOrder(dto.getStartTime(), dto.getEndTime());
|
|
|
|
|
|
}
|
2023-03-16 15:23:01 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 人工结算订单
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
2023-03-18 15:35:29 +08:00
|
|
|
|
public boolean manualSettlementOrder(ManualSettlementDTO dto) {
|
2023-03-17 16:03:16 +08:00
|
|
|
|
log.info("人工结算订单-begin orderCode:{}", dto.getOrderCode());
|
2023-03-16 15:23:01 +08:00
|
|
|
|
// 查询订单
|
|
|
|
|
|
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
|
|
|
|
|
if (orderBasicInfo == null) {
|
|
|
|
|
|
log.info("人工结算订单-根据订单号:{}, 查询为null", dto.getOrderCode());
|
2023-03-16 15:24:52 +08:00
|
|
|
|
return false;
|
2023-03-16 15:23:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 当前登录用户,是否可以结算该订单
|
|
|
|
|
|
AuthorizedDeptVO authorizedMap = SecurityUtils.getAuthorizedMap();
|
|
|
|
|
|
if (authorizedMap == null) {
|
|
|
|
|
|
log.info("人工结算订单-当前登录管理员无权限");
|
2023-03-16 15:24:52 +08:00
|
|
|
|
return false;
|
2023-03-16 15:23:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<String> stationDeptIds = authorizedMap.getStationDeptIds();
|
|
|
|
|
|
if (CollectionUtils.isEmpty(stationDeptIds)) {
|
|
|
|
|
|
// 运营商管理员
|
|
|
|
|
|
List<String> merchantDeptIds = authorizedMap.getMerchantDeptIds();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-18 15:35:29 +08:00
|
|
|
|
String chargingAmount = dto.getChargingAmount();
|
|
|
|
|
|
String chargingDegree = dto.getChargingDegree();
|
2023-03-18 16:57:08 +08:00
|
|
|
|
if (StringUtils.equals(chargingAmount, Constants.ZERO) || StringUtils.equals(chargingDegree, Constants.ZERO)) {
|
2023-03-18 15:35:29 +08:00
|
|
|
|
// 获取最后一次实时数据
|
|
|
|
|
|
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode());
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(chargingRealTimeData)) {
|
|
|
|
|
|
RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0);
|
|
|
|
|
|
chargingAmount = realTimeMonitorData.getChargingAmount();
|
|
|
|
|
|
chargingDegree = realTimeMonitorData.getChargingDegree();
|
|
|
|
|
|
}
|
2023-03-16 15:23:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 组装交易记录数据
|
|
|
|
|
|
TransactionRecordsData data = new TransactionRecordsData();
|
2023-03-18 15:35:29 +08:00
|
|
|
|
data.setConsumptionAmount(chargingAmount); // 总消费金额
|
|
|
|
|
|
data.setTotalElectricity(chargingDegree); // 总用电量
|
2023-03-16 15:23:01 +08:00
|
|
|
|
data.setStopReasonMsg("人工结算订单,操作人:" + SecurityUtils.getUsername()); // 停止原因
|
|
|
|
|
|
|
|
|
|
|
|
// 结算订单
|
2023-09-01 15:45:04 +08:00
|
|
|
|
// orderBasicInfoService.settleOrder(data, orderBasicInfo);
|
|
|
|
|
|
// 新逻辑
|
|
|
|
|
|
String mode = pileMerchantInfoService.getDelayModeByMerchantId(orderBasicInfo.getMerchantId());
|
|
|
|
|
|
AbstractOrderLogic orderLogic = OrderLogicFactory.getOrderLogic(mode);
|
|
|
|
|
|
orderLogic.settleOrder(data, orderBasicInfo);
|
2023-03-16 15:23:01 +08:00
|
|
|
|
|
|
|
|
|
|
// 发送停止充电指令
|
|
|
|
|
|
pileRemoteService.remoteStopCharging(orderBasicInfo.getPileSn(), orderBasicInfo.getConnectorCode());
|
2023-03-17 16:03:16 +08:00
|
|
|
|
|
|
|
|
|
|
log.info("人工结算订单-end orderCode:{}", dto.getOrderCode());
|
2023-03-16 15:24:52 +08:00
|
|
|
|
return true;
|
2023-03-16 15:23:01 +08:00
|
|
|
|
}
|
2023-03-29 15:09:51 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 当前登录会员 获取支付方式
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
|
|
|
|
|
public List<PayModeVO> getPayMode(GetPayModeDTO dto) {
|
|
|
|
|
|
List<PayModeVO> result = Lists.newArrayList();
|
|
|
|
|
|
// 查询会员在站点是否是白名单用户
|
2023-04-21 09:35:42 +08:00
|
|
|
|
PileStationWhitelist whitelist = pileStationWhitelistService.queryWhitelistByMemberId(dto.getStationId(), dto.getMemberId());
|
2023-07-04 14:16:50 +08:00
|
|
|
|
|
|
|
|
|
|
// 查询是否为平台测试员
|
|
|
|
|
|
PlatformTesterVO platformTesterVO = memberBasicInfoService.selectPlatformTesterStatus(dto.getMemberId());
|
|
|
|
|
|
|
|
|
|
|
|
boolean flag = whitelist != null || StringUtils.equals(platformTesterVO.getStatus(), Constants.ONE);
|
2023-07-04 11:42:04 +08:00
|
|
|
|
|
2023-03-29 15:09:51 +08:00
|
|
|
|
if (flag) {
|
|
|
|
|
|
result.add(
|
|
|
|
|
|
PayModeVO.builder()
|
|
|
|
|
|
.payModeCode(OrderPayModeEnum.PAYMENT_OF_WHITELIST.getValue())
|
|
|
|
|
|
.payModeName(OrderPayModeEnum.PAYMENT_OF_WHITELIST.getLabel())
|
|
|
|
|
|
.build()
|
|
|
|
|
|
);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 微信支付
|
|
|
|
|
|
result.add(
|
|
|
|
|
|
PayModeVO.builder()
|
|
|
|
|
|
.payModeCode(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())
|
|
|
|
|
|
.payModeName(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getLabel())
|
|
|
|
|
|
.build()
|
|
|
|
|
|
);
|
|
|
|
|
|
// 余额支付
|
2023-09-05 15:44:25 +08:00
|
|
|
|
result.add(
|
|
|
|
|
|
PayModeVO.builder()
|
|
|
|
|
|
.payModeCode(OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue())
|
|
|
|
|
|
.payModeName(OrderPayModeEnum.PAYMENT_OF_BALANCE.getLabel())
|
|
|
|
|
|
.build()
|
|
|
|
|
|
);
|
2023-03-29 15:09:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2023-04-11 16:13:06 +08:00
|
|
|
|
|
2023-07-27 15:08:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询未开发票订单
|
|
|
|
|
|
* 时间限制15天内
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-04-11 16:13:06 +08:00
|
|
|
|
public List<OrderVO> queryUninvoicedOrderList(QueryOrderDTO dto) {
|
2023-05-08 13:57:39 +08:00
|
|
|
|
int i = 15;
|
2023-04-11 16:13:06 +08:00
|
|
|
|
|
2023-05-08 13:57:39 +08:00
|
|
|
|
// 查询最近15天完成的订单
|
2023-04-11 16:13:06 +08:00
|
|
|
|
LocalDateTime dateTime = LocalDateTime.now().plusDays(-i);
|
|
|
|
|
|
List<OrderVO> orderList = orderBasicInfoService.getListByMemberIdAndOrderStatus(dto.getMemberId(), Lists.newArrayList("6"), dateTime);
|
|
|
|
|
|
|
|
|
|
|
|
// 过滤掉订单金额为0的
|
|
|
|
|
|
orderList = orderList.stream()
|
2023-06-30 11:35:33 +08:00
|
|
|
|
.filter(x -> x.getSettleAmount().compareTo(BigDecimal.ZERO) > 0)
|
2023-04-11 16:13:06 +08:00
|
|
|
|
.collect(Collectors.toList());
|
2023-04-11 17:00:44 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(orderList)) {
|
|
|
|
|
|
return orderList;
|
|
|
|
|
|
}
|
2023-04-11 16:13:06 +08:00
|
|
|
|
|
|
|
|
|
|
// 查询最近60天申请开票记录
|
|
|
|
|
|
QueryInvoiceRecordDTO build = QueryInvoiceRecordDTO.builder()
|
|
|
|
|
|
.memberId(dto.getMemberId())
|
|
|
|
|
|
.startTime(dateTime)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
List<OrderInvoiceRecord> orderInvoiceRecords = orderInvoiceRecordService.selectInvoiceRecordList(build);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(orderInvoiceRecords)) {
|
|
|
|
|
|
return orderList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 排除掉已经申请过的订单
|
2023-04-14 15:22:27 +08:00
|
|
|
|
List<String> orderCodeList = orderInvoiceRecords.stream() // 转化为 Stream
|
|
|
|
|
|
.map(OrderInvoiceRecord::getOrderCodes) // 获取 OrderInvoiceRecord 中的 orderCodes 字符串
|
2023-08-04 13:55:36 +08:00
|
|
|
|
.flatMap(str -> Arrays.stream(str.split(Constants.DEFAULT_DELIMITER))) // 分隔逗号并转化为 Stream
|
2023-04-14 15:22:27 +08:00
|
|
|
|
.collect(Collectors.toList()); // 收集为 List<String>
|
2023-04-11 16:13:06 +08:00
|
|
|
|
|
|
|
|
|
|
orderList = orderList.stream()
|
|
|
|
|
|
.filter(x -> !orderCodeList.contains(x.getOrderCode()))
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
return orderList;
|
|
|
|
|
|
}
|
2023-04-14 11:17:44 +08:00
|
|
|
|
|
2023-05-20 10:53:49 +08:00
|
|
|
|
public List<StationInfoVO> queryUninvoicedStationList(QueryOrderDTO dto) {
|
|
|
|
|
|
return Lists.newArrayList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-14 11:17:44 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 申请开票
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void applyOrderInvoice(ApplyOrderInvoiceDTO dto) {
|
2023-05-20 11:14:33 +08:00
|
|
|
|
int i = 15;
|
|
|
|
|
|
// 查询最近15天完成的订单
|
2023-04-14 15:22:27 +08:00
|
|
|
|
LocalDateTime dateTime = LocalDateTime.now().plusDays(-i);
|
2023-08-04 13:40:38 +08:00
|
|
|
|
// 查询最近15天 会员的开票记录
|
|
|
|
|
|
List<OrderInvoiceRecord> orderInvoiceRecords = orderInvoiceRecordService.selectInvoiceRecordList(dto.getMemberId(), dateTime, LocalDateTime.now());
|
2023-04-14 15:22:27 +08:00
|
|
|
|
List<String> orderCodeList = orderInvoiceRecords.stream() // 转化为 Stream
|
|
|
|
|
|
.map(OrderInvoiceRecord::getOrderCodes) // 获取 OrderInvoiceRecord 中的 orderCodes 字符串
|
2023-08-04 13:55:36 +08:00
|
|
|
|
.flatMap(str -> Arrays.stream(str.split(Constants.DEFAULT_DELIMITER))) // 分隔逗号并转化为 Stream
|
2023-04-14 15:22:27 +08:00
|
|
|
|
.collect(Collectors.toList()); // 收集为 List<String>
|
|
|
|
|
|
|
|
|
|
|
|
// 取交集 校验订单是否已经开票
|
|
|
|
|
|
Set<String> intersection = Sets.intersection(Sets.newHashSet(orderCodeList), Sets.newHashSet(dto.getOrderCodes()));
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(intersection)) {
|
|
|
|
|
|
log.info("申请开票前端传的:{}订单号list, 包含已经申请的订单:{}", dto.getOrderCodes(), intersection);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-23 10:52:58 +08:00
|
|
|
|
// 查抬头信息
|
|
|
|
|
|
MemberInvoiceTitle invoiceTitle = memberInvoiceTitleService.selectMemberInvoiceTitleById(Long.parseLong(dto.getTitleId()));
|
2023-08-04 13:55:36 +08:00
|
|
|
|
|
2023-05-23 10:52:58 +08:00
|
|
|
|
if (StringUtils.isNotEmpty(dto.getReception())) {
|
|
|
|
|
|
boolean b = false;
|
|
|
|
|
|
if (StringUtils.isEmail(dto.getReception()) && !StringUtils.equals(dto.getReception(), invoiceTitle.getEmail())) {
|
|
|
|
|
|
invoiceTitle.setEmail(dto.getReception());
|
|
|
|
|
|
b = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isPhoneNumber(dto.getReception()) && !StringUtils.equals(dto.getReception(), invoiceTitle.getPhoneNumber())) {
|
|
|
|
|
|
invoiceTitle.setPhoneNumber(dto.getReception());
|
|
|
|
|
|
b = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (b) {
|
|
|
|
|
|
memberInvoiceTitleService.updateMemberInvoiceTitle(invoiceTitle);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-04 13:55:36 +08:00
|
|
|
|
// 整理数据
|
|
|
|
|
|
List<OrderVO> orderVOList = orderBasicInfoService.getListByOrderCodes(dto.getOrderCodes());
|
|
|
|
|
|
|
|
|
|
|
|
// 根据运营商分组
|
|
|
|
|
|
Map<String, List<OrderVO>> map = orderVOList.stream().collect(Collectors.groupingBy(OrderVO::getMerchantId));
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal totalAmount = null;
|
|
|
|
|
|
BigDecimal totalElecAmount = null;
|
|
|
|
|
|
BigDecimal totalServiceAmount = null;
|
|
|
|
|
|
// 根据运营商创建多笔开票记录
|
|
|
|
|
|
for (Map.Entry<String, List<OrderVO>> entry : map.entrySet()) {
|
|
|
|
|
|
totalAmount = BigDecimal.ZERO;
|
|
|
|
|
|
totalElecAmount = BigDecimal.ZERO;
|
|
|
|
|
|
totalServiceAmount = BigDecimal.ZERO;
|
|
|
|
|
|
List<OrderVO> orders = entry.getValue();
|
|
|
|
|
|
for (OrderVO orderVO : orders) {
|
|
|
|
|
|
totalAmount = totalAmount.add(orderVO.getOrderAmount());
|
|
|
|
|
|
totalElecAmount = totalElecAmount.add(orderVO.getTotalElectricityAmount());
|
|
|
|
|
|
totalServiceAmount = totalServiceAmount.add(orderVO.getTotalServiceAmount());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 入库
|
|
|
|
|
|
OrderInvoiceRecord orderInvoiceRecord = new OrderInvoiceRecord();
|
|
|
|
|
|
orderInvoiceRecord.setStatus(Constants.ZERO);
|
|
|
|
|
|
orderInvoiceRecord.setMemberId(dto.getMemberId());
|
2023-08-18 15:11:53 +08:00
|
|
|
|
orderInvoiceRecord.setMerchantId(entry.getKey());
|
2023-08-04 13:55:36 +08:00
|
|
|
|
orderInvoiceRecord.setTitleId(dto.getTitleId());
|
|
|
|
|
|
orderInvoiceRecord.setOrderCodes(String.join(Constants.DEFAULT_DELIMITER, dto.getOrderCodes()));
|
|
|
|
|
|
orderInvoiceRecord.setTotalAmount(totalAmount);
|
|
|
|
|
|
orderInvoiceRecord.setTotalElecAmount(totalElecAmount);
|
|
|
|
|
|
orderInvoiceRecord.setTotalServiceAmount(totalServiceAmount);
|
|
|
|
|
|
orderInvoiceRecordService.insertOrderInvoiceRecord(orderInvoiceRecord);
|
|
|
|
|
|
}
|
2023-04-14 11:17:44 +08:00
|
|
|
|
}
|
2023-04-15 16:16:46 +08:00
|
|
|
|
|
2023-07-27 15:08:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询开票记录
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-04-15 16:16:46 +08:00
|
|
|
|
public PageResponse queryInvoiceRecord(QueryInvoiceRecordDTO dto) {
|
|
|
|
|
|
QueryInvoiceRecordDTO build = QueryInvoiceRecordDTO.builder()
|
|
|
|
|
|
.memberId(dto.getMemberId())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
|
|
|
|
|
|
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
|
|
|
|
|
PageHelper.startPage(pageNo, pageSize);
|
|
|
|
|
|
List<OrderInvoiceRecord> orderInvoiceRecords = orderInvoiceRecordService.selectInvoiceRecordList(build);
|
|
|
|
|
|
PageInfo<OrderInvoiceRecord> pageInfo = new PageInfo<>(orderInvoiceRecords);
|
|
|
|
|
|
List<InvoiceRecordVO> volist = Lists.newArrayList();
|
|
|
|
|
|
for (OrderInvoiceRecord orderInvoiceRecord : orderInvoiceRecords) {
|
|
|
|
|
|
volist.add(
|
|
|
|
|
|
InvoiceRecordVO.builder()
|
2023-04-15 17:01:27 +08:00
|
|
|
|
.status(InvoiceRecordEnum.getLabel(orderInvoiceRecord.getStatus()))
|
|
|
|
|
|
.totalAmount(orderInvoiceRecord.getTotalAmount())
|
|
|
|
|
|
.totalElecAmount(orderInvoiceRecord.getTotalElecAmount())
|
|
|
|
|
|
.totalServiceAmount(orderInvoiceRecord.getTotalServiceAmount())
|
|
|
|
|
|
.createTime(DateUtils.formatDateTime(orderInvoiceRecord.getCreateTime()))
|
2023-04-15 16:16:46 +08:00
|
|
|
|
.build()
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
return PageResponse.builder()
|
|
|
|
|
|
.total(pageInfo.getTotal())
|
|
|
|
|
|
.pages(pageInfo.getPages())
|
|
|
|
|
|
.pageNum(pageInfo.getPageNum())
|
|
|
|
|
|
.pageSize(pageInfo.getPageSize())
|
|
|
|
|
|
.list(volist)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
}
|
2023-05-15 14:55:33 +08:00
|
|
|
|
|
2023-05-27 17:49:25 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 汇付支付 支付回调
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
2023-05-20 10:53:49 +08:00
|
|
|
|
public void adapayCallback(HttpServletRequest request) throws Exception {
|
|
|
|
|
|
//验签请参data
|
|
|
|
|
|
String data = request.getParameter("data");
|
|
|
|
|
|
//验签请参sign
|
|
|
|
|
|
String sign = request.getParameter("sign");
|
2023-07-10 15:14:58 +08:00
|
|
|
|
|
2023-05-20 10:53:49 +08:00
|
|
|
|
//验签请参publicKey
|
|
|
|
|
|
String publicKey = AdapayCore.PUBLIC_KEY;
|
|
|
|
|
|
log.info("汇付支付回调验签请参data={}, sign={}", data, sign);
|
|
|
|
|
|
//验签标记
|
|
|
|
|
|
boolean checkSign = AdapaySign.verifySign(data, sign, publicKey);
|
|
|
|
|
|
if (!checkSign) {
|
|
|
|
|
|
log.info("汇付支付回调验签失败:{}", data);
|
2023-05-20 11:14:33 +08:00
|
|
|
|
return;
|
2023-05-20 10:53:49 +08:00
|
|
|
|
}
|
2023-07-10 15:14:58 +08:00
|
|
|
|
|
2023-07-27 15:37:45 +08:00
|
|
|
|
// type
|
|
|
|
|
|
String type = request.getParameter("type");
|
|
|
|
|
|
// 根据type执行不同逻辑
|
2023-07-10 17:06:19 +08:00
|
|
|
|
if (AdapayEventEnum.payment_succeeded.getValue().equals(type)) {
|
|
|
|
|
|
// 支付成功
|
2023-07-10 15:14:58 +08:00
|
|
|
|
paymentSucceeded(data);
|
2023-07-10 17:06:19 +08:00
|
|
|
|
} else if (AdapayEventEnum.refund_succeeded.getValue().equals(type)) {
|
|
|
|
|
|
// 退款成功
|
2023-07-27 15:37:45 +08:00
|
|
|
|
refundSucceeded(data);
|
2023-09-01 17:29:59 +08:00
|
|
|
|
} else if (AdapayEventEnum.refund_failed.getValue().equals(type)) {
|
|
|
|
|
|
// 退款失败
|
|
|
|
|
|
refundFailed(data);
|
2023-07-10 17:06:19 +08:00
|
|
|
|
} else if (AdapayEventEnum.corp_member_failed.getValue().equals(type)) {
|
|
|
|
|
|
// 开户失败 删除
|
|
|
|
|
|
corpMemberFailed(data);
|
2023-07-10 17:39:08 +08:00
|
|
|
|
} else if (AdapayEventEnum.corp_member_succeeded.getValue().equals(type)) {
|
2023-07-11 09:12:21 +08:00
|
|
|
|
// 开户成功
|
2023-07-10 17:39:08 +08:00
|
|
|
|
corpMemberSucceeded(data);
|
2023-07-11 09:12:21 +08:00
|
|
|
|
} else if (AdapayEventEnum.payment_reverse_succeeded.getValue().equals(type)) {
|
|
|
|
|
|
// 支付撤销成功
|
2023-08-17 11:55:14 +08:00
|
|
|
|
paymentReverseSucceeded(data);
|
2023-08-17 12:16:15 +08:00
|
|
|
|
} else if (AdapayEventEnum.payment_reverse_failed.getValue().equals(type)) {
|
|
|
|
|
|
// 支付撤销失败
|
|
|
|
|
|
paymentReverseFailed(data);
|
2023-08-08 14:16:05 +08:00
|
|
|
|
} else if (AdapayEventEnum.cash_succeeded.getValue().equals(type)) {
|
2023-08-28 15:10:38 +08:00
|
|
|
|
// 取现成功
|
2023-08-08 14:24:04 +08:00
|
|
|
|
cashSucceeded(data);
|
|
|
|
|
|
} else if (AdapayEventEnum.cash_failed.getValue().equals(type)) {
|
2023-08-28 15:10:38 +08:00
|
|
|
|
// 取现失败
|
2023-08-08 14:24:04 +08:00
|
|
|
|
cashFailed(data);
|
2023-07-10 15:14:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-08 14:24:04 +08:00
|
|
|
|
|
2023-07-13 16:53:14 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* adapay支付成功回调
|
|
|
|
|
|
* @param data
|
|
|
|
|
|
* @throws JsonProcessingException
|
|
|
|
|
|
*/
|
2023-07-10 15:14:58 +08:00
|
|
|
|
private void paymentSucceeded(String data) throws JsonProcessingException {
|
2023-05-20 10:53:49 +08:00
|
|
|
|
//验签成功 保存到回调记录表中
|
2023-05-30 13:45:56 +08:00
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
2023-05-20 10:53:49 +08:00
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
|
2023-05-30 13:45:56 +08:00
|
|
|
|
AdapayCallbackRecord adapayCallbackRecord = mapper.readValue(jsonObject.toJSONString(), AdapayCallbackRecord.class);
|
2023-08-28 15:05:24 +08:00
|
|
|
|
|
|
|
|
|
|
// 支付扩展域
|
2023-05-30 13:45:56 +08:00
|
|
|
|
adapayCallbackRecord.setExpend(jsonObject.getString("expend"));
|
2023-05-20 10:53:49 +08:00
|
|
|
|
|
2023-08-28 15:05:24 +08:00
|
|
|
|
// 支付id
|
|
|
|
|
|
String paymentId = jsonObject.getString("id");
|
|
|
|
|
|
adapayCallbackRecord.setPaymentId(paymentId);
|
|
|
|
|
|
|
|
|
|
|
|
// 订单附加说明
|
2023-05-27 09:36:07 +08:00
|
|
|
|
JSONObject descJson = JSON.parseObject(adapayCallbackRecord.getDescription());
|
2023-08-28 15:05:24 +08:00
|
|
|
|
|
|
|
|
|
|
// 支付回调中包含的场景类型
|
|
|
|
|
|
String scenarioType = descJson.getString("type");
|
|
|
|
|
|
adapayCallbackRecord.setPayScenario(scenarioType);
|
|
|
|
|
|
|
|
|
|
|
|
// 支付回调中包含的会员id
|
2023-05-27 09:36:07 +08:00
|
|
|
|
String memberId = descJson.getString("memberId");
|
2023-05-30 14:02:51 +08:00
|
|
|
|
adapayCallbackRecord.setMemberId(memberId);
|
2023-08-28 15:05:24 +08:00
|
|
|
|
|
|
|
|
|
|
// 支付回调中包含的订单编号
|
2023-05-27 09:36:07 +08:00
|
|
|
|
String orderCode = descJson.getString("orderCode");
|
2023-05-30 14:02:51 +08:00
|
|
|
|
adapayCallbackRecord.setOrderCode(orderCode);
|
2023-08-28 15:05:24 +08:00
|
|
|
|
|
|
|
|
|
|
// 支付金额
|
2023-05-27 09:36:07 +08:00
|
|
|
|
BigDecimal amount = adapayCallbackRecord.getPayAmt();
|
2023-05-30 14:02:51 +08:00
|
|
|
|
|
|
|
|
|
|
// 保存到数据库
|
|
|
|
|
|
adapayCallbackRecordService.saveAdapayCallbackRecord(adapayCallbackRecord);
|
|
|
|
|
|
|
2023-08-28 17:27:57 +08:00
|
|
|
|
// 保存MemberAdapayRecord
|
|
|
|
|
|
MemberAdapayRecord memberAdapayRecord = new MemberAdapayRecord();
|
|
|
|
|
|
memberAdapayRecord.setMemberId(memberId);
|
|
|
|
|
|
memberAdapayRecord.setPaymentId(paymentId);
|
|
|
|
|
|
memberAdapayRecord.setPaymentOrderNo(adapayCallbackRecord.getOutTransId());
|
|
|
|
|
|
memberAdapayRecord.setScenarioType(scenarioType);
|
|
|
|
|
|
memberAdapayRecord.setPayAmt(amount);
|
|
|
|
|
|
memberAdapayRecord.setRefundAmt(BigDecimal.ZERO);
|
|
|
|
|
|
memberAdapayRecord.setSpendAmt(BigDecimal.ZERO);
|
|
|
|
|
|
memberAdapayRecord.setFreezeAmt(BigDecimal.ZERO);
|
|
|
|
|
|
memberAdapayRecord.setBalanceAmt(amount);
|
|
|
|
|
|
memberAdapayRecordService.insertSelective(memberAdapayRecord);
|
|
|
|
|
|
|
2023-07-14 15:05:36 +08:00
|
|
|
|
// 微信支付订单 记录会员交易流水
|
|
|
|
|
|
MemberTransactionRecord record = MemberTransactionRecord.builder()
|
|
|
|
|
|
.orderCode(orderCode)
|
2023-08-28 15:05:24 +08:00
|
|
|
|
.scenarioType(scenarioType)
|
2023-07-14 15:05:36 +08:00
|
|
|
|
.memberId(memberId)
|
|
|
|
|
|
.actionType(ActionTypeEnum.FORWARD.getValue())
|
|
|
|
|
|
.payMode(PayModeEnum.PAYMENT_OF_WECHATPAY.getValue())
|
|
|
|
|
|
.paymentInstitutions(PaymentInstitutionsEnum.ADAPAY.getValue())
|
|
|
|
|
|
.amount(amount) // 单位元
|
|
|
|
|
|
.outTradeNo(adapayCallbackRecord.getPartyOrderId())
|
|
|
|
|
|
.transactionId(adapayCallbackRecord.getOutTransId())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
memberTransactionRecordService.insertSelective(record);
|
|
|
|
|
|
|
2023-08-28 15:05:24 +08:00
|
|
|
|
if (StringUtils.equals(scenarioType, ScenarioEnum.ORDER.getValue())) { // 1-订单支付
|
2023-08-28 17:27:57 +08:00
|
|
|
|
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-28 17:27:57 +08:00
|
|
|
|
.build();
|
|
|
|
|
|
orderPayRecordService.batchInsert(Lists.newArrayList(orderPayRecord));
|
|
|
|
|
|
|
2023-08-28 19:53:43 +08:00
|
|
|
|
// 更新冻结金额 支付成功后全部冻结
|
2023-08-28 17:30:13 +08:00
|
|
|
|
memberAdapayRecordService.updateFreezeAmount(paymentId, amount);
|
|
|
|
|
|
|
2023-05-27 09:36:07 +08:00
|
|
|
|
// 支付订单成功
|
|
|
|
|
|
PayOrderSuccessCallbackDTO callbackDTO = PayOrderSuccessCallbackDTO.builder()
|
|
|
|
|
|
.orderCode(orderCode)
|
|
|
|
|
|
.payAmount(amount)
|
|
|
|
|
|
.payMode(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())
|
2023-08-28 14:53:02 +08:00
|
|
|
|
.acquirer(AcquirerEnum.ADAPAY.getValue())
|
2023-05-27 09:36:07 +08:00
|
|
|
|
.build();
|
|
|
|
|
|
// 订单支付成功 支付回调
|
2023-07-11 17:01:15 +08:00
|
|
|
|
orderBasicInfoService.payOrderSuccessCallback(callbackDTO);
|
2023-08-28 15:05:24 +08:00
|
|
|
|
} else if (StringUtils.equals(scenarioType, ScenarioEnum.BALANCE.getValue())) { // 2-充值余额
|
2023-05-27 09:36:07 +08:00
|
|
|
|
// 充值余额成功
|
|
|
|
|
|
UpdateMemberBalanceDTO dto = new UpdateMemberBalanceDTO();
|
|
|
|
|
|
dto.setMemberId(memberId);
|
|
|
|
|
|
dto.setType(MemberWalletEnum.TYPE_IN.getValue());
|
|
|
|
|
|
dto.setSubType(MemberWalletEnum.SUBTYPE_TOP_UP.getValue());
|
|
|
|
|
|
dto.setUpdatePrincipalBalance(amount);
|
|
|
|
|
|
memberBasicInfoService.updateMemberBalance(dto);
|
2023-08-29 17:05:36 +08:00
|
|
|
|
} else if (StringUtils.equals(scenarioType, ScenarioEnum.OCCUPY.getValue())) { // 占桩订单
|
2023-08-29 16:40:20 +08:00
|
|
|
|
// 通过订单号查询出占桩订单信息
|
|
|
|
|
|
OrderPileOccupy orderPileOccupy = orderPileOccupyService.queryByOccupyCode(orderCode);
|
|
|
|
|
|
// 订单状态改为 1-订单完成
|
|
|
|
|
|
orderPileOccupy.setStatus(OccupyOrderStatusEnum.ORDER_COMPLETE.getCode());
|
|
|
|
|
|
// 支付状态改为 1-支付完成
|
|
|
|
|
|
orderPileOccupy.setPayStatus(OccupyOrderPayStatusEnum.PAYMENT_COMPLETION.getCode());
|
|
|
|
|
|
|
|
|
|
|
|
orderPileOccupyService.updateByPrimaryKey(orderPileOccupy);
|
2023-05-27 09:36:07 +08:00
|
|
|
|
}
|
2023-07-27 15:37:45 +08:00
|
|
|
|
}
|
2023-05-27 09:36:07 +08:00
|
|
|
|
|
2023-07-27 15:37:45 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 汇付退款成功
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void refundSucceeded(String data) {
|
2023-09-01 17:29:59 +08:00
|
|
|
|
log.info("退款成功 data:{}", JSON.toJSONString(data));
|
2023-07-27 15:37:45 +08:00
|
|
|
|
// 保存退款回调记录
|
|
|
|
|
|
adapayRefundRecordService.saveAdapayRefundRecord(data);
|
2023-09-01 17:29:59 +08:00
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
|
|
|
|
|
JSONObject reason = jsonObject.getJSONObject("reason");
|
|
|
|
|
|
if (ScenarioEnum.BALANCE.getValue().equals(reason.getString("scenarioType"))) {
|
|
|
|
|
|
// 这笔支付订单原来是充值余额的,退款成功了,需要扣掉会员的本金金额
|
|
|
|
|
|
UpdateMemberBalanceDTO dto = new UpdateMemberBalanceDTO();
|
|
|
|
|
|
String memberId = reason.getString("memberId");
|
|
|
|
|
|
dto.setMemberId(memberId);
|
|
|
|
|
|
dto.setUpdatePrincipalBalance(new BigDecimal(jsonObject.getString("refund_amt"))); // 更新会员本金金额,单位元
|
|
|
|
|
|
dto.setType(MemberWalletEnum.TYPE_OUT.getValue());
|
|
|
|
|
|
dto.setSubType(MemberWalletEnum.SUBTYPE_USER_REFUND.getValue());
|
|
|
|
|
|
memberBasicInfoService.updateMemberBalance(dto);
|
|
|
|
|
|
|
|
|
|
|
|
// 收到回调,删除缓存
|
|
|
|
|
|
String redisKey = CacheConstants.MEMBER_BALANCE_REFUNDS_ARE_IN_PROGRESS + memberId;
|
|
|
|
|
|
redisCache.deleteObject(redisKey);
|
|
|
|
|
|
}
|
2023-05-20 11:14:33 +08:00
|
|
|
|
}
|
2023-05-20 10:53:49 +08:00
|
|
|
|
|
2023-07-27 15:08:40 +08:00
|
|
|
|
/**
|
2023-09-01 17:29:59 +08:00
|
|
|
|
* 退款失败
|
2023-07-27 15:08:40 +08:00
|
|
|
|
* @param data
|
|
|
|
|
|
*/
|
2023-09-01 17:29:59 +08:00
|
|
|
|
private void refundFailed(String data) {
|
|
|
|
|
|
log.info("退款失败 data:{}", JSON.toJSONString(data));
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
|
|
|
|
|
JSONObject reason = jsonObject.getJSONObject("reason");
|
|
|
|
|
|
if (ScenarioEnum.BALANCE.getValue().equals(reason.getString("scenarioType"))) {
|
|
|
|
|
|
String memberId = reason.getString("memberId");
|
|
|
|
|
|
|
|
|
|
|
|
// 收到回调,删除缓存
|
|
|
|
|
|
String redisKey = CacheConstants.MEMBER_BALANCE_REFUNDS_ARE_IN_PROGRESS + memberId;
|
|
|
|
|
|
redisCache.deleteObject(redisKey);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 对公账户创建失败
|
|
|
|
|
|
*/
|
2023-07-10 17:06:19 +08:00
|
|
|
|
private void corpMemberFailed(String data) {
|
|
|
|
|
|
// 删除表中的记录
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
|
|
|
|
|
String memberId = jsonObject.getString("member_id");
|
2023-07-10 17:39:08 +08:00
|
|
|
|
if (StringUtils.isBlank(memberId)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-07-10 17:55:26 +08:00
|
|
|
|
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMemberId(memberId);
|
|
|
|
|
|
if (adapayMemberAccount == null) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-07-13 15:12:02 +08:00
|
|
|
|
adapayMemberAccount.setStatus(Constants.TWO);
|
2023-07-10 17:56:19 +08:00
|
|
|
|
// 逻辑删除记录,并删除缓存
|
2023-07-10 17:55:26 +08:00
|
|
|
|
adapayMemberAccountService.updateAdapayMemberAccount(adapayMemberAccount);
|
2023-07-10 17:39:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-27 15:08:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 对公账户创建成功
|
|
|
|
|
|
*/
|
2023-07-10 17:39:08 +08:00
|
|
|
|
private void corpMemberSucceeded(String data) {
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
|
|
|
|
|
String memberId = jsonObject.getString("member_id");
|
|
|
|
|
|
if (StringUtils.isBlank(memberId)) {
|
|
|
|
|
|
return;
|
2023-07-10 17:06:19 +08:00
|
|
|
|
}
|
2023-07-10 17:39:08 +08:00
|
|
|
|
AdapayMemberAccount adapayMemberAccount = new AdapayMemberAccount();
|
|
|
|
|
|
adapayMemberAccount.setAdapayMemberId(memberId);
|
|
|
|
|
|
adapayMemberAccount.setStatus(Constants.ONE);
|
|
|
|
|
|
adapayMemberAccountService.updateAdapayMemberAccountByMemberId(adapayMemberAccount);
|
2023-07-10 17:06:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-08 14:16:05 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 取现成功
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void cashSucceeded(String data) {
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
|
|
|
|
|
String withdrawCode = jsonObject.getString("id");
|
|
|
|
|
|
// 通过取现id查询取现数据
|
|
|
|
|
|
ClearingWithdrawInfo clearingWithdrawInfo = clearingWithdrawInfoService.selectByWithdrawCode(withdrawCode);
|
|
|
|
|
|
clearingWithdrawInfo.setWithdrawStatus(Constants.ONE);
|
2023-08-08 14:35:18 +08:00
|
|
|
|
clearingWithdrawInfo.setUpdateTime(DateUtils.getNowDate());
|
2023-08-08 14:36:49 +08:00
|
|
|
|
clearingWithdrawInfoService.updateByPrimaryKeySelective(clearingWithdrawInfo);
|
2023-08-08 14:16:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-08 14:24:04 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 取现失败
|
|
|
|
|
|
* @param data
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void cashFailed(String data) {
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
|
|
|
|
|
String withdrawCode = jsonObject.getString("id");
|
|
|
|
|
|
// 通过取现id查询取现数据
|
|
|
|
|
|
ClearingWithdrawInfo clearingWithdrawInfo = clearingWithdrawInfoService.selectByWithdrawCode(withdrawCode);
|
|
|
|
|
|
clearingWithdrawInfo.setWithdrawStatus(Constants.TWO);
|
2023-08-08 14:35:18 +08:00
|
|
|
|
clearingWithdrawInfo.setUpdateTime(DateUtils.getNowDate());
|
2023-08-08 14:36:49 +08:00
|
|
|
|
clearingWithdrawInfoService.updateByPrimaryKeySelective(clearingWithdrawInfo);
|
2023-08-08 14:24:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-17 11:55:14 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 支付撤销成功
|
|
|
|
|
|
*/
|
2023-08-17 12:44:36 +08:00
|
|
|
|
private void paymentReverseSucceeded(String data) {
|
2023-08-17 12:13:46 +08:00
|
|
|
|
log.info("支付撤销成功 data:{}", JSON.toJSONString(data));
|
2023-08-17 11:55:14 +08:00
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
2023-08-17 12:44:36 +08:00
|
|
|
|
JSONObject reason = jsonObject.getJSONObject("reason");
|
2023-08-23 16:26:02 +08:00
|
|
|
|
if (ScenarioEnum.BALANCE.getValue().equals(reason.getString("scenarioType"))) {
|
|
|
|
|
|
// 这笔支付订单原来是充值余额的,退款成功了,需要扣掉会员的本金金额
|
|
|
|
|
|
UpdateMemberBalanceDTO dto = new UpdateMemberBalanceDTO();
|
|
|
|
|
|
String memberId = reason.getString("memberId");
|
|
|
|
|
|
dto.setMemberId(memberId);
|
|
|
|
|
|
dto.setUpdatePrincipalBalance(new BigDecimal(jsonObject.getString("reverse_amt"))); // 更新会员本金金额,单位元
|
|
|
|
|
|
dto.setType(MemberWalletEnum.TYPE_OUT.getValue());
|
|
|
|
|
|
dto.setSubType(MemberWalletEnum.SUBTYPE_USER_REFUND.getValue());
|
|
|
|
|
|
memberBasicInfoService.updateMemberBalance(dto);
|
|
|
|
|
|
|
|
|
|
|
|
// 收到回调,删除缓存
|
|
|
|
|
|
String redisKey = CacheConstants.MEMBER_BALANCE_REFUNDS_ARE_IN_PROGRESS + memberId;
|
|
|
|
|
|
redisCache.deleteObject(redisKey);
|
|
|
|
|
|
}
|
2023-08-17 11:55:14 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-17 12:16:15 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 支付撤销失败
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void paymentReverseFailed(String data) {
|
|
|
|
|
|
log.info("支付撤销失败 data:{}", JSON.toJSONString(data));
|
2023-08-23 16:26:02 +08:00
|
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
|
|
|
|
|
JSONObject reason = jsonObject.getJSONObject("reason");
|
|
|
|
|
|
if (ScenarioEnum.BALANCE.getValue().equals(reason.getString("scenarioType"))) {
|
|
|
|
|
|
String memberId = reason.getString("memberId");
|
|
|
|
|
|
|
|
|
|
|
|
// 收到回调,删除缓存
|
|
|
|
|
|
String redisKey = CacheConstants.MEMBER_BALANCE_REFUNDS_ARE_IN_PROGRESS + memberId;
|
|
|
|
|
|
redisCache.deleteObject(redisKey);
|
|
|
|
|
|
}
|
2023-08-17 12:16:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-18 09:52:12 +08:00
|
|
|
|
public Map<String, Object> payOccupyPileOrder(PayOrderDTO dto) {
|
|
|
|
|
|
return orderPileOccupyService.payOccupyPileOrder(dto);
|
|
|
|
|
|
}
|
2023-09-01 11:36:31 +08:00
|
|
|
|
|
2023-09-12 08:33:45 +08:00
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|