|
|
@ -37,7 +37,8 @@ class StoreUserReport extends EloquentRepository |
|
|
$startTime = $params['start_time'] ?? request()->input('start_time',''); |
|
|
$startTime = $params['start_time'] ?? request()->input('start_time',''); |
|
|
$endTime = $params['end_time'] ?? request()->input('end_time',''); |
|
|
$endTime = $params['end_time'] ?? request()->input('end_time',''); |
|
|
$marketId = $params['market_id'] ?? request()->input('market_id',0); |
|
|
$marketId = $params['market_id'] ?? request()->input('market_id',0); |
|
|
$storeIds = $params['store_id'] ?? request()->input('store_id',[]); |
|
|
|
|
|
|
|
|
$storeId = $params['store_id'] ?? request()->input('store_id',[]); |
|
|
|
|
|
$storeIds = $params['store_ids'] ?? request()->input('store_ids',''); |
|
|
|
|
|
|
|
|
/* 根据流水查询 2020-08-18 用全匹配文字方式查询新用户 旧表 */ |
|
|
/* 根据流水查询 2020-08-18 用全匹配文字方式查询新用户 旧表 */ |
|
|
$storeAccount = StoreAccountModel::join(Model::$tableName.' as store',StoreAccountModel::$tableName.'.store_id','store.id') |
|
|
$storeAccount = StoreAccountModel::join(Model::$tableName.' as store',StoreAccountModel::$tableName.'.store_id','store.id') |
|
|
@ -117,8 +118,8 @@ class StoreUserReport extends EloquentRepository |
|
|
$financial3->whereRaw(Model::$tableName.'.market_id ='.$marketId); |
|
|
$financial3->whereRaw(Model::$tableName.'.market_id ='.$marketId); |
|
|
$financial4->whereRaw(Model::$tableName.'.market_id ='.$marketId); |
|
|
$financial4->whereRaw(Model::$tableName.'.market_id ='.$marketId); |
|
|
} |
|
|
} |
|
|
if($storeIds){ |
|
|
|
|
|
$storeStr = implode(',',$storeIds); |
|
|
|
|
|
|
|
|
if($storeId){ |
|
|
|
|
|
$storeStr = implode(',',$storeId); |
|
|
$storeAccount->whereRaw('store.id in('. $storeStr.')'); |
|
|
$storeAccount->whereRaw('store.id in('. $storeStr.')'); |
|
|
$financial0->whereRaw(Model::$tableName.'.id in('. $storeStr.')'); |
|
|
$financial0->whereRaw(Model::$tableName.'.id in('. $storeStr.')'); |
|
|
$financial1->whereRaw(Model::$tableName.'.id in('. $storeStr.')'); |
|
|
$financial1->whereRaw(Model::$tableName.'.id in('. $storeStr.')'); |
|
|
@ -126,6 +127,20 @@ class StoreUserReport extends EloquentRepository |
|
|
$financial3->whereRaw(Model::$tableName.'.id in('. $storeStr.')'); |
|
|
$financial3->whereRaw(Model::$tableName.'.id in('. $storeStr.')'); |
|
|
$financial4->whereRaw(Model::$tableName.'.id in('. $storeStr.')'); |
|
|
$financial4->whereRaw(Model::$tableName.'.id in('. $storeStr.')'); |
|
|
} |
|
|
} |
|
|
|
|
|
if($storeIds){ |
|
|
|
|
|
$storeIds = trim($storeIds,','); |
|
|
|
|
|
$expression = "/^[,1-9]+$/"; |
|
|
|
|
|
preg_match($expression,$storeIds,$matches); |
|
|
|
|
|
$storeIds = $matches[0] ?? 0; |
|
|
|
|
|
|
|
|
|
|
|
$storeAccount->whereRaw('store.id in('. $storeIds.')'); |
|
|
|
|
|
$financial0->whereRaw(Model::$tableName.'.id in('. $storeIds.')'); |
|
|
|
|
|
$financial1->whereRaw(Model::$tableName.'.id in('. $storeIds.')'); |
|
|
|
|
|
$financial2->whereRaw(Model::$tableName.'.id in('. $storeIds.')'); |
|
|
|
|
|
$financial3->whereRaw(Model::$tableName.'.id in('. $storeIds.')'); |
|
|
|
|
|
$financial4->whereRaw(Model::$tableName.'.id in('. $storeIds.')'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$unionAll = $storeAccount->union($financial0)->union($financial1)->union($financial2)->union($financial3)->union($financial4); |
|
|
$unionAll = $storeAccount->union($financial0)->union($financial1)->union($financial2)->union($financial3)->union($financial4); |
|
|
$query = DB::table(Db::raw("({$unionAll->toSql()}) as a1")) |
|
|
$query = DB::table(Db::raw("({$unionAll->toSql()}) as a1")) |
|
|
->select('a1.store_id','a1.store_name','a1.market_id',DB::raw('SUM(a1.new_user_total) as new_total')) |
|
|
->select('a1.store_id','a1.store_name','a1.market_id',DB::raw('SUM(a1.new_user_total) as new_total')) |
|
|
|