diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 014fa2112..e2ebdd981 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -1072,6 +1072,7 @@ func UpdateStoreSkus(ctx *jxcontext.Context, causeFlag, storeID int, skuBindInfo func UpdateStoresSkus(ctx *jxcontext.Context, causeFlag int, storeIDs []int, skuBindInfos []*StoreSkuBindInfo, isScale, isRefreshHigh, isAsync, isContinueWhenError bool) (hint string, err error) { globals.SugarLogger.Debugf("UpdateStoresSkus:%s, storeIDs:%v, skuBindInfos:%s", ctx.GetTrackInfo(), storeIDs, utils.Format4Output(skuBindInfos, true)) if beego.BConfig.RunMode == "jxgy" { + doStoreSkuAuditForGy(ctx, storeIDs, skuBindInfos) var num int64 db := dao.GetDB() skuIDs, err := updateStoresSkusWithoutSync(ctx, db, storeIDs, skuBindInfos, isScale, isRefreshHigh) @@ -5096,6 +5097,74 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto return true, err } +func doStoreSkuAuditForGy(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (isAudit bool, err error) { + globals.SugarLogger.Debugf("doStoreSkuAuditForGy storeIDs: %v", storeIDs) + time.Sleep(time.Second / 5) + db := dao.GetDB() + for _, storeID := range storeIDs { + // stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, nil, "") + //扣点的门店改价不进审核 + // if len(stores) > 0 { + // if stores[0].PayPercentage <= 50 || stores[0].StoreLevel == "E" || stores[0].StoreLevel == "D" { + // globals.SugarLogger.Debugf("doStoreSkuAudit return0 storeID : %v", storeID) + // return false, err + // } + // } + for _, skuBindInfo := range skuBindInfos { + globals.SugarLogger.Debugf("doStoreSkuAudit storeID: %v , nameID: %v", storeID, skuBindInfo.NameID) + storeAudits, err := dao.GetStoreSkuAuditLight(db, []int{storeID}, []int{skuBindInfo.NameID}, model.StoreAuditStatusOnline) + //取消关注,可售排除 + if skuBindInfo.IsFocus == -1 || skuBindInfo.IsSale != 0 || skuBindInfo.UnitPrice == 0 { + globals.SugarLogger.Debugf("doStoreSkuAudit return1 storeID : %v nameID: %v", storeID, skuBindInfo.NameID) + return false, err + } + + if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != auth2.AuthTypeMobile { + globals.SugarLogger.Debugf("doStoreSkuAudit return3 storeID : %v loginType: %v", storeID, ctx.GetLoginType()) + authInfo, err := ctx.GetV2AuthInfo() + if err == nil && authInfo != nil && (ctx.GetFullUser().Type&model.UserTypeOperator) != 0 { + if len(storeAudits) > 0 { + storeAudits[0].DeletedAt = time.Now() + dao.UpdateEntity(db, storeAudits[0], "DeletedAt") + } + globals.SugarLogger.Debugf("doStoreSkuAudit return3 storeID : %v nameID: %v", storeID, skuBindInfo.NameID) + return false, err + } + } + storeSkuAudit := &model.StoreSkuAudit{ + StoreID: storeID, + NameID: skuBindInfo.NameID, + Status: model.StoreAuditStatusCreated, + UnitPrice: skuBindInfo.UnitPrice, + } + //如果是关注改价 + if skuBindInfo.IsFocus == 1 { + if len(storeAudits) > 0 { + storeAudits[0].DeletedAt = time.Now() + dao.UpdateEntity(db, storeAudits[0], "DeletedAt") + } + storeSkuAudit.Type = model.StoreSkuAuditTypeFocus + } else { + storeSkus, _ := dao.GetStoreSkusByNameIDs(db, []int{storeID}, skuBindInfo.NameID) + if len(storeSkus) > 0 { + if len(storeAudits) > 0 { + storeAudits[0].DeletedAt = time.Now() + dao.UpdateEntity(db, storeAudits[0], "DeletedAt") + } + globals.SugarLogger.Debugf("doStoreSkuAudit cover storeID : %v nameID: %v", storeID, skuBindInfo.NameID) + } else { + return false, fmt.Errorf("未查询到该门店商品价,storeID: %v, nameID: %V", storeID, skuBindInfo.NameID) + } + storeSkuAudit.Type = model.StoreSkuAuditTypePrice + storeSkuAudit.OriginUnitPrice = int(storeSkus[0].UnitPrice) + } + dao.WrapAddIDCULDEntity(storeSkuAudit, ctx.GetUserName()) + err = dao.CreateEntity(db, storeSkuAudit) + } + } + return true, err +} + func StoreSkuPriceAudit(ctx *jxcontext.Context, storeSkuAudits []*model.StoreSkuAudit, status int, isAsync, isContinueWhenError bool) (storeSkuAudits2 []*model.StoreSkuAudit, hint string, err error) { db := dao.GetDB() if status == model.StoreAuditStatusOnline { diff --git a/business/jxstore/tempop/tempop.go b/business/jxstore/tempop/tempop.go index f77d32d15..f76e907c4 100644 --- a/business/jxstore/tempop/tempop.go +++ b/business/jxstore/tempop/tempop.go @@ -1879,21 +1879,20 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) { // tasksch.HandleTask(task, nil, true).Run() // _, err = task.GetResult(0) //京东账号更新 - // var ( - // db = dao.GetDB() - // ) - // if configs, err := dao.QueryConfigs(dao.GetDB(), "jdConfigCookie", model.ConfigTypeCookie, ""); err == nil { - // api.JdAPI.SetCookieWithStr(configs[0].Value) - // result, _ := api.JdAPI.GetJdAppInfo() - // if result != nil { - // if vocs, _ := dao.GetVendorOrgCode(db, model.VendorIDJD, result.OrgCode, model.VendorOrgTypePlatform); len(vocs) > 0 { - // vocs[0].AppKey = result.AppKey - // vocs[0].AppSecret = result.AppSecret - // dao.UpdateEntity(db, vocs[0], "AppKey", "AppSecret") - // } - // } - // } - cms.RefreshStoreBind(ctx) + var ( + db = dao.GetDB() + ) + if configs, err := dao.QueryConfigs(dao.GetDB(), "jdConfigCookie", model.ConfigTypeCookie, ""); err == nil { + api.JdAPI.SetCookieWithStr(configs[0].Value) + result, _ := api.JdAPI.GetJdAppInfo() + if result != nil { + if vocs, _ := dao.GetVendorOrgCode(db, model.VendorIDJD, result.OrgCode, model.VendorOrgTypePlatform); len(vocs) > 0 { + vocs[0].AppKey = result.AppKey + vocs[0].AppSecret = result.AppSecret + dao.UpdateEntity(db, vocs[0], "AppKey", "AppSecret") + } + } + } return err }