12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package models
- import (
- "rdluck_tools/orm"
- "time"
- )
- type CygxApplyRecord struct {
- ApplyRecordId int `orm:"column(apply_record_id);pk" description:"申请试用id"`
- BusinessCardUrl string `description:"名片地址"`
- RealName string `description:"姓名"`
- CompanyName string `description:"公司名称"`
- Mobile string `description:"手机号"`
- CreateTime time.Time `description:"创建时间"`
- ApplyMethod int `description:"1:已付费客户申请试用,2:非客户申请试用"`
- }
- func AddApplyRecord(item *ApplyTryReq, mobile, companyNamePay string, userId, companyIdPay int) (err error) {
- o := orm.NewOrm()
- o.Begin()
- defer func() {
- if err != nil {
- o.Rollback()
- } else {
- o.Commit()
- }
- }()
- sql := `INSERT INTO cygx_apply_record (user_id,business_card_url, real_name,company_name, mobile,create_time, apply_method,company_id_pay,company_name_pay)
- VALUES(?,?,?,?,?,?,?,?,?) `
- _, err = o.Raw(sql, userId, item.BusinessCardUrl, item.RealName, item.CompanyName, mobile, time.Now(), item.ApplyMethod, companyIdPay, companyNamePay).Exec()
- if err != nil {
- return
- }
- msql := `UPDATE wx_user
- SET
- note = ?,
- is_note = 1,
- apply_method = ?,
- real_name=?,
- mobile=?
- WHERE user_id = ? `
- _, err = o.Raw(msql, item.CompanyName, item.ApplyMethod, item.RealName, mobile, userId).Exec()
- return
- }
- func GetApplyRecordCount(userId int) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT COUNT(1) AS count FROM cygx_apply_record WHERE user_id=? AND status=0 `
- err = o.Raw(sql, userId).QueryRow(&count)
- return
- }
|