add 商户首页统计标题
This commit is contained in:
parent
9ba48e1ab8
commit
d126b7991f
@ -2,9 +2,13 @@
|
|||||||
|
|
||||||
namespace app\controller\api\dataview;
|
namespace app\controller\api\dataview;
|
||||||
|
|
||||||
|
use app\common\repositories\store\order\StoreOrderRepository;
|
||||||
|
use app\common\repositories\user\UserRelationRepository;
|
||||||
|
use app\common\repositories\user\UserVisitRepository;
|
||||||
use crmeb\basic\BaseController;
|
use crmeb\basic\BaseController;
|
||||||
use app\common\repositories\system\merchant\MerchantRepository as repository;
|
use app\common\repositories\system\merchant\MerchantRepository as repository;
|
||||||
use think\App;
|
use think\App;
|
||||||
|
use think\Db;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
|
|
||||||
class Merchant extends BaseController
|
class Merchant extends BaseController
|
||||||
@ -37,4 +41,45 @@ class Merchant extends BaseController
|
|||||||
$where = $this->request->params([ 'status', 'statusTag', 'is_trader', 'category_id', 'type_id', 'area_id', 'street_id']);
|
$where = $this->request->params([ 'status', 'statusTag', 'is_trader', 'category_id', 'type_id', 'area_id', 'street_id']);
|
||||||
return app('json')->success($this->repository->lst($where, $page, $limit));
|
return app('json')->success($this->repository->lst($where, $page, $limit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 商户统计
|
||||||
|
public function merchantCountMain()
|
||||||
|
{
|
||||||
|
$merId = $this->request->param('mer_id');
|
||||||
|
$today = $this->mainGroup('today', $merId);
|
||||||
|
$yesterday = $this->mainGroup('yesterday', $merId);
|
||||||
|
$lastWeek = $this->mainGroup(date('Y-m-d', strtotime('- 7day')), $merId);
|
||||||
|
$lastWeekRate = [];
|
||||||
|
foreach ($lastWeek as $k => $item) {
|
||||||
|
if ($item == $today[$k])
|
||||||
|
$lastWeekRate[$k] = 0;
|
||||||
|
else if ($item == 0)
|
||||||
|
$lastWeekRate[$k] = $today[$k];
|
||||||
|
else if ($today[$k] == 0)
|
||||||
|
$lastWeekRate[$k] = -$item;
|
||||||
|
else
|
||||||
|
$lastWeekRate[$k] = (float)bcdiv(bcsub($today[$k], $item, 4), $item, 4);
|
||||||
|
}
|
||||||
|
$day = date('Y-m-d');
|
||||||
|
return app('json')->success(compact('today', 'yesterday', 'lastWeekRate', 'day'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mainGroup($date, $merId)
|
||||||
|
{
|
||||||
|
$userVisitRepository = app()->make(UserVisitRepository::class);
|
||||||
|
$repository = app()->make(StoreOrderRepository::class);
|
||||||
|
$relationRepository = app()->make(UserRelationRepository::class);
|
||||||
|
|
||||||
|
$payPrice = (float)$repository->dayOrderPrice($date, $merId);
|
||||||
|
$payUser = (float)$repository->dayOrderUserNum($date, $merId);
|
||||||
|
$visitNum = (float)$userVisitRepository->dateVisitUserNum($date, $merId);
|
||||||
|
$likeStore = (float)$relationRepository->dayLikeStore($date, $merId);
|
||||||
|
$productNum = \think\facade\Db::name('store_product')->alias('p')->field('count(p.product_id) as think_count')
|
||||||
|
->join('merchant m', 'm.mer_id = p.mer_id')
|
||||||
|
->whereTime('p.create_time', '<=', $date)
|
||||||
|
->where('m.mer_id', $merId)
|
||||||
|
->count();
|
||||||
|
// Db::name('store_product')->where('mer_id', $merId)->count();
|
||||||
|
return compact('productNum','payPrice', 'payUser', 'visitNum', 'likeStore');
|
||||||
|
}
|
||||||
}
|
}
|
@ -756,6 +756,7 @@ Route::group('api/', function () {
|
|||||||
|
|
||||||
// api.dataview.Merchant
|
// api.dataview.Merchant
|
||||||
Route::get('merchant_list', 'Merchant/merchantList');
|
Route::get('merchant_list', 'Merchant/merchantList');
|
||||||
|
Route::get('merchant_count_main', 'Merchant/merchantCountMain');
|
||||||
|
|
||||||
// api.dataview.Finance
|
// api.dataview.Finance
|
||||||
Route::get('withdraw_list', 'Finance/withdrawList');
|
Route::get('withdraw_list', 'Finance/withdrawList');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user