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); } }