“âfirst commit
This commit is contained in:
commit
72e58f13d5
58
.env.example
Normal file
58
.env.example
Normal file
@ -0,0 +1,58 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_HOST=
|
||||
PUSHER_PORT=443
|
||||
PUSHER_SCHEME=https
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
VITE_PUSHER_HOST="${PUSHER_HOST}"
|
||||
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
||||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
||||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
* text=auto
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
21
.gitignore
vendored
Normal file
21
.gitignore
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/debugbar
|
||||
/storage/qrcode
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
auth.json
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscodegit merg
|
||||
composer.lock
|
||||
66
README.md
Normal file
66
README.md
Normal file
@ -0,0 +1,66 @@
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## About Laravel
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
|
||||
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
## Laravel Sponsors
|
||||
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||
|
||||
### Premium Partners
|
||||
|
||||
- **[Vehikl](https://vehikl.com/)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[Many](https://www.many.co.uk)**
|
||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||
- **[DevSquad](https://devsquad.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||
- **[OP.GG](https://op.gg)**
|
||||
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
|
||||
- **[Lendio](https://lendio.com)**
|
||||
|
||||
## Contributing
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
73
app/Console/Commands/AddWangYiYunUser.php
Normal file
73
app/Console/Commands/AddWangYiYunUser.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\WangYiYun;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use cccdl\yunxin_sdk\Im\User as ImUser;
|
||||
|
||||
class AddWangYiYunUser extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'add:wang:yi:user';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '同步网易用户';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$end_time = time();
|
||||
$start_time = $end_time - 61;
|
||||
$start_date = date('Y-m-d H:i:s',$start_time);
|
||||
$end_date = date('Y-m-d H:i:s',$end_time);
|
||||
$users = User::whereBetween('created_at',[$start_date,$end_date])->get('id');
|
||||
$imUser = new ImUser(config('chat.im.app_id'), config('chat.im.app_secret'));
|
||||
foreach ($users as $user){
|
||||
$exists = WangYiYun::where('user_id',$user->id)->exists();
|
||||
if($exists){
|
||||
continue;
|
||||
}
|
||||
$ac_cid = make_wangyiyun_accid($user->id);
|
||||
$insert = $yun = [];
|
||||
$insert['user_id'] = $user->id;
|
||||
$insert['accid'] = $ac_cid;
|
||||
$insert['name'] = $yun['name'] = $user->name;
|
||||
$insert['icon'] = $yun['icon'] = $user->avatar;
|
||||
$insert['email'] = $yun['email'] = $user->email;
|
||||
$insert['birth'] = $yun['birth'] = $user->birthday;
|
||||
$insert['mobile'] = $yun['mobile'] = $user->mobile;
|
||||
$insert['gender'] = $yun['gender'] = !empty($user->sex) ? $user->sex : 0;
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$imUserData = $imUser->create($ac_cid, $yun);
|
||||
$token = $imUserData['info']['token'] ?? '';
|
||||
$insert['token'] = $token;
|
||||
WangYiYun::create($insert);
|
||||
DB::commit();
|
||||
|
||||
Log::info('AddWangYiYunUser success user_id:'.$user->id);
|
||||
} catch (\Exception $e) {
|
||||
Log::info('AddWangYiYunUser fail user_id:'.$user->id);
|
||||
DB::rollBack();
|
||||
}
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
46
app/Console/Commands/CheckRegularActivity.php
Normal file
46
app/Console/Commands/CheckRegularActivity.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\RegularActivity;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CheckRegularActivity extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'check:regular_activity';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
RegularActivity::where("status", '<>', RegularActivity::DONE_STATUS)->chunk(100, function ($activities) use($now){
|
||||
foreach ($activities as $activity) {
|
||||
if ($activity->start_time < $now && $activity->end_time > $now) {
|
||||
//进行中
|
||||
RegularActivity::where("id", $activity->id)->update(['status'=>RegularActivity::ONGOING_STATUS]);
|
||||
}elseif ($activity->end_time < $now) {
|
||||
//结束
|
||||
RegularActivity::where("id", $activity->id)->update(['status'=>RegularActivity::DONE_STATUS]);
|
||||
}
|
||||
}
|
||||
});
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
64
app/Console/Commands/CreateAdmin.php
Normal file
64
app/Console/Commands/CreateAdmin.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\CommonService;
|
||||
use App\Models\Admin;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateAdmin extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'admin:create';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'create an administrator account';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$name = $this->ask("enter account name");
|
||||
while (true) {
|
||||
$account = $this->ask('enter account number');
|
||||
if (!CommonService::isMobile($account)) {
|
||||
$this->info("[error] please enter a phone number");
|
||||
continue;
|
||||
}
|
||||
$is_exist = Admin::where("mobile", $account)->exists();
|
||||
if (!$is_exist) break;
|
||||
$this->info("[error] account exists");
|
||||
}
|
||||
while (true) {
|
||||
$password = $this->secret("enter the password");
|
||||
if (strlen($password) < 6) {
|
||||
$this->info('[error] password`s length less than 6');
|
||||
continue;
|
||||
}
|
||||
$re_password = $this->secret("enter the password again");
|
||||
if ($password == $re_password) break;
|
||||
$this->info("[error] password not the same");
|
||||
}
|
||||
|
||||
Admin::create([
|
||||
'name'=>$name?:"Admin",
|
||||
'mobile'=>$account,
|
||||
'password'=>Hash::make($password),
|
||||
'desc'=>"系统管理员"
|
||||
]);
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
52
app/Console/Commands/CreateRestaurantDate.php
Normal file
52
app/Console/Commands/CreateRestaurantDate.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\CommonService;
|
||||
use App\Models\MeetRoom;
|
||||
use App\Models\MeetRoomReserve;
|
||||
use App\Models\RestaurantDate;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CreateRestaurantDate extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'create:restaurant:date';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '提前生成订餐日历';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$date = date('Y-m-d'); // 当前日期
|
||||
$start_date = date('Y-m-01', strtotime('+1 month',strtotime($date)));
|
||||
$end_date = date('Y-m-d', strtotime("$start_date + 1 month -1 day"));
|
||||
$dailies = CommonService::daliy($start_date, $end_date);
|
||||
foreach ($dailies as $day){
|
||||
$status = 2;
|
||||
// $day_of_week = date('w', strtotime($day));
|
||||
// if($day_of_week == 0){
|
||||
// $status = 2;
|
||||
// }
|
||||
$exists = RestaurantDate::where('date',$day)->exists();
|
||||
if($exists){
|
||||
continue;
|
||||
}
|
||||
RestaurantDate::create(['date'=>$day,'status'=>$status]);
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
70
app/Console/Commands/CreateSplitAccessLog.php
Normal file
70
app/Console/Commands/CreateSplitAccessLog.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\CommonService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitAccessLog extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:access_logs'; //quarter季度
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '按周期生成日志数据库';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
// $month = 7;
|
||||
if ($month >= 10) {//下一年
|
||||
$year = $year + 1;
|
||||
}
|
||||
$quarter = CommonService::getQuarter($month);
|
||||
if ($quarter == 4) {//下一个周期季度
|
||||
$quarter = 1;
|
||||
}else {
|
||||
$quarter = $quarter + 1;
|
||||
}
|
||||
$table_name = "access_logs_{$year}{$quarter}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('method')->nullable();
|
||||
$table->string('route')->nullable();
|
||||
$table->enum('channel', ['其他', 'H5', 'Admin', '小程序', 'APP'])->nullable()->comment("渠道");
|
||||
$table->string('time')->nullable();
|
||||
$table->string('client_ip')->nullable();
|
||||
$table->longText('params')->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->text("headers")->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('user_id');
|
||||
$table->index('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
55
app/Console/Commands/CreateSplitBandBlood.php
Normal file
55
app/Console/Commands/CreateSplitBandBlood.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandBlood extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_bloods';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_bloods_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->string('value', 10)->comment("血氧数值");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
57
app/Console/Commands/CreateSplitBandHrrest.php
Normal file
57
app/Console/Commands/CreateSplitBandHrrest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandHrrest extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_hrrests';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_hrrests_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->integer('value')->unsigned()->comment("数值");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
62
app/Console/Commands/CreateSplitBandHrv.php
Normal file
62
app/Console/Commands/CreateSplitBandHrv.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandHrv extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_hrvs';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_hrvs_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->integer('highBP')->comment("高压");
|
||||
$table->integer('stress')->unsigned()->comment("压力");
|
||||
$table->integer('lowBP')->unsigned()->comment("低压");
|
||||
$table->integer('heartRate')->unsigned()->comment("心率");
|
||||
$table->integer('hrv')->unsigned()->comment("血管老化度");
|
||||
$table->integer('vascularAging')->unsigned()->comment("血管老化度");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
55
app/Console/Commands/CreateSplitBandOriginBattery.php
Normal file
55
app/Console/Commands/CreateSplitBandOriginBattery.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandOriginBattery extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_origin_battery';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_origin_battery_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->text("value")->nullable()->comment("数据");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
55
app/Console/Commands/CreateSplitBandOriginBlood.php
Normal file
55
app/Console/Commands/CreateSplitBandOriginBlood.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandOriginBlood extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_origin_bloods';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_origin_bloods_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->text("value")->nullable()->comment("数据");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
57
app/Console/Commands/CreateSplitBandOriginHrrest.php
Normal file
57
app/Console/Commands/CreateSplitBandOriginHrrest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandOriginHrrest extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_origin_hrrests';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_origin_hrrests_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->text("value")->nullable()->comment("数据");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
57
app/Console/Commands/CreateSplitBandOriginHrv.php
Normal file
57
app/Console/Commands/CreateSplitBandOriginHrv.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandOriginHrv extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_origin_hrvs';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_origin_hrvs_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->text("value")->nullable()->comment("数据");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
57
app/Console/Commands/CreateSplitBandOriginSleep.php
Normal file
57
app/Console/Commands/CreateSplitBandOriginSleep.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandOriginSleep extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_origin_sleeps';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_origin_sleeps_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->text("value")->nullable()->comment("数据");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
56
app/Console/Commands/CreateSplitBandOriginSyn.php
Normal file
56
app/Console/Commands/CreateSplitBandOriginSyn.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandOriginSyn extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_origin_syns';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_origin_syns_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->text("value")->nullable()->comment("数据");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
$table->index('date');
|
||||
});
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
57
app/Console/Commands/CreateSplitBandOriginTemp.php
Normal file
57
app/Console/Commands/CreateSplitBandOriginTemp.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandOriginTemp extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_origin_temps';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_origin_temps_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->text("value")->nullable()->comment("数据");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
59
app/Console/Commands/CreateSplitBandSleep.php
Normal file
59
app/Console/Commands/CreateSplitBandSleep.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandSleep extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_sleeps';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_sleeps_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->integer('value')->comment("数值");
|
||||
$table->integer('unit')->unsigned()->comment("采集时间单位");
|
||||
$table->integer('origin_value')->unsigned()->comment("原始数据");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
58
app/Console/Commands/CreateSplitBandSyn.php
Normal file
58
app/Console/Commands/CreateSplitBandSyn.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandSyn extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_syns';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_syns_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->integer('step')->unsigned()->comment("步数");
|
||||
$table->string('distance',10)->comment("距离");
|
||||
$table->string('calories', 10)->comment("卡路里");
|
||||
$table->string('steps')->comment("步频");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
57
app/Console/Commands/CreateSplitBandTemp.php
Normal file
57
app/Console/Commands/CreateSplitBandTemp.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitBandTemp extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'table:band_temps';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date("Y");
|
||||
if ($month == 12) {//下一年
|
||||
$year += 1;
|
||||
$month = 1;
|
||||
}else {
|
||||
$month += 1;
|
||||
}
|
||||
$month = str_pad($month, 2, '0', STR_PAD_LEFT);
|
||||
$table_name = "band_temps_{$year}{$month}";
|
||||
if (!Schema::hasTable($table_name)) {
|
||||
Schema::create($table_name, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned()->comment("用户id");
|
||||
$table->integer('band_id')->unsigned()->comment("手环id");
|
||||
$table->timestamp('date')->nullable()->comment("时间");
|
||||
$table->integer('value')->unsigned()->comment("数值");
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'band_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
59
app/Console/Commands/DailyGuide.php
Normal file
59
app/Console/Commands/DailyGuide.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\SendTemplateNotice;
|
||||
use App\Models\Guide;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class DailyGuide extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'guide:notice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '每日餐单提醒';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//当天餐单
|
||||
$now_date = date("Y-m-d");
|
||||
Guide::with('officialWechat', 'order')->where('phase_date', $now_date)->chunk(100, function ($guides) {
|
||||
foreach ($guides as $guide) {
|
||||
$param = [
|
||||
'touser' => $guide->officialWechat?$guide->officialWechat->openid:null,
|
||||
'template_id' => config('wechat.tpls.daily_guide_notice'),
|
||||
'url' => '',
|
||||
'miniprogram' => [
|
||||
'appid' => config('wechat.mini_program.app_id'),
|
||||
'pagepath' => 'pages/tabBar/serve',
|
||||
],
|
||||
'data' => [
|
||||
'first' => ['value' => '您的餐单还未完成,继续加油!'],
|
||||
'keyword1' => ['value' => $guide->order->trade_no],
|
||||
"keyword2" => ['value' => $guide->order->desc],
|
||||
"keyword3" => ['value' => $guide->phase_title],
|
||||
"keyword4" => ['value' => "当天内"],
|
||||
'remark' => ['value' => "点击进入查看详情"]
|
||||
]
|
||||
];
|
||||
SendTemplateNotice::dispatch($param)->onQueue('health');
|
||||
}
|
||||
});
|
||||
//注释
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
152
app/Console/Commands/DmaQuestionNotice.php
Normal file
152
app/Console/Commands/DmaQuestionNotice.php
Normal file
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\TaskService;
|
||||
use App\Models\DmaProcessLog;
|
||||
use App\Models\Order;
|
||||
use App\Facades\CommonService;
|
||||
use App\Models\ServerQuestion;
|
||||
use App\Models\ServiceRole;
|
||||
use cccdl\yunxin_sdk\Im\Msg;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\ChatService;
|
||||
use Log;
|
||||
|
||||
class DmaQuestionNotice extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'order:finished {notice}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$notice = $this->argument("notice");
|
||||
|
||||
if ($notice == "quesiotn_notice") {// 方案后问卷调查提醒
|
||||
$this->sendQuestionNotice();
|
||||
} elseif ($notice == "clean_notice") { // 方案后清洁提醒
|
||||
$this->sendCleanNotice();
|
||||
} elseif ($notice == "after_body_image") {// 方案后身体照提醒
|
||||
$this->sendAfterBodyImageNotice();
|
||||
} elseif ($notice == "after_body_image_task") {// 方案后身体照任务
|
||||
$this->sendAfterBodyImageTask();
|
||||
} elseif ($notice == "server_question_3") {// 方案结束后教练评估
|
||||
$this->sendServerQuestionTask3();
|
||||
} elseif ($notice == "server_question_60") {// 方案结束后教练评估表
|
||||
$this->sendServerQuestionTask60();
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
public function sendServerQuestionTask3()
|
||||
{
|
||||
$start_time = date("Y-m-d ", strtotime("-4 day"));
|
||||
$end_time = date("Y-m-d ", strtotime("-3 day"));
|
||||
$orders = Order::with("user")->whereHas("group")->whereHas("user")->where("status", "FINISHED")->whereBetween("end_time", [$start_time, $end_time])->get();
|
||||
foreach ($orders as $order) {
|
||||
// $theme = "请填写「用户" . $order->name . "」的【方案后第3天】评估表";
|
||||
$theme = "【" . $order->name . "】方案已结束3天,请所有教练填写用户第一次评价表";
|
||||
$user_ids = ServerQuestion::where('order_id', $order->id)->where('type', 1)->pluck("user_id")->toArray();
|
||||
TaskService::AddTask(0, 0, $theme, [1, 2, 3], $order->id, "", "", "", "", $user_ids);
|
||||
|
||||
$chatService = new ChatService();
|
||||
$chatService->sendImMsgUserToUser($order->id, '系统通知', $theme, '', '', [ServiceRole::MAIN_COACH, ServiceRole::COACH, ServiceRole::CUSTOMER], [], $user_ids);
|
||||
|
||||
DmaProcessLog::addUserProcessLog(0, $order->id, 1, "system_send_server_question_3_msg", $theme, 5);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendServerQuestionTask60()
|
||||
{
|
||||
$start_time = date("Y-m-d ", strtotime("-61 day"));
|
||||
$end_time = date("Y-m-d ", strtotime("-60 day"));
|
||||
$orders = Order::whereHas("group")->whereHas("user")->where("status", "FINISHED")->whereBetween("end_time", [$start_time, $end_time])->get();
|
||||
foreach ($orders as $order) {
|
||||
// $theme = "请填写「用户" . $order->name . "」的【方案后第60天】评估表";
|
||||
$theme = "【" . $order->name . "】方案已结束60天,请所有教练填写用户第二次评价表";
|
||||
$user_ids = ServerQuestion::where('order_id', $order->id)->where('type', 2)->pluck("user_id")->toArray();
|
||||
TaskService::AddTask(0, 0, $theme, [1, 2, 3], $order->id, "", "", "", "", $user_ids);
|
||||
|
||||
$chatService = new ChatService();
|
||||
$chatService->sendImMsgUserToUser($order->id, '系统通知', $theme, '', '', [ServiceRole::MAIN_COACH, ServiceRole::COACH, ServiceRole::CUSTOMER], [], $user_ids);
|
||||
|
||||
DmaProcessLog::addUserProcessLog(0, $order->id, 1, "system_send_server_question_60_msg", $theme, 5);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendAfterBodyImageNotice()
|
||||
{
|
||||
$start_time = date("Y-m-d", strtotime("-1 day"));
|
||||
$end_time = date("Y-m-d");
|
||||
$orders = Order::whereHas("group")->whereHas("user")->where("status", "FINISHED")->whereBetween("end_time", [$start_time, $end_time])->get();
|
||||
foreach ($orders as $order) {
|
||||
if (empty($order->user->after_body_image))
|
||||
continue;
|
||||
$chatService = new ChatService();
|
||||
$chatService->sendGroupMsg($order->user_id, '方案后身体照片', '请点击上传方案后身体照片', 'https://images.health.ufutx.com/202412/12/abc84f7b2b5dc2b94d6d27ca4eeb09ab.png', "yfheal://app/push/UpdateHealthBodyPhotoAfter", []);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendAfterBodyImageTask()
|
||||
{
|
||||
$start_time = date("Y-m-d ", strtotime("-4 day"));
|
||||
$end_time = date("Y-m-d ", strtotime("-3 day"));
|
||||
$orders = Order::whereHas("group")->whereHas("user")->where("status", "FINISHED")->whereBetween("end_time", [$start_time, $end_time])->get();
|
||||
foreach ($orders as $order) {
|
||||
if (empty($order->user->after_body_image))
|
||||
continue;
|
||||
$theme = "请跟进【" . $order->name . "】上传【方案后照片】";
|
||||
TaskService::AddTask(0, 0, $theme, [1, 2, 3], $order->id);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendCleanNotice()
|
||||
{
|
||||
$start_time = date("Y-m-d H:i:s", strtotime("-3 month"));
|
||||
$orders = Order::whereHas("group")->where("status", "FINISHED")->where("end_time", ">", $start_time)->get();
|
||||
foreach ($orders as $order) {
|
||||
$msg = "😊亲爱的【{$order->name}】,一份温馨小建议轻轻来送达!每周抽出 1 天做清洁保养巩固,有助于维持良好的身体状态,能让您的健康生活持续向好,更加精彩。";
|
||||
$imMsg = new Msg(config('chat.im.app_id'), config('chat.im.app_secret'));
|
||||
$imMsg->sendMsg(make_wangyiyun_accid($order->group->owner_id), 1, $order->group->im_chat_id, 0, json_encode(['msg' => $msg]));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function sendQuestionNotice()
|
||||
{
|
||||
Log::info("方案后服务问卷提醒");
|
||||
$nowDate = date("Y-m-d");
|
||||
$orders = Order::whereDoesntHave("afterDmaQuestion")->whereDoesntHave("orderSurveys")->where("service_status", "FINISHED")->get();
|
||||
foreach ($orders as $order) {
|
||||
$log_at = DmaProcessLog::where("order_id", $order->id)->where("key_name", "mark_order_finish")->orderBy("id", "desc")->value("created_at");
|
||||
if ($log_at) {
|
||||
$log_at = $log_at->toDateString();
|
||||
}
|
||||
$day = CommonService::diffDays($nowDate, $log_at);
|
||||
Log::info("订单id:" . $order->id . " day=" . $day);
|
||||
if ($day >= 60 && $day <= 70 && $day % 3 == 0 && $order->group && $order->group->im_chat_id) {
|
||||
$imMsg = new Msg(config('chat.im.app_id'), config('chat.im.app_secret'));
|
||||
$imMsg->sendMsg(make_wangyiyun_accid($order->group->owner_id), 1, $order->group->im_chat_id, 0, json_encode(['msg' => "【{$order->name}】请抽空完成方案后服务问卷,您的反馈非常重要,可以帮助我们了解您方案中的感受,感谢您的支持!"]));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
200
app/Console/Commands/ImportFatLog.php
Normal file
200
app/Console/Commands/ImportFatLog.php
Normal file
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\CommonService;
|
||||
use App\Http\Controllers\TestController;
|
||||
use App\Models\FatLog;
|
||||
use App\Models\NewFatLog;
|
||||
use App\Models\OfflineOrder;
|
||||
use App\Models\Order;
|
||||
use App\Models\User;
|
||||
use App\Models\UserInfo;
|
||||
use App\Models\Version;
|
||||
use App\Services\FatService;
|
||||
use App\Services\OfflineOrderService;
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
class ImportFatLog extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'import:dma {type}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info("导入体脂秤信息");
|
||||
|
||||
$type = $this->argument("type");
|
||||
|
||||
switch($type) {
|
||||
case "user":
|
||||
$content = file_get_contents(storage_path("user.txt"));
|
||||
$contentList = explode("\n", $content);
|
||||
|
||||
foreach($contentList as $content) {
|
||||
$res = json_decode($content);
|
||||
if (empty($res)) {
|
||||
dd($content);
|
||||
}
|
||||
$dataList = $res->data;
|
||||
foreach($dataList as $data) {
|
||||
$user = $this->importStoreUser($data);
|
||||
if ($user && $user->account_id) {
|
||||
$this->info("成功导入用户[{$user->id}]");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "fat_log":
|
||||
$users = User::whereNotNull("account_id")->get();
|
||||
foreach($users as $user) {
|
||||
$file_path = storage_path("list/{$user->account_id}.txt");
|
||||
$fat_content = file_get_contents($file_path);
|
||||
$fat_content = str_replace("'", '"', $fat_content);
|
||||
$res = json_decode($fat_content);
|
||||
if (empty($res)) {
|
||||
dd($fat_content);
|
||||
}
|
||||
if (!count($res->data)) {
|
||||
$this->info("用户[{$user->id}]没有体重信息");
|
||||
continue;
|
||||
};
|
||||
$this->importStoreFat($user, $res);
|
||||
$this->info("成功导入用户[{$user->id}]体重信息");
|
||||
}
|
||||
break;
|
||||
case "order":
|
||||
$users = User::withCount("payOrders")->whereNotNull("account_id")->get();
|
||||
foreach($users as $user) {
|
||||
if ($user->pay_orders_count) {
|
||||
$this->info("用户[{$user->id}]已有订单");
|
||||
continue;
|
||||
}
|
||||
// 创建订单
|
||||
$tradeNo = CommonService::getTradeNO();
|
||||
DB::beginTransaction();
|
||||
$order = Order::create([
|
||||
'user_id' => $user->id,
|
||||
'type' => 'SERVICE',
|
||||
'type_id' => 1,
|
||||
'price' => 0,
|
||||
'pay_status' => 'PAID',
|
||||
'trade_no' => $tradeNo,
|
||||
'name' => $user->name,
|
||||
'area_code' => 86,
|
||||
"status" => Order::NOTSTART_STATUS,
|
||||
"service_status"=> "NOINFO",
|
||||
'mobile' => ctype_digit($user->mobile) ? $user->mobile : aesDecryptCBC($user->mobile),
|
||||
'agency_id' => null,
|
||||
'desc' => '友福健康服务',
|
||||
'is_hook'=>1,
|
||||
]);
|
||||
|
||||
// 创建线下订单
|
||||
OfflineOrder::create([
|
||||
'order_id' => $order->id,
|
||||
'name' => $order->name,
|
||||
'area_code' => 86,
|
||||
'mobile' =>$order->mobile,
|
||||
'contract_no'=>$order->mobile,
|
||||
'pay_type' => 1,
|
||||
'bank_name' => null,
|
||||
'bank_num' => null,
|
||||
'agency_id' => null,
|
||||
'price' => 0,
|
||||
]);
|
||||
DB::commit();
|
||||
$this->info("成功导入用户[{$user->id}]dma订单");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
public function importStoreFat($user, $res)
|
||||
{
|
||||
$fatService = new FatService();
|
||||
foreach($res->data as $data) {
|
||||
$exists = NewFatLog::where("old_id", $data->id)->exists();
|
||||
if ($exists) continue;
|
||||
$log = [
|
||||
["e_name"=>"Weight", "score"=>$data->weight],
|
||||
["e_name"=>"BMI", "score"=>$data->bmi],
|
||||
["e_name"=>"Bodyfat", "score"=>$data->bodyfat],
|
||||
["e_name"=>"Subfat", "score"=>$data->subfat],
|
||||
["e_name"=>"Water", "score"=>$data->water],
|
||||
["e_name"=>"Muscle", "score"=>$data->muscle],
|
||||
["e_name"=>"Visfat", "score"=>$data->visfat],
|
||||
["e_name"=>"Bone", "score"=> number_format($data->bone / 10, 2, ".", "") ],
|
||||
["e_name"=>"BMR", "score"=>$data->bmr * 10],
|
||||
["e_name"=>"BodyShape", "score"=>$data->body_shape],
|
||||
["e_name"=>"Protein", "score"=>$data->protein],
|
||||
["e_name"=>"LBM", "score"=>$data->fat_free_weight],
|
||||
["e_name"=>"Sinew", "score"=>$data->sinew],
|
||||
["e_name"=>"BodyAge", "score"=>$data->bodyage],
|
||||
["e_name"=>"Score", "score"=>$data->score],
|
||||
];
|
||||
$user->fat_device = 1; // 云康宝
|
||||
$res = $fatService->saveFatLog($user,["data"=>$log, "time"=>$data->created_at, "old_id"=>$data->id, "init_data"=>"cs20h", "device_model"=>"CS20H"],Version::TYPE_APP,true);
|
||||
}
|
||||
}
|
||||
|
||||
public function importStoreUser($data)
|
||||
{
|
||||
$user = User::where("account_id", $data->id)->first();
|
||||
if ($user) return $user;
|
||||
if (!$data->phone) return null;
|
||||
$en_phone = aesEncryptCBC($data->phone);
|
||||
$user = User::where(function($sql) use($en_phone, $data) {
|
||||
$sql->where("mobile", $data->phone)->orWhere("mobile", $en_phone);
|
||||
})->whereIn("source", [1,4])->first();
|
||||
if ($user) {
|
||||
User::where("id", $user->id)->update(["account_id"=>$data->id]);
|
||||
$user->account_id = $data->id;
|
||||
return $user;
|
||||
};
|
||||
DB::beginTransaction();
|
||||
$user = User::create([
|
||||
"name"=>$data->account_name,
|
||||
"mobile"=>$en_phone,
|
||||
"birthday"=>$data->birthday,
|
||||
"sex"=>$data->gender?:2,
|
||||
"stature"=>$data->height,
|
||||
"avatar"=>$data->avatar,
|
||||
"source"=>4,
|
||||
"account_id"=>$data->id,
|
||||
"unit"=>"kg",
|
||||
"fat_device"=>1,
|
||||
]);
|
||||
|
||||
UserInfo::create(['user_id'=>$user->id]);
|
||||
DB::commit();
|
||||
return $user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
116
app/Console/Commands/ImportMedicalReport.php
Normal file
116
app/Console/Commands/ImportMedicalReport.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\UploadService;
|
||||
use App\Models\MedicalReport;
|
||||
use App\Models\ServiceUser;
|
||||
use App\Models\User;
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
|
||||
class ImportMedicalReport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'sync:medical_report {type}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$type = $this->argument("type");
|
||||
if ($type == "import") {
|
||||
$this->importReport();
|
||||
} else {
|
||||
$this->syncReport();
|
||||
}
|
||||
}
|
||||
|
||||
public function syncReport()
|
||||
{
|
||||
$user_num = 0;
|
||||
$other_num = 0;
|
||||
$name_arr = [];
|
||||
$name_arr2 = [];
|
||||
$logs = DB::table(table: "health_reports")->get();
|
||||
foreach($logs as $index=>$log) {
|
||||
$this->info("第{$index}位");
|
||||
$user = User::where("name", $log->name)->whereIn("source", User::APP_USER_SOURCE)->first();
|
||||
if ($user) {// 用户存在
|
||||
$user_num++;
|
||||
$report = MedicalReport::where("user_id", $user->id)->where("type", MedicalReport::TYPE_BEFORE)->first();
|
||||
if (empty($report)) {// 没有方案前报告
|
||||
MedicalReport::create([
|
||||
"user_id"=>$user->id,
|
||||
"type"=>MedicalReport::TYPE_BEFORE,
|
||||
"content"=>$log->content,
|
||||
"medical_date"=>date("Y-m-d"),
|
||||
"desc"=>"技术导入数据",
|
||||
"anomaly_type"=>1
|
||||
]);
|
||||
}
|
||||
if ($report->desc != "技术导入数据") {
|
||||
$name_arr2[] = $log->name;
|
||||
}
|
||||
|
||||
|
||||
} else {// 用户不存在
|
||||
$other_num++;
|
||||
$name_arr[] = $log->name;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info("用户数量:{$user_num}");
|
||||
$this->info("非用户数量:{$other_num}");
|
||||
$this->info("非用户名称:".json_encode($name_arr,JSON_UNESCAPED_UNICODE));
|
||||
$this->info("已填过用户名称:".json_encode($name_arr2,JSON_UNESCAPED_UNICODE));
|
||||
|
||||
}
|
||||
|
||||
public function importReport()
|
||||
{
|
||||
|
||||
// $dir = storage_path("health");
|
||||
// $sub_dirs = glob($dir . '/*');
|
||||
$dir = "medical_reports/health/";
|
||||
$sub_dirs = UploadService::getOssDir($dir);
|
||||
foreach ($sub_dirs as $index => $sub_dir) {
|
||||
$this->info("第{$index}位");
|
||||
$arr = explode("/", $sub_dir);
|
||||
$name = $arr[count($arr)-2];
|
||||
if (empty($name)) dd($sub_dir);
|
||||
$log = DB::table("health_reports")->where("name", $name)->first();
|
||||
if ($log) continue;
|
||||
$files = $sub_dirs = UploadService::getOssFile($sub_dir);
|
||||
$urls = [];
|
||||
if (count($files) == 0) {
|
||||
$this->info($sub_dir);
|
||||
dd($index);
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
$this->info($file);
|
||||
if (strpos($file, ".pdf")) {
|
||||
dd($index);
|
||||
}
|
||||
$urls[] = "https://images.health.ufutx.com/".$file;
|
||||
}
|
||||
DB::table(table: "health_reports")->insert(["name"=>$name, "content"=>json_encode($urls)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
app/Console/Commands/MakeWorkUserQrcode.php
Normal file
49
app/Console/Commands/MakeWorkUserQrcode.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\UploadService;
|
||||
use App\Models\ServiceUser;
|
||||
use Illuminate\Console\Command;
|
||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
|
||||
class MakeWorkUserQrcode extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'qrcode:bindWork';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ServiceUser::whereNull('bind_work_qrcode')->chunk(100, function ($users){
|
||||
foreach ($users as $user) {
|
||||
$url = config('app.url').'/api/h5/user/work/auth?service_user_id='.$user->id;
|
||||
$name = time().uniqid().'work_qrcode.png';
|
||||
$path = storage_path("qrcode/$name");
|
||||
QrCode::format('png')->margin(1)->size(300)->generate($url, $path);
|
||||
$pic = '';
|
||||
if (is_file($path)) {
|
||||
$pic = UploadService::uploadFile($path);
|
||||
unlink($path);
|
||||
}
|
||||
ServiceUser::where('id', $user->id)->update(['bind_work_qrcode'=>$pic]);
|
||||
}
|
||||
});
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
84
app/Console/Commands/MedicalReportNotice.php
Normal file
84
app/Console/Commands/MedicalReportNotice.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\DmaProcessLog;
|
||||
use App\Models\MedicalReport;
|
||||
use App\Models\Order;
|
||||
use App\Facades\CommonService;
|
||||
use App\Models\OtherHealthFile;
|
||||
use App\Models\ServiceRole;
|
||||
use App\Services\ChatService;
|
||||
use App\Facades\TaskService;
|
||||
use cccdl\yunxin_sdk\Im\Msg;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
class MedicalReportNotice extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'order:finished:medical_report';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Log::info("复检报告提醒提醒");
|
||||
$nowDate = date("Y-m-d");
|
||||
$orders = Order::whereDoesntHave("afterMedicalReport")->where("service_status", "FINISHED")->get();
|
||||
foreach ($orders as $order) {
|
||||
$log_at = DmaProcessLog::where("order_id", $order->id)->where("key_name", "mark_order_finish")->orderBy("id", "desc")->value("created_at");
|
||||
if (empty($log_at))
|
||||
continue;
|
||||
$log_at = $log_at->toDateString();
|
||||
$day = CommonService::diffDays($nowDate, $log_at);
|
||||
Log::info("订单id:" . $order->id . " day=" . $day);
|
||||
if ($day == 35) {
|
||||
// $imMsg = new Msg(config('chat.im.app_id'), config('chat.im.app_secret'));
|
||||
// $imMsg->sendMsg(make_wangyiyun_accid($order->group->owner_id), 1, $order->group->im_chat_id, 0, json_encode([
|
||||
// 'msg' => "尊敬的【{$order->name}】:
|
||||
|
||||
// 您好!您的健康方案已结束一段时间,我们始终关注您的身体状况。为了确保您的健康持续得到有效管理,建议您近期安排一次身体复查,并将报告提交至本群。我们期待了解您的最新健康状况,以便为您提供更精准的建议和支持。
|
||||
|
||||
// 感谢您的理解与配合!
|
||||
|
||||
// 祝您健康愉快!"
|
||||
// ]));
|
||||
|
||||
|
||||
|
||||
} elseif ($day == 23 || $day == 26 || $day == 29) {
|
||||
// $theme = "用户【" . $order->name . "】的群,复检倒计时7天!
|
||||
// 请跟进【" . $order->name . "】上传【方案后复检报告】,请所有服务人员即刻跟进,务必确保本周内100%完成";
|
||||
|
||||
$file = OtherHealthFile::where("user_id", $order->user_id)->where("type", 1)->first();
|
||||
$report = MedicalReport::where("user_id", $order->user_id)->where("order_id", $order->id)->where("type", 1)->first();
|
||||
if (empty($file) && empty($report)) {
|
||||
$theme = "请提醒用户【" . $order->name . "】上传复检报告";
|
||||
TaskService::AddTask(0, 0, $theme, [1, 2, 3], $order->id);
|
||||
|
||||
$chatService = new ChatService();
|
||||
$chatService->sendImMsgUserToUser($order->id, '系统通知', $theme, '', '', [ServiceRole::MAIN_COACH, ServiceRole::COACH, ServiceRole::CUSTOMER]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
224
app/Console/Commands/OrderSchemeRemainMsg.php
Normal file
224
app/Console/Commands/OrderSchemeRemainMsg.php
Normal file
@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\GuideService;
|
||||
use App\Facades\TaskService;
|
||||
use App\Facades\WechatService;
|
||||
use App\Models\DmaProcessLog;
|
||||
use App\Models\Food;
|
||||
use App\Models\Guide;
|
||||
use App\Models\GuideScheme;
|
||||
use App\Models\Order;
|
||||
use App\Models\ServiceRole;
|
||||
use App\Models\ServiceRoleOrder;
|
||||
use App\Models\ServiceUser;
|
||||
use App\Services\ChatService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class OrderSchemeRemainMsg extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'order:scheme:remain:msg {--order_id=}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '方案营养素余量通知';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$order_id = $this->option('order_id');
|
||||
// 需要检查的餐单方案
|
||||
$schemes = $this->getStartingSchemes($order_id);
|
||||
// 检查方案中的营养素是否预警
|
||||
foreach ($schemes as $scheme) {
|
||||
$msg = $this->rateResult($scheme);
|
||||
Log::info($msg);
|
||||
$this->info($msg);
|
||||
if ($msg) {
|
||||
$chatService = new ChatService();
|
||||
$chatService->sendImMsgUserToUser($scheme->order_id, '系统通知', $msg, 'https://image.fulllinkai.com/202403/29/dea3e0c27107cdf178635d2a41199e5e.png', 'yfheal://app/push/IMGroup', [ServiceRole::MAIN_COACH, ServiceRole::COACH, ServiceRole::CUSTOMER]);
|
||||
}
|
||||
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getStartingSchemes($order_id)
|
||||
{
|
||||
$order_ids = Order::where('status', 'STARTING')->where('user_id', '<>', 0);
|
||||
if ($order_id) {
|
||||
$order_ids = $order_ids->where("id", $order_id);
|
||||
}
|
||||
$order_ids = $order_ids->select('id')->pluck('id')->toArray();
|
||||
$schemes = GuideScheme::whereIn('order_id', $order_ids)->select('order_id', 'scheme')->select('scheme', 'order_id')->get();
|
||||
|
||||
return $schemes;
|
||||
}
|
||||
|
||||
public function rateResult($scheme)
|
||||
{
|
||||
$order = Order::find($scheme->order_id);
|
||||
$msg = "";
|
||||
// 当天营养素和使用量
|
||||
$guideFoods = $this->getGuideFood($scheme);
|
||||
// 方案中所有营养素和份数
|
||||
$scheme = $scheme->scheme;
|
||||
foreach ($guideFoods as $food) {
|
||||
// 营养素信息
|
||||
$foodObj = Food::find($food["id"]);
|
||||
if (empty($foodObj))
|
||||
continue;
|
||||
// 总量 = 份数 * 量
|
||||
$schemeObj = collect($scheme)->where("id", $food["id"])->first();
|
||||
if (empty($schemeObj))
|
||||
continue;
|
||||
$num = $schemeObj->num;
|
||||
$total_num = round($num * $foodObj->quantity);
|
||||
// 已使用的量
|
||||
$use_num = $this->getUseGuideNum($order->id, $foodObj->id);
|
||||
// 余量
|
||||
$remain_num = round($total_num - $use_num);
|
||||
if ($remain_num < 0) {
|
||||
$remain_num = 0;
|
||||
}
|
||||
// 比例
|
||||
$rate = round($remain_num / $total_num, 2);
|
||||
// 是否超过10%
|
||||
if ($rate < 0.1) {
|
||||
Log::info("总量:" . $total_num . " 使用量:" . $use_num . " 剩余量:" . $remain_num . " 剩余比例:" . $rate);
|
||||
$msg .= '营养素id:' . $foodObj->id . ' 营养素:' . $foodObj->name . ' 余量:' . $remain_num . " 剩余率:" . $rate . '%' . "\n";
|
||||
}
|
||||
}
|
||||
$msg_title = '订单号:' . $order->trade_no . "\n" . "餐单日期:" . date("Y-m-d") . "\n" . '用户:' . $order->name . "\n" . '电话:' . $order->mobile . "\n";
|
||||
if ($msg) {
|
||||
$msg = $msg_title . $msg;
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
|
||||
public function getUseGuideNum($order_id, $food_id)
|
||||
{
|
||||
$num = 0;
|
||||
$guides = Guide::where("order_id", $order_id)->where("phase_date", "<=", date("Y-m-d"))->get();
|
||||
foreach ($guides as $guide) {
|
||||
$menu = json_decode($guide->menu);
|
||||
foreach ($menu as $item) {
|
||||
foreach ($item->nutrient as $nutrient) {
|
||||
if ($nutrient->id != $food_id)
|
||||
continue;
|
||||
$num += $nutrient->oneNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $num;
|
||||
}
|
||||
|
||||
public function getGuideFood($scheme)
|
||||
{
|
||||
Log::info("获取当天餐单营养素订单:" . $scheme->order_id);
|
||||
$idArr = [];
|
||||
$array = [];
|
||||
// 餐单日历
|
||||
$guide = Guide::where("order_id", $scheme->order_id)->where("phase_date", date("Y-m-d"))->first();
|
||||
if (empty($guide))
|
||||
return $array;
|
||||
$menu = json_decode($guide->menu);
|
||||
foreach ($menu as $item) {
|
||||
foreach ($item->nutrient as $nutrient) {
|
||||
|
||||
if (in_array($nutrient->id, $idArr)) {
|
||||
$array[$nutrient->title] = ["id" => $nutrient->id, "title" => $nutrient->title, "num" => $nutrient->oneNum + $array[$nutrient->title]["num"]];
|
||||
} else {
|
||||
$idArr[] = $nutrient->id;
|
||||
$array[$nutrient->title] = ["id" => $nutrient->id, "title" => $nutrient->title, "num" => $nutrient->oneNum];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
public function backup()
|
||||
{
|
||||
$order_ids = Order::where('status', 'STARTING')->where('user_id', '<>', 0)->select('id')->pluck('id')->toArray();
|
||||
|
||||
$schemes = GuideScheme::whereIn('order_id', $order_ids)->select('order_id', 'scheme')->pluck('scheme', 'order_id');
|
||||
$guides = Guide::whereIn('order_id', $order_ids)->orderBy('phase_date', 'asc')->get();
|
||||
$new_guides = [];
|
||||
foreach ($guides as $guide) {
|
||||
$new_guides[$guide->order_id]['guides'][] = $guide;
|
||||
|
||||
if (!isset($new_guides[$guide->order_id]['scheme'])) {
|
||||
$new_guides[$guide->order_id]['scheme'] = [];
|
||||
}
|
||||
if (isset($schemes[$guide->order_id])) {
|
||||
$new_guides[$guide->order_id]['scheme'] = json_decode($schemes[$guide->order_id]);
|
||||
}
|
||||
}
|
||||
|
||||
$order_scheme = [];
|
||||
foreach ($new_guides as $order_id => $item) {
|
||||
[$guides_arr, $scheme_food, $flag, $msg] = GuideService::getQuantity($item['scheme'], $item['guides']);
|
||||
if (empty($msg)) {
|
||||
continue;
|
||||
}
|
||||
$order_scheme[] = $msg;
|
||||
}
|
||||
//重组数组
|
||||
$new_scheme = [];
|
||||
foreach ($order_scheme as $sub_array) {
|
||||
foreach ($sub_array as $item) {
|
||||
$new_scheme[] = $item;
|
||||
}
|
||||
}
|
||||
//遍历数据
|
||||
$orderIds = [];
|
||||
foreach ($new_scheme as $value) {
|
||||
if ($value['rate'] > 20) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($value["order_id"], $orderIds))
|
||||
continue;
|
||||
$orderIds[] = $value["order_id"];
|
||||
$order = Order::where('id', $value['order_id'])->first();
|
||||
// $service_user_ids = ServiceRoleOrder::where('order_id',$value['order_id'])->distinct()->pluck('user_id');
|
||||
// $work_user_ids = ServiceUser::whereIn('user_id',$service_user_ids)->pluck('work_user_id');
|
||||
|
||||
$message = '订单号:' . $order->trade_no . "\n" . '餐单日期:' . $value['phase_date'] . "\n" . '餐单类型:' . $value['phase_title'] . "\n" . '用户:' . $order->name . "\n" . '电话:' . $order->mobile . "\n" . '营养素:' . $value['title'] . "\n" . '余量:' . $value['remain_quantity'] . "\n" . "剩余率:" . $value['rate'] . '%';
|
||||
// foreach ($work_user_ids as $work){
|
||||
// if(!$work){
|
||||
// continue;
|
||||
// }
|
||||
// WechatService::sendWorkMessage($work,'text',['content'=>$message]);
|
||||
// }
|
||||
$chatService = new ChatService();
|
||||
$chatService->sendImMsgUserToUser($order->id, '系统通知', $message, 'https://image.fulllinkai.com/202403/29/dea3e0c27107cdf178635d2a41199e5e.png', 'yfheal://app/push/IMGroup', [ServiceRole::MAIN_COACH, ServiceRole::COACH, ServiceRole::CUSTOMER]);
|
||||
|
||||
}
|
||||
|
||||
foreach ($orderIds as $orderId) {
|
||||
$order = Order::where('id', $orderId)->first();
|
||||
DmaProcessLog::addUserProcessLog($order->user_id ?? 0, $order->id ?? 0, 1, "lack_nutrient", "用户营养素余量不足", 0, 5);
|
||||
DmaProcessLog::addUserProcessLog($order->user_id ?? 0, $order->id ?? 0, 1, "send_lack_nutrient", "系统发送营养素余量通知", 0, 5);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
115
app/Console/Commands/RemindDailyStep.php
Normal file
115
app/Console/Commands/RemindDailyStep.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\ChatService;
|
||||
use App\Models\Band;
|
||||
use App\Models\BatteryHistory;
|
||||
use App\Models\DailyStep;
|
||||
use App\Models\Guide;
|
||||
use App\Models\GuideTemplate;
|
||||
use App\Models\Order;
|
||||
use App\Models\ServiceRole;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RemindDailyStep extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'remind:daily_step';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// 正在进行中的订单
|
||||
$orders = Order::whereHas("guides", function ($sql) {
|
||||
$sql->where("phase_date", ">=", date("Y-m-d", strtotime("-1 day")));
|
||||
})->where("status", Order::STARTING_STATUS)->get();
|
||||
foreach ($orders as $order) {
|
||||
// 用户的步数
|
||||
$step = $this->getDailyStep($order->user_id);
|
||||
// 餐单模板步数
|
||||
$templateStep = $this->getTemplateStep($order->id);
|
||||
if (empty($templateStep))
|
||||
continue;
|
||||
// 电量
|
||||
list($timestamp, $battery_percentage) = $this->getBatteryInfo($order->user_id);
|
||||
// 获取消息内容
|
||||
$noticeMsg = $this->getNoticeMsg((string) $order->name, $step, $templateStep, (int) $battery_percentage, $timestamp);
|
||||
// 发送消息
|
||||
ChatService::sendImMsgUserToUser($order->id, "系统通知", $noticeMsg, "", "", [ServiceRole::MAIN_COACH, ServiceRole::COACH, ServiceRole::CUSTOMER]);
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
public function getDailyStep(int $userId): int
|
||||
{
|
||||
$time = date("Y-m-d", strtotime("-1 day"));
|
||||
$step = DailyStep::where(["user_id" => $userId, "date" => $time])->value("step");
|
||||
return $step ?: 0;
|
||||
}
|
||||
|
||||
public function getTemplateStep(int $orderId): int
|
||||
{
|
||||
$step = 0;
|
||||
$time = date("Y-m-d", strtotime("-1 day"));
|
||||
$guide = Guide::where(["order_id" => $orderId, "phase_date" => $time])->first();
|
||||
if (empty($guide))
|
||||
return $step;
|
||||
switch ($guide->phase_title) {
|
||||
case "装修日":
|
||||
$type = 0;
|
||||
break;
|
||||
case "准备日":
|
||||
$type = 1;
|
||||
break;
|
||||
case "清洁日":
|
||||
$type = 2;
|
||||
break;
|
||||
default:
|
||||
return $step;
|
||||
}
|
||||
$step = GuideTemplate::where(["order_id" => $orderId, "type" => $type])->value("step");
|
||||
return $step ?: 0;
|
||||
}
|
||||
|
||||
public function getBatteryInfo(int $userId): array
|
||||
{
|
||||
$timestamp = $battery_percentage = "";
|
||||
$band = Band::where(["user_id" => $userId, "status" => 1])->first();
|
||||
if (empty($band))
|
||||
return [$timestamp, $battery_percentage];
|
||||
|
||||
$log = BatteryHistory::where(["band_id" => $band->id])->orderByDesc("timestamp")->first();
|
||||
if (empty($log))
|
||||
return [$timestamp, $battery_percentage];
|
||||
|
||||
return [$log->timestamp, $log->battery_percentage];
|
||||
}
|
||||
|
||||
public function getNoticeMsg(string $name, int $step, int $templateStep, int $battery_percentage, string $timestamp): string
|
||||
{
|
||||
$status = ($step >= $templateStep) ? "完成了" : "未完成";
|
||||
$msg = "用户【" . $name . "】" . $status . "走路目标:实际步数:" . $step . "步, 目标步数:" . $templateStep . "步 \n";
|
||||
if ($battery_percentage) {
|
||||
$msg .= "最后一次数据同步时间:" . $timestamp . " (当时电量:" . $battery_percentage . "%)";
|
||||
} else {
|
||||
$msg .= "没有最近一次手环电量同步信息";
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
52
app/Console/Commands/RemoveFatLog.php
Normal file
52
app/Console/Commands/RemoveFatLog.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\SendTemplateNotice;
|
||||
use App\Models\Collaborator;
|
||||
use App\Models\FatLog;
|
||||
use App\Models\NewFatLog;
|
||||
use App\Models\Restaurant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RemoveFatLog extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'remove:fat_log';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '去重体脂秤信息';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('去重体脂秤信息');
|
||||
//接收参数
|
||||
NewFatLog::groupBy(["user_id", "created_at", "type"])->having("count", ">", 1)->selectRaw("user_id, created_at, type, count(*) as count")->orderBy("count", "desc")->chunk(100,function($logs) {
|
||||
$count = $logs->count();
|
||||
$this->info("总数:".$count);
|
||||
foreach($logs as $log) {
|
||||
$first_log = NewFatLog::where("user_id", $log->user_id)->where("type", $log->type)->where("created_at", $log->created_at->toDateTimeString())->first();
|
||||
if ($first_log) {
|
||||
NewFatLog::where("id", "!=", $first_log->id)->where("user_id", $log->user_id)->where("type", $log->type)->where("created_at", $log->created_at->toDateTimeString())->delete();
|
||||
$count--;
|
||||
}
|
||||
$this->info("剩余:".$count);
|
||||
}
|
||||
});
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
70
app/Console/Commands/SendEvaluateRestaurantMsg.php
Normal file
70
app/Console/Commands/SendEvaluateRestaurantMsg.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\SendTemplateNotice;
|
||||
use App\Models\Collaborator;
|
||||
use App\Models\Restaurant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendEvaluateRestaurantMsg extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:evaluate:restaurant:msg {diet_type}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '发送评价通知';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Log::info('SendEvaluateRestaurantMsg start');
|
||||
//接收参数
|
||||
$diet_type = $this->argument('diet_type');
|
||||
|
||||
$date = date('Y-m-d');
|
||||
//查看当天已定餐人员,不重复发送通知
|
||||
$today_user = Restaurant::where('date', $date)
|
||||
->where('status', Restaurant::STATUS_TAKE)
|
||||
->where('diet_type', $diet_type)
|
||||
->groupBy('user_id')
|
||||
->pluck('user_id')
|
||||
->toArray();
|
||||
|
||||
foreach ($today_user as $user_id) {
|
||||
$open_id = Collaborator::where('user_id', $user_id)->value('openid');
|
||||
|
||||
Log::info('SendEvaluateRestaurantMsg:user_id:' . $user_id . "|open_id:" . $open_id);
|
||||
// $open_id = 'oHGap6F1HR-5q-JdRKrgb6DwztWQ';
|
||||
if (!$open_id) {
|
||||
continue;
|
||||
}
|
||||
//发送模板消息通知 url = /api/h5/wechat/user/auth?target_path=cateringApplyFor
|
||||
$params = [
|
||||
'touser' => $open_id,
|
||||
'template_id' => config('wechat.tpls.evaluate_restaurant'),
|
||||
'url' => config('app.url') . '/order/#/cateringApplyFor',
|
||||
'data' => [
|
||||
'thing2' => ['value' => '订餐评价'],
|
||||
'time6' => ['value' => $date],
|
||||
]
|
||||
];
|
||||
SendTemplateNotice::dispatch($params)->onQueue('health');
|
||||
}
|
||||
Log::info('SendEvaluateRestaurantMsg end');
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
126
app/Console/Commands/SendImMsg.php
Normal file
126
app/Console/Commands/SendImMsg.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\TaskService;
|
||||
use App\Jobs\SendTemplateNotice;
|
||||
use App\Models\Collaborator;
|
||||
use App\Models\DmaProcess;
|
||||
use App\Models\DmaProcessLog;
|
||||
use App\Models\Group;
|
||||
use App\Models\Guide;
|
||||
use App\Models\Order;
|
||||
use App\Models\Restaurant;
|
||||
use App\Models\ServiceRole;
|
||||
use App\Services\ChatService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
class SendImMsg extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:im:msg {type}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '发送网易云消息';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Log::info('SendImMsg start');
|
||||
//接收参数
|
||||
$type = $this->argument('type');
|
||||
$date = date('Y-m-d');
|
||||
$time = time();
|
||||
//超过5点没发送,发送单对单消息给到副教练
|
||||
$chatService = new ChatService();
|
||||
if ($type == 1) {
|
||||
Log::info('SendImMsg start1');
|
||||
//查看当前日期设置的餐单,并查看当天有没有发送过消息通知(redis)
|
||||
$date = date("Y-m-d", strtotime("+1 day"));
|
||||
$guides = Guide::with("order")->where('phase_date', $date)->where("send_status", 0)->get();
|
||||
// $key = Guide::SEND_GUIDE_MSG;
|
||||
foreach ($guides as $guide) {
|
||||
// $is_send = Redis::get($key.$guide->id);
|
||||
// if($is_send){
|
||||
// continue;
|
||||
// }
|
||||
if ($guide->send_status) {
|
||||
continue;
|
||||
}
|
||||
// 订单状态非开始中 跳过
|
||||
if ($guide->order && $guide->order->status != "STARTING") {
|
||||
continue;
|
||||
}
|
||||
$group = Group::where('order_id', $guide->order_id)->first();
|
||||
if (!$group || !$group->im_chat_id) {
|
||||
continue;
|
||||
}
|
||||
$params = [];
|
||||
$params['chat_id'] = $group->im_chat_id;
|
||||
$params['group_name'] = $group->name;
|
||||
$chatService->sendImMsgUserToUser($guide->order_id, '系统通知', ($group->order->name ?? "") . '今日发送餐单已超时,请尽快发送', 'https://image.fulllinkai.com/202403/29/dea3e0c27107cdf178635d2a41199e5e.png', 'yfheal://app/push/IMGroup', [ServiceRole::MAIN_COACH, ServiceRole::COACH, ServiceRole::CUSTOMER], $params);
|
||||
DmaProcessLog::addUserProcessLog($group->order->user_id ?? 0, $guide->order_id ?? 0, 1, "send_delay_date_guide", "系统发送餐单超时通知", 0, 5);
|
||||
|
||||
$theme = "请发送「用户" . $guide->order->name . "」明天的餐单";
|
||||
$processKey = "send_date_guide";
|
||||
$start_date = date("Y-m-d");
|
||||
$end_date = date("Y-m-d", strtotime("+1 day"));
|
||||
$log = DmaProcessLog::where("order_id", $guide->order_id)->where("key_name", $processKey)->where("created_at", [$start_date, $end_date])->first();
|
||||
if (empty($log)) {
|
||||
TaskService::AddTask(0, 0, $theme, [2], $guide->order_id, "", "", "", $processKey);
|
||||
}
|
||||
}
|
||||
} elseif ($type == 2) {
|
||||
Log::info('SendImMsg start2');
|
||||
$guide_counts = Guide::groupBy('order_id')->selectRaw('order_id, COUNT(*) as count')->get();
|
||||
foreach ($guide_counts as $item) {
|
||||
if ($item->count != 21) {
|
||||
continue;
|
||||
}
|
||||
$order = Order::where('id', $item->order_id)->first();
|
||||
if ($order->status == "STARTING") {
|
||||
$chatService->sendImMsgUserToUser($item->order_id, '系统通知', '请所有服务人员与用户' . $order->name . '进行第二次视频通话', 'https://image.fulllinkai.com/202403/29/dea3e0c27107cdf178635d2a41199e5e.png', '', [ServiceRole::MAIN_COACH, ServiceRole::COACH, ServiceRole::CUSTOMER]);
|
||||
|
||||
// 待办事项-主教练
|
||||
$theme = "请邀请所有服务人员进行「用户" . $order->name . "」服务的第二次「视频通话」,并将相关视频链接转发给“友福服务”";
|
||||
TaskService::AddTask(0, 0, $theme, [1], $order->id);
|
||||
}
|
||||
}
|
||||
} elseif ($type == 3) {
|
||||
Log::info('SendImMsg start3');
|
||||
//查看最近前24小时,近半小时完成的订单
|
||||
$end_time = $time - 86400;
|
||||
$start_time = $end_time - 1800;
|
||||
$end_date = date('Y-m-d H:i:s', $end_time);
|
||||
$start_date = date('Y-m-d H:i:s', $start_time);
|
||||
$orders = Order::where('updated_at', '>=', $start_date)->where('updated_at', '<', $end_date)->where('status', 'FINISHED')->get();
|
||||
foreach ($orders as $order) {
|
||||
$chatService->sendImMsgUserToUser($order->id, '系统通知', '请所有服务人员与' . ($order->name ?? "") . '用户进行第三次视频通话', 'https://image.fulllinkai.com/202403/29/dea3e0c27107cdf178635d2a41199e5e.png', '', [ServiceRole::MAIN_COACH, ServiceRole::COACH, ServiceRole::CUSTOMER]);
|
||||
|
||||
// 待办事项-主教练
|
||||
$theme = "请邀请所有服务人员进行「用户" . $order->name . "」服务的第三次「视频通话」,并将相关视频链接转发给“友福服务”";
|
||||
TaskService::AddTask(0, 0, $theme, [1], $order->id);
|
||||
|
||||
}
|
||||
} elseif ($type == 4) {
|
||||
Log::info('SendImMsg start4');
|
||||
|
||||
}
|
||||
Log::info('SendImMsg end');
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
107
app/Console/Commands/SendReserveRestaurantMsg.php
Normal file
107
app/Console/Commands/SendReserveRestaurantMsg.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\SendTemplateNotice;
|
||||
use App\Models\Collaborator;
|
||||
use App\Models\Restaurant;
|
||||
use App\Models\Wechat;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
class SendReserveRestaurantMsg extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:reserve:restaurant:msg {diet_type}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '发送订餐通知';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Log::info('SendReserveRestaurantMsg start');
|
||||
//接收参数
|
||||
$diet_type = $this->argument('diet_type');
|
||||
|
||||
// 获取当前日期的星期几
|
||||
$day_of_week = date('w');
|
||||
|
||||
if ($day_of_week == 0) {
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
//获取所有订餐人员
|
||||
$list = Restaurant::whereIn('status', [Restaurant::STATUS_PAY, Restaurant::STATUS_WAIT, Restaurant::STATUS_FINISHED, Restaurant::STATUS_EVALUATE])
|
||||
->groupBy('user_id')
|
||||
->pluck('user_id')
|
||||
->toArray();
|
||||
|
||||
//查看用户是否设置开关
|
||||
$redis_switch_key = Restaurant::REDIS_SEND_SWITCH;
|
||||
$switch_uids = Redis::hgetall($redis_switch_key);
|
||||
//查看哪些用户关闭了订餐提醒
|
||||
$uids = [];
|
||||
foreach ($switch_uids as $key => $value) {
|
||||
if ($value == 1) {
|
||||
continue;
|
||||
}
|
||||
$uids[] = $key;
|
||||
}
|
||||
//将所有历史订餐人员和设置关闭提醒的人取差集,如果已定餐人员不设置关闭,默认发送通知
|
||||
$diff = array_diff($list, $uids);
|
||||
|
||||
$date = date('Y-m-d');
|
||||
//查看当天已定餐人员,不重复发送通知
|
||||
$today_user = Restaurant::where('date', $date)
|
||||
->whereIn('status', [Restaurant::STATUS_PAY, Restaurant::STATUS_WAIT, Restaurant::STATUS_FINISHED, Restaurant::STATUS_EVALUATE])
|
||||
->where('diet_type', $diet_type)
|
||||
->groupBy('user_id')
|
||||
->pluck('user_id')
|
||||
->toArray();
|
||||
$user_ids = array_diff($diff, $today_user);
|
||||
|
||||
foreach ($user_ids as $user_id) {
|
||||
$open_id = Wechat::where('user_id', $user_id)->value('openid');
|
||||
Log::info('SendReserveRestaurantMsg:user_id:' . $user_id . "|open_id:" . $open_id);
|
||||
// $open_id = 'oHGap6F1HR-5q-JdRKrgb6DwztWQ';
|
||||
if (!$open_id) {
|
||||
continue;
|
||||
}
|
||||
$diet = '午餐订餐';
|
||||
$reserve_time = '09:00~' . Restaurant::LUNCH_RESERVE_TIME;
|
||||
if ($diet_type == Restaurant::DIET_TYPE_DINNER) {
|
||||
$diet = '晚餐订餐';
|
||||
$reserve_time = '14:00~' . Restaurant::DINNER_RESERVE_TIME;
|
||||
}
|
||||
//发送模板消息通知 url = /api/h5/wechat/user/auth?target_path=cateringApplyFor
|
||||
$params = [
|
||||
'touser' => $open_id,
|
||||
'template_id' => config('wechat.tpls.reserve_restaurant'),
|
||||
'url' => config('app.url') . '/order/#/cateringApplyFor',
|
||||
'data' => [
|
||||
'thing8' => ['value' => '友福健康'],
|
||||
'thing12' => ['value' => '订餐提醒'],
|
||||
'thing14' => ['value' => $diet],
|
||||
'time13' => ['value' => $reserve_time],
|
||||
]
|
||||
];
|
||||
SendTemplateNotice::dispatch($params)->onQueue('health');
|
||||
}
|
||||
Log::info('SendReserveRestaurantMsg end');
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
59
app/Console/Commands/StepSubmitNotice.php
Normal file
59
app/Console/Commands/StepSubmitNotice.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\WechatService;
|
||||
use App\Jobs\SendSubscribeMessage;
|
||||
use App\Models\User;
|
||||
use App\Models\Wechat;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class StepSubmitNotice extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'step:submit:notice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '运动步数上传提醒';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$user_ids = User::query()->pluck('id')->toArray();
|
||||
if (!$user_ids) {
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
foreach ($user_ids as $user_id) {
|
||||
$openid = Wechat::query()->where('user_id', $user_id)->where('type', 'mp')->value('openid');
|
||||
if (!$openid) {
|
||||
continue;
|
||||
}
|
||||
$param = [
|
||||
'touser' => $openid,
|
||||
'template_id' => config('wechat.sub_tpls.step_submit_notice'),
|
||||
'page' => 'pages/user/motionRecord',
|
||||
'data' => [
|
||||
'thing1' => ['value' => '今天的走路步数记得上传记录哦'],
|
||||
'time2' => ['value' => date('Y-m-d')],
|
||||
'thing3' => ['value' => '您的健康是我们最关心的,请注意安全运动'],
|
||||
]
|
||||
];
|
||||
SendSubscribeMessage::dispatch($param)->onQueue('health');
|
||||
// WechatService::sendSubscribeMessage($param);
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
51
app/Console/Commands/SyncLotteryMember.php
Normal file
51
app/Console/Commands/SyncLotteryMember.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\HttpService;
|
||||
use App\Models\LotteryMember;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SyncLotteryMember extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'sync:lottery_member ';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Log::info("同步经销商抽奖名单");
|
||||
$url = config('app.shop_url') . "admin/agent/lotto/codes?export=1";
|
||||
$res = HttpService::getData($url);
|
||||
$members = $res['data'];
|
||||
foreach ($members as $member) {
|
||||
$user_id = 0;
|
||||
if ($member['user']['accid']) {
|
||||
$user_id = explode('_', $member['user']['accid'])[1];
|
||||
}
|
||||
$lottery_member = LotteryMember::where('lottery_id', 1)->where('code', $member['code'])->first();
|
||||
if (empty($lottery_member)) {
|
||||
LotteryMember::create(['user_id'=>$user_id, 'lottery_id'=>1, 'name'=>$member['user']['nickname'], 'mobile'=>$member['user']['mobile'],
|
||||
'code'=>$member['code']
|
||||
]);
|
||||
}
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
46
app/Console/Commands/TestSleepData.php
Normal file
46
app/Console/Commands/TestSleepData.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TestSleepData extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'test:sleep_data';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
set_time_limit(0);
|
||||
DB::table("band_sleeps_202405")->orderBy("id")->chunk(100, function ($sleeps) {
|
||||
foreach ($sleeps as $sleep) {
|
||||
$obj = DB::table("band_sleeps_202405_1")
|
||||
->where('user_id', $sleep->user_id)
|
||||
->where('band_id', $sleep->band_id)
|
||||
->where("date", $sleep->date)->first();
|
||||
if (empty($obj)) {
|
||||
DB::table("band_sleeps_202405_1")->insert((array) $sleep);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
57
app/Console/Commands/UpdateGroupChatName.php
Normal file
57
app/Console/Commands/UpdateGroupChatName.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\WechatService;
|
||||
use App\Models\Group;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateGroupChatName extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'group:chatName';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Group::whereNull('chat_name')->whereNotNull('chat_id')->chunk(100, function ($groups) {
|
||||
foreach ($groups as $group) {
|
||||
Log::info("UpdateGroupChatName group_id: $group->id");
|
||||
$res = WechatService::groupChat($group->chat_id, 1);
|
||||
if ($res) {
|
||||
Log::info(json_encode($res));
|
||||
if ($res->errcode == 0 && $res->group_chat && $res->group_chat->name) {//成功
|
||||
$group->update(['chat_name' => $res->group_chat->name]);
|
||||
continue;
|
||||
|
||||
} elseif ($res->errcode == 86003 || $res->errcode == 49008) {//企业群不存在,解除与系统群关系
|
||||
$group->update(['chat_id' => null]);
|
||||
continue;
|
||||
}
|
||||
if ($res->errcode != 0)
|
||||
throw new \Exception($group->chat_id . "----" . $res->errcode . '----' . $res->errmsg);
|
||||
}
|
||||
if (empty($res))
|
||||
throw new \Exception($group->chat_id . "请求失败");
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
});
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
51
app/Console/Commands/UpdateMeetingRoom.php
Normal file
51
app/Console/Commands/UpdateMeetingRoom.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\MeetRoom;
|
||||
use App\Models\MeetRoomReserve;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UpdateMeetingRoom extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'update:meeting:room';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '更新会议室状态';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$reserve_list = MeetRoomReserve::whereIn('status',[0,1,2])->get();
|
||||
//获取当前时间
|
||||
$time_minute = date('Y-m-d H:i');
|
||||
foreach ($reserve_list as $item){
|
||||
$reserve = MeetRoomReserve::where('id',$item->id)->first();
|
||||
$meet_room = MeetRoom::where('id',$reserve->room_id)->first();
|
||||
if($time_minute>= $reserve->start_time && $time_minute <= $reserve->end_time){
|
||||
$reserve->status = 2;
|
||||
$meet_room->status = 1;
|
||||
}
|
||||
if($reserve->end_time < $time_minute){
|
||||
$reserve->status = 3;
|
||||
$meet_room->status = 0;
|
||||
}
|
||||
$reserve->save();
|
||||
$meet_room->save();
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
43
app/Console/Commands/UpdateRestaurantDate.php
Normal file
43
app/Console/Commands/UpdateRestaurantDate.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Facades\CommonService;
|
||||
use App\Models\MeetRoom;
|
||||
use App\Models\MeetRoomReserve;
|
||||
use App\Models\RestaurantDate;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateRestaurantDate extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'update:restaurant:date';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '当天修改日历';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$date = date('Y-m-d'); // 当前日期
|
||||
$day_of_week = date('w', strtotime($date));
|
||||
Log::info("update_restaurant_date:".$date."|week:".$day_of_week);
|
||||
if ($day_of_week != 0) {
|
||||
RestaurantDate::where('date',$date)->update(['status'=>0]);
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
65
app/Console/Commands/UpdateRestaurantStatus.php
Normal file
65
app/Console/Commands/UpdateRestaurantStatus.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Restaurant;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UpdateRestaurantStatus extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'update:restaurant:status';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '更新餐饮状态';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$date = date('Y-m-d');
|
||||
$list = Restaurant::where('date',$date)
|
||||
->whereIn('status',[Restaurant::STATUS_PAY,Restaurant::STATUS_WAIT])
|
||||
->select('id','date','status','diet_type')->get();
|
||||
$hour = date('H:i');
|
||||
foreach ($list as $item){
|
||||
$restaurant = Restaurant::where('id',$item->id)->first();
|
||||
//如果是午餐,则走一下逻辑
|
||||
if($item->diet_type == Restaurant::DIET_TYPE_LUNCH){
|
||||
//如果状态是已经预定和已支付,到时间修改为等待出餐 10:30后
|
||||
if(in_array($item->status,[Restaurant::STATUS_PAY]) && $hour >= Restaurant::LUNCH_WAIT_TIME){
|
||||
$restaurant->status = Restaurant::STATUS_WAIT;
|
||||
}
|
||||
//如果等待出餐 ,12:00以后自动修改为已完成
|
||||
if(in_array($item->status,[Restaurant::STATUS_WAIT]) && $hour >= Restaurant::LUNCH_FINISH_TIME){
|
||||
$restaurant->status = Restaurant::STATUS_FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
//如果是晚餐,则走这里
|
||||
if($item->diet_type == Restaurant::DIET_TYPE_DINNER){
|
||||
//如果状态是已经预定和已支付,到时间修改为等待出餐 16:40后
|
||||
if(in_array($item->status,[Restaurant::STATUS_PAY]) && $hour >= Restaurant::DINNER_WAIT_TIME){
|
||||
$restaurant->status = Restaurant::STATUS_WAIT;
|
||||
}
|
||||
//如果等待出餐 ,18:00以后自动修改为已完成
|
||||
if(in_array($item->status,[Restaurant::STATUS_WAIT]) && $hour >= Restaurant::DINNER_FINISH_TIME){
|
||||
$restaurant->status = Restaurant::STATUS_FINISHED;
|
||||
}
|
||||
}
|
||||
$restaurant->save();
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
118
app/Console/Kernel.php
Normal file
118
app/Console/Kernel.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
//每日餐单通知
|
||||
// $schedule->command('guide:notice')->dailyAt('07:00');
|
||||
//每日餐单余量通知
|
||||
//每日餐单通知
|
||||
$schedule->command('order:scheme:remain:msg')->dailyAt('09:00');
|
||||
//生成绑定微信
|
||||
$schedule->command('qrcode:bindWork')->everyMinute();
|
||||
//更新微信群名称
|
||||
// $schedule->command('group:chatName')->everyMinute();
|
||||
//更新会议室状态
|
||||
$schedule->command('update:meeting:room')->everyMinute();
|
||||
//更新餐饮状态
|
||||
$schedule->command('update:restaurant:status')->everyMinute();
|
||||
//发送午餐餐饮订餐通知
|
||||
// $schedule->command('send:reserve:restaurant:msg',[0])->dailyAt('09:00');
|
||||
//发送晚餐餐饮订餐通知
|
||||
// $schedule->command('send:reserve:restaurant:msg',[1])->dailyAt('14:00');
|
||||
//发送午餐餐饮评价通知
|
||||
// $schedule->command('send:evaluate:restaurant:msg',[0])->dailyAt('13:00');
|
||||
//发送晚餐餐饮评价通知
|
||||
// $schedule->command('send:evaluate:restaurant:msg',[1])->dailyAt('19:00');
|
||||
//同步网易云用户
|
||||
$schedule->command('add:wang:yi:user')->everyMinute();
|
||||
//运动步数上传提醒
|
||||
$schedule->command('step:submit:notice')->dailyAt('19:00');
|
||||
//同步抽奖名单
|
||||
// $schedule->command('sync:lottery_member')->everyMinute();
|
||||
//生成日志表
|
||||
$schedule->command('table:access_logs')->quarterly();
|
||||
//生成睡眠数据表
|
||||
// $schedule->command('table:band_sleeps')->monthly();
|
||||
// //生成体温数据表
|
||||
// $schedule->command('table:band_temps')->monthly();
|
||||
// //生成心率数据表
|
||||
// $schedule->command('table:band_hrrests')->monthly();
|
||||
// //生成Hrv详细信息
|
||||
// $schedule->command('table:band_hrvs')->monthly();
|
||||
// //生成血氧数据表
|
||||
// $schedule->command('table:band_bloods')->monthly();
|
||||
// //生成综合详细信息
|
||||
// $schedule->command('table:band_syns')->monthly();
|
||||
// //生成睡眠数据表
|
||||
$schedule->command('table:band_origin_sleeps')->monthly();
|
||||
//生成体温数据表
|
||||
$schedule->command('table:band_origin_temps')->monthly();
|
||||
//生成心率数据表
|
||||
$schedule->command('table:band_origin_hrrests')->monthly();
|
||||
//生成Hrv详细信息
|
||||
$schedule->command('table:band_origin_hrvs')->monthly();
|
||||
//生成血氧数据表
|
||||
$schedule->command('table:band_origin_bloods')->monthly();
|
||||
//生成综合详细信息
|
||||
$schedule->command('table:band_origin_syns')->monthly();
|
||||
|
||||
//生成电量消耗数据
|
||||
$schedule->command('table:band_origin_battery')->monthly();
|
||||
|
||||
$schedule->command('create:restaurant:date')->monthlyOn(20, "01:00");
|
||||
$schedule->command('update:restaurant:date')->dailyAt("02:00");
|
||||
|
||||
//检测定期活动状态
|
||||
$schedule->command("check:regular_activity")->everyMinute();
|
||||
|
||||
//app网易云信消息通知
|
||||
$schedule->command('send:im:msg', [1])->dailyAt("18:00");
|
||||
$schedule->command('send:im:msg', [2])->dailyAt("10:00");
|
||||
$schedule->command('send:im:msg', [3])->everyThirtyMinutes();
|
||||
|
||||
// 方案结束后未填写问卷调查提醒
|
||||
$schedule->command('order:finished quesiotn_notice')->dailyAt("10:00");
|
||||
// 方案结束后未上传方案后身体照提醒通知
|
||||
$schedule->command('order:finished after_body_image')->dailyAt("10:00");
|
||||
// 方案结束后未上传方案后身体照提醒任务
|
||||
$schedule->command('order:finished after_body_image_task')->dailyAt("10:00");
|
||||
// 方案结束后提醒用户上传复检报告
|
||||
$schedule->command('order:finished:medical_report')->dailyAt("10:00");
|
||||
// 方案结束后提醒教练填写评估表
|
||||
$schedule->command('order:finished server_question_3')->dailyAt("10:00");
|
||||
$schedule->command('order:finished server_question_60')->dailyAt("10:00");
|
||||
|
||||
// 方案结束后提醒清洁保养
|
||||
$schedule->command("order:finished clean_notice")->weeklyOn(0, "20:30");
|
||||
|
||||
// 每日步数提醒
|
||||
// $schedule->command("remind:daily_step")->dailyAt("08:00");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
30
app/Events/AdminUserCreatedEvent.php
Normal file
30
app/Events/AdminUserCreatedEvent.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class AdminUserCreatedEvent implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public string $mobile;
|
||||
public string $password;
|
||||
public string $remark;
|
||||
|
||||
/**
|
||||
* @param string $mobile
|
||||
* @param string $password
|
||||
*/
|
||||
public function __construct(string $mobile, string $password)
|
||||
{
|
||||
$this->mobile = $mobile;
|
||||
$this->password = $password;
|
||||
$this->remark = "账号创建成功,您的密码是";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
30
app/Events/AdminUserResetPwdEvent.php
Normal file
30
app/Events/AdminUserResetPwdEvent.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class AdminUserResetPwdEvent implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public string $mobile;
|
||||
public string $password;
|
||||
public string $remark;
|
||||
|
||||
/**
|
||||
* @param string $mobile
|
||||
* @param string $password
|
||||
*/
|
||||
public function __construct(string $mobile, string $password)
|
||||
{
|
||||
$this->mobile = $mobile;
|
||||
$this->password = $password;
|
||||
$this->remark = "密码已重置,您的新密码是";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
29
app/Events/CommissionGotEvent.php
Normal file
29
app/Events/CommissionGotEvent.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\OrderCommission;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CommissionGotEvent implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public OrderCommission $order_commission;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param OrderCommission $order_commission
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(OrderCommission $order_commission)
|
||||
{
|
||||
Log::info('order_commission'.$order_commission->id.'触发佣金发放事件start');
|
||||
$this->order_commission = $order_commission;
|
||||
}
|
||||
}
|
||||
37
app/Events/CommissionUnfreezeComplete.php
Normal file
37
app/Events/CommissionUnfreezeComplete.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\OrderCommission;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CommissionUnfreezeComplete implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public OrderCommission $order_commission;
|
||||
public string $template_id;
|
||||
public string $keyword2;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param OrderCommission $order_commission
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(OrderCommission $order_commission)
|
||||
{
|
||||
Log::info('order_commission'.$order_commission->id.'触发佣金解冻完成事件start');
|
||||
$this->order_commission = $order_commission;
|
||||
|
||||
$this->template_id = config('wechat.tpls.commission_notice');
|
||||
|
||||
$this->keyword2 = "实际到账".$order_commission->commission_amount ."元";
|
||||
}
|
||||
}
|
||||
31
app/Events/OperationLoggedEvent.php
Normal file
31
app/Events/OperationLoggedEvent.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class OperationLoggedEvent implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $admin_id;
|
||||
public $ip;
|
||||
public $input;
|
||||
public $details;
|
||||
|
||||
|
||||
public function __construct($details = null)
|
||||
{
|
||||
$data = request()->all();
|
||||
unset($data['password']);
|
||||
|
||||
$this->admin_id = Auth::id();
|
||||
$this->ip = request()->getClientIp();
|
||||
$this->input = $data;
|
||||
$this->details = $details;
|
||||
}
|
||||
}
|
||||
38
app/Events/OrderCommissionSetedEvent.php
Normal file
38
app/Events/OrderCommissionSetedEvent.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\OrderCommission;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class OrderCommissionSetedEvent implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public OrderCommission $order_commission;
|
||||
public string $template_id;
|
||||
public string $keyword2;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param OrderCommission $order_commission
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(OrderCommission $order_commission)
|
||||
{
|
||||
Log::info('order_commission'.$order_commission->id.'触发订单佣金设置完成事件start');
|
||||
$this->order_commission = $order_commission;
|
||||
|
||||
$this->template_id = config('wechat.tpls.commission_notice');
|
||||
|
||||
$this->keyword2 = "有预计收益".$order_commission->commission_amount."元";
|
||||
|
||||
}
|
||||
}
|
||||
29
app/Events/OrderServeFinishedEvent.php
Normal file
29
app/Events/OrderServeFinishedEvent.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\OfflineOrder;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class OrderServeFinishedEvent implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public OfflineOrder $offlineOrder;
|
||||
public string $send_event;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param OfflineOrder $offlineOrder
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(OfflineOrder $offlineOrder)
|
||||
{
|
||||
$this->offlineOrder = $offlineOrder;
|
||||
$this->send_event = 'serve_finished';
|
||||
}
|
||||
}
|
||||
|
||||
29
app/Events/OrderServeStartedEvent.php
Normal file
29
app/Events/OrderServeStartedEvent.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\OfflineOrder;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class OrderServeStartedEvent implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public OfflineOrder $offlineOrder;
|
||||
public string $send_event;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param OfflineOrder $offlineOrder
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(OfflineOrder $offlineOrder)
|
||||
{
|
||||
$this->offlineOrder = $offlineOrder;
|
||||
$this->send_event = 'serve_started';
|
||||
}
|
||||
}
|
||||
|
||||
20
app/Events/WithdrawalsApplyEvent.php
Normal file
20
app/Events/WithdrawalsApplyEvent.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\PartnerWithdrawal;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class WithdrawalsApplyEvent implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public PartnerWithdrawal $withdrawal;
|
||||
public function __construct(PartnerWithdrawal $withdrawal)
|
||||
{
|
||||
$this->withdrawal = $withdrawal;
|
||||
}
|
||||
}
|
||||
20
app/Events/WithdrawalsCompleteEvent.php
Normal file
20
app/Events/WithdrawalsCompleteEvent.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\PartnerWithdrawal;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class WithdrawalsCompleteEvent implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public PartnerWithdrawal $withdrawal;
|
||||
public function __construct(PartnerWithdrawal $withdrawal)
|
||||
{
|
||||
$this->withdrawal = $withdrawal;
|
||||
}
|
||||
}
|
||||
101
app/Exceptions/Handler.php
Normal file
101
app/Exceptions/Handler.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use App\Facades\WechatService;
|
||||
use App\Http\Response\CatchError;
|
||||
use App\Http\Response\ResponseJson;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
use ResponseJson, CatchError;
|
||||
/**
|
||||
* A list of exception types with their corresponding custom log levels.
|
||||
*
|
||||
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||
*/
|
||||
protected $levels = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array<int, class-string<\Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
DB::rollBack();
|
||||
$this->getError($e);
|
||||
$msg = $e->getMessage();
|
||||
// Log::info($msg);
|
||||
if (strstr($msg, 'access_token is invalid or not latest')) {
|
||||
Log::info("刷新access_token");
|
||||
$this->refreshToken();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$this->renderable(function (AuthenticationException $e) {
|
||||
$msg = $e->getMessage();
|
||||
Log::error('AuthenticationException msg:'.$msg);
|
||||
return $this->authFail();
|
||||
});
|
||||
$this->renderable(function (Throwable $e) {
|
||||
if (method_exists($e, 'getStatusCode')) {
|
||||
if ($e->getStatusCode() == 405) {
|
||||
return $this->failure("没有对应的路由方法");
|
||||
}elseif ($e->getStatusCode() == 404) {
|
||||
return $this->failure("没有对应的路由");
|
||||
}
|
||||
}
|
||||
$msg = $e->getMessage();
|
||||
if ($e->getCode() == 5000) {
|
||||
return $this->failure($e->getMessage());
|
||||
}
|
||||
$this->getError($e);
|
||||
Log::error('Throwable msg:'.$msg);
|
||||
if ($msg == 'Route [login] not defined.') return $this->authFail();
|
||||
if (config('app.env') != 'production') return;
|
||||
$msg = trans('auth.server_error')??'服务器休息,请稍后重试';
|
||||
return $this->failure($msg);
|
||||
});
|
||||
}
|
||||
public function refreshToken()
|
||||
{
|
||||
$app = WechatService::app();
|
||||
$accessToken = $app->getAccessToken();
|
||||
$token = $accessToken->refresh();
|
||||
// Log::info($token);
|
||||
$app = WechatService::officialApp();
|
||||
$accessToken = $app->getAccessToken();
|
||||
$token = $accessToken->refresh();
|
||||
// Log::info($token);
|
||||
}
|
||||
|
||||
}
|
||||
76
app/Exports/ActivityApplyExport.php
Normal file
76
app/Exports/ActivityApplyExport.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Activity;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ActivityApplyExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->name,
|
||||
$value->mobile,
|
||||
$value->desk_number,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['昵称','手机号', '座位号', '签到时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
98
app/Exports/ActivityExport.php
Normal file
98
app/Exports/ActivityExport.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Activity;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ActivityExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
if($value->status == Activity::STATUS_CLOSE){
|
||||
$status = "下架";
|
||||
}else{
|
||||
$status = "下架";
|
||||
}
|
||||
if($value->is_free == Activity::FREE){
|
||||
$is_free = "免费";
|
||||
}else{
|
||||
$is_free = "付费";
|
||||
}
|
||||
if($value->is_online == Activity::ONLINE){
|
||||
$is_online = "线上";
|
||||
}else{
|
||||
$is_online = "线下";
|
||||
}
|
||||
$items[] = [
|
||||
$value->id,
|
||||
$value->title,
|
||||
$value->sub_title,
|
||||
$value->start_time,
|
||||
$value->end_time,
|
||||
$value->apply_end_time,
|
||||
$status,
|
||||
$is_free,
|
||||
$is_online,
|
||||
$value->address,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['活动id','主标题', '副标题', '开始时间','结束时间','截止时间','上架状态','是否免费','线上线下','地址','创建时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Exports/ActivityMemberExport.php
Normal file
38
app/Exports/ActivityMemberExport.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\AgentUser;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class ActivityMemberExport implements FromCollection, WithHeadings
|
||||
{
|
||||
|
||||
protected $members;
|
||||
public function __construct($members)
|
||||
{
|
||||
$this->members = $members;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->members as $member) {
|
||||
$level = AgentUser::agentName($member->level);
|
||||
|
||||
$items[] = [$member->user->id, $member->user->name, $member->user->mobile, $member->status?"成功":"失败", $member->updated_at->toDateTimeString(), $level];
|
||||
}
|
||||
return collect($items);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用户id','姓名', '手机号','状态','签到时间','身份']
|
||||
];
|
||||
}
|
||||
}
|
||||
42
app/Exports/ActivityMemberLogExport.php
Normal file
42
app/Exports/ActivityMemberLogExport.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\AgentUser;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class ActivityMemberLogExport implements FromCollection,WithHeadings
|
||||
{
|
||||
protected $members;
|
||||
public function __construct($members)
|
||||
{
|
||||
$this->members = $members;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->members as $member) {
|
||||
$level = AgentUser::agentName($member->level);
|
||||
$res = aesDecryptCBC($member->user->mobile);
|
||||
if (empty($res)) {
|
||||
$mobile = $member->user->mobile;
|
||||
}else {
|
||||
$mobile = $res;
|
||||
}
|
||||
$items[] = [$member->user->id, $member->user->name, $mobile, $member->created_at->toDateTimeString(),$level];
|
||||
}
|
||||
return collect($items);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用户id','姓名', '手机号','签到时间',"身份"]
|
||||
];
|
||||
}
|
||||
}
|
||||
111
app/Exports/ActivityOrderExport.php
Normal file
111
app/Exports/ActivityOrderExport.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Activity;
|
||||
use App\Models\AgentUser;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ActivityOrderExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$is_sign = "未签到";
|
||||
if($value->is_sign){
|
||||
$is_sign = "已签到";
|
||||
}
|
||||
// $items[] = [
|
||||
// $value->activity->title??'',
|
||||
// $value->name,
|
||||
// $value->mobile,
|
||||
// $value->amount,
|
||||
// $value->residue_amount,
|
||||
// $value->sku??'',
|
||||
// $value->recommendUser->name??'',
|
||||
// $value->recommendUser->mobile??'',
|
||||
// $value->trade_no,
|
||||
// $is_sign,
|
||||
// $value->created_at,
|
||||
// ];
|
||||
$level = $value->agent_level;
|
||||
$name = AgentUser::agentName($level);
|
||||
$items[] = [
|
||||
$value->id,
|
||||
$value->name,
|
||||
$value->mobile,
|
||||
$value->sex == 1?"男":"女",
|
||||
$name,
|
||||
$value->recommendUser?$value->recommendUser->name:'',
|
||||
$value->recommendUser?$value->recommendUser->mobile:'',
|
||||
$value->activity?$value->activity->title:'',
|
||||
$value->unusualOrder?$value->unusualOrder->name:'',
|
||||
$value->unusualOrder?$value->unusualOrder->mobile:'',
|
||||
$value->amount,
|
||||
$value->residue_amount,
|
||||
$value->is_apply_food?"已报餐":"未报餐",
|
||||
$value->trade_no,
|
||||
$value->created_at->toDateTimeString(),
|
||||
$value->remark,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
// ['活动名','姓名','手机号', '金额','可退款金额','规格','推荐人','推荐人手机号','订单号','是否签到','购买时间']
|
||||
["id", "报名信息-姓名","报名信息-手机号", "报名信息-性别", "类型", "推荐人-姓名", "推荐人-手机号", "购买活动", "推荐购买用户-姓名","推荐购买用户-手机号", "支付金额", "可退款金额", "是否报餐","订单号", "购买时间",'备注信息'],
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('G')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('J')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
49
app/Exports/ActivityRefundExport.php
Normal file
49
app/Exports/ActivityRefundExport.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
|
||||
class ActivityRefundExport implements FromArray,WithHeadings
|
||||
{
|
||||
|
||||
protected $logs;
|
||||
|
||||
public function __construct($logs)
|
||||
{
|
||||
$this->logs = $logs;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->logs as $log){
|
||||
$type = $log->type == 'ADMIN'?"用户申请退款":"介绍人退款";
|
||||
$items[] = [
|
||||
$log->order->activity->title,
|
||||
$log->order->trade_no,
|
||||
$log->order->name,
|
||||
$log->order->mobile,
|
||||
$log->targetOrder && $log->target_order_id != $log->order_id?$log->targetOrder->name:"",
|
||||
$log->targetOrder && $log->target_order_id != $log->order_id?$log->targetOrder->mobile:"",
|
||||
$log->amount,
|
||||
$type,
|
||||
$log->reason,
|
||||
$log->created_at->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['活动名称','订单号', '姓名', '手机号', "推荐订单-姓名", "推荐订单-手机号",'退款金额','退款类型','拒绝原因','操作时间']
|
||||
];
|
||||
}
|
||||
}
|
||||
75
app/Exports/AgencyExport.php
Normal file
75
app/Exports/AgencyExport.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class AgencyExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->id,
|
||||
!empty($value->city)? $value->city : $value->province,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['分公司id','分公司','创建时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
80
app/Exports/AgencyUserExport.php
Normal file
80
app/Exports/AgencyUserExport.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class AgencyUserExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->id,
|
||||
$value->patners->name??'',
|
||||
$value->patners->mobile??'',
|
||||
$value->agency->province.$value->agency->city,
|
||||
$value->name,
|
||||
$value->mobile,
|
||||
$value->introduce_rights,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['id','负责人名称','负责人手机', '分公司', '成员名','成员手机','创建时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Exports/AgentEarningsExport.php
Normal file
36
app/Exports/AgentEarningsExport.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class AgentEarningsExport implements FromArray,WithHeadings
|
||||
{
|
||||
protected $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['订单ID','总金额','收益金额', '微信手续费', '平台手续费','分销时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$rows =[];
|
||||
$orders = $this->data;
|
||||
|
||||
foreach ($orders as $order)
|
||||
{
|
||||
$rows[] = ['id'=>$order["order_id"], 'total'=>$order['total'], 'amount'=>$order['amount'], 'wechat_fee'=>$order['wechat_fee'], 'ufutx_fee'=>$order['ufutx_fee'], 'time'=>$order['created_at']];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
37
app/Exports/AgentLottoCodesExport.php
Normal file
37
app/Exports/AgentLottoCodesExport.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class AgentLottoCodesExport implements FromArray,WithHeadings
|
||||
{
|
||||
protected $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['商品名称','商品图片','商品规格', '抽奖码', '状态']
|
||||
];
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$rows =[];
|
||||
$orders = $this->data;
|
||||
foreach ($orders as $order)
|
||||
{
|
||||
$goods = $order['order']?$order['order']['shop_info']:'';
|
||||
$rows[] = ['name'=>$goods?$goods['title']:'', 'pic'=>$goods?$goods['pic']:'', 'sku'=>$goods?$goods['sku']['name']:"", 'code'=>$order['code'],
|
||||
'status'=>$order['award']?"中奖":''];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
54
app/Exports/AgentOrdersExport.php
Normal file
54
app/Exports/AgentOrdersExport.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class AgentOrdersExport implements FromArray,WithHeadings
|
||||
{
|
||||
protected $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['商品ID','商品图片','商品名称','商品规格','购买数量', '支付金额',"姓名", "手机号", "订单号", '子商户号','推荐人','推荐人手机号',"线上/线下",'下单时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$rows =[];
|
||||
$orders = $this->data;
|
||||
|
||||
foreach ($orders as $order)
|
||||
{
|
||||
$name = $order->name?:($order->user?$order->user->name:'');
|
||||
$trade_no = $order->trade_no??'';
|
||||
$trade_no = ' '.$trade_no;
|
||||
$mobile = $order->mobile?:($order->user?$order->user->mobile:'');
|
||||
$recommend_user = $order->recommendUser;
|
||||
$recommend_user_name = $recommend_user? $recommend_user['name']:'';
|
||||
$recommend_user_mobile = $recommend_user? $recommend_user['mobile']:'';
|
||||
$type = $order['is_online']?"线上":"线下";
|
||||
$title = $order['shop_info']['title']??'';
|
||||
$pic = $order['shop_info']['pic']??'';
|
||||
$sku_name = $order['shop_info']['sku']['name']??"";
|
||||
$rows[] = ['id'=>$order["id"], 'pic'=>$pic,'title'=>$title,'sku_name'=>$sku_name,'num'=>$order['num'],'price'=>$order['price'], "name"=>$name,"mobile"=>$mobile,'trade_no'=>$trade_no,'sub_mch_id'=>$order->sub_mch_id??'','recommend_user_name'=>$recommend_user_name, "recommend_user_mobile"=>$recommend_user_mobile,'type'=>$type,'time'=>$order['created_at']];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
}
|
||||
47
app/Exports/AgentShopsExport.php
Normal file
47
app/Exports/AgentShopsExport.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class AgentShopsExport implements FromArray,WithHeadings
|
||||
{
|
||||
protected $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['id','商品图片','商品名称', '规格名称/库存', "客户价/准批发商价/批发商价格/员工价", '邮费', "生成抽奖码", "上架状态","平台费"]
|
||||
];
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$rows =[];
|
||||
$shops = $this->data;
|
||||
foreach ($shops as $shop)
|
||||
{
|
||||
$sku_name ='';
|
||||
$freight = '';
|
||||
$price = '';
|
||||
foreach ($shop['sku'] as $sku) {
|
||||
if (!collect($shop['shop_agent']['sku'])->firstWhere('sku_id', $sku['sku_id'])) continue;
|
||||
$sku_name .= $sku['name'] . "/" . $sku["stock"] . ' | ';
|
||||
if (isset($sku['ship_num'])) {
|
||||
$ready_agent_price = $sku['ready_agent_price']??"无";
|
||||
$freight .= "前{$sku['ship_num']}件 {$sku['ship_price']}元,每增加一件{$sku['ship_each_price']}元,最高{$sku['ship_max_price']}元 | ";
|
||||
$price .= "{$sku["price"]}/{$ready_agent_price}/{$sku['agent_price']}/{$sku['staff_price']} | ";
|
||||
}
|
||||
}
|
||||
$rows[] = ['id'=>$shop['id'], 'name'=>$shop['icon'], 'title'=>$shop['title'], 'sku_name'=>$sku_name, "price"=>$price,'freight'=>$freight, "lotto_code"=>$shop['shop_agent']['lotto_code']?"生成":"不生成",'is_show'=>$shop['shop_agent']['is_show']?"上架":"下架", "ratio"=>$shop['shop_agent']['ratio']];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
37
app/Exports/AgentStocksExport.php
Normal file
37
app/Exports/AgentStocksExport.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class AgentStocksExport implements FromArray,WithHeadings
|
||||
{
|
||||
protected $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用户ID','商品名称','商品图片', '提现类型', '收货人姓名', '收货人手机号', '收货人地址','提取数量','提取时间', '状态','快递公司', '快递单号']
|
||||
];
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$rows =[];
|
||||
$stocks = $this->data;
|
||||
foreach ($stocks as $stock)
|
||||
{
|
||||
$rows[] = ['id'=>$stock["id"], 'title'=>$stock['shop']['title'], 'pic'=>$stock['shop']['icon'], 'sku_name'=>$stock['type'] == 'ONLINE'?"线上提取":"线下提取",
|
||||
'name'=>$stock['name'], 'mobile'=>$stock['mobile'], 'address'=>$stock['address'], 'num'=>$stock['num'], 'created_at'=>$stock['created_at'],
|
||||
'status'=>$stock['status'] == 'AUDIT'?"待发货":"已发货", 'express'=>$stock['express'], 'express_no'=>$stock['express_no']];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
39
app/Exports/AgentUsersExport.php
Normal file
39
app/Exports/AgentUsersExport.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\AgentUser;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class AgentUsersExport implements FromArray,WithHeadings
|
||||
{
|
||||
protected $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用户id','姓名', '手机号', '推荐人姓名', '推荐人手机号', "类型", '购买活动订单', '推荐票订单', '推荐票余额', '购买商品数']
|
||||
];
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$rows =[];
|
||||
$users = $this->data;
|
||||
foreach ($users as $user)
|
||||
{
|
||||
$recommend_user = $user->recommendUser;
|
||||
$level = AgentUser::agentName($user['level']);
|
||||
$rows[] = ['id'=>$user['user_id'], 'name'=>$user['user']['name'], 'mobile'=>$user['user']['mobile'], 'recommend_name'=>$recommend_user?$recommend_user->name:'',
|
||||
'recommend_mobile'=>$recommend_user?$recommend_user->mobile:'', "level"=>$level,'activity_count'=>$user->activity_count?:0, 'introduce_activity_count'=>$user->introduce_activity_count?:0, 'residue_amount'=>$user->residue_amount?:0, 'order_count'=>$user->order_count?:0];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
43
app/Exports/AgentUsersSimpleExport.php
Normal file
43
app/Exports/AgentUsersSimpleExport.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class AgentUsersSimpleExport implements FromArray,WithHeadings
|
||||
{
|
||||
protected $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['openid', 'level', 'remark']
|
||||
];
|
||||
}
|
||||
public function array():array
|
||||
{
|
||||
$rows =[];
|
||||
$users = $this->data;
|
||||
foreach ($users as $user)
|
||||
{
|
||||
if ($user->level == 1) {
|
||||
$remark = "经销商";
|
||||
}elseif ($user->level == 2) {
|
||||
$remark = "准经销商";
|
||||
}
|
||||
$rows[] = [
|
||||
$user->officialWechat->openid,
|
||||
$user->level,
|
||||
$remark
|
||||
];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
36
app/Exports/AgentWithdrawsExport.php
Normal file
36
app/Exports/AgentWithdrawsExport.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class AgentWithdrawsExport implements FromArray,WithHeadings
|
||||
{
|
||||
protected $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用户id','用户昵称','用户头像', '用户手机', '提现金额','提现时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$rows =[];
|
||||
$orders = $this->data;
|
||||
foreach ($orders as $order)
|
||||
{
|
||||
$rows[] = ['id'=>$order["user_id"], 'nickname'=>$order['user']['name'], 'pic'=>$order['user']['avatar'], 'mobile'=>$order['user']['mobile'],
|
||||
'amount'=>$order['amount'], 'time'=>$order['created_at']];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
109
app/Exports/AgreementExport.php
Normal file
109
app/Exports/AgreementExport.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Agreement;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class AgreementExport implements FromArray, WithHeadings, WithStyles, WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array(): array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value) {
|
||||
switch ($value->material_type) {
|
||||
case Agreement::MATERIAL_TYPE_ELECTRON:
|
||||
$material_type = '电子版';
|
||||
break;
|
||||
default:
|
||||
$material_type = '纸质';
|
||||
break;
|
||||
}
|
||||
switch ($value->is_notice) {
|
||||
case Agreement::IS_NOTICE_YES:
|
||||
$is_notice = '已签发';
|
||||
break;
|
||||
default:
|
||||
$is_notice = '未签发';
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($value->is_receive) {
|
||||
case Agreement::IS_RECEIVE_YES:
|
||||
$is_receive = '已领取';
|
||||
break;
|
||||
default:
|
||||
$is_receive = '未领取';
|
||||
break;
|
||||
}
|
||||
$items[] = [
|
||||
$value->id,
|
||||
$value->orderInfo->trade_no,
|
||||
$value->number,
|
||||
$value->sign_date,
|
||||
$value->signInfo->name ?? '',
|
||||
$material_type,
|
||||
$is_notice,
|
||||
$value->introduceInfo->name ?? '',
|
||||
implode(',',$value->introduce_rights),
|
||||
$is_receive,
|
||||
$value->quota_id,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['id', '订单号', '协议号', '签署日期', '签署人', '材质类型', '是否签发通知书', '介绍人', '介绍人权益', '是否领取权益', '名额归属', '创建时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
78
app/Exports/AgreementLogExport.php
Normal file
78
app/Exports/AgreementLogExport.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Agreement;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class AgreementLogExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->id,
|
||||
$value->agreement->number,
|
||||
$value->user_name,
|
||||
$value->user_mobile,
|
||||
$value->remark,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['id','协议号', '操作人', '操作人电话','备注','操作时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
78
app/Exports/CanRestaurantExport.php
Normal file
78
app/Exports/CanRestaurantExport.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\AgentUser;
|
||||
use App\Models\Agreement;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CanRestaurantExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->id,
|
||||
$value->name,
|
||||
$value->mobile,
|
||||
$value->office_name,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用户id','姓名', '手机号', '办公室','创建时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
102
app/Exports/ChefPlanListExport.php
Normal file
102
app/Exports/ChefPlanListExport.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\ChefPlan;
|
||||
use App\Models\Restaurant;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ChefPlanListExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
switch ($value->diet_type){
|
||||
case Restaurant::DIET_TYPE_LUNCH:
|
||||
$diet_type = '午餐';
|
||||
break;
|
||||
default:
|
||||
$diet_type = '晚餐';
|
||||
break;
|
||||
}
|
||||
switch ($value->type){
|
||||
case ChefPlan::CHEF_MAIN:
|
||||
$chef_type = '主厨';
|
||||
break;
|
||||
case ChefPlan::CHEF_SOUS:
|
||||
$chef_type = '副厨';
|
||||
break;
|
||||
case ChefPlan::CHEF_HELP:
|
||||
$chef_type = '帮厨';
|
||||
break;
|
||||
default:
|
||||
$chef_type = '帮厨';
|
||||
break;
|
||||
}
|
||||
|
||||
$items[] = [
|
||||
$value->name,
|
||||
$value->mobile,
|
||||
$value->date,
|
||||
$chef_type,
|
||||
$diet_type,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['厨师姓名','厨师电话','日期', '角色', '餐饮类型','创建']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
75
app/Exports/ChefUserExport.php
Normal file
75
app/Exports/ChefUserExport.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ChefUserExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->user_id,
|
||||
$value->name,
|
||||
$value->mobile,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用户id','厨师姓名', '厨师手机号', '申请日期']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
78
app/Exports/CommentExport.php
Normal file
78
app/Exports/CommentExport.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CommentExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->order->name??'',
|
||||
$value->order->mobile??'',
|
||||
$value->order->trade_no??'',
|
||||
$value->type_name,
|
||||
$value->comment,
|
||||
$value->user->name??'',
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用户名','用户电话', '订单号', '备注类型','备注内容','操作人','备注时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
72
app/Exports/CompanyPartnersExport.php
Normal file
72
app/Exports/CompanyPartnersExport.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Partner;
|
||||
use App\Models\ServiceUser;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CompanyPartnersExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
ServiceUser::with('roles', 'user:id,name,avatar')
|
||||
->whereNotNull('user_id')
|
||||
->keyword()
|
||||
->hasCompanyPartner()
|
||||
->orderByDesc('id')
|
||||
->get()->each(function ($user) use(&$items) {
|
||||
$items[] = [$user->id, $user->name, $user->mobile, $user->updated_at];
|
||||
});
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['id', '昵称', '手机号', '操作时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
76
app/Exports/ContractExport.php
Normal file
76
app/Exports/ContractExport.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ContractExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->party_a_name,
|
||||
$value->party_b_name,
|
||||
$value->number,
|
||||
$value->name,
|
||||
$value->sign_date,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['甲方名','乙方名', '合同编号', '合同名',"签署日期"]
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
74
app/Exports/ContractTypeExport.php
Normal file
74
app/Exports/ContractTypeExport.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ContractTypeExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->id,
|
||||
$value->name,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['id','合同类型', '创建日期']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
75
app/Exports/DragonUserExport.php
Normal file
75
app/Exports/DragonUserExport.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Activity;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class DragonUserExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
|
||||
$items[] = [
|
||||
$value->name,
|
||||
$value->invite_name,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['我的名字(输入框1)','邀约人(输入框2)', '填写时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
64
app/Exports/EarningGradeLogsExport.php
Normal file
64
app/Exports/EarningGradeLogsExport.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class EarningGradeLogsExport implements FromCollection, WithHeadings, ShouldAutoSize, WithColumnFormatting
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
"姓名",
|
||||
"手机号",
|
||||
"订单号",
|
||||
"商品名",
|
||||
"规格",
|
||||
"价格",
|
||||
'退款',
|
||||
"分享人姓名",
|
||||
"分享人手机号",
|
||||
"分享人收益",
|
||||
"友福收益",
|
||||
"微信手续费",
|
||||
];
|
||||
}
|
||||
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
'C' => NumberFormat::FORMAT_TEXT,
|
||||
"F" => NumberFormat::FORMAT_NUMBER_00,
|
||||
"G" => NumberFormat::FORMAT_NUMBER_00,
|
||||
'I' => NumberFormat::FORMAT_TEXT,
|
||||
"J" => NumberFormat::FORMAT_NUMBER_00,
|
||||
"K" => NumberFormat::FORMAT_NUMBER_00,
|
||||
"L" => NumberFormat::FORMAT_NUMBER_00,
|
||||
];
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$arr = [];
|
||||
foreach ($this->data as $log)
|
||||
{
|
||||
$arr[] = ['name'=>$log['name'], 'mobile'=>$log['mobile'],'trade_no'=>(string)$log['trade_no'],
|
||||
'goods'=>$log['goods'], 'sku'=>$log['sku'], 'price'=>$log['price'], 'refund_fee'=>$log['refund_fee'],
|
||||
'sharer_name'=>$log['earning']['sharer']['name'], 'sharer_mobile'=>$log['earning']['sharer']['mobile'], 'sharer_amount'=>$log['earning']['sharer']['amount'],
|
||||
"ufutx_amount"=>$log['earning']['ufutx']['amount'], 'weixin_amount'=>$log['earning']['weixin']['amount']];
|
||||
}
|
||||
return collect($arr);
|
||||
}
|
||||
}
|
||||
47
app/Exports/EarningGradeUsersExport.php
Normal file
47
app/Exports/EarningGradeUsersExport.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class EarningGradeUsersExport implements FromCollection, WithHeadings, ShouldAutoSize, WithColumnFormatting
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
"姓名",
|
||||
"手机号",
|
||||
"设置时间",
|
||||
];
|
||||
}
|
||||
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
'C' => NumberFormat::FORMAT_TEXT,
|
||||
"F" => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$arr = [];
|
||||
foreach ($this->data as $log)
|
||||
{
|
||||
$arr[] = ['name'=>$log['nickname'], 'mobile'=>$log['mobile'],'created_at'=>$log['created_at']];
|
||||
}
|
||||
return collect($arr);
|
||||
}
|
||||
}
|
||||
74
app/Exports/FatLogsExport.php
Normal file
74
app/Exports/FatLogsExport.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Activity;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class FatLogsExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->fat_data,
|
||||
$value->created_at
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['体重','测量时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
95
app/Exports/FeedbackExport.php
Normal file
95
app/Exports/FeedbackExport.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Activity;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class FeedbackExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
|
||||
switch($value->source) {
|
||||
case "android":
|
||||
$device = "安卓用户端";
|
||||
break;
|
||||
case "android_server":
|
||||
$device = "安卓教练端";
|
||||
break;
|
||||
case "ios":
|
||||
$device = "ios用户端";
|
||||
break;
|
||||
case "ios_server":
|
||||
$device = "ios教练端";
|
||||
break;
|
||||
default:
|
||||
$device = "";
|
||||
}
|
||||
$device .= $value->version;
|
||||
$items[] = [
|
||||
$value->user->name??'',
|
||||
$device,
|
||||
$value->type,
|
||||
$value->desc,
|
||||
$value->mobile,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['反馈人', '设备','反馈类型', '描述', '联系电话','创建时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('D')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
82
app/Exports/FoodExport.php
Normal file
82
app/Exports/FoodExport.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Food;
|
||||
use App\Models\Order;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class FoodExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
protected $shops;
|
||||
public function __construct($shops)
|
||||
{
|
||||
$this->shops = $shops;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$shops = $this->shops;
|
||||
$rows = [];
|
||||
foreach ($shops as $shop)
|
||||
{
|
||||
$sku_name ='';
|
||||
$freight = '';
|
||||
$price = '';
|
||||
foreach ($shop['sku'] as $sku) {
|
||||
$sku_name .= $sku['name'] . "/" . $sku["stock"] . ' | ';
|
||||
if (isset($sku['ship_num'])) {
|
||||
$ready_agent_price = $sku['ready_agent_price']??"无";
|
||||
$freight .= "前{$sku['ship_num']}件 {$sku['ship_price']}元,每增加一件{$sku['ship_each_price']}元,最高{$sku['ship_max_price']}元 | ";
|
||||
$price .= "{$sku["price"]}/{$ready_agent_price}/{$sku['agent_price']}/{$sku['staff_price']} | ";
|
||||
}
|
||||
}
|
||||
$rows[] = ['id'=>$shop['id'], 'name'=>$shop['icon'], 'title'=>$shop['title'], 'unit'=>$shop->shopFood->unit, 'quantity'=>$shop->shopFood->quantity, 'sku_name'=>$sku_name, "price"=>$price, 'freight'=>$freight, 'is_show'=>$shop->shopFood->is_sale?"上架":"下架"];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['id','商品图片','商品名称',"单位","量", '规格名称/库存', "客户价/准批发商价/批发商价格/员工价", '邮费', "上架状态"]
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Exports/LotteryMembersExport.php
Normal file
35
app/Exports/LotteryMembersExport.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
|
||||
class LotteryMembersExport implements FromArray,WithHeadings
|
||||
{
|
||||
protected $members;
|
||||
public function __construct($members)
|
||||
{
|
||||
$this->members = $members;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$rows = [];
|
||||
foreach ($this->members as $member)
|
||||
{
|
||||
$rows[]= ['user_id'=>$member->user_id, 'name'=>$member->name, 'mobile'=>$member->mobile, 'created_at'=>$member->created_at];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用户id', '用户姓名', '手机号', '参加时间']
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Exports/LotteryWinMembersExport.php
Normal file
34
app/Exports/LotteryWinMembersExport.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class LotteryWinMembersExport implements FromArray,WithHeadings
|
||||
{
|
||||
protected $members;
|
||||
public function __construct($members)
|
||||
{
|
||||
$this->members = $members;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$rows = [];
|
||||
foreach ($this->members as $member)
|
||||
{
|
||||
$rows[] = ['user_id'=>$member->user_id, 'name'=>$member->name, 'mobile'=>$member->mobile, 'level'=>$member->award?$member->award->level:""];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用户id', '用户姓名', '手机号', '中奖奖项']
|
||||
];
|
||||
}
|
||||
}
|
||||
79
app/Exports/MeetRoomExport.php
Normal file
79
app/Exports/MeetRoomExport.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class MeetRoomExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$status = '空闲';
|
||||
if($value->status == 1){
|
||||
$status = '已预定';
|
||||
}
|
||||
$items[] = [
|
||||
$value->id,
|
||||
$value->room_name,
|
||||
$status,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['id','会议室名称', '会议室状态','添加时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
46
app/Exports/NurtureShopsExport.php
Normal file
46
app/Exports/NurtureShopsExport.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class NurtureShopsExport implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $shops;
|
||||
public function __construct($shops)
|
||||
{
|
||||
$this->shops = $shops;
|
||||
}
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$rows = [];
|
||||
$shops = $this->shops;
|
||||
foreach ($shops as $shop)
|
||||
{
|
||||
$sku_name ='';
|
||||
$freight = '';
|
||||
$price = '';
|
||||
foreach ($shop['sku'] as $sku) {
|
||||
$sku_name .= $sku['name'] . "/" . $sku["stock"] . ' | ';
|
||||
if (isset($sku['ship_num'])) {
|
||||
$ready_agent_price = $sku['ready_agent_price']??"无";
|
||||
$freight .= "前{$sku['ship_num']}件 {$sku['ship_price']}元,每增加一件{$sku['ship_each_price']}元,最高{$sku['ship_max_price']}元 | ";
|
||||
$price .= "{$sku["price"]}/{$ready_agent_price}/{$sku['agent_price']}/{$sku['staff_price']} | ";
|
||||
}
|
||||
}
|
||||
$rows[] = ['id'=>$shop['id'], 'name'=>$shop['icon'], 'title'=>$shop['title'], 'sku_name'=>$sku_name, "price"=>$price, 'freight'=>$freight, 'is_show'=>$shop['shop_nurture']['is_show']?"上架":"下架"];
|
||||
}
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['id','商品图片','商品名称', '规格名称/库存', "客户价/准批发商价/批发商价格/员工价", '邮费', "上架状态"]
|
||||
];
|
||||
}
|
||||
}
|
||||
74
app/Exports/OfficeExport.php
Normal file
74
app/Exports/OfficeExport.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class OfficeExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->id,
|
||||
$value->office_name,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['id','办公室房号', '添加时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
124
app/Exports/OfflineOrderExport.php
Normal file
124
app/Exports/OfflineOrderExport.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\OfflineOrder;
|
||||
use App\Models\Order;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class OfflineOrderExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
protected $keyword;
|
||||
protected $status;
|
||||
protected $agency_id;
|
||||
protected $header;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->keyword = $data['keyword']??null;
|
||||
$this->status = $data['status']??null;
|
||||
$this->agency_id = $data['agency_id']??null;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$keywords = $this->keyword;
|
||||
$status = $this->status;
|
||||
$agency_id = $this->agency_id;
|
||||
$orders = [];
|
||||
$offline_orders = OfflineOrder::with([
|
||||
'main_order',
|
||||
'agency:id,name,mobile',
|
||||
'order_commission' => function($commission){
|
||||
$commission->with(['service_user:user_id,name,mobile'])->select('id','order_id','role','user_id');
|
||||
}
|
||||
])
|
||||
->when($keywords,function ($query) use ($keywords) {
|
||||
$query->where(function ($query) use ($keywords) {
|
||||
$query->where('name','like','%'.$keywords.'%')->orWhere('mobile','like','%'.$keywords.'%');
|
||||
});
|
||||
})
|
||||
->when(!empty($status),function ($query) use ($status) {
|
||||
$query->whereHas('main_order',function ($query) use ($status) {
|
||||
$query->where('status',$status);
|
||||
});
|
||||
})
|
||||
->when($agency_id,function ($query) use ($agency_id) {
|
||||
$query->where('agency_id',$agency_id);
|
||||
})
|
||||
->orderByDesc('id')
|
||||
->get();
|
||||
// dd($offline_orders);
|
||||
foreach ($offline_orders as $offline_order) {
|
||||
$order = $offline_order->main_order;
|
||||
$commission_arr = [
|
||||
1=>'',
|
||||
2=>'',
|
||||
3=>'',
|
||||
4=>'',
|
||||
5=>'',
|
||||
];
|
||||
foreach ($offline_order->order_commission as $commission){
|
||||
$commission_arr[$commission->role] .= $commission->service_user?$commission->service_user->name:'' .',';
|
||||
}
|
||||
$orders[] = [$order->id, $order->name, $order->mobile, $order->price,'虚拟订单',
|
||||
['NOTSTART'=>'未开始','STARTING'=>'进行中','FINISHED'=>'已结束'][$order->status],
|
||||
$order->agency?->name??'',
|
||||
'',
|
||||
$commission_arr[5],
|
||||
$commission_arr[1],
|
||||
$commission_arr[2],
|
||||
$commission_arr[3],
|
||||
$offline_order->contract_no,
|
||||
$offline_order->created_at,
|
||||
];
|
||||
}
|
||||
return $orders;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['订单id', '联系人姓名', '联系人电话', '订单价格', '订单类型', '服务状态','子公司', '合作伙伴', '渠道商', '主教练', '副教练', '客服', '合同号', '创建时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
102
app/Exports/OfflineOrderExportV2.php
Normal file
102
app/Exports/OfflineOrderExportV2.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Order;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class OfflineOrderExportV2 implements FromCollection,WithHeadings
|
||||
{
|
||||
|
||||
protected $orders;
|
||||
public function __construct($orders)
|
||||
{
|
||||
$this->orders = $orders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$items =[];
|
||||
$orders = $this->orders;
|
||||
foreach ($orders as $order)
|
||||
{
|
||||
|
||||
$status = "未知";
|
||||
$role1 = $role2 = $role3 = [];
|
||||
if ($order->main_order) {
|
||||
switch ($order->main_order->status) {
|
||||
case Order::NOTSTART_STATUS:
|
||||
$status = "未开始";
|
||||
break;
|
||||
case Order::STARTING_STATUS:
|
||||
$status = "进行中";
|
||||
break;
|
||||
case Order::FINISHED_STATUS:
|
||||
$status = "已完成";
|
||||
break;
|
||||
case Order::SUSPEND_STATUS:
|
||||
$status = "暂停中";
|
||||
break;
|
||||
default:
|
||||
$status = "未知";
|
||||
|
||||
}
|
||||
$service_role = $order->main_order->service_role;
|
||||
foreach ($service_role as $role) {
|
||||
|
||||
if ($role->role_id == 1) {
|
||||
$role1[] = $role->serviceUser->name??'';
|
||||
}
|
||||
if ($role->role_id == 2) {
|
||||
$role2[] = $role->serviceUser->name??'';
|
||||
}
|
||||
if ($role->role_id == 3) {
|
||||
$role3[] = $role->serviceUser->name??'';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$city = $province = '';
|
||||
if ($order->agreement && $order->agreement->quotaInfo && $order->agreement->quotaInfo->agencyInfo) {
|
||||
$city = $order->agreement->quotaInfo->agencyInfo->city;
|
||||
$province = $order->agreement->quotaInfo->agencyInfo->province;
|
||||
}
|
||||
$collaborator_name = '';
|
||||
|
||||
if ($order->agreement && $order->agreement->quotaInfo && $order->agreement->quotaInfo->collaboratorInfo) {
|
||||
$collaborator_name = $order->agreement->quotaInfo->collaboratorInfo->name;
|
||||
}
|
||||
$city = $city?:$province;
|
||||
$agency = $city.'-'.$collaborator_name;
|
||||
|
||||
$items[] = [
|
||||
$order->id,
|
||||
$order->name,
|
||||
$order->mobile,
|
||||
$order->price,
|
||||
"虚拟订单",
|
||||
$status,
|
||||
$agency,
|
||||
implode(',', $role1),
|
||||
implode(',', $role2),
|
||||
implode(',', $role3),
|
||||
$order->contract_no,
|
||||
$order->created_at->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
return collect($items);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
["订单id", "联系人姓名", "联系人手机号","订单价格", "订单类型", "服务状态", '子公司', "主教练",'副教练', '客服',"合同号", "操作时间"]
|
||||
];
|
||||
}
|
||||
}
|
||||
93
app/Exports/OperateStockExport.php
Normal file
93
app/Exports/OperateStockExport.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\ChefPlan;
|
||||
use App\Models\OperateStockLog;
|
||||
use App\Models\Restaurant;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class OperateStockExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
switch ($value->operate_type){
|
||||
case OperateStockLog::OPERATE_TYPE_OUT:
|
||||
$type = '出库';
|
||||
break;
|
||||
default:
|
||||
$type = '入库';
|
||||
break;
|
||||
}
|
||||
$operate_name = $value->operate_name;
|
||||
if(empty($operate_name)){
|
||||
$operate_name = $value->order_id;
|
||||
}
|
||||
$items[] = [
|
||||
$value->name,
|
||||
$type,
|
||||
$operate_name,
|
||||
$value->operate_mobile,
|
||||
$value->num,
|
||||
$value->remark,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['商品名称','操作方式','操作人/订单号','操作人手机号', '数量', '备注','操作时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
93
app/Exports/OrderMedicalReportExport.php
Normal file
93
app/Exports/OrderMedicalReportExport.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Activity;
|
||||
use App\Models\MedicalReport;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class OrderMedicalReportExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
$xueya = "未选择";
|
||||
$tang = "未选择";
|
||||
$shen = "未选择";
|
||||
$xuezhi = "未选择";
|
||||
$xuechanggui = "未选择";
|
||||
$ganggong = "未选择";
|
||||
$MedicalReport = new MedicalReport();
|
||||
$anomaly = $MedicalReport->anomalyTranfer($this->data['user_info']->anomaly);
|
||||
if(is_array($anomaly)){
|
||||
$xueya = implode(',',$anomaly[0]??[]);
|
||||
$tang = implode(',',$anomaly[1]??[]);
|
||||
$shen = implode(',',$anomaly[2]??[]);
|
||||
$xuezhi = implode(',',$anomaly[3]??[]);
|
||||
$xuechanggui = implode(',',$anomaly[4]??[]);
|
||||
$ganggong = implode(',',$anomaly[5]??[]);
|
||||
}
|
||||
$items[] = [
|
||||
$xueya,
|
||||
$tang,
|
||||
$shen,
|
||||
$xuezhi,
|
||||
$xuechanggui,
|
||||
$ganggong
|
||||
];
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['血压','糖检测', '肾功能检测', '血脂四项检查','五分类血常规','肝功三项']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
94
app/Exports/OrderSchemeExport.php
Normal file
94
app/Exports/OrderSchemeExport.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Office;
|
||||
use App\Models\Restaurant;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class OrderSchemeExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$name = "";
|
||||
$num = $price = "";
|
||||
if(isset($value['scheme']) && !empty($value['scheme'])){
|
||||
$scheme = json_decode($value['scheme']);
|
||||
foreach ($scheme as $item){
|
||||
$new_name = $item->name??"";
|
||||
$new_num = $item->num??"0";
|
||||
$new_price = $item->price??"0";
|
||||
$name .= $new_name."\n";
|
||||
$num .= $new_num."\n";
|
||||
$price .= $new_price."\n";
|
||||
}
|
||||
}
|
||||
$items[] = [
|
||||
$value['id']??0,
|
||||
$value['trade_no']." ",
|
||||
$value['name'],
|
||||
$value['mobile'],
|
||||
$name,
|
||||
$num,
|
||||
$price,
|
||||
$value['created_at'],
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['方案id','订单号', '用户姓名', '手机号','名称','数量','价格','设置时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
43
app/Exports/OrderSharesExport.php
Normal file
43
app/Exports/OrderSharesExport.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class OrderSharesExport implements FromCollection, WithHeadings
|
||||
{
|
||||
|
||||
protected $logs;
|
||||
public function __construct($logs)
|
||||
{
|
||||
$this->logs = $logs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$logs = $this->logs;
|
||||
|
||||
$items = [];
|
||||
foreach ($logs as $log) {
|
||||
$items[] = [
|
||||
$log->user->name,
|
||||
$log->user->mobile,
|
||||
$log->trade_no,
|
||||
$log->amount,
|
||||
$log->created_at->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
return collect($items);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用戶姓名','手机号', '订单号', '分润金额',"申请时间"]
|
||||
];
|
||||
}
|
||||
}
|
||||
76
app/Exports/OrderStatExport.php
Normal file
76
app/Exports/OrderStatExport.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Activity;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class OrderStatExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->data as $value){
|
||||
$items[] = [
|
||||
$value->name,
|
||||
$value->mobile,
|
||||
$value->trade_no,
|
||||
$value->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['用户名称','手机号', '订单号', '创建时间']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
167
app/Exports/OrderStepThreeInfoExport.php
Normal file
167
app/Exports/OrderStepThreeInfoExport.php
Normal file
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Activity;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class OrderStepThreeInfoExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = $knows = $stomachs = $hearts = $sleeps = $womans = $mans = $others = $dietarys = $livings = $mentals = $familys = $family_members = $understands = $reallys = $dutys = $personals = [];
|
||||
foreach (json_decode($this->data['user_info']->stomach,true) as $item) {
|
||||
$stomachs[] = $item['name'];
|
||||
}
|
||||
$stomach = implode(',', $stomachs);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->heart,true) as $item) {
|
||||
$hearts[] = $item['name'];
|
||||
}
|
||||
$heart = implode(',', $hearts);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->sleep,true) as $item) {
|
||||
$sleeps[] = $item['name'];
|
||||
}
|
||||
$sleep = implode(',', $sleeps);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->woman,true) as $item) {
|
||||
$womans[] = $item['name'];
|
||||
}
|
||||
$woman = implode(',', $womans);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->man,true) as $item) {
|
||||
$mans[] = $item['name'];
|
||||
}
|
||||
$man = implode(',', $mans);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->other,true) as $item) {
|
||||
$others[] = $item['name'];
|
||||
}
|
||||
$other = implode(',', $others);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->dietary,true) as $item) {
|
||||
$dietarys[] = $item['name'];
|
||||
}
|
||||
$dietary = implode(',', $dietarys);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->living,true) as $item) {
|
||||
$livings[] = $item['name'];
|
||||
}
|
||||
$living = implode(',', $livings);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->mental,true) as $item) {
|
||||
$mentals[] = $item['name'];
|
||||
}
|
||||
$mental = implode(',', $mentals);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->family,true) as $item) {
|
||||
$familys[] = $item['name'];
|
||||
}
|
||||
$family = implode(',', $familys);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->family_member,true) as $item) {
|
||||
$family_members[] = $item['name'];
|
||||
}
|
||||
$family_member = implode(',', $family_members);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->know??[],true) as $item) {
|
||||
$knows[] = $item['name'];
|
||||
}
|
||||
$know = implode(',', $knows);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->understand??[],true) as $item) {
|
||||
$understands[] = $item['name'];
|
||||
}
|
||||
$understand = implode(',', $understands);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->really??[],true) as $item) {
|
||||
$reallys[] = $item['name'];
|
||||
}
|
||||
$really = implode(',', $reallys);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->duty??[],true) as $item) {
|
||||
$dutys[] = $item['name'];
|
||||
}
|
||||
$duty = implode(',', $dutys);
|
||||
|
||||
foreach (json_decode($this->data['user_info']->personal??[],true) as $item) {
|
||||
$personals[] = $item['name'];
|
||||
}
|
||||
$personal = implode(',', $personals);
|
||||
|
||||
$items[] = [
|
||||
$stomach,
|
||||
$heart,
|
||||
$sleep,
|
||||
$woman,
|
||||
$man,
|
||||
$other,
|
||||
$dietary,
|
||||
$living,
|
||||
$mental,
|
||||
$family,
|
||||
$family_member,
|
||||
$know,
|
||||
$understand,
|
||||
$really,
|
||||
$duty,
|
||||
$personal,
|
||||
$this->data['user_info']->desc
|
||||
];
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['胃部问题','心脏问题', '睡眠问题', '妇科问题','男科问题','其他不适反应','饮食习惯','生活习惯','精神心理状态','家庭关系状态','家庭成员','您是否知悉、充分理解并自愿承担方案过程中因自身疾病问题而出现或可能出现的不可抗力或者并发症(如癫痫、抽搐、痉挛、病情加重等),除非经有权司法机关裁决事故系由本公司故意或重大过失引起的,否则本公司不承担任何法律责任','您是否充分理解本公司的健康学习方案原则,并同意严格按本公司的指导方法进行学习,并愿意承担方案过程中可能产生的任何不良反应','您反映的身体症状,以及提供的医院的病例及检验数据(如有),是否真实、准确、完整?','您是否自愿承担健康学习方案过程中突发性生命危险或病情加重的后果,并不以任何形式追究本公司的任何责任?','个人情况','其他不适(填写)']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
81
app/Exports/OrderUserInfoExport.php
Normal file
81
app/Exports/OrderUserInfoExport.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Activity;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class OrderUserInfoExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$items = [];
|
||||
$sex = "男";
|
||||
if($this->data['user']->sex == 2){
|
||||
$sex = "女";
|
||||
}
|
||||
$items[] = [
|
||||
$this->data['user']->name,
|
||||
$this->data['user']->birthday,
|
||||
$this->data['user']->stature,
|
||||
$this->data['user_info']->weight,
|
||||
$sex,
|
||||
$this->data['user']->mobile,
|
||||
$this->data['user_info']->address,
|
||||
];
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['真实姓名','出生日期', '身高', '体重','性别','手机号','地址']
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
$sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
142
app/Exports/OrdersExport.php
Normal file
142
app/Exports/OrdersExport.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Order;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class OrdersExport implements FromArray,WithHeadings,WithStyles,WithEvents
|
||||
{
|
||||
protected $keyword;
|
||||
protected $pay_status;
|
||||
protected $status;
|
||||
protected $agency_id;
|
||||
protected $header;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->keyword = $data['keyword']??null;
|
||||
$this->pay_status = $data['pay_status']??null;
|
||||
$this->status = $data['status']??null;
|
||||
$this->agency_id = $data['agency_id']??null;
|
||||
}
|
||||
|
||||
public function array():array
|
||||
{
|
||||
$orders = [];
|
||||
Order::query()
|
||||
->with([
|
||||
'user:id,name,mobile,avatar',
|
||||
'service:id,title,pic',
|
||||
'agency:id,name,mobile',
|
||||
'commission' => function($commission){
|
||||
$commission->with(['service_user:user_id,name,mobile'])->select('id','order_id','role','user_id');
|
||||
},
|
||||
"recommendUser",
|
||||
])
|
||||
->serviceOrder()
|
||||
->when($this->keyword !== null,function ($query){
|
||||
$query->where(function ($query){
|
||||
$query->where('name', 'like', '%' . $this->keyword . '%')
|
||||
->orWhere('mobile', 'like', '%' . $this->keyword . '%');
|
||||
});
|
||||
})
|
||||
->when($this->pay_status !== null,function ($query){
|
||||
$query->where('pay_status',$this->pay_status);
|
||||
})
|
||||
->when($this->status !== null,function ($query){
|
||||
$query->where('status',$this->status);
|
||||
})
|
||||
->when($this->agency_id !== null,function ($query){
|
||||
$query->where('agency_id',$this->agency_id);
|
||||
})
|
||||
->orderByDesc('id')
|
||||
->get()
|
||||
->each(function ($order) use (&$orders){
|
||||
$commission_arr = [
|
||||
1=>'',
|
||||
2=>'',
|
||||
3=>'',
|
||||
4=>'',
|
||||
5=>'',
|
||||
];
|
||||
foreach ($order->commission as $commission){
|
||||
$commission_arr[$commission->role] .= $commission->service_user?$commission->service_user->name:'' .',';
|
||||
}
|
||||
$order_item = [
|
||||
$order->id,
|
||||
$order->price,
|
||||
['UNPAID'=>'未支付','PAID'=>'已支付'][$order->pay_status],
|
||||
$order->offline_order?'虚拟订单':'线上订单',
|
||||
['NOTSTART'=>'未开始','STARTING'=>'进行中','FINISHED'=>'已结束', 'SUSPEND'=>"暂停中"][$order->status],
|
||||
$order->trade_no.' ',
|
||||
$order->desc,
|
||||
$order->user?->name??null,
|
||||
$order->user?->mobile??null,
|
||||
$order->agency?->name??null,
|
||||
$order->agency?->mobile??null,
|
||||
$order->recommendUser->name??"",
|
||||
$order->recommendUser->mobile??"",
|
||||
$commission_arr[2],
|
||||
$commission_arr[3],
|
||||
$commission_arr[4],
|
||||
$commission_arr[5],
|
||||
];
|
||||
$orders[] = $order_item;
|
||||
});
|
||||
return $orders;
|
||||
}
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
['订单信息', '', '', '', '', '', '', '联系人', '', '子公司信息', '', '服务人员', '', '', '', ''],
|
||||
['订单id', '订单价格', '订单状态', '订单类型', '服务状态', '订单号', '订单描述', '姓名', '电话', '负责人姓名', '电话', '推荐人-姓名', "推荐人-手机号", '主教练', '副教练', '客服', '企业介绍人']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$sheet->getStyle('F')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
|
||||
|
||||
$sheet->mergeCells('A1:G1');
|
||||
$sheet->mergeCells('H1:I1');
|
||||
$sheet->mergeCells('J1:K1');
|
||||
$sheet->mergeCells('L1:P1');
|
||||
|
||||
return [
|
||||
1 => [
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->calculateColumnWidths();
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
108
app/Exports/OrdersExportV2.php
Normal file
108
app/Exports/OrdersExportV2.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Order;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class OrdersExportV2 implements FromCollection,WithHeadings
|
||||
{
|
||||
protected $orders;
|
||||
public function __construct($orders)
|
||||
{
|
||||
$this->orders = $orders;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$items =[];
|
||||
$orders = $this->orders;
|
||||
foreach ($orders as $order)
|
||||
{
|
||||
switch ($order->pay_status) {
|
||||
case Order::UNPAID_STATUS:
|
||||
$pay_status = "未支付";
|
||||
break;
|
||||
case Order::PAID_STATUS:
|
||||
$pay_status = "已支付";
|
||||
break;
|
||||
default:
|
||||
$pay_status = "未知";
|
||||
}
|
||||
switch ($order->status) {
|
||||
case Order::NOTSTART_STATUS:
|
||||
$status = "未开始";
|
||||
break;
|
||||
case Order::STARTING_STATUS:
|
||||
$status = "进行中";
|
||||
break;
|
||||
case Order::FINISHED_STATUS:
|
||||
$status = "已完成";
|
||||
break;
|
||||
case Order::SUSPEND_STATUS:
|
||||
$status = "暂停中";
|
||||
break;
|
||||
default:
|
||||
$status = "未知";
|
||||
|
||||
}
|
||||
$service_role = $order->service_role;
|
||||
$role1 = $role2 = $role3 = [];
|
||||
foreach ($service_role as $role) {
|
||||
if ($role->role_id == 1) {
|
||||
$role1[] = $role->serviceUser->name??'';
|
||||
}
|
||||
if ($role->role_id == 2) {
|
||||
$role2[] = $role->serviceUser->name??'';
|
||||
}
|
||||
if ($role->role_id == 3) {
|
||||
$role3[] = $role->serviceUser->name??'';
|
||||
}
|
||||
}
|
||||
|
||||
$city = $province = '';
|
||||
if ($order->agreement && $order->agreement->quotaInfo && $order->agreement->quotaInfo->agencyInfo) {
|
||||
$city = $order->agreement->quotaInfo->agencyInfo->city;
|
||||
$province = $order->agreement->quotaInfo->agencyInfo->province;
|
||||
}
|
||||
$collaborator_name = '';
|
||||
if ($order->agreement && $order->agreement->quotaInfo && $order->agreement->quotaInfo->collaboratorInfo) {
|
||||
$collaborator_name = $order->agreement->quotaInfo->collaboratorInfo->name;
|
||||
}
|
||||
$city = $city?:$province;
|
||||
$agency = $city.'-'.$collaborator_name;
|
||||
$items[] = [
|
||||
$order->id,
|
||||
$order->name,
|
||||
$order->mobile,
|
||||
$order->recommendUser->name??"",
|
||||
$order->recommendUser->mobile??"",
|
||||
$order->price,
|
||||
$pay_status,
|
||||
$order->offline_order?'虚拟订单':'线上订单',
|
||||
$status,
|
||||
$order->is_show?'展示':'不展示',
|
||||
$agency,
|
||||
implode(',', $role1),
|
||||
implode(',', $role2),
|
||||
implode(',', $role3),
|
||||
$order->trade_no,
|
||||
$order->desc,
|
||||
$order->created_at->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
return collect($items);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
["订单id", "联系人姓名", "联系人手机号", "推荐人姓名", "推荐人手机号", "订单价格", '订单状态', "订单类型", "服务状态", "对外展示", '子公司', "主教练",'副教练', '客服',"订单号", "订单描述", "操作时间"]
|
||||
];
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user