quota.ts 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. import request from "@/utils/request";
  2. const API_PATH = "/payment/quota";
  3. const QuotaAPI = {
  4. // ========= 原有方法 =========
  5. listQuota(query?: QuotaPageQuery) {
  6. return request<ApiResponse<QuotaPageResp>>({
  7. url: `${API_PATH}`,
  8. method: "get",
  9. params: query,
  10. });
  11. },
  12. detailQuota(quotaId: string) {
  13. return request<ApiResponse<QuotaDetail>>({
  14. url: `${API_PATH}/${quotaId}`,
  15. method: "get",
  16. });
  17. },
  18. createQuota(body: QuotaForm) {
  19. return request<ApiResponse<QuotaOperation>>({
  20. url: `${API_PATH}`,
  21. method: "post",
  22. data: body,
  23. });
  24. },
  25. updateQuota(quotaId: string, body: QuotaForm) {
  26. return request<ApiResponse>({
  27. url: `${API_PATH}/${quotaId}`,
  28. method: "put",
  29. data: body,
  30. });
  31. },
  32. deleteQuota(quotaId: string) {
  33. return request<ApiResponse>({
  34. url: `${API_PATH}/${quotaId}`,
  35. method: "delete",
  36. });
  37. },
  38. listByEmployee(employeeId: string, query?: QuotaPageQuery) {
  39. return request<ApiResponse<QuotaPageResp>>({
  40. url: `${API_PATH}/employee/${employeeId}`,
  41. method: "get",
  42. params: query,
  43. });
  44. },
  45. // ========= 手工批量发放额度 =========
  46. /** 手工批量发放额度 */
  47. issueBatchCreate(body: IssueBatchCreateForm) {
  48. return request<ApiResponse<IssueBatchCreateResp>>({
  49. url: `${API_PATH}/issuebatch/create`,
  50. method: "post",
  51. data: body,
  52. });
  53. },
  54. /** 作废手工发放批次 */
  55. issueBatchCancel(body: IssueBatchCancelForm) {
  56. return request<ApiResponse<IssueBatchCancelResp>>({
  57. url: `${API_PATH}/issuebatch/cancel`,
  58. method: "post",
  59. data: body,
  60. });
  61. },
  62. /** 查询手工发放发放明细 */
  63. issueBatchRecords(body: IssueBatchRecordsQuery) {
  64. return request<ApiResponse<IssueBatchRecordsResp>>({
  65. url: `${API_PATH}/issuebatch/records`,
  66. method: "post",
  67. data: body,
  68. });
  69. },
  70. /** 查询手工发放批次列表 */
  71. issueBatchList(query?: IssueBatchListQuery) {
  72. return request<ApiResponse<IssueBatchListResp>>({
  73. url: `${API_PATH}/issuebatch/list`,
  74. method: "get",
  75. params: query,
  76. });
  77. },
  78. };
  79. export default QuotaAPI;
  80. // ========= 原有类型 =========
  81. export interface QuotaPageQuery {
  82. page_no?: number;
  83. page_size?: number;
  84. employee_id?: string;
  85. institution_id?: string;
  86. enterprise_id?: string;
  87. status?: string;
  88. }
  89. export interface QuotaPageResp {
  90. total: number;
  91. list: QuotaTable[];
  92. }
  93. export interface QuotaTable {
  94. id: number;
  95. quota_id?: string;
  96. employee_id?: string;
  97. institution_id?: string;
  98. target_type?: string;
  99. quota_type?: string;
  100. total_amount?: number;
  101. available_amount?: number;
  102. status: string;
  103. created_time: string;
  104. }
  105. export interface QuotaDetail {
  106. id: number;
  107. quota_id?: string;
  108. employee_id?: string;
  109. institution_id?: string;
  110. enterprise_id?: string;
  111. target_type?: string;
  112. target_id?: string;
  113. quota_type?: string;
  114. out_biz_no?: string;
  115. total_amount?: number;
  116. available_amount?: number;
  117. frozen_amount?: number;
  118. share_mode?: string;
  119. issue_name?: string;
  120. valid_from?: string;
  121. valid_to?: string;
  122. status: string;
  123. created_time: string;
  124. updated_time: string;
  125. }
  126. export interface QuotaForm {
  127. employee_id: string;
  128. institution_id: string;
  129. total_amount: number;
  130. available_amount?: number;
  131. valid_from?: string;
  132. valid_to?: string;
  133. }
  134. export interface QuotaOperation {
  135. out_biz_no?: string;
  136. quota_id?: string;
  137. result?: boolean;
  138. }
  139. // ========= 手工批量发放类型 =========
  140. export interface IssueTargetInfo {
  141. issue_quota: string;
  142. owner_open_id?: string;
  143. owner_id?: string;
  144. user_name?: string;
  145. owner_type?: string;
  146. }
  147. export interface IssueBatchCreateForm {
  148. enterprise_id: string;
  149. issue_name: string;
  150. quota_type: string;
  151. effective_start_date: string;
  152. effective_end_date: string;
  153. institution_id: string;
  154. batch_no: string;
  155. share_mode: string;
  156. issue_desc?: string;
  157. issue_target_info_list?: IssueTargetInfo[];
  158. }
  159. export interface IssueQuotaCheckFailedItem {
  160. user_name?: string;
  161. owner_type?: string;
  162. owner_id?: string;
  163. owner_open_id?: string;
  164. issue_quota?: string;
  165. message?: string;
  166. result?: boolean;
  167. }
  168. export interface IssueBatchCreateResp {
  169. issue_batch_id?: string;
  170. issue_quota_check_failed_list?: IssueQuotaCheckFailedItem[];
  171. }
  172. export interface IssueBatchCancelForm {
  173. enterprise_id: string;
  174. institution_id: string;
  175. issue_batch_id: string;
  176. }
  177. export interface IssueBatchCancelResp {
  178. result: boolean;
  179. }
  180. export interface IssueBatchRecordsQuery {
  181. enterprise_id: string;
  182. institution_id: string;
  183. issue_batch_id: string;
  184. page_size: number;
  185. page_num: number;
  186. }
  187. export interface IssueRecordInfoItem {
  188. quota_id?: string;
  189. issue_quota?: string;
  190. issue_status?: number;
  191. owner_type?: string;
  192. owner_id?: string;
  193. owner_open_id?: string;
  194. user_name?: string;
  195. currency?: string;
  196. }
  197. export interface IssueBatchRecordsResp {
  198. page_num: number;
  199. page_size: number;
  200. total_page_count: number;
  201. issue_record_info_list?: IssueRecordInfoItem[];
  202. }
  203. // ========= 常量 =========
  204. export const TARGET_TYPE_OPTIONS = [
  205. { label: "制度维度", value: "INSTITUTION" },
  206. { label: "费用类型维度", value: "EXPENSE_TYPE" },
  207. ];
  208. export const QUOTA_TYPE_OPTIONS = [
  209. { label: "余额", value: "CAP" },
  210. { label: "点券", value: "COUPON" },
  211. { label: "次卡", value: "COUNT" },
  212. ];
  213. export const QUOTA_STATUS_OPTIONS = [
  214. { label: "正常", value: "QUOTA_ACTIVE" },
  215. { label: "冻结", value: "QUOTA_FROZEN" },
  216. { label: "已用完", value: "QUOTA_EXHAUSTED" },
  217. { label: "已过期", value: "QUOTA_EXPIRED" },
  218. ];
  219. export const SHARE_MODE_OPTIONS = [
  220. { label: "不可转增", value: "0" },
  221. { label: "可转增", value: "1" },
  222. ];
  223. export const STATUS_TAG_TYPE: Record<string, string> = {
  224. QUOTA_ACTIVE: "success",
  225. QUOTA_FROZEN: "warning",
  226. QUOTA_EXHAUSTED: "info",
  227. QUOTA_EXPIRED: "danger",
  228. QUOTA_PENDING: "info",
  229. };
  230. export const STATUS_LABEL: Record<string, string> = {
  231. QUOTA_ACTIVE: "正常",
  232. QUOTA_FROZEN: "冻结",
  233. QUOTA_EXHAUSTED: "已用完",
  234. QUOTA_EXPIRED: "已过期",
  235. QUOTA_PENDING: "待发放",
  236. };
  237. export interface IssueBatchListQuery {
  238. page_no?: number;
  239. page_size?: number;
  240. institution_id?: string;
  241. }
  242. export interface IssueBatchItem {
  243. id: number;
  244. issue_batch_id?: string;
  245. batch_no: string;
  246. institution_id: string;
  247. issue_name: string;
  248. quota_type: string;
  249. share_mode: string;
  250. total_count: number;
  251. total_amount?: number;
  252. status: string;
  253. created_time: string;
  254. updated_time?: string;
  255. }
  256. export interface IssueBatchListResp {
  257. items: IssueBatchItem[];
  258. total: number;
  259. page_no: number;
  260. page_size: number;
  261. }
  262. export const ISSUE_BATCH_STATUS_TAG: Record<string, string> = {
  263. ACTIVE: "success",
  264. CANCELLED: "danger",
  265. };
  266. export const ISSUE_BATCH_STATUS_LABEL: Record<string, string> = {
  267. ACTIVE: "有效",
  268. CANCELLED: "已作废",
  269. };