Beispiel #1
0
func (this *configC) Profile_post(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r, w := ctx.Request, ctx.ResponseWriter
	var result gof.Message
	r.ParseForm()

	e := partner.ValuePartner{}
	web.ParseFormToEntity(r.Form, &e)

	//更新
	origin, _ := dps.PartnerService.GetPartner(partnerId)
	e.ExpiresTime = origin.ExpiresTime
	e.JoinTime = origin.JoinTime
	e.LastLoginTime = origin.LastLoginTime
	e.LoginTime = origin.LoginTime
	e.Pwd = origin.Pwd
	e.UpdateTime = time.Now().Unix()
	e.Id = partnerId

	id, err := dps.PartnerService.SavePartner(partnerId, &e)

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
		result.Data = id
	}
	w.Write(result.Marshal())
}
Beispiel #2
0
func (c *partnerC) CreatePartner_post(ctx *web.Context) {
	r, w := ctx.Request, ctx.ResponseWriter
	var result gof.Message
	var isCreate bool
	r.ParseForm()

	partner := partner.ValuePartner{}
	web.ParseFormToEntity(r.Form, &partner)

	dt := time.Now()
	anousPwd := strings.Repeat("*", 10) //匿名密码
	if len(partner.Pwd) != 0 && partner.Pwd != anousPwd {
		partner.Pwd = domain.Md5PartnerPwd(partner.Usr, partner.Pwd)
	}

	//更新
	if partner.Id > 0 {
		original, _ := dps.PartnerService.GetPartner(partner.Id)
		partner.JoinTime = original.JoinTime
		partner.ExpiresTime = original.ExpiresTime
		partner.UpdateTime = dt.Unix()

		if partner.Pwd == anousPwd {
			partner.Pwd = original.Pwd
		}
	} else {
		partner.JoinTime = dt.Unix()
		partner.ExpiresTime = dt.AddDate(10, 0, 0).Unix()
		partner.UpdateTime = dt.Unix()
		isCreate = true
	}

	id, err := dps.PartnerService.SavePartner(partner.Id, &partner)
	if err != nil {
		result.Message = err.Error()
	} else {
		result.Data = id
		result.Result = true
		if isCreate {
			// 初始化商户信息
			dps.PartnerService.InitDefaultLevels(id) // 初始化等级
			dps.SaleService.InitSaleTags(id)         // 初始化销售标签
		}
	}
	w.Write(result.Marshal())
}