sql数据流,amdin业务逻辑接入

This commit is contained in:
comlibmb
2026-02-09 23:14:23 +08:00
parent 8a11a43b6c
commit bf394eb65d
3 changed files with 261 additions and 107 deletions

View File

@@ -84,13 +84,13 @@
<text class="page-val">15条/页 ▼</text>
</view>
<view class="page-btns">
<text class="p-btn disabled"><</text>
<text class="p-btn active">1</text>
<text class="p-btn">></text>
<text :class="['p-btn', page <= 1 ? 'disabled' : '']" @click="prevPage"><</text>
<text class="p-btn active">{{ page }}</text>
<text :class="['p-btn', page >= totalPages ? 'disabled' : '']" @click="nextPage">></text>
</view>
<view class="page-jump">
<text class="jump-txt">前往</text>
<input class="jump-input" placeholder="1" />
<input class="jump-input" placeholder="1" v-model="jumpPage" @confirm="goToJumpPage" />
<text class="jump-txt">页</text>
</view>
</view>
@@ -100,14 +100,15 @@
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { ref, onMounted, computed } from 'vue'
import { fetchRefundOrderPage } from '@/services/orderService.uts'
interface RefundOrder {
id: number
id: string
refundId: string
orderId: string
productImg: string
productName: string
productImg: string
userInfo: string
payPrice: number
refundTime: string
@@ -117,89 +118,101 @@ interface RefundOrder {
}
const searchQuery = ref('')
const total = ref(11)
const orderList = ref<RefundOrder[]>([
{
id: 1,
refundId: '541647750949765120',
orderId: 'cp541646979248160768',
productImg: 'https://p.demo.crmeb.net/uploads/attach/2024/09/20240905/66d87e35b7e9b.jpg',
productName: 'FOMIX 蛋壳椅 进口头层牛皮橙色单人沙发椅Egg chair设计师蛋壳椅 Egg chai...',
userInfo: '181****3601',
payPrice: 7580.00,
refundTime: '2026-02-03 15:54:47',
refundStatus: '仅退款',
orderStatus: '未发货',
refundReason: '其它原因'
},
{
id: 2,
refundId: '541638371601022976',
orderId: 'cp541638302298537984',
productImg: 'https://p.demo.crmeb.net/uploads/attach/2024/09/20240905/66d87e35b7e9b.jpg',
productName: 'UR2024夏季新款女装复古纯欲氛围感一字肩短款T恤衫UWG440060',
userInfo: '陌年微凉',
payPrice: 89.05,
refundTime: '2026-02-03 15:17:30',
refundStatus: '仅退款',
orderStatus: '未发货',
refundReason: '收货地址填错了'
},
{
id: 3,
refundId: '540965628471672832',
orderId: 'cp540873996820807680',
productImg: 'https://p.demo.crmeb.net/uploads/attach/2024/09/20240905/66d87e35b7e9b.jpg',
productName: '爱奇艺智能 奇遇LT01 投影仪 家用卧室超高清手机便携式投影机 (4K超清 支...',
userInfo: '隆胜科技',
payPrice: 1.00,
refundTime: '2026-02-01 18:44:16',
refundStatus: '仅退款',
orderStatus: '未发货',
refundReason: '收货地址填错了'
},
{
id: 4,
refundId: '5409655559492149248',
orderId: 'cp540964778781179904',
productImg: 'https://p.demo.crmeb.net/uploads/attach/2024/09/20240905/66d87e35b7e9b.jpg',
productName: '广儿穿了就会霹死',
userInfo: '隆胜科技',
payPrice: 579.00,
refundTime: '2026-02-01 18:44:00',
refundStatus: '仅退款',
orderStatus: '未发货',
refundReason: '收货地址填错了'
},
{
id: 5,
refundId: '540965491796082688',
orderId: 'cp540964551848361984',
productImg: 'https://p.demo.crmeb.net/uploads/attach/2024/09/20240905/66d87e35b7e9b.jpg',
productName: 'CHICVEN「摩登工业」科技感反光渐变羽绒服立领面包服外套女冬季',
userInfo: '隆胜科技',
payPrice: 900.00,
refundTime: '2026-02-01 18:43:43',
refundStatus: '仅退款',
orderStatus: '未发货',
refundReason: '收货地址填错了'
},
{
id: 6,
refundId: '540579611755413504',
orderId: 'cp537676043612323840',
productImg: 'https://p.demo.crmeb.net/uploads/attach/2024/09/20240905/66d87e35b7e9b.jpg',
productName: 'UR2024夏季新款女装复古纯欲氛围感一字肩短款T恤衫UWG440060',
userInfo: '杨咩咩Tel',
payPrice: 0.00,
refundTime: '2026-01-31 17:10:22',
refundStatus: '仅退款',
orderStatus: '未发货',
refundReason: '收货地址填错了'
}
])
const total = ref(0)
const orderList = ref<RefundOrder[]>([])
const loading = ref(false)
const page = ref(1)
const pageSize = ref(15)
const jumpPage = ref('')
const handleQuery = () => { console.log('Querying...') }
const totalPages = computed((): number => {
if (pageSize.value <= 0) return 1
const pages = Math.ceil(total.value / pageSize.value)
return pages <= 0 ? 1 : pages
})
const refundStatusFilter = ref<number | null>(null)
const loadRefundOrders = async () => {
loading.value = true
try {
const res = await fetchRefundOrderPage(
page.value,
pageSize.value,
refundStatusFilter.value,
searchQuery.value
)
orderList.value = res.items.map((item: any): RefundOrder => {
const refundStatusCode = parseInt(String(item.refund_status ?? '0'))
const orderStatusCode = parseInt(String(item.order_status ?? '0'))
return {
id: String(item.id),
refundId: String(item.refund_no ?? '--'),
orderId: String(item.order_no ?? '--'),
productName: String(item.product_summary?.product_name ?? '多商品订单'),
productImg: String(item.product_summary?.image_url ?? ''),
userInfo: `${String(item.customer_name ?? '未知')} | ${String(item.customer_phone ?? '')}`,
payPrice: parseFloat(String(item.refund_amount ?? '0')),
refundTime: String(item.applied_at ?? '--'),
refundStatus: getRefundStatusName(refundStatusCode),
orderStatus: String(item.order_status_text ?? orderStatusCode),
refundReason: String(item.refund_reason ?? '')
} as RefundOrder
})
total.value = res.total
} catch (e) {
uni.showToast({ title: '退款订单加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
const getRefundStatusName = (status: number): string => {
switch (status) {
case 1: return '申请中'
case 2: return '已同意'
case 3: return '已拒绝'
case 4: return '已完成'
default: return '未知'
}
}
onMounted(() => {
loadRefundOrders()
})
const handleQuery = () => {
page.value = 1
loadRefundOrders()
}
const prevPage = () => {
if (page.value > 1) {
page.value--
loadRefundOrders()
}
}
const nextPage = () => {
if (page.value < totalPages.value) {
page.value++
loadRefundOrders()
}
}
const goToJumpPage = () => {
const targetPage = parseInt(jumpPage.value)
if (!isNaN(targetPage) && targetPage >= 1 && targetPage <= totalPages.value) {
page.value = targetPage
loadRefundOrders()
jumpPage.value = ''
} else {
uni.showToast({ title: '请输入有效的页码', icon: 'none' })
}
}
</script>
<style scoped lang="scss">

View File

@@ -66,13 +66,13 @@
<text class="page-val">15条/页 ▼</text>
</view>
<view class="page-btns">
<text class="p-btn disabled"><</text>
<text class="p-btn active">1</text>
<text class="p-btn">></text>
<text :class="['p-btn', page <= 1 ? 'disabled' : '']" @click="prevPage"><</text>
<text class="p-btn active">{{ page }}</text>
<text :class="['p-btn', page >= totalPages ? 'disabled' : '']" @click="nextPage">></text>
</view>
<view class="page-jump">
<text class="jump-txt">前往</text>
<input class="jump-input" placeholder="1" />
<input class="jump-input" placeholder="1" v-model="jumpPage" @confirm="goToJumpPage" />
<text class="jump-txt">页</text>
</view>
</view>
@@ -104,7 +104,8 @@
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { ref, onMounted, computed } from 'vue'
import { fetchCashierOrderPage } from '@/services/orderService.uts'
interface CashierOrder {
orderId: string
@@ -116,23 +117,85 @@ interface CashierOrder {
const orderId = ref('')
const username = ref('')
const total = ref(12)
const orderList = ref<CashierOrder[]>([
{ orderId: 'hy536720518414336000', userInfo: '东流 | 76058', payPrice: 1.00, discountPrice: 0.00, payTime: '2026-01-21 01:35:43' },
{ orderId: 'hy529509398574268416', userInfo: '半个栗子 | 81997', payPrice: 10000.00, discountPrice: 0.00, payTime: '2026-01-01 04:01:18' },
{ orderId: 'hy511477797936431104', userInfo: '莉莉 | 80736', payPrice: 10.00, discountPrice: 0.00, payTime: '2025-11-12 09:50:09' },
{ orderId: 'hy507152261823070208', userInfo: '. . . | 71546', payPrice: 0.10, discountPrice: 0.00, payTime: '2025-10-31 11:22:01' },
{ orderId: 'hy506826113427701760', userInfo: 'A梁 | 80363', payPrice: 0.10, discountPrice: 0.00, payTime: '2025-10-30 13:46:01' },
{ orderId: 'hy504707908026499072', userInfo: '前前前前 | 80225', payPrice: 2252.00, discountPrice: 0.00, payTime: '2025-10-24 17:29:02' },
{ orderId: 'hy494505602832138240', userInfo: '张总说 | 40028', payPrice: 1.00, discountPrice: 0.00, payTime: '2025-09-26 13:48:43' },
{ orderId: 'hy490819329198129152', userInfo: '虚伪 | 79027', payPrice: 10.00, discountPrice: 0.00, payTime: '2025-09-16 09:40:47' }
])
const total = ref(0)
const orderList = ref<CashierOrder[]>([])
const loading = ref(false)
const page = ref(1)
const pageSize = ref(15)
const jumpPage = ref('')
const totalPages = computed((): number => {
if (pageSize.value <= 0) return 1
const pages = Math.ceil(total.value / pageSize.value)
return pages <= 0 ? 1 : pages
})
const loadCashierOrders = async () => {
loading.value = true
try {
const res = await fetchCashierOrderPage(
page.value,
pageSize.value,
orderId.value ? orderId.value : null,
username.value ? username.value : null
)
orderList.value = res.items.map((item: any): CashierOrder => {
return {
orderId: String(item.order_no ?? '--'),
userInfo: `${String(item.customer_name ?? '未知')} | ${String(item.customer_phone ?? '')}`,
payPrice: parseFloat(String(item.total_amount ?? item.pay_amount ?? '0')),
discountPrice: parseFloat(String(item.discount_amount ?? '0')),
payTime: String(item.paid_at ?? '--')
} as CashierOrder
})
total.value = res.total
} catch (e) {
uni.showToast({ title: '收银订单加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
onMounted(() => {
loadCashierOrders()
})
const handleQuery = () => {
page.value = 1
loadCashierOrders()
}
const prevPage = () => {
if (page.value > 1) {
page.value--
loadCashierOrders()
}
}
const nextPage = () => {
if (page.value < totalPages.value) {
page.value++
loadCashierOrders()
}
}
const goToJumpPage = () => {
const targetPage = parseInt(jumpPage.value)
if (!isNaN(targetPage) && targetPage >= 1 && targetPage <= totalPages.value) {
page.value = targetPage
loadCashierOrders()
jumpPage.value = ''
} else {
uni.showToast({ title: '请输入有效的页码', icon: 'none' })
}
}
const showQrModal = ref(false)
const isClosing = ref(false)
const handleQuery = () => { console.log('Querying...') }
const openQrModal = () => {
showQrModal.value = true
isClosing.value = false

78
services/orderService.uts Normal file
View File

@@ -0,0 +1,78 @@
import { rpcOrNull, rpcOrEmptyArray } from '@/services/analytics/rpc.uts'
export async function fetchRefundOrderPage(
page: number,
pageSize: number,
status: number | null = null,
search: string | null = null
): Promise<{ total: number; items: Array<any> }> {
const res = await rpcOrNull('rpc_admin_refund_order_list', {
p_page: page,
p_page_size: pageSize,
p_refund_status: status,
p_search: search
} as any)
if (res == null) return { total: 0, items: [] as Array<any> }
const anyTotal = (res as any).total
const anyItems = (res as any).items
const total = typeof anyTotal === 'number' ? anyTotal : parseInt(String(anyTotal ?? '0'))
const items = Array.isArray(anyItems) ? (anyItems as Array<any>) : ([] as Array<any>)
return { total, items }
}
export async function fetchCashierOrderPage(
page: number,
pageSize: number,
orderNo: string | null = null,
username: string | null = null
): Promise<{ total: number; items: Array<any> }> {
const res = await rpcOrNull('rpc_admin_cashier_order_list', {
p_page: page,
p_page_size: pageSize,
p_search_order_no: orderNo,
p_search_username: username
} as any)
if (res == null) return { total: 0, items: [] as Array<any> }
const anyTotal = (res as any).total
const anyItems = (res as any).items
const total = typeof anyTotal === 'number' ? anyTotal : parseInt(String(anyTotal ?? '0'))
const items = Array.isArray(anyItems) ? (anyItems as Array<any>) : ([] as Array<any>)
return { total, items }
}
export async function fetchWriteOffRecordPage(
page: number,
pageSize: number,
search: string | null = null
): Promise<{ total: number; items: Array<any> }> {
const res = await rpcOrNull('rpc_admin_write_off_record_list', {
p_page: page,
p_page_size: pageSize,
p_search: search
} as any)
if (res == null) return { total: 0, items: [] as Array<any> }
const anyTotal = (res as any).total
const anyItems = (res as any).items
const total = typeof anyTotal === 'number' ? anyTotal : parseInt(String(anyTotal ?? '0'))
const items = Array.isArray(anyItems) ? (anyItems as Array<any>) : ([] as Array<any>)
return { total, items }
}
export async function fetchOrderSourceStats(startTime: string, endTime: string): Promise<Array<any>> {
return (await rpcOrEmptyArray('rpc_admin_order_source_stats', {
p_start_time: startTime,
p_end_time: endTime
} as any)) as any
}