57 lines
1.9 KiB
Go
57 lines
1.9 KiB
Go
package orderman
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
|
"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/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)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (c *OrderManager) notifyNewFakeJdOrder(orderInfo *jdapi.OrderInfo) (err error) {
|
|
vendorStoreID := orderInfo.DeliveryStationNo
|
|
db := dao.GetDB()
|
|
storeDetail, err := dao.GetStoreDetailByVendorStoreID(db, vendorStoreID, model.VendorIDJD)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
realStoreID := storeDetail.ID
|
|
if storeDetail.LinkStoreID != 0 {
|
|
realStoreID = storeDetail.LinkStoreID
|
|
}
|
|
notifyWxNewFakeJdOrder(orderInfo, realStoreID)
|
|
return err
|
|
}
|
|
|
|
func notifyWxNewFakeJdOrder(order *jdapi.OrderInfo, storeID int) (err error) {
|
|
globals.SugarLogger.Debugf("notifyWxNewFakeJdOrder orderID:%s", order.SrcOrderID)
|
|
|
|
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))
|
|
}
|
|
title := fmt.Sprintf("你有到家菜市新订单%d", order.OrderNum)
|
|
context := sb.String()
|
|
_, err = weixinmsg.SendStoreMessage(jxcontext.AdminCtx, title, context, []int{storeID}, true, true)
|
|
return err
|
|
}
|