Ejemplo n.º 1
0
// Query product
func (p *Suggest) Onproduct() *exit.Exit {
	var query = strings.TrimSpace(p.Query)
	if query == "" {
		return exit.Json("{service:'no suggestions'}")
	}

	// search
	suggest.EnsureLoaded()
	items, err := suggest.Lookup(query, suggest.Product)
	if err != nil {
		return exit.Error(err)
	}

	// translate
	sj := &ProductSuggestions{Query: query}
	sj.Suggestions = make([]ProductSuggestionItem, len(items))
	for idx, item := range items {
		sj.Suggestions[idx] = ProductSuggestionItem{
			Id:          item.Id,
			ProductId:   item.SN,
			Name:        item.Text,
			QueryString: item.QuickString,
			// Data: fmt.Sprint(item.Id),
			// Value: item.QuickString + "||" + item.Text,
		}
	}

	return exit.MarshalJson(sj)
}
Ejemplo n.º 2
0
func (p *Suggest) Setup() *exit.Exit {
	if strings.TrimSpace(p.Query) == "" {
		return exit.Json("{service:'/service'}")
	}
	suggest.EnsureLoaded()

	// search
	items, err := suggest.Lookup(p.Query, p.Type)
	if err != nil {
		return exit.Error(err)
	}
	// translate
	sj := &SuggestJson{Query: p.Query}
	sj.Suggestions = make([]SuggestionJsonItem, len(items))
	for idx, item := range items {
		// fmt.Println("item.SN:", item.Id, item.SN)
		sj.Suggestions[idx] = SuggestionJsonItem{
			Value: item.QuickString + "||" + item.Text,
			Data:  fmt.Sprint(item.Id),
			Id:    item.SN,
			Type:  item.Type,
		}
	}

	return exit.MarshalJson(sj)
}
Ejemplo n.º 3
0
func (p *Hidden) SetupRender() *exit.Exit {
	fmt.Println("=============================================")
	starttime, err := time.Parse("2006-01-02", "2016-03-25")
	if err != nil {
		panic(err)
	}
	endtime, err := time.Parse("2006-01-02", "2016-03-28")
	if err != nil {
		panic(err)
	}
	fmt.Println("Time is from / to: ", starttime, endtime)

	// startTime, err := time.Parse("2006-01-02", starttime)
	// if nil != err {
	// 	panic(err)
	// }
	// endTime, err2 := time.Parse("2006-01-02", endtime)
	// if nil != err2 {
	// 	panic(err2)
	// }

	p.Data = model.NewTestProductSalesTable() //(startTime, endTime)

	pst, err := settleaccountdao.SettleAccount(starttime, endtime, 17)
	if err != nil {
		fmt.Println(err)
		return exit.Error(err)
	}
	p.Data = pst
	fmt.Println("m : ", p.Data)
	return nil
}
Ejemplo n.º 4
0
// display: total stocks
func (p *ProductCalcTable) Setup() *exit.Exit {

	if nil == p.Data {
		panic("Parameter Data Must be set;")
	}

	// get product
	productmap, err := service.Product.BatchFetchProductByIdMap(p.Data.ProductMap())
	if err != nil {
		return exit.Error(err)
	}
	p.products = productmap

	return nil
}
Ejemplo n.º 5
0
func (p *FactorySettleAccount) SetupRender() *exit.Exit {

	// parameter time
	if !utils.IsValidTime(p.TimeFrom) {
		p.TimeFrom = time.Date(2015, time.January, 1, 0, 0, 0, 0, time.Local)
	}
	if !utils.IsValidTime(p.TimeTo) {
		p.TimeTo = time.Now()
	}

	fmt.Println("Time is from / to: ", p.TimeFrom, p.TimeTo)

	// p.Data = model.NewTestProductSalesTable() //(startTime, endTime)
	pst, err := settleaccountdao.SettleAccount(p.TimeFrom, p.TimeTo, p.Provider)
	if err != nil {
		fmt.Println(err)
		return exit.Error(err)
	}
	p.Data = pst

	return nil
}