Example #1
0
// 保存优惠券
func (this *promC) Save_coupon_post(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r := ctx.Request
	r.ParseForm()

	var result gof.Message

	e := promotion.ValuePromotion{}
	web.ParseFormToEntity(r.Form, &e)
	e2 := promotion.ValueCoupon{}
	web.ParseFormToEntity(r.Form, &e2)

	e.PartnerId = partnerId
	e.TypeFlag = promotion.TypeFlagCoupon

	const layout string = "2006-01-02 15:04:05"
	bt, _ := time.Parse(layout, r.FormValue("BeginTime"))
	ot, _ := time.Parse(layout, r.FormValue("OverTime"))
	e2.BeginTime = bt.Unix()
	e2.OverTime = ot.Unix()

	id, err := dps.PromService.SaveCoupon(partnerId, &e, &e2)

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
		result.Data = id
	}
	ctx.Response.JsonOutput(result)
}
Example #2
0
func (this *UserC) PostRegisterInfo_post(ctx *web.Context) {
	ctx.Request.ParseForm()
	var result gof.Message
	var member member.ValueMember
	web.ParseFormToEntity(ctx.Request.Form, &member)
	if i := strings.Index(ctx.Request.RemoteAddr, ":"); i != -1 {
		member.RegIp = ctx.Request.RemoteAddr[:i]
	}

	var memberId int
	var err error

	if len(member.Usr) == 0 || len(member.Pwd) == 0 {
		err = errors.New("注册信息不完整")
	} else {
		member.Pwd = domain.MemberSha1Pwd(member.Pwd)
		memberId, err = dps.MemberService.SaveMember(&member)
		if err == nil {
			invId := dps.MemberService.GetMemberIdByInvitationCode(ctx.Request.FormValue("invi_code"))
			err = dps.MemberService.SaveRelation(memberId, "", invId,
				this.BaseC.GetPartnerId(ctx))
		}
	}

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
	}
	ctx.Response.JsonOutput(result)
}
Example #3
0
// 保存现金返现
func (this *promC) Save_cb_post(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r := ctx.Request
	r.ParseForm()

	var result gof.Message

	e := promotion.ValuePromotion{}
	web.ParseFormToEntity(r.Form, &e)
	e2 := promotion.ValueCashBack{}
	web.ParseFormToEntity(r.Form, &e2)

	e.PartnerId = partnerId
	e.TypeFlag = promotion.TypeFlagCashBack

	id, err := dps.PromService.SaveCashBackPromotion(partnerId, &e, &e2)

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
		result.Data = id
	}
	ctx.Response.JsonOutput(result)
}
Example #4
0
// 断开
func (this *MemberC) Disconnect(ctx *web.Context) {
	var result gof.Message
	if util.MemberHttpSessionDisconnect(ctx) {
		result.Result = true
	} else {
		result.Message = "disconnect fail"
	}
	ctx.Response.JsonOutput(result)
}
Example #5
0
func (this *UserC) Valid_invitation_post(ctx *web.Context) {
	ctx.Request.ParseForm()
	memberId := dps.MemberService.GetMemberIdByInvitationCode(
		ctx.Request.FormValue("invi_code"))
	var result gof.Message
	result.Result = memberId != 0

	if !result.Result {
		result.Message = "推荐人无效"
	}

	ctx.Response.JsonOutput(result)
}
Example #6
0
func (this *UserC) ValidUsr_post(ctx *web.Context) {
	r := ctx.Request
	var msg gof.Message
	r.ParseForm()
	usr := r.FormValue("usr")
	err := dps.MemberService.CheckUsr(usr, 0)
	if err == nil {
		msg.Result = true
	} else {
		msg.Message = err.Error()
	}
	ctx.Response.JsonOutput(msg)
}
Example #7
0
func (this *CartC) cart_RemoveItem(ctx *web.Context,
	p *partner.ValuePartner, memberId int, cartKey string) {
	var result gof.Message
	r := ctx.Request
	goodsId, _ := strconv.Atoi(r.FormValue("id"))
	num, _ := strconv.Atoi(r.FormValue("num"))
	err := dps.ShoppingService.SubCartItem(p.Id, memberId, cartKey, goodsId, num)
	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
	}
	ctx.Response.JsonOutput(result)
}
Example #8
0
func (this *basicC) DeleteDeliver_post(ctx *web.Context) {
	r := ctx.Request
	var result gof.Message
	m := this.GetMember(ctx)
	r.ParseForm()
	id, _ := strconv.Atoi(r.FormValue("id"))

	err := dps.MemberService.DeleteDeliverAddress(m.Id, id)
	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
	}
	ctx.Response.JsonOutput(result)
}
Example #9
0
// 删除邮件模板
func (this *mssC) Del_mail_tpl_post(ctx *web.Context) {
	ctx.Request.ParseForm()
	form := ctx.Request.Form
	var result gof.Message
	partnerId := this.GetPartnerId(ctx)
	adId, _ := strconv.Atoi(form.Get("id"))
	err := dps.PartnerService.DeleteMailTemplate(partnerId, adId)

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
	}

	ctx.Response.JsonOutput(result)
}
Example #10
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)
}
Example #11
0
func (this *goodsC) Del_item_post(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r := ctx.Request
	var result gof.Message

	r.ParseForm()
	id, _ := strconv.Atoi(r.FormValue("id"))
	err := dps.SaleService.DeleteItem(partnerId, id)

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
	}
	ctx.Response.JsonOutput(result)
}
Example #12
0
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())
}
Example #13
0
// 删除促销
func (this *promC) Del_post(ctx *web.Context) {
	ctx.Request.ParseForm()
	form := ctx.Request.Form
	var result gof.Message
	partnerId := this.GetPartnerId(ctx)
	promId, _ := strconv.Atoi(form.Get("id"))

	err := dps.PromService.DelPromotion(partnerId, promId)

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
	}
	ctx.Response.JsonOutput(result)
}
Example #14
0
func (this *accountC) Bank_info_post(ctx *web.Context) {
	m := this.GetMember(ctx)
	r := ctx.Request
	var msg gof.Message
	r.ParseForm()
	e := new(member.BankInfo)
	web.ParseFormToEntity(r.Form, e)
	e.MemberId = m.Id
	err := dps.MemberService.SaveBankInfo(e)

	if err != nil {
		msg.Message = err.Error()
	} else {
		msg.Result = true
	}
	ctx.Response.JsonOutput(msg)
}
Example #15
0
func (this *coverageAreaC) SaveArea_post(ctx *web.Context) {
	r, w := ctx.Request, ctx.Response
	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())
}
Example #16
0
func (this *saleC) Del_stag_post(ctx *web.Context) {
	r := ctx.Request
	var result gof.Message
	r.ParseForm()
	partnerId := this.GetPartnerId(ctx)
	id, err := strconv.Atoi(r.FormValue("id"))
	if err == nil {
		err = dps.SaleService.DeleteSaleTag(partnerId, id)
	}

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
	}
	ctx.Response.JsonOutput(result)
}
Example #17
0
func (this *basicC) Profile_post(ctx *web.Context) {
	mm := this.GetMember(ctx)
	r := ctx.Request
	var result gof.Message
	r.ParseForm()
	m := new(member.ValueMember)
	web.ParseFormToEntity(r.Form, m)
	m.Id = mm.Id
	_, err := dps.MemberService.SaveMember(m)

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
		this.ReCacheMember(ctx, m.Id)
	}
	ctx.Response.JsonOutput(result)
}
Example #18
0
//修改门店信息
func (this *shopC) SaveShop_post(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r, w := ctx.Request, ctx.Response
	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())
}
Example #19
0
func (this *saleC) Save_stag_post(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r := ctx.Request
	var result gof.Message
	r.ParseForm()

	e := sale.ValueSaleTag{}
	web.ParseFormToEntity(r.Form, &e)
	e.PartnerId = this.GetPartnerId(ctx)

	id, err := dps.SaleService.SaveSaleTag(partnerId, &e)

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
		result.Data = id
	}
	ctx.Response.JsonOutput(result)
}
Example #20
0
func (this *configC) SaleConf_post(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r, w := ctx.Request, ctx.Response
	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())
}
Example #21
0
// 保存设置
func (this *mssC) Mss_setting_post(ctx *web.Context) {
	var result gof.Message
	partnerId := this.GetPartnerId(ctx)
	ctx.Request.ParseForm()
	var data map[string]string = make(map[string]string, 0)
	for k, v := range ctx.Request.Form {
		if strings.HasPrefix(k, "mss_") {
			data[k] = v[0]
		}
	}

	err := dps.PartnerService.SaveKeyMaps(partnerId, data)

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
	}
	ctx.Response.JsonOutput(result)
}
Example #22
0
func (this *ShoppingC) applyCoupon(ctx *web.Context) {
	var result gof.Message
	if !this.prepare(ctx) {
		result.Message = "请先登陆"
	} else {
		p := this.BaseC.GetPartner(ctx)
		m := this.BaseC.GetMember(ctx)

		code := ctx.Request.FormValue("code")
		data, err := dps.ShoppingService.BuildOrder(p.Id, m.Id, "", code)
		if err != nil {
			result.Message = err.Error()
		} else {
			ctx.Response.JsonOutput(data)
			return
		}
	}

	ctx.Response.JsonOutput(result)
}
Example #23
0
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())
}
Example #24
0
func (this *UserC) Login_post(ctx *web.Context) {
	r := ctx.Request
	r.ParseForm()
	var result gof.Message
	partnerId := this.BaseC.GetPartnerId(ctx)
	usr, pwd := r.Form.Get("usr"), r.Form.Get("pwd")
	b, m, err := dps.MemberService.Login(partnerId, usr, pwd)

	if b {
		ctx.Session().Set("member", m)
		ctx.Session().Save()
		result.Result = true
	} else {
		if err != nil {
			result.Message = err.Error()
		} else {
			result.Message = "登陆失败"
		}
	}
	ctx.Response.JsonOutput(result)
}
Example #25
0
func (this *loginC) Index_post(ctx *web.Context) {
	r := ctx.Request
	r.ParseForm()
	var result gof.Message
	usr, pwd := r.Form.Get("usr"), r.Form.Get("pwd")
	b, m, err := dps.MemberService.Login(-1, usr, pwd)
	if b {
		ctx.Session().Set("member", m)
		ctx.Session().Save()
		result.Result = true
	} else {
		if err != nil {
			result.Message = err.Error()
		} else {
			result.Message = "登陆失败"
		}
	}
	js, _ := json.Marshal(result)
	ctx.Response.Write(js)

}
Example #26
0
func (this *configC) Profile_post(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r, w := ctx.Request, ctx.Response
	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())
}
Example #27
0
func (this *accountC) Apply_cash_post(ctx *web.Context) {
	var msg gof.Message
	var err error
	ctx.Request.ParseForm()
	partnerId := this.GetPartner(ctx).Id
	amount, _ := strconv.ParseFloat(ctx.Request.FormValue("Amount"), 32)
	tradePwd := ctx.Request.FormValue("TradePwd")
	if amount < minAmount {
		err = errors.New(fmt.Sprintf("必须达到最低提现金额:%s元",
			format.FormatFloat(float32(minAmount))))
	} else {
		m := this.GetMember(ctx)
		err = dps.MemberService.SubmitApplyCash(partnerId, m.Id, tradePwd, member.TypeApplyCashToBank, float32(amount))
	}

	if err != nil {
		msg.Message = err.Error()
	} else {
		msg.Result = true
	}
	ctx.Response.JsonOutput(msg)
}
Example #28
0
// 保存邮件模板
func (this *mssC) Save_mail_tpl_post(ctx *web.Context) {
	partnerId := this.GetPartnerId(ctx)
	r := ctx.Request
	r.ParseForm()

	var result gof.Message

	e := mss.MailTemplate{}
	web.ParseFormToEntity(r.Form, &e)

	//更新
	e.PartnerId = partnerId

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

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
		result.Data = id
	}
	ctx.Response.JsonOutput(result)
}
Example #29
0
func (this *basicC) Pwd_post(ctx *web.Context) {
	r := ctx.Request
	var result gof.Message
	r.ParseForm()
	m := this.GetMember(ctx)
	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.Message = err.Error()
	} else {
		result.Result = true
		this.ReCacheMember(ctx, m.Id)
	}
	ctx.Response.JsonOutput(result)
}
Example #30
0
func (this *goodsC) SaveGoodsSTag_post(ctx *web.Context) {
	r := ctx.Request
	var result gof.Message
	goodsId, err := strconv.Atoi(r.FormValue("GoodsId"))
	if err == nil {
		tags := strings.Split(r.FormValue("SaleTags"), ",")
		var ids []int = []int{}
		for _, v := range tags {
			if i, err := strconv.Atoi(v); err == nil {
				ids = append(ids, i)
			}
		}

		partnerId := this.GetPartnerId(ctx)
		err = dps.SaleService.SaveItemSaleTags(partnerId, goodsId, ids)
	}

	if err != nil {
		result.Message = err.Error()
	} else {
		result.Result = true
	}
	ctx.Response.JsonOutput(result)
}