Merge branch 'dev' into merge_adapay

# Conflicts:
#	jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java
#	jsowell-admin/src/main/resources/application-dev.yml
This commit is contained in:
2023-09-08 15:48:57 +08:00
35 changed files with 3083 additions and 168 deletions

View File

@@ -13,7 +13,6 @@ import com.jsowell.adapay.common.DivMember;
import com.jsowell.adapay.config.AbstractAdapayConfig;
import com.jsowell.adapay.dto.*;
import com.jsowell.adapay.factory.AdapayConfigFactory;
import com.jsowell.adapay.operation.PaymentConfirmOperation;
import com.jsowell.adapay.operation.PaymentReverseOperation;
import com.jsowell.adapay.response.*;
import com.jsowell.adapay.vo.*;
@@ -788,45 +787,6 @@ public class AdapayService {
return null;
}
/**
* 创建交易确认请求/创建分账请求
* 这个方法只适用于给一个用户分账
*/
public PaymentConfirmResponse createPaymentConfirmRequest(PaymentConfirmOperation operation) {
// 调汇付的分账接口 确认交易
Map<String, Object> confirmParams = Maps.newHashMap();
// Adapay生成的支付对象id
confirmParams.put("payment_id", operation.getPaymentId());
// 请求订单号只能为英文、数字或者下划线的一种或多种组合保证在app_id下唯一
confirmParams.put("order_no", "PC" + System.currentTimeMillis());
// 确认金额必须大于0保留两位小数点如0.10、100.05等。必须小于等于原支付金额-已确认金额-已撤销金额。
String amount = AdapayUtil.formatAmount(operation.getConfirmAmt());
confirmParams.put("confirm_amt", amount);
// 附加说明
JSONObject jsonObject = new JSONObject();
jsonObject.put("orderCode", operation.getOrderCode());
jsonObject.put("adapayMemberId", operation.getAdapayMemberId());
confirmParams.put("description", jsonObject.toJSONString());
// 分账对象信息 一次最多7个
DivMember divMember = new DivMember();
divMember.setMember_id(operation.getAdapayMemberId());
divMember.setAmount(amount);
divMember.setFee_flag(Constants.Y);
confirmParams.put("div_members", Lists.newArrayList(divMember));
Map<String, Object> paymentConfirm = null;
try {
paymentConfirm = PaymentConfirm.create(confirmParams, operation.getMerchantKey());
} catch (BaseAdaPayException e) {
log.error("创建交易确认请求error", e);
}
String jsonString = JSON.toJSONString(paymentConfirm);
log.info("调分账接口param:{}, result:{}", JSON.toJSONString(confirmParams), jsonString);
return JSONObject.parseObject(jsonString, PaymentConfirmResponse.class);
}
/**
* 创建交易确认请求/创建分账请求
* 这个方法只适用于给一个用户分账
@@ -906,13 +866,13 @@ public class AdapayService {
/**
* 创建支付确认撤销
*/
public void createConfirmReverse(String paymentConfirmId) throws BaseAdaPayException {
public void createConfirmReverse(String paymentConfirmId, String wechatAppId) throws BaseAdaPayException {
Map<String, Object> confirmReverseParams = Maps.newHashMap();
confirmReverseParams.put("adapay_func_code", "payments.confirm.reverse");
confirmReverseParams.put("payment_confirm_id", paymentConfirmId);
confirmReverseParams.put("reason", "支付确认撤销");
confirmReverseParams.put("order_no", IdUtils.fastSimpleUUID());
Map<String, Object> confirmReverseResult = AdapayCommon.requestAdapay(confirmReverseParams);
Map<String, Object> confirmReverseResult = AdapayCommon.requestAdapay(confirmReverseParams, wechatAppId);
log.info("创建支付确认撤销param:{}, result:{}", JSON.toJSONString(confirmReverseParams), JSON.toJSONString(confirmReverseResult));
}

View File

@@ -239,4 +239,11 @@ public interface OrderBasicInfoMapper {
* @return
*/
IndexOrderInfoVO getIndexOrderDetail(@Param("list") List<String> orderCodeList);
/**
* 通过站点id修改运营商id
* @param stationId
* @return
*/
int updateMerchantByStationId(@Param("stationId")Long stationId, @Param("newMerchantId")String newMerchantId);
}

View File

@@ -113,4 +113,13 @@ public interface OrderPileOccupyMapper {
* @return
*/
OrderPileOccupy queryUnPayOrderByMemberId(String memberId);
/**
* 查询占桩订单列表
*
* @param orderPileOccupy 占桩订单
* @return 占桩订单集合
*/
public List<OrderPileOccupy> selectOrderPileOccupyList(OrderPileOccupy orderPileOccupy);
}

View File

@@ -345,4 +345,11 @@ public interface IOrderBasicInfoService {
void returnUpdateOrderBasicInfo(OrderBasicInfo orderBasicInfo, TransactionRecordsData data);
OrderDetail returnUpdateOrderDetail(OrderBasicInfo orderBasicInfo, TransactionRecordsData data);
/**
* 通过站点id修改运营商id
* @param stationId
* @return
*/
int updateMerchantByStationId(Long stationId, String newMerchantId);
}

View File

@@ -37,6 +37,14 @@ public interface OrderPileOccupyService{
OrderPileOccupy queryByOccupyCode(String occupyCode);
/**
* 查询占桩订单列表
*
* @param orderPileOccupy 占桩订单
* @return 占桩订单集合
*/
public List<OrderPileOccupy> selectOrderPileOccupyList(OrderPileOccupy orderPileOccupy);
List<OrderPileOccupy> queryOccupyOrderList(QueryOccupyOrderDTO dto);
/**

View File

@@ -295,16 +295,16 @@ public class MemberBasicInfoServiceImpl implements IMemberBasicInfoService {
* @return
*/
@Override
public List<MemberVO> selectMemberList(QueryMemberInfoDTO dto) {
// 获取登录账号信息
AuthorizedDeptVO authorizedMap = SecurityUtils.getAuthorizedMap();
if (authorizedMap == null) {
return new ArrayList<>();
}
List<String> merchantDeptIds = authorizedMap.getMerchantDeptIds();
if (CollectionUtils.isNotEmpty(merchantDeptIds)) {
dto.setMerchantDeptIds(merchantDeptIds);
}
public List<MemberVO> selectMemberList(QueryMemberInfoDTO dto) {
// // 获取登录账号信息
// AuthorizedDeptVO authorizedMap = SecurityUtils.getAuthorizedMap();
// if (authorizedMap == null) {
// return new ArrayList<>();
// }
// List<String> merchantDeptIds = authorizedMap.getMerchantDeptIds();
// if (CollectionUtils.isNotEmpty(merchantDeptIds)) {
// dto.setMerchantDeptIds(merchantDeptIds);
// }
return memberBasicInfoMapper.selectMemberList(dto);
}

View File

@@ -7,7 +7,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.jsowell.adapay.dto.QueryPaymentConfirmDTO;
import com.jsowell.adapay.operation.PaymentConfirmOperation;
import com.jsowell.adapay.operation.PaymentReverseOperation;
import com.jsowell.adapay.response.PaymentConfirmResponse;
import com.jsowell.adapay.response.PaymentReverseResponse;
@@ -1027,6 +1026,16 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
return orderDetail;
}
/**
* 通过站点id修改运营商id
* @param stationId
* @return
*/
@Override
public int updateMerchantByStationId(Long stationId, String newMerchantId) {
return orderBasicInfoMapper.updateMerchantByStationId(stationId, newMerchantId);
}
/**
* 卡状态解锁
*/
@@ -1442,22 +1451,24 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
BigDecimal deductionAmount = vo.getDeductionAmount();
// 延时分账使用确认交易API
// PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(paymentId, adapayMemberAccount, deductionAmount, orderCode, wechatAppId);
PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(paymentId,
adapayMemberAccount, deductionAmount, orderCode, wechatAppId);
// 换新的方法,逻辑不变,参数封装了
PaymentConfirmOperation operation = new PaymentConfirmOperation();
operation.setPaymentId(paymentId);
operation.setConfirmAmt(deductionAmount);
operation.setOrderCode(orderCode);
operation.setAdapayMemberId(adapayMemberAccount.getAdapayMemberId());
operation.setMerchantKey(wechatAppId);
PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(operation);
// PaymentConfirmOperation operation = new PaymentConfirmOperation();
// operation.setPaymentId(paymentId);
// operation.setConfirmAmt(deductionAmount);
// operation.setOrderCode(orderCode);
// operation.setAdapayMemberId(adapayMemberAccount.getAdapayMemberId());
// operation.setMerchantKey(wechatAppId);
// PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(operation);
if (paymentConfirmResponse != null && paymentConfirmResponse.isNotFailed()) {
confirmAmt = confirmAmt.add(new BigDecimal(paymentConfirmResponse.getConfirm_amt()));
feeAmt = feeAmt.add(new BigDecimal(paymentConfirmResponse.getFee_amt()));
status = paymentConfirmResponse.getStatus();
memberAdapayRecordService.updateSpendAmount(paymentId, deductionAmount);
// memberAdapayRecordService.updateSpendAmount(paymentId, deductionAmount);
memberAdapayRecordService.unfreezeAmountAndUpdateSpendAmount(paymentId, confirmAmt, confirmAmt);
}
}
@@ -1573,15 +1584,16 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
// 调汇付的分账接口 确认交易
// PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(paymentId, adapayMemberAccount, settleAmount, orderCode, wechatAppId);
PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(paymentId,
adapayMemberAccount, settleAmount, orderCode, wechatAppId);
PaymentConfirmOperation operation = new PaymentConfirmOperation();
operation.setPaymentId(paymentId);
operation.setConfirmAmt(settleAmount);
operation.setOrderCode(orderCode);
operation.setAdapayMemberId(adapayMemberAccount.getAdapayMemberId());
operation.setMerchantKey(wechatAppId);
PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(operation);
// PaymentConfirmOperation operation = new PaymentConfirmOperation();
// operation.setPaymentId(paymentId);
// operation.setConfirmAmt(settleAmount);
// operation.setOrderCode(orderCode);
// operation.setAdapayMemberId(adapayMemberAccount.getAdapayMemberId());
// operation.setMerchantKey(wechatAppId);
// PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(operation);
// 分账接口返回的信息
@@ -3335,11 +3347,13 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
throw new BusinessException(ReturnCodeEnum.CODE_STATION_IS_NOT_OPEN);
}
// 校验启动桩使用的小程序,和充电桩所属一级运营商是否一致
String merchantIdByAppId = pileMerchantInfoService.getFirstLevelMerchantIdByAppId(dto.getAppId());
String merchantIdByMerchantId = pileMerchantInfoService.getFirstLevelMerchantIdByMerchantId(stationInfo.getMerchantId());
if (!StringUtils.equals(merchantIdByAppId, merchantIdByMerchantId)) {
throw new BusinessException("", "当前桩运营商与小程序所属运营商不一致");
if (StringUtils.isNotBlank(dto.getAppId())) {
// 校验启动桩使用的小程序,和充电桩所属一级运营商是否一致
String merchantIdByAppId = pileMerchantInfoService.getFirstLevelMerchantIdByAppId(dto.getAppId());
String merchantIdByMerchantId = pileMerchantInfoService.getFirstLevelMerchantIdByMerchantId(stationInfo.getMerchantId());
if (!StringUtils.equals(merchantIdByAppId, merchantIdByMerchantId)) {
throw new BusinessException("", "当前桩运营商与小程序所属运营商不一致");
}
}
// 如果是鉴权卡或者vin启动不判断枪口状态

View File

@@ -1,5 +1,6 @@
package com.jsowell.pile.service.impl;
import com.alibaba.fastjson2.JSON;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Maps;
import com.jsowell.adapay.service.AdapayService;
@@ -138,6 +139,11 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
return orderPileOccupyMapper.queryByOccupyCode(occupyCode);
}
@Override
public List<OrderPileOccupy> selectOrderPileOccupyList(OrderPileOccupy orderPileOccupy) {
return orderPileOccupyMapper.selectOrderPileOccupyList(orderPileOccupy);
}
/**
* 查询占桩订单列表
*
@@ -190,6 +196,8 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
*/
@Override
public void stopOccupyPileOrder(String pileSn, String connectorCode) {
// 两种情况 1是没有停车地锁自动升起2是停车完成地锁升起
// 根据充电站sn和枪口号查询占桩中的占桩订单
OrderPileOccupy orderPileOccupy = getOccupiedOrder(pileSn, connectorCode);
if (orderPileOccupy == null) {
@@ -385,6 +393,7 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
@Override
public void remoteGroundLock(RemoteGroundLockDTO dto) {
log.info("控制地锁升降并生成占桩订单 params:{}", JSON.toJSONString(dto));
// 控制地锁升降
RemoteControlGroundLockCommand command = new RemoteControlGroundLockCommand();
command.setPileSn(dto.getPileSn());

View File

@@ -776,6 +776,7 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
}
lockInfoList.add(GroundLockInfoVO.LockInfo.builder()
.connectorCode(pileConnectorInfoVO.getPileConnectorCode())
.parkNo(pileConnectorInfoVO.getParkNo())
.lockStatus(parkingLockStatus)
.parkingStatus(data.getParkingStatus())
.build());

View File

@@ -81,6 +81,9 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
@Autowired
private IThirdPartyParkingConfigService parkingConfigService;
@Autowired
private IOrderBasicInfoService orderBasicInfoService;
/**
* 查询充电站信息
@@ -345,6 +348,11 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
pileStationInfo.setDeptId(String.valueOf(newDeptId));
}
/**
* 修改订单中的 merchantId
*/
orderBasicInfoService.updateMerchantByStationId(pileStationInfo.getId(), newMerchantId);
}
/**

View File

@@ -43,6 +43,11 @@ public class GroundLockInfoVO {
*/
private String connectorCode;
/**
* 车位号
*/
private String parkNo;
/**
* 地锁状态
*/