| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.account.api.dto.CompanyAllocateRecordQueryDTO; |
| | | import com.ruoyi.account.api.model.TCompanyAllocateRecord; |
| | | import com.ruoyi.account.api.vo.CompanyAllocateSummaryVO; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | |
| | | */ |
| | | boolean recordAllocate(int userType, String userInfo, String userName, Integer companyId, int changeSource, |
| | | BigDecimal beforeBalance, BigDecimal amount, String remark); |
| | | |
| | | /** |
| | | * 写入一条消费流水(change_type=2,VIN码充电结算调用)。 |
| | | * 以「充电订单号+变更类型」幂等:已存在同订单消费流水时直接返回 true,不重复写入。 |
| | | * |
| | | * @param companyId 所属公司ID |
| | | * @param userType 分配对象类型:1=VIN码,2=刷卡,3=白名单手机号 |
| | | * @param userInfo 分配对象信息(VIN码/卡号/手机号) |
| | | * @param userName 分配对象名称(可为空) |
| | | * @param beforeBalance 消费前用户账户余额 |
| | | * @param amount 本次变动金额(消费传负数) |
| | | * @param chargingOrderCode 充电订单号(幂等键之一) |
| | | * @param remark 备注 |
| | | * @return 是否写入成功(已存在视为成功) |
| | | */ |
| | | boolean recordConsume(Integer companyId, Integer userType, String userInfo, String userName, |
| | | BigDecimal beforeBalance, BigDecimal amount, String chargingOrderCode, String remark); |
| | | |
| | | /** |
| | | * 写入一条消费流水(结算场景,允许金额为 0)。 |
| | | * <p>与 {@link #recordConsume} 语义一致,仅放开「金额为0不写流水」限制: |
| | | * 0 消费订单同样需要落一条流水,作为「该订单已结算」的幂等标记, |
| | | * 保证结算失败回退后的补偿重试不会重复结算(同事务写入)。</p> |
| | | * |
| | | * @return 是否写入成功(已存在视为成功) |
| | | */ |
| | | boolean recordSettleConsume(Integer companyId, Integer userType, String userInfo, String userName, |
| | | BigDecimal beforeBalance, BigDecimal amount, String chargingOrderCode, String remark); |
| | | |
| | | /** |
| | | * 判断指定充电订单是否已在账户侧落消费流水(结算幂等判定使用) |
| | | */ |
| | | boolean existsConsumeRecord(String chargingOrderCode); |
| | | |
| | | /** |
| | | * 批量查询已落消费流水的订单号集合(订单侧兜底扫描判定使用) |
| | | * |
| | | * @param orderCodes 待判定的充电订单号 |
| | | * @return 已存在消费流水的订单号集合,无匹配返回空集合 |
| | | */ |
| | | java.util.List<String> listConsumedOrderCodes(java.util.List<String> orderCodes); |
| | | |
| | | /** |
| | | * 统计公司名下三类主体(VIN码/刷卡/白名单手机号)可用余额与充电锁定金额合计(只读, |
| | | * 账户模式从分配切换为共享前的校验与预加回使用)。 |
| | | * |
| | | * @param companyId 所属公司ID |
| | | */ |
| | | CompanyAllocateSummaryVO sumAllocatedBalance(Integer companyId); |
| | | |
| | | /** |
| | | * 回收公司名下三类主体全部分配余额至公司账户(账户模式:分配→共享)。 |
| | | * <p>内部按固定顺序抢占 VIN/卡/白名单三把公司级并发锁,与额度分配操作串行; |
| | | * 余额清零与流水写入同事务,幂等(重复调用时无余额可回收,返回 0,不重复写流水)。</p> |
| | | * |
| | | * @param companyId 所属公司ID |
| | | * @param operatorName 操作人账号 |
| | | * @param companyName 公司名称(企业账户流水 userInfo,可为空) |
| | | * @param companyBalanceBefore 回退前公司可用余额(企业账户正数流水 beforeBalance) |
| | | * @return 本次实际回收总额(元,无余额时返回 0) |
| | | */ |
| | | BigDecimal recycleAllocatedBalance(Integer companyId, String operatorName, String companyName, |
| | | BigDecimal companyBalanceBefore); |
| | | } |