Exemplo n.º 1
0
func (this *BaseC) Requesting(ctx *web.Context) bool {
	// 商户不存在
	partnerId := getPartnerId(ctx)
	if partnerId <= 0 {
		renderError(ctx, true, "No such partner.")
		return false
	}

	ctx.Items["partner_id"] = partnerId // 缓存PartnerId

	// 校验商户并缓存
	pt := cache.GetValuePartnerCache(partnerId)
	ctx.Items["partner_ins"] = pt

	// 判断线上商店开通情况
	var conf = cache.GetPartnerSiteConf(partnerId)
	if conf == nil {
		renderError(ctx, true, "线上商店未开通")
		return false
	}

	if conf.State == enum.PARTNER_SITE_CLOSED {
		if strings.TrimSpace(conf.StateHtml) == "" {
			conf.StateHtml = "网站暂停访问,请联系商家:" + pt.Tel
		}
		renderError(ctx, true, conf.StateHtml)
		return false
	}

	ctx.Items["partner_siteconf"] = conf

	return true
}
Exemplo n.º 2
0
Arquivo: util.go Projeto: xianmau/go2o
func GetSiteConf(w http.ResponseWriter, p *partner.ValuePartner, api *partner.ApiInfo) (bool, *partner.SiteConf) {
	var conf = cache.GetPartnerSiteConf(p.Id)
	if conf == nil {
		conf, _ = goclient.Partner.GetSiteConf(p.Id, api.ApiSecret)

		if conf == nil {
			w.Write([]byte("网站访问过程中出现了异常,请重试!"))
			return false, nil
		}

		if conf.State == enum.PARTNER_SITE_CLOSED {
			if strings.TrimSpace(conf.StateHtml) == "" {
				conf.StateHtml = "网站暂停访问,请联系商家:" + p.Tel
			}
			w.Write([]byte(conf.StateHtml))
			return false, conf
		}
		cache.SetPartnerSiteConf(p.Id, conf)
	}
	return true, conf
}