From 140fda89272524e40e2c8dbdcd0e6c8cca7ee050 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Mon, 16 Aug 2021 09:41:38 +0800 Subject: [PATCH] aa --- business/jxstore/act/act.go | 18 +++ business/jxstore/act/act_test.go | 119 ++++++++++---------- business/partner/purchase/ebai/order_afs.go | 3 + controllers/act.go | 9 +- 4 files changed, 86 insertions(+), 63 deletions(-) diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index 3f569c5d9..9096ccacb 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -982,6 +982,20 @@ func DeleteActStoreSkuBind(ctx *jxcontext.Context, db *dao.DaoDB, actID int, act return 0, err } + //if len(actMap) == 0 { + // + // return 0, fmt.Errorf("活动%d不存在或已被取消", actID) + //} + //errList := errlist.New() + //for vendorID, act := range actMap { + // if vendorID == model.VendorIDEBAI && act.CreateType != model.ActCreateTypeAPI { + // errList.AddErr(fmt.Errorf("饿百平台不支持修改或取消网页活动")) + // } + //} + //if errList.GetErrListAsOne() != nil { + // return 0, errList.GetErrListAsOne() + //} + actStoreSkuMap, err := dao.GetActStoreSkuVendorInfo(db, actID, nil, nil, nil) if err != nil { return 0, err @@ -2095,3 +2109,7 @@ func GetActMtwmVendor(ctx *jxcontext.Context, storeIDs, skuIDs []int, keyword, b func GetActMtwmVendorSku(ctx *jxcontext.Context, storeID int, keyword string, actType, offset, pageSize int) (page *model.PagedInfo, err error) { return dao.GetActMtwmVendorSkuPage(dao.GetDB(), storeID, keyword, actType, offset, pageSize) } + +func DeleteActStoreSkuVendor(ctx *jxcontext.Context, db *dao.DaoDB, actStoreSkuParam []*ActStoreSkuParam) (err error) { + return fmt.Errorf("暂不支持直接取消平台活动,开发中……") +} diff --git a/business/jxstore/act/act_test.go b/business/jxstore/act/act_test.go index dd76e8cf3..4878718cc 100644 --- a/business/jxstore/act/act_test.go +++ b/business/jxstore/act/act_test.go @@ -1,14 +1,11 @@ package act import ( - "testing" - "time" - "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/model/dao" - "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/testinit" + "testing" "git.rosy.net.cn/jx-callback/business/model" @@ -67,50 +64,50 @@ func TestCreateActOnAlpha(t *testing.T) { } func TestCreateActOnDev(t *testing.T) { - actStoreSkuList := []*ActStoreSkuParam{ - &ActStoreSkuParam{ - ActStoreSku: model.ActStoreSku{ - StoreID: 100884, - SkuID: 22716, - }, - }, - &ActStoreSkuParam{ - ActStoreSku: model.ActStoreSku{ - StoreID: 100884, - SkuID: 22717, - }, - }, - &ActStoreSkuParam{ - ActStoreSku: model.ActStoreSku{ - StoreID: 100920, - SkuID: 22714, - }, - }, - &ActStoreSkuParam{ - ActStoreSku: model.ActStoreSku{ - StoreID: 100920, - SkuID: 22715, - }, - }, - // &ActStoreSkuParam{ - // ActStoreSku: model.ActStoreSku{ - // StoreID: 100119, - // SkuID: 26595, - // }, - // }, - } + //actStoreSkuList := []*ActStoreSkuParam{ + // &ActStoreSkuParam{ + // ActStoreSku: model.ActStoreSku{ + // StoreID: 100884, + // SkuID: 22716, + // }, + // }, + // &ActStoreSkuParam{ + // ActStoreSku: model.ActStoreSku{ + // StoreID: 100884, + // SkuID: 22717, + // }, + // }, + // &ActStoreSkuParam{ + // ActStoreSku: model.ActStoreSku{ + // StoreID: 100920, + // SkuID: 22714, + // }, + // }, + // &ActStoreSkuParam{ + // ActStoreSku: model.ActStoreSku{ + // StoreID: 100920, + // SkuID: 22715, + // }, + // }, + // // &ActStoreSkuParam{ + // // ActStoreSku: model.ActStoreSku{ + // // StoreID: 100119, + // // SkuID: 26595, + // // }, + // // }, + //} // t.Log(utils.Format4Output(actStoreSkuList, true)) - actID, err := CreateAct(jxcontext.AdminCtx, &model.Act{ - Name: "测试活动", - PricePercentage: 80, - Type: model.ActSkuDirectDown, - BeginAt: time.Now().Add(-24 * time.Hour), - EndAt: time.Now().Add(10 * 24 * time.Hour), - }, []int{model.VendorIDJD, model.VendorIDMTWM /*, model.VendorIDEBAI*/}, nil, actStoreSkuList, false) - if err != nil { - t.Fatal(err) - } - globals.SugarLogger.Debug(actID) + //actID, err := CreateAct(jxcontext.AdminCtx, &model.Act{ + // Name: "测试活动", + // PricePercentage: 80, + // Type: model.ActSkuDirectDown, + // BeginAt: time.Now().Add(-24 * time.Hour), + // EndAt: time.Now().Add(10 * 24 * time.Hour), + //}, []int{model.VendorIDJD, model.VendorIDMTWM /*, model.VendorIDEBAI*/}, nil, actStoreSkuList, false) + //if err != nil { + // t.Fatal(err) + //} + //globals.SugarLogger.Debug(actID) } func TestCancelAct(t *testing.T) { @@ -192,18 +189,18 @@ func TestSyncAct(t *testing.T) { } func TestForceUpdateVendorPrice(t *testing.T) { - hint, err := ForceUpdateVendorPrice(jxcontext.AdminCtx, model.VendorIDJD, model.ActSkuDirectDown, []*ActStoreSkuParam{ - &ActStoreSkuParam{ - ActStoreSku: model.ActStoreSku{ - StoreID: 100118, - SkuID: 22509, - ActPrice: 9900, - }, - VendorPrice: 19900, - }, - }, false) - if err != nil { - t.Fatal(err) - } - t.Log(hint) + //hint, err := ForceUpdateVendorPrice(jxcontext.AdminCtx, model.VendorIDJD, model.ActSkuDirectDown, []*ActStoreSkuParam{ + // &ActStoreSkuParam{ + // ActStoreSku: model.ActStoreSku{ + // StoreID: 100118, + // SkuID: 22509, + // ActPrice: 9900, + // }, + // VendorPrice: 19900, + // }, + //}, false) + //if err != nil { + // t.Fatal(err) + //} + //t.Log(hint) } diff --git a/business/partner/purchase/ebai/order_afs.go b/business/partner/purchase/ebai/order_afs.go index 65e323f05..229da640a 100644 --- a/business/partner/purchase/ebai/order_afs.go +++ b/business/partner/purchase/ebai/order_afs.go @@ -246,6 +246,9 @@ func (c *PurchaseHandler) RefundOrder(ctx *jxcontext.Context, order *model.Goods // 发起部分退款 func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, refundSkuList []*model.OrderSku, reason string) (err error) { if globals.EnableEbaiStoreWrite { + if order.Status > model.OrderStatusEndBegin { + return fmt.Errorf("饿百暂不支持售后退款!") + } err = api.EbaiAPI.OrderPartRefund(order.VendorOrderID, orderSkus2AfsSkus(refundSkuList)) } return err diff --git a/controllers/act.go b/controllers/act.go index d07aa416b..66f43e15d 100644 --- a/controllers/act.go +++ b/controllers/act.go @@ -288,8 +288,13 @@ func (c *ActController) UpdateActStoreSkuBind() { } } if len(actStoreSkuDeleteList) > 0 { - if _, err = act.DeleteActStoreSkuBind(params.Ctx, db, params.ActID, actStoreSkuDeleteList); err != nil { - return + //可能是平台直接创建的活动,尝试直接取消一下 + if params.ActID < 1000 { + act.DeleteActStoreSkuVendor(params.Ctx, db, actStoreSkuDeleteList) + } else { + if _, err = act.DeleteActStoreSkuBind(params.Ctx, db, params.ActID, actStoreSkuDeleteList); err != nil { + return + } } } if err == nil {