70 lines
7.9 KiB
Go
70 lines
7.9 KiB
Go
package main
|
|
|
|
import (
|
|
/*
|
|
#include <stdint.h>
|
|
*/
|
|
"C"
|
|
"fmt"
|
|
_ "image/png"
|
|
)
|
|
import (
|
|
"gt.mokkon.com/sainw/libgofunc"
|
|
)
|
|
|
|
//export Sum
|
|
func Sum(a, b int) int {
|
|
return a + b
|
|
}
|
|
|
|
func main() {
|
|
payload := `{ "sales": [ { "shiftId": "1001", "tran_seq": 1, "salePerson": "John Doe", "timeSec": "1717243200", "timeValue": "2026-06-01 14:30:00", "fpId": 3, "productId": 101, "product": "Diesel Premium", "price": "2500", "volume": "40", "amount": "100000", "discount_amount": "5000", "discount_percent": 5.0, "discount_money": 5000, "rule_types": "LOYALTY,FLEET", "promotion_status": true, "custom_promotion_status": false, "discount_volume": "2", "customerId": 5001, "customer_name": "ABC Logistics Pte Ltd", "vehicle_type": "Truck", "vehicle_type_extension": "10-Wheeler", "carNumber": "SGX1234A", "status": "COMPLETED", "receiptNumber": "RCP-20260601-0001", "receiptCount": 1, "mop": "CARD", "local_used_credit": 100.50, "local_credit_limit": 5000.00, "local_credit_balance": 4899.50, "local_debit_balance": 250.75, "loyalty_type": "GOLD", "points_balance": 12500, "reward_amount": 50.25, "reward_points": 500, "redeem_amount": 25.00, "redeem_points": 250, "redeem_exchange_rate": 0.1, "point_exchange_rate": 10.0, "used_credit": 100.50, "credit_limit": 10000.00, "credit_amount": 100.50, "credit_balance": 9899.50, "debit_amount": 50.25, "debit_balance": 449.75, "payment_customer_id": "PAYCUST001", "payment_customer_name": "ABC Logistics", "payment_customer_number": "+6591234567", "corp_id": "CORP001", "corp_name": "ABC Logistics Group", "card_number": "411111******1111", "upload": true, "upload_status": "SUCCESS", "send_sale_data_confirm": true, "loan_amount": 1000, "tax_percent": 9.0, "tax_status": true, "tier": 2, "dealNumber": "DL-20260601-001", "bank_name": "DBS", "bank_payment_type": "VISA", "session_id": "sess_abc123xyz", "tran_id": "txn_987654321", "qrcode_data": "SGQR|PAYNOW|ABCLOGISTICS", "fp_total": 8, "missed_sale_status": false, "opo_status": true, "ip_printer_status": true, "sale_type": "NORMAL" }, { "shiftId": "1001", "tran_seq": 1, "salePerson": "John Doe", "timeSec": "1717243200", "timeValue": "2026-06-01 14:30:00", "fpId": 3, "productId": 101, "product": "Diesel Premium", "price": "2500", "volume": "40", "amount": "100000", "discount_amount": "5000", "discount_percent": 5.0, "discount_money": 5000, "rule_types": "LOYALTY,FLEET", "promotion_status": true, "custom_promotion_status": false, "discount_volume": "2", "customerId": 5001, "customer_name": "ABC Logistics Pte Ltd", "vehicle_type": "Truck", "vehicle_type_extension": "10-Wheeler", "carNumber": "SGX1234A", "status": "COMPLETED", "receiptNumber": "RCP-20260601-0001", "receiptCount": 1, "mop": "CARD", "local_used_credit": 100.50, "local_credit_limit": 5000.00, "local_credit_balance": 4899.50, "local_debit_balance": 250.75, "loyalty_type": "GOLD", "points_balance": 12500, "reward_amount": 50.25, "reward_points": 500, "redeem_amount": 25.00, "redeem_points": 250, "redeem_exchange_rate": 0.1, "point_exchange_rate": 10.0, "used_credit": 100.50, "credit_limit": 10000.00, "credit_amount": 100.50, "credit_balance": 9899.50, "debit_amount": 50.25, "debit_balance": 449.75, "payment_customer_id": "PAYCUST001", "payment_customer_name": "ABC Logistics", "payment_customer_number": "+6591234567", "corp_id": "CORP001", "corp_name": "ABC Logistics Group", "card_number": "411111******1111", "upload": true, "upload_status": "SUCCESS", "send_sale_data_confirm": true, "loan_amount": 1000, "tax_percent": 9.0, "tax_status": true, "tier": 2, "dealNumber": "DL-20260601-001", "bank_name": "DBS", "bank_payment_type": "VISA", "session_id": "sess_abc123xyz", "tran_id": "txn_987654321", "qrcode_data": "SGQR|PAYNOW|ABCLOGISTICS", "fp_total": 8, "missed_sale_status": false, "opo_status": true, "ip_printer_status": true, "sale_type": "NORMAL" } ], "station": { "id": "1", "name": "Jurong Fuel Station", "address": "123 Boon Lay Way, Singapore 640123", "phones": "+65 6123 4567,+65 6987 6543", "code": "STN001", "money_divider": 100, "volume_divider": 1000, "check_tran_duration": 60, "fho_server_offline_duration": 300, "loyalty_backlog_duration": 1440, "token": "station-secret-token-123", "monthly_view": true, "pump_status": true, "currency": "SGD", "tank_manual_status": false, "update_price_type": "AUTO", "show_price_history": true, "old_receipt_status": false, "car_number_modification_status": true, "car_number_entry_status": 2, "shop_code": "SHOP001" }}`
|
|
const temp = `
|
|
<img src="../assets/logo.png" style="width:230;height:200;padding-left:130px;padding-top:30px"/>
|
|
<h1 style="padding-left:150px">{{.station.name}}</h1>
|
|
|
|
<p style="padding-left:0px;font-size:18">Address: မင်္ဂလာပါ {{(index .sales 0).salePerson}}</p>
|
|
<p style="padding-left:0px">Receipt: RCPT001</p>
|
|
<p style="padding-left:0px">Phone: 0977777777</p>
|
|
<p style="padding-left:0px">Date: 4 Jan 2026 15:38:38</p>
|
|
<p style="padding-left:0px">Car No.: 3J/3883</p>
|
|
<p style="padding-left:0px">Casher: မနှင်းနှင်း</p>
|
|
<p style="padding-left:0px">MOP: B2B</p>
|
|
<p style="padding-left:0px">Tier: 1</p>
|
|
<p style="padding-left:0px">Deal No.: RR</p>
|
|
<hr style="height:1px;padding-left:0px;padding-right:10px;padding-bottom:10px"/>
|
|
|
|
<table style="padding-left:0px;padding-bottom:10px;border:0px;font-size:16px;border:0px;">
|
|
<tr>
|
|
<th style="width:120">Item</th>
|
|
<th style="width:50">Pump</th>
|
|
<th>Price</th>
|
|
<th>Liter</th>
|
|
<th>Gallon</th>
|
|
<th>Amount</th>
|
|
</tr>
|
|
{{range .sales}}
|
|
<tr>
|
|
<td>{{.product}}</td>
|
|
<td>{{.fpId}}</td>
|
|
<td>{{.price}}</td>
|
|
<td>{{.volume}}</td>
|
|
<td>{{.volume}}</td>
|
|
<td>{{.amount}}</td>
|
|
</tr>
|
|
{{end}}
|
|
</table>
|
|
|
|
<p style="padding-left:0px;padding-top:50px;">
|
|
စက်သုံးဆီ အရေအတွက် နှင့် အရည်အသွေးစျေးနှုန်းများ အားသံသယရှိပါက ph 09450539099, 09765421033, 09765421029 သို့တိုင်ကြား နိုင်ပါသည်။</p>
|
|
`
|
|
result := libgofunc.GenImg(550, "./out.png", payload, temp, "./")
|
|
fmt.Println("Result:", result)
|
|
// PrintImg(C.CString("usb:/dev/usb/lp1"), C.CString("build/out.png"))
|
|
// libgofunc.Print("int:/dev/bus/usb/001/046", "./out.png")
|
|
// libgofunc.Print("tcp:192.168.100.110:9100", "./out.png")
|
|
// libgofunc.Print("usb:/dev/usb/lp1", "./out.png")
|
|
// printer := "tcp:192.168.100.151:9100"
|
|
// ListUSB()
|
|
}
|