Files
libgofunc/cmd/main.go

70 lines
7.9 KiB
Go
Raw Normal View History

2026-04-08 15:31:23 +06:30
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() {
2026-06-02 10:08:24 +06:30
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_li
2026-04-08 15:31:23 +06:30
const temp = `
<img src="logo.png" style="width:230;height:200;padding-left:130px;padding-top:30px"/>
2026-06-02 10:08:24 +06:30
<h1 style="padding-left:150px">{{.station.name}}</h1>
2026-04-08 15:31:23 +06:30
2026-06-02 10:08:24 +06:30
<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"/>
2026-04-08 15:31:23 +06:30
2026-06-02 10:08:24 +06:30
<table style="padding-left:0px;padding-bottom:10px;border:0px;font-size:16px;border:0px;">
2026-04-08 15:31:23 +06:30
<tr>
2026-06-02 10:08:24 +06:30
<th style="width:120">Item</th>
<th style="width:50">Pump</th>
2026-04-08 15:31:23 +06:30
<th>Price</th>
<th>Liter</th>
<th>Gallon</th>
<th>Amount</th>
</tr>
2026-06-02 10:08:24 +06:30
{{range .sales}}
2026-04-08 15:31:23 +06:30
<tr>
2026-06-02 10:08:24 +06:30
<td>{{.product}}</td>
<td>{{.fpId}}</td>
<td>{{.price}}</td>
<td>{{.volume}}</td>
<td>{{.volume}}</td>
<td>{{.amount}}</td>
2026-04-08 15:31:23 +06:30
</tr>
2026-06-02 10:08:24 +06:30
{{end}}
2026-04-08 15:31:23 +06:30
</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")
2026-06-02 10:08:24 +06:30
// libgofunc.Print("tcp:192.168.100.110:9100", "./out.png")
// libgofunc.Print("usb:/dev/usb/lp1", "./out.png")
2026-04-08 15:31:23 +06:30
// printer := "tcp:192.168.100.151:9100"
// ListUSB()
}