打印到家订单

This commit is contained in:
gazebo
2020-02-05 10:16:07 +08:00
parent 5659eaa847
commit 2ea4f30326
4 changed files with 53 additions and 30 deletions

View File

@@ -4,27 +4,33 @@ import (
"fmt"
"strings"
"git.rosy.net.cn/baseapi/platformapi/jdapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"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/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
)
func (c *OrderManager) OnNewFakeJdOrder(vendorOrderID string) (err error) {
orderInfo, err := api.FakeJdAPI.FakeQuerySingleOrder(vendorOrderID)
if err == nil {
err = c.notifyNewFakeJdOrder(orderInfo)
}
utils.CallFuncAsync(func() {
orderInfo, err := api.FakeJdAPI.FakeQuerySingleOrderRaw(vendorOrderID)
if err == nil {
err = c.notifyNewFakeJdOrder(jd.Map2Order(orderInfo))
}
if err != nil {
globals.SugarLogger.Warnf("OnNewFakeJdOrder failed with err:%v", err)
}
})
return err
}
func (c *OrderManager) notifyNewFakeJdOrder(orderInfo *jdapi.OrderInfo) (err error) {
vendorStoreID := orderInfo.DeliveryStationNo
func (c *OrderManager) notifyNewFakeJdOrder(order *model.GoodsOrder) (err error) {
db := dao.GetDB()
storeDetail, err := dao.GetStoreDetailByVendorStoreID(db, vendorStoreID, model.VendorIDJD)
storeDetail, err := dao.GetStoreDetailByVendorStoreID(db, order.VendorStoreID, model.VendorIDJD)
if err != nil {
return err
}
@@ -32,25 +38,34 @@ func (c *OrderManager) notifyNewFakeJdOrder(orderInfo *jdapi.OrderInfo) (err err
if storeDetail.LinkStoreID != 0 {
realStoreID = storeDetail.LinkStoreID
}
notifyWxNewFakeJdOrder(orderInfo, realStoreID)
notifyWxNewFakeJdOrder(order, realStoreID)
netprinter.PrintOrderByOrder4Store(jxcontext.AdminCtx, order, realStoreID)
return err
}
func notifyWxNewFakeJdOrder(order *jdapi.OrderInfo, storeID int) (err error) {
globals.SugarLogger.Debugf("notifyWxNewFakeJdOrder orderID:%s", order.SrcOrderID)
func notifyWxNewFakeJdOrder(order *model.GoodsOrder, storeID int) (err error) {
globals.SugarLogger.Debugf("notifyWxNewFakeJdOrder orderID:%s", order.VendorOrderID)
sb := new(strings.Builder)
sb.WriteString("老板,你有新订单了\n")
sb.WriteString(fmt.Sprintf("订单号:%s\n", order.SrcOrderID))
sb.WriteString(fmt.Sprintf("买家:%s\n", order.BuyerFullName))
sb.WriteString(fmt.Sprintf("电话:%s\n", order.BuyerMobile))
sb.WriteString(fmt.Sprintf("收货地址:%s\n", order.BuyerFullAddress))
sb.WriteString("商品详情:\n")
for _, product := range order.Product {
sb.WriteString(fmt.Sprintf("\t%s*%d\n", product.SkuName, product.SkuCount))
sb.WriteString(fmt.Sprintf("订单号:%s\n", order.VendorOrderID))
sb.WriteString("送达时间:")
if order.BusinessType == model.BusinessTypeDingshida {
sb.WriteString(utils.Time2Str(order.ExpectedDeliveredTime))
} else {
sb.WriteString("立即达")
}
title := fmt.Sprintf("你有到家菜市新订单%d", order.OrderNum)
context := sb.String()
_, err = weixinmsg.SendStoreMessage(jxcontext.AdminCtx, title, context, []int{storeID}, true, true)
sb.WriteString("\n")
sb.WriteString(fmt.Sprintf("买家:%s\n", order.ConsigneeName))
sb.WriteString(fmt.Sprintf("电话:%s\n", order.ConsigneeMobile))
sb.WriteString(fmt.Sprintf("收货地址:%s\n", order.ConsigneeAddress))
sb.WriteString("商品详情:\n")
for _, sku := range order.Skus {
sb.WriteString(fmt.Sprintf("\t%s*%d\n", sku.SkuName, sku.Count))
}
title := fmt.Sprintf("你有到家菜市新订单%d", order.OrderSeq)
content := sb.String()
// globals.SugarLogger.Debugf("notifyWxNewFakeJdOrder, orderID:%s, content:%s", order.VendorOrderID, content)
_, err = weixinmsg.SendStoreMessage(jxcontext.AdminCtx, title, content, []int{storeID}, true, true)
return err
}