Merged in izzati-feat-format-notis-lelong-baru-30jun (pull request #40)
Izzati feat format notis lelong baru 30jun
This commit is contained in:
@@ -20,6 +20,11 @@ use App\Models\FileMarhun;
|
||||
use App\Services\MarhunPhotoService;
|
||||
use App\Models\Pengesahan;
|
||||
use App\Models\LelongBidMarhun;
|
||||
use App\Models\LogUser;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Jobs\WhatsappPengesahanPembida;
|
||||
use App\Jobs\WhatsappTidakSahBayaran;
|
||||
use PDF;
|
||||
|
||||
class AccountController extends Controller
|
||||
@@ -277,6 +282,7 @@ class AccountController extends Controller
|
||||
|
||||
public function sahbayaronline(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
$currentdate = Carbon::now();
|
||||
$currentdate = $currentdate->toDateTimeString();
|
||||
|
||||
@@ -285,32 +291,65 @@ class AccountController extends Controller
|
||||
$total_payment = 0;
|
||||
|
||||
$senaraisag = $request->senarai_sag;
|
||||
$user_notelbimbit = $request->notel_pembida;
|
||||
$user_namapembida = $request->nama_pembida;
|
||||
|
||||
|
||||
if($request->jenis_button == 'tidaksah'){
|
||||
//insert loguser
|
||||
$loguser = new LogUser;
|
||||
$loguser->user_id = $user->id;
|
||||
$loguser->date = $currentdate;
|
||||
$loguser->username = $user->username;
|
||||
$loguser->nama_user = $user->name;
|
||||
// $loguser->norujukan = $data['norujukan'];
|
||||
$loguser->nota = $request->kodcaw.': '.$request->nama_pembida.' ('.$request->nokp_pembida.'): Bukti Bayaran Tidak Sah';
|
||||
$loguser->save();
|
||||
|
||||
WhatsappTidakSahBayaran::dispatch($user_namapembida);
|
||||
|
||||
return redirect()->route('home')->with('failed','Pembayaran Tidak Sah');
|
||||
|
||||
|
||||
}elseif($request->jenis_button == 'sah'){
|
||||
foreach(json_decode($senaraisag) as $sag)
|
||||
{
|
||||
$payment = Payment::where('id', $sag->payment_id)->first();
|
||||
$payment->disahkan_oleh = $user->id;
|
||||
$payment->disahkan_pada = $currentdate;
|
||||
$payment->save();
|
||||
|
||||
foreach(json_decode($senaraisag) as $sag)
|
||||
{
|
||||
$payment = Payment::where('id', $sag->payment_id)->first();
|
||||
$payment->disahkan_oleh = $user->id;
|
||||
$payment->disahkan_pada = $currentdate;
|
||||
$payment->save();
|
||||
|
||||
$total_payment = $total_payment + $payment->total_payment;
|
||||
$total_payment = $total_payment + $payment->total_payment;
|
||||
|
||||
$eachbid = LelongBid::where('id',$sag->lelongbid_id)->first();
|
||||
$eachbid->status_payment = 1;
|
||||
$eachbid->status_jual = 1;
|
||||
$eachbid->status_semak = 1;
|
||||
$eachbid->t_jual = $currentdate;
|
||||
$eachbid->save();
|
||||
$eachbid = LelongBid::where('id',$sag->lelongbid_id)->first();
|
||||
$eachbid->status_payment = 1;
|
||||
$eachbid->status_jual = 1;
|
||||
$eachbid->status_semak = 1;
|
||||
$eachbid->t_jual = $currentdate;
|
||||
$eachbid->save();
|
||||
|
||||
$bidder = LelongBidder::where('lelongbid_id', $sag->lelongbid_id)
|
||||
->where('payment_id', $sag->payment_id)
|
||||
->where('user_id', $sag->user_id)
|
||||
->first();
|
||||
$bidder->status_payment = 1;
|
||||
$bidder->update();
|
||||
$bidder = LelongBidder::where('lelongbid_id', $sag->lelongbid_id)
|
||||
->where('payment_id', $sag->payment_id)
|
||||
->where('user_id', $sag->user_id)
|
||||
->first();
|
||||
$bidder->status_payment = 1;
|
||||
$bidder->update();
|
||||
}
|
||||
WhatsappPengesahanPembida::dispatch($user_notelbimbit,$user_namapembida);
|
||||
|
||||
//insert loguser
|
||||
$loguser = new LogUser;
|
||||
$loguser->user_id = $user->id;
|
||||
$loguser->date = $currentdate;
|
||||
$loguser->username = $user->username;
|
||||
$loguser->nama_user = $user->name;
|
||||
// $loguser->norujukan = $data['norujukan'];
|
||||
$loguser->nota = $request->kodcaw.': '.$request->nama_pembida.' ('.$request->nokp_pembida.'): Bukti Bayaran Telah Sah';
|
||||
$loguser->save();
|
||||
|
||||
|
||||
return redirect()->route('home')->with('success','Pembayaran Berjaya');
|
||||
}
|
||||
|
||||
return redirect()->route('home')->with('success','Pembayaran Berjaya');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -426,7 +426,9 @@ class HomeController extends Controller
|
||||
$user = Auth::user();
|
||||
$dateTime = date('Y-m-d');
|
||||
|
||||
if ($user->hasRole('callcenter')) {
|
||||
if ($user->hasRole('ajk')) {
|
||||
return view('homeajk');
|
||||
} else if ($user->hasRole('callcenter')) {
|
||||
return view('homecallcenter');
|
||||
} else if ($user->hasRole('operasi-kpi')) {
|
||||
return view('homeoperasikpi');
|
||||
|
||||
@@ -54,6 +54,7 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Jobs\HantarMail;
|
||||
use App\Jobs\WhatsappPemenang;
|
||||
use App\Jobs\AutoTamatlelong;
|
||||
|
||||
class LelongController extends Controller
|
||||
{
|
||||
@@ -1955,6 +1956,8 @@ class LelongController extends Controller
|
||||
$currentdate = Carbon::now();
|
||||
$currenttime = $currentdate->toTimeString();
|
||||
$endtime = $currentdate->addHours(2);
|
||||
// $endtime = $currentdate->addMinutes(3);
|
||||
|
||||
|
||||
$lelong = Lelong::where('id','=',$id)->first();
|
||||
$lelong->masamula_lelong = $currenttime;
|
||||
@@ -1968,8 +1971,22 @@ class LelongController extends Controller
|
||||
$cawlel->masamula_lelong = $currenttime;
|
||||
$cawlel->masatamat_lelong = $endtime->toTimeString();
|
||||
$cawlel->status_online = 1; //start lelong
|
||||
$cawlel->save();
|
||||
$cawlel->save();
|
||||
}
|
||||
//run job tamat lelong
|
||||
AutoTamatLelong::dispatch($id)->delay(Carbon::now()->addHours(2));
|
||||
// AutoTamatLelong::dispatch($id)->delay(Carbon::now()->addMinutes(3));
|
||||
|
||||
|
||||
//insert loguser
|
||||
$loguser = new LogUser;
|
||||
// $loguser->user_id = $user->id;
|
||||
$loguser->date = $currentdate;
|
||||
$loguser->username = 'System';
|
||||
$loguser->nama_user = 'System';
|
||||
// $loguser->norujukan = $data['norujukan'];
|
||||
$loguser->nota = 'Lelongan Mula';
|
||||
$loguser->save();
|
||||
|
||||
return redirect()->route('home');
|
||||
}
|
||||
@@ -3601,11 +3618,39 @@ class LelongController extends Controller
|
||||
|
||||
$datalelbid = LelongBid::where('caw_id','=',$caw->caw_id)->where('lelong_id',$id)->where('status_jual','=', 0)->get();
|
||||
$suratcaw = $datalelbid->all();
|
||||
|
||||
foreach(array_chunk($suratcaw,100) as $data_chunk)
|
||||
{
|
||||
// dd($datalelbid);
|
||||
foreach($data_chunk as $data1)
|
||||
{
|
||||
$biddersag = LelongBidder::where('lelongbid_id', $data1->id)
|
||||
->where('status_bidder','=', 0)->first();
|
||||
if($biddersag){
|
||||
$savedatabidder = $biddersag->replicate();
|
||||
$savedatabidder->setTable('lelongbidder_temp');
|
||||
$savedatabidder->save();
|
||||
|
||||
//insert loguser
|
||||
$loguser = new LogUser;
|
||||
$loguser->user_id = $biddersag->user_id;
|
||||
$loguser->date = $currentdate;
|
||||
$loguser->nama_user = $biddersag->nama_bidder;
|
||||
$loguser->norujukan = $data1->norujukan;
|
||||
$loguser->nota = 'Pernah Bid Sebelum Ini Tapi Kalah';
|
||||
$loguser->save();
|
||||
//hapus lelongbidder yg pernah bid
|
||||
$lelongbidder = LelongBidder::where('lelongbid_id', $data1->id)
|
||||
->where('status_bidder', 0)
|
||||
->delete();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
foreach($data_chunk as $data)
|
||||
{
|
||||
{
|
||||
$savedata = $data->replicate();
|
||||
$savedata->setTable('lelongbid_xlaku');
|
||||
$savedata->save();
|
||||
|
||||
@@ -330,6 +330,173 @@ class NotisController extends Controller
|
||||
return $pdf->download('Penjanaan Notis Fasa 1:Batch Lelong ' . $lelong_id . '.pdf');
|
||||
}
|
||||
|
||||
public function jananotis2_new($lelong_id)
|
||||
{
|
||||
// focus only on variable: $marhuns, $lelongid, $caw, $tarikh_cetak
|
||||
// variable not use: $lelong_id, $customer, $listsag
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
$caw = Cawangan::where('caw_code', '=', $user->kodcaw)->first();
|
||||
|
||||
$currentdate = Carbon::now();
|
||||
$tarikh_cetak = $currentdate->toDateString();
|
||||
|
||||
$current_date_time = $currentdate->toDateTimeString();
|
||||
|
||||
Log::info("Jana notis fasa 1: " . $user->kodcaw . ", " . $user->name);
|
||||
NotifyJanaNotis::dispatch($user->id, $user->kodcaw, $user->name, 'Jana Notis Fasa 1', $current_date_time);
|
||||
|
||||
$lelongid = Lelong::find($lelong_id);
|
||||
|
||||
$arraynorujukan = LelongBid::where('lelong_id', $lelong_id)->where('kodcaw', $caw->caw_code)->pluck('norujukan');
|
||||
|
||||
$marhuns = Gadai::on($caw->caw_code)->whereIn('norujukan', $arraynorujukan)->select('nokp', 'norujukan','bakipjm','tagbaru')->orderBy('nokp', 'asc')->get();
|
||||
|
||||
$marhuns_pluck_nokp = $marhuns->pluck('nokp');
|
||||
|
||||
$customers = Customer::whereIn('kpbaru', $marhuns_pluck_nokp)
|
||||
->orWhereIn('kplama', $marhuns_pluck_nokp)
|
||||
->join('poskod', 'customer.poskod', '=', 'poskod.poskod')
|
||||
->join('daerah', 'poskod.koddaerah', '=', 'daerah.koddaerah')
|
||||
->join('negeri', 'poskod.kodnegeri', '=', 'negeri.kodnegeri')
|
||||
->get();
|
||||
|
||||
$customers_keyBy_noKp = $customers->keyBy(function ($item) {
|
||||
if ($item->kpbaru != '') {
|
||||
return $item->kpbaru;
|
||||
} else if ($item->kplama != '') {
|
||||
return $item->kplama;
|
||||
}
|
||||
});
|
||||
|
||||
foreach ($marhuns as $index => $marhun) {
|
||||
if ($customers_keyBy_noKp[$marhun->nokp]) {
|
||||
$marhuns[$index]['nama'] = $customers_keyBy_noKp[$marhun->nokp];
|
||||
}
|
||||
|
||||
$getdatalelongbid = LelongBid::where('lelong_id', $lelong_id)->where('norujukan', $marhun->norujukan)->first();
|
||||
//jika ambil data dari api
|
||||
$tagbaru = $marhun->tagbaru;
|
||||
// dd($tagbaru);
|
||||
if($tagbaru == '0'){
|
||||
$getkeuntunganhinggatarikhlelong = Http::get(config('app.api_ujrah_url'). 'get/upahtawarruqbytarikh',[
|
||||
'kodcaw' => $user->kodcaw,
|
||||
'norujukan' => $marhun->norujukan,
|
||||
'tarikh' => $getdatalelongbid['t_lelong'],
|
||||
'jeniskeuntungan' => 'asal'
|
||||
])->json();
|
||||
}elseif($tagbaru == '1'){
|
||||
$getkeuntunganhinggatarikhlelong = Http::get(config('app.api_ujrah_url'). 'get/upahtawarruqbytarikh',[
|
||||
'kodcaw' => $user->kodcaw,
|
||||
'norujukan' => $marhun->norujukan,
|
||||
'tarikh' => $getdatalelongbid['t_lelong'],
|
||||
'jeniskeuntungan' => 'onepercent'
|
||||
])->json();
|
||||
}
|
||||
// dd($getkeuntunganhinggatarikhlelong);
|
||||
$nilaitebus = (float) $getkeuntunganhinggatarikhlelong['harga_tebus'];
|
||||
$nilaipembiayaan = (float) $getdatalelongbid['pinjaman'];
|
||||
$nilaikeuntungan = (float) $getkeuntunganhinggatarikhlelong['upahsemasa'];
|
||||
$jumlah = $nilaipembiayaan + $nilaikeuntungan;
|
||||
|
||||
$marhuns[$index]['nilaitebus'] = $nilaitebus;
|
||||
$marhuns[$index]['nilaipembiayaan'] = $nilaipembiayaan;
|
||||
$marhuns[$index]['nilaikeuntungan'] = $nilaikeuntungan;
|
||||
$marhuns[$index]['jumlah'] = $jumlah;
|
||||
}
|
||||
// return view('pdf.jananotis', compact('marhuns', 'lelongid', 'caw', 'tarikh_cetak'));
|
||||
$pdf = PDF::loadView('pdf.jananotis_new', compact('marhuns', 'lelongid', 'caw', 'tarikh_cetak'))
|
||||
->setPaper('a4', 'potrait');
|
||||
|
||||
return $pdf->download('Penjanaan Notis Fasa 1:Batch Lelong ' . $lelong_id . '.pdf');
|
||||
}
|
||||
|
||||
public function jananotis2_new2($lelong_id)
|
||||
{
|
||||
// focus only on variable: $marhuns, $lelongid, $caw, $tarikh_cetak
|
||||
// variable not use: $lelong_id, $customer, $listsag
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
$caw = Cawangan::where('caw_code', '=', $user->kodcaw)->first();
|
||||
|
||||
$currentdate = Carbon::now();
|
||||
$tarikh_cetak = $currentdate->toDateString();
|
||||
|
||||
$current_date_time = $currentdate->toDateTimeString();
|
||||
|
||||
Log::info("Jana notis fasa 1: " . $user->kodcaw . ", " . $user->name);
|
||||
NotifyJanaNotis::dispatch($user->id, $user->kodcaw, $user->name, 'Jana Notis Fasa 1', $current_date_time);
|
||||
|
||||
$lelongid = Lelong::find($lelong_id);
|
||||
|
||||
$arraynorujukan = LelongBid::where('lelong_id', $lelong_id)->where('kodcaw', $caw->caw_code)->pluck('norujukan');
|
||||
|
||||
$marhuns = Gadai::on($caw->caw_code)->whereIn('norujukan', $arraynorujukan)->select('nokp', 'norujukan','bakipjm','tagbaru')->orderBy('nokp', 'asc')->get();
|
||||
|
||||
$marhuns_pluck_nokp = $marhuns->pluck('nokp');
|
||||
|
||||
$customers = Customer::whereIn('kpbaru', $marhuns_pluck_nokp)
|
||||
->orWhereIn('kplama', $marhuns_pluck_nokp)
|
||||
->join('poskod', 'customer.poskod', '=', 'poskod.poskod')
|
||||
->join('daerah', 'poskod.koddaerah', '=', 'daerah.koddaerah')
|
||||
->join('negeri', 'poskod.kodnegeri', '=', 'negeri.kodnegeri')
|
||||
->get();
|
||||
|
||||
$customers_keyBy_noKp = $customers->keyBy(function ($item) {
|
||||
if ($item->kpbaru != '') {
|
||||
return $item->kpbaru;
|
||||
} else if ($item->kplama != '') {
|
||||
return $item->kplama;
|
||||
}
|
||||
});
|
||||
|
||||
foreach ($marhuns as $index => $marhun) {
|
||||
if ($customers_keyBy_noKp[$marhun->nokp]) {
|
||||
$marhuns[$index]['nama'] = $customers_keyBy_noKp[$marhun->nokp];
|
||||
}
|
||||
|
||||
$getdatalelongbid = LelongBid::where('lelong_id', $lelong_id)->where('norujukan', $marhun->norujukan)->first();
|
||||
//jika ambil data dari api
|
||||
$tagbaru = $marhun->tagbaru;
|
||||
// dd($tagbaru);
|
||||
if($tagbaru == '0'){
|
||||
$getkeuntunganhinggatarikhlelong = Http::get(config('app.api_ujrah_url'). 'get/upahtawarruqbytarikh',[
|
||||
'kodcaw' => $user->kodcaw,
|
||||
'norujukan' => $marhun->norujukan,
|
||||
'tarikh' => $getdatalelongbid['t_lelong'],
|
||||
'jeniskeuntungan' => 'asal'
|
||||
])->json();
|
||||
}elseif($tagbaru == '1'){
|
||||
$getkeuntunganhinggatarikhlelong = Http::get(config('app.api_ujrah_url'). 'get/upahtawarruqbytarikh',[
|
||||
'kodcaw' => $user->kodcaw,
|
||||
'norujukan' => $marhun->norujukan,
|
||||
'tarikh' => $getdatalelongbid['t_lelong'],
|
||||
'jeniskeuntungan' => 'onepercent'
|
||||
])->json();
|
||||
}
|
||||
// dd($getkeuntunganhinggatarikhlelong);
|
||||
$nilaitebus = (float) $getkeuntunganhinggatarikhlelong['harga_tebus'];
|
||||
$nilaipembiayaan = (float) $getdatalelongbid['pinjaman'];
|
||||
$nilaikeuntungan = (float) $getkeuntunganhinggatarikhlelong['upahsemasa'];
|
||||
$jumlah = $nilaipembiayaan + $nilaikeuntungan;
|
||||
|
||||
$marhuns[$index]['nilaitebus'] = $nilaitebus;
|
||||
$marhuns[$index]['nilaipembiayaan'] = $nilaipembiayaan;
|
||||
$marhuns[$index]['nilaikeuntungan'] = $nilaikeuntungan;
|
||||
$marhuns[$index]['jumlah'] = $jumlah;
|
||||
}
|
||||
// return view('pdf.jananotis', compact('marhuns', 'lelongid', 'caw', 'tarikh_cetak'));
|
||||
$pdf = PDF::loadView('pdf.jananotisfasa2_new', compact('marhuns', 'lelongid', 'caw', 'tarikh_cetak'))
|
||||
->setPaper('a4', 'potrait');
|
||||
|
||||
return $pdf->download('Penjanaan Notis Fasa 2:Batch Lelong ' . $lelong_id . '.pdf');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function listnotis(Request $request){
|
||||
|
||||
|
||||
|
||||
@@ -519,6 +519,48 @@ class PembidaController extends Controller
|
||||
$bida->save();
|
||||
// dd($request->user_id);
|
||||
|
||||
//temp lelongbidder
|
||||
$datalelbid = LelongBidder::where('lelongbid_id', $bida->id)
|
||||
->where('user_id', $infos->user_id)->get();
|
||||
$suratcaw = $datalelbid->all();
|
||||
foreach(array_chunk($suratcaw,100) as $data_chunk)
|
||||
{
|
||||
// dd($datalelbid);
|
||||
foreach($data_chunk as $data)
|
||||
{
|
||||
$savedata = $data->replicate();
|
||||
$savedata->setTable('lelongbidder_temp');
|
||||
$savedata->save();
|
||||
|
||||
//audit trail
|
||||
$loguser = new LogUser;
|
||||
$loguser->user_id = $user->id;
|
||||
$loguser->date = $currentdate;
|
||||
$loguser->username = $user->username;
|
||||
$loguser->nama_user = $user->name;
|
||||
$loguser->norujukan = $norujukan;
|
||||
$loguser->nota = 'Isytihar Joy Bidder';
|
||||
$loguser->save();
|
||||
}
|
||||
}
|
||||
|
||||
$datalelbidxlaku = LelongBid::where('norujukan', $bida->norujukan)->get();
|
||||
$suratcawxlaku = $datalelbidxlaku->all();
|
||||
foreach(array_chunk($suratcawxlaku,100) as $data_chunkxlaku)
|
||||
{
|
||||
// dd($datalelbid);
|
||||
foreach($data_chunkxlaku as $dataxlaku)
|
||||
{
|
||||
$savedataxlaku = $dataxlaku->replicate();
|
||||
$savedataxlaku->setTable('lelongbid_xlaku');
|
||||
$savedataxlaku->save();
|
||||
// dd($caw_lelsag);
|
||||
$caw_lelsag = LelongBid::where('norujukan', $dataxlaku->norujukan)->first();
|
||||
$caw_lelsag->status_payment = '0';
|
||||
$caw_lelsag->xlaku = '1';
|
||||
$caw_lelsag->update();
|
||||
}
|
||||
}
|
||||
//hapus lelongbidder
|
||||
$lelongbidder = LelongBidder::where('lelongbid_id', $bida->id)
|
||||
->where('user_id', $infos->user_id)
|
||||
|
||||
@@ -112,12 +112,19 @@ class PenggunaController extends Controller
|
||||
$user->name = $request->name;
|
||||
$user->username = $request->username;
|
||||
$user->kodcaw = $request->caw;
|
||||
$user->notelbimbit = $request->notelbimbit;
|
||||
$user->status = 'active';
|
||||
$user->t_daftar = $currentdate;
|
||||
$user->email = $request->email;
|
||||
$user->email_verified_at = $currentdate;
|
||||
$user->password = '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi'; //password
|
||||
$user->user_type = 1;
|
||||
if($arraytaraf[0] == 'ajk'){
|
||||
$user->user_type = 3;
|
||||
}
|
||||
else{
|
||||
$user->user_type = 1;
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
||||
$user->syncRoles($arraytaraf);
|
||||
@@ -173,7 +180,7 @@ class PenggunaController extends Controller
|
||||
$user->email = $request->emel;
|
||||
$user->kodcaw = $request->caw;
|
||||
$user->username = $request->username;
|
||||
// $user->notelbimbit = $request->notelbimbit;
|
||||
$user->notelbimbit = $request->notelbimbit;
|
||||
// $user->nokp = $request->nokp;
|
||||
$user->updated_at = $currentdate;
|
||||
$user->status = $status;
|
||||
@@ -358,6 +365,18 @@ class PenggunaController extends Controller
|
||||
// return $pdf->download('Roles.pdf');
|
||||
}
|
||||
}
|
||||
|
||||
public function listajk()
|
||||
{
|
||||
$alluser = User::with('roles','cawangan')->whereHas("roles", function($q) {
|
||||
$q->where("name",'=', 'ajk');})
|
||||
->orderBy('name','ASC')
|
||||
->get();
|
||||
$allroles = Role::all();
|
||||
$allRolesPluck= $allroles->pluck('name');
|
||||
$caw = Cawangan::all();
|
||||
return view('parameter.listajk',compact('alluser','allroles','caw', 'allRolesPluck'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\Lelong;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Events\LelongNotify;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Models\LogUser;
|
||||
use App\Models\User;
|
||||
use App\Models\CawanganLelong;
|
||||
use App\Models\Cart;
|
||||
|
||||
|
||||
|
||||
class AutoTamatLelong implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$dt = Carbon::now();
|
||||
$timeloni = $dt->toTimeString();
|
||||
$tarikhlelong = $dt->toDateString();
|
||||
|
||||
event(new LelongNotify('stop'));
|
||||
$updatestatus = Lelong::where('sts_lelong',1)
|
||||
->where('tarikh_lelong',$tarikhlelong)
|
||||
->update(['sts_lelong' => 2]);
|
||||
|
||||
$cawlelong = CawanganLelong::where('lelong_id','=',$this->id)->get();
|
||||
foreach($cawlelong as $cawlel) //save old harga asas
|
||||
{
|
||||
// $cawlel->masatamat_lelong = $currenttime;
|
||||
$cawlel->status_online = 0; //start lelong
|
||||
$cawlel->save();
|
||||
}
|
||||
|
||||
$hapuscart = Cart::truncate();
|
||||
|
||||
|
||||
|
||||
$getnoajk = User::where('user_type', 3)->get();
|
||||
foreach($getnoajk as $notifikasi){
|
||||
$mobile_no = '6'.$notifikasi->notelbimbit;
|
||||
|
||||
if(config('app.env') != 'production'){
|
||||
$mobile_no = config('app.admin_phone_number');
|
||||
}
|
||||
$response = Http::get(env('WABOT_API'), [
|
||||
'number' => $mobile_no,
|
||||
'type' => 'text',
|
||||
'message' => 'Lelongan Telah Tamat, Sila Jana Pemenang',
|
||||
'instance_id' => env('WABOT_INSTANCES_ID'),
|
||||
'access_token' => env('WABOT_TOKEN_KEYS')
|
||||
]);
|
||||
}
|
||||
|
||||
//insert loguser
|
||||
$loguser = new LogUser;
|
||||
// $loguser->user_id = $user->id;
|
||||
$loguser->date = $dt;
|
||||
$loguser->username = 'System';
|
||||
$loguser->nama_user = 'System';
|
||||
// $loguser->norujukan = $data['norujukan'];
|
||||
$loguser->nota = 'Lelongan Tamat';
|
||||
$loguser->save();
|
||||
|
||||
Log::info("Lelongan Telah Tamat" . $response);
|
||||
// }
|
||||
|
||||
// event(new LelongNotify('stop'));
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use App\Models\Cawangan;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class WhatsappPengesahanPembida implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $user_notelbimbit;
|
||||
public $user_namapembida;
|
||||
|
||||
// protected $notisid;
|
||||
// protected $cawid;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user_notelbimbit,$user_namapembida)
|
||||
{
|
||||
$this->user_notelbimbit = $user_notelbimbit;
|
||||
$this->user_namapembida = $user_namapembida;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$mobile_no = ltrim($this->user_notelbimbit, '+');
|
||||
$message = 'AR-RAHN PKB: Terima Kasih '.$this->user_namapembida .', Pembayaran Anda Telah Disahkan, Sila Ke Cawangan Berkenaan Untuk Tuntutan Barang Bidaan Anda Hari Ini.';
|
||||
if(config('app.env') != 'production'){
|
||||
$mobile_no = config('app.admin_phone_number');
|
||||
}
|
||||
$response = Http::get(env('WABOT_API'), [
|
||||
'number' => $mobile_no,
|
||||
'type' => 'text',
|
||||
'message' => $message,
|
||||
'instance_id' => env('WABOT_INSTANCES_ID'),
|
||||
'access_token' => env('WABOT_TOKEN_KEYS')
|
||||
]);
|
||||
|
||||
Log::info("WABOT - Akaun Telah Sahkan Pembayaran: ".$this->user_namapembida .'' . $response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use App\Models\LogUser;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
|
||||
|
||||
class WhatsappTidakSahBayaran implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $user_namapembida;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user_namapembida)
|
||||
{
|
||||
$this->user_namapembida = $user_namapembida;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$getnoajk = User::where('user_type', 3)->get();
|
||||
foreach($getnoajk as $notifikasi){
|
||||
$mobile_no = '6'.$notifikasi->notelbimbit;
|
||||
|
||||
if(config('app.env') != 'production'){
|
||||
$mobile_no = config('app.admin_phone_number');
|
||||
}
|
||||
$response = Http::get(env('WABOT_API'), [
|
||||
'number' => $mobile_no,
|
||||
'type' => 'text',
|
||||
'message' => 'Bayaran Pembida yang bernama *'.$this->user_namapembida.'* Adalah *Tidak Sah*, Mohon Pihak AJK Lelong Untuk Buat Semakan, Terima Kasih.' ,
|
||||
'instance_id' => env('WABOT_INSTANCES_ID'),
|
||||
'access_token' => env('WABOT_TOKEN_KEYS')
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ class Lelong extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'tarikh_lelong',
|
||||
'masamula_lelong',
|
||||
'masatamat_lelong',
|
||||
'kali',
|
||||
'harga_emas_asas',
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LelongBidderTemp extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'lelongbidder_temp';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'lelongbid_id',
|
||||
'nama_bidder',
|
||||
'hargabida',
|
||||
'notelbimbit',
|
||||
'nilaimarhun',
|
||||
'cajlelong',
|
||||
'status_bidder',
|
||||
'status_payment',
|
||||
'masa_bidaan'
|
||||
];
|
||||
|
||||
public function lelongbid() {
|
||||
return $this->hasOne(LelongBid::class,'id', 'lelongbid_id');
|
||||
}
|
||||
|
||||
public function payment()
|
||||
{
|
||||
return $this->hasOne(Payment::class, 'lelongbid_id', 'lelongbid_id')->where('remark', '<>', '');
|
||||
}
|
||||
|
||||
public function scanjual() {
|
||||
return $this->hasOne(ScanJual::class, 'lelongbid_id', 'lelongbid_id');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user