*/ class TestCommand extends Command { /** * The name of command. * * @var string */ protected $name = 'mead:test'; /** * The description of command. * * @var string */ protected $description = 'test'; /** * The type of class being generated. * * @var string */ protected $type = 'permission'; /** * Execute the command. * * @return void * @see fire() */ public function handle() { // $this->exportShopOrder(); // $day = "2024-10-27"; // $firstDayOfWeek = Carbon::now()->startOfMonth(); // dd($firstDayOfWeek); //// dd($firstDayOfWeek); // if (Carbon::parse($day)->isSameDay($firstDayOfWeek)) { // $startTimeTxt = Carbon::parse($day)->startOfWeek()->format('Y年m月d日 H:i'); // $endTimeTxt = Carbon::parse($day)->endOfWeek()->format('Y年m月d日 H:i'); // $timeTxt = "{$startTimeTxt}-{$endTimeTxt}"; // dd($timeTxt); // } // $bg = base_path('Data/huojian_bg.png'); // $image = Image::make($bg)->resize(375, 646); // // $nickname = '你好你好你好...'; // self::addText($image, $nickname, 375 / 2, 210, 40, 'F00'); // $day = date('Y-m-d'); // // self::addText($image, Carbon::parse($day)->format('Y年m月d日'), 375 / 2, 458, 16, '3d3d3d'); // $dir = "huojianImg/" . $day; // $filename = Str::random() . '.png'; // $filename = 'mead.png'; // // // Storage::disk('public')->put("{$dir}/{$filename}.txt", 1); // $path = Storage::disk('public')->path("{$dir}/{$filename}"); // $image->save($path); // // Storage::disk('public')->delete("{$dir}/{$filename}.txt"); // $this->testOrderData(); // $this->makeUserOrder(4, 1); // User::refreshUserTag(4); // $this->makeUserOrder(4, 1); // WechatTemplateMessageService::sendAddXuefen(4, 1); // $this->areaToBase(); // ShopOrder::query()->truncate(); // ShopGood::query()->update(['nums' => 3, 'duihuan_nums' => 0]); // ShopOrderGood::query()->truncate(); // // Cache::flush(); // $goods = ShopGood::query()->get(); // foreach ($goods as $good) { // ShopGood::updateKuCun($good->id, $good->nums); // } // // $a = Cache::increment("mead:nums"); // Cache::decrement("mead:nums", $a); // ShopGood::addGoodNums(1, 1, 2); // $url = '/admin/base/auth/login'; // dd(strpos($url, "/admin/") == 0); // $this->export('2024-10-01', '2024-12-01', 1000); $days = Carbon::now()->diffInDays(Carbon::parse("2025-02-05")); for ($i = 0; $i <= $days; $i++) { $day = Carbon::now()->subDays($days)->clone()->addDays($i)->toDateString(); $this->line("数据:{$day}"); Artisan::call("statistical:user {$day}"); } $this->line('ok'); } public function export($start_day, $end_day, $limit = 1000) { $users = Ranking::query()->where('day_type', DayTypeEnum::day)->select(['user_id', DB::raw("sum(day_xuefen) as dxf")])->groupBy('user_id')->orderByDesc('dxf')->limit(10)->get(); foreach ($users as $user) { $gs = OrderGood::query()->where('user_id', $user['user_id'])->select(['user_id', 'good_id', DB::raw('count(nums) as good_nums')])->groupBy('good_id')->pluck('good_nums', 'good_id'); } } public function areaToBase() { $provinces = json_decode(file_get_contents(base_path('app/Support/Sdk/Address/province.json')), true); $citys = json_decode(file_get_contents(base_path('app/Support/Sdk/Address/city.json')), true); $areas = json_decode(file_get_contents(base_path('app/Support/Sdk/Address/area.json')), true); $sheng = []; $shi = []; $qu = []; foreach ($provinces as $province) { $sheng[$province['value'] . '0000'] = [ 'name' => $province['label'], 'pid' => 0, 'zipcode' => $province['value'] . '0000', ]; } file_put_contents(base_path('app/Support/Sdk/Address/province_1.json'), json_encode($sheng, JSON_UNESCAPED_UNICODE)); foreach ($citys as $s) { foreach ($s as $ss) { $sc = substr($ss['value'], 0, 2); $shi[$ss['value'] . '00'] = [ 'name' => $ss['label'], 'pid' => $sc . '0000', 'zipcode' => $ss['value'] . '00', ]; } } file_put_contents(base_path('app/Support/Sdk/Address/city_1.json'), json_encode($shi, JSON_UNESCAPED_UNICODE)); foreach ($areas as $s) { foreach ($s as $ss) { foreach ($ss as $sss) { $sc = substr($sss['value'], 0, 4); $qu[$sss['value']] = [ 'name' => $sss['label'], 'pid' => $sc . '00', 'zipcode' => $sss['value'], ]; } } } file_put_contents(base_path('app/Support/Sdk/Address/area_1.json'), json_encode($qu, JSON_UNESCAPED_UNICODE)); } public function makeUserOrder($user_id, $order_nums = 1) { $users = User::query()->where('id', $user_id)->get(); $tx = 0; foreach ($users as $user) { for ($o = 1; $o <= $order_nums; $o++) { $txf = random_int(1, 3); $da = []; $goods = Good::query()->inRandomOrder()->limit($txf)->get(); foreach ($goods as $good) { $num = random_int(1, 5); $da[] = [ 'ProductGroupID' => 9, 'ProductGroupSKUID' => 9, 'ProductName' => "大卫博士罐装内裤(青春版)", 'ProductCode' => $good['name'], 'SKUCode' => "青春版", 'AttributesVales' => [], 'Qty' => $num, ]; $tx += $num * $good['xuefen']; } $data = [ 'Type' => 1, 'RetailID' => 134, 'Code' => Order::makeNo(), 'AuthorizationCode' => $user->code, 'Domain' => "http://hnsystemse.njjinhao.top/", 'data' => $da ]; dispatch(new ImportOrderJob(json_encode($data, true))); } $this->line($tx); } } public function testOrderData() { //{"Type":1,"RetailID":134,"Code":"2024102947561000002","Domain":"http://hnsystemse.njjinhao.top/","data":[{"ProductGroupID":9,"ProductGroupSKUID":9,"ProductName":"大卫博士罐装内裤(青春版)","ProductCode":"青春版","SKUCode":"青春版","AttributesVales":[],"Qty":2}]} $data = [ 'Type' => 1, 'RetailID' => 134, 'Code' => 2024102947561000002, 'AuthorizationCode' => 'M100001', 'Domain' => "http://hnsystemse.njjinhao.top/", 'data' => [ [ 'ProductGroupID' => 9, 'ProductGroupSKUID' => 9, 'ProductName' => "大卫博士罐装内裤(青春版)", 'ProductCode' => "青春版", 'SKUCode' => "青春版", 'AttributesVales' => [], 'Qty' => 2, ] ] ]; dispatch(new ImportOrderJob(json_encode($data, true))); } public static function addText(&$bgImage, $text, $x, $y, $size, $color, $align = 'center', $valign = 'middle', $ziti = '') { if (!$ziti) $ziti = base_path('Data/ziti/ht.otf'); // $y += ($size / 2); $bgImage->text($text, $x, $y, function ($font) use ($size, $color, $ziti, $align, $valign) { $font->file($ziti); $font->size($size); $font->color($color); $font->angle(0); $font->align($align); $font->valign($valign); }); // return $bgImage; } public function exportShopOrder() { $file_name = time() . '.xlsx'; $ids = [2]; (new ShopOrderExport($ids))->store($file_name); } }