From d22947f552dd804a4242b2aaff1f8e2cb2cda67e Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Mon, 17 Aug 2020 15:27:43 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E5=88=9D=E5=A7=8B-=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7=E6=95=B0?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StoreUserReportController.php | 64 +++++++++++++ app/Admin/Repositories/StoreUserReport.php | 16 ++++ app/Models/storeUserReport.php | 15 +++ dcat_admin_ide_helper.php | 92 ++++++++++--------- resources/lang/zh-CN/store-user-report.php | 13 +++ 5 files changed, 156 insertions(+), 44 deletions(-) create mode 100644 app/Admin/Controllers/StoreUserReportController.php create mode 100644 app/Admin/Repositories/StoreUserReport.php create mode 100644 app/Models/storeUserReport.php create mode 100644 resources/lang/zh-CN/store-user-report.php diff --git a/app/Admin/Controllers/StoreUserReportController.php b/app/Admin/Controllers/StoreUserReportController.php new file mode 100644 index 0000000..0ab474c --- /dev/null +++ b/app/Admin/Controllers/StoreUserReportController.php @@ -0,0 +1,64 @@ +id->sortable(); + $grid->market_id; + $grid->name; + $grid->mm_user_id; + + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id'); + + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new StoreUserReport(), function (Show $show) { + $show->id; + $show->market_id; + $show->name; + $show->mm_user_id; + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new StoreUserReport(), function (Form $form) { + $form->display('id'); + $form->text('market_id'); + $form->text('name'); + $form->text('mm_user_id'); + }); + } +} diff --git a/app/Admin/Repositories/StoreUserReport.php b/app/Admin/Repositories/StoreUserReport.php new file mode 100644 index 0000000..ca24eca --- /dev/null +++ b/app/Admin/Repositories/StoreUserReport.php @@ -0,0 +1,16 @@ + [ + 'StoreUserReport' => 'StoreUserReport', + ], + 'fields' => [ + 'market_id' => '所属市场', + 'name' => '商家名称', + 'mm_user_id' => '所属市场经理', + ], + 'options' => [ + ], +]; From 7d96b5f17744f09a55c9f93c1ded280baa4c6e01 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Tue, 18 Aug 2020 10:26:12 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E5=BA=97=E9=93=BA=E6=96=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=BB=9F=E8=AE=A1-=E6=95=B0=E6=8D=AE=E6=BA=90?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=B7=BB=E5=8A=A0=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StoreUserReportController.php | 1 + app/Admin/Repositories/StoreUserReport.php | 33 ++++++++ app/Admin/routes.php | 5 +- app/Models/CouponSetting.php | 2 +- composer.lock | 79 ++++++++++++++++++- resources/lang/zh-CN/coupon-setting.php | 3 +- resources/lang/zh-CN/store-user-report.php | 1 + 7 files changed, 119 insertions(+), 5 deletions(-) diff --git a/app/Admin/Controllers/StoreUserReportController.php b/app/Admin/Controllers/StoreUserReportController.php index 0ab474c..1b7ef23 100644 --- a/app/Admin/Controllers/StoreUserReportController.php +++ b/app/Admin/Controllers/StoreUserReportController.php @@ -22,6 +22,7 @@ class StoreUserReportController extends AdminController $grid->market_id; $grid->name; $grid->mm_user_id; + $grid->new_user_total; $grid->filter(function (Grid\Filter $filter) { $filter->equal('id'); diff --git a/app/Admin/Repositories/StoreUserReport.php b/app/Admin/Repositories/StoreUserReport.php index ca24eca..a5ca2fb 100644 --- a/app/Admin/Repositories/StoreUserReport.php +++ b/app/Admin/Repositories/StoreUserReport.php @@ -3,7 +3,9 @@ namespace App\Admin\Repositories; use App\Models\storeUserReport as Model; +use Dcat\Admin\Grid\Model as GridModel; use Dcat\Admin\Repositories\EloquentRepository; +use Illuminate\Support\Facades\DB; class StoreUserReport extends EloquentRepository { @@ -13,4 +15,35 @@ class StoreUserReport extends EloquentRepository * @var string */ protected $eloquentClass = Model::class; + + /** + * 获取统计列表数据 + */ + public function get(GridModel $model) + { + $where = ['2020-06-01','2020-07-01']; + + $list = DB::select(" SELECT + store.id + ,store.market_id + ,store.`name` + ,store.mm_user_id + ,count(distinct orders.user_id) new_user_total + FROM + ims_cjdc_order orders + INNER JOIN ims_cjdc_store store ON orders.store_id = store.id + INNER JOIN ims_cjdc_user users ON orders.user_id = users.id + WHERE + users.join_time BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?) + AND UNIX_TIMESTAMP(orders.pay_time) BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?) + GROUP BY store.id + ORDER BY store.id ASC ", + array_merge($where,$where) + ); + $total = count($list); + return $model->makePaginator( + $total, + $list + ); + } } diff --git a/app/Admin/routes.php b/app/Admin/routes.php index 5cf2b29..dfdb92b 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -28,13 +28,14 @@ Route::group([ $router->any('/api/getMpInfo', 'ImsCjdcMarketController@getMpInfo'); $router->get('/coupon/TieForm', 'CouponTieController@CouponTieForm'); - $router->get('/couponTie', 'CouponTieController@CouponTieList'); + $router->resource('/couponSetting', 'couponSettingController'); //获取所有市场 $router->any('/api/getAllMarket', 'LanzuServiceSpeakerController@getAllMarkets'); //根据市场id,商户名查询商户 $router->any('/api/stores', 'LanzuServiceSpeakerController@getStores'); - + //统计店铺新增用户 + $router->resource('/storeUserReport', 'StoreUserReportController'); }); diff --git a/app/Models/CouponSetting.php b/app/Models/CouponSetting.php index 5e2cdcc..cf3889c 100644 --- a/app/Models/CouponSetting.php +++ b/app/Models/CouponSetting.php @@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Model; class CouponSetting extends Model { use HasDateTimeFormatter; - use SoftDeletes; + // use SoftDeletes; protected $table = 'ims_system_coupon_setting'; diff --git a/composer.lock b/composer.lock index b7905c0..d8f4dbc 100644 --- a/composer.lock +++ b/composer.lock @@ -2131,6 +2131,12 @@ "wechat", "weibo" ], + "funding": [ + { + "url": "https://www.patreon.com/overtrue", + "type": "patreon" + } + ], "time": "2020-03-04T15:22:25+00:00" }, { @@ -2204,6 +2210,20 @@ "weixin", "weixin-sdk" ], + "funding": [ + { + "url": "https://www.easywechat.com/img/pay/wechat.jpg", + "type": "custom" + }, + { + "url": "https://github.com/overtrue", + "type": "github" + }, + { + "url": "https://www.patreon.com/overtrue", + "type": "patreon" + } + ], "time": "2020-07-29T07:36:50+00:00" }, { @@ -3183,6 +3203,20 @@ "caching", "psr6" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-07-23T17:22:30+00:00" }, { @@ -3251,6 +3285,20 @@ "interoperability", "standards" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-07-06T13:23:11+00:00" }, { @@ -4850,6 +4898,20 @@ "psr-17", "psr-7" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-06-25T08:21:47+00:00" }, { @@ -5379,6 +5441,20 @@ "instantiate", "serialize" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-06-07T15:42:22+00:00" }, { @@ -7789,5 +7865,6 @@ "platform": { "php": "^7.2.5" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } diff --git a/resources/lang/zh-CN/coupon-setting.php b/resources/lang/zh-CN/coupon-setting.php index 77709ab..d9068fb 100644 --- a/resources/lang/zh-CN/coupon-setting.php +++ b/resources/lang/zh-CN/coupon-setting.php @@ -1,7 +1,8 @@ [ - 'CouponSetting' => 'CouponSetting', + 'CouponSetting' => '领取方式', + 'couponSetting' => '领取方式', ], 'fields' => [ 'name' => '名称', diff --git a/resources/lang/zh-CN/store-user-report.php b/resources/lang/zh-CN/store-user-report.php index 87dd9a1..8fcde6d 100644 --- a/resources/lang/zh-CN/store-user-report.php +++ b/resources/lang/zh-CN/store-user-report.php @@ -6,6 +6,7 @@ return [ 'fields' => [ 'market_id' => '所属市场', 'name' => '商家名称', + 'new_user_total' => '新增用户总数', 'mm_user_id' => '所属市场经理', ], 'options' => [ From 0479c87f01fc9c1e15f8c4be4a06a79b874c3883 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Tue, 18 Aug 2020 12:00:33 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E5=BA=97=E9=93=BA=E6=96=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=BB=9F=E8=AE=A1-=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StoreUserReportController.php | 27 +++++++-- app/Models/ImsCjdcOrder.php | 25 ++++++++ app/Models/ImsCjdcOrderMain.php | 57 +++++++++++++++++++ resources/lang/zh-CN/store-user-report.php | 6 +- 4 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 app/Models/ImsCjdcOrder.php create mode 100644 app/Models/ImsCjdcOrderMain.php diff --git a/app/Admin/Controllers/StoreUserReportController.php b/app/Admin/Controllers/StoreUserReportController.php index 1b7ef23..af19c38 100644 --- a/app/Admin/Controllers/StoreUserReportController.php +++ b/app/Admin/Controllers/StoreUserReportController.php @@ -3,10 +3,14 @@ namespace App\Admin\Controllers; use App\Admin\Repositories\StoreUserReport; +use App\Models\ImsCjdcOrderMain; +use App\Models\storeUserReport as ModelsStoreUserReport; use Dcat\Admin\Form; use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Controllers\AdminController; +use App\Models\ImsCjdcOrder; +use Illuminate\Support\Facades\DB; class StoreUserReportController extends AdminController { @@ -17,15 +21,30 @@ class StoreUserReportController extends AdminController */ protected function grid() { - return Grid::make(new StoreUserReport(), function (Grid $grid) { - $grid->id->sortable(); + $startTime = '2020-06-01';$endTime = '2020-07-01'; + $orderModel = new ImsCjdcOrder(); + $newModel = $orderModel->with([ + 'store:id,market_id,name,mm_user_id', + 'user'=> function($query) use($startTime,$endTime){ + $query->selectRaw(DB::raw('count(distinct user_id) as new_user_total'))->whereRaw("join_time BETWEEN UNIX_TIMESTAMP('?') AND UNIX_TIMESTAMP('?')",[$startTime,$endTime]); + }]) + ->whereRaw("UNIX_TIMESTAMP(pay_time) BETWEEN UNIX_TIMESTAMP('?') AND UNIX_TIMESTAMP('?')",[$startTime,$endTime]) + ->select('store_id') + ->groupBy('store_id') + ->orderBy('market_id','desc') + ->orderbY('new_user_total','desc'); + // return Grid::make(new StoreUserReport(), function (Grid $grid) { + return Grid::make($newModel, function (Grid $grid) { + $grid->disableCreateButton(); + + $grid->store_id; $grid->market_id; - $grid->name; + $grid->store_name; $grid->mm_user_id; $grid->new_user_total; $grid->filter(function (Grid\Filter $filter) { - $filter->equal('id'); + $filter->equal('store_id'); }); }); diff --git a/app/Models/ImsCjdcOrder.php b/app/Models/ImsCjdcOrder.php new file mode 100644 index 0000000..f0e1f95 --- /dev/null +++ b/app/Models/ImsCjdcOrder.php @@ -0,0 +1,25 @@ +hasOne('\App\Models\ImsCjdcUser','id','user_id'); + } + + public function store() + { + return $this->hasOne('\App\Models\ImsCjdcStore','id','store_id'); + } + +} diff --git a/app/Models/ImsCjdcOrderMain.php b/app/Models/ImsCjdcOrderMain.php new file mode 100644 index 0000000..e9f4d63 --- /dev/null +++ b/app/Models/ImsCjdcOrderMain.php @@ -0,0 +1,57 @@ +hasOne('\App\Models\ImsCjdcUser','id','user_id'); + } + + public function market() + { + return $this->hasOne('\App\Models\ImsCjdcMarket','id','market_id'); + } + + /** + * 同时变更主订单和子订单状态, + * @param $oid //主订单id + * @param $state //订单状态 + */ + public function modifyState($oid,$state) + { + return DB::transaction(function () use ($oid,$state){ + $data1['state'] = $data2['state'] = $state; + $data1['update_time'] = time(); + if ($state == 4) { + $data1['complete_time'] = $data2['complete_time'] = time(); + + } elseif ($state == 3) { + $data1['jd_time'] = $data2['jd_time'] = time(); + } + DB::table('ims_cjdc_order_main') + ->where('id',$oid) + ->update($data1); + DB::table('ims_cjdc_order') + ->where('order_main_id',$oid) + ->update($data2); + if ($state==4){ + //添加店铺流水记录 + $account = new StoreAccount(); + $account->addStoreAccount($oid); + } + return true; + }); + + } +} diff --git a/resources/lang/zh-CN/store-user-report.php b/resources/lang/zh-CN/store-user-report.php index 8fcde6d..bdebb38 100644 --- a/resources/lang/zh-CN/store-user-report.php +++ b/resources/lang/zh-CN/store-user-report.php @@ -1,11 +1,13 @@ [ - 'StoreUserReport' => 'StoreUserReport', + 'StoreUserReport' => '店铺新用户报表', + 'storeUserReport' => '店铺新用户报表', ], 'fields' => [ + 'store_id' => '店铺ID', 'market_id' => '所属市场', - 'name' => '商家名称', + 'store_name' => '商家名称', 'new_user_total' => '新增用户总数', 'mm_user_id' => '所属市场经理', ], From c9237908a97d36724fea620938cd472d32f5448b Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Tue, 18 Aug 2020 12:09:47 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Repositories/ImsCjdcOrderMain.php | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 app/Admin/Repositories/ImsCjdcOrderMain.php diff --git a/app/Admin/Repositories/ImsCjdcOrderMain.php b/app/Admin/Repositories/ImsCjdcOrderMain.php new file mode 100644 index 0000000..c09e322 --- /dev/null +++ b/app/Admin/Repositories/ImsCjdcOrderMain.php @@ -0,0 +1,50 @@ +with('market') + ->select('ims_cjdc_order_main.*','ims_cjdc_user.name as user_name') + ->where('type',1) + ->orderBy('ims_cjdc_order_main.id','desc');//只取线上订单数据 + + $this->setSort($model); + $this->setPaginate($model); + + $query = $builder; + $model->getQueries()->unique()->each(function ($value) use (&$query) { + if ($value['method'] == 'paginate') { + $value['arguments'][1] = $this->getGridColumns(); + } elseif ($value['method'] == 'get') { + $value['arguments'] = [$this->getGridColumns()]; + } + $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); + }); + + $query = $query->toArray(); + foreach ($query['data'] as &$value){ + if ($value['state']==3&&$value['order_shipping_code']==1){ + $value['state'] = 31; + } + } + + $query = $model->makePaginator($query['total'],$query['data']); + return $query; + } +} From 58673c8860f83f1d7ae6007ff747acf3e1ee94e6 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Tue, 18 Aug 2020 14:47:40 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E8=BE=93=E5=87=BAsql=E8=AF=AD=E5=8F=A5?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/debugbar.php | 215 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 config/debugbar.php diff --git a/config/debugbar.php b/config/debugbar.php new file mode 100644 index 0000000..23edaa0 --- /dev/null +++ b/config/debugbar.php @@ -0,0 +1,215 @@ + env('DEBUGBAR_ENABLED', true), + 'except' => [ + 'telescope*', + 'horizon*' + ], + + /* + |-------------------------------------------------------------------------- + | Storage settings + |-------------------------------------------------------------------------- + | + | DebugBar stores data for session/ajax requests. + | You can disable this, so the debugbar stores data in headers/session, + | but this can cause problems with large data collectors. + | By default, file storage (in the storage folder) is used. Redis and PDO + | can also be used. For PDO, run the package migrations first. + | + */ + 'storage' => [ + 'enabled' => true, + 'driver' => 'file', // redis, file, pdo, custom + 'path' => storage_path('debugbar'), // For file driver + 'connection' => null, // Leave null for default connection (Redis/PDO) + 'provider' => '' // Instance of StorageInterface for custom driver + ], + + /* + |-------------------------------------------------------------------------- + | Vendors + |-------------------------------------------------------------------------- + | + | Vendor files are included by default, but can be set to false. + | This can also be set to 'js' or 'css', to only include javascript or css vendor files. + | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files) + | and for js: jquery and and highlight.js + | So if you want syntax highlighting, set it to true. + | jQuery is set to not conflict with existing jQuery scripts. + | + */ + + 'include_vendors' => true, + + /* + |-------------------------------------------------------------------------- + | Capture Ajax Requests + |-------------------------------------------------------------------------- + | + | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors), + | you can use this option to disable sending the data through the headers. + | + | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools. + */ + + 'capture_ajax' => true, + 'add_ajax_timing' => false, + + /* + |-------------------------------------------------------------------------- + | Custom Error Handler for Deprecated warnings + |-------------------------------------------------------------------------- + | + | When enabled, the Debugbar shows deprecated warnings for Symfony components + | in the Messages tab. + | + */ + 'error_handler' => false, + + /* + |-------------------------------------------------------------------------- + | Clockwork integration + |-------------------------------------------------------------------------- + | + | The Debugbar can emulate the Clockwork headers, so you can use the Chrome + | Extension, without the server-side code. It uses Debugbar collectors instead. + | + */ + 'clockwork' => false, + + /* + |-------------------------------------------------------------------------- + | DataCollectors + |-------------------------------------------------------------------------- + | + | Enable/disable DataCollectors + | + */ + + 'collectors' => [ + 'phpinfo' => true, // Php version + 'messages' => true, // Messages + 'time' => true, // Time Datalogger + 'memory' => true, // Memory usage + 'exceptions' => true, // Exception displayer + 'log' => true, // Logs from Monolog (merged in messages if enabled) + 'db' => true, // Show database (PDO) queries and bindings + 'views' => true, // Views with their data + 'route' => true, // Current route information + 'auth' => false, // Display Laravel authentication status + 'gate' => true, // Display Laravel Gate checks + 'session' => true, // Display session data + 'symfony_request' => true, // Only one can be enabled.. + 'mail' => true, // Catch mail messages + 'laravel' => false, // Laravel version and environment + 'events' => false, // All events fired + 'default_request' => false, // Regular or special Symfony request logger + 'logs' => false, // Add the latest log messages + 'files' => false, // Show the included files + 'config' => false, // Display config settings + 'cache' => false, // Display cache events + 'models' => true, // Display models + 'livewire' => true, // Display Livewire (when available) + ], + + /* + |-------------------------------------------------------------------------- + | Extra options + |-------------------------------------------------------------------------- + | + | Configure some DataCollectors + | + */ + + 'options' => [ + 'auth' => [ + 'show_name' => true, // Also show the users name/email in the debugbar + ], + 'db' => [ + 'with_params' => true, // Render SQL with the parameters substituted + 'backtrace' => true, // Use a backtrace to find the origin of the query in your files. + 'backtrace_exclude_paths' => [], // Paths to exclude from backtrace. (in addition to defaults) + 'timeline' => false, // Add the queries to the timeline + 'explain' => [ // Show EXPLAIN output on queries + 'enabled' => false, + 'types' => ['SELECT'], // // workaround ['SELECT'] only. https://github.com/barryvdh/laravel-debugbar/issues/888 ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+ + ], + 'hints' => false, // Show hints for common mistakes + ], + 'mail' => [ + 'full_log' => false + ], + 'views' => [ + 'data' => false, //Note: Can slow down the application, because the data can be quite large.. + ], + 'route' => [ + 'label' => true // show complete route on bar + ], + 'logs' => [ + 'file' => null + ], + 'cache' => [ + 'values' => true // collect cache values + ], + ], + + /* + |-------------------------------------------------------------------------- + | Inject Debugbar in Response + |-------------------------------------------------------------------------- + | + | Usually, the debugbar is added just before , by listening to the + | Response after the App is done. If you disable this, you have to add them + | in your template yourself. See http://phpdebugbar.com/docs/rendering.html + | + */ + + 'inject' => true, + + /* + |-------------------------------------------------------------------------- + | DebugBar route prefix + |-------------------------------------------------------------------------- + | + | Sometimes you want to set route prefix to be used by DebugBar to load + | its resources from. Usually the need comes from misconfigured web server or + | from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97 + | + */ + 'route_prefix' => '_debugbar', + + /* + |-------------------------------------------------------------------------- + | DebugBar route domain + |-------------------------------------------------------------------------- + | + | By default DebugBar route served from the same domain that request served. + | To override default domain, specify it as a non-empty value. + */ + 'route_domain' => null, + + /* + |-------------------------------------------------------------------------- + | DebugBar theme + |-------------------------------------------------------------------------- + | + | Switches between light and dark theme. If set to auto it will respect system preferences + | Possible values: auto, light, dark + */ + 'theme' => 'auto', +]; From 8063614cf058df8827d6ff77c7091b9090122305 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Tue, 18 Aug 2020 16:43:45 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E5=BA=97=E9=93=BA=E6=96=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8A=A5=E8=A1=A8--=E4=BF=AE=E6=94=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=BA=90=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StoreUserReportController.php | 23 ++----- app/Admin/Repositories/StoreUserReport.php | 62 ++++++++++++------- app/Models/ImsCjdcOrder.php | 2 +- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/app/Admin/Controllers/StoreUserReportController.php b/app/Admin/Controllers/StoreUserReportController.php index af19c38..4897028 100644 --- a/app/Admin/Controllers/StoreUserReportController.php +++ b/app/Admin/Controllers/StoreUserReportController.php @@ -3,14 +3,10 @@ namespace App\Admin\Controllers; use App\Admin\Repositories\StoreUserReport; -use App\Models\ImsCjdcOrderMain; -use App\Models\storeUserReport as ModelsStoreUserReport; use Dcat\Admin\Form; use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Controllers\AdminController; -use App\Models\ImsCjdcOrder; -use Illuminate\Support\Facades\DB; class StoreUserReportController extends AdminController { @@ -21,20 +17,7 @@ class StoreUserReportController extends AdminController */ protected function grid() { - $startTime = '2020-06-01';$endTime = '2020-07-01'; - $orderModel = new ImsCjdcOrder(); - $newModel = $orderModel->with([ - 'store:id,market_id,name,mm_user_id', - 'user'=> function($query) use($startTime,$endTime){ - $query->selectRaw(DB::raw('count(distinct user_id) as new_user_total'))->whereRaw("join_time BETWEEN UNIX_TIMESTAMP('?') AND UNIX_TIMESTAMP('?')",[$startTime,$endTime]); - }]) - ->whereRaw("UNIX_TIMESTAMP(pay_time) BETWEEN UNIX_TIMESTAMP('?') AND UNIX_TIMESTAMP('?')",[$startTime,$endTime]) - ->select('store_id') - ->groupBy('store_id') - ->orderBy('market_id','desc') - ->orderbY('new_user_total','desc'); - // return Grid::make(new StoreUserReport(), function (Grid $grid) { - return Grid::make($newModel, function (Grid $grid) { + return Grid::make(new StoreUserReport(), function (Grid $grid) { $grid->disableCreateButton(); $grid->store_id; @@ -45,7 +28,9 @@ class StoreUserReportController extends AdminController $grid->filter(function (Grid\Filter $filter) { $filter->equal('store_id'); - + $filter->equal('market_id'); + // $filter->equal('column')->datetime($options)->toTimestamp(); + $filter->equal('pay_time')->month(); }); }); } diff --git a/app/Admin/Repositories/StoreUserReport.php b/app/Admin/Repositories/StoreUserReport.php index a5ca2fb..6e1fa8c 100644 --- a/app/Admin/Repositories/StoreUserReport.php +++ b/app/Admin/Repositories/StoreUserReport.php @@ -5,6 +5,7 @@ namespace App\Admin\Repositories; use App\Models\storeUserReport as Model; use Dcat\Admin\Grid\Model as GridModel; use Dcat\Admin\Repositories\EloquentRepository; +use App\Models\ImsCjdcOrder as orderModel; use Illuminate\Support\Facades\DB; class StoreUserReport extends EloquentRepository @@ -21,29 +22,44 @@ class StoreUserReport extends EloquentRepository */ public function get(GridModel $model) { - $where = ['2020-06-01','2020-07-01']; + + $startTime = '2020-06-01';$endTime = '2020-08-01'; + $this->setSort($model); + $this->setPaginate($model); - $list = DB::select(" SELECT - store.id - ,store.market_id - ,store.`name` - ,store.mm_user_id - ,count(distinct orders.user_id) new_user_total - FROM - ims_cjdc_order orders - INNER JOIN ims_cjdc_store store ON orders.store_id = store.id - INNER JOIN ims_cjdc_user users ON orders.user_id = users.id - WHERE - users.join_time BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?) - AND UNIX_TIMESTAMP(orders.pay_time) BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?) - GROUP BY store.id - ORDER BY store.id ASC ", - array_merge($where,$where) - ); - $total = count($list); - return $model->makePaginator( - $total, - $list - ); + $orderModel = new orderModel(); + + //根据订单查询 + // $query = $orderModel::join('ims_cjdc_store as store','order.store_id','store.id') + // ->join('ims_cjdc_user as user','order.user_id','user.id') + // ->select('store_id','store.market_id','store.name as store_name','mm_user_id',DB::raw("count(distinct order.user_id) as new_user_total")) + // ->whereRaw("UNIX_TIMESTAMP(pay_time) BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)",[$startTime,$endTime]) + // ->whereRaw("join_time BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)",[$startTime,$endTime]) + // ->groupBy('store_id') + // ->orderBy('market_id','desc') + // ->orderBY('new_user_total','desc'); + + // 根据流水查询 + $query = $orderModel::join('ims_cjdc_store as store','order.store_id','store.id') + ->join('ims_cjdc_user as user','order.user_id','user.id') + ->select('store_id','store.market_id','store.name as store_name','mm_user_id',DB::raw("count(distinct order.user_id) as new_user_total")) + ->whereRaw("join_time BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)",[$startTime,$endTime]) + ->groupBy('store_id') + ->orderBy('market_id','desc') + ->orderBY('new_user_total','desc'); + + $model->getQueries()->unique()->each(function ($value) use (&$query) { + if ($value['method'] == 'paginate') { + $value['arguments'][1] = $this->getGridColumns(); + } elseif ($value['method'] == 'get') { + $value['arguments'] = [$this->getGridColumns()]; + } + $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); + }); + + $query = $query->toArray(); + + $query = $model->makePaginator($query['total'],$query['data']); + return $query; } } diff --git a/app/Models/ImsCjdcOrder.php b/app/Models/ImsCjdcOrder.php index f0e1f95..bc1a2ec 100644 --- a/app/Models/ImsCjdcOrder.php +++ b/app/Models/ImsCjdcOrder.php @@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Model; class ImsCjdcOrder extends Model { use HasDateTimeFormatter; - protected $table = 'ims_cjdc_order'; + protected $table = 'ims_cjdc_order as order'; public $timestamps = false; public function user() From 26e6facd401e1e60ce4615d7d2161125e8f90bc2 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Tue, 18 Aug 2020 16:44:56 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E5=BF=BD=E7=95=A5=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- storage/debugbar/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 storage/debugbar/.gitignore diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/storage/debugbar/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore From 11f2801755cd0494ff0ea4f9288f707b88416d66 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Tue, 18 Aug 2020 19:06:08 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E5=BA=97=E9=93=BA=E6=9F=A5=E6=96=B0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=BB=9F=E8=AE=A1--=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StoreUserReportController.php | 38 +++++++++++-- app/Admin/Repositories/StoreUserReport.php | 35 ++++++++---- app/Models/ImsCjdcStore.php | 5 ++ app/Models/StoreAccount.php | 53 +++++++++++++++++++ resources/lang/zh-CN/store-user-report.php | 3 ++ 5 files changed, 120 insertions(+), 14 deletions(-) create mode 100644 app/Models/StoreAccount.php diff --git a/app/Admin/Controllers/StoreUserReportController.php b/app/Admin/Controllers/StoreUserReportController.php index 4897028..0b0da84 100644 --- a/app/Admin/Controllers/StoreUserReportController.php +++ b/app/Admin/Controllers/StoreUserReportController.php @@ -7,6 +7,7 @@ use Dcat\Admin\Form; use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Controllers\AdminController; +use App\Models\ImsCjdcMarket as marketModel; class StoreUserReportController extends AdminController { @@ -19,18 +20,45 @@ class StoreUserReportController extends AdminController { return Grid::make(new StoreUserReport(), function (Grid $grid) { $grid->disableCreateButton(); + $grid->disableDeleteButton(); + $grid->disableEditButton(); + $grid->disableQuickEditButton(); + $grid->disableViewButton(); + $marketList = []; + $list = marketModel::select('id','name')->get()->toArray(); + foreach($list as $value){ + $marketList[$value['id']] = $value['name']; + } $grid->store_id; - $grid->market_id; + $grid->market_id->filter( + Grid\Column\Filter\In::make($marketList) + )->display(function ($markrtId) { + $market = marketModel::find($markrtId); + if (!$market) { + return '数据错误'; + } + return $market->name; + }); $grid->store_name; - $grid->mm_user_id; + $grid->mm_user_id->display(function ($markrtId) { + return '未关联'; + }); $grid->new_user_total; $grid->filter(function (Grid\Filter $filter) { $filter->equal('store_id'); - $filter->equal('market_id'); - // $filter->equal('column')->datetime($options)->toTimestamp(); - $filter->equal('pay_time')->month(); + $filter->like('store.name'); + $filter->whereBetween('time', function ($q) { + $start = $this->input['start'] ?? null; + $end = $this->input['end'] ?? null; + if ($start !== null) { + $q->whereRaw('add_time >= UNIX_TIMESTAMP(?)',$start); + } + if ($end !== null) { + $q->whereRaw('add_time <= UNIX_TIMESTAMP(?)',$end); + } + })->datetime(); }); }); } diff --git a/app/Admin/Repositories/StoreUserReport.php b/app/Admin/Repositories/StoreUserReport.php index 6e1fa8c..9803d47 100644 --- a/app/Admin/Repositories/StoreUserReport.php +++ b/app/Admin/Repositories/StoreUserReport.php @@ -6,6 +6,8 @@ use App\Models\storeUserReport as Model; use Dcat\Admin\Grid\Model as GridModel; use Dcat\Admin\Repositories\EloquentRepository; use App\Models\ImsCjdcOrder as orderModel; +use App\Models\StoreAccount as storeAccountModel; +use App\Models\ImsCjdcStore as storeModel; use Illuminate\Support\Facades\DB; class StoreUserReport extends EloquentRepository @@ -26,10 +28,9 @@ class StoreUserReport extends EloquentRepository $startTime = '2020-06-01';$endTime = '2020-08-01'; $this->setSort($model); $this->setPaginate($model); - - $orderModel = new orderModel(); - //根据订单查询 + //根据订单查询 方法查询出来的数据不对 + // $orderModel = new orderModel(); // $query = $orderModel::join('ims_cjdc_store as store','order.store_id','store.id') // ->join('ims_cjdc_user as user','order.user_id','user.id') // ->select('store_id','store.market_id','store.name as store_name','mm_user_id',DB::raw("count(distinct order.user_id) as new_user_total")) @@ -39,15 +40,31 @@ class StoreUserReport extends EloquentRepository // ->orderBy('market_id','desc') // ->orderBY('new_user_total','desc'); - // 根据流水查询 - $query = $orderModel::join('ims_cjdc_store as store','order.store_id','store.id') - ->join('ims_cjdc_user as user','order.user_id','user.id') - ->select('store_id','store.market_id','store.name as store_name','mm_user_id',DB::raw("count(distinct order.user_id) as new_user_total")) - ->whereRaw("join_time BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)",[$startTime,$endTime]) + /* 根据流水查询 2020-08-18 目前用全匹配文字方式查询新用户,后期维护店铺流水表的类型(category)后再换,或者使用其他方法 */ + $storeAccountModel = new storeAccountModel(); + $query = $storeAccountModel::join('ims_cjdc_store as store','ims_cjdc_store_account.store_id','store.id') + // with(['store' => function($query){ + // $query->select('id','market_id','name as store_name','mm_user_id'); + // }]) + ->select('store_id','store.market_id','store.name as store_name','mm_user_id',DB::raw("count(distinct ims_cjdc_store_account.id) as new_user_total")) + ->whereRaw("note = '新用户下单成功,平台奖励'") + // ->whereRaw("UNIX_TIMESTAMP(account.time) BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)",[$startTime,$endTime]) ->groupBy('store_id') - ->orderBy('market_id','desc') + ->orderBy('store.market_id','desc') ->orderBY('new_user_total','desc'); + // $storeModel = new storeModel(); + // $query = $storeModel + // ->with(['storeAccount'=>function($query){ + // $query->where('note',"新用户下单成功,平台奖励") + // ->select(DB::raw("count(distinct id) as new_user_total")); + // }]) + // ->select('id as store_id','market_id','name as store_name','mm_user_id') + // ->groupBy('id') + // ->orderBy('market_id','desc') + // ->orderBY('new_user_total','desc') + // ; + $model->getQueries()->unique()->each(function ($value) use (&$query) { if ($value['method'] == 'paginate') { $value['arguments'][1] = $this->getGridColumns(); diff --git a/app/Models/ImsCjdcStore.php b/app/Models/ImsCjdcStore.php index 4bb057e..2fa7a25 100644 --- a/app/Models/ImsCjdcStore.php +++ b/app/Models/ImsCjdcStore.php @@ -5,6 +5,7 @@ namespace App\Models; use Dcat\Admin\Traits\HasDateTimeFormatter; use Illuminate\Database\Eloquent\Model; +use App\Models\StoreAccount; class ImsCjdcStore extends Model { @@ -14,4 +15,8 @@ class ImsCjdcStore extends Model public function market(){ return $this->hasOne('\App\Models\ImsCjdcMarket','id','market_id'); } + + public function storeAccount(){ + return $this->hasMany(StoreAccount::class,'store_id','id'); + } } diff --git a/app/Models/StoreAccount.php b/app/Models/StoreAccount.php new file mode 100644 index 0000000..23de9ae --- /dev/null +++ b/app/Models/StoreAccount.php @@ -0,0 +1,53 @@ +where('order_main_id',$oid)->get()->toArray(); + + if (count($orderData)) { + foreach ($orderData as $item) { + if (is_object($item)){ + $accountData['user_id'] = $item->user_id; + $accountData['order_id'] = $item->id; + $accountData['store_id'] = $item->store_id; + $accountData['money'] = $item->money; + $accountData['type'] = $type; + $accountData['note'] = $note; + $accountData['add_time'] = time(); + $accountData['time'] = date('Y-m-d H:i:s', time()); + $data[] = $accountData; + } + } + return DB::table('ims_cjdc_store_account')->insert($data); + } else { + return false; + } + } + + public function store(){ + return $this->hasMany(storeModel::class,'id','store_id'); + } +} diff --git a/resources/lang/zh-CN/store-user-report.php b/resources/lang/zh-CN/store-user-report.php index bdebb38..79a3fde 100644 --- a/resources/lang/zh-CN/store-user-report.php +++ b/resources/lang/zh-CN/store-user-report.php @@ -7,9 +7,12 @@ return [ 'fields' => [ 'store_id' => '店铺ID', 'market_id' => '所属市场', + 'name' => '商家名称', 'store_name' => '商家名称', 'new_user_total' => '新增用户总数', 'mm_user_id' => '所属市场经理', + 'time' => '时间', + 'created_at' => '时间' ], 'options' => [ ], From a9ba1e1ea6efd2bec7d41e7fdfcfb1958bb0cee7 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Wed, 19 Aug 2020 09:47:05 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E5=BA=97=E9=93=BA=E6=96=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8A=A5=E8=A1=A8--=E4=BF=AE=E6=94=B9=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StoreUserReportController.php | 24 +++++++++---------- resources/lang/zh-CN/store-user-report.php | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/Admin/Controllers/StoreUserReportController.php b/app/Admin/Controllers/StoreUserReportController.php index 0b0da84..f31d267 100644 --- a/app/Admin/Controllers/StoreUserReportController.php +++ b/app/Admin/Controllers/StoreUserReportController.php @@ -24,16 +24,9 @@ class StoreUserReportController extends AdminController $grid->disableEditButton(); $grid->disableQuickEditButton(); $grid->disableViewButton(); - $marketList = []; - $list = marketModel::select('id','name')->get()->toArray(); - foreach($list as $value){ - $marketList[$value['id']] = $value['name']; - } $grid->store_id; - $grid->market_id->filter( - Grid\Column\Filter\In::make($marketList) - )->display(function ($markrtId) { + $grid->market_id->display(function ($markrtId) { $market = marketModel::find($markrtId); if (!$market) { return '数据错误'; @@ -41,14 +34,19 @@ class StoreUserReportController extends AdminController return $market->name; }); $grid->store_name; - $grid->mm_user_id->display(function ($markrtId) { - return '未关联'; - }); + // $grid->mm_user_id->display(function ($markrtId) { + // return '未关联'; + // }); $grid->new_user_total; $grid->filter(function (Grid\Filter $filter) { - $filter->equal('store_id'); - $filter->like('store.name'); + $marketList = []; + $list = marketModel::select('id','name')->get()->toArray(); + foreach($list as $value){ + $marketList[$value['id']] = $value['name']; + } + $filter->in('market_id')->multipleSelect($marketList); + $filter->like('store.name','店铺名称'); $filter->whereBetween('time', function ($q) { $start = $this->input['start'] ?? null; $end = $this->input['end'] ?? null; diff --git a/resources/lang/zh-CN/store-user-report.php b/resources/lang/zh-CN/store-user-report.php index 79a3fde..8bc8bc8 100644 --- a/resources/lang/zh-CN/store-user-report.php +++ b/resources/lang/zh-CN/store-user-report.php @@ -8,11 +8,11 @@ return [ 'store_id' => '店铺ID', 'market_id' => '所属市场', 'name' => '商家名称', + 'store.name' => '商家名称', 'store_name' => '商家名称', 'new_user_total' => '新增用户总数', 'mm_user_id' => '所属市场经理', 'time' => '时间', - 'created_at' => '时间' ], 'options' => [ ], From b895eb2ad16d878c89a0e26548bae147c9c1323b Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Wed, 19 Aug 2020 10:04:55 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E5=BA=97=E9=93=BA=E6=96=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8A=A5=E8=A1=A8--=E4=BF=AE=E6=94=B9=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E5=92=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StoreUserReportController.php | 4 +-- app/Admin/Repositories/StoreUserReport.php | 34 ++----------------- resources/lang/zh-CN/store-user-report.php | 2 -- 3 files changed, 5 insertions(+), 35 deletions(-) diff --git a/app/Admin/Controllers/StoreUserReportController.php b/app/Admin/Controllers/StoreUserReportController.php index f31d267..04c4b30 100644 --- a/app/Admin/Controllers/StoreUserReportController.php +++ b/app/Admin/Controllers/StoreUserReportController.php @@ -27,7 +27,7 @@ class StoreUserReportController extends AdminController $grid->store_id; $grid->market_id->display(function ($markrtId) { - $market = marketModel::find($markrtId); + $market = marketModel::select('id','name')->find($markrtId); if (!$market) { return '数据错误'; } @@ -35,7 +35,7 @@ class StoreUserReportController extends AdminController }); $grid->store_name; // $grid->mm_user_id->display(function ($markrtId) { - // return '未关联'; + // return '未关联市场经理'; // }); $grid->new_user_total; diff --git a/app/Admin/Repositories/StoreUserReport.php b/app/Admin/Repositories/StoreUserReport.php index 9803d47..dd5c1de 100644 --- a/app/Admin/Repositories/StoreUserReport.php +++ b/app/Admin/Repositories/StoreUserReport.php @@ -24,46 +24,18 @@ class StoreUserReport extends EloquentRepository */ public function get(GridModel $model) { - - $startTime = '2020-06-01';$endTime = '2020-08-01'; $this->setSort($model); $this->setPaginate($model); - //根据订单查询 方法查询出来的数据不对 - // $orderModel = new orderModel(); - // $query = $orderModel::join('ims_cjdc_store as store','order.store_id','store.id') - // ->join('ims_cjdc_user as user','order.user_id','user.id') - // ->select('store_id','store.market_id','store.name as store_name','mm_user_id',DB::raw("count(distinct order.user_id) as new_user_total")) - // ->whereRaw("UNIX_TIMESTAMP(pay_time) BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)",[$startTime,$endTime]) - // ->whereRaw("join_time BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)",[$startTime,$endTime]) - // ->groupBy('store_id') - // ->orderBy('market_id','desc') - // ->orderBY('new_user_total','desc'); - - /* 根据流水查询 2020-08-18 目前用全匹配文字方式查询新用户,后期维护店铺流水表的类型(category)后再换,或者使用其他方法 */ + /* 根据流水查询 2020-08-18 目前用全匹配文字方式查询新用户 */ $storeAccountModel = new storeAccountModel(); $query = $storeAccountModel::join('ims_cjdc_store as store','ims_cjdc_store_account.store_id','store.id') - // with(['store' => function($query){ - // $query->select('id','market_id','name as store_name','mm_user_id'); - // }]) ->select('store_id','store.market_id','store.name as store_name','mm_user_id',DB::raw("count(distinct ims_cjdc_store_account.id) as new_user_total")) ->whereRaw("note = '新用户下单成功,平台奖励'") - // ->whereRaw("UNIX_TIMESTAMP(account.time) BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)",[$startTime,$endTime]) ->groupBy('store_id') ->orderBy('store.market_id','desc') - ->orderBY('new_user_total','desc'); - - // $storeModel = new storeModel(); - // $query = $storeModel - // ->with(['storeAccount'=>function($query){ - // $query->where('note',"新用户下单成功,平台奖励") - // ->select(DB::raw("count(distinct id) as new_user_total")); - // }]) - // ->select('id as store_id','market_id','name as store_name','mm_user_id') - // ->groupBy('id') - // ->orderBy('market_id','desc') - // ->orderBY('new_user_total','desc') - // ; + ->orderBY('new_user_total','desc') + ->orderBY('store_id','desc'); $model->getQueries()->unique()->each(function ($value) use (&$query) { if ($value['method'] == 'paginate') { diff --git a/resources/lang/zh-CN/store-user-report.php b/resources/lang/zh-CN/store-user-report.php index 8bc8bc8..5bb0d36 100644 --- a/resources/lang/zh-CN/store-user-report.php +++ b/resources/lang/zh-CN/store-user-report.php @@ -7,8 +7,6 @@ return [ 'fields' => [ 'store_id' => '店铺ID', 'market_id' => '所属市场', - 'name' => '商家名称', - 'store.name' => '商家名称', 'store_name' => '商家名称', 'new_user_total' => '新增用户总数', 'mm_user_id' => '所属市场经理',