- 平台活动创建,初步OK
This commit is contained in:
@@ -3,9 +3,9 @@ package act
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
@@ -29,39 +29,39 @@ func TestCreateAct(t *testing.T) {
|
|||||||
actStoreSkuList := []*ActStoreSkuParam{
|
actStoreSkuList := []*ActStoreSkuParam{
|
||||||
&ActStoreSkuParam{
|
&ActStoreSkuParam{
|
||||||
ActStoreSku: model.ActStoreSku{
|
ActStoreSku: model.ActStoreSku{
|
||||||
StoreID: 100884,
|
StoreID: 2,
|
||||||
SkuID: 22716,
|
SkuID: 2142,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&ActStoreSkuParam{
|
&ActStoreSkuParam{
|
||||||
ActStoreSku: model.ActStoreSku{
|
ActStoreSku: model.ActStoreSku{
|
||||||
StoreID: 100884,
|
StoreID: 2,
|
||||||
SkuID: 22717,
|
SkuID: 1162,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&ActStoreSkuParam{
|
&ActStoreSkuParam{
|
||||||
ActStoreSku: model.ActStoreSku{
|
ActStoreSku: model.ActStoreSku{
|
||||||
StoreID: 100920,
|
StoreID: 2,
|
||||||
SkuID: 22714,
|
SkuID: 1167,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&ActStoreSkuParam{
|
&ActStoreSkuParam{
|
||||||
ActStoreSku: model.ActStoreSku{
|
ActStoreSku: model.ActStoreSku{
|
||||||
StoreID: 100920,
|
StoreID: 2,
|
||||||
SkuID: 22715,
|
SkuID: 1172,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// t.Log(utils.Format4Output(actStoreSkuList, true))
|
t.Log(utils.Format4Output(actStoreSkuList, true))
|
||||||
actID, err := CreateAct(jxcontext.AdminCtx, &model.Act{
|
// actID, err := CreateAct(jxcontext.AdminCtx, &model.Act{
|
||||||
Name: "测试活动",
|
// Name: "测试活动",
|
||||||
PricePercentage: 80,
|
// PricePercentage: 80,
|
||||||
Type: model.ActSkuDirectDown,
|
// Type: model.ActSkuDirectDown,
|
||||||
}, []int{model.VendorIDJD, model.VendorIDMTWM, model.VendorIDEBAI}, nil, actStoreSkuList, false)
|
// }, []int{model.VendorIDJD, model.VendorIDMTWM, model.VendorIDEBAI}, nil, actStoreSkuList, false)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
globals.SugarLogger.Debug(actID)
|
// globals.SugarLogger.Debug(actID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCancelAct(t *testing.T) {
|
func TestCancelAct(t *testing.T) {
|
||||||
|
|||||||
@@ -101,9 +101,9 @@ func GetActStoreSkuVendorInfo(db *DaoDB, actID int, vendorIDs, storeIDs, skuIDs
|
|||||||
sqlParams = append(sqlParams, skuIDs)
|
sqlParams = append(sqlParams, skuIDs)
|
||||||
}
|
}
|
||||||
var actStoreSkuList []*model.ActStoreSku2
|
var actStoreSkuList []*model.ActStoreSku2
|
||||||
globals.SugarLogger.Debug(sql)
|
// globals.SugarLogger.Debug(sql)
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(actStoreSkuList, false))
|
// globals.SugarLogger.Debug(utils.Format4Output(actStoreSkuList, false))
|
||||||
if err = GetRows(db, &actStoreSkuList, sql, sqlParams...); err == nil {
|
if err = GetRows(db, &actStoreSkuList, sql, sqlParams...); err == nil {
|
||||||
actStoreSkuMap = make(map[int][]*model.ActStoreSku2)
|
actStoreSkuMap = make(map[int][]*model.ActStoreSku2)
|
||||||
for _, v := range actStoreSkuList {
|
for _, v := range actStoreSkuList {
|
||||||
|
|||||||
@@ -72,10 +72,14 @@ func act2EbaiActivity(act *model.Act2, actOrderRules []*model.ActOrderRule) (act
|
|||||||
ActivityType: actType2Ebai(act.Type),
|
ActivityType: actType2Ebai(act.Type),
|
||||||
StartTime: act.BeginAt.Unix(),
|
StartTime: act.BeginAt.Unix(),
|
||||||
EndTime: act.EndAt.Unix(),
|
EndTime: act.EndAt.Unix(),
|
||||||
|
OpenTime: "00:00",
|
||||||
|
CloseTime: "23:59",
|
||||||
|
WeekDay: "0,1,2,3,4,5,6",
|
||||||
ActivityDesc: act.Advertising,
|
ActivityDesc: act.Advertising,
|
||||||
ShowCategory: act.Name,
|
ShowCategory: act.Name,
|
||||||
PromotionSkuDesc: act.Name,
|
PromotionSkuDesc: act.Advertising,
|
||||||
DayLimit: act.LimitDaily,
|
DayLimit: act.LimitDaily,
|
||||||
|
ActivityPlatform: ebaiapi.ActivityPFAll,
|
||||||
}
|
}
|
||||||
if act.LimitCount > 0 {
|
if act.LimitCount > 0 {
|
||||||
activity.OrderLimit = act.LimitCount
|
activity.OrderLimit = act.LimitCount
|
||||||
@@ -93,8 +97,8 @@ func createOneShopAct(act *model.Act2, shopID string, oneStoreActSku []*model.Ac
|
|||||||
globals.SugarLogger.Debugf("ebai createOneShopAct")
|
globals.SugarLogger.Debugf("ebai createOneShopAct")
|
||||||
activity := act2EbaiActivity(act, nil)
|
activity := act2EbaiActivity(act, nil)
|
||||||
if globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
ebaiActID, err := api.EbaiAPI.ActivityCreate(shopID, 0, 0, activity)
|
ebaiActID, err2 := api.EbaiAPI.ActivityCreate(shopID, 0, 0, activity)
|
||||||
if err == nil {
|
if err = err2; err == nil {
|
||||||
ebaiActIDStr = utils.Int64ToStr(ebaiActID)
|
ebaiActIDStr = utils.Int64ToStr(ebaiActID)
|
||||||
_, err = ActivitySkuAddBatch(ebaiActID, shopID, 0, activity.ActivityType, actStoreSu2Ebai4Add(oneStoreActSku), false)
|
_, err = ActivitySkuAddBatch(ebaiActID, shopID, 0, activity.ActivityType, actStoreSu2Ebai4Add(oneStoreActSku), false)
|
||||||
}
|
}
|
||||||
@@ -310,9 +314,11 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagModifiedMask))
|
if err == nil {
|
||||||
|
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagModifiedMask))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
}()
|
}()
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
_, err2 := dao.BatchUpdateEntityByKV(db, updateItems)
|
_, err2 := dao.BatchUpdateEntityByKV(db, updateItems)
|
||||||
|
|||||||
@@ -251,9 +251,11 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
|
|||||||
}
|
}
|
||||||
updateItems = append(updateItems, partner.ActStoreSku2Update(deleteActInfoMap[vendorActID], model.SyncFlagDeletedMask)...)
|
updateItems = append(updateItems, partner.ActStoreSku2Update(deleteActInfoMap[vendorActID], model.SyncFlagDeletedMask)...)
|
||||||
}
|
}
|
||||||
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagModifiedMask))
|
if err == nil {
|
||||||
|
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagModifiedMask))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
}()
|
}()
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
_, err2 := dao.BatchUpdateEntityByKV(db, updateItems)
|
_, err2 := dao.BatchUpdateEntityByKV(db, updateItems)
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ func createOneShopAct(act *model.Act2, vendorStoreID string, actStoreSku []*mode
|
|||||||
if len(actData) > 0 {
|
if len(actData) > 0 {
|
||||||
if globals.EnableMtwmStoreWrite {
|
if globals.EnableMtwmStoreWrite {
|
||||||
actResult, err2 := api.MtwmAPI.RetailDiscountBatchSave(vendorStoreID, actData)
|
actResult, err2 := api.MtwmAPI.RetailDiscountBatchSave(vendorStoreID, actData)
|
||||||
|
globals.SugarLogger.Debugf("mtwm createOneShopAct err2:%v", err2)
|
||||||
if err = err2; err != nil {
|
if err = err2; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -118,7 +119,7 @@ func createSkuAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.A
|
|||||||
task := tasksch.NewParallelTask("mtwm createSkuAct", nil, ctx,
|
task := tasksch.NewParallelTask("mtwm createSkuAct", nil, ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
list := batchItemList[0].([]*model.ActStoreSku2)
|
list := batchItemList[0].([]*model.ActStoreSku2)
|
||||||
if err = createOneShopAct(act, utils.Int2Str(list[0].StoreID), list); err == nil {
|
if err = createOneShopAct(act, list[0].VendorStoreID, list); err == nil {
|
||||||
retVal = []interface{}{list}
|
retVal = []interface{}{list}
|
||||||
}
|
}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
@@ -188,9 +189,11 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagModifiedMask))
|
if err == nil {
|
||||||
|
updateItems = append(updateItems, partner.Act2Update(act, model.SyncFlagModifiedMask))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
}()
|
}()
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
_, err2 := dao.BatchUpdateEntityByKV(db, updateItems)
|
_, err2 := dao.BatchUpdateEntityByKV(db, updateItems)
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ type ActController struct {
|
|||||||
// @Param beginAt formData string true "开始日期"
|
// @Param beginAt formData string true "开始日期"
|
||||||
// @Param endAt formData string true "结束日期"
|
// @Param endAt formData string true "结束日期"
|
||||||
// @Param pricePercentage formData int true "活动价格比例"
|
// @Param pricePercentage formData int true "活动价格比例"
|
||||||
|
// @Param advertising formData string true "广告语"
|
||||||
// @Param actStoreSkuList formData string true "活动门店商品信息"
|
// @Param actStoreSkuList formData string true "活动门店商品信息"
|
||||||
// @Param advertising formData string false "广告语"
|
|
||||||
// @Param limitDaily formData int false "是否按日0-不限,>0限购单数(限时抢需填)"
|
// @Param limitDaily formData int false "是否按日0-不限,>0限购单数(限时抢需填)"
|
||||||
// @Param limitUser formData int false "是否用户限购0-不限,1-限购"
|
// @Param limitUser formData int false "是否用户限购0-不限,1-限购"
|
||||||
// @Param limitCount formData int false "限购件数 0-不限,如账号限购、设备限购有一个为1,则限购件数必须大于0的整数"
|
// @Param limitCount formData int false "限购件数 0-不限,如账号限购、设备限购有一个为1,则限购件数必须大于0的整数"
|
||||||
@@ -50,6 +50,7 @@ func (c *ActController) CreateAct() {
|
|||||||
PricePercentage: params.PricePercentage,
|
PricePercentage: params.PricePercentage,
|
||||||
BeginAt: timeList[0],
|
BeginAt: timeList[0],
|
||||||
EndAt: timeList[1],
|
EndAt: timeList[1],
|
||||||
|
Advertising: params.Advertising,
|
||||||
Remark: params.Remark,
|
Remark: params.Remark,
|
||||||
}
|
}
|
||||||
retVal, err = act.CreateAct(params.Ctx, actObj, vendorIDs, nil, actStoreSkuList, params.IsAsync)
|
retVal, err = act.CreateAct(params.Ctx, actObj, vendorIDs, nil, actStoreSkuList, params.IsAsync)
|
||||||
|
|||||||
Reference in New Issue
Block a user