puzhibing
2026-09-28 ac5dac6c7c45e4c2ecf3cc7ccebac78d65ca9141
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.ruoyi.account.service;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.account.api.dto.ChargingCardAllocateDTO;
import com.ruoyi.account.api.dto.ChargingCardAuthDTO;
import com.ruoyi.account.api.dto.ChargingCardDeductDTO;
import com.ruoyi.account.api.dto.ChargingCardExcelDTO;
import com.ruoyi.account.api.dto.ChargingCardQueryDTO;
import com.ruoyi.account.api.dto.ChargingCardSaveDTO;
import com.ruoyi.account.api.dto.ChargingCardStatusDTO;
import com.ruoyi.account.api.model.TChargingCard;
import com.ruoyi.account.api.vo.ChargingCardAllocateVO;
import com.ruoyi.account.api.vo.ChargingCardDeductVO;
 
import java.util.List;
 
public interface TChargingCardService extends IService<TChargingCard> {
 
    IPage<TChargingCard> selectCardPage(ChargingCardQueryDTO query);
 
    boolean saveCard(ChargingCardSaveDTO dto);
 
    boolean updateCard(ChargingCardSaveDTO dto);
 
    boolean deleteCards(List<Long> ids);
 
    boolean updateStatus(ChargingCardStatusDTO dto);
 
    /**
     * 额度分配概览:公司可分配余额(available_balance)与总账户余额(累计充值到账)。
     * 仅分配模式(account_mode=2)的公司可执行额度分配。
     *
     * @param companyId 公司ID
     * @return 概览信息;公司不存在时抛出业务异常
     */
    ChargingCardAllocateVO getAllocateOverview(Integer companyId);
 
    /**
     * 卡片额度分配(公司可用余额 → 卡片余额)。
     * 校验公司为启用且分配模式、卡片归属该公司且未在充电,禁止透支;
     * 每张卡片写入余额变更流水,失败时回滚并退还公司已扣金额。
     *
     * @param dto 分配参数(公司、卡片明细、备注)
     * @return 分配后的公司概览(可分配余额为最新值)
     */
    ChargingCardAllocateVO allocateQuota(ChargingCardAllocateDTO dto);
 
    List<ChargingCardExcelDTO> selectExportList(ChargingCardQueryDTO query);
 
    String importCards(List<ChargingCardExcelDTO> cards);
 
    /**
     * 刷卡启动鉴权(内部接口)。
     * 条件密码校验(V0.2 定稿):卡片配置了密码时校验设备上报密码;未配置密码时不校验。
     *
     * @param dto 卡号与设备上报密码
     * @return 鉴权通过返回卡片实体(不包含密码密文);失败抛出 ServiceException 携带原因
     */
    TChargingCard verifyCardForCharging(ChargingCardAuthDTO dto);
 
    /**
     * 锁定卡片为充电中(刷卡订单创建成功后调用)。同卡已有进行中订单时返回 false。
     */
    boolean lockCardForCharging(Long cardId, String orderCode);
 
    /**
     * 解锁卡片(订单终态后调用)。带订单号比对,幂等:已解锁或订单号不匹配时返回 false。
     */
    boolean unlockCardForCharging(Long cardId, String orderCode);
 
    /**
     * 刷卡订单最终结算扣款(内部接口)。
     * 幂等(订单号为幂等键)+ 允许扣成负余额(V0.2 定稿)。
     *
     * @return 扣款结果;duplicated=true 表示该订单此前已扣款,本次未重复扣款
     */
    ChargingCardDeductVO deductBalanceForCharging(ChargingCardDeductDTO dto);
 
    /**
     * 批量查询已经成功写入充电扣款流水的订单号。
     */
    List<String> listDeductedOrderCodes(List<String> orderCodes);
}