到家商城的订单发通知消息
+Store.LinkStoreID
This commit is contained in:
56
business/jxcallback/orderman/fake_jd_order.go
Normal file
56
business/jxcallback/orderman/fake_jd_order.go
Normal file
@@ -0,0 +1,56 @@
|
||||
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
|
||||
}
|
||||
14
business/jxcallback/orderman/fake_jd_order_test.go
Normal file
14
business/jxcallback/orderman/fake_jd_order_test.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package orderman
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestOnNewFakeJdOrder(t *testing.T) {
|
||||
err := FixedOrderManager.OnNewFakeJdOrder("2002984074001021")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
time.Sleep(3 * time.Second)
|
||||
}
|
||||
17
business/jxcallback/orderman/orderman_test.go
Normal file
17
business/jxcallback/orderman/orderman_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package orderman
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/globals/api2"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/elm"
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/weimob/wsc"
|
||||
)
|
||||
|
||||
func init() {
|
||||
testinit.Init()
|
||||
api2.Init()
|
||||
}
|
||||
Reference in New Issue
Block a user