This commit is contained in:
Lemon
2023-07-20 16:04:03 +08:00
6 changed files with 24 additions and 29 deletions

View File

@@ -256,6 +256,10 @@ public class OrderService {
if (orderInfo == null) { if (orderInfo == null) {
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_NULL_ERROR); throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_NULL_ERROR);
} }
// 判断订单状态是不是已经结算了
if (StringUtils.equals(orderInfo.getOrderStatus(), OrderStatusEnum.ORDER_COMPLETE.getValue())) {
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_COMPLETE_ERROR);
}
// 校验订单中的会员与操作会员是否一致 // 校验订单中的会员与操作会员是否一致
if (!StringUtils.equals(orderInfo.getMemberId(), dto.getMemberId())) { if (!StringUtils.equals(orderInfo.getMemberId(), dto.getMemberId())) {
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_MEMBER_NOT_MATCH_ERROR); throw new BusinessException(ReturnCodeEnum.CODE_ORDER_MEMBER_NOT_MATCH_ERROR);

View File

@@ -98,6 +98,8 @@ public enum ReturnCodeEnum {
CODE_FIRMWARE_NOT_FOUND_ERROR("00100046", "未找到相应固件"), CODE_FIRMWARE_NOT_FOUND_ERROR("00100046", "未找到相应固件"),
CODE_ORDER_COMPLETE_ERROR("00100047", "该订单已经结算完成!"),
/* 个人桩 start */ /* 个人桩 start */
CODE_PILE_HAS_BEEN_BINDING_ERROR("00400001", "此桩已被绑定,请联系管理员!"), CODE_PILE_HAS_BEEN_BINDING_ERROR("00400001", "此桩已被绑定,请联系管理员!"),

View File

@@ -7,7 +7,6 @@ import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.ykc.CardStatusEnum;
import com.jsowell.common.enums.ykc.OrderStatusEnum; import com.jsowell.common.enums.ykc.OrderStatusEnum;
import com.jsowell.common.enums.ykc.YKCChargingStopReasonEnum; import com.jsowell.common.enums.ykc.YKCChargingStopReasonEnum;
import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.BytesUtil;
@@ -17,7 +16,8 @@ import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.YKCUtils; import com.jsowell.common.util.YKCUtils;
import com.jsowell.common.util.id.IdUtils; import com.jsowell.common.util.id.IdUtils;
import com.jsowell.netty.factory.YKCOperateFactory; import com.jsowell.netty.factory.YKCOperateFactory;
import com.jsowell.pile.domain.*; import com.jsowell.pile.domain.OrderBasicInfo;
import com.jsowell.pile.domain.ThirdPartyStationRelation;
import com.jsowell.pile.service.*; import com.jsowell.pile.service.*;
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
import com.jsowell.thirdparty.lianlian.service.LianLianService; import com.jsowell.thirdparty.lianlian.service.LianLianService;
@@ -604,24 +604,7 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
if (Objects.isNull(orderBasicInfo.getChargeEndTime())) { // 结束时间 if (Objects.isNull(orderBasicInfo.getChargeEndTime())) { // 结束时间
orderBasicInfo.setChargeEndTime(DateUtils.parseDate(data.getEndTime())); orderBasicInfo.setChargeEndTime(DateUtils.parseDate(data.getEndTime()));
} }
// if (!StringUtils.equals("0000000000000000", data.getLogicCard())) {
// // 根据物理卡号查出当前为锁定状态的卡
// PileAuthCard cardInfo = pileAuthCardService.selectSomeStatusCardInfo(CardStatusEnum.START_LOCK.getCode(), orderBasicInfo.getLogicCard());
// if (cardInfo != null) {
// // orderBasicInfo.setMemberId(cardInfo.getMemberId());
// // 将此卡状态改为正常
// cardInfo.setStatus(CardStatusEnum.NORMAL.getCode());
// pileAuthCardService.updatePileAuthCard(cardInfo);
// }
// }
// // 如果是vin启动将启动锁定状态改为正常
// if (StringUtils.equals(data.getTransactionIdentifier(), "05")) {
// MemberPlateNumberRelation plateInfo = memberPlateNumberRelationService.getMemberPlateInfoByVinCode(data.getVinCode());
// if (plateInfo != null && (StringUtils.equals(plateInfo.getVinStatus(), "2"))) {
// plateInfo.setVinStatus("1");
// memberPlateNumberRelationService.updateMemberPlateNumberRelation(plateInfo);
// }
// }
orderBasicInfoService.updateOrderBasicInfo(orderBasicInfo); orderBasicInfoService.updateOrderBasicInfo(orderBasicInfo);
// 结算订单操作 // 结算订单操作

View File

@@ -629,7 +629,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
// 有时候充电桩到达金额停止充电会多出一点金额比如实际需要充50元的电充电桩传来的消费金额为50.01元,在后台记录的时候需要舍去 // 有时候充电桩到达金额停止充电会多出一点金额比如实际需要充50元的电充电桩传来的消费金额为50.01元,在后台记录的时候需要舍去
if (orderAmount.compareTo(payAmount) > 0) { if (orderAmount.compareTo(payAmount) > 0) {
logger.info("结算订单:【{}】充电桩传来的消费金额:【{}】大于付款金额:【{}】, 消费金额设置为付款金额相等数据", orderBasicInfo.getOrderCode(), orderAmount, payAmount); logger.info("结算订单:【{}】充电桩传来的消费金额:【{}】大于付款金额:【{}】, 消费金额设置为付款金额相等数据", orderCode, orderAmount, payAmount);
orderAmount = payAmount; orderAmount = payAmount;
} }
@@ -640,7 +640,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
BigDecimal residue = payAmount.subtract(orderAmount); BigDecimal residue = payAmount.subtract(orderAmount);
if (residue.compareTo(BigDecimal.ZERO) > 0) { if (residue.compareTo(BigDecimal.ZERO) > 0) {
// 查支付记录 // 查支付记录
List<OrderPayRecord> payRecordList = orderPayRecordService.getOrderPayRecordList(orderBasicInfo.getOrderCode()); List<OrderPayRecord> payRecordList = orderPayRecordService.getOrderPayRecordList(orderCode);
// 更新订单支付记录 // 更新订单支付记录
List<OrderPayRecord> updatePayRecordList = Lists.newArrayList(); List<OrderPayRecord> updatePayRecordList = Lists.newArrayList();
// 根据支付方式不同,走不同渠道退款 // 根据支付方式不同,走不同渠道退款
@@ -684,18 +684,18 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
.subType(MemberWalletEnum.SUBTYPE_ORDER_SETTLEMENT_REFUND.getValue()) // 订单结算退款 .subType(MemberWalletEnum.SUBTYPE_ORDER_SETTLEMENT_REFUND.getValue()) // 订单结算退款
.updatePrincipalBalance(returnPrincipal) .updatePrincipalBalance(returnPrincipal)
.updateGiftBalance(returnGift) .updateGiftBalance(returnGift)
.relatedOrderCode(orderBasicInfo.getOrderCode()) .relatedOrderCode(orderCode)
.build(); .build();
memberBasicInfoService.updateMemberBalance(updateMemberBalanceDTO); memberBasicInfoService.updateMemberBalance(updateMemberBalanceDTO);
} else if (StringUtils.equals(payMode, OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) { // 微信支付 } else if (StringUtils.equals(payMode, OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) { // 微信支付
// 微信退款逻辑 // 微信退款逻辑
WeChatRefundDTO weChatRefundDTO = new WeChatRefundDTO(); WeChatRefundDTO weChatRefundDTO = new WeChatRefundDTO();
weChatRefundDTO.setOrderCode(orderBasicInfo.getOrderCode()); weChatRefundDTO.setOrderCode(orderCode);
weChatRefundDTO.setRefundType("1"); weChatRefundDTO.setRefundType("1");
weChatRefundDTO.setRefundAmount(residue); weChatRefundDTO.setRefundAmount(residue);
// 查到该笔订单付款金额到哪里了 // 查到该笔订单付款金额到哪里了
MemberTransactionRecord transactionRecord = memberTransactionRecordService.selectByOrderCode(orderBasicInfo.getOrderCode(), ActionTypeEnum.FORWARD.getValue()); MemberTransactionRecord transactionRecord = memberTransactionRecordService.selectByOrderCode(orderCode, ActionTypeEnum.FORWARD.getValue());
logger.info("查到该笔订单付款金额到哪里了:{}", JSON.toJSONString(transactionRecord)); logger.info("查到该笔订单付款金额到哪里了:{}", JSON.toJSONString(transactionRecord));
if (StringUtils.equals(transactionRecord.getPaymentInstitutions(), PaymentInstitutionsEnum.WECHAT_PAY.getValue())) { if (StringUtils.equals(transactionRecord.getPaymentInstitutions(), PaymentInstitutionsEnum.WECHAT_PAY.getValue())) {
this.weChatRefund(weChatRefundDTO); this.weChatRefund(weChatRefundDTO);
@@ -710,7 +710,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
// 支付宝退款逻辑 // 支付宝退款逻辑
} else { } else {
// 白名单支付 // 白名单支付
logger.info("订单:{}使用白名单支付,不进行退款处理", orderBasicInfo.getOrderCode()); logger.info("订单:{}使用白名单支付,不进行退款处理", orderCode);
} }
// 更新order_pay_record // 更新order_pay_record
@@ -723,7 +723,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
// 修改订单数据 // 修改订单数据
// 查询订单详情 // 查询订单详情
OrderDetail orderDetail = getOrderDetailByOrderCode(orderBasicInfo.getOrderCode()); OrderDetail orderDetail = getOrderDetailByOrderCode(orderCode);
// 把交易记录中的用电量,金额等信息 更新到orderBasicInfo和orderDetail // 把交易记录中的用电量,金额等信息 更新到orderBasicInfo和orderDetail
orderBasicInfo.setOrderAmount(orderAmount); // 订单总金额 orderBasicInfo.setOrderAmount(orderAmount); // 订单总金额
@@ -815,7 +815,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
dto.setOrderBasicInfo(orderBasicInfo); dto.setOrderBasicInfo(orderBasicInfo);
dto.setOrderDetail(orderDetail); dto.setOrderDetail(orderDetail);
transactionService.doUpdateOrder(dto); transactionService.doUpdateOrder(dto);
logger.info("结算订单 end OrderTransactionDTO:{}", JSONObject.toJSONString(dto)); logger.info("结算订单end:{} OrderTransactionDTO:{}", orderCode, JSONObject.toJSONString(dto));
try { try {
// 将卡/vin状态解锁 // 将卡/vin状态解锁
@@ -845,7 +845,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
sendMsg(orderBasicInfo); sendMsg(orderBasicInfo);
// 从redis中取出实时记录保存到表中 // 从redis中取出实时记录保存到表中
realTimeMonitorDataRedis2DB(orderBasicInfo.getTransactionCode(), orderBasicInfo.getOrderCode()); realTimeMonitorDataRedis2DB(orderBasicInfo.getTransactionCode(), orderCode);
} }
// uniApp 发送停止充电订阅消息 // uniApp 发送停止充电订阅消息

View File

@@ -670,6 +670,11 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
return list; return list;
} }
/**
* 通过站点id查询充电桩列表
* @param stationId 站点id
* @return 充电桩列表
*/
@Override @Override
public List<PileBasicInfo> getPileListByStationId(String stationId) { public List<PileBasicInfo> getPileListByStationId(String stationId) {
String redisKey = CacheConstants.GET_PILE_LIST_BY_STATION_ID + stationId; String redisKey = CacheConstants.GET_PILE_LIST_BY_STATION_ID + stationId;

View File

@@ -46,6 +46,7 @@
<if test="tradeAmount != null "> and trade_amount = #{tradeAmount}</if> <if test="tradeAmount != null "> and trade_amount = #{tradeAmount}</if>
<if test="tradeFee != null "> and trade_fee = #{tradeFee}</if> <if test="tradeFee != null "> and trade_fee = #{tradeFee}</if>
</where> </where>
order by trade_date DESC
</select> </select>
<select id="selectSettleOrderReportById" parameterType="Long" resultMap="SettleOrderReportResult"> <select id="selectSettleOrderReportById" parameterType="Long" resultMap="SettleOrderReportResult">