Commit 98eb7e83c6c28080d658633cba6c2cc2bea435ca
Merge branch 'feature-PrivatePocket' into 'dev'
feat: 检查隐私余额 See merge request !39
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 |
@@ -1759,7 +1795,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | @@ -1759,7 +1795,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | ||
1759 | hidden={paymentMethod !== 'WITHHOLDING_ADVANCE_DEPOSIT'} | 1795 | hidden={paymentMethod !== 'WITHHOLDING_ADVANCE_DEPOSIT'} |
1760 | showSearch | 1796 | showSearch |
1761 | label="预存账号" | 1797 | label="预存账号" |
1762 | - onChange={(value: any, option: any) => { | 1798 | + onChange={async (value: any, option: any) => { |
1763 | console.log(value, '5656value'); | 1799 | console.log(value, '5656value'); |
1764 | console.log(option, '5656option'); | 1800 | console.log(option, '5656option'); |
1765 | 1801 | ||
@@ -1773,18 +1809,31 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | @@ -1773,18 +1809,31 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | ||
1773 | const selectedData = option || {}; | 1809 | const selectedData = option || {}; |
1774 | const realUid = selectedData.uid; | 1810 | const realUid = selectedData.uid; |
1775 | const institution = selectedData.institution; | 1811 | const institution = selectedData.institution; |
1812 | + const phone = selectedData.phone; | ||
1776 | 1813 | ||
1777 | console.log('选中账户信息:', { | 1814 | console.log('选中账户信息:', { |
1778 | value: value, | 1815 | value: value, |
1779 | realUid: realUid, | 1816 | realUid: realUid, |
1780 | institution: institution, | 1817 | institution: institution, |
1818 | + phone: phone, | ||
1781 | }); | 1819 | }); |
1782 | 1820 | ||
1783 | - //检查用户额度 | ||
1784 | - let valid = checkAccountMoney( | ||
1785 | - realUid, // 使用真实UID检查额度 | ||
1786 | - form.getFieldValue('totalPayment'), | ||
1787 | - ); | 1821 | + // 检查是否是隐私钱包 |
1822 | + const isPrivacyWallet = institution === '隐私钱包'; | ||
1823 | + const totalPayment = form.getFieldValue('totalPayment'); | ||
1824 | + let valid; | ||
1825 | + | ||
1826 | + if (isPrivacyWallet) { | ||
1827 | + // 使用隐私钱包检查方式 | ||
1828 | + valid = await checkPrivateWalletMoney( | ||
1829 | + realUid, | ||
1830 | + phone, | ||
1831 | + totalPayment, | ||
1832 | + ); | ||
1833 | + } else { | ||
1834 | + // 使用普通账户检查方式 | ||
1835 | + valid = await checkAccountMoney(realUid, totalPayment); | ||
1836 | + } | ||
1788 | 1837 | ||
1789 | if (!valid) { | 1838 | if (!valid) { |
1790 | form.setFieldValue('prepaidUid', undefined); | 1839 | form.setFieldValue('prepaidUid', undefined); |
@@ -1792,9 +1841,6 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | @@ -1792,9 +1841,6 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | ||
1792 | return; | 1841 | return; |
1793 | } | 1842 | } |
1794 | 1843 | ||
1795 | - // 如果机构是"隐私钱包",则设置privatePocket为true | ||
1796 | - const isPrivacyWallet = institution === '隐私钱包'; | ||
1797 | - | ||
1798 | // 设置真实UID和privatePocket标志 | 1844 | // 设置真实UID和privatePocket标志 |
1799 | form.setFieldValue('realPrepaidUid', realUid); | 1845 | form.setFieldValue('realPrepaidUid', realUid); |
1800 | // 存储为字符串'true'或'false',这样在表单中能正确保存 | 1846 | // 存储为字符串'true'或'false',这样在表单中能正确保存 |
@@ -1807,6 +1853,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | @@ -1807,6 +1853,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => { | ||
1807 | prepaidUid: value, | 1853 | prepaidUid: value, |
1808 | realPrepaidUid: realUid, | 1854 | realPrepaidUid: realUid, |
1809 | privatePocket: isPrivacyWallet, | 1855 | privatePocket: isPrivacyWallet, |
1856 | + accountType: isPrivacyWallet ? '隐私钱包' : '普通账户', | ||
1810 | }); | 1857 | }); |
1811 | }} | 1858 | }} |
1812 | placeholder="请选择预存账号" | 1859 | placeholder="请选择预存账号" |
src/services/definition.ts
@@ -4849,6 +4849,24 @@ export interface UserNowMoneyCheckRequest { | @@ -4849,6 +4849,24 @@ export interface UserNowMoneyCheckRequest { | ||
4849 | uid?: number; | 4849 | uid?: number; |
4850 | } | 4850 | } |
4851 | 4851 | ||
4852 | +export interface UserPrivateMoneyCheckRequest { | ||
4853 | + /** | ||
4854 | + * @description | ||
4855 | + * 手机号码 | ||
4856 | + */ | ||
4857 | + phone?: string; | ||
4858 | + /** | ||
4859 | + * @description | ||
4860 | + * 金额 | ||
4861 | + */ | ||
4862 | + subPrice?: number; | ||
4863 | + /** | ||
4864 | + * @description | ||
4865 | + * 用户ID | ||
4866 | + */ | ||
4867 | + uid?: string; | ||
4868 | +} | ||
4869 | + | ||
4852 | export interface UserPrivatePocketBalanceUpdateRequest { | 4870 | export interface UserPrivatePocketBalanceUpdateRequest { |
4853 | /** | 4871 | /** |
4854 | * @description | 4872 | * @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
@@ -168,6 +168,7 @@ import type { | @@ -168,6 +168,7 @@ import type { | ||
168 | UserDetailRequest, | 168 | UserDetailRequest, |
169 | UserListRequest, | 169 | UserListRequest, |
170 | UserNowMoneyCheckRequest, | 170 | UserNowMoneyCheckRequest, |
171 | + UserPrivateMoneyCheckRequest, | ||
171 | UserPrivatePocketBalanceUpdateRequest, | 172 | UserPrivatePocketBalanceUpdateRequest, |
172 | UserPrivatePocketDeleteRequest, | 173 | UserPrivatePocketDeleteRequest, |
173 | UserPrivatePocketDetailRequest, | 174 | UserPrivatePocketDetailRequest, |
@@ -3360,6 +3361,77 @@ export const postCanrdPrivatePocketList = /* #__PURE__ */ (() => { | @@ -3360,6 +3361,77 @@ export const postCanrdPrivatePocketList = /* #__PURE__ */ (() => { | ||
3360 | return request; | 3361 | return request; |
3361 | })(); | 3362 | })(); |
3362 | 3363 | ||
3364 | +/** @description request parameter type for postCanrdPrivatePocketPrivateMoneyCheck */ | ||
3365 | +export interface PostCanrdPrivatePocketPrivateMoneyCheckOption { | ||
3366 | + /** | ||
3367 | + * @description | ||
3368 | + * request | ||
3369 | + */ | ||
3370 | + body: { | ||
3371 | + /** | ||
3372 | + @description | ||
3373 | + request */ | ||
3374 | + request: UserPrivateMoneyCheckRequest; | ||
3375 | + }; | ||
3376 | +} | ||
3377 | + | ||
3378 | +/** @description response type for postCanrdPrivatePocketPrivateMoneyCheck */ | ||
3379 | +export interface PostCanrdPrivatePocketPrivateMoneyCheckResponse { | ||
3380 | + /** | ||
3381 | + * @description | ||
3382 | + * OK | ||
3383 | + */ | ||
3384 | + 200: ServerResult; | ||
3385 | + /** | ||
3386 | + * @description | ||
3387 | + * Created | ||
3388 | + */ | ||
3389 | + 201: any; | ||
3390 | + /** | ||
3391 | + * @description | ||
3392 | + * Unauthorized | ||
3393 | + */ | ||
3394 | + 401: any; | ||
3395 | + /** | ||
3396 | + * @description | ||
3397 | + * Forbidden | ||
3398 | + */ | ||
3399 | + 403: any; | ||
3400 | + /** | ||
3401 | + * @description | ||
3402 | + * Not Found | ||
3403 | + */ | ||
3404 | + 404: any; | ||
3405 | +} | ||
3406 | + | ||
3407 | +export type PostCanrdPrivatePocketPrivateMoneyCheckResponseSuccess = | ||
3408 | + PostCanrdPrivatePocketPrivateMoneyCheckResponse[200]; | ||
3409 | +/** | ||
3410 | + * @description | ||
3411 | + * 检查用户隐私钱包余额是否足够 | ||
3412 | + * @tags user-private-pocket-controller | ||
3413 | + * @produces * | ||
3414 | + * @consumes application/json | ||
3415 | + */ | ||
3416 | +export const postCanrdPrivatePocketPrivateMoneyCheck = /* #__PURE__ */ (() => { | ||
3417 | + const method = 'post'; | ||
3418 | + const url = '/canrd/privatePocket/privateMoney/check'; | ||
3419 | + function request( | ||
3420 | + option: PostCanrdPrivatePocketPrivateMoneyCheckOption, | ||
3421 | + ): Promise<PostCanrdPrivatePocketPrivateMoneyCheckResponseSuccess> { | ||
3422 | + return requester(request.url, { | ||
3423 | + method: request.method, | ||
3424 | + ...option, | ||
3425 | + }) as unknown as Promise<PostCanrdPrivatePocketPrivateMoneyCheckResponseSuccess>; | ||
3426 | + } | ||
3427 | + | ||
3428 | + /** http method */ | ||
3429 | + request.method = method; | ||
3430 | + /** request url */ | ||
3431 | + request.url = url; | ||
3432 | + return request; | ||
3433 | +})(); | ||
3434 | + | ||
3363 | /** @description request parameter type for postCanrdPrivatePocketSave */ | 3435 | /** @description request parameter type for postCanrdPrivatePocketSave */ |
3364 | export interface PostCanrdPrivatePocketSaveOption { | 3436 | export interface PostCanrdPrivatePocketSaveOption { |
3365 | /** | 3437 | /** |