调整渠道数据统计
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Merchant\Controllers\Controller;
|
||||
use App\Merchant\Exporters\CensusExport;
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\UserCode;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -21,26 +22,23 @@ class IndexController extends Controller
|
||||
|
||||
$coupons = Coupon::where('user_id', $user->id)
|
||||
->whereYear('created_at', $month[0])
|
||||
->whereMonth('created_at', $month[1])
|
||||
// ->whereMonth('created_at', $month[1])
|
||||
->where('status', 2)
|
||||
->get(['id', 'thirdPartyGoodsId', 'created_at']);
|
||||
|
||||
$rules = ActivityRule::get();
|
||||
$rules = $user->code;
|
||||
|
||||
$coupons = $coupons->groupBy('create_day')->map(function ($items, $key) use ($rules) {
|
||||
$data = [
|
||||
'day' => $key,
|
||||
// 'ysd10' => $items->where('thirdPartyGoodsId', 'YSD-full100-10')->count(),
|
||||
// 'ysd25' => $items->where('thirdPartyGoodsId', 'YSD-full100-25')->count(),
|
||||
// 'ysd50' => $items->where('thirdPartyGoodsId', 'YSD-full100-50')->count(),
|
||||
// 'ysd100' => $items->where('thirdPartyGoodsId', 'YSD-full200-100')->count(),
|
||||
];
|
||||
foreach ($rules as $rule) {
|
||||
$data[$rule->code] = $items->where('thirdPartyGoodsId', $rule->code)->count();
|
||||
}
|
||||
$coupons = $coupons->groupBy('create_day')
|
||||
->map(function ($items, $key) use ($rules) {
|
||||
$data = [
|
||||
'day' => $key,
|
||||
];
|
||||
foreach ($rules as $rule) {
|
||||
$data[$rule->code] = $items->where('thirdPartyGoodsId', $rule->code)->count();
|
||||
}
|
||||
|
||||
return collect($data);
|
||||
});
|
||||
return collect($data);
|
||||
});
|
||||
|
||||
$all = [];
|
||||
foreach ($rules as $rule) {
|
||||
|
||||
Reference in New Issue
Block a user