修改商品价格混轮的

This commit is contained in:
苏尹岚
2020-07-03 17:41:53 +08:00
parent 694f61c6ce
commit e3eda17c0b
2 changed files with 38 additions and 15 deletions

View File

@@ -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
}

View File

@@ -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