添加退款订单打印以及退单打印
This commit is contained in:
@@ -95,7 +95,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap
|
||||
order.Status = model.WaybillStatusUnknown
|
||||
}
|
||||
err := dadaapi.Err2CallbackResponse(partner.CurOrderManager.OnWaybillStatusChanged(order), utils.Int2Str(order.Status))
|
||||
defer delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID) // 骑手位置更新
|
||||
defer delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID) // 骑手位置更新
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -120,6 +120,12 @@ func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal
|
||||
}
|
||||
|
||||
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)
|
||||
lat := jxutils.IntCoordinate2Standard(storeDetail.Lat)
|
||||
cityName := storeDetail.CityName
|
||||
@@ -135,7 +141,7 @@ func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.Shop
|
||||
}
|
||||
shopInfo = &dadaapi.ShopInfo{
|
||||
OriginShopID: storeDetail.VendorStoreID,
|
||||
StationName: globals.StoreName + "-" + storeDetail.Name,
|
||||
StationName: brandInfo[0].Name + "-" + storeDetail.Name,
|
||||
Business: dadaapi.BusinessTypeConvStore, // 故意设置成这个的
|
||||
CityName: cityName,
|
||||
AreaName: districtName,
|
||||
|
||||
@@ -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) {
|
||||
globals.SugarLogger.Debug("蜂鸟门店创建")
|
||||
// 获取品牌名称
|
||||
brandInfo, err := dao.GetBrands(dao.GetDB(), "", storeDetail.BrandID, "", false, "")
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("蜂鸟门店创建--1", err)
|
||||
return "", 0, err
|
||||
}
|
||||
createStore := &fnpsapi.CreateStoreBaseInfo{
|
||||
@@ -69,7 +67,6 @@ func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.S
|
||||
|
||||
fnShopId, err := api.FnAPI.CreateStore(createStore)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("蜂鸟门店创建--2", 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.BranchShopName = storeDetail.Name
|
||||
}
|
||||
if updateStore.OwnerName == "" {
|
||||
updateStore.OwnerName = "石锋"
|
||||
}
|
||||
if updateStore.OwnerIDNum == "" {
|
||||
updateStore.OwnerIDNum = "610126198012230014"
|
||||
}
|
||||
|
||||
return api.FnAPI.UpdateStore(updateStore)
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ type IPrinterHandler interface {
|
||||
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)
|
||||
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)
|
||||
PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *PrinterStatus, err error)
|
||||
|
||||
@@ -83,7 +83,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
商品明细: <BR>
|
||||
品名 数量 单价 小计<BR>
|
||||
--------------------------------<BR>`
|
||||
// <BOLD>实际支付:</BOLD>%s<BR>
|
||||
// <BOLD>实际支付:</BOLD>%s<BR>
|
||||
orderParams = append(orderParams,
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
utils.Time2Str(expectedDeliveryTime),
|
||||
@@ -174,7 +174,7 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
|
||||
<B>商品明细: <BR></B>
|
||||
<B>品名数量单价小计<BR></B>
|
||||
--------------------------------<BR>`
|
||||
// <B><BOLD>实际支付:</BOLD></B><B>%s<BR></B>
|
||||
// <B><BOLD>实际支付:</BOLD></B><B>%s<BR></B>
|
||||
orderParams = append(orderParams,
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
utils.Time2Str(expectedDeliveryTime),
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
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) {
|
||||
var no map[string]string
|
||||
if globals.EnableStoreWrite {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
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) {
|
||||
if globals.EnableStoreWrite {
|
||||
err = api.JxPrintAPI.DelPrinterSeq(id1)
|
||||
|
||||
@@ -65,7 +65,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
品名 数量 单价 小计
|
||||
--------------------------------*
|
||||
`
|
||||
// <S011>实际支付: %s*
|
||||
// <S011>实际支付: %s*
|
||||
orderParams := []interface{}{
|
||||
globals.StoreName,
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
@@ -140,7 +140,7 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
|
||||
<big>品名数量单价小计*
|
||||
--------------------------------*
|
||||
`
|
||||
// <big>实际支付: %s*
|
||||
// <big>实际支付: %s*
|
||||
orderParams := []interface{}{
|
||||
globals.StoreName,
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
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 {
|
||||
printerNoNum := utils.Str2Int64WithDefault("1"+printerNo, 0)
|
||||
return printerNoNum > 1000000000
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
// 打印取消或者退款订单
|
||||
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 {
|
||||
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) {
|
||||
if globals.EnableStoreWrite {
|
||||
err = api.YilianyunAPI.AddPrinter(machineCode, secret, printerName)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
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) {
|
||||
if deviceID == "" || deviceSecret == "" {
|
||||
err = fmt.Errorf("打印机ID与打印机密钥都不能为空")
|
||||
|
||||
Reference in New Issue
Block a user