Merge pull request 'dev' (#95) from dev into master

Reviewed-on: #95
This commit is contained in:
mkm 2023-12-12 18:36:22 +08:00
commit 372566e9d4
26 changed files with 1447 additions and 125 deletions

View File

@ -34,7 +34,7 @@ class SpuDao extends BaseDao
$order = 'S.price ASC';
} else if ($where['order'] == 'price_desc') {
$order = 'S.price DESC';
} else {
}else {
$order = 'P.'.$where['order'] . ' DESC';
}
}elseif($where['order'] == 'star'){

View File

@ -583,7 +583,7 @@ class StoreRefundOrderRepository extends BaseRepository
public function getAllList(array $where, int $page, int $limit)
{
$query = $this->dao->search($where)->with(['order' => function ($query) {
$query->field('order_id,order_sn,activity_type');
$query->field('order_id,order_sn,activity_type,user_address_code');
}, 'merchant' => function ($query) {
$query->field('mer_id,mer_name,is_trader');
}, 'refundProduct.product', 'user' => function ($query) {

View File

@ -502,7 +502,7 @@ class MerchantRepository extends BaseRepository
{
if ($money <= 0) return;
$payType = StoreOrder::getInstance()->where('order_id', $orderId)->value('pay_type');
if (systemConfig('mer_lock_time') || $payType == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
if (systemConfig('mer_lock_time') ||in_array($payType,[StoreGroupOrder::PAY_TYPE_BALANCE,StoreGroupOrder::PAY_TYPE_WECHAT,StoreGroupOrder::PAY_TYPE_CREDIT_BUY])) {
app()->make(UserBillRepository::class)->incBill($merId, 'mer_lock_money', $orderType, [
'link_id' => ($orderType === 'order' ? 1 : 2) . $orderId,
'mer_id' => $merId,

View File

@ -0,0 +1,130 @@
<?php
namespace app\controller\api\dataview;
use app\common\dao\user\UserBillDao;
use app\common\dao\user\UserExtractDao;
use app\common\repositories\BaseRepository;
use app\common\repositories\system\merchant\FinancialRecordRepository;
use app\common\repositories\user\UserBillRepository;
use crmeb\basic\BaseController;
use think\App;
use think\facade\Db;
use think\exception\ValidateException;
class Finance extends BaseController
{
/**
* @var repository
*/
protected $repository;
public $areaCode; // 区县地区码
public $streetCode; // 镇街道地区码
public $token;
public function __construct(App $app, BaseRepository $repository)
{
parent::__construct($app);
$this->repository = $repository;
$this->token = trim($this->request->header('X-Token'));
$this->areaCode = $this->request->param('areaCode', '');
$this->streetCode = $this->request->param('streetCode', '');
if ($this->areaCode == '' && $this->streetCode == '') {
throw new ValidateException('请选择地区');
}
}
// 提现记录
public function withdrawList(UserExtractDao $dao)
{
[$page,$limit] = $this->getPage();
$where = $this->request->params(['status','keyword','date','extract_type']);
$query = $dao->search($where)->with(['user' => function ($query) {
$query->field('uid,avatar,nickname');
}]);
$query->join('user_address', 'user_address.uid = UserExtract.uid')->where(function ($query){
if ($this->streetCode != '') {
$query->where('user_address.street_code', $this->streetCode);
} else {
$query->where('user_address.district_code', $this->areaCode);
}
});
$count = $query->count();
$list = $query->page($page, $limit)->select();
return app('json')->success(compact('count', 'list'));
}
// 资金记录
public function billList(UserBillRepository $repository)
{
$dao = app()->make(UserBillDao::class);
[$page, $limit] = $this->getPage();
$where = $this->request->params(['keyword', 'date', 'type']);
$query = $dao->searchJoin($where)->field('ua.street')->leftJoin('user_address ua', 'b.uid = ua.uid')->where(function ($query){
if ($this->streetCode != '') {
$query->where('ua.street_code', $this->streetCode);
} else {
$query->where('ua.district_code', $this->areaCode);
}
})->order('a.create_time DESC');
$count = $query->count();
$list = $query->page($page, $limit)->select();
return app('json')->success(compact('count', 'list'));
}
// 账单管理统计标题
public function financialRecordTitle(FinancialRecordRepository $repository)
{
$where = $this->request->params(['date']);
$where['is_mer'] = $this->request->get('mer_id') ?? 0 ;
if($where['is_mer'] == 0){
$data = $repository->getAdminTitle($where);
}else{
$where['mer_id'] = $this->request->get('mer_id') ?? 0 ;
$data = $repository->getMerchantTitle($where);
}
return app('json')->success($data);
}
public function financialRecord(FinancialRecordRepository $repository)
{
[$page, $limit] = $this->getPage();
$where = $this->request->params([['type',1],'date']);
$where['is_mer'] = $this->request->get('mer_id') ?? 0 ;
$merchant = [];
if($where['is_mer'] != 0){
$where['mer_id'] = $this->request->get('mer_id') ?? 0 ;
$merchant = Db::name('merchant')->find($where['mer_id']);
}
$data = $repository->getAdminList($where,$page, $limit,$merchant);
return app('json')->success($data);
}
public function financialDetail($type)
{
$repository = app()->make(FinancialRecordRepository::class);
$date = $this->request->param('date');
$where['date'] = empty($date) ? date('Y-m-d',time()) : $date ;
$where['is_mer'] = $this->request->param('mer_id') ?? 0 ;
if($this->request->merId()){
$merchant = $this->request->merchant();
$data = $repository->merDetail($type,$where,$merchant);
}else{
$data = $repository->adminDetail($type,$where);
}
return app('json')->success($data);
}
}

View File

@ -0,0 +1,68 @@
<?php
namespace app\controller\api\dataview;
use app\common\repositories\user\UserRepository;
use crmeb\basic\BaseController;
use think\App;
use think\facade\Cache;
use think\facade\Db;
use think\exception\ValidateException;
class Login extends BaseController
{
public function __construct(App $app)
{
parent::__construct($app);
}
public function login()
{
$account = $this->request->post('account', '');
$password = $this->request->post('password', '');
if (!$account){
return app('json')->fail('请输入账号');
}
$user = Db::name('dataview_account')->where('account', $account)->find();
if (!$user) {
throw new ValidateException("账号不存在");
}
if (!md5($password) === $user['password']) {
$msg = '账号或密码错误';
throw new ValidateException($msg);
}
$expire = time()+ 3600 * 24;
$token = md5($expire);
// 缓存token
Cache::set($token.'_dataview_'.$user['id'], $expire);
return app('json')->success(compact('user','token', 'expire'));
}
public function mechantLogin(UserRepository $repository)
{
$account = $this->request->param('account');
$password= $this->request->param('password');
if (!$account) return app('json')->fail('请输入账号');
$user = $repository->accountByUser($account);
if (!$user)return app('json')->fail('账号不存在');;
if (!password_verify($password, $user['pwd'])) {
$msg = '账号或密码错误';
throw new ValidateException($msg);
}
$user['merchant'] = Db::name('merchant')->where('uid', $user['uid'])->find();
$expire = time()+ 3600 * 24;
$token = md5($expire);
// 缓存token
Cache::set($token.'_merchant_'.$user['uid'], $expire);
return app('json')->success(compact('user','token', 'expire'));
}
}

View File

@ -11,6 +11,15 @@ use think\facade\Db;
class Logistics extends BaseController
{
/**
* @var repository
*/
protected $repository;
public $areaCode; // 区县地区码
public $streetCode; // 镇街道地区码
public function __construct(App $app, BaseRepository $repository)
{
parent::__construct($app);
@ -179,4 +188,43 @@ class Logistics extends BaseController
$latestTenOrder = Db::connect('logistics')->name('logistics')->field('receiver_address')->where(['status'=>1, 'courier_id' => $courierId])->order('id', 'desc')->limit(10)->select()->toArray();
return app('json')->success(compact('latestOrder', 'latestTenOrder'));
}
public function logisticsList()
{
$type = $this->request->param('type');
$courierId = $this->request->param('courier_id');
$startTime = $this->request->param('start_time');
$endTime = $this->request->param('end_time');
$list = [];
$count = 0;
if ($type == 1) {
// 待取货
$list = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){
$query->whereBetween('qh_time', [$startTime, $endTime]);
})->select();
$count = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){
$query->whereBetween('qh_time', [$startTime, $endTime]);
})->count();
}
if ($type == 2) {
// 配送中
$list = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){
$query->whereBetween('create_time', [$startTime, $endTime]);
})->select();
$count = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){
$query->whereBetween('create_time', [$startTime, $endTime]);
})->count();
}
if ($type == 3) {
// 已完成
$list = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){
$query->whereBetween('ps_time', [$startTime, $endTime]);
})->select();
$count = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){
$query->whereBetween('ps_time', [$startTime, $endTime]);
})->count();
}
return app('json')->success(compact('count', 'list'));
}
}

View File

@ -0,0 +1,162 @@
<?php
namespace app\controller\api\dataview;
use app\common\model\store\order\StoreOrderProduct;
use app\common\model\store\product\Product as model;
use app\common\model\user\UserVisit;
use app\common\repositories\store\order\StoreOrderProductRepository;
use app\common\repositories\store\order\StoreOrderRepository;
use app\common\repositories\store\product\ProductRepository;
use app\common\repositories\user\UserRelationRepository;
use app\common\repositories\user\UserVisitRepository;
use crmeb\basic\BaseController;
use app\common\repositories\system\merchant\MerchantRepository as repository;
use think\App;
use think\facade\Db;
use think\exception\ValidateException;
use think\facade\Cache;
class Merchant extends BaseController
{
/**
* @var repository
*/
protected $repository;
public $areaCode; // 区县地区码
public $streetCode; // 镇街道地区码
public function __construct(App $app, repository $repository)
{
parent::__construct($app);
$this->repository = $repository;
$this->areaCode = $this->request->param('areaCode', '');
$this->streetCode = $this->request->param('streetCode', '');
if ($this->areaCode == '' && $this->streetCode == '') {
throw new ValidateException('请选择地区');
}
}
// 商户列表
public function merchantList()
{
[$page, $limit] = $this->getPage();
$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));
}
// 商户统计
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');
}
public function merchantProductRanking(StoreOrderProductRepository $repository)
{
$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);
}
public function merchantProductVisit(UserVisitRepository $repository)
{
$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);
}
public function merchantProductCart(ProductRepository $repository)
{
$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);
}
public function merchant()
{
$merId = $this->request->param('mer_id');
$merchant = Db::name('merchant')->where('mer_id', $merId)->find();
return app('json')->success(compact('merchant'));
}
}

View File

@ -2,8 +2,14 @@
namespace app\controller\api\dataview;
use app\common\dao\store\order\StoreOrderDao;
use app\common\dao\store\order\StoreRefundOrderDao;
use app\common\model\store\order\StoreOrder;
use app\common\repositories\BaseRepository;
use app\common\repositories\store\order\StoreOrderRepository;
use app\common\repositories\store\order\StoreRefundOrderRepository;
use crmeb\basic\BaseController;
use Exception;
use think\App;
use think\exception\ValidateException;
use think\facade\Db;
@ -19,15 +25,12 @@ class Order extends BaseController
public $streetCode; // 镇街道地区码
/**
* StoreBrand constructor.
* @param App $app
* @param repository $repository
*/
public $token;
public function __construct(App $app, BaseRepository $repository)
{
parent::__construct($app);
$this->repository = $repository;
$this->token = trim($this->request->header('X-Token'));
$this->areaCode = $this->request->param('areaCode', '');
$this->streetCode = $this->request->param('streetCode', '');
@ -46,7 +49,7 @@ class Order extends BaseController
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->leftJoin('merchant m', 'o.mer_id = m.mer_id')
->leftJoin('store_order_product op', 'o.order_id = op.order_id')
->leftJoin('product_library p', 'op.product_id = p.id')
->leftJoin('store_product p', 'op.product_id = p.product_id')
->whereDay('og.create_time', $day)
->where('o.paid', 1)
->whereNotNull('o.pay_time');
@ -221,62 +224,62 @@ class Order extends BaseController
$list = [];
// 00:00-02:00
$startTime0 = strtotime(date('Y-m-d', time()));
$endTime2 = strtotime(date('Y-m-d 02:00:00'));
$endTime2 = strtotime(date('Y-m-d 01:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime0, $endTime2]);
// 02:00-04:00
$startTime2 = strtotime(date('Y-m-d 02:00:00'));
$endTime4 = strtotime(date('Y-m-d 04:00:00'));
$endTime4 = strtotime(date('Y-m-d 03:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime2, $endTime4]);
// 04:00-06:00
$startTime4 = strtotime(date('Y-m-d 04:00:00'));
$endTime6 = strtotime(date('Y-m-d 06:00:00'));
$endTime6 = strtotime(date('Y-m-d 05:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime4, $endTime6]);
// 06:00-08:00
$startTime6 = strtotime(date('Y-m-d 06:00:00'));
$endTime8 = strtotime(date('Y-m-d 08:00:00'));
$endTime8 = strtotime(date('Y-m-d 07:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime6, $endTime8]);
// 08:00-10:00
$startTime8 = strtotime(date('Y-m-d 08:00:00'));
$endTime10 = strtotime(date('Y-m-d 10:00:00'));
$endTime10 = strtotime(date('Y-m-d 09:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime8, $endTime10]);
// 10:00-12:00
$startTime10 = strtotime(date('Y-m-d 10:00:00'));
$endTime12 = strtotime(date('Y-m-d 12:00:00'));
$endTime12 = strtotime(date('Y-m-d 11:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime10, $endTime12]);
// 12:00-14:00
$startTime12 = strtotime(date('Y-m-d 12:00:00'));
$endTime14 = strtotime(date('Y-m-d 14:00:00'));
$endTime14 = strtotime(date('Y-m-d 13:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime12, $endTime14]);
// 14:00-16:00
$startTime14 = strtotime(date('Y-m-d 14:00:00'));
$endTime16 = strtotime(date('Y-m-d 16:00:00'));
$endTime16 = strtotime(date('Y-m-d 15:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime14, $endTime16]);
// 16:00-18:00
$startTime16 = strtotime(date('Y-m-d 16:00:00'));
$endTime18 = strtotime(date('Y-m-d 18:00:00'));
$endTime18 = strtotime(date('Y-m-d 17:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime16, $endTime18]);
// 18:00-20:00
$startTime18 = strtotime(date('Y-m-d 18:00:00'));
$endTime20 = strtotime(date('Y-m-d 20:00:00'));
$endTime20 = strtotime(date('Y-m-d 19:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime18, $endTime20]);
// 20:00-22:00
$startTime20 = strtotime(date('Y-m-d 20:00:00'));
$endTime22 = strtotime(date('Y-m-d 22:00:00'));
$endTime22 = strtotime(date('Y-m-d 21:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime20, $endTime22]);
// 22:00-24:00
$startTime22 = strtotime(date('Y-m-d 22:00:00'));
$endTime24 = strtotime(date('Y-m-d 24:00:00'));
$endTime24 = strtotime(date('Y-m-d 23:59:59'));
$list[] = $this->getTimeRangeOrderCount([$startTime22, $endTime24]);
return app('json')->success($list);
@ -288,7 +291,7 @@ class Order extends BaseController
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->leftJoin('merchant m', 'o.mer_id = m.mer_id')
->leftJoin('store_order_product op', 'o.order_id = op.order_id')
->leftJoin('product_library p', 'op.product_id = p.id')
->leftJoin('store_product p', 'op.product_id = p.product_id')
->whereTime('og.create_time', 'between', $timeRange) // whereTime('create_time', 'between', [$a[0],$a[1]]);
->where('o.paid', 1)
->whereNotNull('o.pay_time');
@ -339,4 +342,369 @@ class Order extends BaseController
$doneOrderCount = $doneOrderCountQuery->count();
return compact('hourOrderCount', 'pendingOrderCount', 'undeliveredOrderCount', 'doneOrderCount');
}
// 区县订单数据统计
public function orderStatistics()
{
$list = [];
// 该地区下所有乡镇
$geoStreetList = Db::name('geo_street')->field('street_name, street_code')->where('area_code',$this->areaCode)->select()->toArray();
foreach ($geoStreetList as $k=>$street) {
$dayOrderquery = Db::name('store_order')->alias('o')
->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status'])
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->where('o.paid', 1)
->whereNotNull('o.pay_time')
->whereDay('o.create_time', 'today')
->where('og.street_code', $street['street_code']);
$monthOrderquery = Db::name('store_order')->alias('o')
->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status'])
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->where('o.paid', 1)
->whereNotNull('o.pay_time')
->whereMonth('o.create_time', 'this month')
->where('og.street_code', $street['street_code']);
// 日订单数
$street['dayOrderCount'] = $dayOrderquery->count();
// 日订单金额
$street['dayOrderAmount'] = $dayOrderquery->sum('o.total_price');
// 月订单数
$street['monthOrderCount'] = $monthOrderquery->count();
// 月订单金额
$street['monthOrderAmount'] = $monthOrderquery->sum('o.total_price');
$list[$k] = $street;
}
unset($street);
return \app('json')->success(compact('list'));
}
// 镇/街道 当日订单金额
public function streetCurrDayOrderCount()
{
if ($this->streetCode == '') {
return app('json')->fail('请选择镇/街道');
}
$list = [];
// 00:00-04:00
$startTime = strtotime(date('Y-m-d 00:00:00'));
$endTime = strtotime(date('Y-m-d 03:59:59'));
$list[] = $this->getTimeRangeOrderAmount([$startTime, $endTime]);
// 04:00-08:00
$startTime = strtotime(date('Y-m-d 04:00:00'));
$endTime = strtotime(date('Y-m-d 07:59:59'));
$list[] = $this->getTimeRangeOrderAmount([$startTime, $endTime]);
// 08:00-12:00
$startTime = strtotime(date('Y-m-d 08:00:00'));
$endTime = strtotime(date('Y-m-d 11:59:59'));
$list[] = $this->getTimeRangeOrderAmount([$startTime, $endTime]);
// 12:00-16:00
$startTime = strtotime(date('Y-m-d 12:00:00'));
$endTime = strtotime(date('Y-m-d 15:59:59'));
$list[] = $this->getTimeRangeOrderAmount([$startTime, $endTime]);
// 16:00-20:00
$startTime = strtotime(date('Y-m-d 16:00:00'));
$endTime = strtotime(date('Y-m-d 19:59:59'));
$list[] = $this->getTimeRangeOrderAmount([$startTime, $endTime]);
// 20:00-24:00
$startTime = strtotime(date('Y-m-d 20:00:00'));
$endTime = strtotime(date('Y-m-d 23:59:59'));
$list[] = $this->getTimeRangeOrderAmount([$startTime, $endTime]);
return app('json')->success($list);
}
public function getTimeRangeOrderAmount($timeRange=[])
{
$todayAmount = Db::name('store_order')->alias('o')
->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status'])
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->where('o.paid', 1)
->whereNotNull('o.pay_time')
->whereTime('o.create_time', 'between', $timeRange)
->where('og.street_code', $this->streetCode)
->sum('o.total_price');
$yesterdayStartTime = strtotime('-1 days', $timeRange[0]);
$yesterdayEndTime = strtotime('-1 days', $timeRange[1]);
$yesterdayAmount = Db::name('store_order')->alias('o')
->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status'])
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->where('o.paid', 1)
->whereNotNull('o.pay_time')
->whereTime('o.create_time', 'between', [$yesterdayStartTime, $yesterdayEndTime])
->where('og.street_code', $this->streetCode)
->sum('o.total_price');
return compact('todayAmount', 'yesterdayAmount');
}
// 平台商品/店铺销量排行
public function salesRanking()
{
$list = [];
// 商品销量排行榜
$productRankingList = Db::name('store_product')->alias('p')
->field('p.product_id, p.store_name, p.image, COUNT(o.`order_id`) AS total_sales')
->join('store_order_product op', 'p.product_id = op.product_id')
->join('store_order o', 'op.order_id = o.order_id')
->group('p.product_id')
->order('total_sales DESC')
->limit(10)
->select()->toArray();
$productRankingTotal = 0;
foreach ($productRankingList as $k => $v) {
$productRankingTotal += $v['total_sales'];
}
// 店铺销量排行榜
$merchantRankingList = Db::name('store_order')->alias('o')
->field('m.`mer_id`, m.`mer_name`, m.mini_banner, COUNT(o.`order_id`) AS total_sales')
->join('merchant m', 'o.`mer_id` = m.`mer_id`')
->group('m.mer_id')
->order('total_sales DESC')
->limit(10)
->select()->toArray();
$merchantRankingTotal = 0;
foreach ($merchantRankingList as $k => $v) {
$merchantRankingTotal += $v['total_sales'];
}
// 统计每个镇的商品数.
$townProductCount = 0;
$townProductCountList = [];
$geoStreetList = Db::name('geo_street')->field('street_name, street_code')->where('area_code',$this->areaCode)->select()->toArray();
foreach ($geoStreetList as $k => $street) {
$street['product_count'] = Db::name('merchant')->alias('m')->field('p.`product_id`')
->join('store_product p', 'm.mer_id = p.mer_id')
->where('m.street_id', $street['street_code'])
->count();
$townProductCountList[] = $street;
$townProductCount += $street['product_count'];
}
return \app('json')->success(compact('productRankingTotal','productRankingList', 'merchantRankingTotal','merchantRankingList', 'townProductCount','townProductCountList'));
}
// 当日订单金额
public function currDayOrderAmount()
{
$geoStreetList = Db::name('geo_street')->field('street_name, street_code')->where('area_code',$this->areaCode)->select()->toArray();
foreach ($geoStreetList as &$street) {
$street['today_order_amount'] = Db::name('store_order')->alias('o')
->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status'])
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->where('o.paid', 1)
->whereNotNull('o.pay_time')
->whereDay('o.create_time', 'today')
->where('og.street_code', $street['street_code'])
->sum('o.total_price');
$street['yesterday_order_amount'] = Db::name('store_order')->alias('o')
->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status'])
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->where('o.paid', 1)
->whereNotNull('o.pay_time')
->whereDay('o.create_time', 'yesterday')
->where('og.street_code', $street['street_code'])
->sum('o.total_price');
}
unset($street);
return \app('json')->success(compact('geoStreetList'));
}
// 订单列表
public function orderList(StoreOrderRepository $repository, StoreOrderDao $dao)
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','is_trader','activity_type','group_order_sn','store_name']);
$status = $where['status'];
unset($where['status']);
$query = $dao->search($where, null)->where($repository->getOrderType($status))
->with([
'orderProduct',
'merchant' => function ($query) {
return $query->field('mer_id,mer_name,is_trader');
},
'groupOrder' => function ($query) {
$query->field('group_order_id,group_order_sn');
},
'user' => function ($query) {
$query->field('uid,nickname,avatar');
},
]);
$count = $query->count();
$list = $query->page($page, $limit)->select();
return app('json')->success(compact('count', 'list'));
}
// 订单列表统计标题
public function orderCountTitle(StoreOrderRepository $repository)
{
$where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','is_trader','activity_type']);
$data[0] = $repository->getStat($where, $where['status'])[0];
$data[1] = $repository->getStat($where, $where['status'])[1];
$data[2] = $repository->getStat($where, $where['status'])[2];
return app('json')->success($data);
}
// 退款订单列表
public function refundOrderList(StoreRefundOrderRepository $repository)
{
try{
[$page,$limit] = $this->getPage();
$where = $this->request->params(['refund_order_sn','status','refund_type','date','mer_id','order_sn','is_trader']);
$list = $repository->getAllList($where, $page, $limit);
$list['list'] = $list['list']->toArray();
foreach($list['list'] as &$item) {
if(!empty($item['order'])) {
$userAddressCode = explode(',', $item['order']['user_address_code']??'')??[];
if(!empty($userAddressCode)) {
$area = Db::name('geo_area')->where('area_code', $userAddressCode[2])->value('area_name');
$street = Db::name('geo_street')->where('street_code', $userAddressCode[3])->value('street_name');
$item['order']['order_from'] = $area.$street;
} else {
$item['order']['order_from'] = '';
}
}
}
unset($item);
return app('json')->success($list);
} catch(Exception $e) {
throw new ValidateException($e->getFile().$e->getLine().$e->getMessage());
}
}
// 核销订单
public function takeOrderList(StoreOrderRepository $repository, StoreOrderDao $dao)
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['date','order_sn','keywords','username','is_trader']);
$where['take_order'] = 1;
$where['status'] = '';
$where['verify_date'] = $where['date'];
unset($where['date']);
$status = $where['status'];
unset($where['status']);
$query = $dao->search($where, null)->where($repository->getOrderType($status))->with([
'orderProduct',
'merchant' => function ($query) {
return $query->field('mer_id,mer_name,is_trader');
},
'groupOrder' => function ($query) {
$query->field('group_order_id,group_order_sn');
},
'user' => function ($query) {
$query->field('uid,nickname,avatar');
},
]);
$count = $query->count();
$list = $query->page($page, $limit)->select();
foreach($list as &$item) {
if(!empty($item['order'])) {
$userAddressCode = explode(',', $item['user_address_code']??'')??[];
if(!empty($userAddressCode)){
$area = Db::name('geo_area')->where('area_code', $userAddressCode[2])->value('area_name');
$street = Db::name('geo_street')->where('street_code', $userAddressCode[3])->value('street_name');
$item['order_from'] = $area.$street;
} else{
$item['order_from'] = '';
}
}
}
return app('json')->success(compact('count', 'list'));
}
public function takeOrderCountTitle(StoreOrderRepository $repository)
{
$where = $this->request->params(['date','order_sn','keywords','username','is_trader']);
$where['take_order'] = 1;
$where['status'] = '';
$where['verify_date'] = $where['date'];
unset($where['date']);
$data[0] = $repository->getStat($where, '')[0];
$data[1] = $repository->getStat($where, '')[1];
$data[2] = $repository->getStat($where, '')[2];
return app('json')->success($data);
}
public function orderUserNumCount()
{
// 订单数
$orderNum = $this->dayOrderNum('today');
$yesterdayNum = $this->dayOrderNum('yesterday');
$monthOrderNum = $this->dayOrderNum(date('Y/m/d', strtotime('first day of')) . ' 00:00:00' . '-' . date('Y/m/d H:i:s'));
$date = date('Y/m/01 00:00:00', strtotime('last Month')) . '-' . date('Y/m/d 00:00:00', strtotime('-1 day', strtotime('first day of')));
$beforeOrderNum = $this->dayOrderNum($date);
$monthOrderNumRate = $this->getRate($beforeOrderNum, $monthOrderNum);
$orderNumRate = $this->getRate($yesterdayNum, $orderNum);
// 支付数
$orderPayNum = $this->dayOrderUserNum('today');
$yesterdayNum = $this->dayOrderUserNum('yesterday');
$monthOrderPayNum = $this->dayOrderUserNum(date('Y/m/d', strtotime('first day of')) . ' 00:00:00' . '-' . date('Y/m/d H:i:s'));
$date = gmdate('Y/m/01 00:00:00', strtotime('last Month')) . '-' . date('Y/m/d 00:00:00', strtotime('-1 day', strtotime('first day of')));
$beforeOrderNum = $this->dayOrderUserNum($date);
$monthOrderPayRate = $this->getRate($beforeOrderNum, $monthOrderNum);
$orderOrderPayRate = $this->getRate($yesterdayNum, $orderNum);
return app('json')->success(compact('orderNum', 'monthOrderNum', 'monthOrderNumRate', 'orderNumRate', 'orderPayNum', 'monthOrderPayNum', 'monthOrderPayRate', 'orderOrderPayRate'));
}
public function dayOrderNum($day)
{
return StoreOrder::getDB()->alias('o')
->join('product_order_log pog', 'o.order_id=pog.order_id')
->where('o.paid', 1)
->when($day, function ($query, $day) {
getModelTime($query, $day, 'o.pay_time');
})
->where('pog.street_code', $this->streetCode)
->count();
}
public function dayOrderUserNum($day, $merId = null)
{
return StoreOrder::getDB()->alias('o')
->join('product_order_log pog', 'o.order_id=pog.order_id')
->where('o.paid', 1)
->when($day, function ($query, $day) {
getModelTime($query, $day, 'o.pay_time');
})
->where('pog.street_code', $this->streetCode)->group('o.uid')->count();
}
protected function getRate($last, $today, $scale = 2)
{
if ($last == $today)
return 0;
else if ($last == 0)
return $today;
else if ($today == 0)
return -$last;
else
return (float)bcdiv(bcsub($today, $last, $scale), $last, $scale);
}
}

View File

@ -0,0 +1,304 @@
<?php
namespace app\controller\api\dataview;
use app\common\repositories\store\product\ProductRepository;
use app\common\repositories\store\StoreCategoryRepository as repository;
use app\common\repositories\user\UserVisitRepository;
use crmeb\basic\BaseController;
use think\App;
use think\exception\ValidateException;
use think\facade\Cache;
use think\facade\Db;
class Product extends BaseController
{
/**
* @var repository
*/
protected $repository;
public $areaCode; // 区县地区码
public $streetCode; // 镇街道地区码
public function __construct(App $app, repository $repository)
{
parent::__construct($app);
$this->repository = $repository;
$this->areaCode = $this->request->param('areaCode', '');
$this->streetCode = $this->request->param('streetCode', '');
if ($this->areaCode == '' && $this->streetCode == '') {
throw new ValidateException('请选择地区');
}
}
// 今昨 商品和店铺统计信息
public function productCount()
{
$totalProductCounInfo = $this->countTotalProduct();
$newProductCountInfo = $this->countNewProduct();
$merchantCountInfo = $this->countMerchant();
return \app('json')->success(compact('totalProductCounInfo', 'newProductCountInfo', 'merchantCountInfo'));
}
private function countTotalProduct() {
// 今日商品总数 截止到今日商品总数
$todayProductCount = 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', '<=', time())
->where(function ($query){
if ($this->streetCode != '') {
$query->where('m.street_id', $this->streetCode);
} else {
$query->where('m.area_id', $this->streetCode);
}
})
->count();
// 昨日商品总数
$yestertodayProductCount = 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', '<=', strtotime(date('Y-m-d', time()))-1)
->where(function ($query){
if ($this->streetCode != '') {
$query->where('m.street_id', $this->streetCode);
} else {
$query->where('m.area_id', $this->streetCode);
}
})
->count();
// 上周商品总数
$onWeekAgo = strtotime('-7 days');
// 查询截止到上周的商品总数
$lastWeekProductCount = 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', '<=', $onWeekAgo)
->where(function ($query){
if ($this->streetCode != '') {
$query->where('m.street_id', $this->streetCode);
} else {
$query->where('m.area_id', $this->streetCode);
}
})
->count();
// Db::name('store_product')->whereTime('create_time', '<=', $onWeekAgo)->count();
// 本周商品总数
$thisWeekProductCount = 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', '<=', time())
->where(function ($query){
if ($this->streetCode != '') {
$query->where('m.street_id', $this->streetCode);
} else {
$query->where('m.area_id', $this->streetCode);
}
})
->count();
// Db::name('store_product')->whereTime('create_time', '<=', time())->count();
// 计算商品总数周环比增长率
$weeklyProductTotalGrowthRate = $this->getRate($lastWeekProductCount, $thisWeekProductCount,4);
return compact('todayProductCount', 'yestertodayProductCount', 'weeklyProductTotalGrowthRate');
}
private function countNewProduct()
{
// 今日新商品数
$todayNewProductCount = Db::name('store_product')->alias('p')->field('count(p.product_id) as think_count')
->join('merchant m', 'm.mer_id = p.mer_id')
->whereDay('p.create_time', 'today')
->where(function ($query){
if ($this->streetCode != '') {
$query->where('m.street_id', $this->streetCode);
} else {
$query->where('m.area_id', $this->streetCode);
}
})
->count();
// Db::name('store_product')->whereDay('create_time', 'today')->count();
// 昨日新商品数
$yestertodayNewProductCount = Db::name('store_product')->alias('p')->field('count(p.product_id) as think_count')
->join('merchant m', 'm.mer_id = p.mer_id')
->whereDay('p.create_time', 'yesterday')
->where(function ($query){
if ($this->streetCode != '') {
$query->where('m.street_id', $this->streetCode);
} else {
$query->where('m.area_id', $this->streetCode);
}
})
->count();
// Db::name('store_product')->whereDay('create_time', 'yesterday')->count();
// 上周新商品数
$today = date('Y-m-d');
// 获取上一个自然周的开始,结束日期
$previous_week_start = strtotime(date('Y-m-d', strtotime('previous week', strtotime($today))));
$previous_week_end = strtotime('+7 days', strtotime(date('Y-m-d', strtotime('previous week', strtotime($today))))) - 1;
// 查询上一个自然周 周期内新增商品数
$preWeekNewProductCount = 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', 'between', [$previous_week_start, $previous_week_end])
->where(function ($query){
if ($this->streetCode != '') {
$query->where('m.street_id', $this->streetCode);
} else {
$query->where('m.area_id', $this->streetCode);
}
})
->count();
// Db::name('store_product')
// ->whereTime('create_time', 'between', [$previous_week_start, $previous_week_end])
// ->count();
// 本周新商品数
// 获取本自然周的起始日期
$current_week_start = strtotime(date('Y-m-d', strtotime('this week', strtotime($today))));
$current_week_end = time();
// 查询本自然周 周期内新增商品数
$currWeekNewProductCount = 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', 'between', [$current_week_start, $current_week_end])
->where(function ($query){
if ($this->streetCode != '') {
$query->where('m.street_id', $this->streetCode);
} else {
$query->where('m.area_id', $this->streetCode);
}
})
->count();
// Db::name('store_product')
// ->whereTime('create_time', 'between', [$current_week_start, $current_week_end])
// ->count();
// 计算新增商品数的周环比增长率
$weeklyNewProductTotalGrowthRate = $this->getRate($preWeekNewProductCount, $currWeekNewProductCount, 4);
return compact('todayNewProductCount', 'yestertodayNewProductCount', 'weeklyNewProductTotalGrowthRate');
}
private function countMerchant()
{
// 今日累计店铺总数
$todayMerchantCount = Db::name('merchant')
->where(function ($query){
if ($this->streetCode != '') {
$query->where('street_id', $this->streetCode);
} else {
$query->where('area_id', $this->streetCode);
}
})
->whereTime('create_time', '<=', time())
->count();
// 昨日累计店铺总数
$yestertodayMerchantCount = Db::name('merchant')
->where(function ($query){
if ($this->streetCode != '') {
$query->where('street_id', $this->streetCode);
} else {
$query->where('area_id', $this->streetCode);
}
})
->whereTime('create_time', '<=', strtotime(date('Y-m-d', time()))-1)
->count();
// 上周累计店铺总数
$onWeekAgo = strtotime('-7 days');
$lastWeekMerchantCount = Db::name('merchant')
->where(function ($query){
if ($this->streetCode != '') {
$query->where('street_id', $this->streetCode);
} else {
$query->where('area_id', $this->streetCode);
}
})
->whereTime('create_time', '<=', $onWeekAgo)
->count();
// 本周店铺累计总数
$thisWeekMerchantCount = Db::name('merchant')
->where('area_id', $this->areaCode)
->whereTime('create_time', '<=', time())
->count();
// 计算商品总数周环比增长率
$weeklyMerchantGrowthRate = $this->getRate($lastWeekMerchantCount, $thisWeekMerchantCount, 4);
return compact('todayMerchantCount', 'yestertodayMerchantCount', 'weeklyMerchantGrowthRate');
}
// 实时浏览量
public function viewCount()
{
$res = Cache::store('file')->remember(self::class . '@viewCount', function () {
$today = $this->mainGroup('today');
$yesterday = $this->mainGroup('yesterday');
$lastWeek = $this->mainGroup(date('Y-m-d', strtotime('- 7day')));
$lastWeekRate = $this->getRate($lastWeek, $today, 4);
return compact('today', 'yesterday', 'lastWeekRate');
}, 2000 + random_int(600, 1200));
return app('json')->success($res);
}
protected function mainGroup($date)
{
$userVisitRepository = app()->make(UserVisitRepository::class);
$visitNum = (float)$userVisitRepository->dateVisitNum($date);
return $visitNum;
}
/**
* @param $last
* @param $today
* @param int $scale
* @return int|string|null
* @author xaboy
* @day 2020/6/25
*/
protected function getRate($last, $today, $scale = 2)
{
if ($last == $today)
return 0;
else if ($last == 0)
return $today;
else if ($today == 0)
return -$last;
else
return (float)bcdiv(bcsub($today, $last, $scale), $last, $scale);
}
// 商品分类列表
public function productCategoryList()
{
return app('json')->success($this->repository->getFormatList($this->request->merId()));
}
// 商品列表统计标题
public function getStatusFilter(ProductRepository $repository)
{
return app('json')->success($repository->getFilter(null,'商品',0));
}
// 商品列表
public function productList(ProductRepository $repository)
{
[$page, $limit] = $this->getPage();
$where = $this->request->params([['type', 1]]);
$where['is_gift_bag'] = 0;
$_where = $repository->switchType($where['type'], null,0);
// unset($_where['product_type']);
unset($_where['star']);
$where = array_merge($where, $_where);
return app('json')->success($repository->getAdminList(null, $where, $page, $limit));
}
}

View File

@ -0,0 +1,229 @@
<?php
namespace app\controller\api\dataview;
use app\common\model\store\order\StoreOrder;
use app\common\model\user\UserVisit;
use app\common\repositories\BaseRepository;
use app\common\repositories\store\order\StoreOrderRepository;
use app\common\repositories\user\UserRepository;
use app\common\repositories\user\UserVisitRepository;
use crmeb\basic\BaseController;
use think\App;
use think\facade\Cache;
use think\facade\Db;
use think\exception\ValidateException;
class User extends BaseController
{
/**
* @var repository
*/
protected $repository;
public $areaCode; // 区县地区码
public $streetCode; // 镇街道地区码
public function __construct(App $app, BaseRepository $repository)
{
parent::__construct($app);
$this->repository = $repository;
$this->areaCode = $this->request->param('areaCode', '');
$this->streetCode = $this->request->param('streetCode', '');
if ($this->areaCode == '' && $this->streetCode == '') {
throw new ValidateException('请选择地区');
}
}
public function userMerchantCount()
{
// 近5日 平台用户量统计
$userCountlist = [];
$merchatCountList = [];
// 4天前
$startBeforeDay5 = strtotime(date('Y-m-d', strtotime('-4 days')));
$endBeforeDay5 = $startBeforeDay5+ 86399;
$userCountlist[] = $this->getTimeRangeUserCount([$startBeforeDay5, $endBeforeDay5]);
// 3天前
$startBeforeDay4 = strtotime(date('Y-m-d', strtotime('-3 days')));
$endBeforeDay4 = $startBeforeDay4 + 86399;
$userCountlist[] = $this->getTimeRangeUserCount([$startBeforeDay4, $endBeforeDay4]);
// 2天前
$startBeforeDay3 = strtotime(date('Y-m-d', strtotime('-2 days')));
$endBeforeDay3 = $startBeforeDay3 + 86399;
$userCountlist[] = $this->getTimeRangeUserCount([$startBeforeDay3, $endBeforeDay3]);
// 1天前
$startBeforeDay2= strtotime(date('Y-m-d', strtotime('-1 days')));
$endBeforeDay2 = $startBeforeDay2+ 86399;
$userCountlist[] = $this->getTimeRangeUserCount([$startBeforeDay2, $endBeforeDay2]);
// 今天
$startCurrDay1 = strtotime(date('Y-m-d', time()));
$endCurrDay1 = $startCurrDay1+ 86399;
$userCountlist[] = $this->getTimeRangeUserCount([$startCurrDay1, $endCurrDay1]);
// 地方店铺数量统计
// 遍历统计每个乡镇的店铺数
$merchantTotalCount = 0;
// 查镇的用户统计不需要查店铺数
if ($this->streetCode == '') {
// 该地区下所有乡镇
$geoStreetList = Db::name('geo_street')->where('area_code',$this->areaCode)->select()->toArray();
foreach ($geoStreetList as $street) {
$temp['street_name'] = $street['street_name'];
$temp['merchant_count'] = Db::name('merchant')->where('street_id', $street['street_code'])->count();
$merchantTotalCount += $temp['merchant_count'];
$merchatCountList[] = $temp;
unset($temp);
}
}
return app('json')->success(compact('merchantTotalCount' ,'userCountlist', 'merchatCountList'));
}
public function getTimeRangeUserCount($timeRange=[])
{
// 新增
$newUserCount = Db::name('user')->alias('u')
->join('user_address ua', 'u.uid = ua.uid')
->where(function ($query){
if ($this->streetCode != '') {
$query->where('ua.street', $this->streetCode);
} else {
$query->where('ua.district', $this->areaCode);
}
})
->whereTime('u.create_time', 'between', $timeRange)
->count();
// 访问
$viewUserCount = Db::name('user')->alias('u')
->join('user_address ua', 'u.uid = ua.uid')
->where(function ($query){
if ($this->streetCode != '') {
$query->where('ua.street', $this->streetCode);
} else {
$query->where('ua.district', $this->areaCode);
}
})
->whereTime('u.last_time', 'between', $timeRange)
->count();
// 累计
$totalUserCount = Db::name('user')->alias('u')
->join('user_address ua', 'u.uid = ua.uid')
->where(function ($query){
if ($this->streetCode != '') {
$query->where('ua.street', $this->streetCode);
} else {
$query->where('ua.district', $this->areaCode);
}
})
->whereTime('u.create_time', '<', $timeRange[1])
->count();
return compact('newUserCount', 'viewUserCount', 'totalUserCount');
}
public function userTradeCount(StoreOrderRepository $orderRepository, UserVisitRepository $userVisitRepository)
{
$monthDateRow = [];
// 获取当前月份的第一天
$firstDay = date('Y-m-01', time());
$i = 0;
$lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day"));
while (date('Y-m-d', strtotime("$firstDay +$i days")) <= $lastDay) {
$monthDateRow[] = date('Y-m-d', strtotime("$firstDay +$i days"));
$i++;
}
$this->merId = null;
$userTradeCountList = Cache::store('file')->remember(self::class . '@userTradeCount' . $this->streetCode, function () use ($orderRepository, $userVisitRepository, $monthDateRow) {
$list = [];
foreach ($monthDateRow as $date) {
$visitUser = $this->dateVisitUserNum($date);
$orderUser = $this->orderUserNum($date, null);
// $orderPrice = $this->orderPrice($date, null);
$payOrderUser = $this->orderUserNum($date, 1);
$payOrderPrice = $this->orderPrice($date, 1);
// $userRate = $payOrderUser ? bcdiv($payOrderPrice, $payOrderUser, 2) : 0;
// $orderRate = $visitUser ? bcdiv($orderUser, $visitUser, 2) : 0;
// $payOrderRate = $orderUser ? bcdiv($payOrderUser, $orderUser, 2) : 0;
$list[] = compact('date','visitUser', 'orderUser', 'payOrderUser');
}
return $list;
}, 2000 + random_int(600, 1200));
// 县
$area = Db::name('geo_area')->field('area_code, area_name')->where('area_code', $this->areaCode)->find();
// 镇/街道
$streetList = Db::name('geo_street')->field('street_code, street_name')->where('area_code', $this->areaCode)->select();
return app('json')->success(compact('userTradeCountList', 'area', 'streetList'));
}
protected function dateVisitUserNum($date)
{
return UserVisit::getDB()->alias('A')->join('StoreProduct B', 'A.type_id = B.product_id')->join('merchant m', 'B.mer_id=m.mer_id')->when($date, function ($query, $date) {
getModelTime($query, $date, 'A.create_time');
})->where( function ($query) {
if ($this->streetCode != '') {
$query->where('m.street_id', $this->streetCode);
} else {
$query->where('m.area_id', $this->areaCode);
}
})->where('A.type', 'product')->group(' A.uid')->count();
}
public function orderUserNum($date, $paid = null)
{
return StoreOrder::getDB()->alias('o')->join('merchant m', 'o.mer_id=m.mer_id')->when($paid, function ($query, $paid) {
$query->where('paid', $paid);
})->where( function ($query) {
if ($this->streetCode != '') {
$query->where('m.street_id', $this->streetCode);
} else {
$query->where('m.area_id', $this->areaCode);
}
})->when($date, function ($query, $date) use ($paid) {
if (!$paid) {
getModelTime($query, $date, 'o.create_time');
} else
getModelTime($query, $date, 'pay_time');
})->group('o.uid')->count();
}
public function orderPrice($date, $paid = null)
{
return StoreOrder::getDB()->alias('o')->join('merchant m', 'o.mer_id=m.mer_id')->when($paid, function ($query, $paid) {
$query->where('o.paid', $paid);
})->where( function ($query) {
if ($this->streetCode != '') {
$query->where('m.street_id', $this->streetCode);
} else {
$query->where('m.area_id', $this->areaCode);
}
})->when($date, function ($query, $date) use ($paid) {
if (!$paid) {
$query->where(function ($query) use ($date) {
$query->where(function ($query) use ($date) {
$query->where('o.paid', 1);
getModelTime($query, $date, 'pay_time');
})->whereOr(function ($query) use ($date) {
$query->where('o.paid', 0);
getModelTime($query, $date, 'o.create_time');
});
});
} else
getModelTime($query, $date, 'pay_time');
})->sum('o.pay_price');
}
}

View File

@ -75,7 +75,7 @@ class CloudWarehouse extends BaseController
*/
public function town()
{
$params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page']);
$params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page','cate_pid']);
$search = [
'street_id' => $params['street_code'],
'type_id' =>[Merchant::TypeStore,Merchant::TypeTownSupplyChain],
@ -101,6 +101,9 @@ class CloudWarehouse extends BaseController
if (!empty($params['category_id'])) {
$where['cate_id'] = $params['category_id'];
}
if($params['cate_pid']!=''){
$where['cate_pid'] = $params['cate_pid'];
}
$products = $this->spuRepository->getApiSearch($where, $page, $limit, false,true);
return app('json')->success($products);
}

View File

@ -71,7 +71,7 @@ class StoreSpu extends BaseController
unset($where['type_id'], $where['street_id']);
$where['is_gift_bag'] = 0;
$where['product_type'] = 0;
$where['product_type'] = $where['product_type']??0;
$where['order'] = $where['order'] ?: 'star';
if ($where['is_trader'] != 1) unset($where['is_trader']);
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);

View File

@ -87,7 +87,7 @@ class StoreImport extends BaseController
$file = $this->request->file('file');
if (!$file) return app('json')->fail('请上传EXCEL文件');
$file = is_array($file) ? $file[0] : $file;
validate(["file|文件" => ['fileExt' => 'xlsx,xls',]])->check(['file' => $file]);
validate(["file|文件" => ['fileExt' => 'xlsx',]],['请上传xlsx后缀的文件'])->check(['file' => $file]);
$upload = UploadService::create(1);
$ret = $upload->to('excel')->move('file');
if ($ret === false) return app('json')->fail($upload->getError());

View File

@ -21,47 +21,9 @@ class SendGoodsCode
$logisticsPhone = $this->sendLogistics($this->event['order_id'], $this->event['order_sn']);
//生成用户的收货码
$this->generateLogisticsCode($this->event['uid'], $this->event['order_id'], $this->event['order_sn'], $logisticsPhone);
//记录订单收货地址记录
$this->recordOrderAddr($this->event);
}
}
//订单收货记录
public function recordOrderAddr($order) {
//province_code . city_code . district_code . street_code . village_code . brigade_id;
//设置地址信息
$addressInfo = explode(',', $order['user_address_code'] ?? '');
$productOrder = [
'uid' => $order['uid'] ?? 0,
'order_id' => $order['order_id'] ?? 0,
'province_code' => $addressInfo[0] ?? '',
'city_code' => $addressInfo[1] ?? '',
'district_code' => $addressInfo[2] ?? '',
'street_code' => $addressInfo[3] ?? '',
'village_code' => $addressInfo[4] ?? '',
'brigade_id' => $addressInfo[5] ?? 0,
'status' => 1,
'create_time' => date('Y-m-d H:i:s')
];
//商品信息
$productInfo = Db::name('store_order_product')->where('order_id', $order['order_id'] ?? 0)->find();
if ($productInfo) {
$productOrder['product_id'] = $productInfo['product_id'] ?? 0;
$productOrder['product_price'] = $productInfo['product_price'] ?? 0;
$productOrder['total_price'] = $productInfo['total_price'] ?? 0;
$productOrder['product_num'] = $productInfo['product_num'] ?? 0;
}
//商户信息
$merchantInfo = Db::name('merchant')->where('mer_id', $order['mer_id'] ?? 0)->find();
if ($merchantInfo) {
$productOrder['mer_id'] = $merchantInfo['mer_id'] ?? 0;
$productOrder['mer_category_id'] = $merchantInfo['category_id'] ?? 0;
$productOrder['mer_type_id'] = $merchantInfo['type_id'] ?? 0;
$productOrder['is_trader'] = $merchantInfo['is_trader'] ?? 0;
}
Db::name('ProductOrderLog')->insert($productOrder);
}
//用户收货码
public function generateLogisticsCode($uid, $orderId, $orderSn, $logisticsPhone) {
$code = random_int(1000, 9999);

View File

@ -30,31 +30,66 @@ class paySuccess
public function handle($event)
{
try{
try {
$orderList = $event['groupOrder']['orderList'];
foreach ($orderList as $k => $order) {
$merchant = Merchant::find($order['mer_id']);
//添加到代发订单表里
if($merchant['type_id']==Merchant::TypeSupplyChain){
$codes=explode(',',$order['user_address_code']);
if(count($codes)>4){
$merchant_two= Db::name('merchant')->where('street_id',$codes[3])->where('type_id',17)->where('category_id',$merchant['category_id'])->find();
if($merchant_two){
$datas=[
'master_mer_id'=>$order['mer_id'],
'mer_id'=>$merchant_two['mer_id'],
'order_id'=>$order['order_id'],
'status'=>0
];
Db::name('store_order_behalf')->insert($datas);
}
if ($merchant['type_id'] == Merchant::TypeSupplyChain) {
$codes = explode(',', $order['user_address_code']);
if (count($codes) > 4) {
$merchant_two = Db::name('merchant')->where('street_id', $codes[3])->where('type_id', 17)->where('category_id', $merchant['category_id'])->find();
if ($merchant_two) {
$datas = [
'master_mer_id' => $order['mer_id'],
'mer_id' => $merchant_two['mer_id'],
'order_id' => $order['order_id'],
'status' => 0
];
Db::name('store_order_behalf')->insert($datas);
}
}
}
$this->recordOrderAddr($order);
}
}catch(\Exception $e){
Log::error('支付后逻辑报错:'.$e->getMessage().'lien:'.$e->getLine());
} catch (\Exception $e) {
Log::error('支付后逻辑报错:' . $e->getMessage() . 'lien:' . $e->getLine());
}
}
//商品订单日志
public function recordOrderAddr($order)
{
try {
$addressInfo = explode(',', $order['user_address_code'] ?? '');
$productOrder = [
'uid' => $order['uid'] ?? 0,
'order_id' => $order['order_id'] ?? 0,
'province_code' => $addressInfo[0] ?? '',
'city_code' => $addressInfo[1] ?? '',
'district_code' => $addressInfo[2] ?? '',
'street_code' => $addressInfo[3] ?? '',
'village_code' => $addressInfo[4] ?? '',
'brigade_id' => $addressInfo[5] ?? 0,
'product_id' => 0,
'product_price' => 0,
'total_price' => $order['pay_price'] ?? 0,
'product_num' => $order['total_num'] ?? 0,
'status' => 1,
'create_time' => date('Y-m-d H:i:s')
];
//商户信息
$merchantInfo = Db::name('merchant')->where('mer_id', $order['mer_id'] ?? 0)->find();
if ($merchantInfo) {
$productOrder['mer_id'] = $merchantInfo['mer_id'] ?? 0;
$productOrder['mer_category_id'] = $merchantInfo['category_id'] ?? 0;
$productOrder['mer_type_id'] = $merchantInfo['type_id'] ?? 0;
$productOrder['is_trader'] = $merchantInfo['is_trader'] ?? 0;
}
Db::name('ProductOrderLog')->insert($productOrder);
} catch (\Exception $e) {
Log::error('写入商品订单日志报错:' . $e->getMessage() . 'lien:' . $e->getLine());
}
}
}

View File

@ -35,8 +35,6 @@ class SendGoodsCodeJob implements JobInterface
$logisticsPhone = $this->sendLogistics($this->event['order_id'], $this->event['order_sn']);
//生成用户的收货码
$this->generateLogisticsCode($this->event['uid'], $this->event['order_id'], $this->event['order_sn'], $logisticsPhone);
//记录订单收货地址记录
$this->recordOrderAddr($this->event);
}
} catch (\Exception $e) {
Log::info('sendGoodsCodeJob 异常:' . $e->getMessage());
@ -44,41 +42,6 @@ class SendGoodsCodeJob implements JobInterface
$job->delete();
}
//订单收货记录
public function recordOrderAddr($order) {
//province_code . city_code . district_code . street_code . village_code . brigade_id;
//设置地址信息
$addressInfo = explode(',', $order['user_address_code'] ?? '');
$productOrder = [
'uid' => $order['uid'] ?? 0,
'order_id' => $order['order_id'] ?? 0,
'province_code' => $addressInfo[0] ?? '',
'city_code' => $addressInfo[1] ?? '',
'district_code' => $addressInfo[2] ?? '',
'street_code' => $addressInfo[3] ?? '',
'village_code' => $addressInfo[4] ?? '',
'brigade_id' => $addressInfo[5] ?? 0,
'product_id' => 0,
'product_price' => 0,
'total_price' => $order['pay_price'] ?? 0,
'product_num' => $order['total_num'] ?? 0,
'status' => 1,
'create_time' => date('Y-m-d H:i:s')
];
//商品信息
$productInfo = Db::name('store_order_product')->where('order_id', $order['order_id'] ?? 0)->find();
if ($productInfo) {
}
//商户信息
$merchantInfo = Db::name('merchant')->where('mer_id', $order['mer_id'] ?? 0)->find();
if ($merchantInfo) {
$productOrder['mer_id'] = $merchantInfo['mer_id'] ?? 0;
$productOrder['mer_category_id'] = $merchantInfo['category_id'] ?? 0;
$productOrder['mer_type_id'] = $merchantInfo['type_id'] ?? 0;
$productOrder['is_trader'] = $merchantInfo['is_trader'] ?? 0;
}
Db::name('ProductOrderLog')->insert($productOrder);
}
//用户收货码
public function generateLogisticsCode($uid, $orderId, $orderSn, $logisticsPhone) {

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
.title[data-v-3500ed7a]{margin-bottom:16px;color:#17233d;font-weight:500;font-size:14px}.description-term[data-v-3500ed7a]{display:table-cell;padding-bottom:10px;line-height:20px;width:50%;font-size:12px}[data-v-3cd1b9b0] .el-cascader{display:block}.dialog-scustom[data-v-3cd1b9b0]{width:1200px;height:600px}.ela-btn[data-v-3cd1b9b0]{color:#2d8cf0}.Box .ivu-radio-wrapper[data-v-3cd1b9b0]{margin-right:25px}.Box .numPut[data-v-3cd1b9b0]{width:80%!important}.lunBox[data-v-3cd1b9b0]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;border:1px solid #0bb20c}.pictrueBox[data-v-3cd1b9b0]{display:inline-block}.pictrue[data-v-3cd1b9b0]{width:50px;height:50px;border:1px dotted rgba(0,0,0,.1);display:inline-block;position:relative;cursor:pointer}.pictrue img[data-v-3cd1b9b0]{width:100%;height:100%}.pictrueTab[data-v-3cd1b9b0]{width:40px!important;height:40px!important}.upLoad[data-v-3cd1b9b0]{width:40px;height:40px;border:1px dotted rgba(0,0,0,.1);border-radius:4px;background:rgba(0,0,0,.02);cursor:pointer}.ft[data-v-3cd1b9b0]{color:red}.buttonGroup[data-v-3cd1b9b0]{position:relative;display:inline-block;vertical-align:middle;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-tap-highlight-color:rgba(0,0,0,0)}.buttonGroup .small-btn[data-v-3cd1b9b0]{position:relative;float:left;height:24px;padding:0 7px;font-size:14px;border-radius:3px}.buttonGroup .small-btn[data-v-3cd1b9b0]:first-child{margin-left:0;border-bottom-right-radius:0;border-top-right-radius:0}.virtual_boder[data-v-3cd1b9b0]{border:1px solid #1890ff}.virtual_boder2[data-v-3cd1b9b0]{border:1px solid #e7e7e7}.virtual_san[data-v-3cd1b9b0]{position:absolute;bottom:0;right:0;width:0;height:0;border-bottom:26px solid #1890ff;border-left:26px solid transparent}.virtual_dui[data-v-3cd1b9b0]{position:absolute;bottom:-2px;right:2px;color:#fff;font-family:system-ui}.virtual[data-v-3cd1b9b0]{width:120px;height:60px;background:#fff;border-radius:3px;float:left;text-align:center;padding-top:8px;position:relative;cursor:pointer;line-height:23px}.virtual .virtual_top[data-v-3cd1b9b0]{font-size:14px;font-weight:600;color:rgba(0,0,0,.85)}.virtual .virtual_bottom[data-v-3cd1b9b0]{font-size:12px;font-weight:400;color:#999}.virtual[data-v-3cd1b9b0]:nth-child(2n){margin:0 12px}[data-v-7d87bc0d] .el-cascader{display:block}.ela-btn[data-v-7d87bc0d]{color:#2d8cf0}.priceBox[data-v-7d87bc0d]{width:80px}.pictrue[data-v-7d87bc0d]{width:50px;height:50px;border:1px dotted rgba(0,0,0,.1);display:inline-block;position:relative;cursor:pointer}.pictrue img[data-v-7d87bc0d]{width:100%;height:100%}[data-v-7d87bc0d] .el-input-number__decrease,[data-v-7d87bc0d] .el-input-number__increase{display:none}[data-v-7d87bc0d] .el-input-number.is-controls-right .el-input__inner,[data-v-7d87bc0d] .el-input__inner{padding:0 5px}.pictrueTab[data-v-7d87bc0d]{width:40px!important;height:40px!important}.upLoad[data-v-7d87bc0d]{width:40px;height:40px;border:1px dotted rgba(0,0,0,.1);border-radius:4px;background:rgba(0,0,0,.02);cursor:pointer}.bg[data-v-95f6c30c]{z-index:100;position:fixed;left:0;top:0;width:100%;height:100%;background:rgba(0,0,0,.5)}.goods_detail .goods_detail_wrapper[data-v-95f6c30c]{z-index:-10}[data-v-95f6c30c] table.el-input__inner{padding:0}.demo-table-expand[data-v-95f6c30c]{font-size:0}.demo-table-expand1[data-v-95f6c30c] label{width:77px!important;color:#99a9bf}.demo-table-expand .el-form-item[data-v-95f6c30c]{margin-right:0;margin-bottom:0;width:33.33%}.selWidth[data-v-95f6c30c]{width:350px!important}.seachTiele[data-v-95f6c30c]{line-height:35px}
.title[data-v-3500ed7a]{margin-bottom:16px;color:#17233d;font-weight:500;font-size:14px}.description-term[data-v-3500ed7a]{display:table-cell;padding-bottom:10px;line-height:20px;width:50%;font-size:12px}[data-v-3cd1b9b0] .el-cascader{display:block}.dialog-scustom[data-v-3cd1b9b0]{width:1200px;height:600px}.ela-btn[data-v-3cd1b9b0]{color:#2d8cf0}.Box .ivu-radio-wrapper[data-v-3cd1b9b0]{margin-right:25px}.Box .numPut[data-v-3cd1b9b0]{width:80%!important}.lunBox[data-v-3cd1b9b0]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;border:1px solid #0bb20c}.pictrueBox[data-v-3cd1b9b0]{display:inline-block}.pictrue[data-v-3cd1b9b0]{width:50px;height:50px;border:1px dotted rgba(0,0,0,.1);display:inline-block;position:relative;cursor:pointer}.pictrue img[data-v-3cd1b9b0]{width:100%;height:100%}.pictrueTab[data-v-3cd1b9b0]{width:40px!important;height:40px!important}.upLoad[data-v-3cd1b9b0]{width:40px;height:40px;border:1px dotted rgba(0,0,0,.1);border-radius:4px;background:rgba(0,0,0,.02);cursor:pointer}.ft[data-v-3cd1b9b0]{color:red}.buttonGroup[data-v-3cd1b9b0]{position:relative;display:inline-block;vertical-align:middle;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-tap-highlight-color:rgba(0,0,0,0)}.buttonGroup .small-btn[data-v-3cd1b9b0]{position:relative;float:left;height:24px;padding:0 7px;font-size:14px;border-radius:3px}.buttonGroup .small-btn[data-v-3cd1b9b0]:first-child{margin-left:0;border-bottom-right-radius:0;border-top-right-radius:0}.virtual_boder[data-v-3cd1b9b0]{border:1px solid #1890ff}.virtual_boder2[data-v-3cd1b9b0]{border:1px solid #e7e7e7}.virtual_san[data-v-3cd1b9b0]{position:absolute;bottom:0;right:0;width:0;height:0;border-bottom:26px solid #1890ff;border-left:26px solid transparent}.virtual_dui[data-v-3cd1b9b0]{position:absolute;bottom:-2px;right:2px;color:#fff;font-family:system-ui}.virtual[data-v-3cd1b9b0]{width:120px;height:60px;background:#fff;border-radius:3px;float:left;text-align:center;padding-top:8px;position:relative;cursor:pointer;line-height:23px}.virtual .virtual_top[data-v-3cd1b9b0]{font-size:14px;font-weight:600;color:rgba(0,0,0,.85)}.virtual .virtual_bottom[data-v-3cd1b9b0]{font-size:12px;font-weight:400;color:#999}.virtual[data-v-3cd1b9b0]:nth-child(2n){margin:0 12px}[data-v-7d87bc0d] .el-cascader{display:block}.ela-btn[data-v-7d87bc0d]{color:#2d8cf0}.priceBox[data-v-7d87bc0d]{width:80px}.pictrue[data-v-7d87bc0d]{width:50px;height:50px;border:1px dotted rgba(0,0,0,.1);display:inline-block;position:relative;cursor:pointer}.pictrue img[data-v-7d87bc0d]{width:100%;height:100%}[data-v-7d87bc0d] .el-input-number__decrease,[data-v-7d87bc0d] .el-input-number__increase{display:none}[data-v-7d87bc0d] .el-input-number.is-controls-right .el-input__inner,[data-v-7d87bc0d] .el-input__inner{padding:0 5px}.pictrueTab[data-v-7d87bc0d]{width:40px!important;height:40px!important}.upLoad[data-v-7d87bc0d]{width:40px;height:40px;border:1px dotted rgba(0,0,0,.1);border-radius:4px;background:rgba(0,0,0,.02);cursor:pointer}.bg[data-v-489f9ada]{z-index:100;position:fixed;left:0;top:0;width:100%;height:100%;background:rgba(0,0,0,.5)}.goods_detail .goods_detail_wrapper[data-v-489f9ada]{z-index:-10}[data-v-489f9ada] table.el-input__inner{padding:0}.demo-table-expand[data-v-489f9ada]{font-size:0}.demo-table-expand1[data-v-489f9ada] label{width:77px!important;color:#99a9bf}.demo-table-expand .el-form-item[data-v-489f9ada]{margin-right:0;margin-bottom:0;width:33.33%}.selWidth[data-v-489f9ada]{width:350px!important}.seachTiele[data-v-489f9ada]{line-height:35px}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -27,6 +27,7 @@ Route::group(config('admin.admin_prefix'), function () {
Route::group(config('admin.api_admin_prefix') . '/', function () {
$path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR.'admin';
$files = scandir($path);
foreach ($files as $file) {
if($file != '.' && $file != '..'){

View File

@ -716,18 +716,67 @@ Route::group('api/', function () {
// dataview接口
Route::group('dataview', function () {
// Route::post('cancel/:id', '/cancelGroupOrder');
/**---------------------物流溯源监控大屏api-------------------- start **/
Route::get('curr_order_info', 'Order/currOrderInfo');
Route::get('order_ranking', 'Order/orderRanking');
Route::get('delivered_product_ranking', 'Order/deliveredProductRanking');
Route::get('town_map_count', 'Order/townMapCount');
Route::get('date_range_order_count', 'Order/dateRangeOrderCount');
Route::get('vehicle_list', 'Logistics/vehicleList');
Route::get('latest_logistics', 'Logistics/latestLogistics');
Route::get('logistics_count', 'Logistics/logisticsCount');
Route::get('logistics_map_count', 'Logistics/logisticsMapCount');
Route::get('logistics_list', 'Logistics/logisticsList');
/**---------------------物流溯源监控大屏api---------------------- end **/
/**---------------------数据之眼可视化大屏api------------------- start */
// api.dataview.Order
Route::get('order_statistics', 'Order/orderStatistics');
Route::get('sales_ranking', 'Order/salesRanking');
Route::get('curr_day_order_amount', 'Order/currDayOrderAmount');
Route::get('order_list', 'Order/orderList');
Route::get('order_list_count_title', 'Order/orderCountTitle');
Route::get('refund_order_list', 'Order/refundOrderList');
Route::get('take_order_list', 'Order/takeOrderList');
Route::get('take_order_count_title', 'Order/takeOrderCountTitle');
Route::get('street_currday_order_count', 'Order/streetCurrDayOrderCount');
Route::get('order_user_num_count', 'Order/orderUserNumCount');
// api.dataview.User
Route::get('user_merchat_count', 'User/userMerchantCount');
Route::get('user_trade_count', 'User/userTradeCount');
// api.dataview.Product
Route::get('product_count', 'Product/productCount');
Route::get('view_count', 'Product/viewCount');
Route::get('product_category_list', 'Product/productCategoryList');
Route::get('product_status_filter', 'Product/getStatusFilter');
Route::get('product_list', 'Product/productList');
// api.dataview.Merchant
Route::get('merchant_list', 'Merchant/merchantList');
Route::get('merchant_count_main', 'Merchant/merchantCountMain');
Route::get('merchant_product_ranking', 'Merchant/merchantProductRanking');
Route::get('merchant_product_visit', 'Merchant/merchantProductVisit');
Route::get('merchant_product_cart', 'Merchant/merchantProductCart');
Route::get('merchant', 'Merchant/merchant');
// api.dataview.Finance
Route::get('withdraw_list', 'Finance/withdrawList');
Route::get('bill_list', 'Finance/billList');
Route::get('financial_record_title', 'Finance/financialRecordTitle');
Route::get('financial_record', 'Finance/financialRecord');
Route::get('financial_record_detail/:type', 'Finance/financialDetail');
// login
Route::post('login', 'Login/login');
Route::post('mechant_login', 'Login/mechantLogin');
/**---------------------数据之眼可视化大屏api-------------------- end */
})->prefix('api.dataview.');