Ejemplo n.º 1
0
func (this *basicC) SaveDeliver_post(ctx *web.Context) {
	m := this.GetMember(ctx)
	r := ctx.Request
	r.ParseForm()
	var e member.DeliverAddress
	web.ParseFormToEntity(r.Form, &e)
	e.MemberId = m.Id
	_, err := dps.MemberService.SaveDeliverAddress(m.Id, &e)
	if err != nil {
		this.resultOutput(ctx, gof.Message{Result: false, Message: err.Error()})
	} else {
		this.resultOutput(ctx, gof.Message{Result: true})
	}
}
Ejemplo n.º 2
0
func (this *basicC) SaveDeliver_post(ctx *web.Context) {
	m := this.GetMember(ctx)
	var result gof.Message
	r := ctx.Request
	r.ParseForm()
	var e member.DeliverAddress
	web.ParseFormToEntity(r.Form, &e)
	e.MemberId = m.Id
	_, err := dps.MemberService.SaveDeliverAddress(m.Id, &e)
	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
	}
	ctx.Response.JsonOutput(result)
}
Ejemplo n.º 3
0
func (this *basicC) SaveDeliver_post(ctx *web.Context) {
	m := this.GetMember(ctx)
	w, r := ctx.ResponseWriter, ctx.Request
	r.ParseForm()
	var e member.DeliverAddress
	web.ParseFormToEntity(r.Form, &e)
	e.MemberId = m.Id
	b, err := goclient.Member.SaveDeliverAddr(m.Id, m.DynamicToken, &e)
	if err == nil {
		if b {
			w.Write([]byte(`{"result":true}`))
		} else {
			w.Write([]byte(`{"result":false}`))
		}
	} else {
		w.Write([]byte(fmt.Sprintf(`{"result":false,"message":"%s"}`, err.Error())))
	}
}
Ejemplo n.º 4
0
func (this *deliver) checkValue(v *member.DeliverAddress) error {

	v.Address = strings.TrimSpace(v.Address)
	v.RealName = strings.TrimSpace(v.RealName)
	v.Phone = strings.TrimSpace(v.Phone)

	if len([]rune(v.Address)) < 6 { // 判断字符长度
		return member.ErrDeliverAddressLen
	}

	if len([]rune(v.RealName)) < 2 {
		return member.ErrDeliverContactPersonName
	}

	if !phoneRegex.MatchString(v.Phone) {
		return member.ErrDeliverContactPhone
	}
	return nil
}
Ejemplo n.º 5
0
func (this *ShoppingC) SaveDeliverAddr_post(ctx *web.Context) {
	if !this.prepare(ctx) {
		return
	}
	m := this.GetMember(ctx)
	r, w := ctx.Request, ctx.ResponseWriter
	r.ParseForm()
	var e member.DeliverAddress
	web.ParseFormToEntity(r.Form, &e)
	e.MemberId = m.Id
	b, err := dps.MemberService.SaveDeliverAddress(m.Id, &e)
	if err == nil {
		if b > 0 {
			w.Write([]byte(`{"result":true}`))
		} else {
			w.Write([]byte(`{"result":false}`))
		}
	} else {
		w.Write([]byte(fmt.Sprintf(`{"result":false,"message":"%s"}`, err.Error())))
	}
}
Ejemplo n.º 6
0
func (this *Member) SaveDeliverAddr(m *jsv.Args, r *jsv.Result) error {
	memberId, err := Verify(m)
	if err != nil {
		return err
	}

	var e member.DeliverAddress
	err = jsv.UnmarshalMap((*m)["json"], &e)
	if err != nil {
		return err
	}
	e.MemberId = memberId

	_, err = dps.MemberService.SaveDeliverAddress(memberId, &e)
	if err != nil {
		jsv.LogErr(err)
		r.Message = err.Error()
	} else {
		r.Result = true
	}
	return nil
}