mtwm.curPurchaseHandler改为CurPurchaseHandler
This commit is contained in:
@@ -7,19 +7,19 @@ import (
|
||||
)
|
||||
|
||||
func OnCallbackMsg(msg *mtwmapi.CallbackMsg) (response *mtwmapi.CallbackResponse) {
|
||||
if curPurchaseHandler != nil {
|
||||
if CurPurchaseHandler != nil {
|
||||
if msg.Cmd == mtwmapi.MsgTypeStoreStatusChanged {
|
||||
response = curPurchaseHandler.onStoreStatusChanged(msg)
|
||||
response = CurPurchaseHandler.onStoreStatusChanged(msg)
|
||||
} else if msg.Cmd == mtwmapi.MsgTypePrivateNumberDowngrade {
|
||||
response = curPurchaseHandler.onNumberDowngrade(msg)
|
||||
response = CurPurchaseHandler.onNumberDowngrade(msg)
|
||||
} else {
|
||||
if orderID := GetOrderIDFromMsg(msg); orderID != "" {
|
||||
jxutils.CallMsgHandler(func() {
|
||||
switch msg.Cmd {
|
||||
case mtwmapi.MsgTypeWaybillStatus:
|
||||
response = curPurchaseHandler.onWaybillMsg(msg)
|
||||
response = CurPurchaseHandler.onWaybillMsg(msg)
|
||||
default:
|
||||
response = curPurchaseHandler.onOrderMsg(msg)
|
||||
response = CurPurchaseHandler.onOrderMsg(msg)
|
||||
}
|
||||
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDMTWM))
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func OnFinancialMsg(msg *mtwmapi.CallbackMsg) (err error) {
|
||||
if msg.Cmd == mtwmapi.MsgTypeOrderPartialRefund { // 部分退款处理
|
||||
orderData := msg.FormData
|
||||
if orderData.Get("notify_type") == mtwmapi.NotifyTypeSuccess {
|
||||
err = partner.CurOrderManager.SaveAfsOrderFinancialInfo(curPurchaseHandler.AfsOrderDetail2Financial(orderData))
|
||||
err = partner.CurOrderManager.SaveAfsOrderFinancialInfo(CurPurchaseHandler.AfsOrderDetail2Financial(orderData))
|
||||
}
|
||||
}
|
||||
if msg.Cmd == mtwmapi.MsgTypeOrderRefund { // todo 全额退款处理
|
||||
@@ -31,7 +31,7 @@ func OnFinancialMsg(msg *mtwmapi.CallbackMsg) (err error) {
|
||||
orderFinancial, err := partner.CurOrderManager.LoadOrderFinancial(afsOrderID, model.VendorIDMTWM)
|
||||
if err == nil {
|
||||
globals.SugarLogger.Debug(utils.Format4Output(orderFinancial, false))
|
||||
err = partner.CurOrderManager.SaveAfsOrderFinancialInfo(curPurchaseHandler.OrderFinancialDetail2Refund(orderFinancial, orderData))
|
||||
err = partner.CurOrderManager.SaveAfsOrderFinancialInfo(CurPurchaseHandler.OrderFinancialDetail2Refund(orderFinancial, orderData))
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("mtwm OnFinancialMsg, afsOrderID:%s is not found from partner.CurOrderManager.LoadOrderFinancial", afsOrderID)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestOnFinancialMsg(t *testing.T) {
|
||||
},
|
||||
}
|
||||
msg.FormData.Set("food", string(utils.MustMarshal(food)))
|
||||
res := curPurchaseHandler.onAfsOrderMsg(msg)
|
||||
res := CurPurchaseHandler.onAfsOrderMsg(msg)
|
||||
fmt.Println(res)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
curPurchaseHandler *PurchaseHandler
|
||||
CurPurchaseHandler *PurchaseHandler
|
||||
)
|
||||
|
||||
type PurchaseHandler struct {
|
||||
@@ -30,8 +30,8 @@ type PurchaseHandler struct {
|
||||
|
||||
func init() {
|
||||
if api.MtwmAPI != nil {
|
||||
curPurchaseHandler = New()
|
||||
partner.RegisterPurchasePlatform(curPurchaseHandler)
|
||||
CurPurchaseHandler = New()
|
||||
partner.RegisterPurchasePlatform(CurPurchaseHandler)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetOrder(t *testing.T) {
|
||||
result, err := curPurchaseHandler.GetOrder("33437032333978492")
|
||||
result, err := CurPurchaseHandler.GetOrder("33437032333978492")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -19,7 +19,7 @@ func TestGetOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListOrders(t *testing.T) {
|
||||
result, err := curPurchaseHandler.ListOrders(jxcontext.AdminCtx, nil, time.Now(), "4626746")
|
||||
result, err := CurPurchaseHandler.ListOrders(jxcontext.AdminCtx, nil, time.Now(), "4626746")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetStoreSkusFullInfo(t *testing.T) {
|
||||
skuNameList, err := curPurchaseHandler.GetStoreSkusFullInfo(jxcontext.AdminCtx, nil, 2, "2523687", nil)
|
||||
skuNameList, err := CurPurchaseHandler.GetStoreSkusFullInfo(jxcontext.AdminCtx, nil, 2, "2523687", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -19,7 +19,7 @@ func TestGetStoreSkusFullInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetStoreSkusBareInfo(t *testing.T) {
|
||||
storeSkuList, err := curPurchaseHandler.GetStoreSkusBareInfo(jxcontext.AdminCtx, nil, 2, "2523687", []*partner.StoreSkuInfo{
|
||||
storeSkuList, err := CurPurchaseHandler.GetStoreSkusBareInfo(jxcontext.AdminCtx, nil, 2, "2523687", []*partner.StoreSkuInfo{
|
||||
&partner.StoreSkuInfo{
|
||||
SkuID: 969,
|
||||
},
|
||||
@@ -35,26 +35,26 @@ func TestGetStoreSkusBareInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteStoreAllSkus(t *testing.T) {
|
||||
err := curPurchaseHandler.DeleteStoreAllSkus(jxcontext.AdminCtx, nil, 2, "2523687", true)
|
||||
err := CurPurchaseHandler.DeleteStoreAllSkus(jxcontext.AdminCtx, nil, 2, "2523687", true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteStoreAllCategories(t *testing.T) {
|
||||
err := curPurchaseHandler.DeleteStoreAllCategories(jxcontext.AdminCtx, nil, 2, "2523687", true)
|
||||
err := CurPurchaseHandler.DeleteStoreAllCategories(jxcontext.AdminCtx, nil, 2, "2523687", true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetStoreCategory(t *testing.T) {
|
||||
_, err := curPurchaseHandler.GetStoreCategory(jxcontext.AdminCtx, 2, "2523687", "不存在的分类")
|
||||
_, err := CurPurchaseHandler.GetStoreCategory(jxcontext.AdminCtx, 2, "2523687", "不存在的分类")
|
||||
if err == nil {
|
||||
t.Fatal("应该找不到这个分类")
|
||||
}
|
||||
catName := "小月饼"
|
||||
cat, err := curPurchaseHandler.GetStoreCategory(jxcontext.AdminCtx, 2, "2523687", catName)
|
||||
cat, err := CurPurchaseHandler.GetStoreCategory(jxcontext.AdminCtx, 2, "2523687", catName)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if cat.Name != catName {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// func TestSyncStoreCategory(t *testing.T) {
|
||||
// hint, err := curPurchaseHandler.SyncStoreCategory(jxcontext.AdminCtx, nil, testShopID, false)
|
||||
// hint, err := CurPurchaseHandler.SyncStoreCategory(jxcontext.AdminCtx, nil, testShopID, false)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
// }
|
||||
|
||||
// func TestSyncLocalStoreCategory(t *testing.T) {
|
||||
// hint, err := curPurchaseHandler.SyncLocalStoreCategory(jxcontext.AdminCtx, nil, testShopID, true, nil)
|
||||
// hint, err := CurPurchaseHandler.SyncLocalStoreCategory(jxcontext.AdminCtx, nil, testShopID, true, nil)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
// }
|
||||
|
||||
// func TestSyncStoreSkus(t *testing.T) {
|
||||
// hint, err := curPurchaseHandler.SyncStoreSkus(jxcontext.AdminCtx, nil, testShopID, nil, false, true)
|
||||
// hint, err := CurPurchaseHandler.SyncStoreSkus(jxcontext.AdminCtx, nil, testShopID, nil, false, true)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
@@ -32,14 +32,14 @@ import (
|
||||
// }
|
||||
|
||||
func TestDeleteRemoteSkus(t *testing.T) {
|
||||
err := curPurchaseHandler.DeleteStoreAllSkus(jxcontext.AdminCtx, nil, testShopID, testShopVendorID, true)
|
||||
err := CurPurchaseHandler.DeleteStoreAllSkus(jxcontext.AdminCtx, nil, testShopID, testShopVendorID, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteRemoteCategories(t *testing.T) {
|
||||
err := curPurchaseHandler.DeleteStoreAllCategories(jxcontext.AdminCtx, nil, testShopID, testShopVendorID, true)
|
||||
err := CurPurchaseHandler.DeleteStoreAllCategories(jxcontext.AdminCtx, nil, testShopID, testShopVendorID, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestReadStore(t *testing.T) {
|
||||
store, err := curPurchaseHandler.ReadStore(jxcontext.AdminCtx, "4351018")
|
||||
store, err := CurPurchaseHandler.ReadStore(jxcontext.AdminCtx, "4351018")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -19,7 +19,7 @@ func TestReadStore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateStore(t *testing.T) {
|
||||
err := curPurchaseHandler.UpdateStore(nil, 100002, "test")
|
||||
err := CurPurchaseHandler.UpdateStore(nil, 100002, "test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user