From 754c190220e8e1affee7657865fd989195b6b434 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, 6 Jan 2020 10:13:31 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=AD=E4=BD=8D?= =?UTF-8?q?=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 5 ++++- business/model/dao/store_sku.go | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 0207aa87f..b2d210c07 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -261,6 +261,7 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool sql += ` JOIN store_sku_bind t4 ON t4.store_id = t3.id AND t4.sku_id = t2.id AND t4.deleted_at = ? LEFT JOIN sku_name_place_bind t5 ON t1.id = t5.name_id AND t3.city_code = t5.place_code + LEFT JOIN price_refer_snapshot t6 ON t6.city_code = t3.city_code AND t6.name_id = t1.id WHERE t1.deleted_at = ? AND (t1.is_global = 1 OR t5.id IS NOT NULL OR 1 = ?)/* AND t1.status = ?*/ ` sqlParams = append(sqlParams, []interface{}{ @@ -493,7 +494,9 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo t4.jd_sync_status, t4.ebai_sync_status, t4.mtwm_sync_status, t4.jd_price, t4.ebai_price, t4.mtwm_price, t4.jx_price, t4.jd_lock_time, t4.ebai_lock_time, t4.mtwm_lock_time, t4.jx_lock_time, - t4.status_sale_begin, t4.status_sale_end + t4.status_sale_begin, t4.status_sale_end, + t6.mid_unit_price real_mid_unit_price, + ROUND(t6.mid_unit_price * IF(t3.pay_percentage < 50,70,t3.pay_percentage) /100) mid_unit_price `, jdVendorIDField) + sql var tmpList []*tGetStoresSkusInfo beginTime := time.Now() diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index 55d7956ee..867fd4896 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -133,6 +133,8 @@ type StoreSkuNameExt struct { PendingOpType int8 `json:"pendingOpType"` // 取值同 StoreOpRequest.Type PendingUnitPrice int `json:"pendingUnitPrice"` // 这个是待审核的价格申请 Status int + RealMidUnitPrice int `json:"realMidUnitPrice"` + midUnitPrice int `json:"midUnitPrice"` } // GetStoreSkus用 From df6a0b1a1cd1ea599333a11db5b8da4a57520a60 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, 6 Jan 2020 10:46:51 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=AD=E4=BD=8D?= =?UTF-8?q?=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 14 +++++++------- business/model/dao/store.go | 2 +- business/model/dao/store_sku.go | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index b2d210c07..0585a757e 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -495,8 +495,7 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo t4.jd_price, t4.ebai_price, t4.mtwm_price, t4.jx_price, t4.jd_lock_time, t4.ebai_lock_time, t4.mtwm_lock_time, t4.jx_lock_time, t4.status_sale_begin, t4.status_sale_end, - t6.mid_unit_price real_mid_unit_price, - ROUND(t6.mid_unit_price * IF(t3.pay_percentage < 50,70,t3.pay_percentage) /100) mid_unit_price + t6.mid_unit_price real_mid_unit_price `, jdVendorIDField) + sql var tmpList []*tGetStoresSkusInfo beginTime := time.Now() @@ -515,11 +514,12 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo index := jxutils.Combine2Int(v.StoreID, v.ID) if isBySku || storeNameMap[index] == nil { storeName = &dao.StoreSkuNameExt{ - StoreID: v.StoreID, - StoreName: v.StoreName, - SkuName: v.SkuName, - UnitPrice: v.UnitPrice, - PayPercentage: v.PayPercentage, + StoreID: v.StoreID, + StoreName: v.StoreName, + SkuName: v.SkuName, + UnitPrice: v.UnitPrice, + PayPercentage: v.PayPercentage, + RealMidUnitPrice: v.RealMidUnitPrice, } if !isBySku { storeNameMap[index] = storeName diff --git a/business/model/dao/store.go b/business/model/dao/store.go index f3a3e62a5..56a713cb3 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -566,7 +566,7 @@ func GetStorePriceScore(db *DaoDB, storeIDs, vendorIDs []int, fromScore, toScore func GetStorePriceScoreSnapshot(db *DaoDB, snapDate time.Time) (storePriceScoreSnapshot []*model.StorePriceScoreSnapshot, err error) { sql := ` - SELECT c.store_id,ROUND(count(c.unit_price/IF(d.pay_percentage < 50 , 70, d.pay_percentage) <= a.mid_unit_price or NULL)/count(*)*100,2) score + SELECT c.store_id,ROUND(count(c.unit_price/IF(d.pay_percentage < 50 , 70, d.pay_percentage)*100 <= a.mid_unit_price or NULL)/count(*)*100,2) score FROM price_refer_snapshot a JOIN store_sku_bind c ON c.sku_id = a.sku_id AND c.status = ? AND c.deleted_at = ? JOIN store d ON c.store_id = d.id AND d.city_code = a.city_code AND d.deleted_at = ? AND d.status != ? diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index 867fd4896..c8614986d 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -134,7 +134,6 @@ type StoreSkuNameExt struct { PendingUnitPrice int `json:"pendingUnitPrice"` // 这个是待审核的价格申请 Status int RealMidUnitPrice int `json:"realMidUnitPrice"` - midUnitPrice int `json:"midUnitPrice"` } // GetStoreSkus用 @@ -159,8 +158,9 @@ type StoreSkuExt struct { BindLastOperator string `orm:"size(32)" json:"lastOperator"` // 最后操作员 BindDeletedAt time.Time `orm:"type(datetime)" json:"deletedAt"` SubStoreID int `orm:"column(sub_store_id)" json:"subStoreID"` - BindPrice int `json:"price"` // 单位为分,不用int64的原因是这里不需要累加 - UnitPrice int `json:"unitPrice"` // 这个是一斤的门店商品价,放在这里的原因是避免额外增加一张store sku_name表,逻辑上要保证同一SKU NAME中的所有SKU这个字段的数据一致 + BindPrice int `json:"price"` // 单位为分,不用int64的原因是这里不需要累加 + UnitPrice int `json:"unitPrice"` // 这个是一斤的门店商品价,放在这里的原因是避免额外增加一张store sku_name表,逻辑上要保证同一SKU NAME中的所有SKU这个字段的数据一致 + RealMidUnitPrice int `json:"realMidUnitPrice"` //真实的该商品的全国中位价 StoreSkuStatus int `json:"storeSkuStatus"` EbaiID string `orm:"column(ebai_id);index" json:"ebaiID"` From a5ea3ebd3db25a6487e9c023dc7c43445cc66cdb 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, 6 Jan 2020 10:51:54 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=AD=E4=BD=8D?= =?UTF-8?q?=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 0585a757e..3c6fb797e 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -261,13 +261,14 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool sql += ` JOIN store_sku_bind t4 ON t4.store_id = t3.id AND t4.sku_id = t2.id AND t4.deleted_at = ? LEFT JOIN sku_name_place_bind t5 ON t1.id = t5.name_id AND t3.city_code = t5.place_code - LEFT JOIN price_refer_snapshot t6 ON t6.city_code = t3.city_code AND t6.name_id = t1.id + LEFT JOIN price_refer_snapshot t6 ON t6.city_code = t3.city_code AND t6.name_id = t1.id AND snapshot_at = ? WHERE t1.deleted_at = ? AND (t1.is_global = 1 OR t5.id IS NOT NULL OR 1 = ?)/* AND t1.status = ?*/ ` sqlParams = append(sqlParams, []interface{}{ utils.DefaultTimeValue, utils.DefaultTimeValue, utils.Bool2Int(isFocus), + utils.Time2Date(time.Now().AddDate(0, 0, -1)), // model.SkuStatusNormal, }) if isFocus { From 3bd34ce8a5ef4fac27cd8447ae4806d11b4a85f6 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, 6 Jan 2020 11:08:16 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=AD=E4=BD=8D?= =?UTF-8?q?=E4=BB=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 3c6fb797e..e61501f11 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -266,9 +266,9 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool ` sqlParams = append(sqlParams, []interface{}{ utils.DefaultTimeValue, + utils.Time2Date(time.Now().AddDate(0, 0, -1)), utils.DefaultTimeValue, utils.Bool2Int(isFocus), - utils.Time2Date(time.Now().AddDate(0, 0, -1)), // model.SkuStatusNormal, }) if isFocus { From 6f0a3bc971c88d637657cfc391ae3029d9f3756a 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, 6 Jan 2020 11:11:37 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=AD=E4=BD=8D?= =?UTF-8?q?=E4=BB=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 e61501f11..34546a13b 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -261,7 +261,7 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool sql += ` JOIN store_sku_bind t4 ON t4.store_id = t3.id AND t4.sku_id = t2.id AND t4.deleted_at = ? LEFT JOIN sku_name_place_bind t5 ON t1.id = t5.name_id AND t3.city_code = t5.place_code - LEFT JOIN price_refer_snapshot t6 ON t6.city_code = t3.city_code AND t6.name_id = t1.id AND snapshot_at = ? + LEFT JOIN price_refer_snapshot t6 ON t6.city_code = t3.city_code AND t6.name_id = t1.id AND t6.snapshot_at = ? WHERE t1.deleted_at = ? AND (t1.is_global = 1 OR t5.id IS NOT NULL OR 1 = ?)/* AND t1.status = ?*/ ` sqlParams = append(sqlParams, []interface{}{ From 71ba2e13db272631bd5d28c795316ea0479671b5 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, 6 Jan 2020 11:27:01 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=AD=E4=BD=8D?= =?UTF-8?q?=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 3 ++- business/model/dao/store_sku.go | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 34546a13b..ebf34ea1f 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -114,6 +114,7 @@ type tGetStoresSkusInfo struct { model.SkuName PayPercentage int `json:"-"` dao.StoreSkuExt + RealMidUnitPrice int `json:"realMidUnitPrice"` //真实的该商品的全国中位价 } type SheetParam struct { @@ -261,7 +262,7 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool sql += ` JOIN store_sku_bind t4 ON t4.store_id = t3.id AND t4.sku_id = t2.id AND t4.deleted_at = ? LEFT JOIN sku_name_place_bind t5 ON t1.id = t5.name_id AND t3.city_code = t5.place_code - LEFT JOIN price_refer_snapshot t6 ON t6.city_code = t3.city_code AND t6.name_id = t1.id AND t6.snapshot_at = ? + JOIN price_refer_snapshot t6 ON t6.city_code = t3.city_code AND t6.sku_id = t2.id AND t6.snapshot_at = ? WHERE t1.deleted_at = ? AND (t1.is_global = 1 OR t5.id IS NOT NULL OR 1 = ?)/* AND t1.status = ?*/ ` sqlParams = append(sqlParams, []interface{}{ diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index c8614986d..aae0c28bf 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -158,9 +158,8 @@ type StoreSkuExt struct { BindLastOperator string `orm:"size(32)" json:"lastOperator"` // 最后操作员 BindDeletedAt time.Time `orm:"type(datetime)" json:"deletedAt"` SubStoreID int `orm:"column(sub_store_id)" json:"subStoreID"` - BindPrice int `json:"price"` // 单位为分,不用int64的原因是这里不需要累加 - UnitPrice int `json:"unitPrice"` // 这个是一斤的门店商品价,放在这里的原因是避免额外增加一张store sku_name表,逻辑上要保证同一SKU NAME中的所有SKU这个字段的数据一致 - RealMidUnitPrice int `json:"realMidUnitPrice"` //真实的该商品的全国中位价 + BindPrice int `json:"price"` // 单位为分,不用int64的原因是这里不需要累加 + UnitPrice int `json:"unitPrice"` // 这个是一斤的门店商品价,放在这里的原因是避免额外增加一张store sku_name表,逻辑上要保证同一SKU NAME中的所有SKU这个字段的数据一致 StoreSkuStatus int `json:"storeSkuStatus"` EbaiID string `orm:"column(ebai_id);index" json:"ebaiID"` From ff0a3b3a0243e871a235e0f7f948b351424b9c26 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, 6 Jan 2020 14:26:00 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=AD=E4=BD=8D?= =?UTF-8?q?=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 2 +- business/jxstore/report/report.go | 37 +++++++++++++++++++++++++++++-- business/model/dao/report.go | 26 +++++++++++++++++----- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index ebf34ea1f..f44c3e467 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -262,7 +262,7 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool sql += ` JOIN store_sku_bind t4 ON t4.store_id = t3.id AND t4.sku_id = t2.id AND t4.deleted_at = ? LEFT JOIN sku_name_place_bind t5 ON t1.id = t5.name_id AND t3.city_code = t5.place_code - JOIN price_refer_snapshot t6 ON t6.city_code = t3.city_code AND t6.sku_id = t2.id AND t6.snapshot_at = ? + LEFT JOIN price_refer_snapshot t6 ON t6.city_code = 0 AND t6.sku_id = t2.id AND t6.snapshot_at = ? WHERE t1.deleted_at = ? AND (t1.is_global = 1 OR t5.id IS NOT NULL OR 1 = ?)/* AND t1.status = ?*/ ` sqlParams = append(sqlParams, []interface{}{ diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index 997dcce74..e2b9b8f78 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -97,8 +97,10 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn case 1: priceReferSnapshotList, err = dao.GetPriceReferSnapshotNoPage(db, nil, nil, nil, snapshotAt) var ( - citySkuMap = make(map[int]map[int][]int) - resultMap = make(map[int]map[int]*model.PriceReferSnapshot) + citySkuMap = make(map[int]map[int][]int) + countryMap = make(map[int][]int) + resultMap = make(map[int]map[int]*model.PriceReferSnapshot) + resultCountryMap = make(map[int]*model.PriceReferSnapshot) ) storeList, err := dao.GetStoreList(db, nil, nil, "") if err != nil { @@ -145,6 +147,7 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn if len(tList) > 0 { for _, vv := range tList { skuNameMap[vv.NameID] = append(skuNameMap[vv.NameID], vv.UnitPrice) + countryMap[vv.NameID] = append(countryMap[vv.NameID], vv.UnitPrice) } if citySkuMap[v.CityCode] != nil { for nameID, unitPriceList := range skuNameMap { @@ -159,6 +162,26 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn } } } + for k, v := range countryMap { + var midUnitPrice int + var avgUnitPrice int + sort.Ints(v) + if len(v)%2 == 0 { + midUnitPrice = v[len(v)/2-1] + } else { + midUnitPrice = v[len(v)/2] + } + for _, vv := range v { + avgUnitPrice += vv + } + priceRefer := &model.PriceReferSnapshot{ + MidUnitPrice: midUnitPrice, + MaxUnitPrice: v[len(v)-1], + MinUnitPrice: v[0], + AvgUnitPrice: avgUnitPrice / len(v), + } + resultCountryMap[k] = priceRefer + } for k1, v := range citySkuMap { skuNameMap := make(map[int]*model.PriceReferSnapshot) for k2, _ := range v { @@ -193,6 +216,16 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn }() if len(priceReferSnapshotList) > 0 { for _, v := range priceReferSnapshotList { + if v.CityCode == 0 { + if resultCountryMap[v.NameID] != nil { + v.MidUnitPrice = resultCountryMap[v.NameID].MidUnitPrice + v.MaxUnitPrice = resultCountryMap[v.NameID].MaxUnitPrice + v.AvgUnitPrice = resultCountryMap[v.NameID].AvgUnitPrice + v.MinUnitPrice = resultCountryMap[v.NameID].MinUnitPrice + dao.UpdateEntity(db, v, "MidUnitPrice", "MaxUnitPrice", "MinUnitPrice", "AvgUnitPrice") + } + continue + } if resultMap[v.CityCode][v.NameID] != nil { v.MidUnitPrice = resultMap[v.CityCode][v.NameID].MidUnitPrice v.MaxUnitPrice = resultMap[v.CityCode][v.NameID].MaxUnitPrice diff --git a/business/model/dao/report.go b/business/model/dao/report.go index e65873b69..1d47e3c70 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -189,8 +189,11 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time } func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapshot []*model.PriceReferSnapshot, err error) { - sql := ` - SELECT b.city_code,a.sku_id,c.name_id, + var sql string + sql1 := ` + SELECT a.sku_id, c.name_id, + ` + sql2 := ` MAX(a.jd_price) max_jd_price, MIN(a.jd_price) min_jd_price, ROUND(AVG(a.jd_price)) avg_jd_price, @@ -220,6 +223,7 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p )t1 ON t1.sku_id = a.sku_id WHERE a.deleted_at = ? ` + sql = sql1 + "b.city_code, " + sql2 sqlParams := []interface{}{ utils.DefaultTimeValue, model.StoreStatusDisabled, @@ -234,7 +238,19 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p sql += " AND b.city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")" sqlParams = append(sqlParams, cityCodes) } - sql += " GROUP BY 1,2,3" + sql += ` GROUP BY 1,2,3 + UNION ` + sql += sql1 + "0 city_code," + sql2 + if len(skuIDs) > 0 { + sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")" + sqlParams = append(sqlParams, skuIDs) + } + if len(cityCodes) > 0 { + sql += " AND b.city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")" + sqlParams = append(sqlParams, cityCodes) + } + sql += " GROUP BY 1,2" + sqlParams = append(sqlParams, sqlParams...) if err = GetRows(db, &priceReferSnapshot, sql, sqlParams...); err == nil { return priceReferSnapshot, nil } @@ -243,9 +259,9 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int, skuNameID int, snapDate time.Time, offset, pageSize int) (priceReferSnapshot []*PriceReferSnapshotExt, totalCount int, err error) { sql := ` - SELECT SQL_CALC_FOUND_ROWS a.*,b.name city_name + SELECT SQL_CALC_FOUND_ROWS a.*,IF(a.city_code = 0,'全国',b.name) city_name FROM price_refer_snapshot a - JOIN place b ON a.city_code = b.code + LEFT JOIN place b ON a.city_code = b.code WHERE 1=1 AND a.deleted_at = ? ` From f869a8e065617ff4566baaed4b67ad14a9bb4896 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, 6 Jan 2020 15:42:47 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E5=B7=AE=E8=AF=84=E9=80=80=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 16 ++++++-- business/model/dao/dao_order.go | 59 +++++++++++++++++++++++++-- business/model/order.go | 2 +- controllers/jx_order.go | 8 ++-- 4 files changed, 72 insertions(+), 13 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 696dbc0e2..1ca9f8344 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -752,7 +752,7 @@ func RefreshOrdersWithoutJxStoreID(ctx *jxcontext.Context, fromDate, toDate stri return hint, err } -func GetOrdersSupplement(ctx *jxcontext.Context, storIDs, vendorIDs []int, vendorOrderID, fromTime, toTime string, status, stype, IsReverse, offset, pageSize int) (pageInfo *model.PagedInfo, err error) { +func GetOrdersSupplement(ctx *jxcontext.Context, storIDs, vendorIDs, statuss []int, vendorOrderID, fromTime, toTime string, stype, IsReverse, offset, pageSize int) (pageInfo *model.PagedInfo, err error) { var ( db = dao.GetDB() fromTimeP time.Time @@ -767,7 +767,7 @@ func GetOrdersSupplement(ctx *jxcontext.Context, storIDs, vendorIDs []int, vendo if fromTimeP.After(toTimeP) { return nil, fmt.Errorf("时间范围不合法!开始时间:[%v],结束时间:[%v]", fromTimeP, toTimeP) } - result, totalCount, err := dao.GetOrdersSupplement(db, storIDs, vendorIDs, vendorOrderID, fromTimeP, toTimeP, status, stype, IsReverse, offset, pageSize) + result, totalCount, err := dao.GetOrdersSupplement(db, storIDs, vendorIDs, statuss, vendorOrderID, fromTimeP, toTimeP, stype, IsReverse, offset, pageSize) pageInfo = &model.PagedInfo{ Data: result, TotalCount: totalCount, @@ -781,6 +781,9 @@ func AddUpdateOrdersSupplement(ctx *jxcontext.Context, ordersSupplement *model.O id = ordersSupplement.ID ) now := time.Now() + if *ordersSupplement.VendorID == -1 { + ordersSupplement.VendorID = nil + } ordersSupplement.SupplementTime = &now defer func() { if r := recover(); r != nil || err != nil { @@ -791,11 +794,16 @@ func AddUpdateOrdersSupplement(ctx *jxcontext.Context, ordersSupplement *model.O } }() if id > 0 { - if ordersSupplement.Status == 1 { - return 0, fmt.Errorf("已结账的扣款信息不允许修改!门店ID:[%v],订单号:[%v]", ordersSupplement.StoreID, ordersSupplement.VendorOrderID) + orderSupplementFee, _ := dao.GetOrdersSupplementNoPage(db, id, nil, nil, nil, "", utils.ZeroTimeValue, utils.ZeroTimeValue, 0, 0) + if len(orderSupplementFee) > 2 || len(orderSupplementFee) == 0 { + return 0, fmt.Errorf("查询扣款记录有误,请联系技术部!") + } + if orderSupplementFee[0].Status == 1 { + return 0, fmt.Errorf("已结账的扣款信息不允许修改!门店ID:[%v],订单号:[%v]", ordersSupplement.StoreID, *ordersSupplement.VendorOrderID) } ordersSupplement.UpdatedAt = time.Now() ordersSupplement.LastOperator = ctx.GetUserName() + ordersSupplement.CreatedAt = orderSupplementFee[0].CreatedAt if ordersSupplement.Status == -1 { ordersSupplement.DeletedAt = time.Now() } else { diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 321ca7d9a..6a6b0e0e9 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -1053,7 +1053,7 @@ func GetWayBillByOrderID(db *DaoDB, orderStatus, vendorID, waybillVendorID int, return wayBillList, err } -func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID string, fromTime, toTime time.Time, status, stype, IsReverse, offset, pageSize int) (orderSupplementFee []*model.OrderSupplementFee, totalCount int, err error) { +func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs, statuss []int, vendorOrderID string, fromTime, toTime time.Time, stype, IsReverse, offset, pageSize int) (orderSupplementFee []*model.OrderSupplementFee, totalCount int, err error) { sql := ` SELECT SQL_CALC_FOUND_ROWS * FROM order_supplement_fee @@ -1083,9 +1083,9 @@ func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID stri sql += " AND vendor_order_id = ?" sqlParams = append(sqlParams, vendorOrderID) } - if status >= 0 { - sql += " AND status = ?" - sqlParams = append(sqlParams, status) + if len(statuss) > 0 { + sql += " AND status IN (" + GenQuestionMarks(len(vendorIDs)) + ")" + sqlParams = append(sqlParams, statuss) } if stype > 0 { sql += " AND type = ?" @@ -1106,3 +1106,54 @@ func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID stri } return orderSupplementFee, totalCount, err } + +func GetOrdersSupplementNoPage(db *DaoDB, ID int, storIDs, vendorIDs, statuss []int, vendorOrderID string, fromTime, toTime time.Time, stype, IsReverse int) (orderSupplementFee []*model.OrderSupplementFee, err error) { + sql := ` + SELECT * + FROM order_supplement_fee + WHERE 1=1 + AND deleted_at = ? + ` + sqlParams := []interface{}{ + utils.DefaultTimeValue, + } + if !utils.IsTimeZero(fromTime) { + sql += " AND supplement_time >= ?" + sqlParams = append(sqlParams, fromTime) + } + if !utils.IsTimeZero(toTime) { + sql += " AND supplement_time <= ?" + sqlParams = append(sqlParams, toTime) + } + if len(storIDs) > 0 { + sql += " AND store_id IN (" + GenQuestionMarks(len(storIDs)) + ")" + sqlParams = append(sqlParams, storIDs) + } + if len(vendorIDs) > 0 { + sql += " AND vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")" + sqlParams = append(sqlParams, vendorIDs) + } + if vendorOrderID != "" { + sql += " AND vendor_order_id = ?" + sqlParams = append(sqlParams, vendorOrderID) + } + if len(statuss) > 0 { + sql += " AND status IN (" + GenQuestionMarks(len(vendorIDs)) + ")" + sqlParams = append(sqlParams, statuss) + } + if stype > 0 { + sql += " AND type = ?" + sqlParams = append(sqlParams, stype) + } + if ID > 0 { + sql += " AND id = ?" + sqlParams = append(sqlParams, ID) + } + if IsReverse == -1 { + sql += " AND link_id = 0" + } else if IsReverse == 1 { + sql += " AND link_id <> 0" + } + err = GetRows(db, &orderSupplementFee, sql, sqlParams...) + return orderSupplementFee, err +} diff --git a/business/model/order.go b/business/model/order.go index 0b1428818..c4a7fd214 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -348,7 +348,7 @@ type OrderSupplementFee struct { ModelIDCULD StoreID int `orm:"column(store_id)" json:"storeID"` VendorOrderID *string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` - VendorID *string `orm:"column(vendor_id)" json:"vendorID"` + VendorID *int `orm:"column(vendor_id);null" json:"vendorID"` Status int `json:"status"` //账单状态,若已结账则不允许再修改 ,暂时 0为未结账,1为已结账,-1为作废 LinkID int `orm:"column(link_id)" json:"linkID"` //作为冲账标志关联某条扣款记录 SupplementTime *time.Time `orm:"type(datetime);null" json:"supplementTime"` diff --git a/controllers/jx_order.go b/controllers/jx_order.go index e9372bfab..c0f3a7bb6 100644 --- a/controllers/jx_order.go +++ b/controllers/jx_order.go @@ -934,7 +934,7 @@ func (c *OrderController) ComplaintRider() { // @Param vendorIDs query string false "订单所属厂商ID列表" // @Param fromTime query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" // @Param toTime query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" -// @Param status query int false "账单状态,0是未结账,1是已结账" +// @Param statuss query string false "账单状态列表,0是未结账,1是已结账,-1为作废" // @Param type query int false "扣款类型,1为差评补贴,2为优惠券" // @Param isReverse query int false "只查冲账记录,0为默认都查,1为只查冲账,-1为不查冲账" // @Param offset query int false "结果起始序号(以0开始,缺省为0)" @@ -943,10 +943,10 @@ func (c *OrderController) ComplaintRider() { // @Failure 200 {object} controllers.CallResult // @router /GetOrdersSupplement [get] func (c *OrderController) GetOrdersSupplement() { - var vendorIDList, storeIDList []int + var vendorIDList, storeIDList, statusList []int c.callGetOrdersSupplement(func(params *tOrderGetOrdersSupplementParams) (retVal interface{}, errCode string, err error) { - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil { - retVal, err = orderman.GetOrdersSupplement(params.Ctx, storeIDList, vendorIDList, params.VendorOrderID, params.FromTime, params.ToTime, params.Status, params.Type, params.IsReverse, params.Offset, params.PageSize) + if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList, params.Statuss, statusList); err == nil { + retVal, err = orderman.GetOrdersSupplement(params.Ctx, storeIDList, vendorIDList, statusList, params.VendorOrderID, params.FromTime, params.ToTime, params.Type, params.IsReverse, params.Offset, params.PageSize) } return retVal, "", err }) From e0991f8609a7034dfeee62cf679720e6577c8731 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, 6 Jan 2020 16:37:36 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E7=95=85=E9=94=80=E5=93=81=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 15 +++------------ business/model/dao/store_sku.go | 11 ++++++----- business/model/store.go | 2 +- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index f44c3e467..adf9a61ee 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2220,17 +2220,6 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam WHERE a.deleted_at = ? AND a.store_id = ? AND a.status = ?) - UNION - SELECT DISTINCT a.name_id id,0 brand_id - FROM sku a - LEFT JOIN (SELECT DISTINCT b.name_id - FROM store_sku_bind a - JOIN sku b ON a.sku_id = b.id - WHERE a.deleted_at = ? - AND store_id = ?)b ON a.name_id = b.name_id - WHERE a.status = ? - AND a.deleted_at = ? - AND b.name_id IS NULL ` sqlParams := []interface{}{ utils.DefaultTimeValue, @@ -2253,11 +2242,13 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam } for _, v := range skuNameAndPlace { if skuNameMap[v.ID] != nil { - priceReferList, _, _ := dao.GetPriceReferSnapshot(db, []int{cityCode}, nil, v.ID, utils.Time2Date(time.Now().AddDate(0, 0, -1)), 0, 9999) + priceReferList, _ := dao.GetPriceReferSnapshotNoPage(db, []int{cityCode}, nil, []int{v.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1))) if len(priceReferList) > 0 { v.Price = priceReferList[0].MidUnitPrice } v.Type = skuNameMap[v.ID].BrandID + skuList, _ := dao.GetSkus(db, nil, []int{v.ID}, nil, nil) + v.Skus = skuList skuNameAndPlaceList = append(skuNameAndPlaceList, v) } } diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index aae0c28bf..fdb96a4d8 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -202,11 +202,12 @@ type StoreSkuExt struct { type SkuNameAndPlace struct { model.SkuName - CityCode int `json:"cityCode"` - CityName string `json:"cityName"` - Sequence int `json:"sequence"` - Count int `json:"count"` - Type int `json:"type"` + CityCode int `json:"cityCode"` + CityName string `json:"cityName"` + Sequence int `json:"sequence"` + Count int `json:"count"` + Type int `json:"type"` + Skus []*model.SkuAndName `json:"skus"` } type StoreSkuPriceAndWeight struct { diff --git a/business/model/store.go b/business/model/store.go index 553f564b9..26ade2838 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -475,7 +475,7 @@ type PriceReferSnapshot struct { func (*PriceReferSnapshot) TableUnique() [][]string { return [][]string{ - []string{"CityCode", "SkuID", "SnapshotAt"}, + []string{"CityCode", "NameID", "SkuID", "SnapshotAt"}, } } From 14b45ee2779e06428c7560341244a9854472e998 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, 6 Jan 2020 16:51:05 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E7=95=85=E9=94=80=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index adf9a61ee..a3c597c8f 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2230,10 +2230,6 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam utils.DefaultTimeValue, storeID, model.StoreSkuBindStatusNormal, - utils.DefaultTimeValue, - storeID, - model.StoreSkuBindStatusNormal, - utils.DefaultTimeValue, } err = dao.GetRows(db, &skuNameList, sql, sqlParams...) var skuNameMap = make(map[int]*model.SkuName) From 103bce68baa4c278a403c35b9d2601900748b928 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, 6 Jan 2020 18:25:14 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E5=B7=AE=E8=AF=84=E8=A1=A5=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 2 +- business/jxstore/cms/store_sku.go | 86 +++++++++++++++++++++++++-- business/model/dao/dao_order.go | 7 +-- business/model/order.go | 2 +- controllers/jx_order.go | 2 +- 5 files changed, 88 insertions(+), 11 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 1ca9f8344..b1de96c8c 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -799,7 +799,7 @@ func AddUpdateOrdersSupplement(ctx *jxcontext.Context, ordersSupplement *model.O return 0, fmt.Errorf("查询扣款记录有误,请联系技术部!") } if orderSupplementFee[0].Status == 1 { - return 0, fmt.Errorf("已结账的扣款信息不允许修改!门店ID:[%v],订单号:[%v]", ordersSupplement.StoreID, *ordersSupplement.VendorOrderID) + return 0, fmt.Errorf("已结账的扣款信息不允许修改!门店ID:[%v],订单号:[%v]", ordersSupplement.StoreID, ordersSupplement.VendorOrderID) } ordersSupplement.UpdatedAt = time.Now() ordersSupplement.LastOperator = ctx.GetUserName() diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index a3c597c8f..65bd5c91b 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2219,7 +2219,7 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam JOIN sku b ON a.sku_id = b.id AND b.deleted_at = ? WHERE a.deleted_at = ? AND a.store_id = ? - AND a.status = ?) + AND a.status = ?) ` sqlParams := []interface{}{ utils.DefaultTimeValue, @@ -2236,11 +2236,21 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam for _, v := range skuNameList { skuNameMap[v.ID] = v } + store, err := dao.GetStoreDetail(db, storeID, -1) + if err != nil { + return nil, err + } + var payPercentage int + if store.PayPercentage < 50 { + payPercentage = 70 + } else { + payPercentage = store.PayPercentage + } for _, v := range skuNameAndPlace { if skuNameMap[v.ID] != nil { priceReferList, _ := dao.GetPriceReferSnapshotNoPage(db, []int{cityCode}, nil, []int{v.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1))) if len(priceReferList) > 0 { - v.Price = priceReferList[0].MidUnitPrice + v.Price = priceReferList[0].MidUnitPrice * payPercentage / 100 } v.Type = skuNameMap[v.ID].BrandID skuList, _ := dao.GetSkus(db, nil, []int{v.ID}, nil, nil) @@ -2947,9 +2957,15 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContin if len(focusList) > 0 { price = focusList[0].UnitPrice } else { - priceReferList, _, _ := dao.GetPriceReferSnapshot(db, []int{store.CityCode}, nil, k, utils.Time2Date(time.Now().AddDate(0, 0, -1)), 0, 9999) + var payPercentage int + if store.PayPercentage < 50 { + payPercentage = 70 + } else { + payPercentage = store.PayPercentage + } + priceReferList, _ := dao.GetPriceReferSnapshotNoPage(db, []int{store.CityCode}, nil, []int{k}, utils.Time2Date(time.Now().AddDate(0, 0, -1))) if len(priceReferList) > 0 { - price = priceReferList[0].MidUnitPrice + price = priceReferList[0].MidUnitPrice * payPercentage / 100 } } skuBindInfo := &StoreSkuBindInfo{ @@ -2989,6 +3005,68 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContin return hint, err } +func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context) (err error) { + db := dao.GetDB() + storeList, err := dao.GetStoreList(db, nil, nil, "") + for _, v := range storeList { + var ( + skuName []*model.SkuName + skuNameMap = make(map[int]int) + skuBindInfoList []*StoreSkuBindInfo + ) + sql := ` + SELECT DISTINCT a.name_id id + FROM sku a + LEFT JOIN (SELECT DISTINCT b.name_id + FROM store_sku_bind a + JOIN sku b ON a.sku_id = b.id + WHERE a.deleted_at = ? + AND store_id = ?)b ON a.name_id = b.name_id + WHERE a.status = ? + AND a.deleted_at = ? + AND b.name_id IS NULL + ` + sqlParams := []interface{}{ + utils.DefaultTimeValue, + v.ID, + model.SkuStatusNormal, + utils.DefaultTimeValue, + } + err = dao.GetRows(db, &skuName, sql, sqlParams...) + for _, v := range skuName { + skuNameMap[v.ID] = v.ID + } + skuNameAndPlaceList, err2 := GetTopSkusByCityCode(ctx, v.CityCode, v.ID) + if err2 != nil { + return err2 + } + var payPercentage int + if v.PayPercentage < 50 { + payPercentage = 70 + } else { + 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))) + if err == nil && len(priceReferList) > 0 { + storeSkuBindInfo := &StoreSkuBindInfo{ + NameID: v.ID, + UnitPrice: priceReferList[0].MidUnitPrice * payPercentage / 100, + IsFocus: 1, + IsSale: 0, + } + skuBindInfoList = append(skuBindInfoList, storeSkuBindInfo) + } + } + } + } + UpdateStoreSkus(ctx, v.ID, skuBindInfoList, true, true) + } + return err +} + func AutoFocusStoreSkusWithoutFocus(ctx *jxcontext.Context, skuIDs []int, isSync bool) (err error) { var ( nameMap = make(map[int]*StoreSkuBindInfo) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 6a6b0e0e9..7339adfef 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -1084,7 +1084,7 @@ func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs, statuss []int, vendorOrd sqlParams = append(sqlParams, vendorOrderID) } if len(statuss) > 0 { - sql += " AND status IN (" + GenQuestionMarks(len(vendorIDs)) + ")" + sql += " AND status IN (" + GenQuestionMarks(len(statuss)) + ")" sqlParams = append(sqlParams, statuss) } if stype > 0 { @@ -1096,8 +1096,7 @@ func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs, statuss []int, vendorOrd } else if IsReverse == 1 { sql += " AND link_id <> 0" } - sql += ` - LIMIT ? OFFSET ?` + sql += " LIMIT ? OFFSET ?" sqlParams = append(sqlParams, pageSize, offset) Begin(db) defer Commit(db) @@ -1138,7 +1137,7 @@ func GetOrdersSupplementNoPage(db *DaoDB, ID int, storIDs, vendorIDs, statuss [] sqlParams = append(sqlParams, vendorOrderID) } if len(statuss) > 0 { - sql += " AND status IN (" + GenQuestionMarks(len(vendorIDs)) + ")" + sql += " AND status IN (" + GenQuestionMarks(len(statuss)) + ")" sqlParams = append(sqlParams, statuss) } if stype > 0 { diff --git a/business/model/order.go b/business/model/order.go index c4a7fd214..71c300506 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -347,7 +347,7 @@ type OrderPayRefund struct { type OrderSupplementFee struct { ModelIDCULD StoreID int `orm:"column(store_id)" json:"storeID"` - VendorOrderID *string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` + VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` VendorID *int `orm:"column(vendor_id);null" json:"vendorID"` Status int `json:"status"` //账单状态,若已结账则不允许再修改 ,暂时 0为未结账,1为已结账,-1为作废 LinkID int `orm:"column(link_id)" json:"linkID"` //作为冲账标志关联某条扣款记录 diff --git a/controllers/jx_order.go b/controllers/jx_order.go index c0f3a7bb6..dffe0768f 100644 --- a/controllers/jx_order.go +++ b/controllers/jx_order.go @@ -945,7 +945,7 @@ func (c *OrderController) ComplaintRider() { func (c *OrderController) GetOrdersSupplement() { var vendorIDList, storeIDList, statusList []int c.callGetOrdersSupplement(func(params *tOrderGetOrdersSupplementParams) (retVal interface{}, errCode string, err error) { - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList, params.Statuss, statusList); err == nil { + if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList, params.Statuss, &statusList); err == nil { retVal, err = orderman.GetOrdersSupplement(params.Ctx, storeIDList, vendorIDList, statusList, params.VendorOrderID, params.FromTime, params.ToTime, params.Type, params.IsReverse, params.Offset, params.PageSize) } return retVal, "", err From 33f2e2b74d92f8f372087c5ccf819da0671cd9be 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, 7 Jan 2020 08:26:13 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E5=B7=AE=E8=AF=84=E6=89=A3=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index b1de96c8c..7a1316965 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -781,9 +781,6 @@ func AddUpdateOrdersSupplement(ctx *jxcontext.Context, ordersSupplement *model.O id = ordersSupplement.ID ) now := time.Now() - if *ordersSupplement.VendorID == -1 { - ordersSupplement.VendorID = nil - } ordersSupplement.SupplementTime = &now defer func() { if r := recover(); r != nil || err != nil { From c19143696831de3434687293acd5e69efa40cc1d 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, 7 Jan 2020 09:02:35 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=AA=8C=E8=AF=81token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/cms_store_sku.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/cms_store_sku.go b/controllers/cms_store_sku.go index 9f6adbf28..9ad689e1c 100644 --- a/controllers/cms_store_sku.go +++ b/controllers/cms_store_sku.go @@ -467,7 +467,7 @@ func (c *StoreSkuController) GetMissingStoreSkuFromOrder() { // @Title 根据门店信息查找推荐商品(按销量) // @Description 根据门店信息查找推荐商品(按销量) -// @Param token header string true "认证token" +// @Param token header string false "认证token" // @Param storeIDs query string true "门店列表" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult @@ -499,7 +499,7 @@ func (c *StoreSkuController) GetTopSkusByCityCode() { // @Title 根据门店信息查找推荐分类(按商品销量) // @Description 根据门店信息查找推荐分类(按商品销量) -// @Param token header string true "认证token" +// @Param token header string false "认证token" // @Param storeIDs query string true "门店列表" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult