Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 93b99c6eb0 | |||
| 1385539d31 | |||
| 0451ad3dbe | |||
| d5cfe503c5 | |||
| 8dd8def358 | |||
| e3e7694b54 | |||
| 2786b3be0c | |||
| 4648c7072b | |||
| ac57e04eac | |||
| a8888e66d1 | |||
| d0f08545d1 | |||
| 6c9f2f4f0f | |||
| 5d208f7a79 | |||
| aac29bc199 | |||
| 9e73f6ad32 | |||
| ff21d82af5 | |||
| 62c6d240ce | |||
| 1ee7edefff | |||
| b52f4b6919 | |||
| b8e3e2b369 | |||
| 3a86ba5b26 | |||
| b1934e1627 | |||
| 583d936fd2 | |||
| 1076ecbaf2 | |||
| 92894bad44 | |||
| 9916e81dba | |||
| 7fb7f75050 | |||
| 9fa0172017 | |||
| 79bc41d211 | |||
| 2f6f06d3e3 | |||
| 50cf966da7 | |||
| 8de9d872f9 | |||
| 20268cd136 | |||
| aa4c8ca5ba |
+28
@@ -0,0 +1,28 @@
|
|||||||
|
APP_NAME=Lumen
|
||||||
|
APP_ENV=production
|
||||||
|
APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=https://apiannurv2.erahn.com.my
|
||||||
|
APP_TIMEZONE=Asia/Kuala_Lumpur
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_SLACK_WEBHOOK_URL=
|
||||||
|
|
||||||
|
DB_CONNECTION_2=mysql
|
||||||
|
DB_HOST_2=192.168.1.216
|
||||||
|
DB_PORT_2=3306
|
||||||
|
DB_DATABASE_2=annur_tampoi
|
||||||
|
DB_USERNAME_2=spider
|
||||||
|
DB_PASSWORD_2=arrahn@123
|
||||||
|
|
||||||
|
DB_CONNECTION_7=mysql
|
||||||
|
DB_HOST_7=192.168.1.216
|
||||||
|
DB_PORT_7=3306
|
||||||
|
DB_DATABASE_7=master_annur
|
||||||
|
DB_USERNAME_7=spider
|
||||||
|
DB_PASSWORD_7=arrahn@123
|
||||||
|
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
|
|
||||||
|
TENNANT_MASTER_DB=master_annur
|
||||||
+17
-1
@@ -4,6 +4,8 @@ APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa
|
|||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_URL=http://localhost
|
APP_URL=http://localhost
|
||||||
APP_TIMEZONE=Asia/Kuala_Lumpur
|
APP_TIMEZONE=Asia/Kuala_Lumpur
|
||||||
|
API_ARRAHNBID=http://lelong.test/api/
|
||||||
|
API_ARRAHNBID_ANNUR=http://lelong-annur.test/api/
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
LOG_CHANNEL=stack
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
@@ -62,5 +64,19 @@ DB_PASSWORD_7=root
|
|||||||
TENNANT_MASTER_DB=master_erahn
|
TENNANT_MASTER_DB=master_erahn
|
||||||
TENNANT_KAUNTER_DB=kaunter_erahn
|
TENNANT_KAUNTER_DB=kaunter_erahn
|
||||||
|
|
||||||
|
KAUNTER_URL=http://host.docker.internal:8081
|
||||||
|
INTERNAL_NOTIFICATION_SECRET=erahn-local-notification-secret
|
||||||
|
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
QUEUE_CONNECTION=sync
|
QUEUE_CONNECTION=sync
|
||||||
|
|
||||||
|
BSAS_BASE_URL=https://bsasdevapi.bursamalaysia.com/api
|
||||||
|
BSAS_TOKEN_URL=https://bsasdevapi.bursamalaysia.com/oauth/token
|
||||||
|
BSAS_CLIENT_ID=
|
||||||
|
BSAS_CLIENT_SECRET=
|
||||||
|
BSAS_MEMBER_SHORT_NAME=KOOPPKB
|
||||||
|
BSAS_PRODUCT_CODE=CPO-MSIA-09
|
||||||
|
BSAS_TENOR=00088
|
||||||
|
BSAS_MAX_WAIT_TIME=10
|
||||||
|
BSAS_HTTP_TIMEOUT=30
|
||||||
|
BSAS_ORDER_RESULT_RETRIES=2
|
||||||
+27
-163
@@ -5,6 +5,7 @@ APP_DEBUG=true
|
|||||||
APP_URL=http://api_arrahn.test
|
APP_URL=http://api_arrahn.test
|
||||||
APP_TIMEZONE=Asia/Kuala_Lumpur
|
APP_TIMEZONE=Asia/Kuala_Lumpur
|
||||||
API_ARRAHNBID=http://lelong.test/api/
|
API_ARRAHNBID=http://lelong.test/api/
|
||||||
|
API_ARRAHNBID_ANNUR=http://lelong-annur.test/api/
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
LOG_CHANNEL=stack
|
||||||
LOG_SLACK_WEBHOOK_URL=
|
LOG_SLACK_WEBHOOK_URL=
|
||||||
@@ -86,172 +87,35 @@ DB_DATABASE_11=arrahn_pputeh
|
|||||||
DB_USERNAME_11=spider
|
DB_USERNAME_11=spider
|
||||||
DB_PASSWORD_11=G0dz!ll42020
|
DB_PASSWORD_11=G0dz!ll42020
|
||||||
|
|
||||||
DB_CONNECTION_12=mysql
|
|
||||||
DB_HOST_12=127.0.0.1
|
|
||||||
DB_PORT_12=3306
|
|
||||||
DB_DATABASE_12=arrahn_rpanjang
|
|
||||||
DB_USERNAME_12=spider
|
|
||||||
DB_PASSWORD_12=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_13=mysql
|
|
||||||
DB_HOST_13=127.0.0.1
|
|
||||||
DB_PORT_13=3306
|
|
||||||
DB_DATABASE_13=arrahn_tmerah
|
|
||||||
DB_USERNAME_13=spider
|
|
||||||
DB_PASSWORD_13=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_14=mysql
|
|
||||||
DB_HOST_14=127.0.0.1
|
|
||||||
DB_PORT_14=3306
|
|
||||||
DB_DATABASE_14=arrahn_wb
|
|
||||||
DB_USERNAME_14=spider
|
|
||||||
DB_PASSWORD_14=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_15=mysql
|
|
||||||
DB_HOST_15=127.0.0.1
|
|
||||||
DB_PORT_15=3306
|
|
||||||
DB_DATABASE_15=arrahn_wcy
|
|
||||||
DB_USERNAME_15=spider
|
|
||||||
DB_PASSWORD_15=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_16=mysql
|
|
||||||
DB_HOST_16=127.0.0.1
|
|
||||||
DB_PORT_16=3306
|
|
||||||
DB_DATABASE_16=arrahn_bentong
|
|
||||||
DB_USERNAME_16=spider
|
|
||||||
DB_PASSWORD_16=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_17=mysql
|
|
||||||
DB_HOST_17=192.168.0.102
|
|
||||||
DB_PORT_17=3306
|
|
||||||
DB_DATABASE_17=arrahn_kajang
|
|
||||||
DB_USERNAME_17=spider
|
|
||||||
DB_PASSWORD_17=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_18=mysql
|
|
||||||
DB_HOST_18=192.168.0.102
|
|
||||||
DB_PORT_18=3306
|
|
||||||
DB_DATABASE_18=arrahn_kangar
|
|
||||||
DB_USERNAME_18=spider
|
|
||||||
DB_PASSWORD_18=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_19=mysql
|
|
||||||
DB_HOST_19=192.168.0.102
|
|
||||||
DB_PORT_19=3306
|
|
||||||
DB_DATABASE_19=arrahn_kuantan
|
|
||||||
DB_USERNAME_19=spider
|
|
||||||
DB_PASSWORD_19=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_20=mysql
|
|
||||||
DB_HOST_20=192.168.0.102
|
|
||||||
DB_PORT_20=3306
|
|
||||||
DB_DATABASE_20=arrahn_pgudang
|
|
||||||
DB_USERNAME_20=spider
|
|
||||||
DB_PASSWORD_20=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_21=mysql
|
|
||||||
DB_HOST_21=192.168.0.102
|
|
||||||
DB_PORT_21=3306
|
|
||||||
DB_DATABASE_21=arrahn_raub
|
|
||||||
DB_USERNAME_21=spider
|
|
||||||
DB_PASSWORD_21=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_22=mysql
|
|
||||||
DB_HOST_22=192.168.0.102
|
|
||||||
DB_PORT_22=3306
|
|
||||||
DB_DATABASE_22=arrahn_rlaut
|
|
||||||
DB_USERNAME_22=spider
|
|
||||||
DB_PASSWORD_22=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_23=mysql
|
|
||||||
DB_HOST_23=192.168.0.102
|
|
||||||
DB_PORT_23=3306
|
|
||||||
DB_DATABASE_23=arrahn_skudai
|
|
||||||
DB_USERNAME_23=spider
|
|
||||||
DB_PASSWORD_23=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_24=mysql
|
|
||||||
DB_HOST_24=192.168.0.102
|
|
||||||
DB_PORT_24=3306
|
|
||||||
DB_DATABASE_24=arrahn_spetani
|
|
||||||
DB_USERNAME_24=spider
|
|
||||||
DB_PASSWORD_24=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_25=mysql
|
|
||||||
DB_HOST_25=192.168.0.102
|
|
||||||
DB_PORT_25=3306
|
|
||||||
DB_DATABASE_25=arrahn_temerloh
|
|
||||||
DB_USERNAME_25=spider
|
|
||||||
DB_PASSWORD_25=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_26=mysql
|
|
||||||
DB_HOST_26=192.168.0.103
|
|
||||||
DB_PORT_26=3306
|
|
||||||
DB_DATABASE_26=arrahn_api2
|
|
||||||
DB_USERNAME_26=spider
|
|
||||||
DB_PASSWORD_26=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_27=mysql
|
|
||||||
DB_HOST_27=192.168.0.103
|
|
||||||
DB_PORT_27=3306
|
|
||||||
DB_DATABASE_27=arrahn_beaufort
|
|
||||||
DB_USERNAME_27=spider
|
|
||||||
DB_PASSWORD_27=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_28=mysql
|
|
||||||
DB_HOST_28=192.168.0.103
|
|
||||||
DB_PORT_28=3306
|
|
||||||
DB_DATABASE_28=arrahn_kbelud
|
|
||||||
DB_USERNAME_28=spider
|
|
||||||
DB_PASSWORD_28=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_29=mysql
|
|
||||||
DB_HOST_29=192.168.0.103
|
|
||||||
DB_PORT_29=3306
|
|
||||||
DB_DATABASE_29=arrahn_keningau
|
|
||||||
DB_USERNAME_29=spider
|
|
||||||
DB_PASSWORD_29=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_30=mysql
|
|
||||||
DB_HOST_30=192.168.0.103
|
|
||||||
DB_PORT_30=3306
|
|
||||||
DB_DATABASE_30=arrahn_putatan
|
|
||||||
DB_USERNAME_30=spider
|
|
||||||
DB_PASSWORD_30=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_31=mysql
|
|
||||||
DB_HOST_31=192.168.0.103
|
|
||||||
DB_PORT_31=3306
|
|
||||||
DB_DATABASE_31=arrahn_sandakan
|
|
||||||
DB_USERNAME_31=spider
|
|
||||||
DB_PASSWORD_31=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_32=mysql
|
|
||||||
DB_HOST_32=192.168.0.103
|
|
||||||
DB_PORT_32=3306
|
|
||||||
DB_DATABASE_32=arrahn_tawau
|
|
||||||
DB_USERNAME_32=spider
|
|
||||||
DB_PASSWORD_32=G0dz!ll42020
|
|
||||||
|
|
||||||
DB_CONNECTION_33=mysql
|
|
||||||
DB_HOST_33=192.168.0.103
|
|
||||||
DB_PORT_33=3306
|
|
||||||
DB_DATABASE_33=arrahn_tuaran
|
|
||||||
DB_USERNAME_33=spider
|
|
||||||
DB_PASSWORD_33=G0dz!ll42020
|
|
||||||
|
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
QUEUE_CONNECTION=sync
|
QUEUE_CONNECTION=sync
|
||||||
|
|
||||||
WABOT_API=https://md.wabot.my/api/send.php
|
MAX_MUTUEMAS=true
|
||||||
WABOT_INSTANCES_ID=63F40BD120DB4
|
|
||||||
# WABOT_INSTANCES_ID=64892FD7440A6
|
|
||||||
WABOT_TOKEN_KEYS=cbee7e95cf3ffbfa0531d5fddfd44f87
|
|
||||||
|
|
||||||
|
TENNANT_MASTER_DB=master_erahn
|
||||||
|
TENNANT_KAUNTER_DB=kaunter_erahn
|
||||||
|
|
||||||
ONEWAYSMS_API=http://gateway.onewaysms.com.my:10001/api.aspx
|
KAUNTER_URL=http://host.docker.internal:8081
|
||||||
ONEWAYSMS_AUTH_USER=APIUK330HDAFO
|
INTERNAL_NOTIFICATION_SECRET=
|
||||||
ONEWAYSMS_AUTH_PASS=APIUK330HDAFOUK330
|
|
||||||
|
|
||||||
ADMIN_PHONE_NUMBER=60178916936
|
LOGVIEWER_PASSWORD=
|
||||||
ACTIVE_JOB_SERVER=false
|
|
||||||
|
WHATSAPP_TOKEN= # Paste token from Graph API explorer.
|
||||||
|
WHATSAPP_PHONE_NUMBER_ID=1323449077519027
|
||||||
|
WHATSAPP_API_VERSION=v25.0
|
||||||
|
WHATSAPP_TEMPLATE=hello_world
|
||||||
|
WHATSAPP_TEMPLATE_LANG=en_US
|
||||||
|
WHATSAPP_VERIFY_TOKEN= # webhook verify token
|
||||||
|
WHATSAPP_APP_SECRET= # X-Hub-Signature-256 checks; need to be enable first
|
||||||
|
ADMIN_PHONE_NUMBER=60193450165
|
||||||
|
|
||||||
|
BSAS_BASE_URL=https://bsasdevapi.bursamalaysia.com/api
|
||||||
|
BSAS_TOKEN_URL=https://bsasdevapi.bursamalaysia.com/oauth/token
|
||||||
|
BSAS_CLIENT_ID=
|
||||||
|
BSAS_CLIENT_SECRET=
|
||||||
|
BSAS_MEMBER_SHORT_NAME=KOOPPKB
|
||||||
|
BSAS_PRODUCT_CODE=CPO-MSIA-09
|
||||||
|
BSAS_TENOR=00088
|
||||||
|
BSAS_MAX_WAIT_TIME=10
|
||||||
|
BSAS_HTTP_TIMEOUT=30
|
||||||
|
BSAS_ORDER_RESULT_RETRIES=2
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
APP_NAME=Lumen
|
||||||
|
APP_ENV=production
|
||||||
|
APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa
|
||||||
|
APP_DEBUG=false
|
||||||
|
APP_URL=https://apiujrah.erahn.com.my
|
||||||
|
APP_TIMEZONE=Asia/Kuala_Lumpur
|
||||||
|
API_ARRAHNBID=https://adminbid-kopkb.erahn.com.my/api/
|
||||||
|
API_ARRAHNBID_ANNUR=https://adminbid-annur.erahn.com.my/api/
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_SLACK_WEBHOOK_URL=
|
||||||
|
LOGVIEWER_PASSWORD="$2y$10$k7eiUyZdm3BruwAaT1gbmelTm.PPgZptOEQT1nlBjyiR84a4KBMlm"
|
||||||
|
|
||||||
|
DB_CONNECTION_2=mysql
|
||||||
|
DB_HOST_2=192.168.1.216
|
||||||
|
DB_PORT_2=3306
|
||||||
|
DB_DATABASE_2=erahn_xtra
|
||||||
|
DB_USERNAME_2=spider
|
||||||
|
DB_PASSWORD_2=arrahn@123
|
||||||
|
|
||||||
|
DB_CONNECTION_3=mysql
|
||||||
|
DB_HOST_3=192.168.1.216
|
||||||
|
DB_PORT_3=3306
|
||||||
|
DB_DATABASE_3=erahn_baling
|
||||||
|
DB_USERNAME_3=spider
|
||||||
|
DB_PASSWORD_3=arrahn@123
|
||||||
|
|
||||||
|
DB_CONNECTION_4=mysql
|
||||||
|
DB_HOST_4=192.168.1.216
|
||||||
|
DB_PORT_4=3306
|
||||||
|
DB_DATABASE_4=arrahn_ld
|
||||||
|
DB_USERNAME_4=spider
|
||||||
|
DB_PASSWORD_4=arrahn@123
|
||||||
|
|
||||||
|
DB_CONNECTION_5=mysql
|
||||||
|
DB_HOST_5=192.168.1.216
|
||||||
|
DB_PORT_5=3306
|
||||||
|
DB_DATABASE_5=erahn_segamat
|
||||||
|
DB_USERNAME_5=spider
|
||||||
|
DB_PASSWORD_5=arrahn@123
|
||||||
|
|
||||||
|
DB_CONNECTION_6=mysql
|
||||||
|
DB_HOST_6=192.168.1.216
|
||||||
|
DB_PORT_6=3306
|
||||||
|
DB_DATABASE_6=erahn_terengganu
|
||||||
|
DB_USERNAME_6=spider
|
||||||
|
DB_PASSWORD_6=arrahn@123
|
||||||
|
|
||||||
|
DB_CONNECTION_8=mysql
|
||||||
|
DB_HOST_8=192.168.1.216
|
||||||
|
DB_PORT_8=3306
|
||||||
|
DB_DATABASE_8=erahn_benoni
|
||||||
|
DB_USERNAME_8=spider
|
||||||
|
DB_PASSWORD_8=arrahn@123
|
||||||
|
|
||||||
|
DB_CONNECTION_7=mysql
|
||||||
|
DB_HOST_7=192.168.1.216
|
||||||
|
DB_PORT_7=3306
|
||||||
|
DB_DATABASE_7=master_erahn
|
||||||
|
DB_USERNAME_7=spider
|
||||||
|
DB_PASSWORD_7=arrahn@123
|
||||||
|
|
||||||
|
DB_CONNECTION_9=mysql
|
||||||
|
DB_HOST_9=192.168.1.216
|
||||||
|
DB_PORT_9=3306
|
||||||
|
DB_DATABASE_9=annur_tampoi
|
||||||
|
DB_USERNAME_9=spider
|
||||||
|
DB_PASSWORD_9=arrahn@123
|
||||||
|
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
|
|
||||||
|
MAX_MUTUEMAS=true
|
||||||
|
|
||||||
|
TENNANT_MASTER_DB=master_erahn
|
||||||
|
TENNANT_KAUNTER_DB=kaunter_erahn
|
||||||
|
|
||||||
|
KAUNTER_URL=https://ujrah.erahn.com.my
|
||||||
|
INTERNAL_NOTIFICATION_SECRET="nIDTe(u@6[)VLJyd"
|
||||||
|
|
||||||
|
WHATSAPP_CLOUD_ENABLED=true
|
||||||
|
WHATSAPP_TOKEN=EAAZAonT56AO0BSnZAhWLi4UXDRT6iAldbiybxSQZAnGrzIke1QiNWvQkZAbQQTjWeVZC5bL1gEBhW6ff3Shf79nowXiTQEwyxqgZAZB6ZATwFCeTs8MZA5H6ZA76IJBuVqRiAZBvZCfkeSurbUNpEWyi9W7zsT2GWiZCLX8meX0KCfDHu7cp4aBgVu1Ps5ZCRO3bP4ZCQZDZD
|
||||||
|
WHATSAPP_PHONE_NUMBER_ID=1375899418935337
|
||||||
|
WHATSAPP_API_VERSION=v25.0
|
||||||
|
WHATSAPP_TEMPLATE=hebahan_pembiayaan_online
|
||||||
|
WHATSAPP_TEMPLATE_LANG=ms
|
||||||
|
WHATSAPP_VERIFY_TOKEN=418ed86d49422071681c76bed25ae1cb7e90456c794a92f1c9ea417945a35a0a
|
||||||
|
WHATSAPP_APP_SECRET=
|
||||||
|
ADMIN_PHONE_NUMBER=
|
||||||
+26
-10
@@ -4,15 +4,16 @@ APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa
|
|||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_URL=http://127.0.0.1:8090
|
APP_URL=http://127.0.0.1:8090
|
||||||
APP_TIMEZONE=Asia/Kuala_Lumpur
|
APP_TIMEZONE=Asia/Kuala_Lumpur
|
||||||
|
API_ARRAHNBID=http://lelong.test/api/
|
||||||
|
API_ARRAHNBID_ANNUR=http://lelong-annur.test/api/
|
||||||
|
|
||||||
# Unique host ports — change these if they collide with other containers on the server.
|
|
||||||
# Host nginx should proxy the staging domain to 127.0.0.1:${HTTP_PORT}
|
|
||||||
HTTP_PORT=8090
|
HTTP_PORT=8090
|
||||||
MYSQL_PUBLISH_PORT=3308
|
MYSQL_PUBLISH_PORT=3308
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
LOG_CHANNEL=stack
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
LOG_SLACK_WEBHOOK_URL=
|
LOG_SLACK_WEBHOOK_URL=
|
||||||
|
LOGVIEWER_PASSWORD=test123
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=mysql
|
DB_HOST=mysql
|
||||||
@@ -70,15 +71,30 @@ DB_DATABASE_6=erahn_test
|
|||||||
DB_USERNAME_6=root
|
DB_USERNAME_6=root
|
||||||
DB_PASSWORD_6=root
|
DB_PASSWORD_6=root
|
||||||
|
|
||||||
# DB_CONNECTION_8=mysql
|
DB_CONNECTION_9=mysql
|
||||||
# DB_HOST_8=mysql
|
DB_HOST_9=mysql
|
||||||
# DB_PORT_8=3306
|
DB_PORT_9=3306
|
||||||
# DB_DATABASE_8=arrahn_klanas
|
DB_DATABASE_9=annur_tampoi
|
||||||
# DB_USERNAME_8=spider
|
DB_USERNAME_9=root
|
||||||
# DB_PASSWORD_8=G0dz!ll42020
|
DB_PASSWORD_9=root
|
||||||
|
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
|
|
||||||
|
MAX_MUTUEMAS=true
|
||||||
|
|
||||||
TENNANT_MASTER_DB=master_erahn
|
TENNANT_MASTER_DB=master_erahn
|
||||||
TENNANT_KAUNTER_DB=kaunter_erahn
|
TENNANT_KAUNTER_DB=kaunter_erahn
|
||||||
|
|
||||||
CACHE_DRIVER=file
|
KAUNTER_URL=https://staging.erahn.com.my/login
|
||||||
QUEUE_CONNECTION=sync
|
INTERNAL_NOTIFICATION_SECRET=staging_noti_secret
|
||||||
|
|
||||||
|
WHATSAPP_CLOUD_ENABLED=false
|
||||||
|
WHATSAPP_TOKEN=EAAZAonT56AO0BSnZAhWLi4UXDRT6iAldbiybxSQZAnGrzIke1QiNWvQkZAbQQTjWeVZC5bL1gEBhW6ff3Shf79nowXiTQEwyxqgZAZB6ZATwFCeTs8MZA5H6ZA76IJBuVqRiAZBvZCfkeSurbUNpEWyi9W7zsT2GWiZCLX8meX0KCfDHu7cp4aBgVu1Ps5ZCRO3bP4ZCQZDZD
|
||||||
|
WHATSAPP_PHONE_NUMBER_ID=1375899418935337
|
||||||
|
WHATSAPP_API_VERSION=v25.0
|
||||||
|
WHATSAPP_TEMPLATE=hebahan_pembiayaan_online
|
||||||
|
WHATSAPP_TEMPLATE_LANG=ms
|
||||||
|
WHATSAPP_VERIFY_TOKEN=418ed86d49422071681c76bed25ae1cb7e90456c794a92f1c9ea417945a35a0a
|
||||||
|
WHATSAPP_APP_SECRET=
|
||||||
|
ADMIN_PHONE_NUMBER=
|
||||||
-244
@@ -1,244 +0,0 @@
|
|||||||
APP_NAME=Lumen
|
|
||||||
APP_ENV=local
|
|
||||||
APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa
|
|
||||||
APP_DEBUG=false
|
|
||||||
APP_URL=https://api.arrahn.com.my
|
|
||||||
APP_TIMEZONE=Asia/Kuala_Lumpur
|
|
||||||
|
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
|
||||||
LOG_SLACK_WEBHOOK_URL=
|
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
|
||||||
DB_HOST=172.16.4.102
|
|
||||||
DB_PORT=3306
|
|
||||||
DB_DATABASE=arrahn_kb2
|
|
||||||
DB_USERNAME=zone2
|
|
||||||
DB_PASSWORD=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_2=mysql
|
|
||||||
DB_HOST_2=172.16.4.102
|
|
||||||
DB_PORT_2=3306
|
|
||||||
DB_DATABASE_2=arrahn_wcy
|
|
||||||
DB_USERNAME_2=zone2
|
|
||||||
DB_PASSWORD_2=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_3=mysql
|
|
||||||
DB_HOST_3=172.16.4.102
|
|
||||||
DB_PORT_3=3306
|
|
||||||
DB_DATABASE_3=arrahn_1stop
|
|
||||||
DB_USERNAME_3=zone2
|
|
||||||
DB_PASSWORD_3=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_4=mysql
|
|
||||||
DB_HOST_4=172.16.4.102
|
|
||||||
DB_PORT_4=3306
|
|
||||||
DB_DATABASE_4=arrahn_jlwt
|
|
||||||
DB_USERNAME_4=zone2
|
|
||||||
DB_PASSWORD_4=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_5=mysql
|
|
||||||
DB_HOST_5=172.16.4.102
|
|
||||||
DB_PORT_5=3306
|
|
||||||
DB_DATABASE_5=arrahn_wb
|
|
||||||
DB_USERNAME_5=zone2
|
|
||||||
DB_PASSWORD_5=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_6=mysql
|
|
||||||
DB_HOST_6=172.16.4.102
|
|
||||||
DB_PORT_6=3306
|
|
||||||
DB_DATABASE_6=arrahn_kls
|
|
||||||
DB_USERNAME_6=zone2
|
|
||||||
DB_PASSWORD_6=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_7=mysql
|
|
||||||
DB_HOST_7=172.16.4.102
|
|
||||||
DB_PORT_7=3306
|
|
||||||
DB_DATABASE_7=online_arrahn
|
|
||||||
DB_USERNAME_7=zone2
|
|
||||||
DB_PASSWORD_7=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_8=mysql
|
|
||||||
DB_HOST_8=172.16.4.102
|
|
||||||
DB_PORT_8=3306
|
|
||||||
DB_DATABASE_8=arrahn_pp
|
|
||||||
DB_USERNAME_8=zone2
|
|
||||||
DB_PASSWORD_8=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_9=mysql
|
|
||||||
DB_HOST_9=172.16.4.102
|
|
||||||
DB_PORT_9=3306
|
|
||||||
DB_DATABASE_9=arrahn_mace
|
|
||||||
DB_USERNAME_9=zone2
|
|
||||||
DB_PASSWORD_9=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_10=mysql
|
|
||||||
DB_HOST_10=172.16.4.102
|
|
||||||
DB_PORT_10=3306
|
|
||||||
DB_DATABASE_10=arrahn_pm
|
|
||||||
DB_USERNAME_10=zone2
|
|
||||||
DB_PASSWORD_10=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_11=mysql
|
|
||||||
DB_HOST_11=172.16.4.102
|
|
||||||
DB_PORT_11=3306
|
|
||||||
DB_DATABASE_11=arrahn_gm
|
|
||||||
DB_USERNAME_11=zone2
|
|
||||||
DB_PASSWORD_11=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_12=mysql
|
|
||||||
DB_HOST_12172.16.4.102
|
|
||||||
DB_PORT_12=3306
|
|
||||||
DB_DATABASE_12=arrahn_gcl
|
|
||||||
DB_USERNAME_12=zone2
|
|
||||||
DB_PASSWORD_12=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_13=mysql
|
|
||||||
DB_HOST_13=172.16.4.102
|
|
||||||
DB_PORT_13=3306
|
|
||||||
DB_DATABASE_13=arrahn_jli
|
|
||||||
DB_USERNAME_13=zone2
|
|
||||||
DB_PASSWORD_13=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_14=mysql
|
|
||||||
DB_HOST_14=172.16.4.102
|
|
||||||
DB_PORT_14=3306
|
|
||||||
DB_DATABASE_14=arrahn_rp
|
|
||||||
DB_USERNAME_14=zone2
|
|
||||||
DB_PASSWORD_14=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_15=mysql
|
|
||||||
DB_HOST_15=172.16.4.102
|
|
||||||
DB_PORT_15=3306
|
|
||||||
DB_DATABASE_15=arrahn_ktn
|
|
||||||
DB_USERNAME_15=zone2
|
|
||||||
DB_PASSWORD_15=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_16=mysql
|
|
||||||
DB_HOST_16=172.16.4.102
|
|
||||||
DB_PORT_16=3306
|
|
||||||
DB_DATABASE_16=arrahn_pg
|
|
||||||
DB_USERNAME_16=zone2
|
|
||||||
DB_PASSWORD_16=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_17=mysql
|
|
||||||
DB_HOST_17=172.16.4.102
|
|
||||||
DB_PORT_17=3306
|
|
||||||
DB_DATABASE_17=arrahn_skudai
|
|
||||||
DB_USERNAME_17=zone2
|
|
||||||
DB_PASSWORD_17=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_18=mysql
|
|
||||||
DB_HOST_18=172.16.4.102
|
|
||||||
DB_PORT_18=3306
|
|
||||||
DB_DATABASE_18=arrahn_pttn
|
|
||||||
DB_USERNAME_18=zone2
|
|
||||||
DB_PASSWORD_18=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_19=mysql
|
|
||||||
DB_HOST_19=172.16.4.102
|
|
||||||
DB_PORT_19=3306
|
|
||||||
DB_DATABASE_19=arrahn_btg
|
|
||||||
DB_USERNAME_19=zone2
|
|
||||||
DB_PASSWORD_19=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_20=mysql
|
|
||||||
DB_HOST_20=172.16.4.102
|
|
||||||
DB_PORT_20=3306
|
|
||||||
DB_DATABASE_20=arrahn_raub
|
|
||||||
DB_USERNAME_20=zone2
|
|
||||||
DB_PASSWORD_20=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_21=mysql
|
|
||||||
DB_HOST_21=172.16.4.102
|
|
||||||
DB_PORT_21=3306
|
|
||||||
DB_DATABASE_21=arrahn_kgr
|
|
||||||
DB_USERNAME_21=zone2
|
|
||||||
DB_PASSWORD_21=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_22=mysql
|
|
||||||
DB_HOST_22=172.16.4.102
|
|
||||||
DB_PORT_22=3306
|
|
||||||
DB_DATABASE_22=arrahn_sdk
|
|
||||||
DB_USERNAME_22=zone2
|
|
||||||
DB_PASSWORD_22=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_23=mysql
|
|
||||||
DB_HOST_23=172.16.4.102
|
|
||||||
DB_PORT_23=3306
|
|
||||||
DB_DATABASE_23=arrahn_sp
|
|
||||||
DB_USERNAME_23=zone2
|
|
||||||
DB_PASSWORD_23=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_24=mysql
|
|
||||||
DB_HOST_24=172.16.4.102
|
|
||||||
DB_PORT_24=3306
|
|
||||||
DB_DATABASE_24=arrahn_twu
|
|
||||||
DB_USERNAME_24=zone2
|
|
||||||
DB_PASSWORD_24=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_25=mysql
|
|
||||||
DB_HOST_25=172.16.4.102
|
|
||||||
DB_PORT_25=3306
|
|
||||||
DB_DATABASE_25=arrahn_api2
|
|
||||||
DB_USERNAME_25=zone2
|
|
||||||
DB_PASSWORD_25=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_26=mysql
|
|
||||||
DB_HOST_26=172.16.4.102
|
|
||||||
DB_PORT_26=3306
|
|
||||||
DB_DATABASE_26=arrahn_kjg
|
|
||||||
DB_USERNAME_26=zone2
|
|
||||||
DB_PASSWORD_26=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_27=mysql
|
|
||||||
DB_HOST_27=172.16.4.102
|
|
||||||
DB_PORT_27=3306
|
|
||||||
DB_DATABASE_27=arrahn_rl
|
|
||||||
DB_USERNAME_27=zone2
|
|
||||||
DB_PASSWORD_27=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_28=mysql
|
|
||||||
DB_HOST_28=172.16.4.102
|
|
||||||
DB_PORT_28=3306
|
|
||||||
DB_DATABASE_28=arrahn_bfort
|
|
||||||
DB_USERNAME_28=zone2
|
|
||||||
DB_PASSWORD_28=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_29=mysql
|
|
||||||
DB_HOST_29=172.16.4.102
|
|
||||||
DB_PORT_29=3306
|
|
||||||
DB_DATABASE_29=arrahn_kbelud
|
|
||||||
DB_USERNAME_29=zone2
|
|
||||||
DB_PASSWORD_29=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_30=mysql
|
|
||||||
DB_HOST_30=172.16.4.102
|
|
||||||
DB_PORT_30=3306
|
|
||||||
DB_DATABASE_30=arrahn_tuaran
|
|
||||||
DB_USERNAME_30=zone2
|
|
||||||
DB_PASSWORD_30=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_31=mysql
|
|
||||||
DB_HOST_31=172.16.4.102
|
|
||||||
DB_PORT_31=3306
|
|
||||||
DB_DATABASE_31=arrahn_kngau
|
|
||||||
DB_USERNAME_31=zone2
|
|
||||||
DB_PASSWORD_31=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_32=mysql
|
|
||||||
DB_HOST_32=172.16.4.102
|
|
||||||
DB_PORT_32=3306
|
|
||||||
DB_DATABASE_32=arrahn_tm
|
|
||||||
DB_USERNAME_32=zone2
|
|
||||||
DB_PASSWORD_32=G0dz!ll4@2020
|
|
||||||
|
|
||||||
DB_CONNECTION_33=mysql
|
|
||||||
DB_HOST_33=172.16.4.102
|
|
||||||
DB_PORT_33=3306
|
|
||||||
DB_DATABASE_33=arrahn_tmlh
|
|
||||||
DB_USERNAME_33=zone2
|
|
||||||
DB_PASSWORD_33=G0dz!ll4@2020
|
|
||||||
|
|
||||||
CACHE_DRIVER=file
|
|
||||||
QUEUE_CONNECTION=sync
|
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
name: Deploy to Staging
|
name: Deploy to Staging
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
image_tag:
|
image_tag:
|
||||||
@@ -18,10 +21,22 @@ jobs:
|
|||||||
runs-on: host
|
runs-on: host
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Resolve image tag
|
||||||
|
id: resolve
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
if [ "${{ gitea.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
IMAGE_TAG="${{ inputs.image_tag }}"
|
||||||
|
else
|
||||||
|
IMAGE_TAG="${{ gitea.ref_name }}"
|
||||||
|
fi
|
||||||
|
echo "IMAGE_TAG=${IMAGE_TAG}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Deploying image tag: ${IMAGE_TAG}"
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ inputs.image_tag }}
|
ref: ${{ steps.resolve.outputs.IMAGE_TAG }}
|
||||||
|
|
||||||
- name: Login to Docker registry
|
- name: Login to Docker registry
|
||||||
run: |
|
run: |
|
||||||
@@ -33,43 +48,47 @@ jobs:
|
|||||||
- name: Verify image exists in registry
|
- name: Verify image exists in registry
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
IMAGE_TAG="${{ inputs.image_tag }}"
|
IMAGE_TAG="${{ steps.resolve.outputs.IMAGE_TAG }}"
|
||||||
IMAGE="${APP_IMAGE}:${IMAGE_TAG}"
|
IMAGE="${APP_IMAGE}:${IMAGE_TAG}"
|
||||||
|
|
||||||
echo "Checking if image exists: ${IMAGE}"
|
echo "Checking if image exists: ${IMAGE}"
|
||||||
if ! docker manifest inspect "${IMAGE}" > /dev/null 2>&1; then
|
# Tag pushes build in parallel — wait for the image to appear
|
||||||
echo "ERROR: Image ${IMAGE} does not exist in registry!"
|
for i in $(seq 1 30); do
|
||||||
echo "Run the Build Docker Image workflow first."
|
if docker manifest inspect "${IMAGE}" > /dev/null 2>&1; then
|
||||||
exit 1
|
echo "✓ ${IMAGE} found"
|
||||||
fi
|
exit 0
|
||||||
echo "✓ ${IMAGE} found"
|
fi
|
||||||
|
echo "Image not ready yet (attempt ${i}/30), waiting 20s..."
|
||||||
|
sleep 20
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "ERROR: Image ${IMAGE} does not exist in registry after waiting!"
|
||||||
|
echo "Run the Build Docker Image workflow first."
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Pull Docker image
|
- name: Pull Docker image
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
IMAGE_TAG="${{ inputs.image_tag }}"
|
IMAGE_TAG="${{ steps.resolve.outputs.IMAGE_TAG }}"
|
||||||
docker pull "${APP_IMAGE}:${IMAGE_TAG}"
|
docker pull "${APP_IMAGE}:${IMAGE_TAG}"
|
||||||
echo "✓ Image pulled successfully"
|
echo "✓ Image pulled successfully"
|
||||||
|
|
||||||
- name: Sync compose file and deploy
|
- name: Sync compose file and deploy
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
IMAGE_TAG="${{ inputs.image_tag }}"
|
IMAGE_TAG="${{ steps.resolve.outputs.IMAGE_TAG }}"
|
||||||
|
|
||||||
mkdir -p "${DEPLOY_DIR}/docker/nginx" "${DEPLOY_DIR}/docker/mysql"
|
mkdir -p "${DEPLOY_DIR}/docker/nginx" "${DEPLOY_DIR}/docker/mysql"
|
||||||
cp docker-compose.staging.yml "${DEPLOY_DIR}/docker-compose.yml"
|
cp docker-compose.staging.yml "${DEPLOY_DIR}/docker-compose.yml"
|
||||||
cp docker/nginx/default.conf "${DEPLOY_DIR}/docker/nginx/default.conf"
|
cp docker/nginx/default.conf "${DEPLOY_DIR}/docker/nginx/default.conf"
|
||||||
cp -R docker/mysql/init "${DEPLOY_DIR}/docker/mysql/"
|
cp -R docker/mysql/init "${DEPLOY_DIR}/docker/mysql/"
|
||||||
|
|
||||||
if [ ! -f "${DEPLOY_DIR}/.env.staging" ]; then
|
if [ ! -f .env.staging ]; then
|
||||||
if [ -f .env.staging ]; then
|
echo "ERROR: .env.staging is missing in the repository"
|
||||||
cp .env.staging "${DEPLOY_DIR}/.env.staging"
|
exit 1
|
||||||
echo "Copied .env.staging from repo (first deploy). Edit ${DEPLOY_DIR}/.env.staging on the server if needed."
|
|
||||||
else
|
|
||||||
echo "ERROR: ${DEPLOY_DIR}/.env.staging is missing on the server"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
cp .env.staging "${DEPLOY_DIR}/.env.staging"
|
||||||
|
echo "✓ Synced .env.staging from repo"
|
||||||
|
|
||||||
cd "${DEPLOY_DIR}"
|
cd "${DEPLOY_DIR}"
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ Tebus=penyelesaian penuh/ansuran
|
|||||||
docker exec -i api_arrahn_staging_mysql mysql -uroot -proot erahn_test < erahn_test.sql
|
docker exec -i api_arrahn_staging_mysql mysql -uroot -proot erahn_test < erahn_test.sql
|
||||||
```
|
```
|
||||||
|
|
||||||
## Disable the cawangan in arrahn_master_db
|
## Disable the cawangan in arrahn_master_db using feature flag
|
||||||
|
|
||||||
## Feature Flag
|
## Feature Flag
|
||||||
1. Register the flag in api_arrahn/app/Feature.php
|
1. Register the flag in api_arrahn/app/Feature.php
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class BsasOrder extends Model
|
||||||
|
{
|
||||||
|
protected $connection = 'mysql7';
|
||||||
|
protected $table = 'bsas_orders';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'uuid',
|
||||||
|
'norujukan',
|
||||||
|
'kodcaw',
|
||||||
|
'serial_number',
|
||||||
|
'product_code',
|
||||||
|
'bid_value',
|
||||||
|
'otc_murabaha_value',
|
||||||
|
'otc_counter_party',
|
||||||
|
'status',
|
||||||
|
'status_code',
|
||||||
|
'status_message',
|
||||||
|
'e_cert_no',
|
||||||
|
'bid_ecert_response',
|
||||||
|
'otc_ecert_response',
|
||||||
|
'stb_ecert_response',
|
||||||
|
'request_payload',
|
||||||
|
'order_response',
|
||||||
|
'result_response',
|
||||||
|
'created_by',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'bid_value' => 'decimal:2',
|
||||||
|
'otc_murabaha_value' => 'decimal:2',
|
||||||
|
'request_payload' => 'array',
|
||||||
|
'order_response' => 'array',
|
||||||
|
'result_response' => 'array',
|
||||||
|
'bid_ecert_response' => 'array',
|
||||||
|
'otc_ecert_response' => 'array',
|
||||||
|
'stb_ecert_response' => 'array',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Services\Whatsapp\WhatsappCloudClient;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class WhatsappTestSend extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'whatsapp:test {--to= : Recipient MSISDN, default ADMIN_PHONE_NUMBER}';
|
||||||
|
|
||||||
|
protected $description = 'Send the configured WhatsApp Cloud template to a test number';
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$client = new WhatsappCloudClient();
|
||||||
|
|
||||||
|
if (!$client->isConfigured()) {
|
||||||
|
$this->error('Set WHATSAPP_TOKEN and WHATSAPP_PHONE_NUMBER_ID in .env first.');
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$to = $client->normalizeMsisdn($this->option('to') ?: env('ADMIN_PHONE_NUMBER'));
|
||||||
|
if (!$to) {
|
||||||
|
$this->error('Pass --to=60193450165 or set ADMIN_PHONE_NUMBER.');
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$template = config('whatsapp.template', 'hello_world');
|
||||||
|
$lang = config('whatsapp.template_lang', 'en_US');
|
||||||
|
$bodyParams = [];
|
||||||
|
|
||||||
|
if (strtolower($template) !== 'hello_world') {
|
||||||
|
// pembiayaan_online_paid: SAG, amaun, bank, 4 digit akhir, tarikh, rujukan
|
||||||
|
$bodyParams = [
|
||||||
|
'TEST-SAG',
|
||||||
|
'100.00',
|
||||||
|
'Maybank',
|
||||||
|
'1234',
|
||||||
|
date('d/m/Y'),
|
||||||
|
'TEST-REF',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info("Sending {$template} ({$lang}) to {$to} …");
|
||||||
|
$response = $client->sendTemplate($to, $template, $lang, $bodyParams);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
$this->info('OK ' . $response->status() . ' ' . $response->body());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->error('FAIL ' . $response->status() . ' ' . $response->body());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ class Kernel extends ConsoleKernel
|
|||||||
Commands\ClearCachesAll::class,
|
Commands\ClearCachesAll::class,
|
||||||
Commands\RestartSupervisor::class,
|
Commands\RestartSupervisor::class,
|
||||||
Commands\InsertSempornaData::class,
|
Commands\InsertSempornaData::class,
|
||||||
|
Commands\WhatsappTestSend::class,
|
||||||
//Commands\ImportCsv::class,
|
//Commands\ImportCsv::class,
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App;
|
|||||||
class Feature
|
class Feature
|
||||||
{
|
{
|
||||||
const PEMBIAYAAN_ONLINE = 'pembiayaan_online';
|
const PEMBIAYAAN_ONLINE = 'pembiayaan_online';
|
||||||
|
const REBET_ANNUR = 'rebet_annur';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Known flag keys. New features: add a constant here, then INSERT rows for pilot kodcaw.
|
* Known flag keys. New features: add a constant here, then INSERT rows for pilot kodcaw.
|
||||||
@@ -15,6 +16,7 @@ class Feature
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
self::PEMBIAYAAN_ONLINE,
|
self::PEMBIAYAAN_ONLINE,
|
||||||
|
self::REBET_ANNUR,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,9 +42,32 @@ class Feature
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
self::PEMBIAYAAN_ONLINE => 'Pembiayaan Online',
|
self::PEMBIAYAAN_ONLINE => 'Pembiayaan Online',
|
||||||
|
self::REBET_ANNUR => 'Rebet / diskaun Annur',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lelong portal base URL for this branch. rebet_annur branches (Annur/Tampoi)
|
||||||
|
* use API_ARRAHNBID_ANNUR; everyone else uses API_ARRAHNBID.
|
||||||
|
*
|
||||||
|
* Always returned with a trailing slash so callers can append 'portalApi'.
|
||||||
|
*
|
||||||
|
* @param string $kodcaw
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function arrahnbidUrl($kodcaw)
|
||||||
|
{
|
||||||
|
$url = config('app_parameter.api_arrahnbid');
|
||||||
|
if ($kodcaw && self::enabled($kodcaw, self::REBET_ANNUR)) {
|
||||||
|
$annur = config('app_parameter.api_arrahnbid_annur');
|
||||||
|
if ($annur) {
|
||||||
|
$url = $annur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rtrim((string) $url, '/') . '/';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Missing row is off (fail closed).
|
* Missing row is off (fail closed).
|
||||||
*
|
*
|
||||||
|
|||||||
+7
-1
@@ -9,6 +9,10 @@ class Gadai extends Model
|
|||||||
protected $table = 'gadai';
|
protected $table = 'gadai';
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
protected $attributes = [
|
||||||
|
'cara_terima' => 'TUNAI',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*
|
*
|
||||||
@@ -74,7 +78,9 @@ class Gadai extends Model
|
|||||||
'tagkomuditi',
|
'tagkomuditi',
|
||||||
'tempohbayar',
|
'tempohbayar',
|
||||||
'lelong_tawarruq',
|
'lelong_tawarruq',
|
||||||
'tag_tebus'
|
'tag_tebus',
|
||||||
|
'kadarrebet',
|
||||||
|
'diskaun'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class BarangkesController extends Controller
|
|||||||
$itemArray['gadaian_sudah_tebus'] = !is_null($item['tebus']);
|
$itemArray['gadaian_sudah_tebus'] = !is_null($item['tebus']);
|
||||||
|
|
||||||
// Add nokp customer from gadai relationship
|
// Add nokp customer from gadai relationship
|
||||||
$itemArray['nokp'] = $item['gadai']['nokp'];
|
$itemArray['nokp'] = $item['gadai']['nokp'] ?? null;
|
||||||
|
|
||||||
// Remove the tebus relationship data to keep response clean
|
// Remove the tebus relationship data to keep response clean
|
||||||
unset($itemArray['tebus']);
|
unset($itemArray['tebus']);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class CawanganController extends Controller
|
|||||||
|
|
||||||
$data = $cawangan->toArray();
|
$data = $cawangan->toArray();
|
||||||
$data['features'] = Feature::mapFor($code_cawangan);
|
$data['features'] = Feature::mapFor($code_cawangan);
|
||||||
|
$data['api_arrahnbid'] = Feature::arrahnbidUrl($code_cawangan);
|
||||||
|
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,6 @@ class GadaiController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function create($kodcaw,Request $request){
|
public function create($kodcaw,Request $request){
|
||||||
|
|
||||||
$master = new MasterServices($kodcaw);
|
$master = new MasterServices($kodcaw);
|
||||||
$response = $master->createGadai($request);
|
$response = $master->createGadai($request);
|
||||||
|
|
||||||
@@ -228,11 +227,14 @@ class GadaiController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function daftarGadaiMarhun($norujukan,Request $request){
|
public function daftarGadaiMarhun($kodcaw, $norujukan, Request $request)
|
||||||
// dd("ggwp");
|
{
|
||||||
$master = new MasterServices($request->kodcaw);
|
if (\App\ShorakaTransaction::where('norujukan', $norujukan)->exists()) {
|
||||||
$response = $master->createMarhunGadai($request->norujukan,$request);
|
abort(409, 'Kontrak telah dihantar ke Shoraka dan tidak boleh diubah.');
|
||||||
|
}
|
||||||
|
$request->merge(['kodcaw' => $kodcaw, 'norujukan' => $norujukan]);
|
||||||
|
$master = new MasterServices($kodcaw);
|
||||||
|
$response = $master->createMarhunGadai($norujukan, $request);
|
||||||
return response()->json($response, 200);
|
return response()->json($response, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,6 +371,9 @@ class GadaiController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function batalGadai($kodcaw, $norujukan,Request $request){
|
public function batalGadai($kodcaw, $norujukan,Request $request){
|
||||||
|
if (\App\ShorakaTransaction::where('norujukan', $norujukan)->exists()) {
|
||||||
|
abort(409, 'Transaksi Shoraka telah dihantar. Semakan operasi diperlukan sebelum pembatalan.');
|
||||||
|
}
|
||||||
|
|
||||||
$current = Carbon::now();
|
$current = Carbon::now();
|
||||||
$current = new Carbon();
|
$current = new Carbon();
|
||||||
@@ -406,6 +411,11 @@ class GadaiController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function pembelianKomuditi($kodcaw,$norujukan){
|
public function pembelianKomuditi($kodcaw,$norujukan){
|
||||||
|
if (\App\ShorakaTransaction::where('norujukan', $norujukan)->exists()
|
||||||
|
|| !\App\KomuditiTransaksi::on('mysql7')->where('norujukan', $norujukan)->exists()) {
|
||||||
|
app(\App\Services\ShorakaGadaiService::class)->assertCompleted($kodcaw, $norujukan);
|
||||||
|
}
|
||||||
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
$gadai = Gadai::on($cawangan['mysql'])
|
$gadai = Gadai::on($cawangan['mysql'])
|
||||||
@@ -418,6 +428,10 @@ class GadaiController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function cetakSAG($kodcaw,$norujukan,Request $request){
|
public function cetakSAG($kodcaw,$norujukan,Request $request){
|
||||||
|
if (\App\ShorakaTransaction::where('norujukan', $norujukan)->exists()) {
|
||||||
|
app(\App\Services\ShorakaGadaiService::class)->assertCompleted($kodcaw, $norujukan);
|
||||||
|
}
|
||||||
|
|
||||||
$harini = Carbon::now();
|
$harini = Carbon::now();
|
||||||
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
@@ -442,6 +456,10 @@ class GadaiController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function serahMarhun($kodcaw,$norujukan){
|
public function serahMarhun($kodcaw,$norujukan){
|
||||||
|
if (\App\ShorakaTransaction::where('norujukan', $norujukan)->exists()) {
|
||||||
|
app(\App\Services\ShorakaGadaiService::class)->assertCompleted($kodcaw, $norujukan);
|
||||||
|
}
|
||||||
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
$gadai = Gadai::on($cawangan['mysql'])
|
$gadai = Gadai::on($cawangan['mysql'])
|
||||||
->where('norujukan','=',$norujukan)
|
->where('norujukan','=',$norujukan)
|
||||||
@@ -537,7 +555,7 @@ class GadaiController extends Controller
|
|||||||
|
|
||||||
public function getLaporanGadai($kodcaw,$tarikh){
|
public function getLaporanGadai($kodcaw,$tarikh){
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
$gadai_data = Gadai::on($cawangan['mysql'])->select('t_gadai','norujukan','nokp','semakbarcode','masa','berat','nilaimarhun','pinjaman','upah12','percentpinj','teller','nokp','ujrah','onepercent')
|
$gadai_data = Gadai::on($cawangan['mysql'])->select('cara_terima','t_gadai','norujukan','nokp','semakbarcode','masa','berat','nilaimarhun','pinjaman','upah12','percentpinj','teller','nokp','ujrah','onepercent','kadarrebet','diskaun')
|
||||||
->where('t_gadai','=',$tarikh)
|
->where('t_gadai','=',$tarikh)
|
||||||
->orderBy('teller')
|
->orderBy('teller')
|
||||||
->orderBy('sirig')
|
->orderBy('sirig')
|
||||||
@@ -551,6 +569,7 @@ class GadaiController extends Controller
|
|||||||
array_push($gadai,[
|
array_push($gadai,[
|
||||||
"t_gadai"=> $gadaiData['t_gadai'],
|
"t_gadai"=> $gadaiData['t_gadai'],
|
||||||
"norujukan"=> $gadaiData['norujukan'],
|
"norujukan"=> $gadaiData['norujukan'],
|
||||||
|
"cara_terima"=> $gadaiData['cara_terima'],
|
||||||
"nama"=> $customer_info['nama'],
|
"nama"=> $customer_info['nama'],
|
||||||
"nokp"=> $gadaiData['nokp'],
|
"nokp"=> $gadaiData['nokp'],
|
||||||
"semakbarcode"=> $gadaiData['semakbarcode'],
|
"semakbarcode"=> $gadaiData['semakbarcode'],
|
||||||
@@ -563,7 +582,9 @@ class GadaiController extends Controller
|
|||||||
"alamat1"=> $customer_info['alamat1'],
|
"alamat1"=> $customer_info['alamat1'],
|
||||||
"teller"=> $gadaiData['teller'],
|
"teller"=> $gadaiData['teller'],
|
||||||
"onepercent"=> $gadaiData['onepercent'],
|
"onepercent"=> $gadaiData['onepercent'],
|
||||||
"ujrah"=> $gadaiData['ujrah']
|
"ujrah"=> $gadaiData['ujrah'],
|
||||||
|
"kadarrebet"=> $gadaiData['kadarrebet'],
|
||||||
|
"diskaun"=> $gadaiData['diskaun']
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -626,7 +647,7 @@ class GadaiController extends Controller
|
|||||||
"alamat1" => optional($customer)->alamat1,
|
"alamat1" => optional($customer)->alamat1,
|
||||||
"t_gadai" => $g->t_gadai,
|
"t_gadai" => $g->t_gadai,
|
||||||
"norujukan" => $g->norujukan,
|
"norujukan" => $g->norujukan,
|
||||||
"norujukan"=> $g->norujukan,
|
"cara_terima" => strtoupper((string) ($g->cara_terima ?: 'TUNAI')),
|
||||||
|
|
||||||
"nokp"=> $g->nokp,
|
"nokp"=> $g->nokp,
|
||||||
"semakbarcode"=> $g->semakbarcode,
|
"semakbarcode"=> $g->semakbarcode,
|
||||||
@@ -640,6 +661,8 @@ class GadaiController extends Controller
|
|||||||
"teller"=> $g->teller,
|
"teller"=> $g->teller,
|
||||||
"ujrah"=> $g->ujrah,
|
"ujrah"=> $g->ujrah,
|
||||||
"onepercent"=> $g->onepercent,
|
"onepercent"=> $g->onepercent,
|
||||||
|
"kadarrebet"=> $g->kadarrebet,
|
||||||
|
"diskaun"=> $g->diskaun,
|
||||||
"tagbaru"=> $g->tagbaru,
|
"tagbaru"=> $g->tagbaru,
|
||||||
"kodkerja"=> optional($customer)->kodkerja,
|
"kodkerja"=> optional($customer)->kodkerja,
|
||||||
"bangsa"=> optional($customer)->bangsa,
|
"bangsa"=> optional($customer)->bangsa,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Cawangan;
|
|||||||
use App\Mohonid;
|
use App\Mohonid;
|
||||||
use App\MohonAnggota;
|
use App\MohonAnggota;
|
||||||
use App\Customer;
|
use App\Customer;
|
||||||
|
use App\Services\StaffNotificationClient;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
@@ -444,6 +445,8 @@ public function create(REQUEST $request,$kodcaw,$norujukan,$roles)
|
|||||||
$audit->updated_at = $harini;
|
$audit->updated_at = $harini;
|
||||||
$audit->save();
|
$audit->save();
|
||||||
|
|
||||||
|
$this->notifyOperasiAssignAnggota($kodcaw, $cawangan, $kelulusan, $request);
|
||||||
|
|
||||||
// ✅ Return JSON response ke frontend
|
// ✅ Return JSON response ke frontend
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
@@ -466,6 +469,58 @@ public function create(REQUEST $request,$kodcaw,$norujukan,$roles)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inbox for all operasi staff. Failures must not block the teller request.
|
||||||
|
*
|
||||||
|
* @param string $kodcaw
|
||||||
|
* @param \App\Cawangan $cawangan
|
||||||
|
* @param \App\MohonAnggota $kelulusan
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function notifyOperasiAssignAnggota($kodcaw, $cawangan, $kelulusan, Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$nama = trim((string) ($request->nama ?? ''));
|
||||||
|
if ($nama === '' && !empty($kelulusan->nokp)) {
|
||||||
|
$customer = Customer::on('mysql7')
|
||||||
|
->where('kpbaru', $kelulusan->nokp)
|
||||||
|
->orWhere('kplama', $kelulusan->nokp)
|
||||||
|
->first();
|
||||||
|
if ($customer && !empty($customer->nama)) {
|
||||||
|
$nama = trim((string) $customer->nama);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$namaCaw = $kodcaw;
|
||||||
|
if ($cawangan) {
|
||||||
|
$resolved = trim((string) $cawangan->nama_cawangan);
|
||||||
|
if ($resolved !== '') {
|
||||||
|
$namaCaw = $resolved;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app(StaffNotificationClient::class)->notify([
|
||||||
|
'type' => 'anggota.pending_operasi',
|
||||||
|
'cawangan' => $kodcaw,
|
||||||
|
'audience' => ['role' => 'operasi'],
|
||||||
|
'data' => [
|
||||||
|
'id' => $kelulusan->id,
|
||||||
|
'nokp' => $kelulusan->nokp,
|
||||||
|
'nama' => $nama,
|
||||||
|
'teller' => $kelulusan->teller,
|
||||||
|
'komen' => $kelulusan->komen,
|
||||||
|
'cawangan_nama' => $namaCaw,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::warning('Assign anggota operasi notification failed: '.$e->getMessage(), [
|
||||||
|
'kodcaw' => $kodcaw,
|
||||||
|
'nokp' => isset($kelulusan->nokp) ? $kelulusan->nokp : null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//KEPOHONAN EDIT DAN HAPUS
|
//KEPOHONAN EDIT DAN HAPUS
|
||||||
|
|
||||||
public function kepohonancreate(REQUEST $request,$kodcaw,$norujukan)
|
public function kepohonancreate(REQUEST $request,$kodcaw,$norujukan)
|
||||||
@@ -600,26 +655,86 @@ public function create(REQUEST $request,$kodcaw,$norujukan,$roles)
|
|||||||
return response()->json($arraykelulusan,200);
|
return response()->json($arraykelulusan,200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listoperasikelulusan()
|
public function listoperasikelulusan(Request $request)
|
||||||
{
|
{
|
||||||
$harini = Carbon::now();
|
$dateFrom = $request->query('date_from');
|
||||||
$harini = new Carbon;
|
$dateTo = $request->query('date_to');
|
||||||
|
$search = trim((string) $request->query('search', ''));
|
||||||
|
|
||||||
|
// Default to last 30 days to avoid loading entire history
|
||||||
|
if (!$dateFrom && !$dateTo) {
|
||||||
|
$dateTo = Carbon::now()->toDateString();
|
||||||
|
$dateFrom = Carbon::now()->subDays(30)->toDateString();
|
||||||
|
}
|
||||||
|
|
||||||
|
$cawangan_all = Cawangan::on('mysql7')
|
||||||
|
->select('mysql', 'details_caw', 'kodcaw')
|
||||||
|
->get();
|
||||||
|
|
||||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
|
||||||
$arraykelulusan = [];
|
$arraykelulusan = [];
|
||||||
|
|
||||||
foreach($cawangan_all as $index=>$cawangan){
|
foreach ($cawangan_all as $cawangan) {
|
||||||
$kelulusan=Mohon::on($cawangan['mysql'])
|
$query = Mohon::on($cawangan['mysql'])
|
||||||
->where('peloperasi','=','operasi')
|
->select([
|
||||||
->where('operasi','!=','')
|
'tarikh',
|
||||||
->get();
|
'norujukan',
|
||||||
|
'komen',
|
||||||
|
'jumpinj',
|
||||||
|
'nilaimarhun',
|
||||||
|
'berat',
|
||||||
|
'margin',
|
||||||
|
'status',
|
||||||
|
'operasi',
|
||||||
|
'masalulus',
|
||||||
|
])
|
||||||
|
->where('peloperasi', '=', 'operasi')
|
||||||
|
->where('operasi', '!=', '');
|
||||||
|
|
||||||
if(sizeof($kelulusan) != 0){
|
if ($dateFrom) {
|
||||||
array_push($arraykelulusan,["kelulusanall" => $kelulusan,"cawangan" => $cawangan['details_caw'],"cawangankod" => $cawangan['kodcaw']]);
|
$query->where('tarikh', '>=', $dateFrom);
|
||||||
|
}
|
||||||
|
if ($dateTo) {
|
||||||
|
$query->where('tarikh', '<=', $dateTo);
|
||||||
|
}
|
||||||
|
if ($search !== '') {
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('norujukan', 'like', "%{$search}%")
|
||||||
|
->orWhere('operasi', 'like', "%{$search}%")
|
||||||
|
->orWhere('status', 'like', "%{$search}%")
|
||||||
|
->orWhere('komen', 'like', "%{$search}%");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return response()->json($arraykelulusan,200);
|
$kelulusan = $query->orderBy('tarikh', 'desc')->get();
|
||||||
|
|
||||||
|
foreach ($kelulusan as $kel) {
|
||||||
|
$komenParts = explode('|', (string) ($kel->komen ?? ''));
|
||||||
|
$komenParts = array_values(array_filter($komenParts, function ($part) {
|
||||||
|
return $part !== '';
|
||||||
|
}));
|
||||||
|
|
||||||
|
$arraykelulusan[] = [
|
||||||
|
'tarikh' => $kel->tarikh ?? '-',
|
||||||
|
'norujukan' => $kel->norujukan ?? '-',
|
||||||
|
'status' => $kel->status ?? '-',
|
||||||
|
'komen' => $komenParts[0] ?? ($kel->komen ?: '-'),
|
||||||
|
'pinjaman' => $kel->jumpinj ?? '-',
|
||||||
|
'nilaimarhun' => $komenParts[1] ?? ($kel->nilaimarhun ?? '-'),
|
||||||
|
'berat' => $komenParts[2] ?? ($kel->berat ?? '-'),
|
||||||
|
'margin' => $komenParts[3] ?? ($kel->margin ?? '-'),
|
||||||
|
'pelulus' => $kel->operasi ?? '-',
|
||||||
|
'masalulus' => $kel->masalulus ?? '-',
|
||||||
|
'cawangan' => $cawangan['details_caw'],
|
||||||
|
'cawangankod' => $cawangan['kodcaw'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($arraykelulusan, function ($a, $b) {
|
||||||
|
return strcmp((string) ($b['tarikh'] ?? ''), (string) ($a['tarikh'] ?? ''));
|
||||||
|
});
|
||||||
|
|
||||||
|
return response()->json($arraykelulusan, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function UpdateHapusAnsuranOperasi(Request $request){
|
public function UpdateHapusAnsuranOperasi(Request $request){
|
||||||
|
|||||||
@@ -3,15 +3,18 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Audit;
|
use App\Audit;
|
||||||
|
use App\BsasOrder;
|
||||||
use App\Komuditi;
|
use App\Komuditi;
|
||||||
use App\KomuditiPurchase;
|
use App\KomuditiPurchase;
|
||||||
use App\KomuditiTransaksi;
|
use App\KomuditiTransaksi;
|
||||||
use App\KomuditiProduk;
|
use App\KomuditiProduk;
|
||||||
use App\Cawangan;
|
use App\Cawangan;
|
||||||
|
use App\Services\Bsas\BsasOrderService;
|
||||||
use DB;
|
use DB;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class KomuditiController extends Controller
|
class KomuditiController extends Controller
|
||||||
{
|
{
|
||||||
@@ -117,6 +120,9 @@ class KomuditiController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function updateKomuditi(Request $request){
|
public function updateKomuditi(Request $request){
|
||||||
|
if (\App\ShorakaTransaction::where('norujukan', $request->norujukan)->exists()) {
|
||||||
|
abort(409, 'Transaksi Shoraka memerlukan semakan operasi; stok lama tidak boleh diubah.');
|
||||||
|
}
|
||||||
$current = Carbon::now();
|
$current = Carbon::now();
|
||||||
$current = new Carbon();
|
$current = new Carbon();
|
||||||
|
|
||||||
@@ -138,37 +144,20 @@ class KomuditiController extends Controller
|
|||||||
return response()->json($komuditi_transaksi);
|
return response()->json($komuditi_transaksi);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transaksiKomuditi(Request $request){
|
public function transaksiKomuditi(Request $request)
|
||||||
$current = Carbon::now();
|
{
|
||||||
$current = new Carbon();
|
$this->validate($request, ['kodcaw' => 'required|string', 'norujukan' => 'required|string']);
|
||||||
|
return app(ShorakaGadaiController::class)->submitGadai(
|
||||||
$komuditi_current = KomuditiPurchase::on('mysql7')->where('date_purchase','=',$current->toDateString())->orderBy('created_at','desc')->first();
|
$request->kodcaw, $request->norujukan,
|
||||||
|
app(\App\Services\ShorakaGadaiService::class),
|
||||||
$unit_current = $komuditi_current['unit_komuditi'];
|
app(\App\Services\ShorakaService::class)
|
||||||
$update_unit = $unit_current - $request->unit_komuditi;
|
);
|
||||||
|
|
||||||
$unit_current = round((float) $komuditi_current['unit_komuditi'], 2);
|
|
||||||
$unit_komuditi = round((float) $request->unit_komuditi, 2);
|
|
||||||
$update_unit = round($unit_current - $unit_komuditi, 2);
|
|
||||||
|
|
||||||
$update_komuditi = KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
|
|
||||||
'unit_komuditi' => $update_unit
|
|
||||||
]);
|
|
||||||
|
|
||||||
$komuditi_transaksi = KomuditiTransaksi::on('mysql7')->create([
|
|
||||||
'unit_komuditi' => $unit_komuditi,
|
|
||||||
'nosijil'=>$komuditi_current['no_sijil'],
|
|
||||||
'norujukan' => $request->norujukan,
|
|
||||||
'kodcaw' => $request->kodcaw ,
|
|
||||||
'teller' => $request->teller ,
|
|
||||||
'masa' => $current->toTimeString(),
|
|
||||||
'tarikh' => $current->toDateString()
|
|
||||||
]);
|
|
||||||
|
|
||||||
return response()->json($komuditi_transaksi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function batalKomuditi(Request $request){
|
public function batalKomuditi(Request $request){
|
||||||
|
if (\App\ShorakaTransaction::where('norujukan', $request->norujukan)->exists()) {
|
||||||
|
abort(409, 'Transaksi Shoraka memerlukan semakan operasi; stok lama tidak boleh diubah.');
|
||||||
|
}
|
||||||
|
|
||||||
$komuditi_current = KomuditiPurchase::on('mysql7')->orderBy('created_at','desc')->first();
|
$komuditi_current = KomuditiPurchase::on('mysql7')->orderBy('created_at','desc')->first();
|
||||||
|
|
||||||
@@ -338,4 +327,195 @@ class KomuditiController extends Controller
|
|||||||
return response()->json($rekodkomoditi);
|
return response()->json($rekodkomoditi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List BSAS commodity orders for operasi rekod view.
|
||||||
|
*/
|
||||||
|
public function listBsasOrders(Request $request)
|
||||||
|
{
|
||||||
|
$query = BsasOrder::on('mysql7')
|
||||||
|
->select([
|
||||||
|
'id',
|
||||||
|
'uuid',
|
||||||
|
'norujukan',
|
||||||
|
'kodcaw',
|
||||||
|
'serial_number',
|
||||||
|
'product_code',
|
||||||
|
'bid_value',
|
||||||
|
'otc_murabaha_value',
|
||||||
|
'otc_counter_party',
|
||||||
|
'status',
|
||||||
|
'status_code',
|
||||||
|
'status_message',
|
||||||
|
'e_cert_no',
|
||||||
|
'bid_ecert_response',
|
||||||
|
'otc_ecert_response',
|
||||||
|
'stb_ecert_response',
|
||||||
|
'created_by',
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
])
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->orderBy('id', 'desc');
|
||||||
|
|
||||||
|
if ($request->filled('status')) {
|
||||||
|
$query->where('status', $request->input('status'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('kodcaw')) {
|
||||||
|
$query->where('kodcaw', $request->input('kodcaw'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('limit_view')) {
|
||||||
|
$query->limit((int) $request->input('limit_view'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows = $query->get()->map(function (BsasOrder $order) {
|
||||||
|
$payload = $order->toArray();
|
||||||
|
$payload['has_bid_ecert'] = !empty($order->bid_ecert_response);
|
||||||
|
$payload['has_otc_ecert'] = !empty($order->otc_ecert_response);
|
||||||
|
$payload['has_stb_ecert'] = !empty($order->stb_ecert_response);
|
||||||
|
unset($payload['bid_ecert_response'], $payload['otc_ecert_response'], $payload['stb_ecert_response']);
|
||||||
|
|
||||||
|
return $payload;
|
||||||
|
});
|
||||||
|
|
||||||
|
return response()->json($rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SAG-ready komoditi/product payload from confirmed BSAS order for a norujukan.
|
||||||
|
* Replaces daily KomuditiPurchase lookup for per-Terima BSAS purchases.
|
||||||
|
*/
|
||||||
|
public function getBsasOrderByNorujukan($norujukan)
|
||||||
|
{
|
||||||
|
$order = BsasOrder::on('mysql7')
|
||||||
|
->where('norujukan', $norujukan)
|
||||||
|
->where('status', 'confirmed')
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$order) {
|
||||||
|
return response()->json(['message' => 'BSAS order tidak dijumpai untuk norujukan ini.'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$otc = is_array($order->otc_ecert_response) ? $order->otc_ecert_response : [];
|
||||||
|
$productCode = (string) ($order->product_code ?: config('bsas.product_code'));
|
||||||
|
$description = trim((string) ($otc['PNAME'] ?? ''));
|
||||||
|
if ($description === '') {
|
||||||
|
$produk = KomuditiProduk::on('mysql7')->where('kodproduk', $productCode)->first();
|
||||||
|
$description = $produk ? (string) $produk->description : $productCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
$price = (float) ($otc['PRICE_MYR_EQUIVALENT'] ?? $otc['PRICE'] ?? 0);
|
||||||
|
$volume = (float) ($otc['PVOLUME'] ?? 0);
|
||||||
|
$pinjaman = (float) $order->bid_value;
|
||||||
|
if ($volume <= 0 && $price > 0 && $pinjaman > 0) {
|
||||||
|
$volume = round($pinjaman / $price, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'source' => 'bsas',
|
||||||
|
'uuid' => $order->uuid,
|
||||||
|
'komoditi' => [
|
||||||
|
'no_sijil' => $order->e_cert_no ?: $order->uuid,
|
||||||
|
'kodproduct' => $productCode,
|
||||||
|
'nilai' => $price > 0 ? $price : null,
|
||||||
|
],
|
||||||
|
'product' => [
|
||||||
|
'product_code' => $productCode,
|
||||||
|
'kodproduk' => $productCode,
|
||||||
|
'description' => $description,
|
||||||
|
'unit' => 'TAN',
|
||||||
|
],
|
||||||
|
'kuantiti' => $volume,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return stored BSAS eCert payload only (no live BSAS refresh).
|
||||||
|
*/
|
||||||
|
public function getBsasOrderEcert($uuid)
|
||||||
|
{
|
||||||
|
$order = BsasOrder::on('mysql7')->where('uuid', $uuid)->first();
|
||||||
|
|
||||||
|
if (!$order) {
|
||||||
|
return response()->json(['message' => 'BSAS order tidak dijumpai.'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($order->bid_ecert_response) && empty($order->otc_ecert_response) && empty($order->stb_ecert_response)) {
|
||||||
|
return response()->json(['message' => 'eCert belum tersedia untuk order ini.'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'uuid' => $order->uuid,
|
||||||
|
'norujukan' => $order->norujukan,
|
||||||
|
'e_cert_no' => $order->e_cert_no,
|
||||||
|
'serial_number' => $order->serial_number,
|
||||||
|
'product_code' => $order->product_code,
|
||||||
|
'bid_value' => $order->bid_value,
|
||||||
|
'otc_murabaha_value' => $order->otc_murabaha_value,
|
||||||
|
'otc_counter_party' => $order->otc_counter_party,
|
||||||
|
'bid_ecert' => $order->bid_ecert_response,
|
||||||
|
'otc_ecert' => $order->otc_ecert_response,
|
||||||
|
'stb_ecert' => $order->stb_ecert_response,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place BSAS commodity order for a gadai Terima, long-poll result, fetch eCert.
|
||||||
|
*/
|
||||||
|
public function placeBsasOrder(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$service = new BsasOrderService();
|
||||||
|
$order = $service->placeAndConfirm([
|
||||||
|
'norujukan' => $request->input('norujukan'),
|
||||||
|
'kodcaw' => $request->input('kodcaw'),
|
||||||
|
'pinjaman' => $request->input('pinjaman'),
|
||||||
|
'hargajualan' => $request->input('hargajualan'),
|
||||||
|
'nama_pelanggan' => $request->input('nama_pelanggan'),
|
||||||
|
'teller' => $request->input('teller'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'BSAS order confirmed',
|
||||||
|
'order' => $order,
|
||||||
|
], 200);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('BSAS place order failed', [
|
||||||
|
'norujukan' => $request->input('norujukan'),
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => $e->getMessage() ?: 'Gagal pembelian komoditi BSAS.',
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-query BSAS orderResult / retry eCert by stored uuid.
|
||||||
|
*/
|
||||||
|
public function getBsasOrder($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$service = new BsasOrderService();
|
||||||
|
$order = $service->refreshByUuid($uuid);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'OK',
|
||||||
|
'order' => $order,
|
||||||
|
], 200);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('BSAS refresh order failed', [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => $e->getMessage() ?: 'Gagal semak status BSAS.',
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use App\Negeri;
|
|||||||
use App\Lelong;
|
use App\Lelong;
|
||||||
use App\Transaction;
|
use App\Transaction;
|
||||||
use App\Cawangan;
|
use App\Cawangan;
|
||||||
|
use App\Feature;
|
||||||
use App\Gadai;
|
use App\Gadai;
|
||||||
use App\TuntutBaki;
|
use App\TuntutBaki;
|
||||||
use App\WTD;
|
use App\WTD;
|
||||||
@@ -26,6 +27,7 @@ use App\Tunai;
|
|||||||
use App\Audit;
|
use App\Audit;
|
||||||
use App\GlDetail;
|
use App\GlDetail;
|
||||||
use App\Pembeli;
|
use App\Pembeli;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use App\Services\RingkasanHarianServices;
|
use App\Services\RingkasanHarianServices;
|
||||||
@@ -604,16 +606,7 @@ class LelongController extends Controller
|
|||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||||
|
|
||||||
if($cawangan['tagarrahnbid'] == 1){
|
if($cawangan['tagarrahnbid'] == 1){
|
||||||
if(env('APP_ENV') != 'production'){
|
$lelong = $this->fetchPortalLelong($request->kodcaw, $request->norujukan);
|
||||||
$link = 'https://adminbid-kopkb.erahn.com.my/api/portalApi';
|
|
||||||
}else{
|
|
||||||
$link = 'https://adminbid-kopkb.erahn.com.my/api/portalApi';
|
|
||||||
}
|
|
||||||
|
|
||||||
$lelong = Http::withOptions(['verify' => true])->get($link,[
|
|
||||||
'norujukan' => $request->norujukan
|
|
||||||
])->json();
|
|
||||||
$lelong = ($lelong != null) ? $lelong['lelong'] : [];
|
|
||||||
if( $lelong == null )
|
if( $lelong == null )
|
||||||
{
|
{
|
||||||
$lelong = Lelong::on($cawangan['mysql'])
|
$lelong = Lelong::on($cawangan['mysql'])
|
||||||
@@ -656,10 +649,7 @@ class LelongController extends Controller
|
|||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $request->kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $request->kodcaw)->first();
|
||||||
|
|
||||||
if ($cawangan['tagarrahnbid'] == 0){
|
if ($cawangan['tagarrahnbid'] == 0){
|
||||||
$lelong = Http::withOptions(['verify' => true])->get(config('app_parameter.api_arrahnbid').'portalApi',[
|
$lelong = $this->fetchPortalLelong($request->kodcaw, $request->norujukan);
|
||||||
'norujukan' => $request->norujukan
|
|
||||||
])->json();
|
|
||||||
$lelong = ($lelong != null) ? $lelong['lelong'] : [];
|
|
||||||
if( $lelong == null )
|
if( $lelong == null )
|
||||||
{
|
{
|
||||||
$lelong = Lelong::on($cawangan['mysql'])
|
$lelong = Lelong::on($cawangan['mysql'])
|
||||||
@@ -729,8 +719,8 @@ class LelongController extends Controller
|
|||||||
|
|
||||||
if($cawangan['tagarrahnbid'] == 1)
|
if($cawangan['tagarrahnbid'] == 1)
|
||||||
{
|
{
|
||||||
$lelong = Http::withOptions(['verify' => true])->get(config('app_parameter.api_arrahnbid').'portalApi',['norujukan' => $request->norujukan])->json();
|
$lelong = $this->fetchPortalLelong($request->kodcaw, $request->norujukan);
|
||||||
$lelong = ($lelong != null) ? $lelong['lelong'] : [];
|
$lelong = ($lelong != null) ? $lelong : [];
|
||||||
}else{
|
}else{
|
||||||
$lelong = Lelong::on($cawangan['mysql'])->where([['norujukan',$request->norujukan]])->first();
|
$lelong = Lelong::on($cawangan['mysql'])->where([['norujukan',$request->norujukan]])->first();
|
||||||
}
|
}
|
||||||
@@ -2009,4 +1999,31 @@ class LelongController extends Controller
|
|||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch lelong status from arrahnbid. Returns null when the portal is
|
||||||
|
* unreachable so callers can fall back to the local lelong table.
|
||||||
|
*/
|
||||||
|
private function fetchPortalLelong($kodcaw, $norujukan)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$payload = Http::withOptions(['verify' => true])
|
||||||
|
->timeout(5)
|
||||||
|
->get(Feature::arrahnbidUrl($kodcaw).'portalApi', [
|
||||||
|
'norujukan' => $norujukan,
|
||||||
|
])
|
||||||
|
->json();
|
||||||
|
|
||||||
|
return ($payload != null) ? ($payload['lelong'] ?? null) : null;
|
||||||
|
} catch (ConnectionException $e) {
|
||||||
|
Log::warning('Arrahnbid portal unreachable; falling back to local lelong.', [
|
||||||
|
'kodcaw' => $kodcaw,
|
||||||
|
'norujukan' => $norujukan,
|
||||||
|
'url' => Feature::arrahnbidUrl($kodcaw).'portalApi',
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Marhun;
|
use App\Marhun;
|
||||||
|
use App\Gadai;
|
||||||
use App\Jemas;
|
use App\Jemas;
|
||||||
use App\Cawangan;
|
use App\Cawangan;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -58,6 +59,11 @@ class MarhunController extends Controller
|
|||||||
|
|
||||||
public function create($kodcaw,Request $request)
|
public function create($kodcaw,Request $request)
|
||||||
{
|
{
|
||||||
|
$order = \App\ShorakaTransaction::where('norujukan', $request->norujukan)->first();
|
||||||
|
if ($order) {
|
||||||
|
abort(409, 'Kontrak Shoraka telah dihantar dan tidak boleh diubah.');
|
||||||
|
}
|
||||||
|
|
||||||
$current = Carbon::now();
|
$current = Carbon::now();
|
||||||
$current = new Carbon();
|
$current = new Carbon();
|
||||||
|
|
||||||
@@ -126,6 +132,10 @@ class MarhunController extends Controller
|
|||||||
|
|
||||||
public function deletemarhun($kodcaw,$norujukan,Request $request)
|
public function deletemarhun($kodcaw,$norujukan,Request $request)
|
||||||
{
|
{
|
||||||
|
$order = \App\ShorakaTransaction::where('norujukan', $norujukan)->first();
|
||||||
|
if ($order) {
|
||||||
|
abort(409, 'Kontrak Shoraka telah dihantar dan tidak boleh diubah.');
|
||||||
|
}
|
||||||
|
|
||||||
$current = Carbon::now();
|
$current = Carbon::now();
|
||||||
$current = new Carbon();
|
$current = new Carbon();
|
||||||
@@ -151,6 +161,11 @@ class MarhunController extends Controller
|
|||||||
|
|
||||||
public function editmarhun($kodcaw,$norujukan,Request $request)
|
public function editmarhun($kodcaw,$norujukan,Request $request)
|
||||||
{
|
{
|
||||||
|
$order = \App\ShorakaTransaction::where('norujukan', $norujukan)->first();
|
||||||
|
if ($order) {
|
||||||
|
abort(409, 'Kontrak Shoraka telah dihantar dan tidak boleh diubah.');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$current = Carbon::now();
|
$current = Carbon::now();
|
||||||
$current = new Carbon();
|
$current = new Carbon();
|
||||||
@@ -160,39 +175,53 @@ class MarhunController extends Controller
|
|||||||
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
$old_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
|
// Lock the parent first so concurrent edits to this SAG are serialized.
|
||||||
|
(new Marhun)->setConnection($cawangan['mysql'])->getConnection()->transaction(function () use ($cawangan, $norujukan, $request, $harga, $nilai_marhun, $kodcaw, $current) {
|
||||||
|
Gadai::on($cawangan['mysql'])->where('norujukan', $norujukan)->lockForUpdate()->firstOrFail();
|
||||||
|
$old_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->firstOrFail();
|
||||||
|
|
||||||
$marhunToUpdate = [
|
$marhunToUpdate = [
|
||||||
'karat' => $request->karat,
|
'karat' => $request->karat,
|
||||||
'marhun' => $request->marhun,
|
'marhun' => $request->marhun,
|
||||||
'nota' => $request->nota,
|
'nota' => $request->nota,
|
||||||
'tag_permata' => $request->tag_permata,
|
'tag_permata' => $request->tag_permata,
|
||||||
'berat_batu_permata' => $request->berat_batu_permata,
|
'berat_batu_permata' => $request->berat_batu_permata,
|
||||||
'berat' => $request->berat,
|
'berat' => $request->berat,
|
||||||
'harga' => $harga['harga'],
|
'harga' => $harga['harga'],
|
||||||
'n_marhun' => $nilai_marhun,
|
'n_marhun' => $nilai_marhun,
|
||||||
'bil' => $request->kuantiti,
|
'bil' => $request->kuantiti,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Set value berat_batu_permata to null if value passed is null
|
// Set value berat_batu_permata to null if value passed is null
|
||||||
if($marhunToUpdate['berat_batu_permata'] == '') {
|
if($marhunToUpdate['berat_batu_permata'] == '') {
|
||||||
$marhunToUpdate['berat_batu_permata'] = null;
|
$marhunToUpdate['berat_batu_permata'] = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
$jemas = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->update($marhunToUpdate);
|
$jemas = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->update($marhunToUpdate);
|
||||||
|
|
||||||
$new_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
|
// Recalculate from every item belonging to this SAG, after the edit.
|
||||||
|
$totals = Marhun::on($cawangan['mysql'])->where('norujukan', $norujukan)
|
||||||
|
->selectRaw('COALESCE(SUM(berat), 0) AS total_berat, COALESCE(SUM(n_marhun), 0) AS total_nilai, COALESCE(SUM(bil), 0) AS total_kuantiti')
|
||||||
|
->first();
|
||||||
|
Gadai::on($cawangan['mysql'])->where('norujukan', $norujukan)->update([
|
||||||
|
'berat' => $totals->total_berat,
|
||||||
|
'nilaimarhun' => $totals->total_nilai,
|
||||||
|
'kuantiti' => $totals->total_kuantiti,
|
||||||
|
]);
|
||||||
|
|
||||||
$audit = new Audit();
|
$new_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
|
||||||
$audit->users = $request->teller;
|
|
||||||
$audit->actions = 'Ubah Marhun';
|
$audit = new Audit();
|
||||||
$audit->norujukan = $norujukan;
|
$audit->users = $request->teller;
|
||||||
$audit->old_data = $old_data;
|
$audit->actions = 'Ubah Marhun';
|
||||||
$audit->new_data = $new_data;
|
$audit->norujukan = $norujukan;
|
||||||
$audit->kodcaw = $kodcaw;
|
$audit->old_data = $old_data;
|
||||||
$audit->created_at = $current;
|
$audit->new_data = $new_data;
|
||||||
$audit->updated_at = $current;
|
$audit->kodcaw = $kodcaw;
|
||||||
$audit->save();
|
$audit->created_at = $current;
|
||||||
|
$audit->updated_at = $current;
|
||||||
|
$audit->save();
|
||||||
|
});
|
||||||
|
|
||||||
return response('Edit Successfully', 200);
|
return response('Edit Successfully', 200);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,14 @@ class PembiayaanOnlineController extends Controller
|
|||||||
return $this->respond($this->service->show($kodcaw, $norujukan));
|
return $this->respond($this->service->show($kodcaw, $norujukan));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/pembiayaan-online/{kodcaw}/lines/{id}
|
||||||
|
*/
|
||||||
|
public function showLine($kodcaw, $id)
|
||||||
|
{
|
||||||
|
return $this->respond($this->service->showLine($kodcaw, $id));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /api/pembiayaan-online/{kodcaw}/queue
|
* GET /api/pembiayaan-online/{kodcaw}/queue
|
||||||
*/
|
*/
|
||||||
@@ -53,6 +61,8 @@ class PembiayaanOnlineController extends Controller
|
|||||||
foreach ([
|
foreach ([
|
||||||
'kodbank', 'noakaun', 'nama_bank', 'nama_akaun', 'nota',
|
'kodbank', 'noakaun', 'nama_bank', 'nama_akaun', 'nota',
|
||||||
'bukti_akaun_file_id', 'borang_file_id', 'update_customer_bank',
|
'bukti_akaun_file_id', 'borang_file_id', 'update_customer_bank',
|
||||||
|
'bukti_akaun_data', 'bukti_akaun_filename', 'bukti_akaun_type',
|
||||||
|
'borang_data', 'borang_filename', 'borang_type',
|
||||||
] as $key) {
|
] as $key) {
|
||||||
if ($request->has($key)) {
|
if ($request->has($key)) {
|
||||||
$input[$key] = $request->input($key);
|
$input[$key] = $request->input($key);
|
||||||
@@ -62,6 +72,26 @@ class PembiayaanOnlineController extends Controller
|
|||||||
return $this->respond($this->service->updateLine($kodcaw, $id, $input));
|
return $this->respond($this->service->updateLine($kodcaw, $id, $input));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/pembiayaan-online/{kodcaw}/lines/{id}/verify
|
||||||
|
*/
|
||||||
|
public function verifyLine($kodcaw, $id, Request $request)
|
||||||
|
{
|
||||||
|
return $this->respond($this->service->verifyLine(
|
||||||
|
$kodcaw,
|
||||||
|
$id,
|
||||||
|
$request->input('pc_verified_by', '')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/pembiayaan-online/{kodcaw}/lines/{id}/unverify
|
||||||
|
*/
|
||||||
|
public function unverifyLine($kodcaw, $id)
|
||||||
|
{
|
||||||
|
return $this->respond($this->service->unverifyLine($kodcaw, $id));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /api/pembiayaan-online/{kodcaw}/batches
|
* GET /api/pembiayaan-online/{kodcaw}/batches
|
||||||
*/
|
*/
|
||||||
@@ -177,6 +207,22 @@ class PembiayaanOnlineController extends Controller
|
|||||||
return $this->respond($this->service->getBukti($kodcaw, $id));
|
return $this->respond($this->service->getBukti($kodcaw, $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/pembiayaan-online/{kodcaw}/lines/{id}/bukti-akaun
|
||||||
|
*/
|
||||||
|
public function getBuktiAkaun($kodcaw, $id)
|
||||||
|
{
|
||||||
|
return $this->respond($this->service->getBuktiAkaun($kodcaw, $id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/pembiayaan-online/{kodcaw}/lines/{id}/borang
|
||||||
|
*/
|
||||||
|
public function getBorang($kodcaw, $id)
|
||||||
|
{
|
||||||
|
return $this->respond($this->service->getBorang($kodcaw, $id));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /api/pembiayaan-online/{kodcaw}/paid?blast_sent=0
|
* GET /api/pembiayaan-online/{kodcaw}/paid?blast_sent=0
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,291 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\ShorakaTransaction;
|
||||||
|
use App\Services\ShorakaService;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class ShorakaController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$this->validate($request, [
|
||||||
|
'kodcaw' => 'nullable|string|max:30',
|
||||||
|
'norujukan' => 'nullable|string|max:100',
|
||||||
|
'status' => 'nullable|string|max:30',
|
||||||
|
'date_from' => 'nullable|date_format:Y-m-d',
|
||||||
|
'date_to' => 'nullable|date_format:Y-m-d',
|
||||||
|
'per_page' => 'nullable|integer|min:1|max:100',
|
||||||
|
'page' => 'nullable|integer|min:1',
|
||||||
|
'branch_scope' => 'nullable|string|max:30',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$query = ShorakaTransaction::query();
|
||||||
|
foreach (['kodcaw', 'norujukan', 'status'] as $field) {
|
||||||
|
if ($request->filled($field)) {
|
||||||
|
$query->where($field, $request->input($field));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($request->filled('date_from')) {
|
||||||
|
$query->where('created_at', '>=', $request->input('date_from') . ' 00:00:00');
|
||||||
|
}
|
||||||
|
if ($request->filled('date_to')) {
|
||||||
|
$query->where('created_at', '<', Carbon::parse($request->input('date_to'))->addDay()->format('Y-m-d') . ' 00:00:00');
|
||||||
|
}
|
||||||
|
$records = $query->orderByDesc('created_at')->orderByDesc('id')
|
||||||
|
->paginate(min(100, max(1, (int) $request->input('per_page', 25))));
|
||||||
|
$payload = [
|
||||||
|
'data' => $records->getCollection()->map(function (ShorakaTransaction $record) {
|
||||||
|
return [
|
||||||
|
'id' => $record->id,
|
||||||
|
'kodcaw' => $record->kodcaw,
|
||||||
|
'norujukan' => $record->norujukan,
|
||||||
|
'teller' => $record->teller,
|
||||||
|
'status' => $record->status,
|
||||||
|
'order_id' => $record->order_id,
|
||||||
|
'created_at' => optional($record->created_at)->toDateTimeString(),
|
||||||
|
'updated_at' => optional($record->updated_at)->toDateTimeString(),
|
||||||
|
];
|
||||||
|
})->values(),
|
||||||
|
'total' => $records->total(),
|
||||||
|
'current_page' => $records->currentPage(),
|
||||||
|
'per_page' => $records->perPage(),
|
||||||
|
'last_page' => $records->lastPage(),
|
||||||
|
];
|
||||||
|
if ($request->input('with_branches')) {
|
||||||
|
$branches = ShorakaTransaction::query()->whereNotNull('kodcaw');
|
||||||
|
if ($request->filled('branch_scope')) {
|
||||||
|
$branches->where('kodcaw', $request->input('branch_scope'));
|
||||||
|
}
|
||||||
|
$payload['branches'] = $branches->distinct()->orderBy('kodcaw')->pluck('kodcaw')->values();
|
||||||
|
}
|
||||||
|
return response()->json($payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submit(Request $request, ShorakaService $shoraka)
|
||||||
|
{
|
||||||
|
$validated = $this->validate($request, [
|
||||||
|
'norujukan' => 'required|string|max:255',
|
||||||
|
'ownership' => 'required|string|max:255',
|
||||||
|
'order_amount' => 'required|numeric|min:0.01|max:9999999999999.99',
|
||||||
|
'murabaha_amount' => 'required|numeric|min:0.01|max:9999999999999.99',
|
||||||
|
'tenor_other' => 'required|integer|min:1',
|
||||||
|
'teller' => 'nullable|string|max:255',
|
||||||
|
]);
|
||||||
|
if (!$shoraka->configured()) {
|
||||||
|
return $this->unconfigured();
|
||||||
|
}
|
||||||
|
|
||||||
|
$existing = ShorakaTransaction::where('norujukan', $validated['norujukan'])->first();
|
||||||
|
if ($existing) {
|
||||||
|
return $this->duplicate($existing);
|
||||||
|
}
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'product_type' => 'FINANCING',
|
||||||
|
'commodity_type' => '000-COPPER',
|
||||||
|
'ownership' => $validated['ownership'],
|
||||||
|
'ownership_doc_no' => $validated['norujukan'],
|
||||||
|
'value_date' => Carbon::now()->format('d/m/Y'),
|
||||||
|
'order_currency' => 'MYR',
|
||||||
|
'order_amount' => number_format((float) $validated['order_amount'], 2, '.', ''),
|
||||||
|
'murabaha_amount' => number_format((float) $validated['murabaha_amount'], 2, '.', ''),
|
||||||
|
// Appendix codes in v1.5: OTHERS and MONTH.
|
||||||
|
'tenor' => 'OTHERS',
|
||||||
|
'tenor_other' => $validated['tenor_other'],
|
||||||
|
'tenor_other_unit' => 'MONTH',
|
||||||
|
'order_type' => 'Buy & Sell',
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
// The unique norujukan index is the atomic claim for concurrent submissions.
|
||||||
|
$attributes = [
|
||||||
|
'norujukan' => $validated['norujukan'],
|
||||||
|
'kodcaw' => $request->attributes->get('shoraka_kodcaw'),
|
||||||
|
'teller' => $validated['teller'] ?? null,
|
||||||
|
'status' => 'PENDING',
|
||||||
|
'product_type' => $payload['product_type'],
|
||||||
|
'commodity_type' => $payload['commodity_type'],
|
||||||
|
'ownership_name' => $payload['ownership'],
|
||||||
|
'ownership_doc_no' => $payload['ownership_doc_no'],
|
||||||
|
'order_amount' => $payload['order_amount'],
|
||||||
|
'murabaha_amount' => $payload['murabaha_amount'],
|
||||||
|
'request_payload' => $payload,
|
||||||
|
'attempt_count' => 1,
|
||||||
|
];
|
||||||
|
$transaction = ShorakaTransaction::create($attributes);
|
||||||
|
} catch (QueryException $exception) {
|
||||||
|
$existing = ShorakaTransaction::where('norujukan', $validated['norujukan'])->first();
|
||||||
|
if ($existing) {
|
||||||
|
return $this->duplicate($existing);
|
||||||
|
}
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $shoraka->submitOrder($payload);
|
||||||
|
$this->saveOrder($transaction, $response);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Order berjaya dihantar ke Shoraka.',
|
||||||
|
'data' => $this->orderData($transaction),
|
||||||
|
]);
|
||||||
|
} catch (Throwable $exception) {
|
||||||
|
// A timeout or invalid response does not prove the remote trade failed.
|
||||||
|
// Block resubmission until this reference has been reconciled with Shoraka.
|
||||||
|
$transaction->update([
|
||||||
|
'status' => $transaction->order_id ? $transaction->status : 'UNKNOWN',
|
||||||
|
'error_message' => 'Submission outcome requires reconciliation with Shoraka.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->upstreamError('submit', $transaction, $exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function refresh(string $norujukan, ShorakaService $shoraka)
|
||||||
|
{
|
||||||
|
if (!$shoraka->configured()) {
|
||||||
|
return $this->unconfigured();
|
||||||
|
}
|
||||||
|
$transaction = ShorakaTransaction::where('norujukan', $norujukan)->firstOrFail();
|
||||||
|
if (!$transaction->order_id) {
|
||||||
|
return $this->missingOrderId();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $shoraka->orderStatus($transaction->order_id);
|
||||||
|
$this->saveOrder($transaction, $response);
|
||||||
|
|
||||||
|
return response()->json(['success' => true, 'data' => $this->orderData($transaction)]);
|
||||||
|
} catch (Throwable $exception) {
|
||||||
|
return $this->upstreamError('status', $transaction, $exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function certificate(string $norujukan, ShorakaService $shoraka)
|
||||||
|
{
|
||||||
|
if (!$shoraka->configured()) {
|
||||||
|
return $this->unconfigured();
|
||||||
|
}
|
||||||
|
$transaction = ShorakaTransaction::where('norujukan', $norujukan)->firstOrFail();
|
||||||
|
if (!$transaction->order_id) {
|
||||||
|
return $this->missingOrderId();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdf = $shoraka->certificate($transaction->order_id);
|
||||||
|
|
||||||
|
return response($pdf, 200, [
|
||||||
|
'Content-Type' => 'application/pdf',
|
||||||
|
'Content-Disposition' => 'attachment; filename="shoraka-' . $transaction->id . '.pdf"',
|
||||||
|
'Cache-Control' => 'private, no-store',
|
||||||
|
]);
|
||||||
|
} catch (Throwable $exception) {
|
||||||
|
return $this->upstreamError('certificate', $transaction, $exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function callback(Request $request, ShorakaService $shoraka)
|
||||||
|
{
|
||||||
|
if (!$shoraka->configured()) {
|
||||||
|
return $this->unconfigured();
|
||||||
|
}
|
||||||
|
$payload = $request->json()->all();
|
||||||
|
if (!$shoraka->validCallback($payload)) {
|
||||||
|
return response()->json(['success' => false, 'message' => 'Invalid callback signature.'], 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ownershipDocNo and certificateUrl are NOT signed. Never use them to link
|
||||||
|
// a callback to a local record or download a file.
|
||||||
|
$transaction = ShorakaTransaction::where('order_id', $payload['orderId'])->first();
|
||||||
|
if (!$transaction) {
|
||||||
|
return response()->json(['success' => false, 'message' => 'Order not found.'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// There is no signed callback timestamp. Query the current order so a
|
||||||
|
// delayed/replayed callback cannot directly restore an old status.
|
||||||
|
$response = $shoraka->orderStatus($transaction->order_id);
|
||||||
|
unset($payload['signature']);
|
||||||
|
$this->saveOrder($transaction, $response, ['callback_payload' => $payload]);
|
||||||
|
|
||||||
|
// Exact acknowledgement required by section 6.
|
||||||
|
return response('OK', 200, ['Content-Type' => 'text/plain']);
|
||||||
|
} catch (Throwable $exception) {
|
||||||
|
return $this->upstreamError('callback', $transaction, $exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function saveOrder(ShorakaTransaction $transaction, array $response, array $extra = []): void
|
||||||
|
{
|
||||||
|
$transaction->update(array_merge([
|
||||||
|
'order_id' => (string) $response['orderId'],
|
||||||
|
'status' => $response['status'],
|
||||||
|
'certificate_url' => $response['certificateUrl'] ?? null,
|
||||||
|
'response_payload' => $response,
|
||||||
|
'submitted_at' => $transaction->submitted_at ?: Carbon::now(),
|
||||||
|
'completed_at' => $response['status'] === 'Completed'
|
||||||
|
? ($transaction->completed_at ?: Carbon::now()) : $transaction->completed_at,
|
||||||
|
'error_message' => null,
|
||||||
|
], $extra));
|
||||||
|
app(\App\Services\ShorakaGadaiService::class)->sync($transaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function orderData(ShorakaTransaction $transaction): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'norujukan' => $transaction->norujukan,
|
||||||
|
'kodcaw' => $transaction->kodcaw,
|
||||||
|
'teller' => $transaction->teller,
|
||||||
|
'order_id' => $transaction->order_id,
|
||||||
|
'status' => $transaction->status,
|
||||||
|
'certificate_url' => $transaction->certificate_url,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function duplicate(ShorakaTransaction $transaction)
|
||||||
|
{
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Transaksi telah direkodkan. Semak status dengan Shoraka sebelum penghantaran semula.',
|
||||||
|
'data' => $this->orderData($transaction),
|
||||||
|
], 409);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function missingOrderId()
|
||||||
|
{
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Order ID belum tersedia. Semakan dengan Shoraka diperlukan.',
|
||||||
|
], 409);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function unconfigured()
|
||||||
|
{
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'API ID dan Secret Key Shoraka belum dikonfigurasi.',
|
||||||
|
], 503);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function upstreamError(string $operation, ShorakaTransaction $transaction, Throwable $exception)
|
||||||
|
{
|
||||||
|
// Connection exceptions may include request details; log only the class.
|
||||||
|
Log::error('Shoraka request failed', [
|
||||||
|
'operation' => $operation,
|
||||||
|
'transaction_id' => $transaction->id,
|
||||||
|
'exception_type' => get_class($exception),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Permintaan Shoraka gagal. Semak status transaksi sebelum mencuba semula.',
|
||||||
|
], 502);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\KomuditiTransaksi;
|
||||||
|
use App\Services\ShorakaGadaiService;
|
||||||
|
use App\Services\ShorakaService;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ShorakaGadaiController extends ShorakaController
|
||||||
|
{
|
||||||
|
public function readiness(ShorakaService $shoraka)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
\App\ShorakaTransaction::query()->limit(1)->exists();
|
||||||
|
$storeReady = true;
|
||||||
|
} catch (\Throwable $exception) {
|
||||||
|
$storeReady = false;
|
||||||
|
}
|
||||||
|
return response()->json(['provider' => 'shoraka', 'ready' => $storeReady && $shoraka->configured()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showGadai(string $kodcaw, string $norujukan, ShorakaGadaiService $gadaiService)
|
||||||
|
{
|
||||||
|
$gadai = $gadaiService->gadai($kodcaw, $norujukan);
|
||||||
|
$order = $gadaiService->transaction($kodcaw, $norujukan);
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'data' => [
|
||||||
|
'norujukan' => $norujukan, 'kodcaw' => $kodcaw,
|
||||||
|
'order_amount' => $gadai->pinjaman, 'murabaha_amount' => $gadai->hargajualan,
|
||||||
|
'order' => $order ? $this->orderData($order) : null,
|
||||||
|
'details' => $order ? $order->response_payload : null,
|
||||||
|
'simulation' => $order && strpos((string) $order->order_id, 'SIM-') === 0,
|
||||||
|
'can_complete' => $gadai->exists && $order && $order->status === 'Completed'
|
||||||
|
&& number_format((float) $gadai->pinjaman, 2, '.', '') === $order->order_amount
|
||||||
|
&& number_format((float) $gadai->hargajualan, 2, '.', '') === $order->murabaha_amount,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submitGadai(string $kodcaw, string $norujukan, Request $request, ShorakaGadaiService $gadaiService, ShorakaService $shoraka)
|
||||||
|
{
|
||||||
|
$gadai = $gadaiService->gadai($kodcaw, $norujukan);
|
||||||
|
$existing = $gadaiService->transaction($kodcaw, $norujukan);
|
||||||
|
if ($existing) {
|
||||||
|
return $this->duplicate($existing);
|
||||||
|
}
|
||||||
|
// Historical commodity purchases must never be traded again.
|
||||||
|
if (KomuditiTransaksi::on('mysql7')->where('norujukan', $norujukan)->exists()
|
||||||
|
|| $gadai->cetak || $gadai->sttebus) {
|
||||||
|
abort(409, 'Gadaian lama atau telah selesai tidak boleh dihantar sebagai order baharu.');
|
||||||
|
}
|
||||||
|
$payload = $gadaiService->payload($gadai);
|
||||||
|
$teller = $request->input('teller');
|
||||||
|
if (is_string($teller) && $teller !== '') {
|
||||||
|
$payload['teller'] = $teller;
|
||||||
|
}
|
||||||
|
$submission = new Request($payload);
|
||||||
|
$submission->attributes->set('shoraka_kodcaw', $kodcaw);
|
||||||
|
return $this->submit($submission, $shoraka);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function refreshGadai(string $kodcaw, string $norujukan, ShorakaGadaiService $gadaiService, ShorakaService $shoraka)
|
||||||
|
{
|
||||||
|
$gadaiService->gadai($kodcaw, $norujukan);
|
||||||
|
$gadaiService->transaction($kodcaw, $norujukan);
|
||||||
|
return $this->refresh($norujukan, $shoraka);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function certificateGadai(string $kodcaw, string $norujukan, ShorakaGadaiService $gadaiService, ShorakaService $shoraka)
|
||||||
|
{
|
||||||
|
$gadaiService->assertCompleted($kodcaw, $norujukan);
|
||||||
|
return $this->certificate($norujukan, $shoraka);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ use App\Panjar;
|
|||||||
use App\HargaEmas;
|
use App\HargaEmas;
|
||||||
use App\Moratorium;
|
use App\Moratorium;
|
||||||
use App\Audit;
|
use App\Audit;
|
||||||
|
use App\Feature;
|
||||||
use App\LookupWakil;
|
use App\LookupWakil;
|
||||||
|
|
||||||
use App\StokAudit1;
|
use App\StokAudit1;
|
||||||
@@ -193,7 +194,7 @@ class TebusController extends Controller
|
|||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
$tebus_data = Tebus::on($cawangan['mysql'])
|
$tebus_data = Tebus::on($cawangan['mysql'])
|
||||||
->select('tebus.t_tebus', 'gad.t_gadai','gad.hargajualan','gad.bakihargajualan','gad.bakipjm as gadaibakipjm','tebus.nilaimarhun','tebus.tagterima', 'tebus.teller','tebus.jenistebus','tebus.pinjaman','tebus.bakiupah','tebus.bakipjm','gad.norujukan','gad.nokp','tebus.jbg','tebus.ujrah','tebus.onepercent','gad.tagbaru')
|
->select('tebus.t_tebus', 'gad.t_gadai','gad.hargajualan','gad.bakihargajualan','gad.bakipjm as gadaibakipjm','tebus.nilaimarhun','tebus.tagterima', 'tebus.teller','tebus.jenistebus','tebus.pinjaman','tebus.bakiupah','tebus.bakipjm','gad.norujukan','gad.nokp','tebus.jbg','tebus.ujrah','tebus.onepercent','gad.tagbaru','tebus.diskaun_rebate')
|
||||||
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
|
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
|
||||||
// ->join('online_arrahn.customer as cust', function($join)
|
// ->join('online_arrahn.customer as cust', function($join)
|
||||||
// {
|
// {
|
||||||
@@ -232,7 +233,8 @@ class TebusController extends Controller
|
|||||||
"nokp"=>$tebusData['nokp'],
|
"nokp"=>$tebusData['nokp'],
|
||||||
"jbg"=>$tebusData['jbg'],
|
"jbg"=>$tebusData['jbg'],
|
||||||
"ujrah"=>$trans['ujrah_rebet'],
|
"ujrah"=>$trans['ujrah_rebet'],
|
||||||
"onepercent"=>$trans['onepercent_rebet']
|
"onepercent"=>$trans['onepercent_rebet'],
|
||||||
|
"diskaun_rebate"=>$tebusData['diskaun_rebate'],
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -274,7 +276,8 @@ class TebusController extends Controller
|
|||||||
'tebus.jbg',
|
'tebus.jbg',
|
||||||
'tebus.ujrah',
|
'tebus.ujrah',
|
||||||
'tebus.onepercent',
|
'tebus.onepercent',
|
||||||
'gad.tagbaru'
|
'gad.tagbaru',
|
||||||
|
'tebus.diskaun_rebate'
|
||||||
)
|
)
|
||||||
->join('gadai as gad', 'gad.norujukan', '=', 'tebus.norujukan')
|
->join('gadai as gad', 'gad.norujukan', '=', 'tebus.norujukan')
|
||||||
->where('tebus.t_tebus', '>=', $request->mula)
|
->where('tebus.t_tebus', '>=', $request->mula)
|
||||||
@@ -310,7 +313,8 @@ class TebusController extends Controller
|
|||||||
"jbg"=>$tebusData['jbg'],
|
"jbg"=>$tebusData['jbg'],
|
||||||
"ujrah"=>$trans['ujrah_rebet'],
|
"ujrah"=>$trans['ujrah_rebet'],
|
||||||
"onepercent"=>$trans['onepercent_rebet'],
|
"onepercent"=>$trans['onepercent_rebet'],
|
||||||
"tagbaru"=>$tebusData['tagbaru']
|
"tagbaru"=>$tebusData['tagbaru'],
|
||||||
|
"diskaun_rebate"=>$tebusData['diskaun_rebate'],
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -1672,6 +1676,53 @@ class TebusController extends Controller
|
|||||||
return response($rebet);
|
return response($rebet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function RebetPromoCalculation($kodcaw, Request $request)
|
||||||
|
{
|
||||||
|
$kodcaw = $request->kodcaw ?: $kodcaw;
|
||||||
|
if (!Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||||
|
return response(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
||||||
|
|
||||||
|
$rebet = Tebus::on($cawangan['mysql'])
|
||||||
|
->join('gadai as db2', 'tebus.norujukan', '=', 'db2.norujukan')
|
||||||
|
->where('tebus.t_tebus', '<=', $request->tarikh)
|
||||||
|
->where('db2.hargajualan', '>', '0')
|
||||||
|
->whereNotNull('db2.hargajualan')
|
||||||
|
->sum('diskaun_rebate');
|
||||||
|
|
||||||
|
return response($rebet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function PelarasanRebate($kodcaw, Request $request)
|
||||||
|
{
|
||||||
|
$kodcaw = $request->kodcaw ?: $kodcaw;
|
||||||
|
if (!Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||||
|
return response(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cawangan = Cawangan::on('mysql7')
|
||||||
|
->where('kodcaw', $kodcaw)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$tarikhLaporan = Carbon::parse($request->tarikh)->toDateString();
|
||||||
|
$tarikhTamatPelarasan = '2026-09-02';
|
||||||
|
$tarikhAkhir = $tarikhLaporan > $tarikhTamatPelarasan
|
||||||
|
? $tarikhTamatPelarasan
|
||||||
|
: $tarikhLaporan;
|
||||||
|
|
||||||
|
$rebet = Tebus::on($cawangan['mysql'])
|
||||||
|
->join('gadai as db2', 'tebus.norujukan', '=', 'db2.norujukan')
|
||||||
|
->whereDate('tebus.t_tebus', '>=', '2025-05-13')
|
||||||
|
->whereDate('tebus.t_tebus', '<=', $tarikhAkhir)
|
||||||
|
->where('db2.hargajualan', '>', 0)
|
||||||
|
->whereDate('db2.t_gadai', '>', '2023-05-21')
|
||||||
|
->sum('tebus.diskaun_rebate');
|
||||||
|
|
||||||
|
return response($rebet);
|
||||||
|
}
|
||||||
|
|
||||||
public function RebetCalculationLejer($kodcaw,Request $request)
|
public function RebetCalculationLejer($kodcaw,Request $request)
|
||||||
{
|
{
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||||
@@ -1687,6 +1738,26 @@ class TebusController extends Controller
|
|||||||
return response($rebet);
|
return response($rebet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function RebetPromoCalculationLejer($kodcaw, Request $request)
|
||||||
|
{
|
||||||
|
$kodcaw = $request->kodcaw ?: $kodcaw;
|
||||||
|
if (!Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||||
|
return response(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
||||||
|
|
||||||
|
$rebet = Tebus::on($cawangan['mysql'])
|
||||||
|
->join('gadai as db2', 'tebus.norujukan', '=', 'db2.norujukan')
|
||||||
|
->where('tebus.t_tebus', '>=', $request->mula)
|
||||||
|
->where('tebus.t_tebus', '<=', $request->hingga)
|
||||||
|
->where('db2.hargajualan', '>', '0')
|
||||||
|
->whereNotNull('db2.hargajualan')
|
||||||
|
->sum('diskaun_rebate');
|
||||||
|
|
||||||
|
return response($rebet);
|
||||||
|
}
|
||||||
|
|
||||||
public function getUpahLamaToday($kodcaw,$norujukan)
|
public function getUpahLamaToday($kodcaw,$norujukan)
|
||||||
{
|
{
|
||||||
$current = Carbon::now();
|
$current = Carbon::now();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use App\Vault;
|
|||||||
use Auth0\SDK\API\Management\Users;
|
use Auth0\SDK\API\Management\Users;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use App\Services\StaffNotificationClient;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
class TunaiController extends Controller
|
class TunaiController extends Controller
|
||||||
{
|
{
|
||||||
@@ -476,10 +477,54 @@ class TunaiController extends Controller
|
|||||||
$audit->updated_at = $current;
|
$audit->updated_at = $current;
|
||||||
$audit->save();
|
$audit->save();
|
||||||
|
|
||||||
|
$this->notifyKhazanahAliranTunai($kodcaw, $request, $reqteller);
|
||||||
|
|
||||||
return response()->json($reqteller,200);
|
return response()->json($reqteller,200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inbox for PC/PPC at the branch. Failures must not block the request.
|
||||||
|
*
|
||||||
|
* @param string $kodcaw
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \App\RequestTeller $reqteller
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function notifyKhazanahAliranTunai($kodcaw, Request $request, $reqteller)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
||||||
|
$namaCaw = $kodcaw;
|
||||||
|
if ($cawangan) {
|
||||||
|
$nama = trim((string) $cawangan->nama_cawangan);
|
||||||
|
if ($nama !== '') {
|
||||||
|
$namaCaw = $nama;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$modal = (float) $request->modal;
|
||||||
|
$serahan = (float) $request->serahan;
|
||||||
|
|
||||||
|
app(StaffNotificationClient::class)->notify([
|
||||||
|
'type' => 'aliran_tunai.pending_khazanah',
|
||||||
|
'cawangan' => $kodcaw,
|
||||||
|
'audience' => ['role' => 'pc'],
|
||||||
|
'data' => [
|
||||||
|
'request_no' => isset($reqteller->no) ? $reqteller->no : null,
|
||||||
|
'kodlaluan' => $request->kodlaluan,
|
||||||
|
'modal' => $modal,
|
||||||
|
'serahan' => $serahan,
|
||||||
|
'cawangan_nama' => $namaCaw,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::warning('Aliran tunai khazanah notification failed: '.$e->getMessage(), [
|
||||||
|
'kodcaw' => $kodcaw,
|
||||||
|
'kodlaluan' => $request->kodlaluan,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getTunaiSemalam($kodcaw)
|
public function getTunaiSemalam($kodcaw)
|
||||||
{
|
{
|
||||||
$current = new Carbon();
|
$current = new Carbon();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use App\GlDetail;
|
|||||||
use App\imbangdugalama;
|
use App\imbangdugalama;
|
||||||
use App\GlCode;
|
use App\GlCode;
|
||||||
use App\Panjar;
|
use App\Panjar;
|
||||||
|
use App\ModalOnline;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
@@ -168,37 +169,64 @@ class VaultController extends Controller
|
|||||||
return response()->json($updateVault, 200);
|
return response()->json($updateVault, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateVaultDeletePendahuluanSerahan($kodcaw, Request $request)
|
|
||||||
{
|
|
||||||
$current = Carbon::now();
|
|
||||||
$current = new Carbon();
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
|
||||||
|
|
||||||
$vault=Vault::on($cawangan['mysql'])->where('kodcaw','=',$kodcaw)->where('tarikh','=',$current->toDateString())->orderby('tarikh','desc')->first();
|
public function updateVaultDeletePendahuluanSerahan($kodcaw, Request $request)
|
||||||
|
{
|
||||||
|
$current = new Carbon();
|
||||||
|
|
||||||
$bakiawal = $vault['bakiawal'];
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
||||||
$keluar = $vault['keluar'];
|
|
||||||
$masuk = $vault['masuk'];
|
|
||||||
$bakiakhir = $vault['bakiakhir'];
|
|
||||||
$bakieod = $vault['bakieod'];
|
|
||||||
$pendahuluan = $vault['pendahuluan'];
|
|
||||||
$serahan = $vault['serahan'];
|
|
||||||
$totpanjaran = $vault['totpanjar'];
|
|
||||||
|
|
||||||
$glpend = GlDetail::on($cawangan['mysql'])->where('tarikh','=', $current->toDateString())->sum('pendahuluan');
|
if (!$cawangan) {
|
||||||
$glser = GlDetail::on($cawangan['mysql'])->where('tarikh','=', $current->toDateString())->where('teller','<>','ONLINE')->sum('serahan');
|
return response()->json(['message' => 'Cawangan tidak dijumpai'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
$bakiakhir = $bakiawal - $keluar + $masuk + $glpend - $glser - $totpanjaran;
|
$vault = Vault::on($cawangan['mysql'])
|
||||||
|
->where('kodcaw', '=', $kodcaw)
|
||||||
|
->where('tarikh', '=', $current->toDateString())
|
||||||
|
->first();
|
||||||
|
|
||||||
$updateVault=Vault::on($cawangan['mysql'])->where([['tarikh','=',$current->toDateString()],['kodcaw','=', $kodcaw]])->update(array(
|
if (!$vault) {
|
||||||
'pendahuluan' => $glpend,
|
return response()->json(['message' => 'Rekod vault hari ini tidak dijumpai'], 404);
|
||||||
'serahan' => $glser,
|
}
|
||||||
'bakiakhir'=>$bakiakhir,
|
|
||||||
'bakieod'=>$bakiakhir
|
|
||||||
));
|
|
||||||
|
|
||||||
return response()->json($updateVault, 200);
|
$bakiawal = $vault['bakiawal'];
|
||||||
}
|
$keluar = $vault['keluar'];
|
||||||
|
$masuk = $vault['masuk'];
|
||||||
|
$totpanjaran = $vault['totpanjar'];
|
||||||
|
|
||||||
|
// Pendahuluan HQ (dari GL)
|
||||||
|
$glpend = GlDetail::on($cawangan['mysql'])
|
||||||
|
->where('tarikh', '=', $current->toDateString())
|
||||||
|
->sum('pendahuluan');
|
||||||
|
|
||||||
|
// Serahan (GL, exclude teller ONLINE)
|
||||||
|
$glser = GlDetail::on($cawangan['mysql'])
|
||||||
|
->where('tarikh', '=', $current->toDateString())
|
||||||
|
->where('teller', '<>', 'ONLINE')
|
||||||
|
->sum('serahan');
|
||||||
|
|
||||||
|
// Pendahuluan Online (had yang diluluskan hari ini)
|
||||||
|
$modalOnlineHad = ModalOnline::on($cawangan['mysql'])
|
||||||
|
->where('kodcaw', '=', $kodcaw)
|
||||||
|
->where('tarikh', '=', $current->toDateString())
|
||||||
|
->value('had') ?? 0;
|
||||||
|
|
||||||
|
// Gabungan pendahuluan HQ + pendahuluan online
|
||||||
|
$totalPendahuluan = $glpend + $modalOnlineHad;
|
||||||
|
|
||||||
|
$bakiakhir = $bakiawal - $keluar + $masuk + $totalPendahuluan - $glser - $totpanjaran;
|
||||||
|
|
||||||
|
$updateVault = Vault::on($cawangan['mysql'])
|
||||||
|
->where([['tarikh', '=', $current->toDateString()], ['kodcaw', '=', $kodcaw]])
|
||||||
|
->update([
|
||||||
|
'pendahuluan' => $totalPendahuluan,
|
||||||
|
'serahan' => $glser,
|
||||||
|
'bakiakhir' => $bakiakhir,
|
||||||
|
'bakieod' => $bakiakhir,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json($updateVault, 200);
|
||||||
|
}
|
||||||
|
|
||||||
public function create($kodcaw,Request $request)
|
public function create($kodcaw,Request $request)
|
||||||
{
|
{
|
||||||
@@ -481,25 +509,24 @@ class VaultController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function CalculationPendahuluanSerahan($kodcaw,Request $request)
|
public function CalculationPendahuluanSerahan($kodcaw,Request $request)
|
||||||
{
|
{
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
$serahanpkb = '1000/020';
|
$serahanpkb = '1000/020';
|
||||||
$serahanjmc = '1000/026';
|
$serahanjmc = '1000/026';
|
||||||
$pendahuluanpkb = '7000/102';
|
$pendahuluanpkb = '7000/102';
|
||||||
$pendahuluanjmc = '7000/106';
|
$pendahuluanjmc = '7000/106';
|
||||||
$serahankoperasi = '1000/090';
|
$serahankoperasi = '1000/090';
|
||||||
|
|
||||||
//Selepas Tawarruq
|
//Selepas Tawarruq
|
||||||
|
|
||||||
$serahanpkbTawarruq = GlDetail::on($cawangan['mysql'])
|
$serahanpkbTawarruq = GlDetail::on($cawangan['mysql'])
|
||||||
->where('ktacct','=',$serahanpkb)
|
->where('ktacct','=',$serahanpkb)
|
||||||
->where('tarikh','<=', $request->tarikh)
|
->where('tarikh','<=', $request->tarikh)
|
||||||
->where('tarikh','>','2021-03-24')
|
->where('tarikh','>','2021-03-24')
|
||||||
->sum('serahan');
|
->sum('serahan');
|
||||||
|
|
||||||
|
//Sebelum Tawarruq
|
||||||
//Sebelum Tawarruq
|
|
||||||
if($kodcaw == 'KB2' || $kodcaw == 'WCY' || $kodcaw == '1STOP' || $kodcaw == 'ARM' || $kodcaw == 'APM' || $kodcaw == '010621' || $kodcaw == '010915' || $kodcaw == '020303')
|
if($kodcaw == 'KB2' || $kodcaw == 'WCY' || $kodcaw == '1STOP' || $kodcaw == 'ARM' || $kodcaw == 'APM' || $kodcaw == '010621' || $kodcaw == '010915' || $kodcaw == '020303')
|
||||||
{
|
{
|
||||||
$serahanpkb = GlDetail::on($cawangan['mysql'])
|
$serahanpkb = GlDetail::on($cawangan['mysql'])
|
||||||
@@ -546,47 +573,53 @@ class VaultController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Selepas Tawarruq
|
//Selepas Tawarruq
|
||||||
|
|
||||||
$pendahuluanPKBtawarruq = GlDetail::on($cawangan['mysql'])
|
$pendahuluanPKBtawarruq = GlDetail::on($cawangan['mysql'])
|
||||||
->where('ktacct','=',$pendahuluanpkb)
|
->where('ktacct','=',$pendahuluanpkb)
|
||||||
->where([['tarikh','<=', $request->tarikh],['tarikh','>','2021-03-24']])
|
->where([['tarikh','<=', $request->tarikh],['tarikh','>','2021-03-24']])
|
||||||
->sum('pendahuluan');
|
->sum('pendahuluan');
|
||||||
|
|
||||||
//Sebelum Tawarruq
|
//Sebelum Tawarruq
|
||||||
|
|
||||||
$pendahuluanPKB = GlDetail::on($cawangan['mysql'])
|
$pendahuluanPKB = GlDetail::on($cawangan['mysql'])
|
||||||
->where('ktacct','=',$pendahuluanpkb)
|
->where('ktacct','=',$pendahuluanpkb)
|
||||||
->where([['tarikh','<=', $request->tarikh],['tarikh','>','2013-12-31']])
|
->where([['tarikh','<=', $request->tarikh],['tarikh','>','2013-12-31']])
|
||||||
->sum('amaun');
|
|
||||||
|
|
||||||
$pendahuluanJMC = GlDetail::on($cawangan['mysql'])
|
|
||||||
->where('ktacct','=','7000/106')
|
|
||||||
->where([['tarikh','<=', $request->tarikh],['tarikh','>','2013-12-31']])
|
|
||||||
->sum('amaun');
|
|
||||||
|
|
||||||
$pendahuluanpkblama = imbangdugalama::on($cawangan['mysql'])
|
|
||||||
->sum('pendahuluan_pkb');
|
|
||||||
|
|
||||||
$pendahuluanjmclama = imbangdugalama::on($cawangan['mysql'])
|
|
||||||
->sum('pendahuluan_jmc');
|
|
||||||
|
|
||||||
$total = $pendahuluanPKBtawarruq + $pendahuluanjmclama + $pendahuluanpkblama + $pendahuluanPKB + $pendahuluanJMC;
|
|
||||||
|
|
||||||
$pindahkekpkb = GlCode::on($cawangan['mysql'])
|
|
||||||
->where('glcode','=',$serahankoperasi)
|
|
||||||
->sum('amaun');
|
->sum('amaun');
|
||||||
|
|
||||||
if($kodcaw == '011229')
|
$pendahuluanJMC = GlDetail::on($cawangan['mysql'])
|
||||||
$totalserahan -= 0.10;
|
->where('ktacct','=','7000/106')
|
||||||
|
->where([['tarikh','<=', $request->tarikh],['tarikh','>','2013-12-31']])
|
||||||
|
->sum('amaun');
|
||||||
|
|
||||||
if($kodcaw == '011013')
|
$pendahuluanpkblama = imbangdugalama::on($cawangan['mysql'])
|
||||||
$totalserahan += 641000;
|
->sum('pendahuluan_pkb');
|
||||||
|
|
||||||
$arraypend = ['pendahuluan' => $total,'serahan' => $totalserahan,'pindahkekpkb' => $pindahkekpkb];
|
$pendahuluanjmclama = imbangdugalama::on($cawangan['mysql'])
|
||||||
|
->sum('pendahuluan_jmc');
|
||||||
|
|
||||||
return response()->json($arraypend);
|
//Pendahuluan Online (had)
|
||||||
}
|
$modalOnlineHad = ModalOnline::on($cawangan['mysql'])
|
||||||
|
->where('kodcaw','=', $kodcaw)
|
||||||
|
->where('tarikh','=', $request->tarikh)
|
||||||
|
->value('had') ?? 0;
|
||||||
|
|
||||||
|
$total = $pendahuluanPKBtawarruq + $pendahuluanjmclama + $pendahuluanpkblama + $pendahuluanPKB + $pendahuluanJMC + $modalOnlineHad;
|
||||||
|
|
||||||
|
$pindahkekpkb = GlCode::on($cawangan['mysql'])
|
||||||
|
->where('glcode','=',$serahankoperasi)
|
||||||
|
->sum('amaun');
|
||||||
|
|
||||||
|
if($kodcaw == '011229')
|
||||||
|
$totalserahan -= 0.10;
|
||||||
|
|
||||||
|
if($kodcaw == '011013')
|
||||||
|
$totalserahan += 641000;
|
||||||
|
|
||||||
|
$arraypend = ['pendahuluan' => $total,'serahan' => $totalserahan,'pindahkekpkb' => $pindahkekpkb];
|
||||||
|
|
||||||
|
return response()->json($arraypend);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function CalculationPendahuluanSerahanLejer($kodcaw,Request $request)
|
public function CalculationPendahuluanSerahanLejer($kodcaw,Request $request)
|
||||||
@@ -732,5 +765,19 @@ class VaultController extends Controller
|
|||||||
|
|
||||||
return response()->json($vault);
|
return response()->json($vault);
|
||||||
}
|
}
|
||||||
|
public function CalculationModalOnlineLejer($kodcaw, Request $request)
|
||||||
|
{
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
|
$tarikh = $request->hingga;
|
||||||
|
|
||||||
|
$modal_online = ModalOnline::on($cawangan['mysql'])
|
||||||
|
->where('kodcaw', '=', $kodcaw)
|
||||||
|
->where('tarikh', '=', $tarikh)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'had' => $modal_online ? floatval($modal_online->had) : 0,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Meta WhatsApp Cloud webhook: verify challenge + acknowledge events.
|
||||||
|
* Sufficient for production onboarding; delivery statuses are logged only.
|
||||||
|
*/
|
||||||
|
class WhatsappWebhookController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* GET /api/whatsapp/webhook
|
||||||
|
* Meta sends hub.mode, hub.verify_token, hub.challenge.
|
||||||
|
*/
|
||||||
|
public function verify(Request $request)
|
||||||
|
{
|
||||||
|
$mode = $request->query('hub_mode', $request->query('hub.mode'));
|
||||||
|
$token = $request->query('hub_verify_token', $request->query('hub.verify_token'));
|
||||||
|
$challenge = $request->query('hub_challenge', $request->query('hub.challenge'));
|
||||||
|
|
||||||
|
$expected = (string) config('whatsapp.verify_token');
|
||||||
|
|
||||||
|
if ($mode === 'subscribe' && $expected !== '' && hash_equals($expected, (string) $token)) {
|
||||||
|
Log::info('WhatsApp webhook verified');
|
||||||
|
return response((string) $challenge, 200)
|
||||||
|
->header('Content-Type', 'text/plain');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::warning('WhatsApp webhook verify failed', [
|
||||||
|
'mode' => $mode,
|
||||||
|
'token_match' => $expected !== '' && hash_equals($expected, (string) $token),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response('Forbidden', 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/whatsapp/webhook
|
||||||
|
* Acknowledge quickly; optionally check X-Hub-Signature-256 when app secret is set.
|
||||||
|
*/
|
||||||
|
public function handle(Request $request)
|
||||||
|
{
|
||||||
|
$raw = $request->getContent();
|
||||||
|
|
||||||
|
if (!$this->signatureOk($request, $raw)) {
|
||||||
|
Log::warning('WhatsApp webhook invalid signature');
|
||||||
|
return response('Invalid signature', 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$payload = json_decode($raw, true);
|
||||||
|
if (!is_array($payload)) {
|
||||||
|
return response('OK', 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->logEvents($payload);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('WhatsApp webhook log failed: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return response('OK', 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function signatureOk(Request $request, $raw)
|
||||||
|
{
|
||||||
|
$secret = trim((string) config('whatsapp.app_secret'));
|
||||||
|
if ($secret === '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$header = (string) $request->header('X-Hub-Signature-256', '');
|
||||||
|
if ($header === '' || strpos($header, 'sha256=') !== 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$expected = 'sha256=' . hash_hmac('sha256', $raw, $secret);
|
||||||
|
|
||||||
|
return hash_equals($expected, $header);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function logEvents(array $payload)
|
||||||
|
{
|
||||||
|
$entries = $payload['entry'] ?? [];
|
||||||
|
if (!is_array($entries)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($entries as $entry) {
|
||||||
|
$changes = $entry['changes'] ?? [];
|
||||||
|
if (!is_array($changes)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($changes as $change) {
|
||||||
|
$value = $change['value'] ?? [];
|
||||||
|
if (!is_array($value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($value['statuses'] ?? [] as $status) {
|
||||||
|
Log::info('WhatsApp status', [
|
||||||
|
'id' => $status['id'] ?? null,
|
||||||
|
'status' => $status['status'] ?? null,
|
||||||
|
'recipient' => $status['recipient_id'] ?? null,
|
||||||
|
'errors' => $status['errors'] ?? null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($value['messages'] ?? [] as $message) {
|
||||||
|
Log::info('WhatsApp inbound', [
|
||||||
|
'from' => $message['from'] ?? null,
|
||||||
|
'type' => $message['type'] ?? null,
|
||||||
|
'id' => $message['id'] ?? null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
|
||||||
|
class LogViewerPassword
|
||||||
|
{
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
$passwordHash = config('logviewer.password');
|
||||||
|
|
||||||
|
if (!is_string($passwordHash) || $passwordHash === '') {
|
||||||
|
return response('Akses log belum dikonfigurasi.', 503)
|
||||||
|
->header('Cache-Control', 'no-store');
|
||||||
|
}
|
||||||
|
|
||||||
|
$provided = $request->getPassword();
|
||||||
|
if ($request->getUser() !== 'logviewer' || !is_string($provided) ||
|
||||||
|
!password_verify($provided, $passwordHash)) {
|
||||||
|
return response('Kata laluan diperlukan untuk mengakses log.', 401, [
|
||||||
|
'WWW-Authenticate' => 'Basic realm="Log Viewer", charset="UTF-8"',
|
||||||
|
'Cache-Control' => 'no-store',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $next($request);
|
||||||
|
$response->headers->set('Cache-Control', 'no-store');
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\BlastWasap;
|
||||||
|
use App\Customer;
|
||||||
|
use App\Services\Whatsapp\WhatsappCloudClient;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class WhatsappPembiayaanOnlinePaid extends Job
|
||||||
|
{
|
||||||
|
public $kodcaw;
|
||||||
|
public $cawName;
|
||||||
|
public $nokp;
|
||||||
|
public $norujukan;
|
||||||
|
public $pinjaman;
|
||||||
|
public $namaBank;
|
||||||
|
public $noakaun;
|
||||||
|
public $tarikhBayaran;
|
||||||
|
public $noRujukanBayaran;
|
||||||
|
|
||||||
|
public function __construct(array $data)
|
||||||
|
{
|
||||||
|
$this->kodcaw = $data['kodcaw'] ?? null;
|
||||||
|
$this->cawName = $data['caw_name'] ?? null;
|
||||||
|
$this->nokp = $data['nokp'] ?? null;
|
||||||
|
$this->norujukan = $data['norujukan'] ?? null;
|
||||||
|
$this->pinjaman = $data['pinjaman'] ?? null;
|
||||||
|
$this->namaBank = $data['nama_bank'] ?? null;
|
||||||
|
$this->noakaun = $data['noakaun'] ?? null;
|
||||||
|
$this->tarikhBayaran = $data['tarikh_bayaran'] ?? null;
|
||||||
|
$this->noRujukanBayaran = $data['no_rujukan_bayaran'] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$client = new WhatsappCloudClient();
|
||||||
|
$now = Carbon::now();
|
||||||
|
|
||||||
|
if (!$client->isConfigured()) {
|
||||||
|
Log::warning('WhatsApp Cloud skipped: token or phone_number_id missing', [
|
||||||
|
'norujukan' => $this->norujukan,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$customer = Customer::on('mysql7')
|
||||||
|
->where(function ($q) {
|
||||||
|
$q->where('kpbaru', $this->nokp)->orWhere('kplama', $this->nokp);
|
||||||
|
})
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$storedPhone = $customer ? ($customer->telefon ?: $customer->telefon2) : null;
|
||||||
|
$to = $client->normalizeMsisdn($storedPhone);
|
||||||
|
|
||||||
|
if (!config('whatsapp.whatsapp_cloud_enabled')) {
|
||||||
|
$admin = $client->normalizeMsisdn(env('ADMIN_PHONE_NUMBER'));
|
||||||
|
if (!$admin) {
|
||||||
|
Log::warning('WhatsApp Cloud skipped: ADMIN_PHONE_NUMBER required when WHATSAPP_ENABLED is false', [
|
||||||
|
'norujukan' => $this->norujukan,
|
||||||
|
]);
|
||||||
|
$this->logBlast($now, $storedPhone, 'skipped: ADMIN_PHONE_NUMBER empty');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$to = $admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$to) {
|
||||||
|
Log::warning('WhatsApp Cloud skipped: no phone', [
|
||||||
|
'nokp' => $this->nokp,
|
||||||
|
'norujukan' => $this->norujukan,
|
||||||
|
]);
|
||||||
|
$this->logBlast($now, $storedPhone, 'skipped: no phone');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$template = config('whatsapp.template', 'hello_world');
|
||||||
|
$lang = config('whatsapp.template_lang', 'en_US');
|
||||||
|
$bodyParams = $this->isHelloWorld($template) ? [] : $this->bodyParams();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $client->sendTemplate($to, $template, $lang, $bodyParams);
|
||||||
|
$this->logBlast($now, $to, $response->body());
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('WhatsappPembiayaanOnlinePaid failed: ' . $e->getMessage(), [
|
||||||
|
'norujukan' => $this->norujukan,
|
||||||
|
]);
|
||||||
|
$this->logBlast($now, $to, 'exception: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isHelloWorld($template)
|
||||||
|
{
|
||||||
|
return strtolower((string) $template) === 'hello_world';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matches Meta template pembiayaan_online_paid (ms):
|
||||||
|
* AR-RAHN KoPKB: Pembiayaan bagi No. SAG *{{1}}* sebanyak *RM{{2}}*
|
||||||
|
* telah berjaya dikreditkan ke akaun *{{3}}* berakhir *{{4}}* pada *{{5}}*.
|
||||||
|
* Rujukan: *{{6}}*
|
||||||
|
*
|
||||||
|
* {{1}} SAG, {{2}} amaun, {{3}} nama bank/akaun, {{4}} 4 digit akhir, {{5}} tarikh, {{6}} rujukan bayaran
|
||||||
|
*
|
||||||
|
* @return array<int,string>
|
||||||
|
*/
|
||||||
|
protected function bodyParams()
|
||||||
|
{
|
||||||
|
$bank = trim((string) $this->namaBank);
|
||||||
|
$tail = $this->accountTail($this->noakaun);
|
||||||
|
|
||||||
|
$tarikh = $this->tarikhBayaran
|
||||||
|
? Carbon::parse($this->tarikhBayaran)->format('d/m/Y')
|
||||||
|
: Carbon::now()->format('d/m/Y');
|
||||||
|
|
||||||
|
return [
|
||||||
|
$this->norujukan ?: '-',
|
||||||
|
number_format((float) $this->pinjaman, 2, '.', ''),
|
||||||
|
$bank !== '' ? $bank : '-',
|
||||||
|
$tail !== '' ? $tail : '-',
|
||||||
|
$tarikh,
|
||||||
|
$this->noRujukanBayaran ?: '-',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function accountTail($noakaun)
|
||||||
|
{
|
||||||
|
$digits = preg_replace('/\D+/', '', (string) $noakaun);
|
||||||
|
if ($digits === '') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return substr($digits, -4);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function logBlast($now, $telefon, $status)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$log = new BlastWasap();
|
||||||
|
$log->kodcaw = $this->kodcaw;
|
||||||
|
$log->nokp = $this->nokp;
|
||||||
|
$log->notelefon = $telefon;
|
||||||
|
$log->norujukan = $this->norujukan;
|
||||||
|
$log->status = is_string($status) ? $status : json_encode($status);
|
||||||
|
$log->created_at = $now;
|
||||||
|
$log->updated_at = $now;
|
||||||
|
$log->save();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('log_blast_wasap save failed: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class KadarRebet extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'kadar_rebet';
|
||||||
|
protected $connection = 'mysql7';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'pembiayaan_min',
|
||||||
|
'pembiayaan_max',
|
||||||
|
'kadarrebet',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -32,6 +32,8 @@ class PembiayaanOnline extends Model
|
|||||||
'paid_at',
|
'paid_at',
|
||||||
'created_by',
|
'created_by',
|
||||||
'pc_submitted_by',
|
'pc_submitted_by',
|
||||||
|
'pc_verified_by',
|
||||||
|
'pc_verified_at',
|
||||||
'ops_by',
|
'ops_by',
|
||||||
'nota',
|
'nota',
|
||||||
'blast_sent',
|
'blast_sent',
|
||||||
|
|||||||
@@ -0,0 +1,193 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Bsas;
|
||||||
|
|
||||||
|
use Illuminate\Http\Client\PendingRequest;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
class BsasClient
|
||||||
|
{
|
||||||
|
const TOKEN_CACHE_KEY = 'bsas.oauth.token';
|
||||||
|
const TOKEN_CACHE_SECONDS = 82800; // 23 hours
|
||||||
|
|
||||||
|
public function getAccessToken(): string
|
||||||
|
{
|
||||||
|
$cached = Cache::get(self::TOKEN_CACHE_KEY);
|
||||||
|
if (is_string($cached) && $cached !== '') {
|
||||||
|
return $cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Drop bad cache entries (e.g. whole JSON array accidentally stored).
|
||||||
|
if ($cached !== null) {
|
||||||
|
Cache::forget(self::TOKEN_CACHE_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tokenUrl = config('bsas.token_url');
|
||||||
|
$clientId = config('bsas.client_id');
|
||||||
|
$clientSecret = config('bsas.client_secret');
|
||||||
|
|
||||||
|
if (!$tokenUrl || !$clientId || !$clientSecret) {
|
||||||
|
throw new RuntimeException('BSAS OAuth is not configured (token_url / client_id / client_secret).');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $this->http()
|
||||||
|
->asForm()
|
||||||
|
->post($tokenUrl, [
|
||||||
|
'grant_type' => 'client_credentials',
|
||||||
|
'client_id' => $clientId,
|
||||||
|
'client_secret' => $clientSecret,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = $response->json();
|
||||||
|
if (!is_array($payload)) {
|
||||||
|
$payload = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$response->successful()) {
|
||||||
|
Log::error('BSAS OAuth token request failed', [
|
||||||
|
'status' => $response->status(),
|
||||||
|
'body' => $payload ?: $response->body(),
|
||||||
|
]);
|
||||||
|
throw new RuntimeException('Gagal mendapatkan BSAS access token.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = $payload['access_token'] ?? null;
|
||||||
|
if (!is_string($token) || $token === '') {
|
||||||
|
Log::error('BSAS OAuth response missing string access_token', [
|
||||||
|
'body' => $payload,
|
||||||
|
]);
|
||||||
|
throw new RuntimeException('BSAS OAuth response missing access_token.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$expiresIn = (int) ($payload['expires_in'] ?? self::TOKEN_CACHE_SECONDS);
|
||||||
|
$ttl = max(60, min(self::TOKEN_CACHE_SECONDS, $expiresIn - 300));
|
||||||
|
Cache::put(self::TOKEN_CACHE_KEY, $token, $ttl);
|
||||||
|
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function placeOrder(array $payload): array
|
||||||
|
{
|
||||||
|
return $this->requestJson('post', '/process/svc/bsas/order', $payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function orderResult(string $uuid, array $body = []): array
|
||||||
|
{
|
||||||
|
$maxWait = (string) ($body['maxWaitTime'] ?? config('bsas.max_wait_time', 10));
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'header' => [
|
||||||
|
'memberShortName' => config('bsas.member_short_name'),
|
||||||
|
'uuid' => $uuid,
|
||||||
|
],
|
||||||
|
'body' => [
|
||||||
|
'serialNumbers' => (string) ($body['serialNumbers'] ?? '1'),
|
||||||
|
'forceYN' => (string) ($body['forceYN'] ?? 'Y'),
|
||||||
|
'maxWaitTime' => $maxWait,
|
||||||
|
'waitAllDoneYN' => (string) ($body['waitAllDoneYN'] ?? 'Y'),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Long poll: client timeout must exceed BSAS maxWaitTime.
|
||||||
|
$timeout = max(
|
||||||
|
(int) config('bsas.http_timeout', 30),
|
||||||
|
(int) $maxWait + 20
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->requestJson('get', '/process/svc/bsas/orderResult', $payload, $timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBidEcert(string $ecertNo): array
|
||||||
|
{
|
||||||
|
return $this->requestEcert('/process/svc/bsas/bidXML', $ecertNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOtcEcert(string $ecertNo): array
|
||||||
|
{
|
||||||
|
return $this->requestEcert('/process/svc/bsas/otcXML', $ecertNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStbEcert(string $ecertNo): array
|
||||||
|
{
|
||||||
|
return $this->requestEcert('/process/svc/bsas/stbXML', $ecertNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function requestEcert(string $path, string $ecertNo): array
|
||||||
|
{
|
||||||
|
$payload = [
|
||||||
|
'input' => [
|
||||||
|
'ecertno' => $ecertNo,
|
||||||
|
'membershortname' => config('bsas.member_short_name'),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->requestJson('get', $path, $payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function requestJson(string $method, string $path, array $payload, ?int $timeout = null): array
|
||||||
|
{
|
||||||
|
$url = rtrim(config('bsas.base_url'), '/') . '/' . ltrim($path, '/');
|
||||||
|
$timeout = $timeout ?? (int) config('bsas.http_timeout', 30);
|
||||||
|
$token = $this->getAccessToken();
|
||||||
|
|
||||||
|
$pending = $this->http($timeout)
|
||||||
|
->withToken($token)
|
||||||
|
->acceptJson();
|
||||||
|
|
||||||
|
if (strtolower($method) === 'get') {
|
||||||
|
$response = $pending
|
||||||
|
->withHeaders(['Content-Type' => 'application/json'])
|
||||||
|
->send('GET', $url, [
|
||||||
|
'body' => json_encode($payload),
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$response = $pending->asJson()->post($url, $payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
if (!is_array($json)) {
|
||||||
|
$body = $response->body();
|
||||||
|
$cloudflare = stripos($body, 'cloudflare') !== false || stripos($body, 'Attention Required') !== false;
|
||||||
|
|
||||||
|
if ($cloudflare) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
'BSAS blocked by Cloudflare (check IP whitelist). HTTP ' . $response->status()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException('BSAS returned invalid JSON response.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$response->successful()) {
|
||||||
|
Log::error('BSAS HTTP error', [
|
||||||
|
'method' => $method,
|
||||||
|
'url' => $url,
|
||||||
|
'status' => $response->status(),
|
||||||
|
'body' => $json,
|
||||||
|
]);
|
||||||
|
throw new RuntimeException('BSAS request failed (HTTP ' . $response->status() . ').');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('BSAS API call', [
|
||||||
|
'method' => $method,
|
||||||
|
'path' => $path,
|
||||||
|
'status' => $response->status(),
|
||||||
|
'header' => $json['header'] ?? null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $json;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function http(?int $timeout = null): PendingRequest
|
||||||
|
{
|
||||||
|
$timeout = $timeout ?? (int) config('bsas.http_timeout', 30);
|
||||||
|
|
||||||
|
return Http::withOptions([
|
||||||
|
'timeout' => $timeout,
|
||||||
|
'connect_timeout' => min(15, $timeout),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,374 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Bsas;
|
||||||
|
|
||||||
|
use App\BsasOrder;
|
||||||
|
use App\KomuditiTransaksi;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
class BsasOrderService
|
||||||
|
{
|
||||||
|
/** @var BsasClient */
|
||||||
|
protected $client;
|
||||||
|
|
||||||
|
public function __construct(BsasClient $client = null)
|
||||||
|
{
|
||||||
|
$this->client = $client ?: new BsasClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place BSAS order for a gadai Terima, long-poll result, fetch eCert.
|
||||||
|
*
|
||||||
|
* @param array $input norujukan, kodcaw, pinjaman, hargajualan, nama_pelanggan, teller
|
||||||
|
* @return BsasOrder
|
||||||
|
*/
|
||||||
|
public function placeAndConfirm(array $input): BsasOrder
|
||||||
|
{
|
||||||
|
$norujukan = (string) ($input['norujukan'] ?? '');
|
||||||
|
$kodcaw = (string) ($input['kodcaw'] ?? '');
|
||||||
|
$pinjaman = round((float) ($input['pinjaman'] ?? 0), 2);
|
||||||
|
$hargajualan = round((float) ($input['hargajualan'] ?? 0), 2);
|
||||||
|
$counterParty = trim((string) ($input['nama_pelanggan'] ?? ''));
|
||||||
|
$createdBy = (string) ($input['teller'] ?? '');
|
||||||
|
|
||||||
|
if ($norujukan === '' || $kodcaw === '' || $pinjaman <= 0) {
|
||||||
|
throw new RuntimeException('BSAS order requires norujukan, kodcaw and pinjaman.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$existing = BsasOrder::on('mysql7')
|
||||||
|
->where('norujukan', $norujukan)
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($existing && $existing->status === 'confirmed') {
|
||||||
|
if ($this->needsEcertFetch($existing)) {
|
||||||
|
$this->fetchAndStoreEcert($existing);
|
||||||
|
}
|
||||||
|
$this->ensureKomuditiTransaksi($existing, $createdBy);
|
||||||
|
return $existing->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($existing && in_array($existing->status, ['pending', 'submitted'], true) && !empty($existing->uuid)) {
|
||||||
|
return $this->completeSubmittedOrder($existing, $createdBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
$serial = '1';
|
||||||
|
$payload = $this->buildOrderPayload($pinjaman, $hargajualan, $counterParty, $serial);
|
||||||
|
|
||||||
|
$order = BsasOrder::on('mysql7')->create([
|
||||||
|
'uuid' => null,
|
||||||
|
'norujukan' => $norujukan,
|
||||||
|
'kodcaw' => $kodcaw,
|
||||||
|
'serial_number' => $serial,
|
||||||
|
'product_code' => config('bsas.product_code'),
|
||||||
|
'bid_value' => $pinjaman,
|
||||||
|
'otc_murabaha_value' => $hargajualan,
|
||||||
|
'otc_counter_party' => $counterParty,
|
||||||
|
'status' => 'pending',
|
||||||
|
'request_payload' => $payload,
|
||||||
|
'created_by' => $createdBy,
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$orderResponse = $this->client->placeOrder($payload);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$order->status = 'failed';
|
||||||
|
$order->status_message = $e->getMessage();
|
||||||
|
$order->save();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
$order->order_response = $orderResponse;
|
||||||
|
$uuid = data_get($orderResponse, 'header.uuid');
|
||||||
|
$errorCode = trim((string) data_get($orderResponse, 'header.errorCode', ''));
|
||||||
|
$errorMsg = trim((string) data_get($orderResponse, 'header.errorMsg', ''));
|
||||||
|
|
||||||
|
if ($errorCode !== '' || !$uuid) {
|
||||||
|
$order->status = 'failed';
|
||||||
|
$order->status_message = $errorMsg !== '' ? $errorMsg : 'BSAS order rejected (missing uuid or errorCode set).';
|
||||||
|
$order->save();
|
||||||
|
throw new RuntimeException($order->status_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$bodyStatus = data_get($orderResponse, 'body.0.statusCode');
|
||||||
|
if ($bodyStatus !== null && (int) $bodyStatus !== 0) {
|
||||||
|
$order->uuid = $uuid;
|
||||||
|
$order->status = 'failed';
|
||||||
|
$order->status_code = (int) $bodyStatus;
|
||||||
|
$order->status_message = (string) data_get($orderResponse, 'body.0.statusMessage', 'BSAS order body statusCode != 0');
|
||||||
|
$order->save();
|
||||||
|
throw new RuntimeException($order->status_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$order->uuid = $uuid;
|
||||||
|
$order->status = 'submitted';
|
||||||
|
$order->save();
|
||||||
|
|
||||||
|
return $this->completeSubmittedOrder($order, $createdBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-query orderResult / eCert for an existing uuid.
|
||||||
|
*/
|
||||||
|
public function refreshByUuid(string $uuid): BsasOrder
|
||||||
|
{
|
||||||
|
$order = BsasOrder::on('mysql7')->where('uuid', $uuid)->first();
|
||||||
|
if (!$order) {
|
||||||
|
throw new RuntimeException('BSAS order not found for uuid.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order->status === 'confirmed') {
|
||||||
|
if ($this->needsEcertFetch($order)) {
|
||||||
|
$this->fetchAndStoreEcert($order);
|
||||||
|
}
|
||||||
|
return $order->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->completeSubmittedOrder($order, (string) $order->created_by);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function completeSubmittedOrder(BsasOrder $order, string $createdBy): BsasOrder
|
||||||
|
{
|
||||||
|
if (empty($order->uuid)) {
|
||||||
|
throw new RuntimeException('BSAS order has no uuid to poll.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->longPollOrderResult($order->uuid, (string) $order->serial_number);
|
||||||
|
$order->result_response = $result;
|
||||||
|
|
||||||
|
$headerError = trim((string) data_get($result, 'header.errorCode', ''));
|
||||||
|
$headerMsg = trim((string) data_get($result, 'header.errorMsg', ''));
|
||||||
|
$statusCode = data_get($result, 'body.0.statusCode');
|
||||||
|
$statusMessage = (string) data_get($result, 'body.0.statusMessage', '');
|
||||||
|
$bidErrNo = trim((string) data_get($result, 'body.0.bidErrNo', ''));
|
||||||
|
$otcErrNo = trim((string) data_get($result, 'body.0.otcErrNo', ''));
|
||||||
|
$stbErrNo = trim((string) data_get($result, 'body.0.stbErrNo', ''));
|
||||||
|
$bidMsg = trim((string) data_get($result, 'body.0.bidMsg', ''));
|
||||||
|
$otcMsg = trim((string) data_get($result, 'body.0.otcMsg', ''));
|
||||||
|
$stbMsg = trim((string) data_get($result, 'body.0.stbMsg', ''));
|
||||||
|
$ecertNo = $this->extractEcertNo($result, $order->order_response);
|
||||||
|
|
||||||
|
if ($headerError !== '') {
|
||||||
|
$order->status = 'failed';
|
||||||
|
$order->status_code = is_numeric($statusCode) ? (int) $statusCode : null;
|
||||||
|
$order->status_message = $headerMsg !== '' ? $headerMsg : 'BSAS orderResult header errorCode set.';
|
||||||
|
$order->save();
|
||||||
|
throw new RuntimeException($order->status_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Live BSAS result often has no statusCode; success is ecertNo and/or bid/otc/stb ErrNo=999 (OK).
|
||||||
|
$successByStatusCode = $statusCode !== null && (int) $statusCode === 0;
|
||||||
|
$successByErrNo = ($bidErrNo === '999' || strtoupper($bidMsg) === 'OK')
|
||||||
|
&& ($otcErrNo === '999' || strtoupper($otcMsg) === 'OK')
|
||||||
|
&& ($stbErrNo === '999' || strtoupper($stbMsg) === 'OK');
|
||||||
|
$successByEcert = $ecertNo !== null && $ecertNo !== '';
|
||||||
|
|
||||||
|
if (!$successByStatusCode && !$successByErrNo && !$successByEcert) {
|
||||||
|
if ($statusCode !== null && (int) $statusCode !== 0) {
|
||||||
|
$order->status = 'failed';
|
||||||
|
$order->status_code = (int) $statusCode;
|
||||||
|
$order->status_message = $statusMessage !== '' ? $statusMessage : 'BSAS orderResult statusCode != 0';
|
||||||
|
$order->save();
|
||||||
|
throw new RuntimeException($order->status_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$order->status = 'submitted';
|
||||||
|
$order->status_message = 'BSAS orderResult belum selesai / tiada ecert.';
|
||||||
|
$order->save();
|
||||||
|
throw new RuntimeException('BSAS orderResult belum selesai. Sila cuba semula.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$order->status_code = $statusCode !== null ? (int) $statusCode : 0;
|
||||||
|
$order->status_message = $statusMessage !== '' ? $statusMessage : ($bidMsg ?: 'OK');
|
||||||
|
$order->status = 'confirmed';
|
||||||
|
if ($ecertNo) {
|
||||||
|
$order->e_cert_no = $ecertNo;
|
||||||
|
}
|
||||||
|
$order->save();
|
||||||
|
|
||||||
|
if ($this->needsEcertFetch($order)) {
|
||||||
|
$this->fetchAndStoreEcert($order);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($order->e_cert_no)) {
|
||||||
|
Log::warning('BSAS order confirmed but ecertno missing', [
|
||||||
|
'norujukan' => $order->norujukan,
|
||||||
|
'uuid' => $order->uuid,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ensureKomuditiTransaksi($order, $createdBy);
|
||||||
|
|
||||||
|
return $order->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function longPollOrderResult(string $uuid, string $serial): array
|
||||||
|
{
|
||||||
|
$retries = max(1, (int) config('bsas.order_result_retries', 2));
|
||||||
|
$last = [];
|
||||||
|
|
||||||
|
for ($i = 0; $i < $retries; $i++) {
|
||||||
|
$last = $this->client->orderResult($uuid, [
|
||||||
|
'serialNumbers' => $serial,
|
||||||
|
'forceYN' => 'Y',
|
||||||
|
'maxWaitTime' => (string) config('bsas.max_wait_time', 10),
|
||||||
|
'waitAllDoneYN' => 'Y',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Done when statusCode is set, or bid, OTC and STB have all reported.
|
||||||
|
$bidDone = trim((string) data_get($last, 'body.0.bidErrNo', '')) !== '';
|
||||||
|
$otcDone = trim((string) data_get($last, 'body.0.otcErrNo', '')) !== '';
|
||||||
|
$stbDone = trim((string) data_get($last, 'body.0.stbErrNo', '')) !== '';
|
||||||
|
$hasEcert = trim((string) data_get($last, 'body.0.ecertNo', '')) !== ''
|
||||||
|
|| trim((string) data_get($last, 'body.0.eCertNo', '')) !== '';
|
||||||
|
|
||||||
|
if (
|
||||||
|
data_get($last, 'body.0.statusCode') !== null
|
||||||
|
|| ($bidDone && $otcDone && $stbDone)
|
||||||
|
|| ($hasEcert && $stbDone)
|
||||||
|
) {
|
||||||
|
return $last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $last;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function needsEcertFetch(BsasOrder $order): bool
|
||||||
|
{
|
||||||
|
return empty($order->bid_ecert_response)
|
||||||
|
|| empty($order->otc_ecert_response)
|
||||||
|
|| empty($order->stb_ecert_response);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function fetchAndStoreEcert(BsasOrder $order): void
|
||||||
|
{
|
||||||
|
$ecertNo = $order->e_cert_no;
|
||||||
|
if (!$ecertNo) {
|
||||||
|
$ecertNo = $this->extractEcertNo($order->result_response, $order->order_response);
|
||||||
|
if ($ecertNo) {
|
||||||
|
$order->e_cert_no = $ecertNo;
|
||||||
|
$order->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$ecertNo) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$calls = [
|
||||||
|
'bid_ecert_response' => 'getBidEcert',
|
||||||
|
'otc_ecert_response' => 'getOtcEcert',
|
||||||
|
'stb_ecert_response' => 'getStbEcert',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($calls as $column => $method) {
|
||||||
|
if (!empty($order->{$column})) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$ecert = $this->client->{$method}($ecertNo);
|
||||||
|
$order->{$column} = $ecert;
|
||||||
|
if ($column === 'otc_ecert_response' && empty($order->e_cert_no) && !empty($ecert['ECERTNO'])) {
|
||||||
|
$order->e_cert_no = $ecert['ECERTNO'];
|
||||||
|
}
|
||||||
|
$order->save();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('BSAS eCert fetch failed after confirmed order', [
|
||||||
|
'norujukan' => $order->norujukan,
|
||||||
|
'uuid' => $order->uuid,
|
||||||
|
'e_cert_no' => $ecertNo,
|
||||||
|
'certificate' => $column,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function ensureKomuditiTransaksi(BsasOrder $order, string $teller): void
|
||||||
|
{
|
||||||
|
$exists = KomuditiTransaksi::on('mysql7')
|
||||||
|
->where('norujukan', $order->norujukan)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($exists) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$current = Carbon::now();
|
||||||
|
KomuditiTransaksi::on('mysql7')->create([
|
||||||
|
'unit_komuditi' => round((float) $order->bid_value, 2),
|
||||||
|
'nosijil' => $order->e_cert_no ?: $order->uuid,
|
||||||
|
'norujukan' => $order->norujukan,
|
||||||
|
'kodcaw' => $order->kodcaw,
|
||||||
|
'teller' => $teller !== '' ? $teller : $order->created_by,
|
||||||
|
'masa' => $current->toTimeString(),
|
||||||
|
'tarikh' => $current->toDateString(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildOrderPayload(float $pinjaman, float $hargajualan, string $counterParty, string $serial): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'header' => [
|
||||||
|
'memberShortName' => config('bsas.member_short_name'),
|
||||||
|
'uuid' => $this->uuidV4(),
|
||||||
|
],
|
||||||
|
'body' => [
|
||||||
|
'serialNumber' => $serial,
|
||||||
|
'bidOption' => 'Y',
|
||||||
|
'otcOption' => 'Y',
|
||||||
|
'stbOption' => 'Y',
|
||||||
|
'productCode' => config('bsas.product_code'),
|
||||||
|
'purchaseType' => 'P',
|
||||||
|
'clientName' => '',
|
||||||
|
'currency' => 'MYR',
|
||||||
|
'bidValue' => number_format($pinjaman, 2, '.', ''),
|
||||||
|
'valueDate' => Carbon::now()->format('Ymd'),
|
||||||
|
'tenor' => config('bsas.tenor'),
|
||||||
|
'otcCounterParty' => $counterParty,
|
||||||
|
'otcMurabaha' => '',
|
||||||
|
'otcMurabahaValue' => number_format($hargajualan, 2, '.', ''),
|
||||||
|
'eCertNo' => '',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Best-effort extract ecert number from result/order payloads.
|
||||||
|
*/
|
||||||
|
protected function extractEcertNo($result, $orderResponse): ?string
|
||||||
|
{
|
||||||
|
$candidates = [
|
||||||
|
data_get($result, 'body.0.eCertNo'),
|
||||||
|
data_get($result, 'body.0.ecertNo'),
|
||||||
|
data_get($result, 'body.0.ECERTNO'),
|
||||||
|
data_get($result, 'body.0.ecertno'),
|
||||||
|
data_get($result, 'body.0.certificateNo'),
|
||||||
|
data_get($orderResponse, 'body.0.eCertNo'),
|
||||||
|
data_get($orderResponse, 'body.0.ecertNo'),
|
||||||
|
data_get($orderResponse, 'body.0.ECERTNO'),
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($candidates as $value) {
|
||||||
|
$value = trim((string) $value);
|
||||||
|
if ($value !== '') {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function uuidV4(): string
|
||||||
|
{
|
||||||
|
$data = random_bytes(16);
|
||||||
|
$data[6] = chr((ord($data[6]) & 0x0f) | 0x40);
|
||||||
|
$data[8] = chr((ord($data[8]) & 0x3f) | 0x80);
|
||||||
|
|
||||||
|
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ use App\Cawangan;
|
|||||||
use App\Feature;
|
use App\Feature;
|
||||||
use App\ModalOnline;
|
use App\ModalOnline;
|
||||||
use App\RequestModalOnline;
|
use App\RequestModalOnline;
|
||||||
|
use App\Services\StaffNotificationClient;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@@ -362,6 +363,8 @@ class ModalOnlineService
|
|||||||
'nota' => $nota,
|
'nota' => $nota,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->notifyOperasiModalRequest($kodcaw, $request, $jenis);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'ok' => true,
|
'ok' => true,
|
||||||
'status' => 201,
|
'status' => 201,
|
||||||
@@ -373,6 +376,54 @@ class ModalOnlineService
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inbox for all operasi staff. Failures must not block the request.
|
||||||
|
*
|
||||||
|
* @param string $kodcaw
|
||||||
|
* @param \App\RequestModalOnline $request
|
||||||
|
* @param string $jenis
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function notifyOperasiModalRequest($kodcaw, $request, $jenis)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
app(StaffNotificationClient::class)->notify([
|
||||||
|
'type' => 'modal_online.pending_operasi',
|
||||||
|
'cawangan' => $kodcaw,
|
||||||
|
'audience' => ['role' => 'operasi'],
|
||||||
|
'data' => [
|
||||||
|
'request_id' => $request->id,
|
||||||
|
'amaun' => (float) $request->amaun,
|
||||||
|
'dimohon_oleh' => $request->dimohon_oleh,
|
||||||
|
'jenis' => $jenis,
|
||||||
|
'nota' => $request->nota,
|
||||||
|
'cawangan_nama' => $this->cawanganNama($kodcaw),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::warning('Operasi modal-online notification failed: '.$e->getMessage(), [
|
||||||
|
'kodcaw' => $kodcaw,
|
||||||
|
'request_id' => $request->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $kodcaw
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function cawanganNama($kodcaw)
|
||||||
|
{
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
||||||
|
if (!$cawangan) {
|
||||||
|
return $kodcaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nama = trim((string) $cawangan->nama_cawangan);
|
||||||
|
|
||||||
|
return $nama !== '' ? $nama : $kodcaw;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List top-up requests.
|
* List top-up requests.
|
||||||
* For PC: pass kodcaw. For Operasi: omit kodcaw (all branches).
|
* For PC: pass kodcaw. For Operasi: omit kodcaw (all branches).
|
||||||
|
|||||||
@@ -9,16 +9,21 @@ use App\Cawangan;
|
|||||||
use App\Customer;
|
use App\Customer;
|
||||||
use App\Feature;
|
use App\Feature;
|
||||||
use App\Gadai;
|
use App\Gadai;
|
||||||
|
use App\Jobs\WhatsappPembiayaanOnlinePaid;
|
||||||
use App\PembiayaanOnline;
|
use App\PembiayaanOnline;
|
||||||
|
use App\Services\StaffNotificationClient;
|
||||||
|
use App\Services\Whatsapp\WhatsappCloudClient;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class PembiayaanOnlineService
|
class PembiayaanOnlineService
|
||||||
{
|
{
|
||||||
const MIN_PINJAMAN = 5000.00;
|
const MIN_PINJAMAN = 1.00;
|
||||||
const MAX_PINJAMAN = 50000.00;
|
const MAX_PINJAMAN = 50000.00;
|
||||||
const PC_QUEUE_STATUSES = ['PENDING_PC', 'REJECTED_PC'];
|
const PC_QUEUE_STATUSES = ['PENDING_PC', 'REJECTED_PC', 'VERIFIED_PC'];
|
||||||
|
const PC_VERIFY_FROM_STATUSES = ['PENDING_PC', 'REJECTED_PC'];
|
||||||
|
const PC_SUBMITTABLE_STATUSES = ['VERIFIED_PC'];
|
||||||
|
|
||||||
protected $modalOnlineService;
|
protected $modalOnlineService;
|
||||||
|
|
||||||
@@ -258,6 +263,36 @@ class PembiayaanOnlineService
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{ok:bool,status:int,payload:mixed}
|
||||||
|
*/
|
||||||
|
public function showLine($kodcaw, $id)
|
||||||
|
{
|
||||||
|
$resolved = $this->resolveMysql($kodcaw);
|
||||||
|
if (!$resolved['ok']) {
|
||||||
|
return $resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
$line = PembiayaanOnline::on($resolved['mysql'])
|
||||||
|
->where('kodcaw', $kodcaw)
|
||||||
|
->where('id', $id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$line) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 404,
|
||||||
|
'payload' => ['message' => 'Pembiayaan online tidak dijumpai'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'ok' => true,
|
||||||
|
'status' => 200,
|
||||||
|
'payload' => $line,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
* @return array{ok:bool,status:int,payload:mixed}
|
||||||
*/
|
*/
|
||||||
@@ -332,7 +367,7 @@ class PembiayaanOnlineService
|
|||||||
'ok' => false,
|
'ok' => false,
|
||||||
'status' => 422,
|
'status' => 422,
|
||||||
'payload' => [
|
'payload' => [
|
||||||
'message' => 'Hanya rekod PENDING_PC / REJECTED_PC boleh dikemaskini',
|
'message' => 'Hanya rekod PENDING_PC / REJECTED_PC / VERIFIED_PC boleh dikemaskini',
|
||||||
'status' => $line->status,
|
'status' => $line->status,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -368,6 +403,31 @@ class PembiayaanOnlineService
|
|||||||
$fields['borang_file_id'] = $input['borang_file_id'];
|
$fields['borang_file_id'] = $input['borang_file_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($input['bukti_akaun_data'])) {
|
||||||
|
$saved = $this->storeBuktiFile([
|
||||||
|
'data' => $input['bukti_akaun_data'],
|
||||||
|
'filename' => $input['bukti_akaun_filename'] ?? $input['filename'] ?? null,
|
||||||
|
'type' => $input['bukti_akaun_type'] ?? $input['type'] ?? null,
|
||||||
|
]);
|
||||||
|
if (!$saved['ok']) {
|
||||||
|
return $saved;
|
||||||
|
}
|
||||||
|
$fields['bukti_akaun_file_id'] = $saved['payload']['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($input['borang_data'])) {
|
||||||
|
$saved = $this->storeBuktiFile([
|
||||||
|
'data' => $input['borang_data'],
|
||||||
|
'filename' => $input['borang_filename'] ?? null,
|
||||||
|
'type' => $input['borang_type'] ?? null,
|
||||||
|
]);
|
||||||
|
if (!$saved['ok']) {
|
||||||
|
$saved['payload']['message'] = 'Borang pengesahan diperlukan: fail, nama fail dan jenis fail.';
|
||||||
|
return $saved;
|
||||||
|
}
|
||||||
|
$fields['borang_file_id'] = $saved['payload']['id'];
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($fields)) {
|
if (empty($fields)) {
|
||||||
return [
|
return [
|
||||||
'ok' => false,
|
'ok' => false,
|
||||||
@@ -395,6 +455,12 @@ class PembiayaanOnlineService
|
|||||||
? (bool) $input['update_customer_bank']
|
? (bool) $input['update_customer_bank']
|
||||||
: true;
|
: true;
|
||||||
|
|
||||||
|
if ($line->status === 'VERIFIED_PC') {
|
||||||
|
$fields['status'] = !empty($line->reject_reason) ? 'REJECTED_PC' : 'PENDING_PC';
|
||||||
|
$fields['pc_verified_by'] = null;
|
||||||
|
$fields['pc_verified_at'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::connection($mysql)->transaction(function () use ($mysql, $line, $fields, $updateCustomerBank) {
|
DB::connection($mysql)->transaction(function () use ($mysql, $line, $fields, $updateCustomerBank) {
|
||||||
PembiayaanOnline::on($mysql)->where('id', $line->id)->update($fields);
|
PembiayaanOnline::on($mysql)->where('id', $line->id)->update($fields);
|
||||||
@@ -433,6 +499,159 @@ class PembiayaanOnlineService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PC confirms one queue line before it can be submitted to Operasi.
|
||||||
|
*
|
||||||
|
* @return array{ok:bool,status:int,payload:mixed}
|
||||||
|
*/
|
||||||
|
public function verifyLine($kodcaw, $id, $pcBy)
|
||||||
|
{
|
||||||
|
$resolved = $this->resolveMysql($kodcaw);
|
||||||
|
if (!$resolved['ok']) {
|
||||||
|
return $resolved;
|
||||||
|
}
|
||||||
|
$mysql = $resolved['mysql'];
|
||||||
|
|
||||||
|
$pcBy = trim((string) $pcBy);
|
||||||
|
if ($pcBy === '') {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 422,
|
||||||
|
'payload' => ['message' => 'pc_verified_by diperlukan'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return DB::connection($mysql)->transaction(function () use ($mysql, $kodcaw, $id, $pcBy) {
|
||||||
|
$line = PembiayaanOnline::on($mysql)
|
||||||
|
->where('kodcaw', $kodcaw)
|
||||||
|
->where('id', $id)
|
||||||
|
->lockForUpdate()
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$line) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 404,
|
||||||
|
'payload' => ['message' => 'Pembiayaan online tidak dijumpai'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($line->status === 'VERIFIED_PC') {
|
||||||
|
return [
|
||||||
|
'ok' => true,
|
||||||
|
'status' => 200,
|
||||||
|
'payload' => $line,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array($line->status, self::PC_VERIFY_FROM_STATUSES, true)) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 422,
|
||||||
|
'payload' => [
|
||||||
|
'message' => 'Hanya rekod PENDING_PC / REJECTED_PC boleh disemak',
|
||||||
|
'status' => $line->status,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($line->kodbank) || empty($line->noakaun)) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 422,
|
||||||
|
'payload' => [
|
||||||
|
'message' => 'Maklumat bank tidak lengkap. Kemaskini bank sebelum semak.',
|
||||||
|
'id' => $line->id,
|
||||||
|
'norujukan' => $line->norujukan,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
PembiayaanOnline::on($mysql)->where('id', $line->id)->update([
|
||||||
|
'status' => 'VERIFIED_PC',
|
||||||
|
'pc_verified_by' => $pcBy,
|
||||||
|
'pc_verified_at' => Carbon::now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'ok' => true,
|
||||||
|
'status' => 200,
|
||||||
|
'payload' => PembiayaanOnline::on($mysql)->where('id', $line->id)->first(),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('PembiayaanOnline verifyLine failed: ' . $e->getMessage());
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 500,
|
||||||
|
'payload' => ['message' => 'Gagal semak pembiayaan online'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undo PC verification so the line must be checked again.
|
||||||
|
*
|
||||||
|
* @return array{ok:bool,status:int,payload:mixed}
|
||||||
|
*/
|
||||||
|
public function unverifyLine($kodcaw, $id)
|
||||||
|
{
|
||||||
|
$resolved = $this->resolveMysql($kodcaw);
|
||||||
|
if (!$resolved['ok']) {
|
||||||
|
return $resolved;
|
||||||
|
}
|
||||||
|
$mysql = $resolved['mysql'];
|
||||||
|
|
||||||
|
try {
|
||||||
|
return DB::connection($mysql)->transaction(function () use ($mysql, $kodcaw, $id) {
|
||||||
|
$line = PembiayaanOnline::on($mysql)
|
||||||
|
->where('kodcaw', $kodcaw)
|
||||||
|
->where('id', $id)
|
||||||
|
->lockForUpdate()
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$line) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 404,
|
||||||
|
'payload' => ['message' => 'Pembiayaan online tidak dijumpai'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($line->status !== 'VERIFIED_PC') {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 422,
|
||||||
|
'payload' => [
|
||||||
|
'message' => 'Hanya rekod VERIFIED_PC boleh dibatalkan semakan',
|
||||||
|
'status' => $line->status,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
PembiayaanOnline::on($mysql)->where('id', $line->id)->update([
|
||||||
|
'status' => !empty($line->reject_reason) ? 'REJECTED_PC' : 'PENDING_PC',
|
||||||
|
'pc_verified_by' => null,
|
||||||
|
'pc_verified_at' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'ok' => true,
|
||||||
|
'status' => 200,
|
||||||
|
'payload' => PembiayaanOnline::on($mysql)->where('id', $line->id)->first(),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('PembiayaanOnline unverifyLine failed: ' . $e->getMessage());
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 500,
|
||||||
|
'payload' => ['message' => 'Gagal batal semakan pembiayaan online'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
* @return array{ok:bool,status:int,payload:mixed}
|
||||||
*/
|
*/
|
||||||
@@ -488,6 +707,26 @@ class PembiayaanOnlineService
|
|||||||
->orderBy('id', 'asc')
|
->orderBy('id', 'asc')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
// Fetch customer phone numbers in one query for the batch approval form.
|
||||||
|
$identityNumbers = $lines->pluck('nokp')->filter()->unique()->values()->all();
|
||||||
|
$phones = [];
|
||||||
|
if ($identityNumbers) {
|
||||||
|
$customers = Customer::on('mysql7')->select('kpbaru', 'kplama', 'telefon')
|
||||||
|
->where(function ($query) use ($identityNumbers) {
|
||||||
|
$query->whereIn('kpbaru', $identityNumbers)->orWhereIn('kplama', $identityNumbers);
|
||||||
|
})->get();
|
||||||
|
foreach ($customers as $customer) {
|
||||||
|
foreach ([$customer->kpbaru, $customer->kplama] as $identity) {
|
||||||
|
if ($identity !== null && $identity !== '') {
|
||||||
|
$phones[(string) $identity] = $customer->telefon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
$line->setAttribute('telefon', $phones[(string) $line->nokp] ?? null);
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'ok' => true,
|
'ok' => true,
|
||||||
'status' => 200,
|
'status' => 200,
|
||||||
@@ -544,7 +783,7 @@ class PembiayaanOnlineService
|
|||||||
$tarikh = $now->toDateString();
|
$tarikh = $now->toDateString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return DB::connection($mysql)->transaction(function () use (
|
$result = DB::connection($mysql)->transaction(function () use (
|
||||||
$mysql,
|
$mysql,
|
||||||
$kodcaw,
|
$kodcaw,
|
||||||
$ids,
|
$ids,
|
||||||
@@ -573,12 +812,12 @@ class PembiayaanOnlineService
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
if (!in_array($line->status, self::PC_QUEUE_STATUSES, true)) {
|
if (!in_array($line->status, self::PC_SUBMITTABLE_STATUSES, true)) {
|
||||||
return [
|
return [
|
||||||
'ok' => false,
|
'ok' => false,
|
||||||
'status' => 422,
|
'status' => 422,
|
||||||
'payload' => [
|
'payload' => [
|
||||||
'message' => 'Rekod bukan dalam queue PC',
|
'message' => 'Rekod belum disemak PC. Sahkan satu-satu sebelum hantar ke Operasi.',
|
||||||
'id' => $line->id,
|
'id' => $line->id,
|
||||||
'norujukan' => $line->norujukan,
|
'norujukan' => $line->norujukan,
|
||||||
'status' => $line->status,
|
'status' => $line->status,
|
||||||
@@ -652,6 +891,127 @@ class PembiayaanOnlineService
|
|||||||
'payload' => ['message' => 'Gagal hantar batch pembiayaan online'],
|
'payload' => ['message' => 'Gagal hantar batch pembiayaan online'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($result['ok'])) {
|
||||||
|
$this->notifyOperasiBatchSubmitted($kodcaw, $ids, $pcBy, $result['payload']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inbox for all operasi staff after PC submit. Failures must not block the batch.
|
||||||
|
*
|
||||||
|
* @param string $kodcaw
|
||||||
|
* @param array $ids
|
||||||
|
* @param string $pcBy
|
||||||
|
* @param array $payload
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function notifyOperasiBatchSubmitted($kodcaw, array $ids, $pcBy, array $payload)
|
||||||
|
{
|
||||||
|
$batch = isset($payload['batch']) ? $payload['batch'] : null;
|
||||||
|
if (!$batch) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$batchId = is_array($batch) ? ($batch['id'] ?? null) : $batch->id;
|
||||||
|
$batchNo = is_array($batch) ? ($batch['batch_no'] ?? '') : $batch->batch_no;
|
||||||
|
$slot = is_array($batch) ? ($batch['slot'] ?? '') : $batch->slot;
|
||||||
|
$bilangan = is_array($batch) ? ($batch['bilangan'] ?? 0) : $batch->bilangan;
|
||||||
|
$jumlah = is_array($batch) ? ($batch['jumlah_keseluruhan'] ?? 0) : $batch->jumlah_keseluruhan;
|
||||||
|
|
||||||
|
if (!$batchId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
app(StaffNotificationClient::class)->notify([
|
||||||
|
'type' => 'pembiayaan_online.batch_operasi',
|
||||||
|
'cawangan' => $kodcaw,
|
||||||
|
'audience' => ['role' => 'operasi'],
|
||||||
|
'data' => [
|
||||||
|
'batch_id' => $batchId,
|
||||||
|
'batch_no' => $batchNo,
|
||||||
|
'slot' => $slot,
|
||||||
|
'appended' => !empty($payload['appended']),
|
||||||
|
'submitted_count' => count($ids),
|
||||||
|
'bilangan' => $bilangan,
|
||||||
|
'jumlah_keseluruhan' => (float) $jumlah,
|
||||||
|
'pc_submitted_by' => $pcBy,
|
||||||
|
'cawangan_nama' => $this->cawanganNama($kodcaw),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::warning('Operasi batch notification failed: '.$e->getMessage(), [
|
||||||
|
'kodcaw' => $kodcaw,
|
||||||
|
'batch_id' => $batchId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $kodcaw
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function cawanganNama($kodcaw)
|
||||||
|
{
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
||||||
|
if (!$cawangan) {
|
||||||
|
return $kodcaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nama = trim((string) $cawangan->nama_cawangan);
|
||||||
|
|
||||||
|
return $nama !== '' ? $nama : $kodcaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inbox for PC at this branch. Failures must not block the operasi action.
|
||||||
|
*
|
||||||
|
* @param string $kodcaw
|
||||||
|
* @param string $type
|
||||||
|
* @param array $data
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function notifyPcPembiayaanOnline($kodcaw, $type, array $data)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
app(StaffNotificationClient::class)->notify([
|
||||||
|
'type' => $type,
|
||||||
|
'cawangan' => $kodcaw,
|
||||||
|
'audience' => ['role' => 'pc'],
|
||||||
|
'data' => array_merge($data, [
|
||||||
|
'cawangan_nama' => $this->cawanganNama($kodcaw),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::warning('PC pembiayaan-online notification failed: '.$e->getMessage(), [
|
||||||
|
'kodcaw' => $kodcaw,
|
||||||
|
'type' => $type,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $line
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function lineNotifyFields($line)
|
||||||
|
{
|
||||||
|
if (!$line) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$isArr = is_array($line);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'norujukan' => $isArr ? ($line['norujukan'] ?? '') : $line->norujukan,
|
||||||
|
'nama_pelanggan' => $isArr ? ($line['nama_pelanggan'] ?? '') : $line->nama_pelanggan,
|
||||||
|
'pinjaman' => $isArr ? ($line['pinjaman'] ?? 0) : $line->pinjaman,
|
||||||
|
'ops_by' => $isArr ? ($line['ops_by'] ?? '') : $line->ops_by,
|
||||||
|
'reject_reason' => $isArr ? ($line['reject_reason'] ?? '') : $line->reject_reason,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -826,7 +1186,7 @@ class PembiayaanOnlineService
|
|||||||
$now = Carbon::now();
|
$now = Carbon::now();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return DB::connection($mysql)->transaction(function () use ($mysql, $kodcaw, $id, $opsBy, $reason, $now) {
|
$result = DB::connection($mysql)->transaction(function () use ($mysql, $kodcaw, $id, $opsBy, $reason, $now) {
|
||||||
$line = PembiayaanOnline::on($mysql)
|
$line = PembiayaanOnline::on($mysql)
|
||||||
->where('kodcaw', $kodcaw)
|
->where('kodcaw', $kodcaw)
|
||||||
->where('id', $id)
|
->where('id', $id)
|
||||||
@@ -869,6 +1229,8 @@ class PembiayaanOnlineService
|
|||||||
'rejected_at' => $now,
|
'rejected_at' => $now,
|
||||||
'ops_by' => $opsBy,
|
'ops_by' => $opsBy,
|
||||||
'batch_id' => null,
|
'batch_id' => null,
|
||||||
|
'pc_verified_by' => null,
|
||||||
|
'pc_verified_at' => null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$batch = null;
|
$batch = null;
|
||||||
@@ -895,6 +1257,18 @@ class PembiayaanOnlineService
|
|||||||
'payload' => ['message' => 'Gagal tolak pembiayaan online'],
|
'payload' => ['message' => 'Gagal tolak pembiayaan online'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($result['ok'])) {
|
||||||
|
$this->notifyPcPembiayaanOnline($kodcaw, 'pembiayaan_online.rejected_pc', array_merge(
|
||||||
|
$this->lineNotifyFields(isset($result['payload']['pembiayaan_online']) ? $result['payload']['pembiayaan_online'] : null),
|
||||||
|
[
|
||||||
|
'ops_by' => $opsBy,
|
||||||
|
'reject_reason' => $reason,
|
||||||
|
]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1015,7 +1389,7 @@ class PembiayaanOnlineService
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return DB::connection($mysql)->transaction(function () use (
|
$result = DB::connection($mysql)->transaction(function () use (
|
||||||
$mysql,
|
$mysql,
|
||||||
$kodcaw,
|
$kodcaw,
|
||||||
$id,
|
$id,
|
||||||
@@ -1114,6 +1488,18 @@ class PembiayaanOnlineService
|
|||||||
'payload' => ['message' => 'Gagal tanda PAID / muat naik bukti'],
|
'payload' => ['message' => 'Gagal tanda PAID / muat naik bukti'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($result['ok'])) {
|
||||||
|
$this->notifyPcPembiayaanOnline($kodcaw, 'pembiayaan_online.paid_pc', array_merge(
|
||||||
|
$this->lineNotifyFields(isset($result['payload']['pembiayaan_online']) ? $result['payload']['pembiayaan_online'] : null),
|
||||||
|
[
|
||||||
|
'paid_count' => 1,
|
||||||
|
'ops_by' => $opsBy,
|
||||||
|
]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1159,7 +1545,7 @@ class PembiayaanOnlineService
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return DB::connection($mysql)->transaction(function () use (
|
$result = DB::connection($mysql)->transaction(function () use (
|
||||||
$mysql,
|
$mysql,
|
||||||
$kodcaw,
|
$kodcaw,
|
||||||
$batchId,
|
$batchId,
|
||||||
@@ -1251,6 +1637,19 @@ class PembiayaanOnlineService
|
|||||||
'payload' => ['message' => 'Gagal tanda PAID batch'],
|
'payload' => ['message' => 'Gagal tanda PAID batch'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($result['ok'])) {
|
||||||
|
$batch = isset($result['payload']['batch']) ? $result['payload']['batch'] : null;
|
||||||
|
$this->notifyPcPembiayaanOnline($kodcaw, 'pembiayaan_online.paid_pc', [
|
||||||
|
'paid_count' => isset($result['payload']['dibayar']) ? (int) $result['payload']['dibayar'] : 0,
|
||||||
|
'batch_id' => $batch ? (is_array($batch) ? ($batch['id'] ?? null) : $batch->id) : $batchId,
|
||||||
|
'batch_no' => $batch ? (is_array($batch) ? ($batch['batch_no'] ?? '') : $batch->batch_no) : '',
|
||||||
|
'jumlah_keseluruhan' => $batch ? (is_array($batch) ? ($batch['jumlah_keseluruhan'] ?? 0) : $batch->jumlah_keseluruhan) : 0,
|
||||||
|
'ops_by' => $opsBy,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1314,6 +1713,124 @@ class PembiayaanOnlineService
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get attached bank-account slip (bukti_akaun_file_id) for a line.
|
||||||
|
*
|
||||||
|
* @return array{ok:bool,status:int,payload:mixed}
|
||||||
|
*/
|
||||||
|
public function getBuktiAkaun($kodcaw, $id)
|
||||||
|
{
|
||||||
|
$resolved = $this->resolveMysql($kodcaw);
|
||||||
|
if (!$resolved['ok']) {
|
||||||
|
return $resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
$line = PembiayaanOnline::on($resolved['mysql'])
|
||||||
|
->where('kodcaw', $kodcaw)
|
||||||
|
->where('id', $id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$line) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 404,
|
||||||
|
'payload' => ['message' => 'Pembiayaan online tidak dijumpai'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($line->bukti_akaun_file_id)) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 404,
|
||||||
|
'payload' => ['message' => 'Slip bank belum dimuat naik'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = ARFiles::on('mysql7')->where('id', $line->bukti_akaun_file_id)->first();
|
||||||
|
if (!$file) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 404,
|
||||||
|
'payload' => ['message' => 'Fail slip bank tidak dijumpai'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'ok' => true,
|
||||||
|
'status' => 200,
|
||||||
|
'payload' => [
|
||||||
|
'pembiayaan_online_id' => $line->id,
|
||||||
|
'norujukan' => $line->norujukan,
|
||||||
|
'file' => [
|
||||||
|
'id' => $file->id,
|
||||||
|
'filename' => $file->filename,
|
||||||
|
'type' => $file->type,
|
||||||
|
'tarikhmasa' => $file->tarikhmasa,
|
||||||
|
'data' => $file->data,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get attached signed online-financing confirmation form (borang_file_id).
|
||||||
|
*
|
||||||
|
* @return array{ok:bool,status:int,payload:mixed}
|
||||||
|
*/
|
||||||
|
public function getBorang($kodcaw, $id)
|
||||||
|
{
|
||||||
|
$resolved = $this->resolveMysql($kodcaw);
|
||||||
|
if (!$resolved['ok']) {
|
||||||
|
return $resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
$line = PembiayaanOnline::on($resolved['mysql'])
|
||||||
|
->where('kodcaw', $kodcaw)
|
||||||
|
->where('id', $id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$line) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 404,
|
||||||
|
'payload' => ['message' => 'Pembiayaan online tidak dijumpai'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($line->borang_file_id)) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 404,
|
||||||
|
'payload' => ['message' => 'Borang pengesahan belum dimuat naik'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = ARFiles::on('mysql7')->where('id', $line->borang_file_id)->first();
|
||||||
|
if (!$file) {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'status' => 404,
|
||||||
|
'payload' => ['message' => 'Fail borang pengesahan tidak dijumpai'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'ok' => true,
|
||||||
|
'status' => 200,
|
||||||
|
'payload' => [
|
||||||
|
'pembiayaan_online_id' => $line->id,
|
||||||
|
'norujukan' => $line->norujukan,
|
||||||
|
'file' => [
|
||||||
|
'id' => $file->id,
|
||||||
|
'filename' => $file->filename,
|
||||||
|
'type' => $file->type,
|
||||||
|
'tarikhmasa' => $file->tarikhmasa,
|
||||||
|
'data' => $file->data,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PC list of PAID lines awaiting blast / tally.
|
* PC list of PAID lines awaiting blast / tally.
|
||||||
*
|
*
|
||||||
@@ -1349,8 +1866,8 @@ class PembiayaanOnlineService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PC marks PAID line(s) as tallied / blast done (blast_sent=1).
|
* PC marks PAID line(s) as tallied / blast done (blast_sent=1),
|
||||||
* Actual WhatsApp/SMS dispatch can be wired later.
|
* then queues WhatsApp Cloud template to each customer (or ADMIN_PHONE_NUMBER off-prod).
|
||||||
*
|
*
|
||||||
* @param array|int|string $ids
|
* @param array|int|string $ids
|
||||||
* @return array{ok:bool,status:int,payload:mixed}
|
* @return array{ok:bool,status:int,payload:mixed}
|
||||||
@@ -1379,7 +1896,7 @@ class PembiayaanOnlineService
|
|||||||
$updated = 0;
|
$updated = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return DB::connection($mysql)->transaction(function () use ($mysql, $kodcaw, $ids, $blastBy, $now, &$updated) {
|
$result = DB::connection($mysql)->transaction(function () use ($mysql, $kodcaw, $ids, $blastBy, $now, &$updated) {
|
||||||
$lines = PembiayaanOnline::on($mysql)
|
$lines = PembiayaanOnline::on($mysql)
|
||||||
->where('kodcaw', $kodcaw)
|
->where('kodcaw', $kodcaw)
|
||||||
->whereIn('id', $ids)
|
->whereIn('id', $ids)
|
||||||
@@ -1433,6 +1950,50 @@ class PembiayaanOnlineService
|
|||||||
'payload' => ['message' => 'Gagal tanda blast/tally'],
|
'payload' => ['message' => 'Gagal tanda blast/tally'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($result['ok'])) {
|
||||||
|
$this->queuePaidWhatsapp($kodcaw, $result['payload']['data'] ?? []);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatch Cloud API jobs after tally commit. Failures are logged; tally stays PAID/blast_sent.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Support\Collection|array $lines
|
||||||
|
*/
|
||||||
|
protected function queuePaidWhatsapp($kodcaw, $lines)
|
||||||
|
{
|
||||||
|
$client = new WhatsappCloudClient();
|
||||||
|
if (!$client->isConfigured()) {
|
||||||
|
Log::info('WhatsApp Cloud not configured; tally saved without send', ['kodcaw' => $kodcaw]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $kodcaw)->first();
|
||||||
|
$cawName = $cawangan ? $cawangan->nama_cawangan : $kodcaw;
|
||||||
|
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
try {
|
||||||
|
dispatch(new WhatsappPembiayaanOnlinePaid([
|
||||||
|
'kodcaw' => $kodcaw,
|
||||||
|
'caw_name' => $cawName,
|
||||||
|
'nokp' => $line->nokp ?? null,
|
||||||
|
'norujukan' => $line->norujukan ?? null,
|
||||||
|
'pinjaman' => $line->pinjaman ?? null,
|
||||||
|
'nama_bank' => $line->nama_bank ?? null,
|
||||||
|
'noakaun' => $line->noakaun ?? null,
|
||||||
|
'tarikh_bayaran' => $line->tarikh_bayaran ?? null,
|
||||||
|
'no_rujukan_bayaran' => $line->no_rujukan_bayaran ?? null,
|
||||||
|
]));
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('queuePaidWhatsapp dispatch failed: ' . $e->getMessage(), [
|
||||||
|
'kodcaw' => $kodcaw,
|
||||||
|
'id' => $line->id ?? null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1509,40 +2070,88 @@ class PembiayaanOnlineService
|
|||||||
return BatchPembiayaanOnline::on($mysql)->where('id', $batchId)->first();
|
return BatchPembiayaanOnline::on($mysql)->where('id', $batchId)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function suggestSlot()
|
public function slotJadual()
|
||||||
{
|
{
|
||||||
$now = Carbon::now();
|
return [
|
||||||
$mins = ((int) $now->format('G')) * 60 + (int) $now->format('i');
|
[
|
||||||
|
|
||||||
if ($mins < 11 * 60) {
|
|
||||||
return [
|
|
||||||
'slot' => 'BATCH1',
|
'slot' => 'BATCH1',
|
||||||
|
'label' => 'Batch 1',
|
||||||
|
'mula' => '00:00',
|
||||||
'cutoff' => '11:00',
|
'cutoff' => '11:00',
|
||||||
'proses' => '12:30',
|
'proses' => '12:30',
|
||||||
'lewat' => false,
|
],
|
||||||
'nota' => 'Dalam waktu Batch 1',
|
[
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($mins < 15 * 60) {
|
|
||||||
return [
|
|
||||||
'slot' => 'BATCH2',
|
'slot' => 'BATCH2',
|
||||||
|
'label' => 'Batch 2',
|
||||||
|
'mula' => '11:00',
|
||||||
'cutoff' => '15:00',
|
'cutoff' => '15:00',
|
||||||
'proses' => '16:30',
|
'proses' => '16:30',
|
||||||
'lewat' => false,
|
],
|
||||||
'nota' => 'Dalam waktu Batch 2',
|
];
|
||||||
];
|
}
|
||||||
|
|
||||||
|
public function suggestSlot()
|
||||||
|
{
|
||||||
|
$now = Carbon::now('Asia/Kuala_Lumpur');
|
||||||
|
$mins = ((int) $now->format('G')) * 60 + (int) $now->format('i');
|
||||||
|
$jadual = $this->slotJadual();
|
||||||
|
$batch1 = $jadual[0];
|
||||||
|
$batch2 = $jadual[1];
|
||||||
|
$cutoff1 = $this->hmToMinutes($batch1['cutoff']);
|
||||||
|
$cutoff2 = $this->hmToMinutes($batch2['cutoff']);
|
||||||
|
|
||||||
|
if ($mins < $cutoff1) {
|
||||||
|
return $this->slotPayload($batch1, false, $cutoff1 - $mins, 'Dalam waktu Batch 1', $now, $jadual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($mins < $cutoff2) {
|
||||||
|
return $this->slotPayload($batch2, false, $cutoff2 - $mins, 'Dalam waktu Batch 2', $now, $jadual);
|
||||||
|
}
|
||||||
|
|
||||||
|
$lewat = $this->slotPayload(
|
||||||
|
$batch2,
|
||||||
|
true,
|
||||||
|
0,
|
||||||
|
'Selepas cutoff Batch 2 — masih boleh hantar; Operasi mungkin proses esok',
|
||||||
|
$now,
|
||||||
|
$jadual
|
||||||
|
);
|
||||||
|
$lewat['proses'] = $batch2['proses'] . ' (hari berikutnya jika sudah lewat)';
|
||||||
|
|
||||||
|
return $lewat;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function slotPayload(array $batch, $lewat, $bakiMinit, $nota, Carbon $now, array $jadual)
|
||||||
|
{
|
||||||
|
$parts = explode(':', (string) $batch['cutoff']);
|
||||||
|
$cutoffAt = $now->copy()->setTime(
|
||||||
|
isset($parts[0]) ? (int) $parts[0] : 0,
|
||||||
|
isset($parts[1]) ? (int) $parts[1] : 0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'slot' => 'BATCH2',
|
'slot' => $batch['slot'],
|
||||||
'cutoff' => '15:00',
|
'cutoff' => $batch['cutoff'],
|
||||||
'proses' => '16:30 (hari berikutnya jika sudah lewat)',
|
'cutoff_at' => $cutoffAt->toIso8601String(),
|
||||||
'lewat' => true,
|
'server_now' => $now->toIso8601String(),
|
||||||
'nota' => 'Selepas cutoff Batch 2 — masih boleh hantar; Operasi mungkin proses esok',
|
'proses' => $batch['proses'],
|
||||||
|
'lewat' => (bool) $lewat,
|
||||||
|
'baki_minit' => (int) $bakiMinit,
|
||||||
|
'nota' => $nota,
|
||||||
|
'jadual' => $jadual,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function hmToMinutes($hm)
|
||||||
|
{
|
||||||
|
$parts = explode(':', (string) $hm);
|
||||||
|
$h = isset($parts[0]) ? (int) $parts[0] : 0;
|
||||||
|
$m = isset($parts[1]) ? (int) $parts[1] : 0;
|
||||||
|
|
||||||
|
return ($h * 60) + $m;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One batch per branch / day / slot (B1-001 or B2-001). Later submits append.
|
* One batch per branch / day / slot (B1-001 or B2-001). Later submits append.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Cawangan;
|
||||||
|
use App\Customer;
|
||||||
|
use App\Gadai;
|
||||||
|
use App\ShorakaTransaction;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
class ShorakaGadaiService
|
||||||
|
{
|
||||||
|
public function gadai(string $kodcaw, string $norujukan): Gadai
|
||||||
|
{
|
||||||
|
$branch = Cawangan::on('mysql7')->where('kodcaw', $kodcaw)->firstOrFail();
|
||||||
|
return Gadai::on($branch->mysql)->where('kodcaw', $kodcaw)->where('norujukan', $norujukan)->first()
|
||||||
|
?? abort(404, 'Maklumat gadaian tidak tersedia. Semakan diperlukan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function payload(Gadai $gadai): array
|
||||||
|
{
|
||||||
|
$customer = Customer::on('mysql7')->where(function ($query) use ($gadai) {
|
||||||
|
$query->where('kpbaru', $gadai->nokp)->orWhere('kplama', $gadai->nokp);
|
||||||
|
})->firstOrFail();
|
||||||
|
if (!$customer->nama || $gadai->pinjaman <= 0 || $gadai->hargajualan < $gadai->pinjaman) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'norujukan' => 'Nama pelanggan, pembiayaan dan harga jualan mesti lengkap.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'norujukan' => $gadai->norujukan,
|
||||||
|
'ownership' => $customer->nama,
|
||||||
|
'order_amount' => $gadai->pinjaman,
|
||||||
|
'murabaha_amount' => $gadai->hargajualan,
|
||||||
|
// Both GadaiV1 and GadaiV2 price the contract using upah12.
|
||||||
|
// "tempoh" is elapsed charge time, NOT the contractual tenor.
|
||||||
|
'tenor_other' => 12,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transaction(string $kodcaw, string $norujukan)
|
||||||
|
{
|
||||||
|
$order = ShorakaTransaction::where('norujukan', $norujukan)->first();
|
||||||
|
if ($order && (string) $order->kodcaw !== $kodcaw) {
|
||||||
|
abort(409, 'Rekod Shoraka tidak dipadankan dengan cawangan ini.');
|
||||||
|
}
|
||||||
|
return $order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sync(ShorakaTransaction $order): void
|
||||||
|
{
|
||||||
|
if (!$order->kodcaw) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$gadai = $this->gadai($order->kodcaw, $order->norujukan);
|
||||||
|
if (!$gadai->exists) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$sameAmounts = number_format((float) $gadai->pinjaman, 2, '.', '') === $order->order_amount
|
||||||
|
&& number_format((float) $gadai->hargajualan, 2, '.', '') === $order->murabaha_amount;
|
||||||
|
$gadai->getConnection()->table('gadai')->where('norujukan', $order->norujukan)->update([
|
||||||
|
'tagkomuditi' => $order->status === 'Completed' && $sameAmounts ? 1 : 0,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCompleted(string $kodcaw, string $norujukan): void
|
||||||
|
{
|
||||||
|
$gadai = $this->gadai($kodcaw, $norujukan);
|
||||||
|
$order = $this->transaction($kodcaw, $norujukan);
|
||||||
|
if (!$gadai->exists || !$order || $order->status !== 'Completed'
|
||||||
|
|| number_format((float) $gadai->pinjaman, 2, '.', '') !== $order->order_amount
|
||||||
|
|| number_format((float) $gadai->hargajualan, 2, '.', '') !== $order->murabaha_amount) {
|
||||||
|
abort(409, 'Pembiayaan dan SAG ditahan sehingga transaksi Shoraka selesai dan amaun sepadan.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Http\Client\Response;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
class ShorakaService
|
||||||
|
{
|
||||||
|
const STATUSES = ['Active', 'Completed', 'Cancelled', 'Pending Sell', 'Take Delivery'];
|
||||||
|
|
||||||
|
const CALLBACK_FIELDS = [
|
||||||
|
'orderId', 'status', 'bankName', 'ownershipName', 'commodityType',
|
||||||
|
'unit', 'volume', 'productType', 'valueDate', 'cancelDate', 'orderType',
|
||||||
|
'orderCurrency', 'orderAmount', 'murabahaAmount', 'tenor',
|
||||||
|
'tenorOther', 'tenorOtherUnit',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $baseUrl;
|
||||||
|
protected $apiId;
|
||||||
|
protected $secretKey;
|
||||||
|
protected $timeout;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->baseUrl = rtrim((string) config('services.shoraka.base_url'), '/');
|
||||||
|
$this->apiId = (string) config('services.shoraka.api_id');
|
||||||
|
$this->secretKey = (string) config('services.shoraka.secret_key');
|
||||||
|
$this->timeout = (int) config('services.shoraka.timeout', 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configured(): bool
|
||||||
|
{
|
||||||
|
if ($this->simulationRequested()) {
|
||||||
|
return $this->simulationAllowed() && in_array($this->simulationMode(), ['failed', 'pending'], true);
|
||||||
|
}
|
||||||
|
return $this->apiId !== '' && $this->secretKey !== '';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function simulationAllowed(): bool
|
||||||
|
{
|
||||||
|
return app()->environment('local', 'testing');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function simulationMode(): string
|
||||||
|
{
|
||||||
|
return strtolower(trim((string) config('services.shoraka.simulation', 'off')));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function simulationRequested(): bool
|
||||||
|
{
|
||||||
|
return !in_array($this->simulationMode(), ['', 'off'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function simulatedResponse(string $orderId): array
|
||||||
|
{
|
||||||
|
if (!$this->simulationAllowed()) {
|
||||||
|
throw new RuntimeException('Shoraka simulation is restricted to local/testing.');
|
||||||
|
}
|
||||||
|
if (strpos($orderId, 'SIM-FAILED-') === 0) {
|
||||||
|
return ['orderId' => $orderId, 'status' => 'Cancelled'];
|
||||||
|
}
|
||||||
|
if (strpos($orderId, 'SIM-PENDING-') === 0) {
|
||||||
|
return ['orderId' => $orderId, 'status' => 'Active'];
|
||||||
|
}
|
||||||
|
throw new RuntimeException('Invalid simulation order ID.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submitOrder(array $data): array
|
||||||
|
{
|
||||||
|
if ($this->simulationRequested()) {
|
||||||
|
if (!$this->simulationAllowed() || !in_array($this->simulationMode(), ['failed', 'pending'], true)) {
|
||||||
|
throw new RuntimeException('Shoraka simulation configuration is not allowed.');
|
||||||
|
}
|
||||||
|
return $this->simulatedResponse('SIM-' . strtoupper($this->simulationMode()) . '-' . bin2hex(random_bytes(12)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$payload = ['api_id' => $this->apiId];
|
||||||
|
foreach ([
|
||||||
|
'product_type', 'commodity_type', 'ownership', 'value_date',
|
||||||
|
'order_currency', 'order_amount', 'murabaha_amount', 'tenor',
|
||||||
|
'tenor_other', 'tenor_other_unit', 'order_type', 'ownership_doc_no',
|
||||||
|
] as $field) {
|
||||||
|
$payload[$field] = $data[$field] ?? '';
|
||||||
|
}
|
||||||
|
foreach (['order_amount', 'murabaha_amount'] as $field) {
|
||||||
|
$payload[$field] = number_format((float) $payload[$field], 2, '.', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ownership_doc_no is deliberately excluded by the v1.5 signature contract.
|
||||||
|
$signed = $payload;
|
||||||
|
unset($signed['api_id'], $signed['ownership_doc_no']);
|
||||||
|
$payload['signature'] = $this->signature(array_values($signed));
|
||||||
|
|
||||||
|
return $this->orderResponse($this->request()->post(
|
||||||
|
$this->baseUrl . '/api/submitorder', $payload
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function orderStatus(string $orderId): array
|
||||||
|
{
|
||||||
|
if (strpos($orderId, 'SIM-') === 0) {
|
||||||
|
return $this->simulatedResponse($orderId); // Never send simulated references to the real provider.
|
||||||
|
}
|
||||||
|
if ($this->simulationRequested()) {
|
||||||
|
throw new RuntimeException('Real order status is unavailable while simulation is enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->orderResponse($this->request()->post(
|
||||||
|
$this->baseUrl . '/api/orderstatus', $this->orderPayload($orderId)
|
||||||
|
), $orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function certificate(string $orderId): string
|
||||||
|
{
|
||||||
|
if ($this->simulationRequested() || strpos($orderId, 'SIM-') === 0) {
|
||||||
|
throw new RuntimeException('Certificates are unavailable for simulation.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Section 5 specifies POST, despite GET in the document history.
|
||||||
|
$response = $this->request()->accept('application/pdf')->post(
|
||||||
|
$this->baseUrl . '/api/certificate', $this->orderPayload($orderId)
|
||||||
|
);
|
||||||
|
$this->checkResponse($response);
|
||||||
|
$type = strtolower(trim(explode(';', $response->header('Content-Type'))[0]));
|
||||||
|
if ($type !== 'application/pdf' || substr($response->body(), 0, 5) !== '%PDF-') {
|
||||||
|
throw new RuntimeException('Shoraka returned an invalid PDF certificate.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->body();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validCallback(array $payload): bool
|
||||||
|
{
|
||||||
|
if ($this->simulationRequested() || strpos((string) ($payload['orderId'] ?? ''), 'SIM-') === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->configured()
|
||||||
|
|| !isset($payload['apiId'], $payload['signature'])
|
||||||
|
|| !is_string($payload['apiId'])
|
||||||
|
|| !hash_equals($this->apiId, $payload['apiId'])
|
||||||
|
|| !is_string($payload['signature'])
|
||||||
|
|| !preg_match('/\A[0-9a-fA-F]{64}\z/', $payload['signature'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = [];
|
||||||
|
foreach (self::CALLBACK_FIELDS as $field) {
|
||||||
|
// Preserve the original strings: decimal formatting affects the hash.
|
||||||
|
if (!array_key_exists($field, $payload) || !is_string($payload[$field])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$values[] = $payload[$field];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $payload['orderId'] !== ''
|
||||||
|
&& in_array($payload['status'], self::STATUSES, true)
|
||||||
|
&& hash_equals($this->signature($values), strtolower($payload['signature']));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function signature(array $values): string
|
||||||
|
{
|
||||||
|
return hash('sha256', implode(';', array_merge(
|
||||||
|
[$this->secretKey, $this->apiId], $values
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function orderPayload(string $orderId): array
|
||||||
|
{
|
||||||
|
if ($orderId === '') {
|
||||||
|
throw new RuntimeException('Shoraka order ID is required.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'api_id' => $this->apiId,
|
||||||
|
'order_id' => $orderId,
|
||||||
|
'signature' => $this->signature([$orderId]),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function request()
|
||||||
|
{
|
||||||
|
if (!$this->configured()) {
|
||||||
|
throw new RuntimeException('Shoraka credentials are not configured.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Never forward signed requests through redirects or retry a trade automatically.
|
||||||
|
return Http::asForm()->acceptJson()->timeout($this->timeout)
|
||||||
|
->withOptions(['allow_redirects' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function checkResponse(Response $response): void
|
||||||
|
{
|
||||||
|
if (!$response->successful()) {
|
||||||
|
// Do not expose upstream bodies which may contain credentials or customer data.
|
||||||
|
throw new RuntimeException('Shoraka request failed. HTTP ' . $response->status());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function orderResponse(Response $response, string $expectedId = null): array
|
||||||
|
{
|
||||||
|
$this->checkResponse($response);
|
||||||
|
$data = $response->json();
|
||||||
|
if (!is_array($data)
|
||||||
|
|| !isset($data['orderId'], $data['status'])
|
||||||
|
|| !(is_string($data['orderId']) || is_int($data['orderId']))
|
||||||
|
|| (string) $data['orderId'] === ''
|
||||||
|
|| !in_array($data['status'], self::STATUSES, true)
|
||||||
|
|| ($expectedId !== null && (string) $data['orderId'] !== $expectedId)) {
|
||||||
|
throw new RuntimeException('Shoraka returned an invalid order response.');
|
||||||
|
}
|
||||||
|
if (isset($data['certificateUrl']) && !is_string($data['certificateUrl'])) {
|
||||||
|
throw new RuntimeException('Shoraka returned an invalid certificate URL.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class StaffNotificationClient
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Ask kaunter to persist a staff inbox row. Never throws.
|
||||||
|
*
|
||||||
|
* @param array $payload
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function notify(array $payload)
|
||||||
|
{
|
||||||
|
$base = rtrim((string) config('kaunter.url'), '/');
|
||||||
|
$secret = (string) config('kaunter.notification_secret');
|
||||||
|
|
||||||
|
if ($base === '' || $secret === '') {
|
||||||
|
Log::info('Staff notification skipped: KAUNTER_URL or INTERNAL_NOTIFICATION_SECRET is empty');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$timeout = (int) config('kaunter.notification_timeout', 3);
|
||||||
|
if ($timeout < 1) {
|
||||||
|
$timeout = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = Http::timeout($timeout)
|
||||||
|
->withHeaders([
|
||||||
|
'X-Internal-Token' => $secret,
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
])
|
||||||
|
->asJson()
|
||||||
|
->post($base . '/internal/notifications', $payload);
|
||||||
|
|
||||||
|
if (!$response->successful()) {
|
||||||
|
Log::warning('Staff notification to kaunter failed', [
|
||||||
|
'status' => $response->status(),
|
||||||
|
'body' => $response->body(),
|
||||||
|
'type' => isset($payload['type']) ? $payload['type'] : null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::warning('Staff notification to kaunter errored: '.$e->getMessage(), [
|
||||||
|
'type' => isset($payload['type']) ? $payload['type'] : null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Whatsapp;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class WhatsappCloudClient
|
||||||
|
{
|
||||||
|
public function isConfigured()
|
||||||
|
{
|
||||||
|
return trim((string) config('whatsapp.token')) !== ''
|
||||||
|
&& trim((string) config('whatsapp.phone_number_id')) !== '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Malaysia MSISDN for Graph API, e.g. 60193450165.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function normalizeMsisdn($raw)
|
||||||
|
{
|
||||||
|
$digits = preg_replace('/\D+/', '', (string) $raw);
|
||||||
|
if ($digits === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($digits, '60') === 0) {
|
||||||
|
return $digits;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($digits, '0') === 0) {
|
||||||
|
return '60' . substr($digits, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '60' . $digits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $to
|
||||||
|
* @param string $templateName
|
||||||
|
* @param string $lang
|
||||||
|
* @param array<int,string> $bodyParams
|
||||||
|
* @return \Illuminate\Http\Client\Response
|
||||||
|
*/
|
||||||
|
public function sendTemplate($to, $templateName, $lang, array $bodyParams = [])
|
||||||
|
{
|
||||||
|
$payload = [
|
||||||
|
'messaging_product' => 'whatsapp',
|
||||||
|
'to' => $to,
|
||||||
|
'type' => 'template',
|
||||||
|
'template' => [
|
||||||
|
'name' => $templateName,
|
||||||
|
'language' => ['code' => $lang],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
if (count($bodyParams) > 0) {
|
||||||
|
$payload['template']['components'] = [[
|
||||||
|
'type' => 'body',
|
||||||
|
'parameters' => array_map(function ($text) {
|
||||||
|
return [
|
||||||
|
'type' => 'text',
|
||||||
|
'text' => $this->sanitizeParam($text),
|
||||||
|
];
|
||||||
|
}, array_values($bodyParams)),
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = config('whatsapp.api_version', 'v25.0');
|
||||||
|
$phoneId = config('whatsapp.phone_number_id');
|
||||||
|
$url = 'https://graph.facebook.com/' . $version . '/' . $phoneId . '/messages';
|
||||||
|
|
||||||
|
$response = Http::withToken(config('whatsapp.token'))
|
||||||
|
->acceptJson()
|
||||||
|
->asJson()
|
||||||
|
->post($url, $payload);
|
||||||
|
|
||||||
|
if (!$response->successful()) {
|
||||||
|
Log::error('WhatsApp Cloud send failed', [
|
||||||
|
'to' => $to,
|
||||||
|
'template' => $templateName,
|
||||||
|
'status' => $response->status(),
|
||||||
|
'body' => $response->json() ?: $response->body(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function sanitizeParam($text)
|
||||||
|
{
|
||||||
|
$text = trim(preg_replace('/\s+/', ' ', (string) $text));
|
||||||
|
if ($text === '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
return mb_substr($text, 0, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ShorakaTransaction extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'norujukan',
|
||||||
|
'kodcaw',
|
||||||
|
'teller',
|
||||||
|
'order_id',
|
||||||
|
'status',
|
||||||
|
'product_type',
|
||||||
|
'commodity_type',
|
||||||
|
'ownership_name',
|
||||||
|
'ownership_doc_no',
|
||||||
|
'order_amount',
|
||||||
|
'murabaha_amount',
|
||||||
|
'certificate_url',
|
||||||
|
'certificate_path',
|
||||||
|
'request_payload',
|
||||||
|
'response_payload',
|
||||||
|
'callback_payload',
|
||||||
|
'attempt_count',
|
||||||
|
'error_message',
|
||||||
|
'submitted_at',
|
||||||
|
'completed_at',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'order_amount' => 'decimal:2',
|
||||||
|
'murabaha_amount' => 'decimal:2',
|
||||||
|
'request_payload' => 'array',
|
||||||
|
'response_payload' => 'array',
|
||||||
|
'callback_payload' => 'array',
|
||||||
|
'submitted_at' => 'datetime',
|
||||||
|
'completed_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -88,9 +88,7 @@ class GadaiV1
|
|||||||
|
|
||||||
$hargajualan = $request->pinjaman + $upah12;
|
$hargajualan = $request->pinjaman + $upah12;
|
||||||
|
|
||||||
$gadai = Gadai::on($cawangan['mysql'])
|
$gadaiFields = array(
|
||||||
->where('norujukan','=',$norujukan)
|
|
||||||
->update(array(
|
|
||||||
'nilaimarhun' => $total_nilai_marhun,
|
'nilaimarhun' => $total_nilai_marhun,
|
||||||
'berat'=> $total_berat,
|
'berat'=> $total_berat,
|
||||||
'pinjaman' => $request->pinjaman,
|
'pinjaman' => $request->pinjaman,
|
||||||
@@ -115,7 +113,8 @@ class GadaiV1
|
|||||||
'upahdibayar' => 0.00,
|
'upahdibayar' => 0.00,
|
||||||
'tempohbayar' => 0.00,
|
'tempohbayar' => 0.00,
|
||||||
'lelong_tawarruq' => 1
|
'lelong_tawarruq' => 1
|
||||||
));
|
);
|
||||||
|
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan', $norujukan)->update($gadaiFields);
|
||||||
|
|
||||||
$new_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
$new_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ use Carbon\Carbon;
|
|||||||
use App\Gadai;
|
use App\Gadai;
|
||||||
use App\HargaEmas;
|
use App\HargaEmas;
|
||||||
use App\InOutMar;
|
use App\InOutMar;
|
||||||
use App\KomuditiPurchase;
|
|
||||||
use App\KomuditiTransaksi;
|
|
||||||
use App\Marhun;
|
use App\Marhun;
|
||||||
use App\Moratorium;
|
use App\Moratorium;
|
||||||
use App\Palsu;
|
use App\Palsu;
|
||||||
@@ -809,19 +807,18 @@ class Penebusan
|
|||||||
$array_tebus = $request->only(['jeniskeuntungan', 'nopelanggan','jenistebus','addpinjaman','nowakil','marhun','teller','bakipinjaman','bakiupah']);
|
$array_tebus = $request->only(['jeniskeuntungan', 'nopelanggan','jenistebus','addpinjaman','nowakil','marhun','teller','bakipinjaman','bakiupah']);
|
||||||
$array_trans = $request->only(['nopelanggan', 'noic','jenisAT','pinjaman','pinjamanbaru','marhun','teller','jenistebus']);
|
$array_trans = $request->only(['nopelanggan', 'noic','jenisAT','pinjaman','pinjamanbaru','marhun','teller','jenistebus']);
|
||||||
$array_tebus_base = $request->only(['totalbayaran', 'bakiupah','jeniskeuntungan','bakipinjaman','jenistebus','teller','nowakil','duitpelanggan']);
|
$array_tebus_base = $request->only(['totalbayaran', 'bakiupah','jeniskeuntungan','bakipinjaman','jenistebus','teller','nowakil','duitpelanggan']);
|
||||||
$array_trans_base = $request->only(['pinjaman','teller','pinjamanbaru']);
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
DB::connection($cawangan['mysql'])->beginTransaction();
|
DB::connection($cawangan['mysql'])->beginTransaction();
|
||||||
$this->saveTebus($kodcaw,$norujukan,$gadai,$cawangan,$array_tebus);
|
$this->saveTebus($kodcaw,$norujukan,$gadai,$cawangan,$array_tebus);
|
||||||
$this->createTransaction($cawangan,$kodcaw,$norujukan,$array_trans);
|
$newReference = $this->createTransaction($cawangan,$kodcaw,$norujukan,$array_trans);
|
||||||
|
|
||||||
DB::connection('mysql7')->beginTransaction();
|
DB::connection('mysql7')->beginTransaction();
|
||||||
$this->saveTebusBase($kodcaw,$norujukan,$gadai,$array_tebus_base);
|
$this->saveTebusBase($kodcaw,$norujukan,$gadai,$array_tebus_base);
|
||||||
$this->createTransactionBase($norujukan,$kodcaw,$array_trans_base);
|
|
||||||
$array_response = [
|
$array_response = [
|
||||||
'result' => 'success',
|
'result' => 'success',
|
||||||
'data' => 1
|
'data' => 1,
|
||||||
|
'norujukan_baru' => $newReference
|
||||||
];
|
];
|
||||||
|
|
||||||
DB::connection($cawangan['mysql'])->commit();
|
DB::connection($cawangan['mysql'])->commit();
|
||||||
@@ -949,7 +946,7 @@ class Penebusan
|
|||||||
$gadaiTransaction = Gadai::on($cawangan['mysql'])->where('t_gadai','=',$current->toDateString())->orderBy('sirig', 'desc')->first();
|
$gadaiTransaction = Gadai::on($cawangan['mysql'])->where('t_gadai','=',$current->toDateString())->orderBy('sirig', 'desc')->first();
|
||||||
$gadaiTransaction = optional($gadaiTransaction)->toArray();
|
$gadaiTransaction = optional($gadaiTransaction)->toArray();
|
||||||
|
|
||||||
$new_sirig = ($gadaiTransaction) ? $gadaiTransaction['sirig'] + 1 : 1;
|
$new_sirig = (int) ($gadaiTransaction['sirig'] ?? 0) + 1;
|
||||||
$curent_year = substr($current->year,2,2);
|
$curent_year = substr($current->year,2,2);
|
||||||
$curent_month = sprintf("%02d", $current->month);
|
$curent_month = sprintf("%02d", $current->month);
|
||||||
$current_day = sprintf("%02d", $current->day);
|
$current_day = sprintf("%02d", $current->day);
|
||||||
@@ -1077,37 +1074,11 @@ class Penebusan
|
|||||||
't_update' => $current->toDateString(),
|
't_update' => $current->toDateString(),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
return $new_sag_number;
|
||||||
}catch(\Exception $e){
|
}catch(\Exception $e){
|
||||||
throw new \Exception("Error in Transaction: " . $e->getMessage());
|
throw new \Exception("Error in Transaction: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createTransactionBase($norujukan,$kodcaw,$array_trans_base){
|
}
|
||||||
$current = Carbon::now();
|
|
||||||
|
|
||||||
$komuditi_current = KomuditiPurchase::on('mysql7')->where('date_purchase','=',$current->toDateString())->orderBy('created_at','desc')->first();
|
|
||||||
|
|
||||||
$unit_current = isset($komuditi_current['unit_komuditi']) ? $komuditi_current['unit_komuditi']: 0;
|
|
||||||
|
|
||||||
try{
|
|
||||||
$update_unit = $unit_current - $array_trans_base['pinjamanbaru'];
|
|
||||||
|
|
||||||
KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
|
|
||||||
'unit_komuditi' => $update_unit
|
|
||||||
]);
|
|
||||||
|
|
||||||
KomuditiTransaksi::on('mysql7')->create([
|
|
||||||
'unit_komuditi' => $update_unit,
|
|
||||||
'nosijil'=>$komuditi_current['no_sijil'],
|
|
||||||
'norujukan' => $norujukan,
|
|
||||||
'kodcaw' => $kodcaw,
|
|
||||||
'teller' => $array_trans_base['teller'],
|
|
||||||
'masa' => $current->toTimeString(),
|
|
||||||
'tarikh' => $current->toDateString()
|
|
||||||
]);
|
|
||||||
}catch(\Exception $e){
|
|
||||||
throw new \Exception("Error in TransactionBase: " . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Support\v2;
|
namespace App\Support\v2;
|
||||||
|
|
||||||
|
use App\Feature;
|
||||||
|
use App\KadarRebet;
|
||||||
use App\KadarUpah;
|
use App\KadarUpah;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class Calculation
|
class Calculation
|
||||||
{
|
{
|
||||||
@@ -55,7 +58,7 @@ class Calculation
|
|||||||
return $ujrah_sebenar;
|
return $ujrah_sebenar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function kiraanKeuntunganRebet(float $pembiayaan = 0.0,float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
|
public function kiraanKeuntunganRebet(float $pembiayaan = 0.0,float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0, $kodcaw = null){
|
||||||
|
|
||||||
$this->one_percent = $this->getKadarUpah($nilaimarhun);
|
$this->one_percent = $this->getKadarUpah($nilaimarhun);
|
||||||
|
|
||||||
@@ -66,8 +69,59 @@ class Calculation
|
|||||||
$ujrah_sebenar = (!empty($ujrah_sebenar)) ? $this->getRoundedMethod($ujrah_sebenar) : 0;
|
$ujrah_sebenar = (!empty($ujrah_sebenar)) ? $this->getRoundedMethod($ujrah_sebenar) : 0;
|
||||||
|
|
||||||
$keuntungan = $onepercent + $ujrah_sebenar;
|
$keuntungan = $onepercent + $ujrah_sebenar;
|
||||||
|
$annur = $this->kiraanDiskaunAnnur($kodcaw, $pembiayaan, $keuntungan);
|
||||||
|
|
||||||
return ['keuntungan' => $keuntungan,'onepercent' => $onepercent, 'ujrah' => $ujrah_sebenar];
|
return [
|
||||||
|
'keuntungan' => $keuntungan,
|
||||||
|
'onepercent' => $onepercent,
|
||||||
|
'ujrah' => $ujrah_sebenar,
|
||||||
|
'diskaun' => $annur['diskaun'],
|
||||||
|
'kadarrebet' => $annur['kadarrebet'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annur promotional discount. Other cawangan get 0 unless rebet_annur is enabled.
|
||||||
|
*/
|
||||||
|
public function kiraanDiskaunAnnur($kodcaw, float $pembiayaan = 0.0, float $keuntungan = 0.0)
|
||||||
|
{
|
||||||
|
$empty = ['kadarrebet' => 0, 'diskaun' => 0];
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!$kodcaw || !Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||||
|
return $empty;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
$percent = $this->kiraanRebetAnnur($pembiayaan);
|
||||||
|
if ($percent <= 0 || $keuntungan <= 0) {
|
||||||
|
return ['kadarrebet' => $percent, 'diskaun' => 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'kadarrebet' => $percent,
|
||||||
|
'diskaun' => $this->getRoundedMethod($keuntungan * ($percent / 100)),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function kiraanRebetAnnur(float $pembiayaan = 0.0)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (!Schema::connection('mysql7')->hasTable('kadar_rebet')) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$kadarrebet = KadarRebet::on('mysql7')
|
||||||
|
->where('pembiayaan_min', '<=', $pembiayaan)
|
||||||
|
->where('pembiayaan_max', '>=', $pembiayaan)
|
||||||
|
->sum('kadarrebet');
|
||||||
|
|
||||||
|
return (float) $kadarrebet;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function kiraanKeuntunganSebenar(float $pembiayaan = 0.0,float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
|
public function kiraanKeuntunganSebenar(float $pembiayaan = 0.0,float $nilaimarhun = 0.0,float $kadarujrah = 0.0,float $margin = 0.0){
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Support\v2;
|
|||||||
use App\Audit;
|
use App\Audit;
|
||||||
use App\Cawangan;
|
use App\Cawangan;
|
||||||
use App\Customer;
|
use App\Customer;
|
||||||
|
use App\Feature;
|
||||||
use App\KadarUpah;
|
use App\KadarUpah;
|
||||||
use App\Support\v2\Calculation;
|
use App\Support\v2\Calculation;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
@@ -137,14 +138,13 @@ if (is_null($kadar_raw)) {
|
|||||||
$upah12 = $onepercentservices->getRoundedMethod($upah1 * 12);
|
$upah12 = $onepercentservices->getRoundedMethod($upah1 * 12);
|
||||||
$ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah']);
|
$ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah']);
|
||||||
$onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent']);
|
$onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent']);
|
||||||
|
$annur = $onepercentservices->kiraanDiskaunAnnur($request->kodcaw, $request->pinjaman, $keuntungan['keuntungan']);
|
||||||
|
|
||||||
$hargajualan = $request->pinjaman + $upah12;
|
$hargajualan = $request->pinjaman + $upah12;
|
||||||
|
|
||||||
$akrual = $this->kiraupahTawarruqStokAuditUjrahOnePercent(0.5,0,$kadar_raw,$request->pinjaman,$total_nilai_marhun,$margin_pinjam);
|
$akrual = $this->kiraupahTawarruqStokAuditUjrahOnePercent(0.5,0,$kadar_raw,$request->pinjaman,$total_nilai_marhun,$margin_pinjam);
|
||||||
|
|
||||||
$gadai = Gadai::on($cawangan['mysql'])
|
$gadaiFields = [
|
||||||
->where('norujukan','=',$norujukan)
|
|
||||||
->update(array(
|
|
||||||
'nilaimarhun' => $total_nilai_marhun,
|
'nilaimarhun' => $total_nilai_marhun,
|
||||||
'berat'=> $total_berat,
|
'berat'=> $total_berat,
|
||||||
'pinjaman' => $request->pinjaman,
|
'pinjaman' => $request->pinjaman,
|
||||||
@@ -176,7 +176,23 @@ if (is_null($kadar_raw)) {
|
|||||||
'tagbaru' => 1,
|
'tagbaru' => 1,
|
||||||
'tunggakanujrah' => $akrual['ujrah'],
|
'tunggakanujrah' => $akrual['ujrah'],
|
||||||
'tunggakanonepercent' => $akrual['keuntungan'],
|
'tunggakanonepercent' => $akrual['keuntungan'],
|
||||||
));
|
];
|
||||||
|
if (Feature::enabled($request->kodcaw, Feature::REBET_ANNUR)) {
|
||||||
|
$requestedKadar = (float) $request->input('kadar_rebate', 0);
|
||||||
|
$requestedDiskaun = (float) $request->input('rebate', 0);
|
||||||
|
|
||||||
|
if ($requestedKadar > 0 || $requestedDiskaun > 0) {
|
||||||
|
$gadaiFields['kadarrebet'] = $requestedKadar;
|
||||||
|
$gadaiFields['diskaun'] = $requestedDiskaun;
|
||||||
|
} elseif (($request->transaction ?? '') === 'Daftar Gadai') {
|
||||||
|
$gadaiFields['kadarrebet'] = $annur['kadarrebet'];
|
||||||
|
$gadaiFields['diskaun'] = $annur['diskaun'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$gadai = Gadai::on($cawangan['mysql'])
|
||||||
|
->where('norujukan','=',$norujukan)
|
||||||
|
->update($gadaiFields);
|
||||||
|
|
||||||
$new_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
$new_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
||||||
|
|
||||||
@@ -240,14 +256,15 @@ if (is_null($kadar_raw)) {
|
|||||||
}
|
}
|
||||||
$bilang_bln = $tempoh - $gadai_data['tempohbayar'];
|
$bilang_bln = $tempoh - $gadai_data['tempohbayar'];
|
||||||
|
|
||||||
$upah = $onepercentservices->kiraanKeuntunganRebet($gadai_data['bakipjm'],$gadai_data['nilaimarhun'],$gadai_data['kadarupah'],$gadai_data['margin_semasa']);
|
$upah = $onepercentservices->kiraanKeuntunganRebet($gadai_data['bakipjm'],$gadai_data['nilaimarhun'],$gadai_data['kadarupah'],$gadai_data['margin_semasa'], $this->kodcaw);
|
||||||
|
|
||||||
//$upahrebet_raw = $bilang_bln * $upah['keuntungan'];
|
//$upahrebet_raw = $bilang_bln * $upah['keuntungan'];
|
||||||
$onepercent = $onepercentservices->getRoundedMethod($bilang_bln * $upah['onepercent']);
|
$onepercent = $onepercentservices->getRoundedMethod($bilang_bln * $upah['onepercent']);
|
||||||
$ujrah = $onepercentservices->getRoundedMethod($bilang_bln * $upah['ujrah']);
|
$ujrah = $onepercentservices->getRoundedMethod($bilang_bln * $upah['ujrah']);
|
||||||
$upahrebet_raw = $onepercent + $ujrah;
|
$upahrebet_raw = $onepercent + $ujrah;
|
||||||
$upahrebet_raw = $onepercentservices->getRoundedMethod($upahrebet_raw);
|
$upahrebet_raw = $onepercentservices->getRoundedMethod($upahrebet_raw);
|
||||||
|
$upahrebet_raw = $upahrebet_raw - ($upah['diskaun'] ?? 0);
|
||||||
|
|
||||||
return $upahrebet_raw;
|
return $upahrebet_raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +299,7 @@ if (is_null($kadar_raw)) {
|
|||||||
|
|
||||||
$margin_semasa = ($gadai['bakipjm'] / $gadai['nilaimarhun']) * 100;
|
$margin_semasa = ($gadai['bakipjm'] / $gadai['nilaimarhun']) * 100;
|
||||||
|
|
||||||
$keuntungan = $onepercent->kiraanKeuntunganRebet($gadai['bakipjm'],$gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['margin_semasa']);
|
$keuntungan = $onepercent->kiraanKeuntunganRebet($gadai['bakipjm'],$gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['margin_semasa'], $kodcaw);
|
||||||
$ujrahasal = $onepercent->kiraanUjrahSebenar($gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['percentpinj']);
|
$ujrahasal = $onepercent->kiraanUjrahSebenar($gadai['nilaimarhun'],$gadai['kadarupah'],$gadai['percentpinj']);
|
||||||
|
|
||||||
$onepercentasal = $gadai['pinjaman'] * (1/100);
|
$onepercentasal = $gadai['pinjaman'] * (1/100);
|
||||||
@@ -319,7 +336,7 @@ if (is_null($kadar_raw)) {
|
|||||||
$keun = $onepercent->getRoundedMethod($onepercentasal * $bilang_bln);
|
$keun = $onepercent->getRoundedMethod($onepercentasal * $bilang_bln);
|
||||||
$keuntungan_rebate = $onepercent->getRoundedMethod($keuntungan['onepercent'] * $bilang_bln);
|
$keuntungan_rebate = $onepercent->getRoundedMethod($keuntungan['onepercent'] * $bilang_bln);
|
||||||
|
|
||||||
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
$transactionUpahFields = [
|
||||||
'norujukan' => $norujukan,
|
'norujukan' => $norujukan,
|
||||||
'bayaran_keuntungan' => $upahsemasa,
|
'bayaran_keuntungan' => $upahsemasa,
|
||||||
'bayaran_pembiayaan' => $baki_bayaran,
|
'bayaran_pembiayaan' => $baki_bayaran,
|
||||||
@@ -333,7 +350,12 @@ if (is_null($kadar_raw)) {
|
|||||||
'tempoh' => $gadai['tempoh'],
|
'tempoh' => $gadai['tempoh'],
|
||||||
'beza_tempoh' => $bilang_bln,
|
'beza_tempoh' => $bilang_bln,
|
||||||
'margin_semasa' => $margin_semasa,
|
'margin_semasa' => $margin_semasa,
|
||||||
]);
|
];
|
||||||
|
if (Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||||
|
$transactionUpahFields['kadardiskaun'] = $keuntungan['diskaun'] ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create($transactionUpahFields);
|
||||||
|
|
||||||
$transaksi_gadai = TransaksiGadai::on('mysql7')->create([
|
$transaksi_gadai = TransaksiGadai::on('mysql7')->create([
|
||||||
'kodcaw' => $old_data['kodcaw'],
|
'kodcaw' => $old_data['kodcaw'],
|
||||||
|
|||||||
@@ -5,14 +5,13 @@ namespace App\Support\v2;
|
|||||||
use App\Advansur;
|
use App\Advansur;
|
||||||
use App\Audit;
|
use App\Audit;
|
||||||
use App\Cawangan;
|
use App\Cawangan;
|
||||||
|
use App\Feature;
|
||||||
use App\KadarUpah;
|
use App\KadarUpah;
|
||||||
use App\Support\v2\Calculation;
|
use App\Support\v2\Calculation;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Gadai;
|
use App\Gadai;
|
||||||
use App\HargaEmas;
|
use App\HargaEmas;
|
||||||
use App\InOutMar;
|
use App\InOutMar;
|
||||||
use App\KomuditiPurchase;
|
|
||||||
use App\KomuditiTransaksi;
|
|
||||||
use App\Marhun;
|
use App\Marhun;
|
||||||
use App\FailoverTransaction;
|
use App\FailoverTransaction;
|
||||||
use App\FailoverTransactionFailed;
|
use App\FailoverTransactionFailed;
|
||||||
@@ -39,6 +38,32 @@ class Penebusan
|
|||||||
$this->cawangan_info = $cawangan_info;
|
$this->cawangan_info = $cawangan_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function diskaunAnnur($kodcaw, $gadai)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (!Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (float) ($gadai['diskaun'] ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function tebusAnnurFields($kodcaw, $diskaun)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (!Feature::enabled($kodcaw, Feature::REBET_ANNUR)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['diskaun_rebate' => $diskaun];
|
||||||
|
}
|
||||||
|
|
||||||
public function tebusTawarruq($kodcaw,$norujukan){
|
public function tebusTawarruq($kodcaw,$norujukan){
|
||||||
$onepercentservices = new Calculation();
|
$onepercentservices = new Calculation();
|
||||||
|
|
||||||
@@ -53,7 +78,8 @@ class Penebusan
|
|||||||
$jeniskeuntungan = ($gadai_data['tagbaru'] == 1) ? 'onepercent' : 'asal';
|
$jeniskeuntungan = ($gadai_data['tagbaru'] == 1) ? 'onepercent' : 'asal';
|
||||||
|
|
||||||
$rebet = $this->rebetselepastawarruq($kodcaw,$norujukan,$jeniskeuntungan);
|
$rebet = $this->rebetselepastawarruq($kodcaw,$norujukan,$jeniskeuntungan);
|
||||||
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet;
|
$diskaun = $this->diskaunAnnur($kodcaw, $gadai_data);
|
||||||
|
$harga_tebus = $gadai_data['bakihargajualan'] - $rebet - $diskaun;
|
||||||
|
|
||||||
// $hargatebus = round($harga_tebus,PHP_ROUND_HALF_UP);
|
// $hargatebus = round($harga_tebus,PHP_ROUND_HALF_UP);
|
||||||
// $hargatebus = bcdiv(round($harga_tebus,2),1,1);
|
// $hargatebus = bcdiv(round($harga_tebus,2),1,1);
|
||||||
@@ -485,6 +511,8 @@ class Penebusan
|
|||||||
|
|
||||||
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
||||||
|
|
||||||
|
$diskaun = $this->diskaunAnnur($kodcaw, $gadai);
|
||||||
|
|
||||||
//check duplicate
|
//check duplicate
|
||||||
$data = Transaction::on('mysql7')->where('norujukan','=',$norujukan)->whereIn('trans_type', ['P', 'T', 'S'])->first();
|
$data = Transaction::on('mysql7')->where('norujukan','=',$norujukan)->whereIn('trans_type', ['P', 'T', 'S'])->first();
|
||||||
|
|
||||||
@@ -502,7 +530,6 @@ class Penebusan
|
|||||||
$harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
|
$harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
|
||||||
$upah_tebus = $this->kiraupahTawarruq($norujukan);
|
$upah_tebus = $this->kiraupahTawarruq($norujukan);
|
||||||
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
|
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
|
||||||
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
|
||||||
|
|
||||||
if($request->jeniskeuntungan == 'onepercent'){
|
if($request->jeniskeuntungan == 'onepercent'){
|
||||||
$array_onepercent = $this->kiraupahUjrahOnePercent($kodcaw,$norujukan);
|
$array_onepercent = $this->kiraupahUjrahOnePercent($kodcaw,$norujukan);
|
||||||
@@ -514,10 +541,15 @@ class Penebusan
|
|||||||
$ujrah = $array_onepercent['ujrah'];
|
$ujrah = $array_onepercent['ujrah'];
|
||||||
$onepercent = $array_onepercent['onepercent'];
|
$onepercent = $array_onepercent['onepercent'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$harga_tebus['harga'] -= $diskaun;
|
||||||
|
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$bayaran_keuntungan_bersih = max(0, $upah_rebet_sebenar);
|
||||||
|
|
||||||
$create_tebus = Tebus::on($cawangan['mysql'])->create([
|
|
||||||
|
$create_tebus = Tebus::on($cawangan['mysql'])->create(array_merge([
|
||||||
'kodcaw'=> $kodcaw,
|
'kodcaw'=> $kodcaw,
|
||||||
'norujukan'=> $norujukan,
|
'norujukan'=> $norujukan,
|
||||||
'nopelanggan' => $request->nopelanggan,
|
'nopelanggan' => $request->nopelanggan,
|
||||||
@@ -543,7 +575,7 @@ class Penebusan
|
|||||||
'teller' => $request->teller,
|
'teller' => $request->teller,
|
||||||
'ujrah' => $ujrah_rebet,
|
'ujrah' => $ujrah_rebet,
|
||||||
'onepercent' => $onepercent_rebet,
|
'onepercent' => $onepercent_rebet,
|
||||||
]);
|
], $this->tebusAnnurFields($kodcaw, $diskaun)));
|
||||||
|
|
||||||
$create_inoutmar = InOutMar::on($cawangan['mysql'])->create([
|
$create_inoutmar = InOutMar::on($cawangan['mysql'])->create([
|
||||||
'tarikh' => $current->toDateString(),
|
'tarikh' => $current->toDateString(),
|
||||||
@@ -561,7 +593,7 @@ class Penebusan
|
|||||||
|
|
||||||
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
||||||
'norujukan' => $norujukan,
|
'norujukan' => $norujukan,
|
||||||
'bayaran_keuntungan' => $upah_tebus,
|
'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
|
||||||
'bayaran_pembiayaan' => $gadai['bakipjm'],
|
'bayaran_pembiayaan' => $gadai['bakipjm'],
|
||||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||||
'tarikh_bayaran'=> $current,
|
'tarikh_bayaran'=> $current,
|
||||||
@@ -651,6 +683,8 @@ class Penebusan
|
|||||||
|
|
||||||
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
|
||||||
|
|
||||||
|
$diskaun = $this->diskaunAnnur($kodcaw, $gadai);
|
||||||
|
|
||||||
//check duplicate
|
//check duplicate
|
||||||
$data = Transaction::on('mysql7')->where('norujukan','=',$norujukan)->where('trans_type','=','AT')->first();
|
$data = Transaction::on('mysql7')->where('norujukan','=',$norujukan)->where('trans_type','=','AT')->first();
|
||||||
|
|
||||||
@@ -668,7 +702,6 @@ class Penebusan
|
|||||||
$harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
|
$harga_tebus = $this->hargaTebusTawarruq($kodcaw,$norujukan,$request->jeniskeuntungan);
|
||||||
$upah_tebus = $this->kiraupahTawarruq($norujukan);
|
$upah_tebus = $this->kiraupahTawarruq($norujukan);
|
||||||
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
|
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
|
||||||
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
|
||||||
|
|
||||||
if($request->jeniskeuntungan == 'onepercent'){
|
if($request->jeniskeuntungan == 'onepercent'){
|
||||||
$array_onepercent = $this->kiraupahUjrahOnePercent($kodcaw,$norujukan);
|
$array_onepercent = $this->kiraupahUjrahOnePercent($kodcaw,$norujukan);
|
||||||
@@ -681,6 +714,9 @@ class Penebusan
|
|||||||
$ujrah = $array_onepercent['ujrah'];
|
$ujrah = $array_onepercent['ujrah'];
|
||||||
$onepercent = $array_onepercent['onepercent'];
|
$onepercent = $array_onepercent['onepercent'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$harga_tebus['harga'] -= $diskaun;
|
||||||
|
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$update_gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array(
|
$update_gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array(
|
||||||
@@ -690,7 +726,7 @@ class Penebusan
|
|||||||
|
|
||||||
// $upah_rebet = $this->kiraUpahRebet($kodcaw,$norujukan);
|
// $upah_rebet = $this->kiraUpahRebet($kodcaw,$norujukan);
|
||||||
|
|
||||||
$create_tebus = Tebus::on($cawangan['mysql'])->create([
|
$create_tebus = Tebus::on($cawangan['mysql'])->create(array_merge([
|
||||||
'kodcaw'=> $kodcaw,
|
'kodcaw'=> $kodcaw,
|
||||||
'norujukan'=> $norujukan,
|
'norujukan'=> $norujukan,
|
||||||
'nopelanggan' => $request->nopelanggan,
|
'nopelanggan' => $request->nopelanggan,
|
||||||
@@ -716,7 +752,7 @@ class Penebusan
|
|||||||
'teller' => $request->teller,
|
'teller' => $request->teller,
|
||||||
'ujrah' => $ujrah_rebet,
|
'ujrah' => $ujrah_rebet,
|
||||||
'onepercent' => $onepercent_rebet,
|
'onepercent' => $onepercent_rebet,
|
||||||
]);
|
], $this->tebusAnnurFields($kodcaw, $diskaun)));
|
||||||
|
|
||||||
$create_inoutmar = InOutMar::on($cawangan['mysql'])->create([
|
$create_inoutmar = InOutMar::on($cawangan['mysql'])->create([
|
||||||
'tarikh' => $current->toDateString(),
|
'tarikh' => $current->toDateString(),
|
||||||
@@ -734,9 +770,11 @@ class Penebusan
|
|||||||
|
|
||||||
$bayaran_pembiayaan = $request->totalbayaran - $request->bakiupah;
|
$bayaran_pembiayaan = $request->totalbayaran - $request->bakiupah;
|
||||||
|
|
||||||
|
$bayaran_keuntungan_bersih = max(0, $upah_rebet_sebenar);
|
||||||
|
|
||||||
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
|
||||||
'norujukan' => $norujukan,
|
'norujukan' => $norujukan,
|
||||||
'bayaran_keuntungan' => $upah_tebus,
|
'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
|
||||||
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
||||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||||
'tarikh_bayaran'=> $current,
|
'tarikh_bayaran'=> $current,
|
||||||
@@ -944,20 +982,19 @@ class Penebusan
|
|||||||
$array_tebus = $request->only(['jeniskeuntungan', 'nopelanggan','jenistebus','addpinjaman','nowakil','marhun','teller']);
|
$array_tebus = $request->only(['jeniskeuntungan', 'nopelanggan','jenistebus','addpinjaman','nowakil','marhun','teller']);
|
||||||
$array_trans = $request->only(['nopelanggan', 'noic','jenisAT','pinjaman','pinjamanbaru','marhun','teller','jenistebus']);
|
$array_trans = $request->only(['nopelanggan', 'noic','jenisAT','pinjaman','pinjamanbaru','marhun','teller','jenistebus']);
|
||||||
$array_tebus_base = $request->only(['totalbayaran', 'bakiupah','jeniskeuntungan','bakipinjaman','jenistebus','teller','nowakil','duitpelanggan']);
|
$array_tebus_base = $request->only(['totalbayaran', 'bakiupah','jeniskeuntungan','bakipinjaman','jenistebus','teller','nowakil','duitpelanggan']);
|
||||||
$array_trans_base = $request->only(['pinjaman','teller','pinjamanbaru']);
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
DB::connection($cawangan['mysql'])->beginTransaction();
|
DB::connection($cawangan['mysql'])->beginTransaction();
|
||||||
$this->saveTebus($kodcaw,$norujukan,$gadai,$cawangan,$array_tebus);
|
$this->saveTebus($kodcaw,$norujukan,$gadai,$cawangan,$array_tebus);
|
||||||
$this->createTransaction($cawangan,$kodcaw,$norujukan,$array_trans);
|
$newReference = $this->createTransaction($cawangan,$kodcaw,$norujukan,$array_trans);
|
||||||
|
|
||||||
DB::connection('mysql7')->beginTransaction();
|
DB::connection('mysql7')->beginTransaction();
|
||||||
$this->saveTebusBase($kodcaw,$norujukan,$gadai,$array_tebus_base);
|
$this->saveTebusBase($kodcaw,$norujukan,$gadai,$array_tebus_base);
|
||||||
$this->createTransactionBase($norujukan,$kodcaw,$array_trans_base);
|
|
||||||
$array_response = [
|
$array_response = [
|
||||||
'result' => 'success',
|
'result' => 'success',
|
||||||
'data' => 1
|
'data' => 1,
|
||||||
|
'norujukan_baru' => $newReference
|
||||||
];
|
];
|
||||||
|
|
||||||
DB::connection($cawangan['mysql'])->commit();
|
DB::connection($cawangan['mysql'])->commit();
|
||||||
@@ -1004,19 +1041,18 @@ class Penebusan
|
|||||||
$array_tebus = $request->only(['jeniskeuntungan', 'nopelanggan','jenistebus','addpinjaman','nowakil','marhun','teller']);
|
$array_tebus = $request->only(['jeniskeuntungan', 'nopelanggan','jenistebus','addpinjaman','nowakil','marhun','teller']);
|
||||||
$array_trans = $request->only(['nopelanggan', 'noic','pinjaman','pinjamanbaru','marhun','teller','jenistebus']);
|
$array_trans = $request->only(['nopelanggan', 'noic','pinjaman','pinjamanbaru','marhun','teller','jenistebus']);
|
||||||
$array_tebus_base = $request->only(['totalbayaran', 'bakiupah','jeniskeuntungan','bakipinjaman','jenistebus','teller','nowakil','duitpelanggan']);
|
$array_tebus_base = $request->only(['totalbayaran', 'bakiupah','jeniskeuntungan','bakipinjaman','jenistebus','teller','nowakil','duitpelanggan']);
|
||||||
$array_trans_base = $request->only(['pinjaman','teller','pinjamanbaru']);
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
DB::connection($cawangan['mysql'])->beginTransaction();
|
DB::connection($cawangan['mysql'])->beginTransaction();
|
||||||
$this->saveTebus($kodcaw,$norujukan,$gadai,$cawangan,$array_tebus);
|
$this->saveTebus($kodcaw,$norujukan,$gadai,$cawangan,$array_tebus);
|
||||||
$this->createTransaction($cawangan,$kodcaw,$norujukan,$array_trans);
|
$newReference = $this->createTransaction($cawangan,$kodcaw,$norujukan,$array_trans);
|
||||||
DB::connection('mysql7')->beginTransaction();
|
DB::connection('mysql7')->beginTransaction();
|
||||||
$this->saveTebusBase($kodcaw,$norujukan,$gadai,$array_tebus_base);
|
$this->saveTebusBase($kodcaw,$norujukan,$gadai,$array_tebus_base);
|
||||||
$this->createTransactionBase($norujukan,$kodcaw,$array_trans_base);
|
|
||||||
|
|
||||||
$array_response = [
|
$array_response = [
|
||||||
'result' => 'success',
|
'result' => 'success',
|
||||||
'data' => 1
|
'data' => 1,
|
||||||
|
'norujukan_baru' => $newReference
|
||||||
];
|
];
|
||||||
|
|
||||||
DB::connection($cawangan['mysql'])->commit();
|
DB::connection($cawangan['mysql'])->commit();
|
||||||
@@ -1131,12 +1167,16 @@ class Penebusan
|
|||||||
$onepercent_rebet = $array_onepercent_rebet['onepercent'] - $upah_rebet['onepercent'];
|
$onepercent_rebet = $array_onepercent_rebet['onepercent'] - $upah_rebet['onepercent'];
|
||||||
$ujrah_rebet = $array_onepercent_rebet['ujrah'] - $upah_rebet['ujrah'];
|
$ujrah_rebet = $array_onepercent_rebet['ujrah'] - $upah_rebet['ujrah'];
|
||||||
|
|
||||||
|
$diskaun = $this->diskaunAnnur($kodcaw, $gadai);
|
||||||
|
$harga_tebus['harga'] -= $diskaun;
|
||||||
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
||||||
|
|
||||||
|
$bayaran_keuntungan_bersih = max(0, $upah_rebet_sebenar);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
TransaksiKeuntungan::on('mysql7')->create([
|
TransaksiKeuntungan::on('mysql7')->create([
|
||||||
'norujukan' => $norujukan,
|
'norujukan' => $norujukan,
|
||||||
'bayaran_keuntungan' => $upah_tebus,
|
'bayaran_keuntungan' => $bayaran_keuntungan_bersih,
|
||||||
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
||||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||||
'tarikh_bayaran'=> $current,
|
'tarikh_bayaran'=> $current,
|
||||||
@@ -1184,7 +1224,7 @@ class Penebusan
|
|||||||
$gadaiTransaction = Gadai::on($cawangan['mysql'])->where('t_gadai','=',$current->toDateString())->orderBy('sirig', 'desc')->first();
|
$gadaiTransaction = Gadai::on($cawangan['mysql'])->where('t_gadai','=',$current->toDateString())->orderBy('sirig', 'desc')->first();
|
||||||
$gadaiTransaction = optional($gadaiTransaction)->toArray();
|
$gadaiTransaction = optional($gadaiTransaction)->toArray();
|
||||||
|
|
||||||
$new_sirig = ($gadaiTransaction) ? $gadaiTransaction['sirig'] + 1 : 1;
|
$new_sirig = (int) ($gadaiTransaction['sirig'] ?? 0) + 1;
|
||||||
$curent_year = substr($current->year,2,2);
|
$curent_year = substr($current->year,2,2);
|
||||||
$curent_month = sprintf("%02d", $current->month);
|
$curent_month = sprintf("%02d", $current->month);
|
||||||
$current_day = sprintf("%02d", $current->day);
|
$current_day = sprintf("%02d", $current->day);
|
||||||
@@ -1312,39 +1352,11 @@ class Penebusan
|
|||||||
't_update' => $current->toDateString(),
|
't_update' => $current->toDateString(),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
return $new_sag_number;
|
||||||
}catch(\Exception $e){
|
}catch(\Exception $e){
|
||||||
throw new \Exception("Error in Transaction: " . $e->getMessage());
|
throw new \Exception("Error in Transaction: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createTransactionBase($norujukan,$kodcaw,$array_trans_base){
|
}
|
||||||
$current = Carbon::now();
|
|
||||||
|
|
||||||
$komuditi_current = KomuditiPurchase::on('mysql7')->where('date_purchase','=',$current->toDateString())->orderBy('created_at','desc')->first();
|
|
||||||
|
|
||||||
$unit_current = isset($komuditi_current['unit_komuditi']) ? $komuditi_current['unit_komuditi']: 0;
|
|
||||||
|
|
||||||
try{
|
|
||||||
$update_unit = $unit_current - $array_trans_base['pinjamanbaru'];
|
|
||||||
|
|
||||||
KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
|
|
||||||
'unit_komuditi' => $update_unit
|
|
||||||
]);
|
|
||||||
|
|
||||||
KomuditiTransaksi::on('mysql7')->create([
|
|
||||||
'unit_komuditi' => $update_unit,
|
|
||||||
'nosijil'=>$komuditi_current['no_sijil'],
|
|
||||||
'norujukan' => $norujukan,
|
|
||||||
'kodcaw' => $kodcaw,
|
|
||||||
'teller' => $array_trans_base['teller'],
|
|
||||||
'masa' => $current->toTimeString(),
|
|
||||||
'tarikh' => $current->toDateString()
|
|
||||||
]);
|
|
||||||
}catch(\Exception $e){
|
|
||||||
throw new \Exception("Error in TransactionBase: " . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
+2
-1
@@ -52,7 +52,8 @@ class Tebus extends Model
|
|||||||
'pinjamanterkini',
|
'pinjamanterkini',
|
||||||
'tarikhbyrn',
|
'tarikhbyrn',
|
||||||
'ujrah',
|
'ujrah',
|
||||||
'onepercent'
|
'onepercent',
|
||||||
|
'diskaun_rebate'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class TransaksiKeuntungan extends Model
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'norujukan','bayaran_keuntungan','tarikh_bayaran','kodcaw','bayaran_pembiayaan','keuntungan_rebet','ujrah','ujrah_rebet','onepercent','onepercent_rebet','tempoh','beza_tempoh','margin_semasa','rounded'
|
'norujukan','bayaran_keuntungan','tarikh_bayaran','kodcaw','bayaran_pembiayaan','keuntungan_rebet','ujrah','ujrah_rebet','onepercent','onepercent_rebet','tempoh','beza_tempoh','margin_semasa','rounded','kadardiskaun'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+11
-3
@@ -87,12 +87,17 @@ $app->singleton(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$app->configure('app');
|
$app->configure('app');
|
||||||
|
$app->configure('services');
|
||||||
$app->configure('logging');
|
$app->configure('logging');
|
||||||
|
$app->configure('logviewer');
|
||||||
$app->configure('tinker');
|
$app->configure('tinker');
|
||||||
$app->configure('tennant_database');
|
$app->configure('tennant_database');
|
||||||
$app->configure('report');
|
$app->configure('report');
|
||||||
$app->configure('app_parameter');
|
$app->configure('app_parameter');
|
||||||
$app->configure('parameter');
|
$app->configure('parameter');
|
||||||
|
$app->configure('whatsapp');
|
||||||
|
$app->configure('kaunter');
|
||||||
|
$app->configure('bsas');
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Register Middleware
|
| Register Middleware
|
||||||
@@ -108,9 +113,9 @@ $app->configure('parameter');
|
|||||||
// App\Http\Middleware\ExampleMiddleware::class
|
// App\Http\Middleware\ExampleMiddleware::class
|
||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
// $app->routeMiddleware([
|
$app->routeMiddleware([
|
||||||
// 'auth' => App\Http\Middleware\Authenticate::class,
|
'logviewer.password' => App\Http\Middleware\LogViewerPassword::class,
|
||||||
// ]);
|
]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -153,4 +158,7 @@ $app->middleware([
|
|||||||
$app->register(\Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider::class);
|
$app->register(\Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider::class);
|
||||||
$app->register(\Laravel\Tinker\TinkerServiceProvider::class);
|
$app->register(\Laravel\Tinker\TinkerServiceProvider::class);
|
||||||
$app->register(\App\Providers\AppServiceProvider::class);
|
$app->register(\App\Providers\AppServiceProvider::class);
|
||||||
|
|
||||||
|
$app->register(\KitLoong\MigrationsGenerator\MigrationsGeneratorServiceProvider::class);
|
||||||
|
|
||||||
return $app;
|
return $app;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fzaninotto/faker": "^1.9.1",
|
"fzaninotto/faker": "^1.9.1",
|
||||||
|
"kitloong/laravel-migrations-generator": "^6.11",
|
||||||
"mockery/mockery": "^1.3.1",
|
"mockery/mockery": "^1.3.1",
|
||||||
"phpunit/phpunit": "^8.5"
|
"phpunit/phpunit": "^8.5"
|
||||||
},
|
},
|
||||||
|
|||||||
Generated
+142
-4
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "2a35e67752107934701ceea957a4fd34",
|
"content-hash": "64c3d9455edb548f4cd5ec1f8d9f77be",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "auth0/auth0-php",
|
"name": "auth0/auth0-php",
|
||||||
@@ -6686,6 +6686,81 @@
|
|||||||
},
|
},
|
||||||
"time": "2020-07-09T08:09:16+00:00"
|
"time": "2020-07-09T08:09:16+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "kitloong/laravel-migrations-generator",
|
||||||
|
"version": "v6.11.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/kitloong/laravel-migrations-generator.git",
|
||||||
|
"reference": "0f007e86dce6e0cfd71dc0b757da18851c376c3b"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/kitloong/laravel-migrations-generator/zipball/0f007e86dce6e0cfd71dc0b757da18851c376c3b",
|
||||||
|
"reference": "0f007e86dce6e0cfd71dc0b757da18851c376c3b",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"doctrine/dbal": "^2.4|^3.0",
|
||||||
|
"ext-pdo": "*",
|
||||||
|
"illuminate/support": "^5.6|^6.0|^7.0|^8.0|^9.0|^10.0",
|
||||||
|
"myclabs/php-enum": "^1.6|^1.7|^1.8",
|
||||||
|
"php": ">=7.1.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"barryvdh/laravel-ide-helper": "^2.5",
|
||||||
|
"friendsofphp/php-cs-fixer": "^2.19.0|^3.1",
|
||||||
|
"larastan/larastan": "^0.4|^0.5|^0.6|^0.7|^1.0|^2.0",
|
||||||
|
"mockery/mockery": "^1.0",
|
||||||
|
"orchestra/testbench": "^3.6|^4.0|^5.0|^6.0|^7.0|^8.0",
|
||||||
|
"phpmd/phpmd": "^2.10",
|
||||||
|
"slevomat/coding-standard": "^6.0|^7.0|^8.5",
|
||||||
|
"squizlabs/php_codesniffer": "^3.5"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"KitLoong\\MigrationsGenerator\\MigrationsGeneratorServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"KitLoong\\MigrationsGenerator\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Kit Loong",
|
||||||
|
"email": "kitloong1008@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Generates Laravel Migrations from an existing database",
|
||||||
|
"keywords": [
|
||||||
|
"artisan",
|
||||||
|
"generator",
|
||||||
|
"laravel",
|
||||||
|
"lumen",
|
||||||
|
"migration",
|
||||||
|
"migrations"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/kitloong/laravel-migrations-generator/issues",
|
||||||
|
"source": "https://github.com/kitloong/laravel-migrations-generator/tree/v6.11.1"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.buymeacoffee.com/kitloong",
|
||||||
|
"type": "custom"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-02-06T14:42:33+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "mockery/mockery",
|
"name": "mockery/mockery",
|
||||||
"version": "1.5.0",
|
"version": "1.5.0",
|
||||||
@@ -6817,6 +6892,69 @@
|
|||||||
],
|
],
|
||||||
"time": "2022-03-03T13:19:32+00:00"
|
"time": "2022-03-03T13:19:32+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "myclabs/php-enum",
|
||||||
|
"version": "1.8.5",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/myclabs/php-enum.git",
|
||||||
|
"reference": "e7be26966b7398204a234f8673fdad5ac6277802"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/e7be26966b7398204a234f8673fdad5ac6277802",
|
||||||
|
"reference": "e7be26966b7398204a234f8673fdad5ac6277802",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
|
"php": "^7.3 || ^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^9.5",
|
||||||
|
"squizlabs/php_codesniffer": "1.*",
|
||||||
|
"vimeo/psalm": "^4.6.2 || ^5.2"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"MyCLabs\\Enum\\": "src/"
|
||||||
|
},
|
||||||
|
"classmap": [
|
||||||
|
"stubs/Stringable.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP Enum contributors",
|
||||||
|
"homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP Enum implementation",
|
||||||
|
"homepage": "https://github.com/myclabs/php-enum",
|
||||||
|
"keywords": [
|
||||||
|
"enum"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/myclabs/php-enum/issues",
|
||||||
|
"source": "https://github.com/myclabs/php-enum/tree/1.8.5"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/mnapoli",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-01-14T11:49:03+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phar-io/manifest",
|
"name": "phar-io/manifest",
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
@@ -8389,12 +8527,12 @@
|
|||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"stability-flags": [],
|
"stability-flags": {},
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "^7.2.5"
|
"php": "^7.2.5"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": {},
|
||||||
"plugin-api-version": "2.3.0"
|
"plugin-api-version": "2.9.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "laravel/lumen",
|
|
||||||
"description": "The Laravel Lumen Framework.",
|
|
||||||
"keywords": ["framework", "laravel", "lumen"],
|
|
||||||
"license": "MIT",
|
|
||||||
"type": "project",
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2.5",
|
|
||||||
"auth0/auth0-php": "^7.4",
|
|
||||||
"laravel/lumen-framework": "^7.0",
|
|
||||||
"rap2hpoutre/laravel-log-viewer": "^1.7"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"fzaninotto/faker": "^1.9.1",
|
|
||||||
"mockery/mockery": "^1.3.1",
|
|
||||||
"phpunit/phpunit": "^8.5"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"database/seeds",
|
|
||||||
"database/factories"
|
|
||||||
],
|
|
||||||
"psr-4": {
|
|
||||||
"App\\": "app/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload-dev": {
|
|
||||||
"classmap": [
|
|
||||||
"tests/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"preferred-install": "dist",
|
|
||||||
"sort-packages": true,
|
|
||||||
"optimize-autoloader": true
|
|
||||||
},
|
|
||||||
"minimum-stability": "dev",
|
|
||||||
"prefer-stable": true,
|
|
||||||
"scripts": {
|
|
||||||
"post-root-package-install": [
|
|
||||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
|||||||
return [
|
return [
|
||||||
'url' => env('APP_URL', 'http://localhost'),
|
'url' => env('APP_URL', 'http://localhost'),
|
||||||
'api_arrahnbid' => env('API_ARRAHNBID', 'http://lelong.test/api/'),
|
'api_arrahnbid' => env('API_ARRAHNBID', 'http://lelong.test/api/'),
|
||||||
|
'api_arrahnbid_annur' => env('API_ARRAHNBID_ANNUR', env('API_ARRAHNBID', 'http://lelong.test/api/')),
|
||||||
'api_v3' => env('API_V3', 'http://apiv3.localhost/api/')
|
'api_v3' => env('API_V3', 'http://apiv3.localhost/api/')
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'base_url' => rtrim(env('BSAS_BASE_URL', 'https://bsasdevapi.bursamalaysia.com/api'), '/'),
|
||||||
|
'token_url' => env('BSAS_TOKEN_URL', 'https://bsasdevapi.bursamalaysia.com/oauth/token'),
|
||||||
|
'client_id' => env('BSAS_CLIENT_ID'),
|
||||||
|
'client_secret' => env('BSAS_CLIENT_SECRET'),
|
||||||
|
'member_short_name' => env('BSAS_MEMBER_SHORT_NAME', 'KOOPPKB'),
|
||||||
|
'product_code' => env('BSAS_PRODUCT_CODE', 'CPO-MSIA-09'),
|
||||||
|
'tenor' => env('BSAS_TENOR', '00088'),
|
||||||
|
'max_wait_time' => (int) env('BSAS_MAX_WAIT_TIME', 10),
|
||||||
|
'http_timeout' => (int) env('BSAS_HTTP_TIMEOUT', 30),
|
||||||
|
'order_result_retries' => (int) env('BSAS_ORDER_RESULT_RETRIES', 2),
|
||||||
|
];
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'url' => env('KAUNTER_URL', ''),
|
||||||
|
'notification_secret' => env('INTERNAL_NOTIFICATION_SECRET', ''),
|
||||||
|
'notification_timeout' => (int) env('KAUNTER_NOTIFICATION_TIMEOUT', 3),
|
||||||
|
];
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'password' => env('LOGVIEWER_PASSWORD'),
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Pattern and storage path settings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The env key for pattern and storage path with a default value
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'max_file_size' => 52428800, // size in Byte
|
||||||
|
'pattern' => env('LOGVIEWER_PATTERN', '*.log'),
|
||||||
|
'storage_path' => env('LOGVIEWER_STORAGE_PATH', storage_path('logs')),
|
||||||
|
];
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
'shoraka' => [
|
||||||
|
// Local UI tests only: off, failed or pending. Success is deliberately excluded.
|
||||||
|
'simulation' => env('SHORAKA_SIMULATION', 'off'),
|
||||||
|
'base_url' => env(
|
||||||
|
'SHORAKA_BASE_URL',
|
||||||
|
'https://uat2.shorakagroup.com'
|
||||||
|
),
|
||||||
|
|
||||||
|
'api_id' => env('SHORAKA_API_ID'),
|
||||||
|
|
||||||
|
'secret_key' => env('SHORAKA_SECRET_KEY'),
|
||||||
|
|
||||||
|
'timeout' => env(
|
||||||
|
'SHORAKA_TIMEOUT',
|
||||||
|
60
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'whatsapp_cloud_enabled' => env('WHATSAPP_CLOUD_ENABLED', true),
|
||||||
|
'token' => env('WHATSAPP_TOKEN'),
|
||||||
|
'phone_number_id' => env('WHATSAPP_PHONE_NUMBER_ID'),
|
||||||
|
'api_version' => env('WHATSAPP_API_VERSION', 'v25.0'),
|
||||||
|
'template' => env('WHATSAPP_TEMPLATE', 'hello_world'),
|
||||||
|
'template_lang' => env('WHATSAPP_TEMPLATE_LANG', 'en_US'),
|
||||||
|
'verify_token' => env('WHATSAPP_VERIFY_TOKEN'),
|
||||||
|
'app_secret' => env('WHATSAPP_APP_SECRET'),
|
||||||
|
];
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateKadarRebetTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Master DB (mysql7) — Annur rebet bands by pembiayaan range.
|
||||||
|
* Empty table + feature flag off = other cawangan unchanged.
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
if (Schema::connection('mysql7')->hasTable('kadar_rebet')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Schema::connection('mysql7')->create('kadar_rebet', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->decimal('pembiayaan_min', 12, 2)->default(0);
|
||||||
|
$table->decimal('pembiayaan_max', 12, 2)->default(0);
|
||||||
|
$table->decimal('kadarrebet', 8, 4)->default(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql7')->dropIfExists('kadar_rebet');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddAnnurDiskaunColumns extends Migration
|
||||||
|
{
|
||||||
|
public function getActiveDB()
|
||||||
|
{
|
||||||
|
$config_db = array_keys(config('database.connections'));
|
||||||
|
|
||||||
|
return array_filter($config_db, function ($connection) {
|
||||||
|
try {
|
||||||
|
if ($connection === 'mysql7') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
DB::connection($connection)->getPdo();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
foreach ($this->getActiveDB() as $dbase) {
|
||||||
|
if (Schema::connection($dbase)->hasTable('gadai')) {
|
||||||
|
$addKadar = !Schema::connection($dbase)->hasColumn('gadai', 'kadarrebet');
|
||||||
|
$addDiskaun = !Schema::connection($dbase)->hasColumn('gadai', 'diskaun');
|
||||||
|
if ($addKadar || $addDiskaun) {
|
||||||
|
Schema::connection($dbase)->table('gadai', function (Blueprint $table) use ($addKadar, $addDiskaun) {
|
||||||
|
if ($addKadar) {
|
||||||
|
$table->decimal('kadarrebet', 8, 4)->nullable()->default(0);
|
||||||
|
}
|
||||||
|
if ($addDiskaun) {
|
||||||
|
$table->decimal('diskaun', 12, 2)->nullable()->default(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
Schema::connection($dbase)->hasTable('tebus')
|
||||||
|
&& !Schema::connection($dbase)->hasColumn('tebus', 'diskaun_rebate')
|
||||||
|
) {
|
||||||
|
Schema::connection($dbase)->table('tebus', function (Blueprint $table) {
|
||||||
|
$table->decimal('diskaun_rebate', 12, 2)->nullable()->default(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
Schema::connection('mysql7')->hasTable('transaksi_keuntungan')
|
||||||
|
&& !Schema::connection('mysql7')->hasColumn('transaksi_keuntungan', 'kadardiskaun')
|
||||||
|
) {
|
||||||
|
Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) {
|
||||||
|
$table->decimal('kadardiskaun', 12, 2)->nullable()->default(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
foreach ($this->getActiveDB() as $dbase) {
|
||||||
|
if (Schema::connection($dbase)->hasTable('gadai')) {
|
||||||
|
Schema::connection($dbase)->table('gadai', function (Blueprint $table) use ($dbase) {
|
||||||
|
$drops = [];
|
||||||
|
if (Schema::connection($dbase)->hasColumn('gadai', 'kadarrebet')) {
|
||||||
|
$drops[] = 'kadarrebet';
|
||||||
|
}
|
||||||
|
if (Schema::connection($dbase)->hasColumn('gadai', 'diskaun')) {
|
||||||
|
$drops[] = 'diskaun';
|
||||||
|
}
|
||||||
|
if ($drops) {
|
||||||
|
$table->dropColumn($drops);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
Schema::connection($dbase)->hasTable('tebus')
|
||||||
|
&& Schema::connection($dbase)->hasColumn('tebus', 'diskaun_rebate')
|
||||||
|
) {
|
||||||
|
Schema::connection($dbase)->table('tebus', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('diskaun_rebate');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
Schema::connection('mysql7')->hasTable('transaksi_keuntungan')
|
||||||
|
&& Schema::connection('mysql7')->hasColumn('transaksi_keuntungan', 'kadardiskaun')
|
||||||
|
) {
|
||||||
|
Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('kadardiskaun');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateShorakaTransactionsTable extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create(
|
||||||
|
'shoraka_transactions',
|
||||||
|
function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
|
||||||
|
// Rujukan pembiayaan dalam eRahn
|
||||||
|
$table->string('norujukan')->unique();
|
||||||
|
|
||||||
|
// Maklumat daripada Shoraka
|
||||||
|
$table->string('order_id')
|
||||||
|
->nullable()
|
||||||
|
->unique();
|
||||||
|
|
||||||
|
$table->string('status')
|
||||||
|
->default('PENDING');
|
||||||
|
|
||||||
|
$table->string('product_type')
|
||||||
|
->default('FINANCING');
|
||||||
|
|
||||||
|
$table->string('commodity_type');
|
||||||
|
|
||||||
|
$table->string('ownership_name');
|
||||||
|
$table->string('ownership_doc_no')
|
||||||
|
->nullable();
|
||||||
|
|
||||||
|
$table->decimal(
|
||||||
|
'order_amount',
|
||||||
|
15,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
|
||||||
|
$table->decimal(
|
||||||
|
'murabaha_amount',
|
||||||
|
15,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
|
||||||
|
$table->string('certificate_url')
|
||||||
|
->nullable();
|
||||||
|
|
||||||
|
$table->string('certificate_path')
|
||||||
|
->nullable();
|
||||||
|
|
||||||
|
// Simpan payload untuk audit dan troubleshooting
|
||||||
|
$table->json('request_payload')
|
||||||
|
->nullable();
|
||||||
|
|
||||||
|
$table->json('response_payload')
|
||||||
|
->nullable();
|
||||||
|
|
||||||
|
$table->json('callback_payload')
|
||||||
|
->nullable();
|
||||||
|
|
||||||
|
$table->unsignedInteger('attempt_count')
|
||||||
|
->default(0);
|
||||||
|
|
||||||
|
$table->text('error_message')
|
||||||
|
->nullable();
|
||||||
|
|
||||||
|
$table->timestamp('submitted_at')
|
||||||
|
->nullable();
|
||||||
|
|
||||||
|
$table->timestamp('completed_at')
|
||||||
|
->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->index('status');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('shoraka_transactions');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddPcVerifiedToPembiayaanOnlineTable extends Migration
|
||||||
|
{
|
||||||
|
public function getActiveDB()
|
||||||
|
{
|
||||||
|
return array_filter(
|
||||||
|
array_keys(config('database.connections')),
|
||||||
|
function ($connection) {
|
||||||
|
try {
|
||||||
|
if ($connection === 'mysql7') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::connection($connection)->getPdo();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
foreach ($this->getActiveDB() as $dbase) {
|
||||||
|
if (!Schema::connection($dbase)->hasTable('pembiayaan_online')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Schema::connection($dbase)->table('pembiayaan_online', function (Blueprint $table) use ($dbase) {
|
||||||
|
if (!Schema::connection($dbase)->hasColumn('pembiayaan_online', 'pc_verified_by')) {
|
||||||
|
$table->string('pc_verified_by', 100)
|
||||||
|
->nullable()
|
||||||
|
->after('pc_submitted_by');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Schema::connection($dbase)->hasColumn('pembiayaan_online', 'pc_verified_at')) {
|
||||||
|
$table->timestamp('pc_verified_at')
|
||||||
|
->nullable()
|
||||||
|
->after('pc_verified_by');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
foreach ($this->getActiveDB() as $dbase) {
|
||||||
|
if (!Schema::connection($dbase)->hasTable('pembiayaan_online')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Schema::connection($dbase)->table('pembiayaan_online', function (Blueprint $table) use ($dbase) {
|
||||||
|
$cols = [];
|
||||||
|
if (Schema::connection($dbase)->hasColumn('pembiayaan_online', 'pc_verified_at')) {
|
||||||
|
$cols[] = 'pc_verified_at';
|
||||||
|
}
|
||||||
|
if (Schema::connection($dbase)->hasColumn('pembiayaan_online', 'pc_verified_by')) {
|
||||||
|
$cols[] = 'pc_verified_by';
|
||||||
|
}
|
||||||
|
if (!empty($cols)) {
|
||||||
|
$table->dropColumn($cols);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddKodcawToShorakaTransactions extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('shoraka_transactions', function (Blueprint $table) {
|
||||||
|
$table->string('kodcaw', 20)->nullable()->index();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('shoraka_transactions', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('kodcaw');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateBsasOrdersTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Master DB (mysql7) — per-Terima BSAS commodity orders.
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
if (Schema::connection('mysql7')->hasTable('bsas_orders')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Schema::connection('mysql7')->create('bsas_orders', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id');
|
||||||
|
$table->string('uuid', 64)->nullable()->unique();
|
||||||
|
$table->string('norujukan', 50)->index();
|
||||||
|
$table->string('kodcaw', 20)->index();
|
||||||
|
$table->string('serial_number', 20)->default('1');
|
||||||
|
$table->string('product_code', 50)->nullable();
|
||||||
|
$table->decimal('bid_value', 14, 2)->nullable();
|
||||||
|
$table->decimal('otc_murabaha_value', 14, 2)->nullable();
|
||||||
|
$table->string('otc_counter_party', 150)->nullable();
|
||||||
|
$table->string('status', 30)->default('pending')->index();
|
||||||
|
$table->integer('status_code')->nullable();
|
||||||
|
$table->string('status_message', 255)->nullable();
|
||||||
|
$table->string('e_cert_no', 100)->nullable()->index();
|
||||||
|
$table->json('bid_ecert_response')->nullable();
|
||||||
|
$table->json('otc_ecert_response')->nullable();
|
||||||
|
$table->json('stb_ecert_response')->nullable();
|
||||||
|
$table->json('request_payload')->nullable();
|
||||||
|
$table->json('order_response')->nullable();
|
||||||
|
$table->json('result_response')->nullable();
|
||||||
|
$table->string('created_by', 100)->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->index(['norujukan', 'status']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql7')->dropIfExists('bsas_orders');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddTellerToShorakaTransactions extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('shoraka_transactions', function (Blueprint $table) {
|
||||||
|
$table->string('teller')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('shoraka_transactions', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('teller');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class DropUnusedCawanganTables extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Empty legacy tables on every branch database.
|
||||||
|
* mysql7 is the master database and is skipped.
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$tables = [
|
||||||
|
'advansur',
|
||||||
|
'alert',
|
||||||
|
'ansrugi',
|
||||||
|
'auditbarcode',
|
||||||
|
'auditdaftar',
|
||||||
|
'auditrekodsemakan',
|
||||||
|
'audtrail',
|
||||||
|
'bajet',
|
||||||
|
'bakipelanggan',
|
||||||
|
'batchlel_xtra',
|
||||||
|
'bayaranpenebusan',
|
||||||
|
'belian',
|
||||||
|
'budgetgadai',
|
||||||
|
'budgettebus',
|
||||||
|
'budgetupah',
|
||||||
|
'checker',
|
||||||
|
'configkaunter',
|
||||||
|
'coordination',
|
||||||
|
'customer',
|
||||||
|
'gadaisimulasi',
|
||||||
|
'gadaitemp',
|
||||||
|
'gadaixtra',
|
||||||
|
'glejer',
|
||||||
|
'hapusgadaionline',
|
||||||
|
'hapuskira',
|
||||||
|
'hargaemasbeli',
|
||||||
|
'hargaemasjual',
|
||||||
|
'imbangan',
|
||||||
|
'imbang_duga_lama',
|
||||||
|
'inoutmarxtra',
|
||||||
|
'jemas00',
|
||||||
|
'jemasbeli',
|
||||||
|
'jemasxtra',
|
||||||
|
'jualan',
|
||||||
|
'jualemas',
|
||||||
|
'jumlahtebus',
|
||||||
|
'karatbeli',
|
||||||
|
'karatjual',
|
||||||
|
'karatxtra',
|
||||||
|
'kawalanstok',
|
||||||
|
'kawalanstokxtra',
|
||||||
|
'kawalanstok_lama',
|
||||||
|
'kumpulan',
|
||||||
|
'kurangxtra',
|
||||||
|
'ku_nm',
|
||||||
|
'ku_nmbaru',
|
||||||
|
'ku_nmxtra',
|
||||||
|
'lapringkasan',
|
||||||
|
'lapterkumpul',
|
||||||
|
'lapterkumpulharian',
|
||||||
|
'lelkarat',
|
||||||
|
'lelmarhun_xtra',
|
||||||
|
'lelongxtra',
|
||||||
|
'marhunbeli',
|
||||||
|
'marhunjual',
|
||||||
|
'marhunsimulasi',
|
||||||
|
'marhunxtra',
|
||||||
|
'model',
|
||||||
|
'outmarhun',
|
||||||
|
'outmarhunxtra',
|
||||||
|
'parameter',
|
||||||
|
'pelelong',
|
||||||
|
'pembeliemas',
|
||||||
|
'pemeriksaan',
|
||||||
|
'pengesahangadai',
|
||||||
|
'pengguna',
|
||||||
|
'percentonline',
|
||||||
|
'polisxtra',
|
||||||
|
'poskod',
|
||||||
|
'ramalan',
|
||||||
|
'rekodtangguh',
|
||||||
|
'sahabat',
|
||||||
|
'senhitam',
|
||||||
|
'serahbaki',
|
||||||
|
'simpanan',
|
||||||
|
'simulasi_batchlel',
|
||||||
|
'simulasi_batchlelxtra',
|
||||||
|
'simulasi_lelmarhun',
|
||||||
|
'simulasi_lelongxtra',
|
||||||
|
'syarikat',
|
||||||
|
'tagpelanggan',
|
||||||
|
'tebuslelong',
|
||||||
|
'tebus_xtra',
|
||||||
|
'tempimbang',
|
||||||
|
'tempnosiri',
|
||||||
|
'tempnosirixtra',
|
||||||
|
'temppwd',
|
||||||
|
'temptarikhaging',
|
||||||
|
'temp_ic',
|
||||||
|
'tunaigadteb',
|
||||||
|
'tuntutan',
|
||||||
|
'tuntutbakixtra',
|
||||||
|
'ubs_code',
|
||||||
|
'zparameter',
|
||||||
|
'zparameter1',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($this->getActiveDB() as $connection) {
|
||||||
|
$this->dropTables($connection, $tables);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// Original table definitions are not kept. This drop cannot be reversed.
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getActiveDB()
|
||||||
|
{
|
||||||
|
$config_db = array_keys(config('database.connections'));
|
||||||
|
|
||||||
|
return array_filter($config_db, function ($connection) {
|
||||||
|
try {
|
||||||
|
if ($connection === 'mysql7') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::connection($connection)->getPdo();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function dropTables($connection, array $tables)
|
||||||
|
{
|
||||||
|
$db = DB::connection($connection);
|
||||||
|
$placeholders = implode(',', array_fill(0, count($tables), '?'));
|
||||||
|
$rows = $db->select(
|
||||||
|
"SELECT TABLE_NAME AS table_name
|
||||||
|
FROM information_schema.TABLES
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_TYPE = 'BASE TABLE'
|
||||||
|
AND LOWER(TABLE_NAME) IN ($placeholders)",
|
||||||
|
$tables
|
||||||
|
);
|
||||||
|
|
||||||
|
if (count($rows) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$quoted = array_map(function ($row) {
|
||||||
|
return '`'.str_replace('`', '``', $row->table_name).'`';
|
||||||
|
}, $rows);
|
||||||
|
|
||||||
|
$db->statement('SET FOREIGN_KEY_CHECKS=0');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$db->statement('DROP TABLE IF EXISTS '.implode(', ', $quoted));
|
||||||
|
} finally {
|
||||||
|
$db->statement('SET FOREIGN_KEY_CHECKS=1');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class DropUnusedMasterTables extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Empty legacy tables on the master database (mysql7).
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$tables = [
|
||||||
|
'approval_withdrawal',
|
||||||
|
'cawangan00',
|
||||||
|
'cawangan_notis',
|
||||||
|
'coordination',
|
||||||
|
'customers_main',
|
||||||
|
'log_blast_sms',
|
||||||
|
'log_blast_wasap',
|
||||||
|
'mobile_payment_info',
|
||||||
|
'mobile_payment_log',
|
||||||
|
'moratorium',
|
||||||
|
'otp_token',
|
||||||
|
'tac_express_payment',
|
||||||
|
];
|
||||||
|
|
||||||
|
$db = DB::connection('mysql7');
|
||||||
|
$placeholders = implode(',', array_fill(0, count($tables), '?'));
|
||||||
|
$rows = $db->select(
|
||||||
|
"SELECT TABLE_NAME AS table_name
|
||||||
|
FROM information_schema.TABLES
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_TYPE = 'BASE TABLE'
|
||||||
|
AND LOWER(TABLE_NAME) IN ($placeholders)",
|
||||||
|
$tables
|
||||||
|
);
|
||||||
|
|
||||||
|
if (count($rows) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$quoted = array_map(function ($row) {
|
||||||
|
return '`'.str_replace('`', '``', $row->table_name).'`';
|
||||||
|
}, $rows);
|
||||||
|
|
||||||
|
$db->statement('SET FOREIGN_KEY_CHECKS=0');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$db->statement('DROP TABLE IF EXISTS '.implode(', ', $quoted));
|
||||||
|
} finally {
|
||||||
|
$db->statement('SET FOREIGN_KEY_CHECKS=1');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// Original table definitions are not kept. This drop cannot be reversed.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateAddtunaiTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('addtunai', function (Blueprint $table) {
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->string('kodcaw', 10)->nullable()->default('');
|
||||||
|
$table->string('kodlaluan', 100)->nullable()->default('');
|
||||||
|
$table->decimal('tambah', 11)->nullable()->default(0);
|
||||||
|
$table->decimal('kurang', 11)->nullable()->default(0);
|
||||||
|
$table->string('nota', 40)->nullable()->default('');
|
||||||
|
$table->integer('bil')->default(0);
|
||||||
|
$table->timestamp('created_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('addtunai');
|
||||||
|
}
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateAkruNetPecahanTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('akru_net_pecahan', function (Blueprint $table) {
|
||||||
|
$table->unsignedBigInteger('id');
|
||||||
|
$table->integer('tahun');
|
||||||
|
$table->integer('bulan');
|
||||||
|
$table->decimal('persen_semasa', 9);
|
||||||
|
$table->decimal('ujrah_semasa', 9);
|
||||||
|
$table->decimal('persen_sebelum', 9);
|
||||||
|
$table->decimal('ujrah_sebelum', 9);
|
||||||
|
$table->decimal('keuntungan_semasa_1persen', 9);
|
||||||
|
$table->decimal('keuntungan_semasa_ujrah', 9);
|
||||||
|
$table->decimal('baki_keun_blm_byr_1persen', 9);
|
||||||
|
$table->decimal('baki_keun_blm_byr_ujrah', 9);
|
||||||
|
$table->decimal('pend_akru_1persen', 9);
|
||||||
|
$table->decimal('pend_akru_ujrah', 9);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('akru_net_pecahan');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateAkruNetTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('akru_net', function (Blueprint $table) {
|
||||||
|
$table->integer('id');
|
||||||
|
$table->integer('tahun')->nullable();
|
||||||
|
$table->integer('bulan')->nullable();
|
||||||
|
$table->decimal('jumlah', 9)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('akru_net');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateBandarTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('bandar', function (Blueprint $table) {
|
||||||
|
$table->string('kodbandar', 10)->nullable();
|
||||||
|
$table->string('namabandar', 30)->nullable();
|
||||||
|
$table->string('kodnegeri', 3)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('bandar');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateBankTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('bank', function (Blueprint $table) {
|
||||||
|
$table->string('bankcode', 10)->nullable();
|
||||||
|
$table->string('bankdesc', 30)->nullable();
|
||||||
|
$table->string('note', 30)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('bank');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateBatalgadaiTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('batalgadai', function (Blueprint $table) {
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->string('norujukan', 20)->nullable();
|
||||||
|
$table->string('tellerid', 50)->nullable();
|
||||||
|
$table->string('namateller', 30)->nullable();
|
||||||
|
$table->date('tarikh');
|
||||||
|
$table->time('masa');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('batalgadai');
|
||||||
|
}
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateBatchPembiayaanOnlineTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('batch_pembiayaan_online', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id');
|
||||||
|
$table->string('batch_no', 50);
|
||||||
|
$table->string('kodcaw', 20);
|
||||||
|
$table->date('tarikh');
|
||||||
|
$table->string('slot', 20)->nullable()->comment('BATCH1 / BATCH2');
|
||||||
|
$table->integer('bilangan')->default(0);
|
||||||
|
$table->decimal('jumlah_keseluruhan', 12)->default(0);
|
||||||
|
$table->string('status', 30)->default('DRAFT');
|
||||||
|
$table->string('pc_submitted_by', 100)->nullable();
|
||||||
|
$table->timestamp('submitted_at')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->index(['kodcaw', 'tarikh', 'status']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('batch_pembiayaan_online');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateBatchlelTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('batchlel', function (Blueprint $table) {
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->string('kodcaw', 10)->default('');
|
||||||
|
$table->integer('batchno');
|
||||||
|
$table->date('tarikh')->nullable()->default('0000-00-00');
|
||||||
|
$table->date('tarikh2')->nullable()->default('0000-00-00');
|
||||||
|
$table->time('masadari')->nullable()->default('00:00:00');
|
||||||
|
$table->time('masahingga')->nullable()->default('00:00:00');
|
||||||
|
$table->string('pilihankos', 1)->default('');
|
||||||
|
$table->decimal('pcntkos', 5)->default(0);
|
||||||
|
$table->decimal('koslelong', 7)->default(0);
|
||||||
|
$table->decimal('jumnm', 11)->default(0);
|
||||||
|
$table->decimal('diskaun', 5)->default(0);
|
||||||
|
$table->string('alamat1', 40)->default('');
|
||||||
|
$table->string('alamat2', 40)->default('');
|
||||||
|
$table->string('alamat3', 40)->default('');
|
||||||
|
$table->string('alamat4', 20)->default('');
|
||||||
|
$table->string('telefon', 30)->default('');
|
||||||
|
$table->integer('nopelelong')->default(0);
|
||||||
|
$table->decimal('percentgst', 3)->default(6);
|
||||||
|
$table->decimal('percentgst_hj', 3)->default(0);
|
||||||
|
$table->date('t_daftar')->nullable();
|
||||||
|
$table->integer('tag_sms')->default(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('batchlel');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateBrandTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('brand', function (Blueprint $table) {
|
||||||
|
$table->integer('brandNo');
|
||||||
|
$table->string('brand', 30);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('brand');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateCawanganTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('cawangan', function (Blueprint $table) {
|
||||||
|
$table->string('kodcaw', 10);
|
||||||
|
$table->string('kodnegeri', 3)->nullable();
|
||||||
|
$table->string('namacaw', 80)->nullable();
|
||||||
|
$table->string('alamat1', 60)->nullable();
|
||||||
|
$table->string('alamat2', 60)->nullable();
|
||||||
|
$table->string('alamat3', 60)->nullable();
|
||||||
|
$table->string('alamat4', 60)->nullable();
|
||||||
|
$table->string('notel', 40)->nullable();
|
||||||
|
$table->string('nofaks', 11);
|
||||||
|
$table->date('systemdate')->nullable();
|
||||||
|
$table->decimal('cajkhidmat', 7)->nullable()->default(0);
|
||||||
|
$table->tinyInteger('openst')->nullable()->default(0);
|
||||||
|
$table->string('prkod', 2)->nullable();
|
||||||
|
$table->string('nokotak', 10)->nullable();
|
||||||
|
$table->string('murtahin', 60)->nullable();
|
||||||
|
$table->string('saksi', 60)->nullable();
|
||||||
|
$table->string('glus', 15)->nullable();
|
||||||
|
$table->string('glut', 15)->nullable();
|
||||||
|
$table->decimal('ut_kasar', 15)->default(0);
|
||||||
|
$table->decimal('belanjat', 15)->default(0);
|
||||||
|
$table->decimal('ut_bersih', 15)->default(0);
|
||||||
|
$table->string('msword', 80)->nullable();
|
||||||
|
$table->date('t_aging');
|
||||||
|
$table->string('cawangan', 20)->nullable()->default('Wakaf Bharu');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('cawangan');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateDaerahTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('daerah', function (Blueprint $table) {
|
||||||
|
$table->integer('koddaerah')->nullable()->default(0);
|
||||||
|
$table->string('namadaerah', 30)->nullable();
|
||||||
|
$table->string('kodnegeri', 3)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('daerah');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateDenominasiTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('denominasi', function (Blueprint $table) {
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->integer('bd1')->default(0);
|
||||||
|
$table->decimal('b1', 11)->default(0);
|
||||||
|
$table->integer('bd5')->default(0);
|
||||||
|
$table->decimal('b5', 11)->default(0);
|
||||||
|
$table->integer('bd10')->default(0);
|
||||||
|
$table->decimal('b10', 11)->default(0);
|
||||||
|
$table->integer('bd20')->default(0);
|
||||||
|
$table->decimal('b20', 11)->default(0);
|
||||||
|
$table->integer('bd50')->default(0);
|
||||||
|
$table->decimal('b50', 11)->default(0);
|
||||||
|
$table->integer('bd100')->default(0);
|
||||||
|
$table->decimal('b100', 11)->default(0);
|
||||||
|
$table->integer('txtring1')->default(0);
|
||||||
|
$table->decimal('k1', 11)->default(0);
|
||||||
|
$table->integer('txtring5')->default(0);
|
||||||
|
$table->decimal('k5', 11)->default(0);
|
||||||
|
$table->integer('txtsen1')->default(0);
|
||||||
|
$table->decimal('k01', 11)->default(0);
|
||||||
|
$table->integer('txtsen5')->default(0);
|
||||||
|
$table->decimal('k05', 11)->default(0);
|
||||||
|
$table->integer('txtsen10')->default(0);
|
||||||
|
$table->decimal('k010', 11)->default(0);
|
||||||
|
$table->integer('txtsen20')->default(0);
|
||||||
|
$table->decimal('k020', 11)->default(0);
|
||||||
|
$table->integer('txtsen50')->default(0);
|
||||||
|
$table->decimal('k050', 11)->default(0);
|
||||||
|
$table->integer('txtring10')->default(0);
|
||||||
|
$table->decimal('k10', 11)->default(0);
|
||||||
|
$table->integer('txtring20')->default(0);
|
||||||
|
$table->decimal('k20', 11)->default(0);
|
||||||
|
$table->integer('txtring50')->default(0);
|
||||||
|
$table->decimal('k50', 11)->default(0);
|
||||||
|
$table->integer('txtring100')->default(0);
|
||||||
|
$table->decimal('k100', 11)->default(0);
|
||||||
|
$table->integer('txtring1000')->default(0);
|
||||||
|
$table->decimal('k1000', 11)->default(0);
|
||||||
|
$table->decimal('jumlahbundle', 11)->default(0);
|
||||||
|
$table->decimal('txtjumlah', 11)->default(0);
|
||||||
|
$table->string('nota', 100)->nullable();
|
||||||
|
$table->decimal('jumlahkeping', 11)->default(0);
|
||||||
|
$table->decimal('lebihan', 11)->default(0);
|
||||||
|
$table->integer('sd1')->default(0);
|
||||||
|
$table->integer('sd2')->default(0);
|
||||||
|
$table->integer('sd5')->default(0);
|
||||||
|
$table->decimal('s1', 11)->default(0);
|
||||||
|
$table->decimal('s2', 11)->default(0);
|
||||||
|
$table->decimal('s5', 11)->default(0);
|
||||||
|
$table->integer('recno');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('denominasi');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateGadaiTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('gadai', function (Blueprint $table) {
|
||||||
|
$table->string('kodcaw', 10)->nullable();
|
||||||
|
$table->string('norujukan', 20);
|
||||||
|
$table->string('prkod', 2)->nullable();
|
||||||
|
$table->string('nopelanggan', 12)->nullable();
|
||||||
|
$table->string('nokp', 14)->nullable();
|
||||||
|
$table->date('t_gadai')->nullable();
|
||||||
|
$table->time('masa')->nullable();
|
||||||
|
$table->integer('sirig')->nullable()->default(0);
|
||||||
|
$table->decimal('nilaimarhun', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('n_marhuns', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('berat', 7)->nullable()->default(0);
|
||||||
|
$table->decimal('pinjaman', 9)->nullable()->default(0);
|
||||||
|
$table->string('cara_terima', 20)->nullable();
|
||||||
|
$table->decimal('telahbayar', 7)->nullable()->default(0);
|
||||||
|
$table->decimal('upahtelahbyr', 7)->default(0);
|
||||||
|
$table->decimal('cajtelahbyr', 7)->nullable()->default(0);
|
||||||
|
$table->decimal('ansuran', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('ansupah', 7)->nullable()->default(0);
|
||||||
|
$table->decimal('kadarupah', 5)->nullable()->default(0);
|
||||||
|
$table->decimal('tempoh', 10)->default(0);
|
||||||
|
$table->date('t_lanjut1')->nullable();
|
||||||
|
$table->date('t_lanjut2')->nullable();
|
||||||
|
$table->date('t_matang')->nullable();
|
||||||
|
$table->date('t_matang1')->nullable();
|
||||||
|
$table->date('t_matang2')->nullable();
|
||||||
|
$table->date('t_notis1')->nullable();
|
||||||
|
$table->date('t_notis2')->nullable();
|
||||||
|
$table->date('t_notis3')->nullable();
|
||||||
|
$table->date('t_lelong')->nullable();
|
||||||
|
$table->date('t_hapus')->nullable();
|
||||||
|
$table->string('sttebus', 1)->nullable();
|
||||||
|
$table->string('terima', 1)->nullable();
|
||||||
|
$table->integer('cetak')->nullable()->default(0);
|
||||||
|
$table->string('tncek', 1)->nullable();
|
||||||
|
$table->string('nocek', 10)->nullable();
|
||||||
|
$table->string('bkcode', 4)->nullable();
|
||||||
|
$table->string('glcode', 15)->nullable();
|
||||||
|
$table->string('teller', 100)->nullable();
|
||||||
|
$table->string('pelulus', 50)->nullable();
|
||||||
|
$table->string('pelulust', 7)->nullable();
|
||||||
|
$table->string('disburseid', 7)->nullable();
|
||||||
|
$table->time('disbursetime')->nullable();
|
||||||
|
$table->string('cancelid', 7)->nullable();
|
||||||
|
$table->time('canceltime')->nullable();
|
||||||
|
$table->string('f_lulus', 1)->nullable();
|
||||||
|
$table->string('tag', 1)->nullable();
|
||||||
|
$table->decimal('jbg', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('bakipjm', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('bakiupah', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('cajlain', 7)->nullable()->default(0);
|
||||||
|
$table->string('marhun')->nullable();
|
||||||
|
$table->string('jenisupah', 1)->nullable();
|
||||||
|
$table->decimal('cajkhidmat', 7)->nullable()->default(0);
|
||||||
|
$table->tinyInteger('stcajkhidmat')->nullable()->default(0);
|
||||||
|
$table->string('kodgl', 15)->nullable();
|
||||||
|
$table->tinyInteger('taglel')->nullable()->default(0);
|
||||||
|
$table->integer('instno')->nullable()->default(0);
|
||||||
|
$table->integer('currInstno')->nullable()->default(0);
|
||||||
|
$table->decimal('ansakhir', 7)->nullable()->default(0);
|
||||||
|
$table->decimal('ansupahakhir', 7)->nullable()->default(0);
|
||||||
|
$table->decimal('jumupahaz', 7)->nullable()->default(0);
|
||||||
|
$table->decimal('tunggakan', 7)->nullable()->default(0);
|
||||||
|
$table->date('t_update')->nullable();
|
||||||
|
$table->string('jantina', 1)->nullable();
|
||||||
|
$table->string('bangsa', 1)->nullable();
|
||||||
|
$table->integer('sirit')->nullable()->default(0);
|
||||||
|
$table->tinyInteger('jenisansur')->nullable()->default(0);
|
||||||
|
$table->string('nokotak', 10)->nullable();
|
||||||
|
$table->tinyInteger('tiada')->nullable()->default(0);
|
||||||
|
$table->integer('tagtbaki')->default(0);
|
||||||
|
$table->string('penilai', 50)->nullable();
|
||||||
|
$table->string('namapenilai', 30)->nullable();
|
||||||
|
$table->integer('tagserah')->default(0);
|
||||||
|
$table->date('tempTarikhAging')->nullable();
|
||||||
|
$table->string('jenistebus', 1);
|
||||||
|
$table->string('namapelulus', 50)->nullable();
|
||||||
|
$table->decimal('percentpinj', 9)->default(0);
|
||||||
|
$table->integer('kuantiti')->default(0);
|
||||||
|
$table->string('namateller', 30)->nullable();
|
||||||
|
$table->decimal('jumtebus', 11)->nullable()->default(0);
|
||||||
|
$table->decimal('upahnotis', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('upahpercuma', 11);
|
||||||
|
$table->integer('tagpalsu')->default(0);
|
||||||
|
$table->decimal('upahdibayar', 10)->default(0);
|
||||||
|
$table->integer('tagcetak');
|
||||||
|
$table->integer('tag_sms')->default(0);
|
||||||
|
$table->string('semakbarcode', 40)->default('Tidak Lulus');
|
||||||
|
$table->integer('wangkeluarteller')->default(0);
|
||||||
|
$table->integer('semakpetibesi')->default(0);
|
||||||
|
$table->integer('semakaudit')->default(0);
|
||||||
|
$table->string('historygadaian', 20)->default('0');
|
||||||
|
$table->integer('tagkiratebus')->default(0);
|
||||||
|
$table->integer('checkbp')->default(0);
|
||||||
|
$table->decimal('pampasan', 9)->default(0);
|
||||||
|
$table->integer('lel1stop')->default(0);
|
||||||
|
$table->string('tellernew', 40);
|
||||||
|
$table->string('idjompay', 25)->default('0');
|
||||||
|
$table->integer('tangguh')->default(0);
|
||||||
|
$table->date('tebus')->nullable();
|
||||||
|
$table->decimal('upahSim', 7)->default(0);
|
||||||
|
$table->decimal('jbgakru', 5)->default(0);
|
||||||
|
$table->decimal('upahakru', 7)->default(0);
|
||||||
|
$table->integer('tagpalsu2')->default(0);
|
||||||
|
$table->integer('tagcall')->default(0);
|
||||||
|
$table->decimal('upah_semasa', 11)->nullable()->default(0);
|
||||||
|
$table->decimal('simulasi_hargaasas', 11)->nullable()->default(0);
|
||||||
|
$table->decimal('simulasi_cajlelong', 11)->nullable()->default(0);
|
||||||
|
$table->decimal('simulasi_bakilelong', 11)->nullable()->default(0);
|
||||||
|
$table->decimal('sim_hargaasas', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('sim_cajlelong', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('sim_upahlelong', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('sim_bakilelong', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('percentrebet', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('rebet', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('upahlpsrebet', 9)->nullable()->default(0);
|
||||||
|
$table->integer('taguploadslip')->nullable()->default(0);
|
||||||
|
$table->integer('tagsahupahonline')->nullable()->default(0);
|
||||||
|
$table->decimal('bayarupahonline', 9)->nullable()->default(0);
|
||||||
|
$table->date('tbayaronline')->nullable();
|
||||||
|
$table->decimal('upahsebenar', 9)->nullable()->default(0);
|
||||||
|
$table->integer('tagupdatedbonline')->nullable()->default(0);
|
||||||
|
$table->decimal('bayarpinjamanonline', 9)->nullable()->default(0);
|
||||||
|
$table->string('jenis_bayaran', 5)->nullable();
|
||||||
|
$table->decimal('upah12', 9)->nullable();
|
||||||
|
$table->decimal('hargajualan', 9)->nullable();
|
||||||
|
$table->decimal('bakihargajualan', 9)->nullable();
|
||||||
|
$table->tinyInteger('tagkomuditi')->nullable();
|
||||||
|
$table->tinyInteger('lelong_tawarruq')->nullable()->default(1);
|
||||||
|
$table->float('tempohbayar', 10)->default(0);
|
||||||
|
$table->char('tag_tebus', 2);
|
||||||
|
$table->decimal('kadarujrah', 5);
|
||||||
|
$table->decimal('ujrah', 9);
|
||||||
|
$table->decimal('onepercent', 9);
|
||||||
|
$table->decimal('margin_semasa', 5);
|
||||||
|
$table->tinyInteger('tagbaru')->default(0);
|
||||||
|
$table->decimal('tunggakanujrah', 9);
|
||||||
|
$table->decimal('tunggakanonepercent', 9);
|
||||||
|
$table->tinyInteger('tagnotis')->default(0);
|
||||||
|
$table->decimal('kadarrebet', 8, 4)->nullable()->default(0);
|
||||||
|
$table->decimal('diskaun', 12)->nullable()->default(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('gadai');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateGlcodeTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('glcode', function (Blueprint $table) {
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->string('kodcaw', 10)->nullable();
|
||||||
|
$table->string('glcode', 15)->nullable();
|
||||||
|
$table->string('descpt', 40)->nullable();
|
||||||
|
$table->string('acttype', 1)->nullable();
|
||||||
|
$table->string('jenisakaun', 10)->nullable();
|
||||||
|
$table->tinyInteger('bayaran')->nullable()->default(0);
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->decimal('amaun', 15)->nullable()->default(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('glcode');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateGldetailTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('gldetail', function (Blueprint $table) {
|
||||||
|
$table->string('kodcaw', 10)->nullable();
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->string('dtacct', 15)->nullable();
|
||||||
|
$table->string('ktacct', 15)->nullable();
|
||||||
|
$table->string('descpt', 40)->nullable();
|
||||||
|
$table->string('acttype', 1)->nullable();
|
||||||
|
$table->string('fracttype', 1)->nullable();
|
||||||
|
$table->decimal('amaun', 13)->default(0);
|
||||||
|
$table->string('teller', 7)->nullable();
|
||||||
|
$table->string('pelulus', 7)->nullable();
|
||||||
|
$table->string('terima', 1)->nullable();
|
||||||
|
$table->string('jenisbyr', 2)->nullable();
|
||||||
|
$table->string('bkcode', 4)->nullable();
|
||||||
|
$table->string('nocek', 6)->nullable();
|
||||||
|
$table->decimal('pendahuluan', 13)->nullable()->default(0);
|
||||||
|
$table->decimal('serahan', 13)->nullable()->default(0);
|
||||||
|
$table->timestamp('date_created');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('gldetail');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateHargaemasTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('hargaemas', function (Blueprint $table) {
|
||||||
|
$table->string('karat', 5)->nullable();
|
||||||
|
$table->date('t_efektif')->nullable();
|
||||||
|
$table->decimal('harga', 7)->nullable()->default(0);
|
||||||
|
$table->time('m_efektif');
|
||||||
|
$table->decimal('harga2', 5);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('hargaemas');
|
||||||
|
}
|
||||||
|
}
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateImbangDugaBackupTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('imbang_duga_backup', function (Blueprint $table) {
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->string('kodcaw', 10)->nullable();
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->decimal('tunaiditangan', 11)->nullable();
|
||||||
|
$table->decimal('pembiayaantawarruq', 11)->nullable();
|
||||||
|
$table->decimal('bayaranpendahuluan', 11)->nullable();
|
||||||
|
$table->decimal('pinjamankoop', 11)->nullable();
|
||||||
|
$table->decimal('emaspalsu', 11)->nullable();
|
||||||
|
$table->decimal('serahan', 11)->nullable();
|
||||||
|
$table->decimal('bds', 11)->nullable();
|
||||||
|
$table->decimal('perubatan', 11)->nullable();
|
||||||
|
$table->decimal('keraian', 11)->nullable();
|
||||||
|
$table->decimal('rugilelong', 11)->nullable();
|
||||||
|
$table->decimal('bakilelong', 11)->nullable();
|
||||||
|
$table->decimal('wtd', 11)->nullable();
|
||||||
|
$table->decimal('untungrugiterkumpul', 11)->nullable();
|
||||||
|
$table->decimal('keun_sebenar', 11)->nullable();
|
||||||
|
$table->decimal('pendahuluan', 11)->nullable();
|
||||||
|
$table->decimal('cajlelong', 11)->nullable();
|
||||||
|
$table->decimal('pindahkekpkb', 11)->nullable();
|
||||||
|
$table->decimal('penghutangkaki', 11)->nullable();
|
||||||
|
$table->decimal('phapuskira', 11)->nullable();
|
||||||
|
$table->decimal('belian1stop', 11)->nullable();
|
||||||
|
$table->decimal('keun_penggadai', 11)->nullable();
|
||||||
|
$table->decimal('pend_terakru', 11)->nullable();
|
||||||
|
$table->decimal('cajperkhidmatan', 11)->nullable();
|
||||||
|
$table->decimal('cajlelongxtra', 11)->nullable();
|
||||||
|
$table->decimal('upahsimpanxtra', 11)->nullable();
|
||||||
|
$table->decimal('bakilelongxtra', 11)->nullable();
|
||||||
|
$table->decimal('rugilelongxtra', 11)->nullable();
|
||||||
|
$table->decimal('utgterkumpulxtra', 11)->nullable();
|
||||||
|
$table->decimal('jualan1stop', 11)->nullable();
|
||||||
|
$table->decimal('hapuskira', 11)->nullable();
|
||||||
|
$table->decimal('totalharta', 11)->nullable();
|
||||||
|
$table->decimal('totaltanggungan', 11)->nullable();
|
||||||
|
$table->integer('tagtally')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->decimal('ujrah', 9);
|
||||||
|
$table->decimal('onepercent', 9);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('imbang_duga_backup');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateInoutmarTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('inoutmar', function (Blueprint $table) {
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->time('masa')->nullable();
|
||||||
|
$table->string('norujukan', 14)->nullable();
|
||||||
|
$table->decimal('nm', 9)->nullable();
|
||||||
|
$table->string('kpd', 20)->nullable();
|
||||||
|
$table->string('drp', 20)->nullable();
|
||||||
|
$table->decimal('bln', 3, 0)->nullable();
|
||||||
|
$table->decimal('thn', 5, 0)->nullable();
|
||||||
|
$table->tinyInteger('tag')->nullable();
|
||||||
|
$table->string('jenistebus', 2);
|
||||||
|
$table->string('namateller', 30);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('inoutmar');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateJemasTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('jemas', function (Blueprint $table) {
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->string('marhun', 30)->nullable();
|
||||||
|
$table->string('descpt', 30)->nullable();
|
||||||
|
$table->integer('ordernum');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('jemas');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateJenisakaunTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('jenisakaun', function (Blueprint $table) {
|
||||||
|
$table->integer('recno')->default(0);
|
||||||
|
$table->string('kod', 1)->nullable();
|
||||||
|
$table->string('keterangan', 20)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('jenisakaun');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateKaratTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('karat', function (Blueprint $table) {
|
||||||
|
$table->string('karat', 10)->nullable();
|
||||||
|
$table->string('keterangan', 20)->nullable();
|
||||||
|
$table->decimal('harga', 5)->nullable();
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->decimal('harga2', 5)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('karat');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateLelmarhunTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('lelmarhun', function (Blueprint $table) {
|
||||||
|
$table->string('kodcaw', 10)->nullable();
|
||||||
|
$table->string('norujukan', 20)->nullable();
|
||||||
|
$table->date('t_gadai')->nullable();
|
||||||
|
$table->decimal('bil', 3, 0)->nullable();
|
||||||
|
$table->string('marhun', 30)->nullable();
|
||||||
|
$table->string('nota', 30)->nullable();
|
||||||
|
$table->string('karat', 10)->nullable();
|
||||||
|
$table->decimal('berat', 7)->nullable();
|
||||||
|
$table->decimal('harga', 5)->nullable();
|
||||||
|
$table->decimal('n_marhun', 9)->nullable();
|
||||||
|
$table->integer('batch_no')->nullable();
|
||||||
|
$table->decimal('hargaasas', 11)->nullable();
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->decimal('hargaasas_sim', 7)->nullable();
|
||||||
|
$table->decimal('beratasal', 11)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('lelmarhun');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateLelongTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('lelong', function (Blueprint $table) {
|
||||||
|
$table->integer('batchno')->default(0);
|
||||||
|
$table->integer('sirilel')->nullable();
|
||||||
|
$table->string('kodcaw', 10)->nullable();
|
||||||
|
$table->string('norujukan', 20)->nullable();
|
||||||
|
$table->date('t_lelong')->nullable();
|
||||||
|
$table->decimal('hargaasas', 9)->nullable()->default(0);
|
||||||
|
$table->decimal('sandaran', 11)->default(0);
|
||||||
|
$table->decimal('hargajual', 9)->nullable()->default(0);
|
||||||
|
$table->string('glcode', 15)->nullable();
|
||||||
|
$table->date('t_jual')->nullable();
|
||||||
|
$table->integer('nopembeli')->nullable()->default(0);
|
||||||
|
$table->decimal('jbg', 7)->nullable()->default(0);
|
||||||
|
$table->decimal('kadarupah', 5)->default(0);
|
||||||
|
$table->decimal('upahsimpan', 7)->nullable();
|
||||||
|
$table->decimal('ansuran', 9)->nullable();
|
||||||
|
$table->decimal('nilaimarhun', 9)->default(0);
|
||||||
|
$table->decimal('pinjaman', 9)->default(0);
|
||||||
|
$table->decimal('bakipjmas', 9)->nullable();
|
||||||
|
$table->decimal('bakipjm', 9)->nullable();
|
||||||
|
$table->decimal('bakiupahas', 7)->nullable();
|
||||||
|
$table->decimal('bakiupah', 9)->default(0);
|
||||||
|
$table->decimal('cajlainas', 7)->nullable();
|
||||||
|
$table->decimal('cajlain', 7)->nullable();
|
||||||
|
$table->decimal('cajlelongas', 7)->nullable();
|
||||||
|
$table->decimal('cajlelong', 7)->default(0);
|
||||||
|
$table->decimal('baki', 9)->default(0);
|
||||||
|
$table->string('terima', 1)->nullable();
|
||||||
|
$table->tinyInteger('cetak')->default(0);
|
||||||
|
$table->string('teller', 20)->nullable();
|
||||||
|
$table->string('pelulus', 20)->nullable();
|
||||||
|
$table->string('pelulust', 7)->nullable();
|
||||||
|
$table->string('f_lulus', 1)->nullable();
|
||||||
|
$table->string('type', 1)->nullable();
|
||||||
|
$table->string('prkod', 2)->nullable();
|
||||||
|
$table->tinyInteger('tagsurat')->nullable();
|
||||||
|
$table->date('trkhtuntut')->nullable();
|
||||||
|
$table->string('tellertb', 7)->nullable();
|
||||||
|
$table->string('pelulustb', 7)->nullable();
|
||||||
|
$table->string('terimatb', 1)->nullable();
|
||||||
|
$table->date('t_hapuskira')->nullable();
|
||||||
|
$table->decimal('hapuskira', 7)->nullable();
|
||||||
|
$table->decimal('hkpjm', 9)->nullable();
|
||||||
|
$table->string('cancelid', 7)->nullable();
|
||||||
|
$table->time('canceltime')->nullable();
|
||||||
|
$table->string('kodgl', 15)->nullable();
|
||||||
|
$table->date('t_update')->nullable();
|
||||||
|
$table->decimal('berat', 7)->default(0);
|
||||||
|
$table->string('marhun')->nullable();
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->decimal('lebihkurang', 9)->default(0);
|
||||||
|
$table->decimal('nilaimarhuns', 9)->default(0);
|
||||||
|
$table->integer('tagaid')->nullable();
|
||||||
|
$table->decimal('gst_hj', 7)->nullable();
|
||||||
|
$table->decimal('gst_cl', 7)->nullable();
|
||||||
|
$table->decimal('hargajual_sim', 7)->nullable();
|
||||||
|
$table->decimal('cajlelong_sim', 7)->nullable();
|
||||||
|
$table->decimal('gst_hj_sim', 7)->nullable();
|
||||||
|
$table->decimal('gst_cl_sim', 7)->nullable();
|
||||||
|
$table->decimal('bakiupah_sim', 7)->nullable();
|
||||||
|
$table->decimal('hargaasas_sim', 7)->nullable();
|
||||||
|
$table->string('mutu_terendah', 10)->nullable();
|
||||||
|
$table->decimal('harga_baru', 7)->nullable();
|
||||||
|
$table->decimal('turun', 7)->nullable();
|
||||||
|
$table->decimal('percent', 7)->nullable();
|
||||||
|
$table->decimal('baki_sim', 7)->nullable();
|
||||||
|
$table->decimal('hargalama', 7)->nullable();
|
||||||
|
$table->date('t_lelong_sim')->nullable();
|
||||||
|
$table->integer('tag_gst')->nullable();
|
||||||
|
$table->decimal('makan_pinj', 7)->nullable();
|
||||||
|
$table->decimal('baki_upah6', 7)->nullable();
|
||||||
|
$table->decimal('baki6', 7)->nullable();
|
||||||
|
$table->decimal('rugi_asal', 9)->default(0);
|
||||||
|
$table->string('tagpelanggan', 20)->nullable()->default('99');
|
||||||
|
$table->integer('fasa')->default(0);
|
||||||
|
$table->decimal('pmt', 11)->nullable();
|
||||||
|
$table->string('tagpmt', 20)->nullable();
|
||||||
|
$table->decimal('hargaasasasal', 11)->nullable();
|
||||||
|
$table->decimal('beratasal', 11)->default(0);
|
||||||
|
$table->integer(' loopsemak')->nullable();
|
||||||
|
$table->integer('lel1stop')->default(0);
|
||||||
|
$table->integer('jbg_lelong')->default(0);
|
||||||
|
$table->decimal('berat_plastik', 11)->nullable()->default(0);
|
||||||
|
$table->integer('status_bida_online')->default(0);
|
||||||
|
$table->string('nopelanggan', 14)->nullable();
|
||||||
|
$table->integer('tag_tbaki')->nullable();
|
||||||
|
$table->string('pel_tbaki', 20)->default('0');
|
||||||
|
$table->integer('tagcall')->default(0);
|
||||||
|
$table->decimal('ujrah', 9);
|
||||||
|
$table->decimal('onepercent', 9);
|
||||||
|
$table->tinyInteger('tagujrah')->default(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('lelong');
|
||||||
|
}
|
||||||
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateLelongTebusTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('lelong_tebus', function (Blueprint $table) {
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->string('teller', 100)->nullable();
|
||||||
|
$table->string('norujukan', 30)->nullable();
|
||||||
|
$table->string('batch_no', 10)->nullable();
|
||||||
|
$table->decimal('nilai_marhun', 11)->nullable();
|
||||||
|
$table->decimal('pinjaman', 11)->nullable();
|
||||||
|
$table->decimal('upah', 11)->nullable();
|
||||||
|
$table->integer('jbg')->nullable();
|
||||||
|
$table->string('jenis_tebus', 10)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('lelong_tebus');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateMarhunTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('marhun', function (Blueprint $table) {
|
||||||
|
$table->string('kodcaw', 3)->nullable();
|
||||||
|
$table->string('norujukan', 20)->nullable();
|
||||||
|
$table->date('t_gadai')->nullable();
|
||||||
|
$table->decimal('bil', 3, 0)->nullable();
|
||||||
|
$table->string('marhun', 30)->nullable();
|
||||||
|
$table->string('nota', 30)->nullable();
|
||||||
|
$table->string('karat', 10)->nullable();
|
||||||
|
$table->decimal('berat', 7)->nullable();
|
||||||
|
$table->decimal('harga', 5)->nullable();
|
||||||
|
$table->decimal('n_marhun', 9)->nullable();
|
||||||
|
$table->tinyInteger('tags')->nullable();
|
||||||
|
$table->tinyInteger('cfmlelong')->nullable();
|
||||||
|
$table->decimal('hargas', 5)->nullable();
|
||||||
|
$table->decimal('n_marhuns', 7)->nullable();
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->integer('new')->nullable();
|
||||||
|
$table->date('ttag')->nullable();
|
||||||
|
$table->decimal('hel', 9)->nullable();
|
||||||
|
$table->decimal('nml', 9)->nullable();
|
||||||
|
$table->decimal('berat_batu_permata', 7)->nullable();
|
||||||
|
$table->integer('tag_permata')->default(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('marhun');
|
||||||
|
}
|
||||||
|
}
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateModalOnlineTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('modal_online', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id');
|
||||||
|
$table->date('tarikh');
|
||||||
|
$table->string('kodcaw', 20);
|
||||||
|
$table->decimal('had', 12)->default(100000);
|
||||||
|
$table->decimal('digunakan', 12)->default(0);
|
||||||
|
$table->decimal('baki', 12)->default(100000);
|
||||||
|
$table->decimal('tambah', 12)->default(0);
|
||||||
|
$table->decimal('kurang', 12)->default(0);
|
||||||
|
$table->tinyInteger('ditutup')->default(0);
|
||||||
|
$table->string('ditutup_oleh', 100)->nullable();
|
||||||
|
$table->timestamp('ditutup_at')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->unique(['tarikh', 'kodcaw']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('modal_online');
|
||||||
|
}
|
||||||
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateMohonAnggotaTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('mohon_anggota', function (Blueprint $table) {
|
||||||
|
$table->unsignedBigInteger('id');
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->string('nokp', 20)->nullable();
|
||||||
|
$table->string('nama', 100)->nullable();
|
||||||
|
$table->string('status', 50)->default('MENUNGGU OPERASI');
|
||||||
|
$table->text('komen')->nullable();
|
||||||
|
$table->string('teller', 100)->nullable();
|
||||||
|
$table->string('peloperasi', 100)->nullable();
|
||||||
|
$table->dateTime('datetime_pelulus')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('mohon_anggota');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateMohonTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('mohon', function (Blueprint $table) {
|
||||||
|
$table->integer('id');
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->string('norujukan', 20);
|
||||||
|
$table->decimal('siri', 9, 0)->default(0);
|
||||||
|
$table->mediumText('komen')->nullable();
|
||||||
|
$table->date('lastdategadai')->nullable();
|
||||||
|
$table->integer('bilgad')->default(0);
|
||||||
|
$table->decimal('jumpinj', 9)->default(0);
|
||||||
|
$table->string('jenistebus', 2);
|
||||||
|
$table->string('teller', 100)->nullable();
|
||||||
|
$table->string('pelulus', 100);
|
||||||
|
$table->string('peloperasi', 100);
|
||||||
|
$table->string('masalulus', 100);
|
||||||
|
$table->string('khazanah', 100);
|
||||||
|
$table->string('operasi', 100);
|
||||||
|
$table->decimal('margin', 10)->nullable();
|
||||||
|
$table->decimal('nilaimarhun', 10)->nullable();
|
||||||
|
$table->decimal('berat', 10)->nullable();
|
||||||
|
$table->string('status', 100)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('mohon');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateMohonidTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('mohonid', function (Blueprint $table) {
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->time('masa')->nullable()->comment('Time period');
|
||||||
|
$table->string('onlineid', 40)->nullable();
|
||||||
|
$table->string('mohon', 40)->nullable();
|
||||||
|
$table->string('norujukan', 20)->nullable();
|
||||||
|
$table->string('id', 40)->nullable();
|
||||||
|
$table->timestamp('timestamp_approved_by_pc')->nullable()->comment('Time Approved by PC');
|
||||||
|
$table->string('katalaluan', 50)->nullable();
|
||||||
|
$table->integer('benar')->nullable();
|
||||||
|
$table->string('teller', 100)->nullable();
|
||||||
|
$table->decimal('pinjaman', 10)->nullable();
|
||||||
|
$table->decimal('ansuran', 10)->default(0)->comment('Ansuran Amount');
|
||||||
|
$table->decimal('nilaimarhun', 10)->nullable();
|
||||||
|
$table->decimal('berat', 10)->nullable();
|
||||||
|
$table->decimal('margin', 4)->nullable();
|
||||||
|
$table->boolean('tagoperasi')->default(false)->comment('Tag Operasi');
|
||||||
|
$table->string('operasi')->nullable()->comment('Nama Operasi');
|
||||||
|
$table->timestamp('timestamp_approved_by_operasi')->nullable()->comment('Time approved by Operasi');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('mohonid');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateNegeriTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('negeri', function (Blueprint $table) {
|
||||||
|
$table->string('kodnegeri', 3)->nullable();
|
||||||
|
$table->string('negeri', 25)->nullable();
|
||||||
|
$table->string('cutiumum', 1)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('negeri');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreatePalsuTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('palsu', function (Blueprint $table) {
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->string('kodcaw', 10)->nullable();
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->string('norujukan', 20)->nullable();
|
||||||
|
$table->string('teller', 20)->nullable();
|
||||||
|
$table->string('nota', 100)->nullable();
|
||||||
|
$table->decimal('pembiayaan', 11)->nullable()->comment('Pembiayaan amount');
|
||||||
|
$table->decimal('nilaimarhun', 11)->nullable()->comment('Nilai marhun amount');
|
||||||
|
$table->double('jbg', 4, 2)->nullable()->comment('JBG value');
|
||||||
|
$table->decimal('untung', 11)->nullable()->comment('Untung amount');
|
||||||
|
$table->decimal('untungonepercent', 11)->nullable()->comment('Satu Persen amount');
|
||||||
|
$table->decimal('untungcajlain', 11)->nullable()->comment('Caj Lain-Lain amount');
|
||||||
|
$table->string('jenis', 50)->nullable()->comment('Jenis/Type classification');
|
||||||
|
$table->unsignedSmallInteger('status')->default(0)->comment('Status value');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('palsu');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreatePampasanTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('pampasan', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id');
|
||||||
|
$table->string('norujukan', 50)->unique();
|
||||||
|
$table->string('baucerno', 30)->index();
|
||||||
|
$table->string('kodcaw', 20)->index();
|
||||||
|
$table->decimal('jumlah_pampasan', 11);
|
||||||
|
$table->json('denominasi')->nullable();
|
||||||
|
$table->string('teller', 100);
|
||||||
|
$table->tinyInteger('status')->default(0)->comment('0 = belum dituntut, 1 = dituntut');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->timestamp('agreement_printed_at')->nullable()->comment('Timestamp when agreement was printed');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('pampasan');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreatePanjarTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->create('panjar', function (Blueprint $table) {
|
||||||
|
$table->integer('recno');
|
||||||
|
$table->date('tarikh')->nullable();
|
||||||
|
$table->string('deskripsi', 100)->nullable();
|
||||||
|
$table->decimal('bayaran', 11)->nullable();
|
||||||
|
$table->longText('nota')->nullable();
|
||||||
|
$table->integer('tag')->nullable();
|
||||||
|
$table->string('kategori', 40)->nullable();
|
||||||
|
$table->string('nama', 40);
|
||||||
|
$table->string('id', 40)->nullable();
|
||||||
|
$table->decimal('bakiperubatan', 11)->nullable();
|
||||||
|
$table->string('nobaucer', 15)->nullable();
|
||||||
|
$table->integer('nobil')->nullable();
|
||||||
|
$table->string('tuntutoleh', 40)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::connection('mysql2')->dropIfExists('panjar');
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user