// 会员基本信息 func (this *memberC) Member_basic(ctx *web.Context) { memberId, _ := strconv.Atoi(ctx.Request.URL.Query().Get("member_id")) m := dps.MemberService.GetMember(memberId) if m == nil { ctx.Response.Write([]byte("no such member")) } else { lv := dps.PartnerService.GetLevel(this.GetPartnerId(ctx), m.Level) ctx.App.Template().Execute(ctx.Response, gof.TemplateDataMap{ "m": m, "lv": lv, "sexName": gfmt.BoolString(m.Sex == 1, "先生", gfmt.BoolString(m.Sex == 2, "女士", "-")), "lastLoginTime": format.HanUnixDateTime(m.LastLoginTime), "regTime": format.HanUnixDateTime(m.RegTime), }, "views/partner/member/basic_info.html") } }
//todo:bug 当在UCenter登陆,会话会超时 func (this *mainC) Index(ctx *web.Context) { if this.base.Requesting(ctx) { mm := this.base.GetMember(ctx) p := this.base.GetPartner(ctx) conf := this.base.GetSiteConf(p.Id) acc := dps.MemberService.GetAccount(mm.Id) js, _ := json.Marshal(mm) info := make(map[string]string) info["memName"] = mm.Name lv := dps.PartnerService.GetLevel(p.Id, mm.Level) //nextLv := dps.PartnerService.GetNextLevel(p.Id, mm.Level) // if nextLv == nil { // nextLv = lv // } this.base.ExecuteTemplate(ctx, gof.TemplateDataMap{ "level": lv, //"nLevel": nextLv, "member": mm, "partner": p, "conf": conf, "partner_host": conf.Host, "json": template.JS(js), "acc": acc, "regTime": time.Unix(mm.RegTime, 0).Format("2006-01-02"), "name": template.HTML(gfmt.BoolString(len(mm.Name) == 0, `<span class="red">未填写</span>`, mm.Name)), "sex": gfmt.BoolString(mm.Sex == 1, "先生", gfmt.BoolString(mm.Sex == 2, "女士", "")), }, "views/ucenter/{device}/index.html", "views/ucenter/{device}/inc/header.html", "views/ucenter/{device}/inc/menu.html", "views/ucenter/{device}/inc/footer.html") } }
func (this *goodsC) LvPrice(ctx *web.Context) { partnerId := this.GetPartnerId(ctx) //todo: should be goodsId itemId, _ := strconv.Atoi(ctx.Request.URL.Query().Get("item_id")) goods := dps.SaleService.GetGoodsBySku(partnerId, itemId, 0) lvs := dps.PartnerService.GetMemberLevels(partnerId) var prices []*sale.MemberPrice = dps.SaleService.GetGoodsLevelPrices(partnerId, goods.GoodsId) var buf *bytes.Buffer = bytes.NewBufferString("") var fmtFunc = func(level int, levelName string, id int, price float32, enabled int) { buf.WriteString(fmt.Sprintf(` <tr> <td><input type="hidden" field="Id_%d" value="%d"/> %s</td> <td align="center"><input type="number" field="Price_%d" value="%s"/></td> <td align="center"><input type="checkbox" field="Enabled_%d" %s/></td> </tr> `, level, id, levelName, level, format.FormatFloat(price), level, gfmt.BoolString(enabled == 1, "checked=\"checked\"", ""))) } var b bool for _, v := range lvs { b = false for _, v1 := range prices { if v.Value == v1.Level { fmtFunc(v.Value, v.Name, v1.Id, v1.Price, v1.Enabled) b = true break } } if !b { fmtFunc(v.Value, v.Name, 0, goods.SalePrice, 0) } } ctx.App.Template().Execute(ctx.Response, gof.TemplateDataMap{ "goods": goods, "setHtml": template.HTML(buf.String()), }, "views/partner/goods/level_price.html") }