添加退款订单打印以及退单打印
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"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/netprinter"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
|
||||
"git.rosy.net.cn/jx-callback/globals/api2"
|
||||
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 {
|
||||
//如果取消订单则要把库存加回去
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
if !isDuplicated {
|
||||
if order != nil {
|
||||
order.Skus = c.loadOrderSku(db, order.VendorOrderID, order.VendorID)
|
||||
|
||||
@@ -2,6 +2,7 @@ package basesch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
|
||||
"strings"
|
||||
"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) {
|
||||
skus := make([]*model.OrderFinancialSkuExt, 0, 0)
|
||||
afsOrder, err := partner.CurOrderManager.LoadAfsOrder(afsOrderID, vendorID)
|
||||
if err == nil {
|
||||
if c.IsReallyCallPlatformAPI {
|
||||
@@ -228,7 +230,7 @@ func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID s
|
||||
var (
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -628,6 +628,12 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
if bill.Status == model.WaybillStatusAccepted && order.NotifyType == 0 {
|
||||
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.DeliveryType == model.OrderDeliveryTypeStoreSelf {
|
||||
@@ -636,6 +642,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
}
|
||||
}
|
||||
|
||||
//订单已经是结束状态之后来的运单143945553920000001
|
||||
if order.Status > model.OrderStatusEndBegin {
|
||||
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
|
||||
@@ -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))
|
||||
if len(valid) > 0 {
|
||||
if globals.IsAddEvent {
|
||||
@@ -1398,7 +1373,7 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vend
|
||||
storeMap.SyncStatus = model.SyncFlagNewMask //京东商城要去建店
|
||||
} else {
|
||||
if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil {
|
||||
store, err2 := handler.ReadStore(ctx, vendorOrgCode, storeMap.VendorStoreID,storeMap.VendorStoreName)
|
||||
store, err2 := handler.ReadStore(ctx, vendorOrgCode, storeMap.VendorStoreID, storeMap.VendorStoreName)
|
||||
if err = err2; err == nil || storeMap.IsSync == 0 {
|
||||
if store != nil {
|
||||
storeMap.Status = store.Status
|
||||
@@ -1567,7 +1542,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
||||
|
||||
if vendorID != model.VendorIDJX && vendorID != model.VendorIDYB {
|
||||
if vendorStoreID := utils.Interface2String(valid["vendorStoreID"]); vendorStoreID != "" {
|
||||
vendorStoreInfo, err2 := storeHandler.ReadStore(ctx, storeMap.VendorOrgCode, vendorStoreID,storeMap.VendorStoreName)
|
||||
vendorStoreInfo, err2 := storeHandler.ReadStore(ctx, storeMap.VendorOrgCode, vendorStoreID, storeMap.VendorStoreName)
|
||||
if err = err2; err == nil {
|
||||
valid["deliveryType"] = vendorStoreInfo.DeliveryType
|
||||
}
|
||||
@@ -2253,7 +2228,7 @@ func GetStoresVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, v
|
||||
storeMap := batchItemList[0].(*model.StoreMap)
|
||||
if model.IsVendorRemote(storeMap.VendorID) {
|
||||
if handler := partner.GetPurchasePlatformFromVendorID(storeMap.VendorID); handler != nil {
|
||||
store, err2 := handler.ReadStore(ctx, storeMap.VendorOrgCode, storeMap.VendorStoreID,storeMap.VendorStoreName)
|
||||
store, err2 := handler.ReadStore(ctx, storeMap.VendorOrgCode, storeMap.VendorStoreID, storeMap.VendorStoreName)
|
||||
if err = err2; err == nil {
|
||||
retVal = []interface{}{&model.VendorStoreSnapshot{
|
||||
StoreID: storeMap.StoreID,
|
||||
@@ -2907,13 +2882,13 @@ func GetVendorStoreInfo(ctx *jxcontext.Context, vendorIDList []int, isAsync, isC
|
||||
storeID := batchItemList[0].(string)
|
||||
if partner.IsMultiStore(vendorID) {
|
||||
multiHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler)
|
||||
storeDetail, err = multiHandler.ReadStore(ctx, "", storeID,"")
|
||||
storeDetail, err = multiHandler.ReadStore(ctx, "", storeID, "")
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
} else {
|
||||
singleHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreHandler)
|
||||
storeDetail, err = singleHandler.ReadStore(ctx, "", storeID,"")
|
||||
storeDetail, err = singleHandler.ReadStore(ctx, "", storeID, "")
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
@@ -5276,7 +5251,7 @@ func RefreshStoreIsOnline(ctx *jxcontext.Context) (err error) {
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeMap := batchItemList[0].(*model.StoreMap)
|
||||
if handler := CurVendorSync.GetStoreHandler(storeMap.VendorID); handler != nil {
|
||||
if store, err := handler.ReadStore(ctx, storeMap.VendorOrgCode, storeMap.VendorStoreID,""); err == nil && store != nil {
|
||||
if store, err := handler.ReadStore(ctx, storeMap.VendorOrgCode, storeMap.VendorStoreID, ""); err == nil && store != nil {
|
||||
if store.Status != model.StoreStatusDisabled {
|
||||
storeMap.IsOnline = 1
|
||||
} else {
|
||||
|
||||
@@ -70,6 +70,7 @@ func getStore4Print(db *dao.DaoDB, storeID int) (store *model.Store, err error)
|
||||
return store, err
|
||||
}
|
||||
|
||||
// PrintOrderByOrder4Store 打印订单信息
|
||||
func PrintOrderByOrder4Store(ctx *jxcontext.Context, order *model.GoodsOrder, storeID int) (printResult *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("PrintOrderByOrder4Store orderID:%s", order.VendorOrderID)
|
||||
db := dao.GetDB()
|
||||
@@ -99,6 +100,29 @@ func PrintOrderByOrder4Store(ctx *jxcontext.Context, order *model.GoodsOrder, st
|
||||
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) {
|
||||
store := &model.Store{}
|
||||
store.ID = storeID
|
||||
|
||||
@@ -389,11 +389,13 @@ type Store struct {
|
||||
OperatorPhone3 string `orm:"size(16)" json:"operatorPhone3"` // 饿百运营人电话
|
||||
OperatorRole3 string `orm:"size(32)" json:"operatorRole3"` // 饿百运营人组(角色)
|
||||
|
||||
PromoteInfo string `orm:"size(255)" json:"promoteInfo"` //门店公告(所有平台统一的公告)
|
||||
IsBoughtMatter int `json:"isBoughtMatter"` //这周是否申请过物料
|
||||
SoundPercentage int `json:"soundPercentage"` //打印机声音大小比例
|
||||
Banner string `orm:"size(9999)" json:"banner"` //门店商城bannar图
|
||||
BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID
|
||||
PromoteInfo string `orm:"size(255)" json:"promoteInfo"` //门店公告(所有平台统一的公告)
|
||||
IsBoughtMatter int `json:"isBoughtMatter"` //这周是否申请过物料
|
||||
SoundPercentage int `json:"soundPercentage"` //打印机声音大小比例
|
||||
Banner string `orm:"size(9999)" json:"banner"` //门店商城bannar图
|
||||
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 {
|
||||
|
||||
@@ -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