From e3eda17c0b4d8312b1c9e566776c9751e62fe09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 3 Jul 2020 17:41:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E6=B7=B7=E8=BD=AE=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/tempop/tempop.go | 49 ++++++++++++++++++++++--------- business/model/dao/store_sku.go | 4 ++- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/business/jxstore/tempop/tempop.go b/business/jxstore/tempop/tempop.go index 744aed916..007e837cf 100644 --- a/business/jxstore/tempop/tempop.go +++ b/business/jxstore/tempop/tempop.go @@ -1610,21 +1610,42 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) { // continue // } // } - - // type tStore struct { + db := dao.GetDB() + type tStore struct { + NameID int `orm:column(name_id)` + StoreID int `orm:column(store_id)` + } + var resultList []*tStore + stores, _ := dao.GetStoreList(db, nil, nil, nil, nil, "") + for _, v := range stores { + var resultList2 []*tStore + sql := ` + SELECT a.name_id,a.store_id FROM ( + SELECT DISTINCT a.unit_price,b.name_id,a.store_id from store_sku_bind a,sku b,store c + where a.sku_id = b.id + and c.id = a.store_id and c.deleted_at = '1970-01-01 00:00:00' + and a.store_id = ? + and a.deleted_at = '1970-01-01 00:00:00')a + GROUP BY 1,2 + HAVING count(a.unit_price) > 1 + ` + sqlParams := []interface{}{v.ID} + err = dao.GetRows(db, &resultList2, sql, sqlParams) + resultList = append(resultList, resultList2...) + } + fmt.Println("resultList", utils.Format4Output(resultList, false)) + // var skuBindInfos []*cms.StoreSkuBindInfo + // for _, v := range resultList { + // storeSkus, _ := dao.GetStoreSkusByNameIDs(db, []int{v.StoreID}, v.NameID) + // unitPirce := storeSkus[0].UnitPrice + // skuBindInfo := &cms.StoreSkuBindInfo{ + // StoreID: v.StoreID, + // NameID: v.NameID, + // UnitPrice: int(unitPirce), + // } + // skuBindInfos = append(skuBindInfos, skuBindInfo) // } - - // sql := ` - // SELECT count(a.unit_price) count,a.name_id,a.store_id FROM ( - // SELECT DISTINCT a.unit_price,b.name_id,a.store_id from store_sku_bind a,sku b,store c - // where a.sku_id = b.id - // and c.id = a.store_id and c.deleted_at = '1970-01-01 00:00:00' - // and a.store_id = ? - // and a.deleted_at = '1970-01-01 00:00:00')a - // GROUP BY 2,3 - // HAVING count(a.unit_price) > 1 - // ` - // sqlParams := []interface{}{} + // _, err = cms.UpdateStoresSkusByBind(ctx, nil, skuBindInfos, true, true, false) return err } diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index ebc1b5575..8993304df 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -997,7 +997,9 @@ func GetStoreSkusByNameIDs(db *DaoDB, storeIDs []int, nameID int) (skuList []*St sql += " AND a.store_id in (" + GenQuestionMarks(len(storeIDs)) + ")" sqlParams = append(sqlParams, storeIDs) } - sql += " AND a.status != ?" + sql += ` AND a.status != ? + ORDER BY a.created_at + ` sqlParams = append(sqlParams, model.SkuStatusDeleted) err = GetRows(db, &skuList, sql, sqlParams...) return skuList, err