From 296d877d550d767e00a1d22b043accf00133b6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 8 Jan 2020 10:20:50 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=85=B3=E6=B3=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 772e849a5..bbaeb71cf 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2872,6 +2872,7 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync, } for k, v := range skuNameMap { skuBindInfo := &StoreSkuBindInfo{ + StoreID: store.ID, NameID: k, UnitPrice: v, IsFocus: 1, @@ -2893,7 +2894,7 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync, case 2: for _, v := range result1 { tUpdate := v.(*tUpdateStoresSkus) - UpdateStoresSkus(ctx, []int{tUpdate.StoreID}, tUpdate.SkuBindInfos, false, isAsync, isContinueWhenError) + UpdateStoresSkusByBind(ctx, tUpdate.SkuBindInfos, true, true) } } return result, err @@ -3048,12 +3049,13 @@ func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context) (err error payPercentage = v.PayPercentage } if len(skuNameAndPlaceList) > 0 { - for _, v := range skuNameAndPlaceList { - if skuNameMap[v.ID] != 0 { - priceReferList, err := dao.GetPriceReferSnapshotNoPage(db, []int{v.CityCode}, nil, []int{v.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1))) + for _, vv := range skuNameAndPlaceList { + if skuNameMap[vv.ID] != 0 { + priceReferList, err := dao.GetPriceReferSnapshotNoPage(db, []int{vv.CityCode}, nil, []int{vv.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1))) if err == nil && len(priceReferList) > 0 { storeSkuBindInfo := &StoreSkuBindInfo{ - NameID: v.ID, + StoreID: v.ID, + NameID: vv.ID, UnitPrice: priceReferList[0].MidUnitPrice * payPercentage / 100, IsFocus: 1, IsSale: 0, @@ -3063,7 +3065,7 @@ func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context) (err error } } } - UpdateStoreSkus(ctx, v.ID, skuBindInfoList, true, true) + UpdateStoresSkusByBind(ctx, skuBindInfoList, true, true) } return err } From d7ae6eb9a277e19216cef837c95288786243a1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 8 Jan 2020 10:30:03 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=B1=8F=E8=94=BD=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/cms_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/cms_store_sku.go b/controllers/cms_store_sku.go index dc1c5ae62..916fe9fbf 100644 --- a/controllers/cms_store_sku.go +++ b/controllers/cms_store_sku.go @@ -620,7 +620,7 @@ func (c *StoreSkuController) FocusStoreSkusBySku() { var skuIDList []int c.callFocusStoreSkusBySku(func(params *tStoreSkuFocusStoreSkusBySkuParams) (retVal interface{}, errCode string, err error) { if jxutils.Strings2Objs(params.SkuIDs, &skuIDList); err == nil { - retVal, err = cms.FocusStoreSkusBySku(params.Ctx, skuIDList, params.IsAsync, params.IsContinueWhenError) + // retVal, err = cms.FocusStoreSkusBySku(params.Ctx, skuIDList, params.IsAsync, params.IsContinueWhenError) } return retVal, "", err }) From 4a51bfca9bb97cb4af1459c0f64f99374d201a52 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 8 Jan 2020 10:38:08 +0800 Subject: [PATCH 3/6] +StoresOrderSaleInfo.DistanceFreightMoney, WaybillTipMoney --- business/jxcallback/orderman/orderman_ext.go | 3 +++ business/model/dao/dao_order.go | 17 +++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 60ff706f3..a8cb01875 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -655,6 +655,9 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID } saleInfo.ActualPayPrice += v.ActualPayPrice saleInfo.Count++ + + saleInfo.DistanceFreightMoney += v.DistanceFreightMoney + saleInfo.WaybillTipMoney += v.WaybillTipMoney } orderMap[universalOrderID].SkuCount += v.Count diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 7339adfef..6416c5f3f 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -16,22 +16,27 @@ const ( ) type StoresOrderSaleInfo struct { - StoreID int `orm:"column(store_id)" json:"storeID"` - VendorID int `orm:"column(vendor_id)" json:"vendorID"` - Status int `json:"status"` + StoreID int `orm:"column(store_id)" json:"storeID"` + VendorID int `orm:"column(vendor_id)" json:"vendorID"` + Status int `json:"status"` + Count int `json:"count"` ShopPrice int64 `json:"shopPrice"` VendorPrice int64 `json:"vendorPrice"` SalePrice int64 `json:"salePrice"` ActualPayPrice int64 `json:"actualPayPrice"` - EarningPrice int64 `json:"earningPrice"` // 预估结算给门店老板的钱 + EarningPrice int64 `json:"earningPrice"` // 预估结算给门店老板的钱 + DistanceFreightMoney int64 `json:"distanceFreightMoney"` // 商户承担的远距离配送费(当前只有京东到家有值) + WaybillTipMoney int64 `json:"waybillTipMoney"` // 京西加的平台配送小费 } type OrderSkuWithActualPayPrice struct { model.OrderSku - ActualPayPrice int64 `json:"actualPayPrice"` // 单位为分 顾客实际支付 + ActualPayPrice int64 `json:"actualPayPrice"` // 单位为分 顾客实际支付 + DistanceFreightMoney int64 `json:"distanceFreightMoney"` // 商户承担的远距离配送费(当前只有京东到家有值) + WaybillTipMoney int64 `json:"waybillTipMoney"` // 京西加的平台配送小费 StoreID int `orm:"column(store_id)" json:"storeID"` // 外部系统里记录的 jxstoreid Status int `json:"status"` // 参见OrderStatus*相关的常量定义 @@ -345,7 +350,7 @@ func GetStoreOrderSkuList(db *DaoDB, storeIDs []int, finishedAtBegin, finishedAt // order_finished_at sql := ` SELECT t1.*, - t2.actual_pay_price, t2.status, IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) store_id, + IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) store_id, t2.status, t2.actual_pay_price, t2.distance_freight_money, t2.waybill_tip_money, t3.pay_percentage FROM order_sku t1 JOIN goods_order t2 ON t2.vendor_order_id = t1.vendor_order_id AND t2.vendor_id = t1.vendor_id From b92cff33389e0e78b0dcd350bcd672d4b46b4377 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 8 Jan 2020 10:38:55 +0800 Subject: [PATCH 4/6] =?UTF-8?q?!token=E6=94=B9=E4=B8=BA7=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/auth2/auth2.go | 11 ++++++----- business/jxstore/cms/store_sku.go | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/business/auth2/auth2.go b/business/auth2/auth2.go index da46bbc13..b023acaed 100644 --- a/business/auth2/auth2.go +++ b/business/auth2/auth2.go @@ -157,7 +157,7 @@ func getFixedTokenName(token string) *AuthInfo { } func createAuthInfo(user IUser, authBindInfo *AuthBindEx) (authInfo *AuthInfo) { - token, tokenType := createToken(user) + token, tokenType := createToken(user, authBindInfo) expireDuration := DefTokenDuration authInfo = &AuthInfo{ AuthBindInfo: authBindInfo, @@ -378,9 +378,9 @@ func ClearUserToken(userID string) { ///////////// -func createToken(user IUser) (token string, tokenType int) { +func createToken(user IUser, authBindInfo *AuthBindEx) (token string, tokenType int) { userID := TokenUserEmpty - userName := TokenUserEmpty + userName := authBindInfo.AuthID tokenType = TokenTypeOnlyAuth if user != nil { userID = user.GetID() @@ -392,8 +392,9 @@ func createToken(user IUser) (token string, tokenType int) { TokenVer, userID, time.Now().Format("20060102-150405"), - userName, + authBindInfo.Type, utils.GetUUID(), + userName, }, TokenTypeSep), tokenType } @@ -404,7 +405,7 @@ func GetTokenType(token string) (tokenType int) { tokenType = TokenTypeNone if token != "" { tokenPartList := strings.Split(token, TokenTypeSep) - if (len(tokenPartList) == 1) || (len(tokenPartList) == 6 && tokenPartList[2] != TokenUserEmpty) { + if (len(tokenPartList) == 1) || (len(tokenPartList) >= 6 && tokenPartList[2] != TokenUserEmpty) { tokenType = TokenTypeNormal } else { tokenType = TokenTypeOnlyAuth diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 65bd5c91b..446bd9ab9 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -1037,7 +1037,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs } setStoreSkuBindStatus(skuBind, model.SyncFlagNewMask) dao.WrapAddIDCULDEntity(skuBind, userName) - globals.SugarLogger.Debug(utils.Format4Output(skuBind, false)) + // globals.SugarLogger.Debug(utils.Format4Output(skuBind, false)) if deletedSku := dao.GetDeletedStoreSkuBind(db, skuBind.StoreID, skuBind.SkuID); deletedSku == nil { if err = dao.CreateEntity(db, skuBind); err != nil { dao.Rollback(db) From 82eb16ba660ed9d63a2bccd215077a56bd6c3dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 8 Jan 2020 10:39:16 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=95=86=E5=93=81=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=85=B3=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 38 ++++++++++++------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index bbaeb71cf..8bf330d35 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2836,9 +2836,8 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync, taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { store := batchItemList[0].(*model.Store) var ( - skuBindInfos []*StoreSkuBindInfo - skuNameMap = make(map[int]int) - skuInfoMap = make(map[int][]*StoreSkuBindSkuInfo) + skuNameMap = make(map[int]int) + skuInfoMap = make(map[int][]*StoreSkuBindSkuInfo) ) for _, v := range skuList { var ( @@ -2879,23 +2878,19 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync, IsSale: 1, Skus: skuInfoMap[k], } - skuBindInfos = append(skuBindInfos, skuBindInfo) + retVal = []*StoreSkuBindInfo{skuBindInfo} } - tUpdate := &tUpdateStoresSkus{ - StoreID: store.ID, - SkuBindInfos: skuBindInfos, - } - retVal = []*tUpdateStoresSkus{tUpdate} return retVal, err } taskParallel := tasksch.NewParallelTask("根据skuID关注商品", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx, taskFunc, storeList) tasksch.HandleTask(taskParallel, task, true).Run() result1, _ = taskParallel.GetResult(0) case 2: + var skuBindInfos []*StoreSkuBindInfo for _, v := range result1 { - tUpdate := v.(*tUpdateStoresSkus) - UpdateStoresSkusByBind(ctx, tUpdate.SkuBindInfos, true, true) + skuBindInfos = append(skuBindInfos, v.(*StoreSkuBindInfo)) } + UpdateStoresSkusByBind(ctx, skuBindInfos, true, true) } return result, err } @@ -2950,7 +2945,6 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContin case 1: taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { store := batchItemList[0].(*model.Store) - var skuBindInfos []*StoreSkuBindInfo for k, v := range skuNameMap { var price int focusList, _ := dao.GetStoreSkuBindByNameID(db, store.ID, k, model.StoreSkuBindStatusNormal) @@ -2976,23 +2970,19 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContin IsFocus: 1, Skus: v, } - skuBindInfos = append(skuBindInfos, skuBindInfo) + retVal = []*StoreSkuBindInfo{skuBindInfo} } - tUpdate := &tUpdateStoresSkus{ - StoreID: store.ID, - SkuBindInfos: skuBindInfos, - } - retVal = []*tUpdateStoresSkus{tUpdate} return retVal, err } taskParallel := tasksch.NewParallelTask("根据skuID部分关注商品", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx, taskFunc, storeList) tasksch.HandleTask(taskParallel, task, true).Run() result1, _ = taskParallel.GetResult(0) case 2: + var skuBindInfos []*StoreSkuBindInfo for _, v := range result1 { - tUpdate := v.(*tUpdateStoresSkus) - UpdateStoresSkusByBind(ctx, tUpdate.SkuBindInfos, isAsync, isContinueWhenError) + skuBindInfos = append(skuBindInfos, v.(*StoreSkuBindInfo)) } + UpdateStoresSkusByBind(ctx, skuBindInfos, isAsync, isContinueWhenError) } return result, err } @@ -3009,12 +2999,12 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContin func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context) (err error) { db := dao.GetDB() + var skuBindInfoList []*StoreSkuBindInfo storeList, err := dao.GetStoreList(db, nil, nil, "") for _, v := range storeList { var ( - skuName []*model.SkuName - skuNameMap = make(map[int]int) - skuBindInfoList []*StoreSkuBindInfo + skuName []*model.SkuName + skuNameMap = make(map[int]int) ) sql := ` SELECT DISTINCT a.name_id id @@ -3065,8 +3055,8 @@ func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context) (err error } } } - UpdateStoresSkusByBind(ctx, skuBindInfoList, true, true) } + UpdateStoresSkusByBind(ctx, skuBindInfoList, true, true) return err } From a3e4503081c72bfc3268608619a05f70a7461ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 8 Jan 2020 10:42:34 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=A0=B9=E6=8D=AEskuid=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=85=B3=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/cms_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/cms_store_sku.go b/controllers/cms_store_sku.go index 916fe9fbf..dc1c5ae62 100644 --- a/controllers/cms_store_sku.go +++ b/controllers/cms_store_sku.go @@ -620,7 +620,7 @@ func (c *StoreSkuController) FocusStoreSkusBySku() { var skuIDList []int c.callFocusStoreSkusBySku(func(params *tStoreSkuFocusStoreSkusBySkuParams) (retVal interface{}, errCode string, err error) { if jxutils.Strings2Objs(params.SkuIDs, &skuIDList); err == nil { - // retVal, err = cms.FocusStoreSkusBySku(params.Ctx, skuIDList, params.IsAsync, params.IsContinueWhenError) + retVal, err = cms.FocusStoreSkusBySku(params.Ctx, skuIDList, params.IsAsync, params.IsContinueWhenError) } return retVal, "", err })