This commit is contained in:
gazebo
2019-07-01 18:08:38 +08:00
parent 3099884331
commit 4c6ebce30d
2 changed files with 3 additions and 122 deletions

View File

@@ -231,10 +231,6 @@ func GetActDetail(ctx *jxcontext.Context, actID int) (actDetail *ActDetail, err
return actDetail, err
}
func UpdateAct(ctx *jxcontext.Context, act *model.Act, actRules []*ActOrderRuleParam, actStoreSku []*ActStoreSkuParam) (err error) {
return err
}
func CancelAct(ctx *jxcontext.Context, actID int) (err error) {
db := dao.GetDB()
if err = deleteActStoreBind(ctx, db, actID, nil); err != nil {
@@ -353,93 +349,4 @@ func SyncAct(ctx *jxcontext.Context, actID int, vendorIDs, storeIDs, skuIDs []in
}
}
return err
// var actOrderRules []*model.ActOrderRule
// db := dao.GetDB()
// actMap, err := dao.GetActVendorInfo(db, actID, vendorIDs)
// if err != nil {
// return err
// }
// actStoreMap, err := dao.GetActStoreVendorInfo(db, actID, vendorIDs, storeIDs)
// if err != nil {
// return err
// }
// actStoreSkuMap, err := dao.GetActStoreSkuVendorInfo(db, actID, vendorIDs, storeIDs, skuIDs)
// if err != nil {
// return err
// }
// var realVendorIDs []int
// for vendorID := range actMap {
// realVendorIDs = append(realVendorIDs, vendorID)
// }
// task := tasksch.NewParallelTask("SyncAct", nil, ctx,
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
// vendorID := batchItemList[0].(int)
// handler := partner.GetPurchasePlatformFromVendorID(vendorID)
// if handler == nil {
// err = fmt.Errorf("不被支持的vendorID:%d", vendorID)
// } else {
// act := actMap[vendorID]
// actStore := actStoreMap[vendorID]
// actStoreSku := actStoreSkuMap[vendorID]
// // globals.SugarLogger.Debugf("%s", utils.Format4Output(act, false))
// // globals.SugarLogger.Debugf("%s", utils.Format4Output(actStore, false))
// // globals.SugarLogger.Debugf("%s", utils.Format4Output(actStoreSku, false))
// if act != nil && actStore != nil && actStoreSku != nil {
// if model.IsSyncStatusNeedCreate(act.SyncStatus) {
// err = handler.CreateAct(ctx, task, act, actOrderRules, actStore, actStoreSku)
// } else if model.IsSyncStatusNeedUpdate(act.SyncStatus) {
// if act.Status == model.ActStatusCanceled {
// err = handler.CancelAct(ctx, task, act, actStore, actStoreSku)
// } else {
// // actStoreMap2Remove, actStoreMap2Add, actStoreMap2Update := splitActStore(actStore)
// // err = handler.UpdateAct(ctx, task, act, actOrderRules, actStoreMap2Remove, actStoreMap2Add, actStoreMap2Update, actStoreSku)
// }
// }
// if err == nil {
// actMap := &model.ActMap{}
// actMap.ID = act.MapID
// dao.UpdateEntityLogically(db, actMap, map[string]interface{}{
// model.FieldSyncStatus: 0,
// model.FieldVendorActID: act.VendorActID,
// }, ctx.GetUserName(), nil)
// for _, v := range actStore {
// storeMap := model.ActStoreMap{}
// storeMap.ID = v.MapID
// dao.UpdateEntityLogically(db, storeMap, map[string]interface{}{
// model.FieldSyncStatus: 0,
// model.FieldVendorActID: v.VendorActID,
// }, ctx.GetUserName(), nil)
// }
// for _, v := range actStoreSku {
// storeSkuMap := model.ActStoreSkuMap{}
// storeSkuMap.ID = v.MapID
// dao.UpdateEntityLogically(db, storeSkuMap, map[string]interface{}{
// model.FieldSyncStatus: 0,
// model.FieldVendorActID: v.VendorActID,
// }, ctx.GetUserName(), nil)
// }
// }
// }
// }
// return nil, err
// }, realVendorIDs)
// tasksch.ManageTask(task).Run()
// _, err = task.GetResult(0)
return err
}
// func splitActStore(actStore []*model.ActStore2) (actStoreMap2Remove, actStoreMap2Add, actStoreMap2Update []*model.ActStore2) {
// for _, v := range actStore {
// if model.IsSyncStatusNeedDelete(v.SyncStatus) {
// if !dao.IsVendorThingIDEmpty(v.VendorActID) {
// actStoreMap2Remove = append(actStoreMap2Remove, v)
// }
// } else if model.IsSyncStatusNeedCreate(v.SyncStatus) {
// actStoreMap2Add = append(actStoreMap2Add, v)
// } else if model.IsSyncStatusNeedUpdate(v.SyncStatus) {
// actStoreMap2Update = append(actStoreMap2Update, v)
// }
// }
// return actStoreMap2Remove, actStoreMap2Add, actStoreMap2Update
// }

View File

@@ -114,11 +114,6 @@ func AdjustPromotionSku(promotionType int, infoId int64, outInfoId string, skus
return skusResult, err
}
func getTraceID(ctx *jxcontext.Context) (traceID string) {
traceID = ctx.GetUserName() + utils.GetUUID()
return traceID
}
func storeSku2Jd(actStoreSku []*model.ActStoreSku2, handler func(syncStatus int) bool) (jdActStoreSku []*jdapi.PromotionSku) {
for _, v := range actStoreSku {
if handler(v.SyncStatus) {
@@ -133,17 +128,8 @@ func storeSku2Jd(actStoreSku []*model.ActStoreSku2, handler func(syncStatus int)
return jdActStoreSku
}
func (c *PurchaseHandler) CreateAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.Act2, actOrderRules []*model.ActOrderRule, actStoreSku []*model.ActStoreSku2) (err error) {
if act.Type < model.ActOrderBegin {
act.VendorActID, err = createSkuAct(ctx, act, actStoreSku)
} else {
}
return err
}
func createSkuAct(ctx *jxcontext.Context, act *model.Act2, actStoreSku []*model.ActStoreSku2) (vendorActID string, err error) {
traceID := getTraceID(ctx)
traceID := ctx.GetAccessUUID()
outInfoID := ""
if act.VendorActID == "" {
outInfoID = utils.Int2Str(act.ID)
@@ -166,25 +152,13 @@ func createSkuAct(ctx *jxcontext.Context, act *model.Act2, actStoreSku []*model.
func cancelSkuActSkus(ctx *jxcontext.Context, actType int, vendorActID string, actStoreSku []*model.ActStoreSku2) (err error) {
if skuList := storeSku2Jd(actStoreSku, model.IsSyncStatusNeedDelete); len(skuList) > 0 {
err = CancelPromotionSku(actType, utils.Str2Int64(vendorActID), "", skuList, getTraceID(ctx))
err = CancelPromotionSku(actType, utils.Str2Int64(vendorActID), "", skuList, ctx.GetAccessUUID())
}
return err
}
func cancelSkuAct(ctx *jxcontext.Context, actType int, vendorActID string) (err error) {
err = CancelPromotion(actType, utils.Str2Int64(vendorActID), "", getTraceID(ctx))
return err
}
func (c *PurchaseHandler) UpdateAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.Act2, actOrderRules []*model.ActOrderRule, actStoreSku []*model.ActStoreSku2) (err error) {
return err
}
func (c *PurchaseHandler) CancelAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.Act2, actStoreSku []*model.ActStoreSku2) (err error) {
if act.Type < model.ActOrderBegin {
outInfoID := utils.Int2Str(act.ID)
err = CancelPromotion(act.Type, 0, outInfoID, getTraceID(ctx))
}
err = CancelPromotion(actType, utils.Str2Int64(vendorActID), "", ctx.GetAccessUUID())
return err
}