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