@ -44,15 +44,14 @@ class StoreUserReport extends EloquentRepository
-> select ( 'store_id' , 'store.name as store_name' , 'store.market_id' , DB :: raw ( " count(distinct " . StoreAccountModel :: $tableName . " .id) as new_user_total " ))
-> select ( 'store_id' , 'store.name as store_name' , 'store.market_id' , DB :: raw ( " count(distinct " . StoreAccountModel :: $tableName . " .id) as new_user_total " ))
-> whereRaw ( " note = '新用户下单成功,平台奖励' " )
-> whereRaw ( " note = '新用户下单成功,平台奖励' " )
-> groupBy ( 'store_id' );
-> groupBy ( 'store_id' );
// dd($storeAccount->get()->toArray());
/* 根据流水查询 2020-10-29 用类型字段查询新用户 新表 */
/* 根据流水查询 2020-10-29 用类型字段查询新用户 新表 */
$financial0 = Model :: select ( Model :: $tableName . '.id as store_id' , Model :: $tableName . '.name as store_name' , 'market_id' , DB :: raw ( 'count(distinct f0.id) as new_user_total' ))
$financial0 = Model :: select ( Model :: $tableName . '.id as store_id' , Model :: $tableName . '.name as store_name' , 'market_id' , DB :: raw ( 'count(distinct f0.id) as new_user_total' ))
-> join ( FinancialRecordModel0 :: $tableName . ' as f0' , Model :: $tableName . '.user_id' , '=' , 'f0.user_id' , 'left' )
-> join ( FinancialRecordModel0 :: $tableName . ' as f0' , Model :: $tableName . '.user_id' , '=' , 'f0.user_id' , 'left' )
-> whereRaw ( Model :: $tableName . '.user_id MOD 5 = 0' )
-> whereRaw ( Model :: $tableName . '.user_id MOD 5 = 0' )
-> whereRaw ( 'user_type =' . Type :: USER_TYPE_STORE )
-> whereRaw ( 'user_type =' . Type :: USER_TYPE_STORE )
// ->where('source_type',Type::SOURCE_TYPE_ORDER)
// ->where('money_type',Type::MONEY_TYPE_STORE_PLAT_NEW_USER)
-> whereRaw ( 'source_type = ' . Type :: SOURCE_TYPE_ORDER )
-> whereRaw ( 'money_type = ' . Type :: MONEY_TYPE_STORE_PLAT_NEW_USER )
-> whereRaw ( 'f0.created_at > 1600444800' )
-> whereRaw ( 'f0.created_at > 1600444800' )
-> groupBy ( 'store_id' , 'store_name' , 'market_id' );
-> groupBy ( 'store_id' , 'store_name' , 'market_id' );
@ -60,8 +59,8 @@ class StoreUserReport extends EloquentRepository
-> join ( FinancialRecordModel1 :: $tableName . ' as f1' , Model :: $tableName . '.user_id' , '=' , 'f1.user_id' , 'left' )
-> join ( FinancialRecordModel1 :: $tableName . ' as f1' , Model :: $tableName . '.user_id' , '=' , 'f1.user_id' , 'left' )
-> whereRaw ( Model :: $tableName . '.user_id MOD 5 = 1' )
-> whereRaw ( Model :: $tableName . '.user_id MOD 5 = 1' )
-> whereRaw ( 'user_type =' . Type :: USER_TYPE_STORE )
-> whereRaw ( 'user_type =' . Type :: USER_TYPE_STORE )
// ->where('source_type',Type::SOURCE_TYPE_ORDER)
// ->where('money_type',Type::MONEY_TYPE_STORE_PLAT_NEW_USER)
-> whereRaw ( 'source_type = ' . Type :: SOURCE_TYPE_ORDER )
-> whereRaw ( 'money_type = ' . Type :: MONEY_TYPE_STORE_PLAT_NEW_USER )
-> whereRaw ( 'f1.created_at > 1600444800' )
-> whereRaw ( 'f1.created_at > 1600444800' )
-> groupBy ( 'store_id' , 'store_name' , 'market_id' );
-> groupBy ( 'store_id' , 'store_name' , 'market_id' );
@ -69,8 +68,8 @@ class StoreUserReport extends EloquentRepository
-> join ( FinancialRecordModel2 :: $tableName . ' as f2' , Model :: $tableName . '.user_id' , '=' , 'f2.user_id' , 'left' )
-> join ( FinancialRecordModel2 :: $tableName . ' as f2' , Model :: $tableName . '.user_id' , '=' , 'f2.user_id' , 'left' )
-> whereRaw ( Model :: $tableName . '.user_id MOD 5 = 2' )
-> whereRaw ( Model :: $tableName . '.user_id MOD 5 = 2' )
-> whereRaw ( 'user_type =' . Type :: USER_TYPE_STORE )
-> whereRaw ( 'user_type =' . Type :: USER_TYPE_STORE )
// ->where('source_type',Type::SOURCE_TYPE_ORDER)
// ->where('money_type',Type::MONEY_TYPE_STORE_PLAT_NEW_USER)
-> whereRaw ( 'source_type = ' . Type :: SOURCE_TYPE_ORDER )
-> whereRaw ( 'money_type = ' . Type :: MONEY_TYPE_STORE_PLAT_NEW_USER )
-> whereRaw ( 'f2.created_at > 1600444800' )
-> whereRaw ( 'f2.created_at > 1600444800' )
-> groupBy ( 'store_id' , 'store_name' , 'market_id' );
-> groupBy ( 'store_id' , 'store_name' , 'market_id' );
@ -78,8 +77,8 @@ class StoreUserReport extends EloquentRepository
-> join ( FinancialRecordModel3 :: $tableName . ' as f3' , Model :: $tableName . '.user_id' , '=' , 'f3.user_id' , 'left' )
-> join ( FinancialRecordModel3 :: $tableName . ' as f3' , Model :: $tableName . '.user_id' , '=' , 'f3.user_id' , 'left' )
-> whereRaw ( Model :: $tableName . '.user_id MOD 5 = 3' )
-> whereRaw ( Model :: $tableName . '.user_id MOD 5 = 3' )
-> whereRaw ( 'user_type =' . Type :: USER_TYPE_STORE )
-> whereRaw ( 'user_type =' . Type :: USER_TYPE_STORE )
// ->where('source_type',Type::SOURCE_TYPE_ORDER)
// ->where('money_type',Type::MONEY_TYPE_STORE_PLAT_NEW_USER)
-> whereRaw ( 'source_type = ' . Type :: SOURCE_TYPE_ORDER )
-> whereRaw ( 'money_type = ' . Type :: MONEY_TYPE_STORE_PLAT_NEW_USER )
-> whereRaw ( 'f3.created_at > 1600444800' )
-> whereRaw ( 'f3.created_at > 1600444800' )
-> groupBy ( 'store_id' , 'store_name' , 'market_id' );
-> groupBy ( 'store_id' , 'store_name' , 'market_id' );
@ -87,8 +86,8 @@ class StoreUserReport extends EloquentRepository
-> join ( FinancialRecordModel4 :: $tableName . ' as f4' , Model :: $tableName . '.user_id' , '=' , 'f4.user_id' , 'left' )
-> join ( FinancialRecordModel4 :: $tableName . ' as f4' , Model :: $tableName . '.user_id' , '=' , 'f4.user_id' , 'left' )
-> whereRaw ( Model :: $tableName . '.user_id MOD 5 = 4' )
-> whereRaw ( Model :: $tableName . '.user_id MOD 5 = 4' )
-> whereRaw ( 'user_type =' . Type :: USER_TYPE_STORE )
-> whereRaw ( 'user_type =' . Type :: USER_TYPE_STORE )
// ->where('source_type',Type::SOURCE_TYPE_ORDER)
// ->where('money_type',Type::MONEY_TYPE_STORE_PLAT_NEW_USER)
-> whereRaw ( 'source_type = ' . Type :: SOURCE_TYPE_ORDER )
-> whereRaw ( 'money_type = ' . Type :: MONEY_TYPE_STORE_PLAT_NEW_USER )
-> whereRaw ( 'f4.created_at > 1600444800' )
-> whereRaw ( 'f4.created_at > 1600444800' )
-> groupBy ( 'store_id' , 'store_name' , 'market_id' );
-> groupBy ( 'store_id' , 'store_name' , 'market_id' );
@ -119,7 +118,7 @@ class StoreUserReport extends EloquentRepository
$financial4 -> whereRaw ( Model :: $tableName . '.market_id =' . $marketId );
$financial4 -> whereRaw ( Model :: $tableName . '.market_id =' . $marketId );
}
}
if ( $storeIds ){
if ( $storeIds ){
$storeStr = implode ( ',' , $storeIds ); //dd($storeArr);
$storeStr = implode ( ',' , $storeIds );
$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 . ')' );