コード例 #1
0
ファイル: shopping_c.go プロジェクト: jackyan/go2o
func (this *ShoppingC) Payment(ctx *web.Context) {
	if !this.prepare(ctx) {
		return
	}
	r := ctx.Request

	p := this.BaseC.GetPartner(ctx)
	m := this.BaseC.GetMember(ctx)

	siteConf := this.BaseC.GetSiteConf(ctx)
	var payHtml string // 支付HTML
	var payOpt string
	var payHelp string

	orderNo := r.URL.Query().Get("order_no")
	order := dps.ShoppingService.GetOrderByNo(p.Id, orderNo)

	// 已经支付成功
	if order.IsPaid == 1 {
		this.orderFinish(ctx, p, m, siteConf, order)
		return
	}

	if order != nil {
		if order.PaymentOpt == enum.PaymentOnlinePay {
			payHtml = fmt.Sprintf(`<div class="btn_payment"><a class="btn"
				href="/pay/create?pay_opt=alipay&order_no=%s" target="_blank">%s</a></div>`,
				order.OrderNo, "立即支付")
		}
		payOpt = enum.GetPaymentName(order.PaymentOpt)
		payHelp = enum.GetPaymentHelpContent(order.PaymentOpt)

		this.BaseC.ExecuteTemplate(ctx, gof.TemplateDataMap{
			"partner":      p,
			"member":       m,
			"conf":         siteConf,
			"order":        order,
			"payment_opt":  payOpt,
			"payment_html": template.HTML(payHtml),
			"payment_help": template.HTML(payHelp),
		},
			"views/shop/ols/{device}/order_payment.html",
			"views/shop/ols/{device}/inc/header.html",
			"views/shop/ols/{device}/inc/footer.html")
	} else {
		this.OrderEmpty(ctx, p, m, siteConf)
	}
}
コード例 #2
0
ファイル: member_c.go プロジェクト: sunxboy/go2o
func (this *memberC) View(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r, w := ctx.Request, ctx.Response
	r.ParseForm()
	e := dps.ShoppingService.GetOrderByNo(partnerId, r.FormValue("order_no"))
	if e == nil {
		w.Write([]byte("无效订单"))
		return
	}

	member := dps.MemberService.GetMember(e.MemberId)
	if member == nil {
		w.Write([]byte("无效订单"))
		return
	}

	e.ItemsInfo = strings.Replace(e.ItemsInfo, "\n", "<br />", -1)
	if len(e.Note) == 0 {
		e.Note = "无备注"
	}

	js, _ := json.Marshal(e)

	var shopName string
	var payment string
	var orderStateText string
	if e.ShopId == 0 {
		shopName = "未指定"
	} else {
		shopName = dps.PartnerService.GetShopValueById(partnerId, e.ShopId).Name
	}
	payment = enum.GetPaymentName(e.PaymentOpt)
	orderStateText = enum.OrderState(e.Status).String()

	ctx.App.Template().Execute(w,
		gof.TemplateDataMap{
			"entity":   template.JS(js),
			"member":   member,
			"shopName": shopName,
			"payment":  payment,
			"state":    orderStateText,
		}, "views/partner/order/order_view.html")
}