From ae5737f24341968a89a75b5f8e630c7e0f0fced1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 11 May 2020 09:36:35 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=AE=A2=E5=8D=95earningprice=E6=8B=86?= =?UTF-8?q?=E5=88=86=E6=96=B0=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 24 +++++------- business/model/dao/act.go | 55 +++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 8b72d0fc2..d7bdec088 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -341,7 +341,6 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao. return err } skumapper := storeSkuPriceAndWeight2Map(l) - var skuMultiCountMap = make(map[int][]*tSkuCountPrice) for _, v := range orderSkus { v.VendorOrderID = order.VendorOrderID v.VendorID = order.VendorID @@ -370,29 +369,26 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao. salePrice = 0 } v.EarningPrice = jxutils.CaculateSkuEarningPrice(v.ShopPrice, salePrice, storePayPercentage) - skuMultiCountMap[v.SkuID] = append(skuMultiCountMap[v.SkuID], &tSkuCountPrice{ - Count: v.Count, - SalePrice: v.SalePrice, - }) } // 直营店始终按比例结算,不考虑活动与结算表 if changePriceType != model.StoreChangePriceTypeManagedStore { updateSingleOrderEarningPrice(order, db) } - globals.SugarLogger.Debugf("skuMultiCountMap", utils.Format4Output(skuMultiCountMap, false)) //TODO 重复购买有活动且结算价大于0的商品需要拆分,第一个商品按结算价,后面的商品按shopprice 或者 saleprice, 2020-05-06 //TODO 京东美团的订单,做活动的商品之前就会拆分出来,所以只做更新,饿百暂时不管, 2020-05-07 + //TODO 不根据商品是否拆分,直接根据该商品做了活动,并且他的vendorPrice 和 salePrice 相等,就按新规则结算, 2020-05-11 if order.VendorID == model.VendorIDJD || order.VendorID == model.VendorIDMTWM { for _, v := range orderSkus { if v.EarningPrice > 0 { - if len(skuMultiCountMap[v.SkuID]) > 1 { - var price = 0 - for _, vv := range skuMultiCountMap[v.SkuID] { - if int(vv.SalePrice) > price { - price = int(vv.SalePrice) - } - } - if price == int(v.SalePrice) { + var storeID int + if order.StoreID == 0 { + storeID = order.JxStoreID + } else { + storeID = order.StoreID + } + result, err := dao.GetEffectiveActStoreSkuInfo2(db, 0, []int{order.VendorID}, []int{model.ActSkuSecKill, model.ActSkuDirectDown}, []int{storeID}, []int{v.SkuID}, order.OrderCreatedAt, order.OrderCreatedAt) + if len(result) > 0 && err == nil { + if v.VendorPrice == v.SalePrice { var earningPrice = 0 if v.ShopPrice < v.SalePrice { earningPrice = int(utils.Float64TwoInt64(math.Round(utils.Int2Float64(int(v.ShopPrice)) * utils.Int2Float64(storePayPercentage) / 100))) diff --git a/business/model/dao/act.go b/business/model/dao/act.go index 9a7d8a41c..ff5049cf4 100644 --- a/business/model/dao/act.go +++ b/business/model/dao/act.go @@ -419,6 +419,61 @@ func GetEffectiveActStoreSkuInfo(db *DaoDB, actID int, vendorIDs []int, actType return actStoreSkuList, err } +func GetEffectiveActStoreSkuInfo2(db *DaoDB, actID int, vendorIDs []int, actTypes []int, storeIDs, skuIDs []int, beginAt, endAt time.Time) (actStoreSkuList []*model.ActStoreSku2, err error) { + if utils.IsTimeZero(beginAt) { + return nil, fmt.Errorf("GeActStoreSkuInfo必须指定活动开始时间") + } + if utils.IsTimeZero(endAt) { + endAt = beginAt + } + sql := ` + SELECT + t1.type, + t2.*, + t3.actual_act_price, t3.sync_status, t3.vendor_price, t3.vendor_id + FROM act t1 + JOIN act_store_sku t2 ON t2.act_id = t1.id AND t2.deleted_at = ? + JOIN act_store_sku_map t3 ON t3.bind_id = t2.id AND t3.act_id = t1.id AND (t3.sync_status & ? = 0 OR t1.type = ?) + JOIN act_map t4 ON t4.act_id = t1.id AND t4.vendor_id = t3.vendor_id AND t4.deleted_at = ? AND (t4.sync_status & ? = 0 OR t1.type = ?) + WHERE t1.deleted_at = ? AND t1.status = ? AND NOT (t1.begin_at > ? OR t1.end_at < ?) AND t1.create_type = ?` + sqlParams := []interface{}{ + utils.DefaultTimeValue, + + model.SyncFlagNewMask, + model.ActSkuFake, + + utils.DefaultTimeValue, model.SyncFlagNewMask, model.ActSkuFake, + utils.DefaultTimeValue, model.ActStatusCreated, endAt, beginAt, model.ActCreateTypeAPI, + } + if len(vendorIDs) > 0 { + sql += " AND (t1.vendor_mask & ?) <> 0 AND t3.vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")" + sqlParams = append(sqlParams, model.GetVendorMask(vendorIDs...), vendorIDs) + } + if actID > 0 { + sql += " AND t1.id = ?" + sqlParams = append(sqlParams, actID) + } + if len(actTypes) > 0 { + sql += " AND t1.type IN (" + GenQuestionMarks(len(actTypes)) + ")" + sqlParams = append(sqlParams, actTypes) + } + if len(storeIDs) > 0 { + sql += " AND t2.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")" + sqlParams = append(sqlParams, storeIDs) + } + if len(skuIDs) > 0 { + sql += " AND t2.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")" + sqlParams = append(sqlParams, skuIDs) + } + if globals.IsStoreSkuAct { + sql += " AND t1.is_special = 0" + } + // globals.SugarLogger.Debug(sql) + // globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) + err = GetRows(db, &actStoreSkuList, sql, sqlParams...) + return actStoreSkuList, err +} + func UpdateActStatusByTime(db *DaoDB, refTime time.Time) (num int64, err error) { sql := ` UPDATE act t1 From 971cc8afa0746afafceb5b771477efbb8ecde1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 11 May 2020 10:19:21 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=93=B6=E8=B1=B9?= =?UTF-8?q?=E5=88=B0=E4=BA=AC=E8=A5=BF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index b9b36a168..a39fd5322 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -888,12 +888,15 @@ func (d *SyncErrResultLock) AppendData(syncErrResult SyncErrResult) { func (v *VendorSync) SyncStoreSkusFromYb(ctx *jxcontext.Context, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { var ( vendorID = model.VendorIDYB - db = dao.GetDB() ) - storeMapList, err := dao.GetStoresMapList2(db, []int{vendorID}, storeIDs, nil, model.StoreStatusAll, model.StoreIsSyncYes, "", false) - for _, v := range storeMapList { - hint, err = syncStoreSkusFromYb(ctx, v.StoreID, vendorID, v.VendorStoreID, isAsync, isContinueWhenError) - } + hint, err = v.LoopStoresMap(ctx, dao.GetDB(), fmt.Sprintf("同步银豹到京西:%v", storeIDs), isAsync, true, []int{vendorID}, storeIDs, + func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { + loopMapInfo := batchItemList[0].(*LoopStoreMapInfo) + for _, v := range loopMapInfo.StoreMapList { + hint, err = syncStoreSkusFromYb(ctx, v.StoreID, vendorID, v.VendorStoreID, isAsync, isContinueWhenError) + } + return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID) + }, isContinueWhenError) return hint, err } From 95af9fe84ee7ba5cd60963d4cf888d18a27c7a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 12 May 2020 11:01:05 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=B8=AD=E4=BD=8D=E4=BB=B7=E4=BD=8E?= =?UTF-8?q?=E4=BA=8E5=E5=9D=97=E7=9A=84=E4=B8=8D=E5=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 073f93ddf..ea24bab24 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2555,12 +2555,14 @@ func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int, isCountry } if len(priceReferList) > 0 { //TODO 高于中位价20%才刷, 2020-05-08 - if storeSku.UnitPrice > priceReferList[0].MidUnitPrice/payPercentage*120 { - skuBindInfo := &StoreSkuBindInfo{ - NameID: priceReferList[0].NameID, - UnitPrice: priceReferList[0].MidUnitPrice / payPercentage * 100, + if priceReferList[0].MidUnitPrice >= 500 { + if storeSku.UnitPrice > priceReferList[0].MidUnitPrice/payPercentage*120 { + skuBindInfo := &StoreSkuBindInfo{ + NameID: priceReferList[0].NameID, + UnitPrice: priceReferList[0].MidUnitPrice / payPercentage * 100, + } + skuBindInfos = append(skuBindInfos, skuBindInfo) } - skuBindInfos = append(skuBindInfos, skuBindInfo) } } } From a3beb2ceaf44f73921258282d14ee29bbc01f6c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 12 May 2020 11:01:28 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=B8=AD=E4=BD=8D=E4=BB=B7=E4=BD=8E?= =?UTF-8?q?=E4=BA=8E5=E5=9D=97=E7=9A=84=E4=B8=8D=E5=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index ea24bab24..19c55f3c0 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2559,7 +2559,7 @@ func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int, isCountry if storeSku.UnitPrice > priceReferList[0].MidUnitPrice/payPercentage*120 { skuBindInfo := &StoreSkuBindInfo{ NameID: priceReferList[0].NameID, - UnitPrice: priceReferList[0].MidUnitPrice / payPercentage * 100, + UnitPrice: priceReferList[0].MidUnitPrice / payPercentage * 120, } skuBindInfos = append(skuBindInfos, skuBindInfo) } From 39b1583f1fe5c049e818f3cf8cff121722efc369 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, 13 May 2020 13:55:16 +0800 Subject: [PATCH 5/6] =?UTF-8?q?getstroes=E5=A2=9E=E5=8A=A0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store.go | 4 ++++ controllers/cms_store.go | 1 + 2 files changed, 5 insertions(+) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 49fbe37b9..7a5084c4c 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -398,6 +398,10 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte sqlWhere += " AND t1.address LIKE ?" sqlWhereParams = append(sqlWhereParams, "%"+params["address"].(string)+"%") } + if params["marketManPhone"] != nil { + sqlWhere += " AND t1.marketManPhone = ?" + sqlWhereParams = append(sqlWhereParams, params["marketManPhone"].(string)) + } if params["tel"] != nil { sqlWhere += " AND (t1.tel1 LIKE ? OR t1.tel2 LIKE ?)" sqlWhereParams = append(sqlWhereParams, "%"+params["tel"].(string)+"%") diff --git a/controllers/cms_store.go b/controllers/cms_store.go index aef66e7a9..c2b7bc993 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -39,6 +39,7 @@ type StoreController struct { // @Param orderTimeTo query string false "订单创建结束时间" // @Param orderCountFrom query int false "订单量起始" // @Param orderCountTo query int false "订单量结束" +// @Param marketManPhone query string false "市场负责人电话" // @Param briefLevel query int false "返回信息精简模式" // @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" // @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" From 855089b37560be82ef79b26e55936a6693474ba4 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, 13 May 2020 14:05:12 +0800 Subject: [PATCH 6/6] =?UTF-8?q?getstroes=E5=A2=9E=E5=8A=A0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 7a5084c4c..9a7504f51 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -399,7 +399,7 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte sqlWhereParams = append(sqlWhereParams, "%"+params["address"].(string)+"%") } if params["marketManPhone"] != nil { - sqlWhere += " AND t1.marketManPhone = ?" + sqlWhere += " AND t1.market_man_phone = ?" sqlWhereParams = append(sqlWhereParams, params["marketManPhone"].(string)) } if params["tel"] != nil {