From 31b7fe33e8f368f7a4d63f4b5de4a5f66b5b685f Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 17:44:15 +0800 Subject: [PATCH 1/6] StoreChangePriceTypeBossDisabled --- business/cs/weimob_order.go | 3 ++- business/model/store.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/business/cs/weimob_order.go b/business/cs/weimob_order.go index 932ff1d12..1f2afd8e6 100644 --- a/business/cs/weimob_order.go +++ b/business/cs/weimob_order.go @@ -83,9 +83,10 @@ func GetStoreList4Mobile(db *dao.DaoDB, mobileList []string) (storeList []*model sql := ` SELECT t1.* FROM store t1 - WHERE t1.deleted_at = ?` + WHERE t1.deleted_at = ? /*AND t1.change_price_type = ?*/` sqlParams := []interface{}{ utils.DefaultTimeValue, + // model.StoreChangePriceTypeBossDisabled, } if len(mobileList) > 0 { questionMarks := dao.GenQuestionMarks(len(mobileList)) diff --git a/business/model/store.go b/business/model/store.go index 9338dd8d5..2bbab4956 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -43,8 +43,9 @@ const ( ) const ( - StoreChangePriceTypeDirect = 0 - StoreChangePriceTypeNeedApprove = 1 + StoreChangePriceTypeDirect = 0 + StoreChangePriceTypeNeedApprove = 1 + StoreChangePriceTypeBossDisabled = 2 ) var ( From f4e29f719a1ace8f86406d9140ef057d442d8c67 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 18:36:19 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=99=90=E5=88=B6=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E8=80=81=E6=9D=BF=E7=9B=B4=E6=8E=A5=E4=BF=AE=E6=94=B9=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E6=94=B9=E4=BB=B7=E5=B1=9E=E6=80=A7=E4=B8=BA=EF=BC=9A?= =?UTF-8?q?StoreChangePriceTypeBossDisabled=E7=9A=84=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 16 ++++++++++++---- business/jxutils/jxcontext/jxcontext.go | 12 ++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 25d9e9bf1..3f91a1525 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -131,6 +131,8 @@ type tStoreSkuBindAndSpec struct { SkuNamePrice int SkuNameUnit string RealSkuID int `orm:"column(real_sku_id)"` + + ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核 } type SkuSaleInfo struct { @@ -907,6 +909,10 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs // return nil, err // } // globals.SugarLogger.Debugf("updateStoresSkusWithoutSync2, storeIDs:%v, skuBindInfos:%s", storeIDs, utils.Format4Output(skuBindInfos, false)) + isUserCanDirectChangePrice := true + if user := ctx.GetFullUser(); user != nil { + isUserCanDirectChangePrice = user.Type&model.UserTypeOperator != 0 + } userName := ctx.GetUserName() needSyncIDMap := make(map[int]int) @@ -931,7 +937,8 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs sql += " IF(t5.unit_price > 0, t5.unit_price, t3.price) sku_name_price," } sql += ` - t3.unit sku_name_unit, t3.name, t3.status sku_name_status + t3.unit sku_name_unit, t3.name, t3.status sku_name_status, + ts.change_price_type FROM sku t1 JOIN store ts ON ts.id = ? AND ts.deleted_at = ? LEFT JOIN store_sku_bind t2 ON t2.sku_id = t1.id AND t2.store_id = ts.id AND t2.deleted_at = ? @@ -981,10 +988,11 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs for _, v := range allBinds { var num int64 inSkuBind := inSkuBinsMap[v.RealSkuID] + isCanChangePrice := (isUserCanDirectChangePrice || v.ChangePriceType != model.StoreChangePriceTypeBossDisabled) // globals.SugarLogger.Debug(utils.Format4Output(inSkuBind, false)) var skuBind *model.StoreSkuBind if v.ID == 0 { - if skuBindInfo.IsFocus == 1 && v.SkuNameStatus == model.SkuStatusNormal && v.SkuStatus == model.SkuStatusNormal { + if skuBindInfo.IsFocus == 1 && v.SkuNameStatus == model.SkuStatusNormal && v.SkuStatus == model.SkuStatusNormal && isCanChangePrice { skuBind = &model.StoreSkuBind{ StoreID: storeID, SkuID: v.RealSkuID, @@ -1008,7 +1016,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs } else { skuBind = &v.StoreSkuBind - if skuBindInfo.IsFocus == -1 { + if skuBindInfo.IsFocus == -1 && isCanChangePrice { if num, err = dao.DeleteEntityLogically(db, skuBind, map[string]interface{}{ model.FieldStatus: model.StoreSkuBindStatusDeleted, model.FieldJdSyncStatus: model.SyncFlagDeletedMask, @@ -1038,7 +1046,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs setStoreSkuBindStatus(skuBind, model.SyncFlagSaleMask) updateFieldMap[model.FieldStatus] = 1 } - if skuBindInfo.UnitPrice != 0 { // 这里是否需要加此条件限制 + if skuBindInfo.UnitPrice != 0 && isCanChangePrice { // 这里是否需要加此条件限制 skuBind.UnitPrice = unitPrice skuBind.Price = jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit) setStoreSkuBindStatus(skuBind, model.SyncFlagPriceMask) diff --git a/business/jxutils/jxcontext/jxcontext.go b/business/jxutils/jxcontext/jxcontext.go index 7c91a9bd3..b7a46648e 100644 --- a/business/jxutils/jxcontext/jxcontext.go +++ b/business/jxutils/jxcontext/jxcontext.go @@ -6,6 +6,7 @@ import ( "git.rosy.net.cn/jx-callback/business/auth2" "git.rosy.net.cn/jx-callback/business/model" + "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/globals" ) @@ -156,3 +157,14 @@ func (ctx *Context) GetUserID() (userID string) { } return userID } + +func (ctx *Context) GetFullUser() (user *model.User) { + token := ctx.GetToken() + authInfo, err2 := auth2.GetTokenInfo(token) + if err2 == nil { + if authInfo.TokenType == auth2.TokenTypeNormal { + user, _ = dao.GetUserByID(dao.GetDB(), "user_id", authInfo.GetID()) + } + } + return user +} From 7d76db62dc540ea1c203f54fdbd5d23b8f5eff9f Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 1 Nov 2019 10:40:28 +0800 Subject: [PATCH 3/6] =?UTF-8?q?dao.GetStoreSkus2=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E5=A4=9A=E9=97=A8=E5=BA=97=E5=B9=B3=E5=8F=B0=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=88=9B=E5=BB=BA=E7=9A=84=E5=95=86=E5=93=81?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E7=9B=B4=E6=8E=A5=E8=BF=87=E6=BB=A4=EF=BC=8C?= =?UTF-8?q?=E8=AE=A9=E4=B8=8A=E5=B1=82=E5=90=8C=E6=AD=A5=E6=97=B6=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/store_sku.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index c83416d25..d61410ad5 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -286,10 +286,11 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo sql += " AND t1.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")" sqlParams = append(sqlParams, skuIDs) } - if !isSingleStorePF { - sql += " AND t2.%s_id <> 0" - fmtParams = append(fmtParams, fieldPrefix) - } + // 多门店平台没有成功创建的商品,不直接过滤,让上层同步时报错 + // if !isSingleStorePF { + // sql += " AND t2.%s_id <> 0" + // fmtParams = append(fmtParams, fieldPrefix) + // } sql = fmt.Sprintf(sql, fmtParams...) sql += " ORDER BY t1.price" // globals.SugarLogger.Debug(sql) From 099fe6189f10bf9ddb724a9ea9c122e66c4482b4 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 1 Nov 2019 14:35:51 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=BD=93=E8=BE=93=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E9=A5=BF=E7=99=BE=E9=97=A8=E5=BA=97ID=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E8=BD=AC=E4=B8=BA=E6=95=B4=E6=95=B0=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/ebai/store.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index b50caaef9..d76a5c13e 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -80,7 +80,10 @@ func getCoordintate(data interface{}) float64 { } func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) { - baiduShopID := utils.Str2Int64(vendorStoreID) + baiduShopID := utils.Str2Int64WithDefault(vendorStoreID, 0) + if baiduShopID == 0 { + return nil, fmt.Errorf("饿百门店ID:%s非法,应该是一个整数", vendorStoreID) + } result, err := api.EbaiAPI.ShopGet("", baiduShopID) if err == nil { // globals.SugarLogger.Debug(utils.Format4Output(result, false)) From 0c2981e8f87d9ba79d31ccfbeb0a75a605ec1b45 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 1 Nov 2019 14:48:08 +0800 Subject: [PATCH 5/6] up --- business/model/dao/store_sku.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index d61410ad5..ab244cb4a 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -287,10 +287,10 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo sqlParams = append(sqlParams, skuIDs) } // 多门店平台没有成功创建的商品,不直接过滤,让上层同步时报错 - // if !isSingleStorePF { - // sql += " AND t2.%s_id <> 0" - // fmtParams = append(fmtParams, fieldPrefix) - // } + if !isSingleStorePF { + sql += " AND t2.%s_id <> 0" + fmtParams = append(fmtParams, fieldPrefix) + } sql = fmt.Sprintf(sql, fmtParams...) sql += " ORDER BY t1.price" // globals.SugarLogger.Debug(sql) From 28c0c5a393faf317058535b86e19573bd11e1cd0 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 1 Nov 2019 15:23:39 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=A4=9A=E9=97=A8=E5=BA=97=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E6=B2=A1=E6=9C=89=E5=88=9B=E5=BB=BA=E7=9A=84=E5=95=86?= =?UTF-8?q?=E5=93=81=EF=BC=8C=E5=88=A0=E9=99=A4=E9=97=A8=E5=BA=97=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=97=B6=E7=9A=84=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= =?UTF-8?q?=20=E5=9C=A8=E8=AE=BE=E7=BD=AE=E5=88=A0=E9=99=A4=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E5=95=86=E5=93=81=E6=97=B6=EF=BC=8C=E5=BF=85=E9=A1=BB?= =?UTF-8?q?=E8=A6=81=E6=98=AFskuname=E6=88=96sku=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E5=95=86=E5=93=81=E6=97=B6=E4=BC=9A=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=88=A0=E9=99=A4=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync_store_sku.go | 6 ++++-- business/model/dao/store_sku.go | 8 ++++---- business/partner/partner.go | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 24b9a9670..74efff588 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -238,10 +238,12 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = utils.Str2Int64WithDefault(sku.VendorSkuID, 0) } else if model.IsSyncStatusDelete(syncStatus) { sku.StoreSkuSyncStatus = 0 - if utils.IsTimeZero(sku.BindDeletedAt) { + if utils.IsTimeZero(sku.BindDeletedAt) && (sku.ID == 0 || sku.NameID == 0) { kvs[model.FieldDeletedAt] = time.Now() } - kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = 0 + if !dao.IsVendorThingIDEmpty(sku.VendorSkuID) && !partner.IsMultiStore(vendorID) { + kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = 0 + } } else { sku.StoreSkuSyncStatus = sku.StoreSkuSyncStatus & model.SyncFlagPriceMask } diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index ab244cb4a..d61410ad5 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -287,10 +287,10 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo sqlParams = append(sqlParams, skuIDs) } // 多门店平台没有成功创建的商品,不直接过滤,让上层同步时报错 - if !isSingleStorePF { - sql += " AND t2.%s_id <> 0" - fmtParams = append(fmtParams, fieldPrefix) - } + // if !isSingleStorePF { + // sql += " AND t2.%s_id <> 0" + // fmtParams = append(fmtParams, fieldPrefix) + // } sql = fmt.Sprintf(sql, fmtParams...) sql += " ORDER BY t1.price" // globals.SugarLogger.Debug(sql) diff --git a/business/partner/partner.go b/business/partner/partner.go index 28dadcba3..102304630 100644 --- a/business/partner/partner.go +++ b/business/partner/partner.go @@ -265,6 +265,5 @@ func IsMultiStore(vendorID int) bool { if _, ok := GetPurchasePlatformFromVendorID(vendorID).(IMultipleStoresHandler); ok { return true } - return false }