diff --git a/src/api/shop/shopDealerOrder/model/index.ts b/src/api/shop/shopDealerOrder/model/index.ts index 6cbac61..6380ea6 100644 --- a/src/api/shop/shopDealerOrder/model/index.ts +++ b/src/api/shop/shopDealerOrder/model/index.ts @@ -28,6 +28,8 @@ export interface ShopDealerOrder { isInvalid?: number; // 佣金结算(0未结算 1已结算) isSettled?: number; + // 分销佣金比例 + rate?: number; // 结算时间 settleTime?: number; // 订单备注 diff --git a/src/dealer/customer/add.tsx b/src/dealer/customer/add.tsx index d91c3b0..1de41d0 100644 --- a/src/dealer/customer/add.tsx +++ b/src/dealer/customer/add.tsx @@ -15,6 +15,8 @@ import { formatDateForDatabase, extractDateForCalendar, formatDateForDisplay } from "@/utils/dateUtils"; +import {ShopDealerUser} from "@/api/shop/shopDealerUser/model"; +import {getShopDealerUser, pageShopDealerUser} from "@/api/shop/shopDealerUser"; const AddShopDealerApply = () => { const {user} = useUser() @@ -24,6 +26,7 @@ const AddShopDealerApply = () => { const formRef = useRef(null) const [isEditMode, setIsEditMode] = useState(false) const [existingApply, setExistingApply] = useState(null) + const [referee, setReferee] = useState() // 日期选择器状态 const [showApplyTimePicker, setShowApplyTimePicker] = useState(false) @@ -78,7 +81,12 @@ const AddShopDealerApply = () => { } const reload = async () => { + // 查询推荐人信息 + const dealerUser = await getShopDealerUser(Number(Taro.getStorageSync('UserId'))) + setReferee(dealerUser) + if (!params.id) { + setLoading(false); return false; } // 查询当前用户ID是否已有申请记录 @@ -100,7 +108,7 @@ const AddShopDealerApply = () => { Taro.setNavigationBarTitle({title: '签约'}) } } catch (error) { - setLoading(true) + setLoading(false) console.error('查询申请记录失败:', error); setIsEditMode(false); setExistingApply(null); @@ -126,6 +134,7 @@ const AddShopDealerApply = () => { }; const submitSucceed = async (values: any) => { + try { // 验证必填字段 if (!values.mobile || values.mobile.trim() === '') { @@ -146,6 +155,18 @@ const AddShopDealerApply = () => { return; } + // 验证报备人是否存在 + if (values.userId > 0) { + const isExist = await pageShopDealerUser({userId: Number(values.userId)}); + if(isExist && isExist.count == 0){ + Taro.showToast({ + title: '报备人不存在', + icon: 'error' + }); + return; + } + } + // 检查客户是否已存在 const res = await pageShopDealerApply({dealerName: values.dealerName, type: 4, applyStatus: 10}); @@ -205,7 +226,7 @@ const AddShopDealerApply = () => { type: 4, realName: values.realName || user?.nickname, mobile: values.mobile, - refereeId: 33534, + refereeId: referee?.refereeId, applyStatus: isEditMode ? 20 : 10, auditTime: undefined, // 设置保护期过期时间(7天后) @@ -265,6 +286,13 @@ const AddShopDealerApply = () => { useEffect(() => { reload().then(() => { setLoading(false) + }).catch((error) => { + console.error('页面加载失败:', error); + setLoading(false); + Taro.showToast({ + title: '页面加载失败', + icon: 'error' + }); }) }, []); // 依赖用户ID,当用户变化时重新加载 @@ -290,7 +318,7 @@ const AddShopDealerApply = () => { - + @@ -299,9 +327,6 @@ const AddShopDealerApply = () => { - - - {isEditMode && ( <> @@ -338,8 +363,12 @@ const AddShopDealerApply = () => { {/**/} )} - -选择 + + diff --git a/src/dealer/orders/index.tsx b/src/dealer/orders/index.tsx index 0b5a09d..b882dd7 100644 --- a/src/dealer/orders/index.tsx +++ b/src/dealer/orders/index.tsx @@ -1,6 +1,6 @@ import React, {useState, useEffect, useCallback} from 'react' import {View, Text, ScrollView} from '@tarojs/components' -import {Empty, Tag, PullToRefresh, Loading} from '@nutui/nutui-react-taro' +import {Empty, PullToRefresh, Loading} from '@nutui/nutui-react-taro' import Taro from '@tarojs/taro' import {pageShopDealerOrder} from '@/api/shop/shopDealerOrder' import {useDealerUser} from '@/hooks/useDealerUser' @@ -97,11 +97,11 @@ const DealerOrders: React.FC = () => { return '待结算' } - const getStatusColor = (isSettled?: number, isInvalid?: number) => { - if (isInvalid === 1) return 'danger' - if (isSettled === 1) return 'success' - return 'warning' - } + // const getStatusColor = (isSettled?: number, isInvalid?: number) => { + // if (isInvalid === 1) return 'danger' + // if (isSettled === 1) return 'success' + // return 'warning' + // } const renderOrderItem = (order: OrderWithDetails) => ( @@ -109,28 +109,35 @@ const DealerOrders: React.FC = () => { 电费收益 - - {getStatusText(order.isSettled, order.isInvalid)} - - - - - - 结算金额:¥{order.orderPrice || '0.00'} - ¥{(Number(order.orderPrice) * 10).toFixed(2)} + + + 客户名称:{order.comments} + + + 收益比率:{order.rate} + + + - 客户:{order.comments} + 结算电量:{order.orderPrice || '0.00'} + + 状态:{getStatusText(order.isSettled, order.isInvalid)} + + + + {order.settleTime} + )