商户 各接口
This commit is contained in:
parent
4f70d330f1
commit
91935ddb7c
@ -122,19 +122,28 @@ class Merchant extends BaseController
|
||||
$startDate = $this->request->param('start_date');
|
||||
$endDate = $this->request->param('end_date');
|
||||
$merId = $this->request->param('mer_id');
|
||||
$res = Cache::store('file')->remember(self::class . '@merchantProductRanking' . $merId. $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) {
|
||||
$list = StoreOrderProduct::getDB()->alias('A')->leftJoin('StoreOrder B', 'A.order_id = B.order_id')
|
||||
->field(\think\facade\Db::raw('sum(A.product_num) as total,A.product_id,cart_info'))
|
||||
->whereBetweenTime('B.pay_time', $startDate, $endDate)
|
||||
->where('B.mer_id', $merId)
|
||||
->where('B.paid', 1)->group('A.product_id')->limit(30)->order('total DESC')->select();
|
||||
$totalCount = 0;
|
||||
foreach ($list as $item) {
|
||||
$totalCount += $item['total'];
|
||||
}
|
||||
return compact('list', 'totalCount');
|
||||
}, 2000 + random_int(600, 1200));
|
||||
return app('json')->success($res);
|
||||
// $res = Cache::store('file')->remember(self::class . '@merchantProductRanking' . $merId. $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) {
|
||||
// $list = StoreOrderProduct::getDB()->alias('A')->leftJoin('StoreOrder B', 'A.order_id = B.order_id')
|
||||
// ->field(\think\facade\Db::raw('sum(A.product_num) as total,A.product_id,cart_info'))
|
||||
// ->whereBetweenTime('B.pay_time', $startDate, $endDate)
|
||||
// ->where('B.mer_id', $merId)
|
||||
// ->where('B.paid', 1)->group('A.product_id')->limit(30)->order('total DESC')->select();
|
||||
// $totalCount = 0;
|
||||
// foreach ($list as $item) {
|
||||
// $totalCount += $item['total'];
|
||||
// }
|
||||
// return compact('list', 'totalCount');
|
||||
// }, 2000 + random_int(600, 1200));
|
||||
$list = StoreOrderProduct::getDB()->alias('A')->leftJoin('StoreOrder B', 'A.order_id = B.order_id')
|
||||
->field(\think\facade\Db::raw('sum(A.product_num) as total,A.product_id,cart_info'))
|
||||
->whereBetweenTime('B.pay_time', $startDate, $endDate)
|
||||
->where('B.mer_id', $merId)
|
||||
->where('B.paid', 1)->group('A.product_id')->limit(30)->order('total DESC')->select();
|
||||
$totalCount = 0;
|
||||
foreach ($list as $item) {
|
||||
$totalCount += $item['total'];
|
||||
}
|
||||
return app('json')->success(compact('list', 'totalCount'));
|
||||
}
|
||||
|
||||
public function merchantProductVisit(UserVisitRepository $repository)
|
||||
@ -142,20 +151,30 @@ class Merchant extends BaseController
|
||||
$startDate = $this->request->param('start_date');
|
||||
$endDate = $this->request->param('end_date');
|
||||
$merId = $this->request->param('mer_id');
|
||||
$res = Cache::store('file')->remember(self::class . '@merchantProductVisit' . $merId . $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) {
|
||||
$list = UserVisit::getDB()->alias('A')->join('StoreProduct B', 'A.type_id = B.product_id')
|
||||
->join('Merchant C', 'C.mer_id = B.mer_id')
|
||||
->field(\think\facade\Db::raw('count(A.type_id) as total,B.image,B.store_name'))
|
||||
->whereBetweenTime('A.create_time', $startDate, $endDate)
|
||||
->where('A.type', 'product')->where('B.mer_id', $merId)->group('A.type_id')->order('total DESC')
|
||||
->limit(30)->select();
|
||||
$totalCount = 0;
|
||||
foreach ($list as $item) {
|
||||
$totalCount += $item['total'];
|
||||
}
|
||||
return compact('list', 'totalCount');
|
||||
}, 2000 + random_int(600, 1200));
|
||||
return app('json')->success($res);
|
||||
// $res = Cache::store('file')->remember(self::class . '@merchantProductVisit' . $merId . $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) {
|
||||
// $list = UserVisit::getDB()->alias('A')->join('StoreProduct B', 'A.type_id = B.product_id')
|
||||
// ->join('Merchant C', 'C.mer_id = B.mer_id')
|
||||
// ->field(\think\facade\Db::raw('count(A.type_id) as total,B.image,B.store_name'))
|
||||
// ->whereBetweenTime('A.create_time', $startDate, $endDate)
|
||||
// ->where('A.type', 'product')->where('B.mer_id', $merId)->group('A.type_id')->order('total DESC')
|
||||
// ->limit(30)->select();
|
||||
// $totalCount = 0;
|
||||
// foreach ($list as $item) {
|
||||
// $totalCount += $item['total'];
|
||||
// }
|
||||
// return compact('list', 'totalCount');
|
||||
// }, 2000 + random_int(600, 1200));
|
||||
$list = UserVisit::getDB()->alias('A')->join('StoreProduct B', 'A.type_id = B.product_id')
|
||||
->join('Merchant C', 'C.mer_id = B.mer_id')
|
||||
->field(\think\facade\Db::raw('count(A.type_id) as total,B.image,B.store_name'))
|
||||
->whereBetweenTime('A.create_time', $startDate, $endDate)
|
||||
->where('A.type', 'product')->where('B.mer_id', $merId)->group('A.type_id')->order('total DESC')
|
||||
->limit(30)->select();
|
||||
$totalCount = 0;
|
||||
foreach ($list as $item) {
|
||||
$totalCount += $item['total'];
|
||||
}
|
||||
return app('json')->success(compact('list', 'totalCount'));
|
||||
}
|
||||
|
||||
public function merchantProductCart(ProductRepository $repository)
|
||||
@ -163,21 +182,30 @@ class Merchant extends BaseController
|
||||
$startDate = $this->request->param('start_date');
|
||||
$endDate = $this->request->param('end_date');
|
||||
$merId = $this->request->param('mer_id');
|
||||
$res = Cache::store('file')->remember(self::class . '@merchantProductCart' . $merId . $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) {
|
||||
$list = \app\common\model\store\product\Product::getDB()->alias('A')->leftJoin('StoreCart B', 'A.product_id = B.product_id')
|
||||
->field(\think\facade\Db::raw('sum(B.cart_num) as total,A.product_id,A.store_name,A.image'))
|
||||
->whereBetweenTime('B.create_time', $startDate, $endDate)
|
||||
->where('A.mer_id', $merId)
|
||||
->where('B.product_type', 0)->where('B.is_pay', 0)->where('B.is_del', 0)
|
||||
->where('B.is_new', 0)->where('B.is_fail', 0)->group('A.product_id')->limit(30)->order('total DESC')->select();
|
||||
$totalCount = 0;
|
||||
foreach ($list as $item) {
|
||||
$totalCount += $item['total'];
|
||||
}
|
||||
return compact('list', 'totalCount');
|
||||
}, 2000 + random_int(600, 1200));
|
||||
|
||||
return app('json')->success($res);
|
||||
// $res = Cache::store('file')->remember(self::class . '@merchantProductCart' . $merId . $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) {
|
||||
// $list = \app\common\model\store\product\Product::getDB()->alias('A')->leftJoin('StoreCart B', 'A.product_id = B.product_id')
|
||||
// ->field(\think\facade\Db::raw('sum(B.cart_num) as total,A.product_id,A.store_name,A.image'))
|
||||
// ->whereBetweenTime('B.create_time', $startDate, $endDate)
|
||||
// ->where('A.mer_id', $merId)
|
||||
// ->where('B.product_type', 0)->where('B.is_pay', 0)->where('B.is_del', 0)
|
||||
// ->where('B.is_new', 0)->where('B.is_fail', 0)->group('A.product_id')->limit(30)->order('total DESC')->select();
|
||||
// $totalCount = 0;
|
||||
// foreach ($list as $item) {
|
||||
// $totalCount += $item['total'];
|
||||
// }
|
||||
// return compact('list', 'totalCount');
|
||||
// }, 2000 + random_int(600, 1200));
|
||||
$list = \app\common\model\store\product\Product::getDB()->alias('A')->leftJoin('StoreCart B', 'A.product_id = B.product_id')
|
||||
->field(\think\facade\Db::raw('sum(B.cart_num) as total,A.product_id,A.store_name,A.image'))
|
||||
->whereBetweenTime('B.create_time', $startDate, $endDate)
|
||||
->where('A.mer_id', $merId)
|
||||
->where('B.product_type', 0)->where('B.is_pay', 0)->where('B.is_del', 0)
|
||||
->where('B.is_new', 0)->where('B.is_fail', 0)->group('A.product_id')->limit(30)->order('total DESC')->select();
|
||||
$totalCount = 0;
|
||||
foreach ($list as $item) {
|
||||
$totalCount += $item['total'];
|
||||
}
|
||||
return app('json')->success(compact('list', 'totalCount'));
|
||||
}
|
||||
|
||||
public function merchant()
|
||||
|
Loading…
x
Reference in New Issue
Block a user