订单配送,打印机
This commit is contained in:
@@ -22,8 +22,10 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
PrinterFontSizeNormal = int8(0) //正常大小
|
||||
PrinterFontSizeBig = int8(1) //两倍大小
|
||||
PrinterFontSizeNormal = int8(0) //正常大小一份
|
||||
PrinterFontSizeBig = int8(1) //两倍大小一份
|
||||
PrinterFontSizeNormal2 = int8(2) //正常字体两份
|
||||
PrinterFontSizeBig2 = int8(3) //大字体两份
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -79,7 +79,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
\n
|
||||
\n
|
||||
商品明细: \n
|
||||
品名 数量 单价 小计\n
|
||||
品名 数量 小计\n
|
||||
--------------------------------\n`
|
||||
// <FB>实际支付:</FB>%s\n
|
||||
orderParams = append(orderParams,
|
||||
@@ -98,8 +98,9 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
|
||||
for _, sku := range order.Skus {
|
||||
orderFmt += `%s\n`
|
||||
orderFmt += `%8s%10s%10s\n`
|
||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||
orderFmt += `%6s%8s%8s\n`
|
||||
//orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||
//标品需要打印条形码
|
||||
if sku.Upc != "" {
|
||||
orderFmt += `upc码: %s\n`
|
||||
@@ -164,7 +165,7 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
|
||||
\n
|
||||
\n
|
||||
<FS2>商品明细: \n</FS2>
|
||||
<FS2>品名数量单价小计\n</FS2>
|
||||
品名 数量 小计\n
|
||||
--------------------------------\n`
|
||||
// <FS2><FB>实际支付:</FB>%s\n</FS2>
|
||||
orderParams = append(orderParams,
|
||||
@@ -183,8 +184,10 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
|
||||
|
||||
for _, sku := range order.Skus {
|
||||
orderFmt += `<FS2>%s\n</FS2>`
|
||||
orderFmt += `<FS2>%s %s %s\n\n</FS2>`
|
||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||
//orderFmt += `<FS2>%s %s %s\n\n</FS2>`
|
||||
orderFmt += `<FH><FB>%s %s %s\n\n</FB></FH>`
|
||||
//orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||
//标品需要打印条形码
|
||||
if sku.Upc != "" {
|
||||
orderFmt += `<FS2>upc码: %s\n</FS2>`
|
||||
@@ -250,12 +253,22 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
|
||||
return
|
||||
}
|
||||
content := ""
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig {
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 {
|
||||
content = c.getOrderContentBig(order, store.Tel1, storeDetail)
|
||||
} else {
|
||||
content = c.getOrderContent(order, store.Tel1, storeDetail)
|
||||
}
|
||||
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
|
||||
|
||||
var count = 0
|
||||
for {
|
||||
printerStatus, err := c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
|
||||
if (store.PrinterFontSize == partner.PrinterFontSizeBig2 || store.PrinterFontSize == partner.PrinterFontSizeNormal2) && count < 1 {
|
||||
count = count + 1
|
||||
continue
|
||||
} else {
|
||||
return printerStatus, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, machineCode, secret, printerName string) (notUsed1, notUsed2 string, err error) {
|
||||
|
||||
@@ -118,26 +118,40 @@ func onTTPayRefund(msg *wxpayapi.RefundResultMsg) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func refundOrderByTT(ctx *jxcontext.Context, orderPay *model.OrderPay, refundID string, refundFee int, refundDesc string) (orderPayRefund *model.OrderPayRefund, err error) {
|
||||
result, err := api.WxpayAPI.PayRefund(&wxpayapi.PayRefundParam{
|
||||
OutTradeNo: orderPay.VendorOrderID,
|
||||
NotifyURL: globals.WxpayNotifyURL,
|
||||
OutRefundNo: refundID,
|
||||
TotalFee: orderPay.TotalFee,
|
||||
RefundFee: refundFee,
|
||||
RefundDesc: wxpayapi.CData(refundDesc),
|
||||
// 申请退款
|
||||
func RefundOrderByTT(ctx *jxcontext.Context, orderPay *model.OrderPay, refundID string, refundFee int, refundDesc string) (orderPayRefund *model.OrderPayRefund, err error) {
|
||||
result, err := api.TiktokApi.RefundOrderTT(&tiktok.RefundOrderReq{
|
||||
AppID: api.TiktokApi.GetAppID(),
|
||||
OutOrderNo: orderPay.VendorOrderID,
|
||||
OutRefundNo: refundID,
|
||||
Reason: refundDesc,
|
||||
RefundAmount: orderPay.TotalFee,
|
||||
CpExtra: "msg",
|
||||
NotifyURL: globals.TictokpayNotifyURL,
|
||||
})
|
||||
if err == nil {
|
||||
orderPayRefund = &model.OrderPayRefund{
|
||||
RefundID: refundID,
|
||||
VendorRefundID: result.RefundID,
|
||||
VendorRefundID: result,
|
||||
VendorOrderID: orderPay.VendorOrderID,
|
||||
VendorID: orderPay.VendorID,
|
||||
Status: model.RefundStatusNo,
|
||||
TransactionID: orderPay.TransactionID,
|
||||
RefundFee: orderPay.TotalFee,
|
||||
RefundFee: refundFee,
|
||||
RefundCreatedAt: time.Now(),
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(orderPayRefund, ctx.GetUserName())
|
||||
db := dao.GetDB()
|
||||
if result != "" {
|
||||
orderPayRefund.Status = model.RefundStatusYes
|
||||
} else {
|
||||
orderPayRefund.Status = model.RefundStatusFailed
|
||||
}
|
||||
orderPayRefund.OriginalData = utils.Format4Output(result, true)
|
||||
dao.CreateEntity(db, orderPayRefund)
|
||||
|
||||
orderPay.Status = model.PayStatusRefund
|
||||
dao.UpdateEntity(db, orderPay)
|
||||
}
|
||||
return orderPayRefund, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user