添加退款订单打印以及退单打印

This commit is contained in:
邹宗楠
2022-06-14 15:23:02 +08:00
parent caa0b76302
commit 140d07bb92
14 changed files with 285 additions and 47 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"git.rosy.net.cn/jx-callback/business/authz/autils" "git.rosy.net.cn/jx-callback/business/authz/autils"
"git.rosy.net.cn/jx-callback/business/jxutils/excel" "git.rosy.net.cn/jx-callback/business/jxutils/excel"
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg" "git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
"git.rosy.net.cn/jx-callback/globals/api2" "git.rosy.net.cn/jx-callback/globals/api2"
beego "github.com/astaxie/beego/server/web" beego "github.com/astaxie/beego/server/web"
@@ -243,11 +244,20 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m
} else if orderStatus.Status == model.OrderStatusCanceled { } else if orderStatus.Status == model.OrderStatusCanceled {
//如果取消订单则要把库存加回去 //如果取消订单则要把库存加回去
if order, err2 := c.LoadOrder(orderStatus.VendorOrderID, orderStatus.VendorID); err2 == nil { if order, err2 := c.LoadOrder(orderStatus.VendorOrderID, orderStatus.VendorID); err2 == nil {
//ModifyOrderSkusStock(db, order, true) // 判断是否需要打印取消订单
storeDetail, err := c.LoadStoreDetail(order.StoreID, order.VendorID)
if err == nil && storeDetail.IsPrintCancelOrder == model.YES { // 取消申请
_, err = netprinter.PrintRefundOrCancelOrder(jxcontext.AdminCtx, model.YES, order, order.StoreID)
}
if err != nil {
globals.SugarLogger.Debug("Get store Detail Err: ", err)
}
//门店发单的订单,取消后要退回配送费 //门店发单的订单,取消后要退回配送费
resetCreateWaybillFee(db, order) resetCreateWaybillFee(db, order)
} }
} }
if !isDuplicated { if !isDuplicated {
if order != nil { if order != nil {
order.Skus = c.loadOrderSku(db, order.VendorOrderID, order.VendorID) order.Skus = c.loadOrderSku(db, order.VendorOrderID, order.VendorID)

View File

@@ -2,6 +2,7 @@ package basesch
import ( import (
"fmt" "fmt"
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
"strings" "strings"
"time" "time"
@@ -206,6 +207,7 @@ func (c *BaseScheduler) CancelWaybillByID(ctx *jxcontext.Context, vendorWaybillI
} }
func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID string, vendorID, approveType int, reason string) (err error) { func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID string, vendorID, approveType int, reason string) (err error) {
skus := make([]*model.OrderFinancialSkuExt, 0, 0)
afsOrder, err := partner.CurOrderManager.LoadAfsOrder(afsOrderID, vendorID) afsOrder, err := partner.CurOrderManager.LoadAfsOrder(afsOrderID, vendorID)
if err == nil { if err == nil {
if c.IsReallyCallPlatformAPI { if c.IsReallyCallPlatformAPI {
@@ -228,7 +230,7 @@ func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID s
var ( var (
afsCount, orderCount int afsCount, orderCount int
) )
skus, _ := dao.GetAfsOrderSkuInfo(db, order.VendorOrderID, afsOrderID, order.VendorID, false) skus, _ = dao.GetAfsOrderSkuInfo(db, order.VendorOrderID, afsOrderID, order.VendorID, false)
for _, v := range skus { for _, v := range skus {
afsCount += v.Count afsCount += v.Count
} }
@@ -274,6 +276,19 @@ func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID s
dao.SetAfsOrderFlag(dao.GetDB(), ctx.GetUserName(), afsOrderID, vendorID, flag) dao.SetAfsOrderFlag(dao.GetDB(), ctx.GetUserName(), afsOrderID, vendorID, flag)
} }
} }
if approveType != partner.AfsApproveTypeRefused {
storeDetail, err := partner.CurOrderManager.LoadStoreDetail(afsOrder.StoreID, afsOrder.VendorID)
if err != nil {
globals.SugarLogger.Debug("Get store detail Err : ", err)
return err
}
if storeDetail.IsPrintRefundOrder == model.YES { // 打印退款订单
order2, _ := partner.CurOrderManager.LoadOrder(afsOrder.VendorOrderID, afsOrder.VendorID)
_, err = netprinter.PrintRefundOrCancelOrder(jxcontext.AdminCtx, model.NO, order2, afsOrder.StoreID)
}
}
return err return err
} }

View File

@@ -628,6 +628,12 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
if bill.Status == model.WaybillStatusAccepted && order.NotifyType == 0 { if bill.Status == model.WaybillStatusAccepted && order.NotifyType == 0 {
smsmsg.NotifyPickOrder(order) smsmsg.NotifyPickOrder(order)
} }
// 订单在三方配送中,转自送
if order.Status >= model.OrderStatusDelivering && order.DeliveryType == model.OrderDeliveryTypeStoreSelf {
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, switch2SelfDeliverRetryCount, switch2SelfDeliverRetryGap)
}
// 订单处于配送状态来的新分配骑手运单 // 订单处于配送状态来的新分配骑手运单
if order.Status >= model.OrderStatusDelivering && order.Status < model.OrderStatusEndBegin && bill.Status < model.OrderStatusDelivering { if order.Status >= model.OrderStatusDelivering && order.Status < model.OrderStatusEndBegin && bill.Status < model.OrderStatusDelivering {
if order.DeliveryType == model.OrderDeliveryTypeStoreSelf { if order.DeliveryType == model.OrderDeliveryTypeStoreSelf {
@@ -636,6 +642,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime) s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
} }
} }
//订单已经是结束状态之后来的运单143945553920000001 //订单已经是结束状态之后来的运单143945553920000001
if order.Status > model.OrderStatusEndBegin { if order.Status > model.OrderStatusEndBegin {
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime) s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)

View File

@@ -1028,33 +1028,8 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
} }
} }
} }
// if roleMap[k] != "" {
// if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
// if roleMoblieMap[authInfo.Mobile] == "" {
// return 0, errors.New(fmt.Sprintf("当前用户 [%v] 无权限修改 [%v] 字段!", authInfo.Name, roleMap[k]))
// }
// }
// }
// if marketManPhoneRoleMap[k] != "" {
// if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
// if marketManPhoneRoleMoblieMap[authInfo.Mobile] == "" {
// return 0, errors.New(fmt.Sprintf("当前用户 [%v] 无权限修改 [%v] 字段!", authInfo.Name, roleMap[k]))
// }
// }
// }
} }
// districtCode := 0
// if valid["districtCode"] != nil {
// districtCode = int(utils.MustInterface2Int64(valid["districtCode"]))
// }
// if districtCode == 0 && store.DistrictCode == 0 {
// if lng == 0 {
// lng = jxutils.IntCoordinate2Standard(store.Lng)
// lat = jxutils.IntCoordinate2Standard(store.Lat)
// }
// valid["districtCode"] = api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat)
// }
globals.SugarLogger.Debugf("UpdateStore track:%s, storeID:%d, valid:%s", ctx.GetTrackInfo(), storeID, utils.Format4Output(valid, true)) globals.SugarLogger.Debugf("UpdateStore track:%s, storeID:%d, valid:%s", ctx.GetTrackInfo(), storeID, utils.Format4Output(valid, true))
if len(valid) > 0 { if len(valid) > 0 {
if globals.IsAddEvent { if globals.IsAddEvent {

View File

@@ -70,6 +70,7 @@ func getStore4Print(db *dao.DaoDB, storeID int) (store *model.Store, err error)
return store, err return store, err
} }
// PrintOrderByOrder4Store 打印订单信息
func PrintOrderByOrder4Store(ctx *jxcontext.Context, order *model.GoodsOrder, storeID int) (printResult *partner.PrinterStatus, err error) { func PrintOrderByOrder4Store(ctx *jxcontext.Context, order *model.GoodsOrder, storeID int) (printResult *partner.PrinterStatus, err error) {
globals.SugarLogger.Debugf("PrintOrderByOrder4Store orderID:%s", order.VendorOrderID) globals.SugarLogger.Debugf("PrintOrderByOrder4Store orderID:%s", order.VendorOrderID)
db := dao.GetDB() db := dao.GetDB()
@@ -99,6 +100,29 @@ func PrintOrderByOrder4Store(ctx *jxcontext.Context, order *model.GoodsOrder, st
return printResult, err return printResult, err
} }
// PrintRefundOrCancelOrder 打印退单或取消订单信息
func PrintRefundOrCancelOrder(ctx *jxcontext.Context, printType int, order *model.GoodsOrder, storeID int) (printResult *partner.PrinterStatus, err error) {
db := dao.GetDB()
store, err := getStore4Print(db, storeID)
if err == nil {
handler, err := GetHandlerFromStore(store)
if err != nil {
return &partner.PrinterStatus{
PrintResult: partner.PrintResultNoPrinter,
}, nil
}
storeDetail, _ := dao.GetStoreDetail(db, storeID, order.VendorID, order.VendorOrgCode)
printResult, err = handler.PrintCancelOrRefundOrder(ctx, printType, store, storeDetail, order)
if err == nil {
dao.SetOrderPrintFlag(db, ctx.GetUserName(), order.VendorOrderID, order.VendorID, true)
}
}
if err != nil {
globals.SugarLogger.Infof("PrintRefundOrCancelOrder orderID:%s failed with error:%v", order.VendorOrderID, err)
}
return printResult, err
}
func GetNetPrinterStatus(ctx *jxcontext.Context, storeID int) (printResult *partner.PrinterStatus, err error) { func GetNetPrinterStatus(ctx *jxcontext.Context, storeID int) (printResult *partner.PrinterStatus, err error) {
store := &model.Store{} store := &model.Store{}
store.ID = storeID store.ID = storeID

View File

@@ -394,6 +394,8 @@ type Store struct {
SoundPercentage int `json:"soundPercentage"` //打印机声音大小比例 SoundPercentage int `json:"soundPercentage"` //打印机声音大小比例
Banner string `orm:"size(9999)" json:"banner"` //门店商城bannar图 Banner string `orm:"size(9999)" json:"banner"` //门店商城bannar图
BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID
IsPrintCancelOrder int `orm:"column(is_print_cancel_order)" json:"isPrintCancelOrder"` //是否打印取消订单1是/-1否
IsPrintRefundOrder int `orm:"column(is_print_refund_order)" json:"isPrintRefundOrder"` //是否打印退款订单1是/-1否
} }
func (*Store) TableUnique() [][]string { func (*Store) TableUnique() [][]string {

View File

@@ -120,6 +120,12 @@ func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal
} }
func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.ShopInfo) { func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.ShopInfo) {
// 获取品牌名称
brandInfo, err := dao.GetBrands(dao.GetDB(), "", storeDetail.BrandID, "", false, "")
if err != nil {
return nil
}
lng := jxutils.IntCoordinate2Standard(storeDetail.Lng) lng := jxutils.IntCoordinate2Standard(storeDetail.Lng)
lat := jxutils.IntCoordinate2Standard(storeDetail.Lat) lat := jxutils.IntCoordinate2Standard(storeDetail.Lat)
cityName := storeDetail.CityName cityName := storeDetail.CityName
@@ -135,7 +141,7 @@ func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.Shop
} }
shopInfo = &dadaapi.ShopInfo{ shopInfo = &dadaapi.ShopInfo{
OriginShopID: storeDetail.VendorStoreID, OriginShopID: storeDetail.VendorStoreID,
StationName: globals.StoreName + "-" + storeDetail.Name, StationName: brandInfo[0].Name + "-" + storeDetail.Name,
Business: dadaapi.BusinessTypeConvStore, // 故意设置成这个的 Business: dadaapi.BusinessTypeConvStore, // 故意设置成这个的
CityName: cityName, CityName: cityName,
AreaName: districtName, AreaName: districtName,

View File

@@ -34,11 +34,9 @@ func getAuditStatus(vendorAuditStatus int) int {
} }
func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) { func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) {
globals.SugarLogger.Debug("蜂鸟门店创建")
// 获取品牌名称 // 获取品牌名称
brandInfo, err := dao.GetBrands(dao.GetDB(), "", storeDetail.BrandID, "", false, "") brandInfo, err := dao.GetBrands(dao.GetDB(), "", storeDetail.BrandID, "", false, "")
if err != nil { if err != nil {
globals.SugarLogger.Debug("蜂鸟门店创建--1", err)
return "", 0, err return "", 0, err
} }
createStore := &fnpsapi.CreateStoreBaseInfo{ createStore := &fnpsapi.CreateStoreBaseInfo{
@@ -69,7 +67,6 @@ func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.S
fnShopId, err := api.FnAPI.CreateStore(createStore) fnShopId, err := api.FnAPI.CreateStore(createStore)
if err != nil { if err != nil {
globals.SugarLogger.Debug("蜂鸟门店创建--2", err)
return "", 0, err return "", 0, err
} }
@@ -145,6 +142,12 @@ func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.S
updateStore.HeadShopName = brandInfo[0].Name + "-" + storeDetail.Name updateStore.HeadShopName = brandInfo[0].Name + "-" + storeDetail.Name
updateStore.BranchShopName = storeDetail.Name updateStore.BranchShopName = storeDetail.Name
} }
if updateStore.OwnerName == "" {
updateStore.OwnerName = "石锋"
}
if updateStore.OwnerIDNum == "" {
updateStore.OwnerIDNum = "610126198012230014"
}
return api.FnAPI.UpdateStore(updateStore) return api.FnAPI.UpdateStore(updateStore)
} }

View File

@@ -63,6 +63,7 @@ type IPrinterHandler interface {
RebindPrinter(ctx *jxcontext.Context, lastBindResult *BindPrinterResult) (bindResult *BindPrinterResult, err error) RebindPrinter(ctx *jxcontext.Context, lastBindResult *BindPrinterResult) (bindResult *BindPrinterResult, err error)
PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *PrinterStatus, err error) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *PrinterStatus, err error)
PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *PrinterStatus, err error)
EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error) EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error)
PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *PrinterStatus, err error) PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *PrinterStatus, err error)

View File

@@ -265,6 +265,10 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content) return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
} }
func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
return nil, err
}
func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, printerSN, printerKey, printerName string) (notUsed1, notUsed2 string, err error) { func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, printerSN, printerKey, printerName string) (notUsed1, notUsed2 string, err error) {
var no map[string]string var no map[string]string
if globals.EnableStoreWrite { if globals.EnableStoreWrite {

View File

@@ -255,6 +255,10 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
return c.PrintMsg(ctx, store.PrinterSN, utils.Int2Str(order.OrderSeq), order.VendorOrderID, content) return c.PrintMsg(ctx, store.PrinterSN, utils.Int2Str(order.OrderSeq), order.VendorOrderID, content)
} }
func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
return nil, err
}
func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error) { func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error) {
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
err = api.JxPrintAPI.DelPrinterSeq(id1) err = api.JxPrintAPI.DelPrinterSeq(id1)

View File

@@ -307,6 +307,10 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content) return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
} }
func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
return nil, err
}
func isV500(printerNo string) bool { func isV500(printerNo string) bool {
printerNoNum := utils.Str2Int64WithDefault("1"+printerNo, 0) printerNoNum := utils.Str2Int64WithDefault("1"+printerNo, 0)
return printerNoNum > 1000000000 return printerNoNum > 1000000000

View File

@@ -210,6 +210,170 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
return strings.Replace(fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...), "\\n", "\r\n", -1) return strings.Replace(fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...), "\\n", "\r\n", -1)
} }
// 打印取消或者退款订单
func (c *PrinterHandler) getCancelOrRefundOrderContent(order *model.GoodsOrder, printType int, storeDetail *dao.StoreDetail) (content string) {
expectedDeliveryTime := order.ExpectedDeliveredTime
if utils.IsTimeZero(expectedDeliveryTime) {
expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
}
orderParams := []interface{}{}
orderFmt := ``
if storeDetail != nil {
if storeDetail.BrandIsPrint == model.NO {
orderFmt += `
<FS2><CA>%s</CA></FS2>\n\n
`
if order.VendorOrgCode == "34665" {
orderParams = append(orderParams, globals.StoreNameEbai2)
} else {
orderParams = append(orderParams, storeDetail.BrandName)
}
}
}
title := ``
if printType == model.YES { // 退单
title = `<CA>取消订单详情</CA>\n`
} else {
title = `<CA>退款订单详情</CA>\n`
}
orderFmt += `
<CA>手机买菜上京西</CA>\n
` + title + `
--------------------------------
下单时间: %s\n
预计送达: %s\n
订单编号: %s\n
`
orderFmt += `
\n
<FS>%s#%d</FS>\n\n
客户: %s\n
电话: %s\n
地址: %s\n
\n
客户备注: \n
<FS>%s</FS>\n
\n
\n
商品明细: \n
品名 数量 小计\n
--------------------------------\n`
orderParams = append(orderParams,
utils.Time2Str(order.OrderCreatedAt),
utils.Time2Str(expectedDeliveryTime),
order.VendorOrderID,
jxutils.GetVendorName(order.VendorID),
//order.OrderSeq,
order.VendorOrderID,
order.ConsigneeName,
order.ConsigneeMobile,
order.ConsigneeAddress,
order.BuyerComment,
)
for _, sku := range order.Skus {
orderFmt += `<FH>%s</FH>\n`
orderFmt += `<FH>%20s%8s</FH>\n`
orderParams = append(orderParams, sku.SkuName, "X"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
//标品需要打印条形码
if sku.Upc != "" {
orderFmt += `upc码 %s\n`
orderParams = append(orderParams, sku.Upc)
}
}
orderFmt += `\n
<FB>共%d种%d件商品</FB>
\n
--------------------------------\n
--------------------------------\n
`
// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
orderParams = append(orderParams, order.SkuCount, order.GoodsCount)
return strings.Replace(fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...), "\\n", "\r\n", -1)
}
// 打印取消或者退款订单,大字体
func (c *PrinterHandler) getCancelOrRefundOrderContentBig(order *model.GoodsOrder, printType int, storeDetail *dao.StoreDetail) (content string) {
expectedDeliveryTime := order.ExpectedDeliveredTime
if utils.IsTimeZero(expectedDeliveryTime) {
expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
}
orderParams := []interface{}{}
orderFmt := ``
if storeDetail != nil {
if storeDetail.BrandIsPrint == model.NO {
orderFmt += `
<FS2><CA>%s</CA></FS2>\n\n
`
if order.VendorOrgCode == "34665" {
orderParams = append(orderParams, globals.StoreNameEbai2)
} else {
orderParams = append(orderParams, storeDetail.BrandName)
}
}
}
title := ``
if printType == model.YES { // 退单
title = `<CA>退单申请</CA>\n`
} else {
title = `<CA>退款申请</CA>\n`
}
orderFmt += `
<CA>手机买菜上京西</CA>\n
` + title + `
--------------------------------
<FS>下单时间: %s\n\n</FS>
<FS>预计送达: %s\n\n</FS>
<FS>订单编号: %s\n</FS>
\n
<FS>%s#%d</FS>\n\n
<FS>客户: %s\n</FS>
<FS>电话: %s\n</FS>
<FS>地址: %s\n</FS>
\n
<FS>客户备注: \n</FS>
<FS>%s</FS>\n
\n
\n
<FS>商品明细: \n</FS>
品名 数量 小计\n
--------------------------------\n`
orderParams = append(orderParams,
utils.Time2Str(order.OrderCreatedAt),
utils.Time2Str(expectedDeliveryTime),
order.VendorOrderID,
jxutils.GetVendorName(order.VendorID),
//order.OrderSeq,
order.VendorOrderID,
order.ConsigneeName,
order.ConsigneeMobile,
order.ConsigneeAddress,
order.BuyerComment,
)
for _, sku := range order.Skus {
orderFmt += `<FH2>%s\n</FH2>`
orderFmt += `<FS><FB>%15s%8s</FB>\n</FS>`
orderParams = append(orderParams, sku.SkuName, "X"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
//标品需要打印条形码
if sku.Upc != "" {
orderFmt += `<FS>upc码 %s\n</FS>`
orderParams = append(orderParams, sku.Upc)
}
}
orderFmt += `\n
<FS><FB>共%d种%d件商品</FB></FS>
\n
--------------------------------\n
--------------------------------\n
`
// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
orderParams = append(orderParams, order.SkuCount, order.GoodsCount)
return strings.Replace(fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...), "\\n", "\r\n", -1)
}
func (c *PrinterHandler) GetVendorID() int { func (c *PrinterHandler) GetVendorID() int {
return model.VendorIDYiLianYun return model.VendorIDYiLianYun
} }
@@ -272,6 +436,21 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
} }
} }
func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
globals.SugarLogger.Debugf("yilianyun PrintCancelOrRefundOrder orderID:%s, storeID:%d", order.VendorOrderID, store.ID)
if len(order.Skus) == 0 {
return
}
content := ""
if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 {
content = c.getCancelOrRefundOrderContent(order, printType, storeDetail)
} else {
content = c.getCancelOrRefundOrderContentBig(order, printType, storeDetail)
}
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
}
func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, machineCode, secret, printerName string) (notUsed1, notUsed2 string, err error) { func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, machineCode, secret, printerName string) (notUsed1, notUsed2 string, err error) {
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
err = api.YilianyunAPI.AddPrinter(machineCode, secret, printerName) err = api.YilianyunAPI.AddPrinter(machineCode, secret, printerName)

View File

@@ -230,6 +230,10 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content) return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
} }
func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
return nil, err
}
func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, deviceID, deviceSecret, printerName string) (notUsed1, notUsed2 string, err error) { func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, deviceID, deviceSecret, printerName string) (notUsed1, notUsed2 string, err error) {
if deviceID == "" || deviceSecret == "" { if deviceID == "" || deviceSecret == "" {
err = fmt.Errorf("打印机ID与打印机密钥都不能为空") err = fmt.Errorf("打印机ID与打印机密钥都不能为空")