// PrePayOrder return data for invoke wechat payment
558587
func (pcf *Pay) PrePayOrder(p *Params) (payOrder PreOrder, err error) {
	nonceStr := util.RandomStr(32)
	param := make(map[string]interface{})
	param["appid"] = pcf.AppID
	param["body"] = p.Body
	param["mch_id"] = pcf.PayMchID
	param["nonce_str"] =nonceStr
	param["notify_url"] =pcf.PayNotifyURL
	param["out_trade_no"] =p.OutTradeNo
	param["spbill_create_ip"] =p.CreateIP
	param["total_fee"] =p.TotalFee
	param["trade_type"] =p.TradeType
	param["openid"] = p.OpenID

	bizKey := "&key="+pcf.PayKey
	str := orderParam(param,bizKey)
	sign := util.MD5Sum(str)
	request := payRequest{
		AppID:          pcf.AppID,
		MchID:          pcf.PayMchID,
		NonceStr:       nonceStr,
		Sign:           sign,
		Body:           p.Body,
		OutTradeNo:     p.OutTradeNo,
		TotalFee:       p.TotalFee,
		SpbillCreateIP: p.CreateIP,
		NotifyURL:      pcf.PayNotifyURL,
		TradeType:      p.TradeType,
		OpenID:         p.OpenID,
	}
	rawRet, err := util.PostXML(payGateway, request)
	if err != nil {
		return
	}
	err = xml.Unmarshal(rawRet, &payOrder)
	if err != nil {
		return
	}
	if payOrder.ReturnCode == "SUCCESS" {
		//pay success
		if payOrder.ResultCode == "SUCCESS" {
			err = nil
			return
		}
		err = errors.New(payOrder.ErrCode + payOrder.ErrCodeDes)
		return
	}
	err = errors.New("[msg : xmlUnmarshalError] [rawReturn : " + string(rawRet) + "] [params : " + str + "] [sign : " + sign + "]")
	return
}
1270189
func (cp *CachePool) Preload(fileIndex int64) error {
	channel := cp.fileChans[int(fileIndex)]

	select {
	case <-channel:
		// already preloaded, all done!
		return nil
	default:
		// need to preload now
	}

	success := false
	defer func() {
		if success {
			close(channel)
		}
	}()

	reader, err := cp.source.GetReader(fileIndex)
	if err != nil {
		return errors.WithStack(err)
	}
	defer cp.source.Close()

	writer, err := cp.cache.GetWriter(fileIndex)
	if err != nil {
		return errors.WithStack(err)
	}
	defer writer.Close()

	_, err = io.Copy(writer, reader)
	if err != nil {
		return errors.WithStack(err)
	}

	success = true

	return nil
}
1203549
func (l Listing) applySort() {
	// Check '.Order' to know how to sort
	if l.Order == "desc" {
		switch l.Sort {
		case sortByName:
			sort.Sort(sort.Reverse(byName(l)))
		case sortBySize:
			sort.Sort(sort.Reverse(bySize(l)))
		case sortByTime:
			sort.Sort(sort.Reverse(byTime(l)))
		default:
			// If not one of the above, do nothing
			return
		}
	} else { // If we had more Orderings we could add them here
		switch l.Sort {
		case sortByName:
			sort.Sort(byName(l))
		case sortBySize:
			sort.Sort(bySize(l))
		case sortByTime:
			sort.Sort(byTime(l))
		default:
			// If not one of the above, do nothing
			return
		}
	}
}
1140220
func (e *CElement) PrevWaitChan() <-chan struct{} {
	e.mtx.RLock()
	defer e.mtx.RUnlock()

	return e.prevWaitCh
}
579791
func PackWithOrder(w io.Writer, data interface{}, order binary.ByteOrder) error {
	return PackWithOptions(w, data, &Options{Order: order})
}
398065
func (q Query) Prepend(item interface{}) Query {
	return Query{
		Iterate: func() Iterator {
			next := q.Iterate()
			prepended := false

			return func() (interface{}, bool) {
				if prepended {
					return next()
				}

				prepended = true
				return item, true
			}
		},
	}
}
856981
func (b *Bar) PrependElapsed() *Bar {
	b.PrependFunc(func(b *Bar) string {
		return strutil.PadLeft(b.TimeElapsedString(), 5, ' ')
	})
	return b
}
77288
func (options *FontOptions) SetSubpixelOrder(subpixelOrder SubpixelOrder) {
	C.cairo_font_options_set_subpixel_order(options.Ptr, C.cairo_subpixel_order_t(subpixelOrder))
	if err := options.status(); err != nil {
		panic(err)
	}
}
417319
func (a *DateHistogramAggregation) Order(order string, asc bool) *DateHistogramAggregation {
	a.order = order
	a.orderAsc = asc
	return a
}
140963
func TopSort(g Iterator) (order []int, ok bool) {
	order, ok = topsort(g, true)
	return
}
1005607
func (p *PhysicalProperty) AllSameOrder() (bool, bool) {
	if len(p.Items) == 0 {
		return true, false
	}
	for i := 1; i < len(p.Items); i++ {
		if p.Items[i].Desc != p.Items[i-1].Desc {
			return false, false
		}
	}
	return true, p.Items[0].Desc
}
1218453
func Sorting(field sortingField, order sortingOrder) QueryOpt {
	return QueryOpt{func(o *QueryOptions) {
		o.SortField = field
		o.SortOrder = order
	}}
}
150284
func (s *Selection) BeforeHtml(html string) *Selection {
	return s.BeforeNodes(parseHtml(html)...)
}
1057767
func prepareOptions(options []StaticOptions) StaticOptions {
	var opt StaticOptions
	if len(options) > 0 {
		opt = options[0]
	}

	if len(opt.IndexFile) == 0 {
		opt.IndexFile = "index.html"
	}

	if len(opt.Prefix) != 0 {
		// ensure we have a leading "/"
		if opt.Prefix[0] != '/' {
			opt.Prefix = "/" + opt.Prefix
		}

		// remove all trailing "/"
		opt.Prefix = strings.TrimRight(opt.Prefix, "/")
	}

	return opt
}
101631
func (s GeoDistanceSort) Order(ascending bool) GeoDistanceSort {
	s.ascending = ascending
	return s
}
1323577
func (s *Selection) PrependSelection(sel *Selection) *Selection {
	return s.PrependNodes(sel.Nodes...)
}
523894
func Pay(id string, params *stripe.OrderPayParams) (*stripe.Order, error) {
	return getC().Pay(id, params)
}