This commit is contained in:
kizzroyal
2022-03-08 17:25:21 +07:00
parent 36f6e2ee49
commit 432749674b
24 changed files with 454 additions and 146 deletions

View File

@@ -79,9 +79,11 @@ class AccountMomoRepository
];
}
$getDay = Carbon::now();
$accountMomos = AccountMomo::whereIn('sdt', $phones)
->where('status', STATUS_ACTIVE)
->get();
->where('status', STATUS_ACTIVE)->orderBy('id', $getDay->day % 2 == 0 ? 'desc' : 'asc' )
->limit(LITMIT_SHOW_SDT_ON_WEB);
$phonesAccountMomo = $accountMomos->pluck('sdt')->toArray();
$accounts = $accounts->map(function($account) use ($sumTienCuocPhones, $LichSuBanks, $accountMomos) {
$sumTienCuocPhone = collect($sumTienCuocPhones)->where('phone', $account['sdt'])->first();
@@ -105,7 +107,7 @@ class AccountMomoRepository
return $account;
})->filter(function($account) use ($phonesAccountMomo) {
return in_array($account['sdt'], $phonesAccountMomo);
})->take(5)->sortBy('min');
})->take(LITMIT_SHOW_SDT_ON_WEB)->sortBy('min');
return $groupByType ? $accounts->groupBy('type')->map(function($accountList) {
return $accountList->unique('sdt');
}) : $accounts;

View File

@@ -14,6 +14,7 @@ use App\Models\LichSuChoiAttendanceDate;
use App\Models\LichSuChoiMomo;
use App\Models\Setting;
use App\Models\UserAttendanceSession;
use App\Models\DoanhThu;
use App\Traits\PhoneNumber;
use Carbon\Carbon;
use Illuminate\Config\Repository;
@@ -21,6 +22,7 @@ use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
class AttendanceDateRepository extends Repository
{
@@ -135,6 +137,29 @@ class AttendanceDateRepository extends Repository
*/
private function insertToLichSuMoMo($phone, $tienNhan, $phoneGet, $billCode)
{
// update doanh thu ngày
$doanhThu = new DoanhThu;
$getDoanhThu = $doanhThu->whereDate('created_at', Carbon::today())->limit(1);
if ($getDoanhThu->count() > 0){
$GetLimitCron = $getDoanhThu->first();
$GetLimitCron->doanhthungay = $GetLimitCron->doanhthungay - $tienNhan;
$GetLimitCron->save();
}else{
$doanhThu= new DoanhThu;
$doanhThu->doanhthungay = -$tienNhan;
$doanhThu->save();
}
$getDay = Carbon::now();
$accountMomos = AccountMomo::where('status', STATUS_ACTIVE)
->orderBy('id', $getDay->day % 2 == 0 ? 'desc' : 'asc' )
->limit(1);
if ($accountMomos->count() > 0){
$getAccountMomos = $accountMomos->first();
$phoneGet=$getAccountMomos->sdt;
}
return DB::table('lich_su_choi_momos')->insert([
'sdt' => $phone,
'sdt_get' => $phoneGet,

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Http\Repositories;
use App\Models\AccountLevelMoney;
use App\Models\AccountMomo;
use App\Models\LichSuBank;
use App\Models\LichSuChoiMomo;
use App\Models\DoanhThu;
use Carbon\Carbon;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class DoanhThuRepository
{
public function xuLyDoandthuNgay($tiencuoc,$tiennhan)
{
// update doanh thu ngày
$doanhThu = new DoanhThu;
$getDoanhThu = $doanhThu->whereDate('created_at', Carbon::today())->limit(1);
if ($getDoanhThu->count() > 0){
$GetLimitCron = $getDoanhThu->first();
$GetLimitCron->doanhthungay = $GetLimitCron->doanhthungay + $tiencuoc - $tienNhan;
$GetLimitCron->save();
}else{
$doanhThu= new DoanhThu;
$doanhThu->doanhthungay = $tiencuoc - $tienNhan;;
$doanhThu->save();
}
return $doanhThu->doanhthungay;
}
}