Commit 1c2146133993674725d6fb5ab6b37fbfa9c23603
1 parent
cbb31ced
feat: 检查隐私余额
Showing
3 changed files
with
147 additions
and
10 deletions
src/pages/Order/OrderList/OrderDrawer.tsx
@@ -3,6 +3,7 @@ import { | @@ -3,6 +3,7 @@ import { | ||
3 | postCanrdApiUserAddressList, | 3 | postCanrdApiUserAddressList, |
4 | postCanrdApiUserDetail, | 4 | postCanrdApiUserDetail, |
5 | postCanrdApiUserNowMoneyCheck, | 5 | postCanrdApiUserNowMoneyCheck, |
6 | + postCanrdPrivatePocketPrivateMoneyCheck, | ||
6 | postDistrictSelectByLevel, | 7 | postDistrictSelectByLevel, |
7 | postDistrictSelectByNameAndLevel, | 8 | postDistrictSelectByNameAndLevel, |
8 | postDistrictSelOrderProvince, | 9 | postDistrictSelOrderProvince, |
@@ -648,6 +649,41 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | @@ -648,6 +649,41 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | ||
648 | }; | 649 | }; |
649 | 650 | ||
650 | /** | 651 | /** |
652 | + * 检查隐私钱包余额 | ||
653 | + * @param uid 用户ID | ||
654 | + * @param phone 手机号 | ||
655 | + * @param subPrice 金额 | ||
656 | + */ | ||
657 | + const checkPrivateWalletMoney = async ( | ||
658 | + uid: any, | ||
659 | + phone: any, | ||
660 | + subPrice: any, | ||
661 | + ) => { | ||
662 | + let res = await postCanrdPrivatePocketPrivateMoneyCheck({ | ||
663 | + data: { uid: uid, phone: phone, subPrice: subPrice }, | ||
664 | + }); | ||
665 | + if (res && res.result === RESPONSE_CODE.SUCCESS && res.data) { | ||
666 | + let data = res.data; | ||
667 | + let isEnough = data.isEnough; | ||
668 | + if (isEnough) { | ||
669 | + return true; | ||
670 | + } | ||
671 | + | ||
672 | + message.error( | ||
673 | + '隐私钱包余额不足,当前预减的金额为:' + | ||
674 | + data.subPrice + | ||
675 | + ',当前隐私钱包余额为:' + | ||
676 | + data.privateMoney, | ||
677 | + ); | ||
678 | + return false; | ||
679 | + } | ||
680 | + | ||
681 | + return false; | ||
682 | + }; | ||
683 | + | ||
684 | + // 已在prepaidUid字段的onChange处理器中直接实现账户选择逻辑 | ||
685 | + | ||
686 | + /** | ||
651 | * 总金额改变触发事件 | 687 | * 总金额改变触发事件 |
652 | * 如果是预存单,需要检查余额 | 688 | * 如果是预存单,需要检查余额 |
653 | * @param value | 689 | * @param value |
@@ -1751,7 +1787,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | @@ -1751,7 +1787,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | ||
1751 | hidden={paymentMethod !== 'WITHHOLDING_ADVANCE_DEPOSIT'} | 1787 | hidden={paymentMethod !== 'WITHHOLDING_ADVANCE_DEPOSIT'} |
1752 | showSearch | 1788 | showSearch |
1753 | label="预存账号" | 1789 | label="预存账号" |
1754 | - onChange={(value: any, option: any) => { | 1790 | + onChange={async (value: any, option: any) => { |
1755 | console.log(value, '5656value'); | 1791 | console.log(value, '5656value'); |
1756 | console.log(option, '5656option'); | 1792 | console.log(option, '5656option'); |
1757 | 1793 | ||
@@ -1765,18 +1801,31 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | @@ -1765,18 +1801,31 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | ||
1765 | const selectedData = option || {}; | 1801 | const selectedData = option || {}; |
1766 | const realUid = selectedData.uid; | 1802 | const realUid = selectedData.uid; |
1767 | const institution = selectedData.institution; | 1803 | const institution = selectedData.institution; |
1804 | + const phone = selectedData.phone; | ||
1768 | 1805 | ||
1769 | console.log('选中账户信息:', { | 1806 | console.log('选中账户信息:', { |
1770 | value: value, | 1807 | value: value, |
1771 | realUid: realUid, | 1808 | realUid: realUid, |
1772 | institution: institution, | 1809 | institution: institution, |
1810 | + phone: phone, | ||
1773 | }); | 1811 | }); |
1774 | 1812 | ||
1775 | - //检查用户额度 | ||
1776 | - let valid = checkAccountMoney( | ||
1777 | - realUid, // 使用真实UID检查额度 | ||
1778 | - form.getFieldValue('totalPayment'), | ||
1779 | - ); | 1813 | + // 检查是否是隐私钱包 |
1814 | + const isPrivacyWallet = institution === '隐私钱包'; | ||
1815 | + const totalPayment = form.getFieldValue('totalPayment'); | ||
1816 | + let valid; | ||
1817 | + | ||
1818 | + if (isPrivacyWallet) { | ||
1819 | + // 使用隐私钱包检查方式 | ||
1820 | + valid = await checkPrivateWalletMoney( | ||
1821 | + realUid, | ||
1822 | + phone, | ||
1823 | + totalPayment, | ||
1824 | + ); | ||
1825 | + } else { | ||
1826 | + // 使用普通账户检查方式 | ||
1827 | + valid = await checkAccountMoney(realUid, totalPayment); | ||
1828 | + } | ||
1780 | 1829 | ||
1781 | if (!valid) { | 1830 | if (!valid) { |
1782 | form.setFieldValue('prepaidUid', undefined); | 1831 | form.setFieldValue('prepaidUid', undefined); |
@@ -1784,9 +1833,6 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | @@ -1784,9 +1833,6 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | ||
1784 | return; | 1833 | return; |
1785 | } | 1834 | } |
1786 | 1835 | ||
1787 | - // 如果机构是"隐私钱包",则设置privatePocket为true | ||
1788 | - const isPrivacyWallet = institution === '隐私钱包'; | ||
1789 | - | ||
1790 | // 设置真实UID和privatePocket标志 | 1836 | // 设置真实UID和privatePocket标志 |
1791 | form.setFieldValue('realPrepaidUid', realUid); | 1837 | form.setFieldValue('realPrepaidUid', realUid); |
1792 | // 存储为字符串'true'或'false',这样在表单中能正确保存 | 1838 | // 存储为字符串'true'或'false',这样在表单中能正确保存 |
@@ -1799,6 +1845,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | @@ -1799,6 +1845,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | ||
1799 | prepaidUid: value, | 1845 | prepaidUid: value, |
1800 | realPrepaidUid: realUid, | 1846 | realPrepaidUid: realUid, |
1801 | privatePocket: isPrivacyWallet, | 1847 | privatePocket: isPrivacyWallet, |
1848 | + accountType: isPrivacyWallet ? '隐私钱包' : '普通账户', | ||
1802 | }); | 1849 | }); |
1803 | }} | 1850 | }} |
1804 | placeholder="请选择预存账号" | 1851 | placeholder="请选择预存账号" |
src/services/definition.ts
@@ -4823,6 +4823,24 @@ export interface UserNowMoneyCheckRequest { | @@ -4823,6 +4823,24 @@ export interface UserNowMoneyCheckRequest { | ||
4823 | uid?: number; | 4823 | uid?: number; |
4824 | } | 4824 | } |
4825 | 4825 | ||
4826 | +export interface UserPrivateMoneyCheckRequest { | ||
4827 | + /** | ||
4828 | + * @description | ||
4829 | + * 手机号码 | ||
4830 | + */ | ||
4831 | + phone?: string; | ||
4832 | + /** | ||
4833 | + * @description | ||
4834 | + * 金额 | ||
4835 | + */ | ||
4836 | + subPrice?: number; | ||
4837 | + /** | ||
4838 | + * @description | ||
4839 | + * 用户ID | ||
4840 | + */ | ||
4841 | + uid?: string; | ||
4842 | +} | ||
4843 | + | ||
4826 | export interface UserPrivatePocketBalanceUpdateRequest { | 4844 | export interface UserPrivatePocketBalanceUpdateRequest { |
4827 | /** | 4845 | /** |
4828 | * @description | 4846 | * @description |
@@ -5605,7 +5623,7 @@ export interface SalesRechargePrepaymentAuditRequest { | @@ -5605,7 +5623,7 @@ export interface SalesRechargePrepaymentAuditRequest { | ||
5605 | * @description | 5623 | * @description |
5606 | * 销售代表编码 | 5624 | * 销售代表编码 |
5607 | */ | 5625 | */ |
5608 | - salescode?: string; | 5626 | + salesCode?: string; |
5609 | } | 5627 | } |
5610 | 5628 | ||
5611 | export interface SalesRechargePrepaymentCreateRequest { | 5629 | export interface SalesRechargePrepaymentCreateRequest { |
src/services/request.ts
@@ -167,6 +167,7 @@ import type { | @@ -167,6 +167,7 @@ import type { | ||
167 | UserDetailRequest, | 167 | UserDetailRequest, |
168 | UserListRequest, | 168 | UserListRequest, |
169 | UserNowMoneyCheckRequest, | 169 | UserNowMoneyCheckRequest, |
170 | + UserPrivateMoneyCheckRequest, | ||
170 | UserPrivatePocketBalanceUpdateRequest, | 171 | UserPrivatePocketBalanceUpdateRequest, |
171 | UserPrivatePocketDeleteRequest, | 172 | UserPrivatePocketDeleteRequest, |
172 | UserPrivatePocketDetailRequest, | 173 | UserPrivatePocketDetailRequest, |
@@ -3359,6 +3360,77 @@ export const postCanrdPrivatePocketList = /* #__PURE__ */ (() => { | @@ -3359,6 +3360,77 @@ export const postCanrdPrivatePocketList = /* #__PURE__ */ (() => { | ||
3359 | return request; | 3360 | return request; |
3360 | })(); | 3361 | })(); |
3361 | 3362 | ||
3363 | +/** @description request parameter type for postCanrdPrivatePocketPrivateMoneyCheck */ | ||
3364 | +export interface PostCanrdPrivatePocketPrivateMoneyCheckOption { | ||
3365 | + /** | ||
3366 | + * @description | ||
3367 | + * request | ||
3368 | + */ | ||
3369 | + body: { | ||
3370 | + /** | ||
3371 | + @description | ||
3372 | + request */ | ||
3373 | + request: UserPrivateMoneyCheckRequest; | ||
3374 | + }; | ||
3375 | +} | ||
3376 | + | ||
3377 | +/** @description response type for postCanrdPrivatePocketPrivateMoneyCheck */ | ||
3378 | +export interface PostCanrdPrivatePocketPrivateMoneyCheckResponse { | ||
3379 | + /** | ||
3380 | + * @description | ||
3381 | + * OK | ||
3382 | + */ | ||
3383 | + 200: ServerResult; | ||
3384 | + /** | ||
3385 | + * @description | ||
3386 | + * Created | ||
3387 | + */ | ||
3388 | + 201: any; | ||
3389 | + /** | ||
3390 | + * @description | ||
3391 | + * Unauthorized | ||
3392 | + */ | ||
3393 | + 401: any; | ||
3394 | + /** | ||
3395 | + * @description | ||
3396 | + * Forbidden | ||
3397 | + */ | ||
3398 | + 403: any; | ||
3399 | + /** | ||
3400 | + * @description | ||
3401 | + * Not Found | ||
3402 | + */ | ||
3403 | + 404: any; | ||
3404 | +} | ||
3405 | + | ||
3406 | +export type PostCanrdPrivatePocketPrivateMoneyCheckResponseSuccess = | ||
3407 | + PostCanrdPrivatePocketPrivateMoneyCheckResponse[200]; | ||
3408 | +/** | ||
3409 | + * @description | ||
3410 | + * 检查用户隐私钱包余额是否足够 | ||
3411 | + * @tags user-private-pocket-controller | ||
3412 | + * @produces * | ||
3413 | + * @consumes application/json | ||
3414 | + */ | ||
3415 | +export const postCanrdPrivatePocketPrivateMoneyCheck = /* #__PURE__ */ (() => { | ||
3416 | + const method = 'post'; | ||
3417 | + const url = '/canrd/privatePocket/privateMoney/check'; | ||
3418 | + function request( | ||
3419 | + option: PostCanrdPrivatePocketPrivateMoneyCheckOption, | ||
3420 | + ): Promise<PostCanrdPrivatePocketPrivateMoneyCheckResponseSuccess> { | ||
3421 | + return requester(request.url, { | ||
3422 | + method: request.method, | ||
3423 | + ...option, | ||
3424 | + }) as unknown as Promise<PostCanrdPrivatePocketPrivateMoneyCheckResponseSuccess>; | ||
3425 | + } | ||
3426 | + | ||
3427 | + /** http method */ | ||
3428 | + request.method = method; | ||
3429 | + /** request url */ | ||
3430 | + request.url = url; | ||
3431 | + return request; | ||
3432 | +})(); | ||
3433 | + | ||
3362 | /** @description request parameter type for postCanrdPrivatePocketSave */ | 3434 | /** @description request parameter type for postCanrdPrivatePocketSave */ |
3363 | export interface PostCanrdPrivatePocketSaveOption { | 3435 | export interface PostCanrdPrivatePocketSaveOption { |
3364 | /** | 3436 | /** |