CaiWuXiTong/modules/EcommerceFinance/Database/Seeds/AlipayBillsTableSeeder.php
xuxiake c934f5f12c feat(ecommerce): 店铺收款账户账单·淘系支付宝账户页
按淘系支付宝账单表1(25字段)在现有系统落地:
- 迁移:新增 ec_alipay_bills 表(标识/账单/账号流水/商品/金额/时间分组)
- 模型:AlipayBill(App\Abstracts\Model,company 作用域)
- 控制器:AlipayBills(admin 路由组,筛选/排序/分页 + 收入/支出/余额/笔数汇总)
- 路由:modules/EcommerceFinance/Routes/admin.php 登记 alipay-bills
- 前端:views/business/pages.js 统一业务页入口(从路径取 company_id/page slug)
  + components/business/TaobaoAlipayBills.vue(25列分组表/筛选/汇总卡/分页)
- webpack.mix.js 增加入口;business.pages.show 末尾按 slug 引入脚本
- 种子:表1 真实3行 + 补充行(演示用)
2026-07-21 17:52:18 +08:00

135 lines
6.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Modules\EcommerceFinance\Database\Seeds;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class AlipayBillsTableSeeder extends Seeder
{
/**
* 演示数据:表1 真实 3 行 + 补充行,便于本地预览淘系支付宝账户页面。
* 运行:php artisan db:seed --class=Modules\\EcommerceFinance\\Database\\Seeds\\AlipayBillsTableSeeder
*/
public function run()
{
$companyId = (int) (DB::table('companies')->value('id') ?? 1);
DB::table('ec_alipay_bills')->where('company_id', $companyId)->delete();
$rows = [
// —— 表1 真实样例 ——
[
'record_code' => '2000000001114707218',
'store_name' => '淘宝-亿家达家居鞋柜电脑桌',
'bill_item' => '交易收款', 'business_type' => '交易付款',
'remark' => '实木腿窄书桌书架一体电脑桌床边桌卧室家用小户型学习桌写字桌子',
'alipay_account' => '2088680870590483', 'counterparty_account' => '**文',
'account_order_no' => '1570801495986359201',
'business_serial_no' => '2026062923001159201451054134',
'merchant_order_no' => 'T200P5121711939135003306',
'online_order_no' => '5121711939135003306',
'goods_name' => '实木腿窄书桌书架一体电脑桌床边桌卧室家用小户型学习桌写字桌子',
'online_real_store' => '淘宝-亿家达家居鞋柜电脑桌',
'income' => 130.93, 'expense' => 0.00, 'balance' => 13899.81,
'occurred_at' => '2026-07-01 23:57:11', 'modifier' => 'api',
],
[
'record_code' => '2000000001114782775',
'store_name' => '天猫-亿家达旗舰店',
'bill_item' => '以旧换新自补平台过桥', 'business_type' => '交易分账',
'remark' => '以旧换新自补平台过桥{3310629457741000253}',
'alipay_account' => '2088870779873392', 'counterparty_account' => '浙江天猫技术有限公司',
'account_order_no' => '1570778496992153730',
'business_serial_no' => '2026062823001153731421787379',
'merchant_order_no' => 'T200P3310629457741000253',
'online_order_no' => '3310629457741000253',
'goods_name' => '书柜储物柜一体靠墙置物柜客厅墙边小格子柜卧室床边柜子飘窗书架',
'online_real_store' => '天猫-亿家达旗舰店',
'income' => 0.00, 'expense' => 17.44, 'balance' => 253157.10,
'occurred_at' => '2026-07-01 23:55:56', 'modifier' => 'api',
],
[
'record_code' => '2000000001114787788',
'store_name' => '天猫-卓禾家具旗舰店',
'bill_item' => '以旧换新自补平台过桥', 'business_type' => '交易分账',
'remark' => '以旧换新自补平台过桥{3310023615943000698}',
'alipay_account' => '2088480341979438', 'counterparty_account' => '浙江天猫技术有限公司',
'account_order_no' => '1570765667613157810',
'business_serial_no' => '2026062623001157811400561188',
'merchant_order_no' => 'T200P3310023615943000698',
'online_order_no' => '3310023615943000698',
'goods_name' => '沙发边几可移动升降小茶几桌子中古风客厅C型床边桌电脑桌置物架',
'online_real_store' => '天猫-卓禾家具旗舰店',
'income' => 0.00, 'expense' => 32.35, 'balance' => 83929.40,
'occurred_at' => '2026-07-01 23:55:52', 'modifier' => 'api',
],
];
// —— 补充演示行(覆盖更多 账单项目 / 业务类型) ——
$shops = ['淘宝-亿家达家居鞋柜电脑桌', '天猫-亿家达旗舰店', '天猫-卓禾家具旗舰店'];
$items = [
['交易收款', '交易付款', 0],
['退款', '退款', 1],
['提现到银行卡', '提现', 1],
['服务费', '手续费', 1],
['红包补贴', '交易分账', 0],
['以旧换新自补平台过桥', '交易分账', 1],
];
$goods = [
'北欧实木餐桌椅组合小户型吃饭桌',
'懒人沙发卧室阳台休闲单椅',
'岩板茶几客厅现代简约小茶桌',
'儿童学习桌可升降书桌写字台',
'衣柜简易组装卧室衣橱',
'实木床头柜卧室收纳柜',
];
$seq = 2000000001114790000;
$balance = 90000.00;
for ($i = 0; $i < 14; $i++) {
[$item, $type, $isOut] = $items[$i % count($items)];
$shop = $shops[$i % count($shops)];
$amount = $isOut
? round(5 + ($i * 13 % 120), 2)
: round(80 + ($i * 37 % 900), 2);
$balance += $isOut ? -$amount : $amount;
$day = str_pad((string) (1 + ($i % 15)), 2, '0', STR_PAD_LEFT);
$hh = str_pad((string) (8 + ($i % 12)), 2, '0', STR_PAD_LEFT);
$mm = str_pad((string) (($i * 7) % 60), 2, '0', STR_PAD_LEFT);
$rows[] = [
'record_code' => (string) ($seq++),
'store_name' => $shop,
'bill_item' => $item, 'business_type' => $type,
'remark' => $item === '以旧换新自补平台过桥' ? ('以旧换新自补平台过桥{33' . (1000000000000000 + $i) . '}') : $item,
'alipay_account' => '2088' . (800000000000 + $i),
'counterparty_account' => $isOut ? '浙江天猫技术有限公司' : '**客',
'account_order_no' => (string) (1570700000000000000 + $i),
'business_serial_no' => '202606' . $day . '2300115' . (1000000 + $i),
'merchant_order_no' => 'T200P' . (3300000000000000 + $i),
'online_order_no' => (string) (3300000000000000 + $i),
'goods_name' => $goods[$i % count($goods)],
'online_real_store' => $shop,
'income' => $isOut ? 0.00 : $amount,
'expense' => $isOut ? $amount : 0.00,
'balance' => round($balance, 2),
'occurred_at' => '2026-07-' . $day . ' ' . $hh . ':' . $mm . ':11',
'modifier' => 'api',
];
}
$now = now();
foreach ($rows as &$row) {
$row['company_id'] = $companyId;
$row['platform'] = 'taobao';
$row['created_from'] = 'ecommerce-finance';
$row['created_at'] = $now;
$row['updated_at'] = $now;
}
unset($row);
DB::table('ec_alipay_bills')->insert($rows);
}
}