|
|
@@ -15,7 +15,9 @@ namespace addon\store\shop\controller;
|
|
|
use app\model\store\Stat as StatModel;
|
|
|
use app\model\store\Store as StoreModel;
|
|
|
use app\shop\controller\BaseShop;
|
|
|
+use app\model\system\UserGroup;
|
|
|
use Carbon\Carbon;
|
|
|
+use think\validate\ValidateRule;
|
|
|
|
|
|
|
|
|
class Stat extends BaseShop
|
|
|
@@ -25,7 +27,16 @@ class Stat extends BaseShop
|
|
|
*/
|
|
|
public function store()
|
|
|
{
|
|
|
- $store_list = ( new StoreModel() )->getStoreList([ [ 'site_id', '=', $this->site_id ] ], 'store_id,store_name');
|
|
|
+ $user_info = $this->user_info;
|
|
|
+ $user_id = $user_info['uid'];
|
|
|
+ $uwhere['uid'] = $user_id;
|
|
|
+ $UgObj = new UserGroup();
|
|
|
+
|
|
|
+ $user_store_list =$UgObj->getUserList($uwhere,'uid,store_id');
|
|
|
+
|
|
|
+ $store_id_arr = array_column($user_store_list['data'],'store_id');
|
|
|
+
|
|
|
+ $store_list = ( new StoreModel() )->getStoreList([ [ 'site_id', '=', $this->site_id ],['store_id','in',$store_id_arr] ], 'store_id,store_name');
|
|
|
$this->assign('store_list', $store_list[ 'data' ]);
|
|
|
$this->assign('today', Carbon::today()->toDateString());
|
|
|
$this->assign('yesterday', Carbon::yesterday()->toDateString());
|
|
|
@@ -46,10 +57,17 @@ class Stat extends BaseShop
|
|
|
$start_time = input('end_time');
|
|
|
$end_time = input('start_time');
|
|
|
}
|
|
|
+ $user_info = $this->user_info;
|
|
|
+ $user_id = $user_info['uid'];
|
|
|
+ $uwhere['uid'] = $user_id;
|
|
|
+ $UgObj = new UserGroup();
|
|
|
+
|
|
|
+ $user_store_list =$UgObj->getUserList($uwhere,'uid,store_id');
|
|
|
|
|
|
+ $store_id_arr = array_column($user_store_list['data'],'store_id');
|
|
|
$stat_model = new StatModel();
|
|
|
|
|
|
- $data = $stat_model->getShopStatSum($this->site_id, $start_time, $end_time, $store_id);
|
|
|
+ $data = $stat_model->getShopStatSum($this->site_id, $start_time, $end_time, $store_id,$store_id_arr);
|
|
|
return $data;
|
|
|
}
|
|
|
}
|