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()) }
func (this *categoryC) DelCategory_post(ctx *web.Context) { partnerId := this.GetPartnerId(ctx) r, w := ctx.Request, ctx.ResponseWriter var result gof.Message r.ParseForm() categoryId, _ := strconv.Atoi(r.Form.Get("id")) //删除分类 err := dps.SaleService.DeleteCategory(partnerId, categoryId) if err != nil { result = gof.Message{Result: false, Message: err.Error()} } else { result = gof.Message{Result: true, Message: ""} } w.Write(result.Marshal()) }
func (this *goodsC) Del_post(ctx *web.Context) { partnerId := this.GetPartnerId(ctx) r, w := ctx.Request, ctx.Response var result gof.Message r.ParseForm() id, _ := strconv.Atoi(r.FormValue("id")) err := dps.SaleService.DeleteGoods(partnerId, id) if err != nil { result = gof.Message{Result: true, Message: err.Error()} } else { result = gof.Message{Result: true, Message: "", Data: id} } w.Write(result.Marshal()) }
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()) }
func (this *coverageAreaC) SaveArea_post(ctx *web.Context) { r, w := ctx.Request, ctx.ResponseWriter var result gof.Message r.ParseForm() coverageArea := delivery.CoverageValue{} web.ParseFormToEntity(r.Form, &coverageArea) id, err := dps.DeliverService.CreateCoverageArea(&coverageArea) if err != nil { result = gof.Message{Result: true, Message: err.Error()} } else { result = gof.Message{Result: true, Message: "", Data: id} } w.Write(result.Marshal()) }
//修改门店信息 func (this *categoryC) SaveCategory_post(ctx *web.Context) { partnerId := this.GetPartnerId(ctx) r, w := ctx.Request, ctx.ResponseWriter var result gof.Message r.ParseForm() e := sale.ValueCategory{} web.ParseFormToEntity(r.Form, &e) id, err := dps.SaleService.SaveCategory(partnerId, &e) if err != nil { result = gof.Message{Result: false, Message: err.Error()} } else { result = gof.Message{Result: true, Message: "", Data: id} } w.Write(result.Marshal()) }
func (this *basicC) Profile_post(ctx *web.Context) { mm := this.GetMember(ctx) r, w := ctx.Request, ctx.ResponseWriter var result gof.Message r.ParseForm() clientM := new(member.ValueMember) web.ParseFormToEntity(r.Form, clientM) clientM.Id = mm.Id _, err := goclient.Member.SaveMember(clientM, mm.DynamicToken) if err != nil { result = gof.Message{Result: false, Message: err.Error()} } else { result = gof.Message{Result: true} } w.Write(result.Marshal()) }
func (this *accountC) ApplyCash_post(ctx *web.Context) { m := this.GetMember(ctx) r, w := ctx.Request, ctx.ResponseWriter var result gof.Message r.ParseForm() e := new(member.BankInfo) web.ParseFormToEntity(r.Form, e) e.MemberId = m.Id err := goclient.Member.SaveBankInfo(m.Id, m.DynamicToken, e) if err != nil { result = gof.Message{Result: false, Message: err.Error()} } else { result = gof.Message{Result: true} } w.Write(result.Marshal()) }
func (this *mainC) Login_post(ctx *web.Context) { r := ctx.Request var msg gof.Message r.ParseForm() usr, pwd := r.Form.Get("uid"), r.Form.Get("pwd") if domain.Md5Pwd(pwd, usr) == ctx.App.Config().GetString("webmaster_valid_md5") { ctx.Session().Set("master_id", 1) if err := ctx.Session().Save(); err != nil { msg.Message = err.Error() } else { msg.Result = true } } else { msg.Message = "用户或密码不正确!" } ctx.Response.Write(msg.Marshal()) }
//修改门店信息 func (this *shopC) SaveShop_post(ctx *web.Context) { partnerId := this.GetPartnerId(ctx) r, w := ctx.Request, ctx.ResponseWriter var result gof.Message r.ParseForm() shop := partner.ValueShop{} web.ParseFormToEntity(r.Form, &shop) id, err := dps.PartnerService.SaveShop(partnerId, &shop) if err != nil { result = gof.Message{Result: true, Message: err.Error()} } else { result = gof.Message{Result: true, Message: "", Data: id} } w.Write(result.Marshal()) }
func (this *configC) SaleConf_post(ctx *web.Context) { partnerId := this.GetPartnerId(ctx) r, w := ctx.Request, ctx.ResponseWriter var result gof.Message r.ParseForm() e := partner.SaleConf{} web.ParseFormToEntity(r.Form, &e) e.PartnerId = partnerId err := dps.PartnerService.SaveSaleConf(partnerId, &e) if err != nil { result = gof.Message{Result: false, Message: err.Error()} } else { result = gof.Message{Result: true, Message: ""} } w.Write(result.Marshal()) }
func (this *goodsC) SaveItem_post(ctx *web.Context) { partnerId := this.GetPartnerId(ctx) r, w := ctx.Request, ctx.Response var result gof.Message r.ParseForm() e := sale.ValueItem{} web.ParseFormToEntity(r.Form, &e) e.State = 1 //todo: 暂时使用 id, err := dps.SaleService.SaveItem(partnerId, &e) if err != nil { result = gof.Message{Result: true, Message: err.Error()} } else { result = gof.Message{Result: true, Message: "", Data: id} } w.Write(result.Marshal()) }
func (this *basicC) Pwd_post(ctx *web.Context) { r, w := ctx.Request, ctx.ResponseWriter m := this.GetMember(ctx) var result gof.Message r.ParseForm() var oldPwd, newPwd, rePwd string oldPwd = r.FormValue("OldPwd") newPwd = r.FormValue("NewPwd") rePwd = r.FormValue("RePwd") var err error if newPwd != rePwd { err = errors.New("两次密码输入不一致") } else { err = dps.MemberService.ModifyPassword(m.Id, oldPwd, newPwd) } if err != nil { result = gof.Message{Result: false, Message: err.Error()} } else { result = gof.Message{Result: true} } w.Write(result.Marshal()) }
func (this *promC) Bind_coupon_post(ctx *web.Context) { partnerId := this.GetPartnerId(ctx) r, w := ctx.Request, ctx.Response var result gof.Message r.ParseForm() id, err := strconv.Atoi(r.FormValue("id")) if err == nil { memberIds := strings.TrimSpace(r.FormValue("member_ids")) if memberIds == "" { result.Message = "请选择会员" } else { idArr := strings.Split(memberIds, ",") err = dps.PromService.BindCoupons(partnerId, id, idArr) } } if err != nil { result.Result = false result.Message = err.Error() } else { result.Result = true } w.Write(result.Marshal()) }
func (this *promC) SaveCoupon_post(ctx *web.Context) { partnerId := this.GetPartnerId(ctx) r, w := ctx.Request, ctx.ResponseWriter var result gof.Message r.ParseForm() var e promotion.ValueCoupon web.ParseFormToEntity(r.Form, &e) const layout string = "2006-01-02 15:04:05" bt, _ := time.Parse(layout, r.FormValue("BeginTime")) ot, _ := time.Parse(layout, r.FormValue("OverTime")) e.BeginTime = bt.Unix() e.OverTime = ot.Unix() _, err := dps.PromService.SaveCoupon(partnerId, &e) if err != nil { result = gof.Message{Result: false, Message: err.Error()} } else { result = gof.Message{Result: true, Message: ""} } w.Write(result.Marshal()) }