示例#1
0
文件: partner.go 项目: zoe527/go2o
func (this *Partner) RegisterMember(m *jsv.Args, r *jsv.Result) error {

	var err error

	e := member.ValueMember{}

	if err = jsv.UnmarshalMap((*m)["json"], &e); err != nil {
		return err
	}
	var cardId string
	var tgId int
	var partnerId int

	cardId = (*m)["card_id"].(string)
	tgId, _ = strconv.Atoi((*m)["tg_id"].(string))
	partnerId, _ = strconv.Atoi((*m)["partner_id"].(string))

	//如果卡片ID为空时,自动生成
	if cardId == "" {
		cardId = time.Now().Format("200601021504")
	}
	e.RegFrom = "WEB"

	e.Pwd = domain.MemberSha1Pwd(e.Pwd)
	id, err := dps.MemberService.SaveMember(&e)

	if err == nil {
		dps.MemberService.SaveRelation(id, cardId, tgId, partnerId)
		r.Result = true
		return nil
	}
	return err
}
示例#2
0
文件: partner.go 项目: zoe527/go2o
func (this *partnerClient) GetShops(partnerId int, secret string) (a []partner.ValueShop, err error) {
	var result jsv.Result
	err = this.conn.WriteAndDecode([]byte(fmt.Sprintf(
		`{"partner_id":"%s","secret":"%s"}>>Partner.GetShops`,
		strconv.Itoa(partnerId), secret)), &result, 2048)
	if err != nil {
		return nil, err
	}
	a = []partner.ValueShop{}
	err = jsv.UnmarshalMap(result.Data, &a)
	return a, err
}
示例#3
0
文件: member.go 项目: zoe527/go2o
func (this *memberClient) GetDeliverAddrs(memberId int, token string) (addrs []member.DeliverAddress, err error) {
	var result jsv.Result
	err = this.conn.WriteAndDecode([]byte(fmt.Sprintf(
		`{"member_id":"%d","token":"%s"}>>Member.GetDeliverAddrs`,
		memberId, token)), &result, 1024)
	if err != nil {
		return nil, err
	}
	addrs = []member.DeliverAddress{}
	err = jsv.UnmarshalMap(result.Data, &addrs)
	return addrs, err
}
示例#4
0
文件: partner.go 项目: zoe527/go2o
func (this *partnerClient) GetSiteConf(partnerId int, secret string) (c *partner.SiteConf, err error) {
	var result jsv.Result
	err = this.conn.WriteAndDecode([]byte(fmt.Sprintf(
		`{"partner_id":"%s","secret":"%s"}>>Partner.GetSiteConf`,
		strconv.Itoa(partnerId), secret)), &result, 2048)

	if err != nil {
		return nil, err
	}
	c = new(partner.SiteConf)
	err = jsv.UnmarshalMap(result.Data, &c)
	return c, nil
}
示例#5
0
文件: partner.go 项目: zoe527/go2o
func (this *partnerClient) GetItems(partnerId int, secret string, categoryId int, getNum int) (
	a []*valueobject.Goods, err error) {
	var result jsv.Result
	err = this.conn.WriteAndDecode([]byte(fmt.Sprintf(
		`{"partner_id":"%s","secret":"%s","cid":"%d","num":"%d"}>>Partner.GetItems`,
		strconv.Itoa(partnerId), secret, categoryId, getNum)), &result, 2048)
	if err != nil {
		return nil, err
	}
	a = []*valueobject.Goods{}
	err = jsv.UnmarshalMap(result.Data, &a)
	return a, err
}
示例#6
0
文件: member.go 项目: zoe527/go2o
func (this *memberClient) GetBankInfo(memberId int, token string) (
	a *member.BankInfo, err error) {
	var result jsv.Result
	err = this.conn.WriteAndDecode([]byte(fmt.Sprintf(
		`{"member_id":"%d","token":"%s"}>>Member.GetBankInfo`,
		memberId, token)), &result, 256)
	if err != nil {
		return nil, err
	}
	a = &member.BankInfo{}
	err = jsv.UnmarshalMap(result.Data, &a)
	return a, err
}
示例#7
0
文件: member.go 项目: zoe527/go2o
func (this *memberClient) GetDeliverAddrById(memberId int, token string, addr_id int) (
	e *member.DeliverAddress, err error) {
	var result jsv.Result
	err = this.conn.WriteAndDecode([]byte(fmt.Sprintf(
		`{"member_id":"%d","token":"%s","addr_id":"%d"}>>Member.GetDeliverAddrById`,
		memberId, token, addr_id)), &result, 256)
	if err != nil {
		return nil, err
	}
	e = &member.DeliverAddress{}
	err = jsv.UnmarshalMap(result.Data, &e)
	return e, err
}
示例#8
0
文件: member.go 项目: zoe527/go2o
func (this *Member) SaveBankInfo(m *jsv.Args, r *jsv.Result) error {
	memberId, err := Verify(m)
	if err != nil {
		return err
	}

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

	if err != nil {
		jsv.LogErr(err)
		return err
	} else {
		r.Result = true
	}
	return nil
}
示例#9
0
文件: member.go 项目: zoe527/go2o
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
}