Bugfix/list clickup issue (#5)

Reviewed-on: #5
Co-authored-by: ISMAIL MASSERAN <ismail@koppkb.com>
Co-committed-by: ISMAIL MASSERAN <ismail@koppkb.com>
This commit was merged in pull request #5.
This commit is contained in:
2026-10-19 13:30:36 +08:00
committed by ismailmasseran
parent b1d393b1a1
commit e29a5891c8
196 changed files with 18243 additions and 19520 deletions
+189 -222
View File
@@ -3,44 +3,22 @@
namespace App\Http\Controllers;
use App\Events\PaymentNotify;
use Illuminate\Http\Request;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
use Illuminate\Support\Facades\Auth;
use App\Models\User;
use PDF;
use App\Models\Cawangan;
use App\Models\JenisEmas;
use App\Models\JenisKarat;
use App\Models\Simulasi;
use App\Models\SimulasiBid;
use App\Models\SimulasiBidMarhun;
use App\Models\SimKarat;
use App\Models\SimKarat_temp;
use App\Models\CawanganSimulasi;
use App\Models\Lelong;
use App\Models\CawanganLelong;
use App\Models\LelongBid;
use App\Models\LelongBidMarhun;
use App\Models\LelKarat;
use App\Models\LelKarat_temp;
use App\Models\LelongBidder;
use App\Models\Resit;
use App\Models\Payment;
use Session;
use Carbon\Carbon;
use Money\Money;
use Billplz\Client;
use Http\Client\Common\HttpMethodsClient;
use Http\Adapter\Guzzle7\Client as GuzzleHttpClient;
use Http\Message\MessageFactory\GuzzleMessageFactory;
use App\Models\LogUser;
use App\Jobs\WhatsappPembidaFPXPaid;
use App\Models\Payment;
use App\Models\Resit;
use App\Models\User;
use Billplz\Client;
use Carbon\Carbon;
use Http\Adapter\Guzzle7\Client as GuzzleHttpClient;
use Http\Client\Common\HttpMethodsClient;
use Http\Message\MessageFactory\GuzzleMessageFactory;
use Illuminate\Http\Request;
use Money\Money;
class ApiController extends Controller
{
@@ -55,49 +33,46 @@ class ApiController extends Controller
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function __construct(){
// parent::__construct();
if(config('app.env') != 'production'){
$this->api_key = 'abecfd0c-98d8-4635-abc2-2fcba8c60c11';
$this->XSignature_Key = 'S-GWr7z03XjAhqPsFfu_H5nQ';
$this->collection_id = 'bwdtejv0';
}else{
$this->api_key = 'f3e82fe1-a422-4660-97f0-65cc59ff6c47';
$this->XSignature_Key = 'S-alZUbzmD2_TF3vmrRqgehQ';
public function __construct()
{
// parent::__construct();
if (config('app.env') != 'production') {
$this->api_key = 'abecfd0c-98d8-4635-abc2-2fcba8c60c11';
$this->XSignature_Key = 'S-GWr7z03XjAhqPsFfu_H5nQ';
$this->collection_id = 'bwdtejv0';
} else {
$this->api_key = 'f3e82fe1-a422-4660-97f0-65cc59ff6c47';
$this->XSignature_Key = 'S-alZUbzmD2_TF3vmrRqgehQ';
$this->collection_id = 'lx_bplsb';
}
}
}
public function biditem()
}
public function biditem()
{
$currentdate = Carbon::now();
$currentdate = $currentdate->toDateString();
// dd($currentdate->toDateString());
$lelong = Lelong::where('tarikh_lelong','=',$currentdate)->get();
$lelong = Lelong::where('tarikh_lelong', '=', $currentdate)->get();
$arrayID = [];
foreach($lelong as $data)
{
array_push($arrayID,$data->id);
foreach ($lelong as $data) {
array_push($arrayID, $data->id);
}
$lelongbid = LelongBid::whereIn('lelong_id',$arrayID)
->join('lelongbidmarhun','lelongbid.id','=','lelongbidmarhun.lelongbid_id')
->get();
$lelongbid = LelongBid::whereIn('lelong_id', $arrayID)
->join('lelongbidmarhun', 'lelongbid.id', '=', 'lelongbidmarhun.lelongbid_id')
->get();
$surat = LelongBid::whereIn('lelong_id',$arrayID)->get();
$surat = LelongBid::whereIn('lelong_id', $arrayID)->get();
if(sizeof($lelongbid)!=0)
{
if (count($lelongbid) != 0) {
return response()->json([
'success' => true,
'lelong' => $lelong,
'surat' => $surat,
'item' => $lelongbid
'item' => $lelongbid,
]);
}
else
{
} else {
return response()->json([
'success' => false,
'message' => 'No Data',
@@ -105,23 +80,19 @@ class ApiController extends Controller
}
}
public function karat()
public function karat()
{
$jenisemas = JenisEmas::all();
$jeniskarat = JenisKarat::all();
if(sizeof($jenisemas)!=0 && sizeof($jeniskarat)!=0 )
{
if (count($jenisemas) != 0 && count($jeniskarat) != 0) {
return response()->json([
'success' => true,
'karat' => $jeniskarat,
'emas' => $jenisemas
'emas' => $jenisemas,
]);
}
else
{
} else {
return response()->json([
'success' => false,
'message' => 'No Data',
@@ -133,59 +104,60 @@ class ApiController extends Controller
{
return view('pembayaran.testbillplz');
}
public function feepayment(Request $request)
{
$arraycollection_id = array();
$arraycollection_id = [];
$http = new HttpMethodsClient(
new GuzzleHttpClient(),
new GuzzleMessageFactory()
);
$billplz = new Client($http, $this->api_key);
if(config('app.env') != 'production'){
$billplz->useSandbox();
}
new GuzzleHttpClient,
new GuzzleMessageFactory
);
$billplz->useVersion('v4');
$billplz = new Client($http, $this->api_key);
if (config('app.env') != 'production') {
$billplz->useSandbox();
}
$bill = $billplz->bill();
$billplz->useVersion('v4');
$current = Carbon::now();
$current = new Carbon();
$bill = $billplz->bill();
$current = Carbon::now();
$current = new Carbon;
$day = $current->day;
$month = $current->month;
$year = $current->format('y');
$year = $current->format('y');
$total_bayaran = 1100;
$collection_id = $this->collection_id;
$response = $bill->create(
$collection_id,
$request->email,
$request->notel,
$request->name,
Money::MYR($total_bayaran),
route('pay.callback'),
'Bayaran Borang',
['redirect_url' => route('pay.paymentStatus')]
// ['redirect_url' => url('http://localhost:8080/test')]
);
$response = $bill->create(
$collection_id,
$request->email,
$request->notel,
$request->name,
Money::MYR($total_bayaran),
route('pay.callback'),
'Bayaran Borang',
['redirect_url' => route('pay.paymentStatus')]
// ['redirect_url' => url('http://localhost:8080/test')]
);
// dd($response);
$previous_siri = Resit::orderBy('id','desc')->first();
if($previous_siri){
$previous_siri = Resit::orderBy('id', 'desc')->first();
if ($previous_siri) {
$nosiri = $previous_siri->id + 1;
}else{
} else {
$nosiri = 1;
}
$billcode = $response->toArray();
$billcode = $response->toArray();
// dd($billcode);
// $billcode['redirect_url'] = 'http://192.168.0.10:8003/api/pembayaran/response';
// dd($billcode);
$reference_no = 'LPKB' . $day . $month . $year . sprintf("%08d", $nosiri);
$reference_no = 'LPKB'.$day.$month.$year.sprintf('%08d', $nosiri);
// $response2 = $bill->get($billcode['id']);
// dd($response2->toArray());
$resit = new Resit;
@@ -197,8 +169,7 @@ class ApiController extends Controller
$resit->total_payment = 10;
$resit->save();
// return redirect($billcode['url'] . '?auto_submit=true');
// return redirect($billcode['url'] . '?auto_submit=true');
return response()->json([
'success' => true,
'message' => $billcode['url'],
@@ -206,41 +177,42 @@ class ApiController extends Controller
// return view('pembayaran.result.berjaya',compact('arraybayaran'));
}
public function callback(Request $request){
public function callback(Request $request)
{
// dd('hye callback');
$http = new HttpMethodsClient(
new GuzzleHttpClient(),
new GuzzleMessageFactory()
);
$billplz = new Client($http, $this->api_key);
if(config('app.env') != 'production'){
$billplz->useSandbox();
}
$billplz->useVersion('v4');
$http = new HttpMethodsClient(
new GuzzleHttpClient,
new GuzzleMessageFactory
);
$bill = $billplz->bill();
$billplz = new Client($http, $this->api_key);
if (config('app.env') != 'production') {
$billplz->useSandbox();
}
$billplz->useVersion('v4');
$data = $bill->webhook($request->toArray());
if($data['billplz']['paid'] == 'true'){
$resit = Resit::where('billplz_id','=',$data['billplz']['id'])->first();
$bill = $billplz->bill();
$data = $bill->webhook($request->toArray());
if ($data['billplz']['paid'] == 'true') {
$resit = Resit::where('billplz_id', '=', $data['billplz']['id'])->first();
$resit->status = 'PAID';
$resit->paid_at = $data['billplz']['paid_at'];
$resit->save();
$payment = new Payment;
$payment->user_id = $resit->user_id;
$payment->lelong_id = $resit->lelong_id;
$payment->total_payment = $resit->total_payment;
$payment->resit_id = $resit->id;
$payment->status_payment_opt = 2; //bayar secara online 2
$payment->status = 1; //fee rm10 - 1
$payment->status_payment_opt = 2; // bayar secara online 2
$payment->status = 1; // fee rm10 - 1
$payment->remark = 'BAYARAN ONLINE';
$payment->save();
event(new PaymentNotify('PAID',$resit->user_id,$payment->id));
event(new PaymentNotify('PAID', $resit->user_id, $payment->id));
$success = true;
@@ -251,47 +223,49 @@ class ApiController extends Controller
// 'resit' => $resit
// ]);
return view('pembida.feePaymentResult',compact('data', 'result', 'success'));
}else{
$resit = Resit::where('billplz_id','=',$data['billplz']['id'])->first();
return view('pembida.feePaymentResult', compact('data', 'result', 'success'));
} else {
$resit = Resit::where('billplz_id', '=', $data['billplz']['id'])->first();
$resit->status = 'UNSUCCESSFUL';
$resit->paid_at = null;
$resit->save();
$result = $resit->toArray();
$success = false;
event(new PaymentNotify('UNSUCCESSFUL',$resit->user_id,''));
// return response()->json([
event(new PaymentNotify('UNSUCCESSFUL', $resit->user_id, ''));
// return response()->json([
// 'success' => false,
// 'resit' => $resit
// ]);
return view('pembida.feePaymentResult',compact('data', 'result', 'success'));
}
}
return view('pembida.feePaymentResult', compact('data', 'result', 'success'));
}
}
public function response(Request $request){
public function response(Request $request)
{
// dd('hye response');
$http = new HttpMethodsClient(
new GuzzleHttpClient(),
new GuzzleMessageFactory()
);
$billplz = new Client($http, $this->api_key);
if(config('app.env') != 'production'){
$billplz->useSandbox();
}
$billplz->useVersion('v4');
$http = new HttpMethodsClient(
new GuzzleHttpClient,
new GuzzleMessageFactory
);
$bill = $billplz->bill();
$billplz = new Client($http, $this->api_key);
if (config('app.env') != 'production') {
$billplz->useSandbox();
}
$billplz->useVersion('v4');
$bill = $billplz->bill();
$req = $request->toArray();
$response = $bill->get($req['billplz']['id']);
$data = $response->toArray();
$data = $response->toArray();
// dd($data);
if($data['paid'] == 'true'){
$resit = Resit::where('billplz_id','=',$data['id'])->first();
if ($data['paid'] == 'true') {
$resit = Resit::where('billplz_id', '=', $data['id'])->first();
$resit->status = 'PAID';
$resit->paid_at = $data['paid_at'];
$resit->save();
@@ -301,12 +275,12 @@ class ApiController extends Controller
$payment->lelong_id = $resit->lelong_id;
$payment->total_payment = $resit->total_payment;
$payment->resit_id = $resit->id;
$payment->status_payment_opt = 2; //bayar secara online 2
$payment->status = 1; //fee rm10 - 1
$payment->status_payment_opt = 2; // bayar secara online 2
$payment->status = 1; // fee rm10 - 1
$payment->remark = 'BAYARAN ONLINE';
$payment->save();
event(new PaymentNotify('PAID',$resit->user_id,$payment->id));
event(new PaymentNotify('PAID', $resit->user_id, $payment->id));
$success = true;
@@ -317,91 +291,92 @@ class ApiController extends Controller
// 'resit' => $resit
// ]);
return view('pembida.feePaymentResult',compact('data', 'result', 'success'));
return view('pembida.feePaymentResult', compact('data', 'result', 'success'));
// return redirect()->to('http://localhost:8080/test')->with(['resit'=>$resit]);
}else{
$resit = Resit::where('billplz_id','=',$data['id'])->first();
} else {
$resit = Resit::where('billplz_id', '=', $data['id'])->first();
$resit->status = 'UNSUCCESSFUL';
$resit->paid_at = null;
$resit->save();
$result = $resit->toArray();
$success = false;
event(new PaymentNotify('UNSUCCESSFUL',$resit->user_id,''));
// return response()->json([
event(new PaymentNotify('UNSUCCESSFUL', $resit->user_id, ''));
// return response()->json([
// 'success' => false,
// 'resit' => $resit
// ]);
return view('pembida.feePaymentResult',compact('data', 'result', 'success'));
}
}
return view('pembida.feePaymentResult', compact('data', 'result', 'success'));
}
}
public function bidpayment(Request $request)
{
$arraycollection_id = array();
$arraycollection_id = [];
$http = new HttpMethodsClient(
new GuzzleHttpClient(),
new GuzzleMessageFactory()
);
$billplz = new Client($http, $this->api_key);
if(config('app.env') != 'production'){
$billplz->useSandbox();
}
new GuzzleHttpClient,
new GuzzleMessageFactory
);
$billplz->useVersion('v4');
$billplz = new Client($http, $this->api_key);
if (config('app.env') != 'production') {
$billplz->useSandbox();
}
$bill = $billplz->bill();
$billplz->useVersion('v4');
$current = Carbon::now();
$current = new Carbon();
$bill = $billplz->bill();
$current = Carbon::now();
$current = new Carbon;
$day = $current->day;
$month = $current->month;
$year = $current->format('y');
$year = $current->format('y');
$total_bayaran = ($request->total)*100+100;
$total_bayaran = ($request->total) * 100 + 100;
// dump($request->total);
// dd($total_bayaran);
$collection_id = $this->collection_id;
$response = $bill->create(
$collection_id,
$request->email,
$request->notel,
$request->name,
Money::MYR($total_bayaran),
route('pay.bidcallback'),
'Bayaran Bidaan',
['redirect_url' => route('pay.bidpaymentStatus')]
);
$response = $bill->create(
$collection_id,
$request->email,
$request->notel,
$request->name,
Money::MYR($total_bayaran),
route('pay.bidcallback'),
'Bayaran Bidaan',
['redirect_url' => route('pay.bidpaymentStatus')]
);
// dd($response->toArray());
$previous_siri = Resit::orderBy('id','desc')->first();
if($previous_siri){
$previous_siri = Resit::orderBy('id', 'desc')->first();
if ($previous_siri) {
$nosiri = $previous_siri->id + 1;
}else{
} else {
$nosiri = 1;
}
$billcode = $response->toArray();
$billcode = $response->toArray();
// dd($billcode);
// $billcode['redirect_url'] = 'http://192.168.0.10:8003/api/pembayaran/response';
// dd($billcode);
$reference_no = 'LPKB' . $day . $month . $year . sprintf("%08d", $nosiri);
$reference_no = 'LPKB'.$day.$month.$year.sprintf('%08d', $nosiri);
// $response2 = $bill->get($billcode['id']);
// dd($response2->toArray());
$resit = new Resit;
$resit->user_id = $request->user_id;
$resit->lelong_id = $request->lelong_id;
$resit->reference_no = $reference_no;
$resit->billplz_id = $billcode['id'];
$resit->resit_type = 2; //billplz resit for bid payment
$resit->resit_type = 2; // billplz resit for bid payment
$resit->total_payment = $request->total;
$resit->invoice_id = $request->invoice_id;
$resit->invoice_no = $request->invoice_no;
@@ -419,15 +394,14 @@ class ApiController extends Controller
$payment->lelongbid_id = $index['lelongbid_id'];
$payment->norujukan = $index['norujukan'];
$payment->total_payment = $index['total_payment'];
$payment->status_payment_opt = 2; //bayar secara online 2
$payment->status = 0; //0-unpaid //1-fee //2-bid
$payment->status_payment_opt = 2; // bayar secara online 2
$payment->status = 0; // 0-unpaid //1-fee //2-bid
$payment->remark = '';
$payment->resit_id = $resit->id;
$payment->save();
}
// return redirect($billcode['url'] . '?auto_submit=true');
// return redirect($billcode['url'] . '?auto_submit=true');
return response()->json([
'success' => true,
'message' => $billcode['url'],
@@ -439,8 +413,8 @@ class ApiController extends Controller
{
// dd('hye callback');
$http = new HttpMethodsClient(
new GuzzleHttpClient(),
new GuzzleMessageFactory()
new GuzzleHttpClient,
new GuzzleMessageFactory
);
$billplz = new Client($http, $this->api_key);
@@ -482,8 +456,8 @@ class ApiController extends Controller
->where('resit_id', $resit->id)
->get();
foreach ($payment as $index) {
$index->status = 2; //0-unpaid //1-fee //2-bid
$index->remark = "BERJAYA BAYARAN ONLINE";
$index->status = 2; // 0-unpaid //1-fee //2-bid
$index->remark = 'BERJAYA BAYARAN ONLINE';
$index->update();
// $updateTag = LelongBid::where('lelongbid.norujukan', $index->norujukan)->first();
@@ -500,7 +474,7 @@ class ApiController extends Controller
$updateTagBid->save();
$updateTagBidder = LelongBidder::where('lelongbid_id', $updateTagBid->id)
->where('user_id', $resit->user_id)->first();
->where('user_id', $resit->user_id)->first();
$updateTagBidder->status_payment = 2;
$updateTagBidder->payment_id = $index->id;
$updateTagBidder->save();
@@ -543,8 +517,8 @@ class ApiController extends Controller
{
// dd($request->all());
$http = new HttpMethodsClient(
new GuzzleHttpClient(),
new GuzzleMessageFactory()
new GuzzleHttpClient,
new GuzzleMessageFactory
);
$billplz = new Client($http, $this->api_key);
@@ -587,8 +561,8 @@ class ApiController extends Controller
->get();
foreach ($payment as $index) {
$index->status = 2; //0-unpaid //1-fee //2-bid
$index->remark = "BERJAYA BAYARAN ONLINE";
$index->status = 2; // 0-unpaid //1-fee //2-bid
$index->remark = 'BERJAYA BAYARAN ONLINE';
$index->update();
// $updateTag = LelongBid::where('lelongbid.norujukan', $index->norujukan)->first();
@@ -605,7 +579,7 @@ class ApiController extends Controller
$updateTagBid->save();
$updateTagBidder = LelongBidder::where('lelongbid_id', $updateTagBid->id)
->where('user_id', $resit->user_id)->first();
->where('user_id', $resit->user_id)->first();
$updateTagBidder->status_payment = 2;
$updateTagBidder->payment_id = $index->id;
$updateTagBidder->save();
@@ -647,24 +621,23 @@ class ApiController extends Controller
}
}
// BillplzService.php atau ApiController.php
public function processPaidResit(array $data)
{
$currentdate = Carbon::now();
$currentdate = $currentdate->toDateTimeString();
$loguser = new LogUser;
$loguser->user_id = User::where('name','System')->first()->id;
$loguser->user_id = User::where('name', 'System')->first()->id;
$loguser->date = $currentdate;
$loguser->username = 'System';
$loguser->nama_user = 'System';
$loguser->norujukan = $data['billplz']['id'];
$loguser->nota = 'Callback Resit Billplz Telah Bayar : Billplz_id -'.$data['billplz']['id'];
$loguser->save();
$resit = Resit::where('billplz_id', '=', $data['billplz']['id'])->first();
if (!$resit) {
if (! $resit) {
return false;
}
@@ -684,7 +657,7 @@ class ApiController extends Controller
foreach ($payment as $index) {
$index->status = 2;
$index->remark = "BERJAYA BAYARAN ONLINE";
$index->remark = 'BERJAYA BAYARAN ONLINE';
$index->update();
$updateTagBid = LelongBid::where('norujukan', $index->norujukan)->first();
@@ -703,13 +676,7 @@ class ApiController extends Controller
}
event(new PaymentNotify('PAID', $resit->user_id, $payment));
//notifikasi wasap kepada pembida//
WhatsappPembidaFPXPaid::dispatch($resit->user_id,
$resit->id,
$resit->total_payment);
return true;
}
}