with(['communities'=>function($query){ $query->select(['area_id','id']); }])->get(['id'])->toArray(); $area_ids = []; $communities_ids =[]; $city_max = 0; $com_max = 0; foreach ($cities as $city){ $area_ids[]= $city['id']; $city_max ++; foreach ($city['communities'] as $community){ $communities_ids[] = $community['id']; $com_max++; } } $us = UserInfo::all(['id','role'])->toArray(); $user_common = []; $user_agent = []; $user_agent_user = []; foreach ($us as $u){ if ($u['role'] == UserInfo::Role_Common) $user_common[] = $u['id']; if ($u['role'] == UserInfo::Role_Agent) $user_agent[] = $u['id']; if ($u['role'] == UserInfo::Role_Agent_User) $user_agent_user[] = $u['id']; } $us = DeviceInfo::all(['id'])->toArray(); $device_ids =[]; $device_max = 0; foreach ($us as $u){ $device_max ++; $device_ids[] = $u['id']; } for ($i = 0;$i<2000;$i++){ echo "第{$i}个投放记录开始创建\r\n"; $tempRow = []; $tempRow['device_id'] = $device_ids[rand(0,$device_max-1)]; $tempRow['user_id'] = $user_common[rand(0,count($user_common)-1)]; $tempRow['no'] = strtoupper(uniqid()); $tempRow['weight'] = rand(1,99999); $tempRow['money'] = rand(0,1000); $tempRow['finished_at'] = date('Y-m-d H:i:s'); $tempRow['status'] = rand(1,3); $tempRow['created_at'] = date('Y-m-d H:i:s',strtotime("-".rand(1,365)." days")); DeliverInfo::create($tempRow); } for ($i = 0;$i<2000;$i++){ echo "第{$i}个收运记录开始创建\r\n"; $tempRow = []; $tempRow['device_id'] = $device_ids[rand(0,$device_max-1)]; $tempRow['user_id'] = $user_agent_user[rand(0,count($user_agent_user)-1)]; $tempRow['no'] = strtoupper(uniqid()); $tempRow['weight'] = rand(1,999999); $tempRow['money'] = rand(0,1000); $tempRow['created_at'] = date('Y-m-d H:i:s',strtotime("-".rand(1,365)." days")); $tempRow['status'] = rand(1,2); TransportInfo::create($tempRow); } $banks = array( '渤海银行', '广发银行', '国家开发银行', '恒丰银行', '华夏银行', '交通银行', '平安银行', '上海浦东发展银行', '兴业银行', '招商银行', '浙商银行', '中国工商银行', '中国光大银行', '中国建设银行', '中国民生银行', '中国农业银行', '中国银行', '中国邮政储蓄银行', '中信银行', ); for ($i = 0;$i<2000;$i++){ echo "第{$i}个提现记录开始创建\r\n"; $tempRow = []; $tempRow['user_id'] = $user_common[rand(0,count($user_common)-1)]; $tempRow['order_no'] = strtoupper(uniqid()); $tempRow['money'] = rand(0,3000); $tempRow['poundage'] = rand(0,200); $tempRow['pay_money'] = $tempRow['money']-$tempRow['poundage']; $tempRow['paid_at'] = date('Y-m-d H:i:s'); $tempRow['bank_card'] = $faker_zh->phoneNumber; $tempRow['bank_name'] = $banks[rand(0,count($banks)-1)]; $tempRow['name'] = $faker_zh->name; $tempRow['mobile'] = $faker_zh->phoneNumber; $tempRow['ali_account'] = $faker_zh->phoneNumber; $tempRow['ali_name'] = $faker_zh->name; $tempRow['status'] = rand(0,1); $tempRow['type'] = rand(0,2); $tempRow['created_at'] = date('Y-m-d H:i:s',strtotime("-".rand(1,365)." days")); $tempRow['reason'] = $faker_en->company; WithdrawInfo::create($tempRow); } for ($i = 0;$i<2000;$i++){ echo "第{$i}个充值记录开始创建\r\n"; $tempRow = []; $tempRow['user_id'] = $user_common[rand(0,count($user_common)-1)]; $tempRow['order_no'] = strtoupper(uniqid()); $tempRow['money'] = rand(0,1000); $tempRow['type'] =rand(0,1); $tempRow['created_at'] = date('Y-m-d H:i:s',strtotime("-".rand(1,365)." days")); $tempRow['finished_at'] = date('Y-m-d H:i:s',strtotime("-".rand(1,365)." days")); $tempRow['status'] = rand(0,1); RechargeInfo::create($tempRow); } for ($i = 0;$i<2000;$i++){ echo "第{$i}个余额记录开始创建\r\n"; $tempRow = []; $tempRow['user_id'] = $user_common[rand(0,count($user_common)-1)]; $tempRow['method'] = rand(1,6); $s = [-1,1]; $tempRow['admin_id'] = $s[rand(0,1)]; $tempRow['balance'] = rand(10,1000); $tempRow['money'] =rand(10,1000); $tempRow['detail'] = $faker_en->text; AccountInfo::create($tempRow); } } }