From d22f743b18e2ae7b6015ef0f9b7e11f6ec6511be Mon Sep 17 00:00:00 2001 From: denghy Date: Wed, 7 Nov 2018 17:56:50 +0800 Subject: [PATCH] =?UTF-8?q?RD=E6=95=B0=E6=8D=AE=E5=BA=93=E8=AE=BE=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 10 +- app/Dicts.php | 6 + .../2018_08_14_142405_create_logs.php | 2 + app/Domains/{True => Real}/.gitkeep | 0 .../2018_11_07_093322_create_real_tables.php | 192 ++++++++++++++++++ .../Providers/RealServiceProvider.php} | 12 +- .../Providers/RouteServiceProvider.php | 4 +- app/Domains/Real/Routes/api.php | 15 ++ app/Domains/{True => Real}/Routes/web.php | 8 +- app/Domains/{True => Real}/composer.json | 2 +- .../2018_11_06_185140_create_true_tables.php | 28 --- app/Domains/True/Routes/api.php | 15 -- app/Models/Card.php | 60 ++++++ app/Models/Real/Bloc.php | 18 ++ app/Models/Real/Company.php | 28 +++ app/Models/Real/Order.php | 40 ++++ app/Models/Real/Package.php | 28 +++ config/database.php | 22 +- database/seeds/PermissionSeeder.php | 4 +- tests/ExampleTest.php | 17 +- 20 files changed, 434 insertions(+), 77 deletions(-) rename app/Domains/{True => Real}/.gitkeep (100%) create mode 100644 app/Domains/Real/Database/migrations/2018_11_07_093322_create_real_tables.php rename app/Domains/{True/Providers/TrueServiceProvider.php => Real/Providers/RealServiceProvider.php} (65%) rename app/Domains/{True => Real}/Providers/RouteServiceProvider.php (82%) create mode 100644 app/Domains/Real/Routes/api.php rename app/Domains/{True => Real}/Routes/web.php (52%) rename app/Domains/{True => Real}/composer.json (82%) delete mode 100644 app/Domains/True/Database/migrations/2018_11_06_185140_create_true_tables.php delete mode 100644 app/Domains/True/Routes/api.php create mode 100644 app/Models/Card.php create mode 100644 app/Models/Real/Bloc.php create mode 100644 app/Models/Real/Company.php create mode 100644 app/Models/Real/Order.php create mode 100644 app/Models/Real/Package.php diff --git a/.env.example b/.env.example index 8c78c296..05d954d6 100644 --- a/.env.example +++ b/.env.example @@ -14,11 +14,11 @@ DB_DATABASE=vd DB_USERNAME=root DB_PASSWORD=root -DB_TD_HOST=rm-bp13y52rav2jc6952o.mysql.rds.aliyuncs.com -DB_TD_PORT=3306 -DB_TD_DATABASE=ckb_jxc -DB_TD_USERNAME=root -DB_TD_PASSWORD=Fxft123456 +DB_REAL_HOST=rm-bp13y52rav2jc6952o.mysql.rds.aliyuncs.com +DB_REAL_PORT=3306 +DB_REAL_DATABASE=ckb_jxc +DB_REAL_USERNAME=root +DB_REAL_PASSWORD=Fxft123456 DB_MONGO_DSN=mongodb://root:Fxft2017@dds-bp104401edaca7e41595-pub.mongodb.rds.aliyuncs.com:3717,dds-bp104401edaca7e42171-pub.mongodb.rds.aliyuncs.com:3717/admin?replicaSet=mgset-3015103 DB_MONGO_DATABASE=CardInfo diff --git a/app/Dicts.php b/app/Dicts.php index f51f6a0f..95a739c4 100644 --- a/app/Dicts.php +++ b/app/Dicts.php @@ -7,6 +7,7 @@ use Illuminate\Config\Repository; class Dicts extends Repository { const DICTS = [ + 'has' => ['无', '有'], 'sex' => ['未知', '男', '女'], 'params' => ['limit', 'page', 'search', 'searchFields', 'filter', 'orderBy', 'sortedBy', 'with', 'searchJoin'], 'horoscope' => ['未知', '水瓶座', '双鱼座', '白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座'], @@ -17,6 +18,11 @@ class Dicts extends Repository 'permission_status' => ['关闭', '启用'], 'week' => ['周日', '周一', '周二', '周三', '周四', '周五', '周六'], 'weekIso' => ['周一', '周二', '周三', '周四', '周五', '周六', '周日'], + 'pay_type' => ['微信支付', '支付宝', '银行转账'], + 'carrier_operator' => ['联通', '移动', '电信'], + 'service_type' => ['套餐开通', '套餐续费', '套餐更换', '套餐销售'], + 'card_status' => ['测试期', '沉默期', '服务期', '已注销'], + 'bloc_channel' => ['运营商', '中间商'], ]; public function __construct() diff --git a/app/Domains/Log/Database/migrations/2018_08_14_142405_create_logs.php b/app/Domains/Log/Database/migrations/2018_08_14_142405_create_logs.php index da317095..34145594 100644 --- a/app/Domains/Log/Database/migrations/2018_08_14_142405_create_logs.php +++ b/app/Domains/Log/Database/migrations/2018_08_14_142405_create_logs.php @@ -34,6 +34,8 @@ class CreateLogs extends Migration $table->primary('id'); }); + + db_alter('logs', '日志表'); } /** diff --git a/app/Domains/True/.gitkeep b/app/Domains/Real/.gitkeep similarity index 100% rename from app/Domains/True/.gitkeep rename to app/Domains/Real/.gitkeep diff --git a/app/Domains/Real/Database/migrations/2018_11_07_093322_create_real_tables.php b/app/Domains/Real/Database/migrations/2018_11_07_093322_create_real_tables.php new file mode 100644 index 00000000..1bb58dbc --- /dev/null +++ b/app/Domains/Real/Database/migrations/2018_11_07_093322_create_real_tables.php @@ -0,0 +1,192 @@ +string('id', 20)->comment('企业编号'); + $table->string('name', 32)->comment('企业名称'); + $table->timestamps(); + + $table->primary('id'); + $table->index('name'); + }); + + db_alter('real_companies', 'RD企业'); + + Schema::create('real_blocs', function (Blueprint $table) { + $table->string('id', 20)->comment('集团编号'); + $table->string('name', 32)->comment('集团名称'); + $table->tinyInteger('carrier_operator')->comment('运营商(0:联通 1:移动 2:电信)'); + $table->string('city')->comment('城市'); + $table->tinyInteger('channel')->comment('渠道(0:运营商 1:中间商)'); + $table->timestamps(); + + $table->primary('id'); + $table->index('name'); + $table->index('carrier_operator'); + }); + + db_alter('real_blocs', 'RD来源集团'); + + Schema::create('real_packages', function (Blueprint $table) { + $table->string('id', 20)->comment('套餐编号'); + $table->string('parent_id', 20)->comment('父级编号'); + $table->string('name', 32)->comment('套餐名称'); + $table->tinyInteger('type')->unsigned()->default(0)->comment('套餐类型(0:基础套餐 1:续费包 2:加油包 3:可选包 4:附加包)'); + $table->tinyInteger('carrier_operator')->comment('运营商(0:联通 1:移动 2:电信)'); + $table->integer('cost_price')->unsigned()->default(0)->comment('成本价格'); + $table->integer('guide_price')->unsigned()->default(0)->comment('指导价格'); + $table->integer('flows')->unsigned()->default(0)->comment('套餐流量(M)'); + $table->integer('voices')->unsigned()->default(0)->comment('套餐语音(分钟)'); + $table->integer('messages')->unsigned()->default(0)->comment('套餐短信(条)'); + $table->tinyInteger('has_message_switch')->unsigned()->default(0)->comment('短信开关(0:无 1:有)'); + $table->tinyInteger('has_lbs')->unsigned()->default(0)->comment('lbs位置服务(0:无 1:有)'); + $table->tinyInteger('flow_cycles')->unsigned()->default(0)->comment('流量周期(月)'); + $table->tinyInteger('package_cycles')->unsigned()->default(0)->comment('套餐周期(月)'); + $table->timestamps(); + + $table->primary('id'); + $table->index('name'); + $table->index('parent_id'); + $table->index('type'); + $table->index('carrier_operator'); + }); + + db_alter('real_packages', 'RD套餐'); + + // 企业套餐关联表 + Schema::create('real_company_has_packages', function (Blueprint $table) { + $table->string('company_id', 20)->comment('企业编号'); + $table->string('package_id', 20)->comment('套餐编号'); + $table->primary(['company_id', 'package_id']); + }); + + db_alter('real_company_has_packages', 'RD企业套餐关联表'); + + Schema::create('cards', function (Blueprint $table) { + $table->string('sim', 20)->comment('sim号'); + $table->string('imei', 20)->comment('imei号'); + $table->string('iccid', 20)->comment('iccid号'); + $table->string('real_company_id', 20)->comment('RD企业编号'); + $table->string('real_package_id', 20)->comment('RD套餐编号'); + $table->string('real_bloc_id', 20)->comment('RD来源集团编号'); + $table->integer('real_price')->unsigned()->default(0)->comment('RD售价'); + $table->tinyInteger('carrier_operator')->comment('运营商(0:联通 1:移动 2:电信)'); + $table->string('virtual_company_id', 20)->comment('VD企业编号'); + $table->string('virtual_package_id', 20)->comment('VD套餐编号'); + $table->integer('virtual_price')->unsigned()->default(0)->comment('VD售价'); + $table->timestamp('activate_at')->nullable()->comment('激活时间'); + $table->timestamps(); + + $table->primary('sim'); + $table->index('imei'); + $table->index('iccid'); + $table->index('real_company_id'); + $table->index('real_package_id'); + $table->index('real_bloc_id'); + $table->index('carrier_operator'); + $table->index('virtual_company_id'); + $table->index('virtual_package_id'); + $table->index('activate_at'); + }); + + db_alter('cards', '卡基础信息表'); + + Schema::create('real_orders', function (Blueprint $table) { + $table->string('id', 20)->comment('订单编号'); + $table->tinyInteger('type')->unsigned()->default(0)->comment('套餐类型(0:基础套餐 1:续费包 2:加油包 3:可选包 4:附加包)'); + $table->string('company_id', 20)->comment('RD企业编号'); + $table->string('package_id', 20)->comment('RD套餐编号'); + $table->integer('unit_price')->unsigned()->default(0)->comment('订单单价'); + $table->integer('counts')->unsigned()->default(0)->comment('出卡数量'); + $table->integer('total_price')->unsigned()->default(0)->comment('订单总价'); + $table->timestamp('order_at')->nullable()->comment('订单时间'); + $table->timestamp('service_start_at')->nullable()->comment('服务开始时间'); + $table->timestamp('service_end_at')->nullable()->comment('服务结束时间'); + $table->timestamps(); + + $table->index('type'); + $table->index('company_id'); + $table->index('package_id'); + $table->index('order_at'); + }); + + db_alter('real_orders', 'RD订单'); + + // 卡关联基础订单 + Schema::create('real_order_base_card_relations', function (Blueprint $table) { + $table->string('orders_id', 20)->comment('订单编号'); + $table->string('sim', 20)->comment('sim卡号'); + $table->primary(['orders_id', 'sim']); + }); + + db_alter('real_order_base_card_relations', 'RD卡关联基础订单'); + + // 卡关联续费订单 + Schema::create('real_order_renewal_card_relations', function (Blueprint $table) { + $table->string('orders_id', 20)->comment('订单编号'); + $table->string('sim', 20)->comment('sim卡号'); + $table->primary(['orders_id', 'sim']); + }); + + db_alter('real_order_renewal_card_relations', 'RD卡关联续费订单'); + + // 卡关联加油包订单 + Schema::create('real_order_flows_card_relations', function (Blueprint $table) { + $table->string('orders_id', 20)->comment('订单编号'); + $table->string('sim', 20)->comment('sim卡号'); + $table->primary(['orders_id', 'sim']); + }); + + db_alter('real_order_flows_card_relations', 'RD卡关联加油包订单'); + + // 卡关联可选包订单 + Schema::create('real_order_optional_card_relations', function (Blueprint $table) { + $table->string('orders_id', 20)->comment('订单编号'); + $table->string('sim', 20)->comment('sim卡号'); + $table->primary(['orders_id', 'sim']); + }); + + db_alter('real_order_optional_card_relations', 'RD卡关联可选包订单'); + + // 卡关联附加订单 + Schema::create('real_order_additional_card_relations', function (Blueprint $table) { + $table->string('orders_id', 20)->comment('订单编号'); + $table->string('sim', 20)->comment('sim卡号'); + $table->primary(['orders_id', 'sim']); + }); + + db_alter('real_order_additional_card_relations', 'RD卡关联附加订单'); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('real_order_additional_card_relations'); + Schema::dropIfExists('real_order_optional_card_relations'); + Schema::dropIfExists('real_order_flows_card_relations'); + Schema::dropIfExists('real_order_renewal_card_relations'); + Schema::dropIfExists('real_order_base_card_relations'); + Schema::dropIfExists('real_orders'); + Schema::dropIfExists('cards'); + Schema::dropIfExists('real_company_has_packages'); + Schema::dropIfExists('real_packages'); + Schema::dropIfExists('real_blocs'); + Schema::dropIfExists('real_companies'); + } +} diff --git a/app/Domains/True/Providers/TrueServiceProvider.php b/app/Domains/Real/Providers/RealServiceProvider.php similarity index 65% rename from app/Domains/True/Providers/TrueServiceProvider.php rename to app/Domains/Real/Providers/RealServiceProvider.php index b3730844..7b7ec019 100644 --- a/app/Domains/True/Providers/TrueServiceProvider.php +++ b/app/Domains/Real/Providers/RealServiceProvider.php @@ -1,24 +1,24 @@ loadMigrationsFrom([realpath(__DIR__ . '/../Database/migrations')]); + $this->loadMigrationsFrom([realpath(__DIR__ . '/../Database/migrations')]); // $this->app->make(EloquentFactory::class)->load(realpath(__DIR__ . '/../Database/factories')); - // $this->mergeConfigFrom(realpath(__DIR__ . '/../config.php'), 'domain.true'); + // $this->mergeConfigFrom(realpath(__DIR__ . '/../config.php'), 'domain.real'); } /** diff --git a/app/Domains/True/Providers/RouteServiceProvider.php b/app/Domains/Real/Providers/RouteServiceProvider.php similarity index 82% rename from app/Domains/True/Providers/RouteServiceProvider.php rename to app/Domains/Real/Providers/RouteServiceProvider.php index f7cca79f..a105c331 100644 --- a/app/Domains/True/Providers/RouteServiceProvider.php +++ b/app/Domains/Real/Providers/RouteServiceProvider.php @@ -1,5 +1,5 @@ app; - $namespace = 'App\Domains\True\Http\Controllers'; + $namespace = 'App\Domains\Real\Http\Controllers'; $pathApi = __DIR__.'/../Routes/api.php'; $pathWeb = __DIR__.'/../Routes/web.php'; diff --git a/app/Domains/Real/Routes/api.php b/app/Domains/Real/Routes/api.php new file mode 100644 index 00000000..c09468b5 --- /dev/null +++ b/app/Domains/Real/Routes/api.php @@ -0,0 +1,15 @@ +group(['prefix' => 'reals', 'as' => 'reals'], function($router) { + + // The controllers live in Domains/Real/Http/Controllers + $router->get('/', ['as' => 'index', 'uses' => 'RealController@index']); + + /** + * 需要认证的接口 + */ + // $router->group(['middleware' => ['adminAuth']], function($router) { + // // $router->post('delete', ['as' => 'delete', 'uses' => 'RealController@delete']); + // }); +}); \ No newline at end of file diff --git a/app/Domains/True/Routes/web.php b/app/Domains/Real/Routes/web.php similarity index 52% rename from app/Domains/True/Routes/web.php rename to app/Domains/Real/Routes/web.php index 2186e459..228b63ec 100644 --- a/app/Domains/True/Routes/web.php +++ b/app/Domains/Real/Routes/web.php @@ -1,14 +1,14 @@ group(['prefix' => 'trues', 'as' => 'trues'], function($router) { +$router->group(['prefix' => 'reals', 'as' => 'reals'], function($router) { - // The controllers live in Domains/True/Http/Controllers - // $router->get('/', ['as' => 'index', 'uses' => 'TrueController@index']); + // The controllers live in Domains/Real/Http/Controllers + // $router->get('/', ['as' => 'index', 'uses' => 'RealController@index']); /** * 需要认证的接口 */ // $router->group(['middleware' => ['userAuth']], function($router) { - // // $router->post('delete', ['as' => 'delete', 'uses' => 'TrueController@delete']); + // // $router->post('delete', ['as' => 'delete', 'uses' => 'RealController@delete']); // }); }); diff --git a/app/Domains/True/composer.json b/app/Domains/Real/composer.json similarity index 82% rename from app/Domains/True/composer.json rename to app/Domains/Real/composer.json index b69548a9..377dca99 100644 --- a/app/Domains/True/composer.json +++ b/app/Domains/Real/composer.json @@ -1,5 +1,5 @@ { - "name": "app/true", + "name": "app/real", "description": "", "type": "app-domain", "require": { diff --git a/app/Domains/True/Database/migrations/2018_11_06_185140_create_true_tables.php b/app/Domains/True/Database/migrations/2018_11_06_185140_create_true_tables.php deleted file mode 100644 index 404fceb1..00000000 --- a/app/Domains/True/Database/migrations/2018_11_06_185140_create_true_tables.php +++ /dev/null @@ -1,28 +0,0 @@ -group(['prefix' => 'trues', 'as' => 'trues'], function($router) { - - // The controllers live in Domains/True/Http/Controllers - $router->get('/', ['as' => 'index', 'uses' => 'TrueController@index']); - - /** - * 需要认证的接口 - */ - // $router->group(['middleware' => ['adminAuth']], function($router) { - // // $router->post('delete', ['as' => 'delete', 'uses' => 'TrueController@delete']); - // }); -}); \ No newline at end of file diff --git a/app/Models/Card.php b/app/Models/Card.php new file mode 100644 index 00000000..8ce11340 --- /dev/null +++ b/app/Models/Card.php @@ -0,0 +1,60 @@ +belongsTo(RealCompany::class, 'real_company_id', 'id'); + } + + public function realPackage() + { + return $this->belongsTo(RealPackage::class, 'real_package_id', 'id'); + } + + // 基础订单 + public function realOrderBases() + { + return $this->belongsToMany(RealOrder::class, 'real_order_base_card_relations', 'sim' ,'order_id'); + } + + // 续费订单 + public function realOrderRenewals() + { + return $this->belongsToMany(RealOrder::class, 'real_order_renewal_card_relations', 'sim' ,'order_id'); + } + + // 加油包订单 + public function realOrderFlows() + { + return $this->belongsToMany(RealOrder::class, 'real_order_flows_card_relations', 'sim' ,'order_id'); + } + + // 可选包订单 + public function realOrderOptional() + { + return $this->belongsToMany(RealOrder::class, 'real_order_optional_card_relations', 'sim' ,'order_id'); + } + + // 附加包订单 + public function realOrderAdditional() + { + return $this->belongsToMany(RealOrder::class, 'real_order_additional_card_relations', 'sim' ,'order_id'); + } +} diff --git a/app/Models/Real/Bloc.php b/app/Models/Real/Bloc.php new file mode 100644 index 00000000..bcf00822 --- /dev/null +++ b/app/Models/Real/Bloc.php @@ -0,0 +1,18 @@ +hasMany(Card::class, 'real_bloc_id', 'id'); + } +} diff --git a/app/Models/Real/Company.php b/app/Models/Real/Company.php new file mode 100644 index 00000000..9211dbdb --- /dev/null +++ b/app/Models/Real/Company.php @@ -0,0 +1,28 @@ +belongsToMany(Package::class, 'real_company_has_packages', 'company_id', 'package_id'); + } + + public function cards() + { + return $this->hasMany(Card::class, 'real_company_id', 'id'); + } + + public function orders() + { + return $this->hasMany(Order::class, 'company_id', 'id'); + } +} diff --git a/app/Models/Real/Order.php b/app/Models/Real/Order.php new file mode 100644 index 00000000..e8d13d97 --- /dev/null +++ b/app/Models/Real/Order.php @@ -0,0 +1,40 @@ +belongsToMany(Card::class, 'real_order_base_card_relations', 'order_id', 'sim'); + } + + public function cardRenewals() + { + return $this->belongsToMany(Card::class, 'real_order_renewal_card_relations', 'order_id', 'sim'); + } + + public function cardFlows() + { + return $this->belongsToMany(Card::class, 'real_order_flows_card_relations', 'order_id', 'sim'); + } + + public function cardOptional() + { + return $this->belongsToMany(Card::class, 'real_order_optional_card_relations', 'order_id', 'sim'); + } + + public function cardAdditional() + { + return $this->belongsToMany(Card::class, 'real_order_additional_card_relations', 'order_id', 'sim'); + } +} diff --git a/app/Models/Real/Package.php b/app/Models/Real/Package.php new file mode 100644 index 00000000..d32bc855 --- /dev/null +++ b/app/Models/Real/Package.php @@ -0,0 +1,28 @@ +belongsToMany(Company::class, 'real_company_has_packages', 'package_id', 'company_id'); + } + + public function cards() + { + return $this->hasMany(Card::class, 'real_package_id', 'id'); + } + + public function orders() + { + return $this->hasMany(Order::class, 'package_id', 'id'); + } +} diff --git a/config/database.php b/config/database.php index 2e425c23..91d884c2 100644 --- a/config/database.php +++ b/config/database.php @@ -71,18 +71,18 @@ return [ 'strict' => env('DB_STRICT_MODE', false), ], - 'td' => [ + 'real' => [ 'driver' => 'mysql', - 'host' => env('DB_TD_HOST', 'localhost'), - 'port' => env('DB_TD_PORT', 3306), - 'database' => env('DB_TD_DATABASE', 'forge'), - 'username' => env('DB_TD_USERNAME', 'forge'), - 'password' => env('DB_TD_PASSWORD', ''), - 'charset' => env('DB_TD_CHARSET', 'utf8mb4'), - 'collation' => env('DB_TD_COLLATION', 'utf8mb4_unicode_ci'), - 'prefix' => env('DB_TD_PREFIX', ''), - 'timezone' => env('DB_TD_TIMEZONE', '+08:00'), - 'strict' => env('DB_TD_STRICT_MODE', false), + 'host' => env('DB_REAL_HOST', 'localhost'), + 'port' => env('DB_REAL_PORT', 3306), + 'database' => env('DB_REAL_DATABASE', 'forge'), + 'username' => env('DB_REAL_USERNAME', 'forge'), + 'password' => env('DB_REAL_PASSWORD', ''), + 'charset' => env('DB_REAL_CHARSET', 'utf8mb4'), + 'collation' => env('DB_REAL_COLLATION', 'utf8mb4_unicode_ci'), + 'prefix' => env('DB_REAL_PREFIX', ''), + 'timezone' => env('DB_REAL_TIMEZONE', '+08:00'), + 'strict' => env('DB_REAL_STRICT_MODE', false), ], 'mongo' => [ diff --git a/database/seeds/PermissionSeeder.php b/database/seeds/PermissionSeeder.php index 28105ab6..a39dfd3f 100644 --- a/database/seeds/PermissionSeeder.php +++ b/database/seeds/PermissionSeeder.php @@ -10,9 +10,7 @@ use App\Domains\Permission\Repositories\PermissionRepository; class PermissionSeeder extends Seeder { - const ROLES = [ - 'name' => '超级管理员', 'type' => 0, - ]; + const ROLES = ['name' => '超级管理员']; const PERMISSIONS = [ [ diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php index e6d41ee3..328afbd7 100644 --- a/tests/ExampleTest.php +++ b/tests/ExampleTest.php @@ -1,7 +1,20 @@ table('tblCard')->find('1440059652572'); +dd(\DB::connection('mongo')->table('tblCard')->count()); -dd($res); \ No newline at end of file +$conditions = [ + 'starttime' => Carbon::parse('2018-10-01')->startOfDay(), + 'endtime' => Carbon::parse('2018-10-31')->startOfDay(), +]; + +$res = \DB::connection('mongo')->table('tblCard')->where(function ($query) use ($conditions) { + $query->where('exPCodes.cDate', '>=', $conditions['starttime'])->where('exPCodes.cDate', '<=', $conditions['endtime'])->where('oDate', 'exists', false); +})->orWhere(function ($query) use ($conditions) { + $query->where('exPCodes.oDate', '>=', $conditions['starttime'])->where('exPCodes.oDate', '<=', $conditions['endtime'])->where('pType', 0); +})->first(); + +dd($res['exPCodes']);