Example #1
0
func (this *saleService) SaveCategory(merchantId int, v *sale.Category) (int, error) {
	sl := this._rep.GetSale(merchantId)
	var ca sale.ICategory
	if v.Id > 0 {
		ca = sl.CategoryManager().GetCategory(v.Id)
		if err := ca.SetValue(v); err != nil {
			return 0, err
		}
	} else {
		ca = sl.CategoryManager().CreateCategory(v)
	}

	return ca.Save()
}
Example #2
0
// 获取分页上架的商品
func (this *saleService) GetShopPagedOnShelvesGoods(merchantId, categoryId, start, end int,
	sortBy string) (total int, list []*valueobject.Goods) {
	var sl sale.ISale = this._rep.GetSale(merchantId)

	if categoryId > 0 {
		var cate sale.ICategory = sl.CategoryManager().GetCategory(categoryId)
		var ids []int = cate.GetChildes()
		ids = append(ids, categoryId)
		total, list = this._goodsRep.GetPagedOnShelvesGoods(merchantId, ids, start, end, "", sortBy)
	} else {
		total = -1
		list = sl.GoodsManager().GetOnShelvesGoods(start, end, sortBy)
	}
	for _, v := range list {
		v.Image = format.GetGoodsImageUrl(v.Image)
	}
	return total, list
}