123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- package eta_trial
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type EtaTrialApproval struct {
- ApprovalId int `orm:"column(approval_id);pk" description:"eta审批id"`
- UserName string `description:"客户名称"`
- CompanyName string `description:"客户公司姓名"`
- Position string `description:"职位"`
- Mobile string `description:"手机号"`
- SellerId int `description:"销售id"`
- Seller string `description:"销售员名称"`
- CreateTime time.Time
- ModifyTime time.Time
- ApprovalContent string `description:"待审内容"`
- ApplyMethod int `description:"申请类型:1:申请账号 2:申请启用"`
- ApplyReasons string `description:"申请理由"`
- ApprovalRemark string `description:"审批描述"`
- ApprovalStatus string `description:"审批状态 '待审批','已审批','驳回','已撤回'"`
- }
- func GetETATrialApprovalByMobile(mobile string) (item *EtaTrialApproval, err error) {
- sql := `SELECT * FROM eta_trial_approval WHERE mobile = ? ORDER BY create_time DESC LIMIT 1`
- o := orm.NewOrm()
- err = o.Raw(sql, mobile).QueryRow(&item)
- return
- }
- // AddETATrialApproval 新增审批
- func AddETATrialApproval(item *EtaTrialApproval) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- type ETATrialListResp struct {
- BannedList []*ETATrialAddRespItem
- RepeatList []*ETATrialAddRespItem
- SuccessList []*ETATrialAddRespItem
- InternalList []*ETATrialAddRespItem
- }
- type ETATrialAddRespItem struct {
- UserName string `description:"客户名称"`
- CompanyName string `description:"客户公司姓名"`
- Position string `description:"职位"`
- Mobile string `description:"手机号"`
- Seller string `description:"销售"`
- }
- type ETAAddEnableReq struct {
- UserName string `description:"客户名称"`
- CompanyName string `description:"客户公司姓名"`
- Position string `description:"职位"`
- Mobile string `description:"手机号"`
- ApplyReasons string `description:"申请理由"`
- }
- type ETATrialApplyRevokeReq struct {
- Mobile string `description:"客户手机号"`
- }
- // 消息撤回
- func RevokeApproval(mobile string) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE eta_trial_approval SET approval_status=4,modify_time=NOW()
- WHERE mobile=? AND approval_status=1 `
- _, err = o.Raw(sql, mobile).Exec()
- return
- }
- func DelApproval(approvalId int) (err error) {
- o := orm.NewOrm()
- sql := `DELETE FROM eta_trial_approval WHERE approval_id = ? `
- _, err = o.Raw(sql, approvalId).Exec()
- return
- }
- func RejectApproval(approvalId int, reason string) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE eta_trial_approval SET approval_status=3,modify_time=NOW(), approval_remark = ?
- WHERE approval_id=? `
- _, err = o.Raw(sql, reason, approvalId).Exec()
- return
- }
- func ApprovalTrial(approvalId int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE eta_trial_approval SET approval_status=2,modify_time=NOW()
- WHERE approval_id=? `
- _, err = o.Raw(sql, approvalId).Exec()
- return
- }
- func GetETATrialApprovalById(approvalId int) (item *EtaTrialApproval, err error) {
- sql := `SELECT * FROM eta_trial_approval WHERE approval_id = ? `
- o := orm.NewOrm()
- err = o.Raw(sql, approvalId).QueryRow(&item)
- return
- }
- func GetETATrialApprovalBySellerId(condition, sortStr string, pars []interface{}, startSize, pageSize int) (items []*EtaTrialApprovalResp, err error) {
- sql := `SELECT
- a.*, b.account, b.password
- FROM
- eta_trial_approval AS a
- LEFT JOIN eta_trial AS b ON a.mobile = b.mobile AND a.approval_status = '已审批'
- WHERE
- 1 = 1 AND a.seller_id = ? `
- o := orm.NewOrm()
- if condition != "" {
- sql += condition
- }
- sql += sortStr + ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- func GetETATrialApprovalCountBySellerId(condition, sortStr string, pars []interface{}) (count int, err error) {
- sql := `SELECT COUNT(1) AS count FROM eta_trial_approval AS a WHERE 1=1 AND a.seller_id = ? `
- o := orm.NewOrm()
- if condition != "" {
- sql += condition
- }
- err = o.Raw(sql, pars).QueryRow(&count)
- return
- }
- type ETATrialApprovalListRespList struct {
- List []*EtaTrialApprovalResp
- Paging *paging.PagingItem
- }
- type EtaTrialApprovalResp struct {
- ApprovalId int `orm:"column(approval_id);pk" description:"eta审批id"`
- UserName string `description:"客户名称"`
- CompanyName string `description:"客户公司姓名"`
- Position string `description:"职位"`
- Mobile string `description:"手机号"`
- SellerId int `description:"销售id"`
- Seller string `description:"销售员名称"`
- CreateTime string
- ModifyTime string
- ApprovalContent string `description:"待审内容"`
- ApplyMethod int `description:"申请类型:1:申请账号 2:申请启用"`
- ApplyReasons string `description:"申请理由"`
- ApprovalRemark string `description:"审批描述"`
- ApprovalStatus string `description:"审批状态 '待审批','已审批','驳回','已撤回'"`
- Account string `description:"账号"`
- Password string `description:"密码-明文"`
- }
- func GetETATrialApprovalList(condition, sortStr string, pars []interface{}, startSize, pageSize int) (items []*EtaTrialApprovalResp, err error) {
- sql := `SELECT * FROM eta_trial_approval WHERE 1=1 `
- o := orm.NewOrm()
- if condition != "" {
- sql += condition
- }
- sql += sortStr + ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- func GetETATrialApprovalListCount(condition string, pars []interface{}) (count int, err error) {
- sql := `SELECT COUNT(1) AS count FROM eta_trial_approval WHERE 1=1 `
- o := orm.NewOrm()
- if condition != "" {
- sql += condition
- }
- err = o.Raw(sql, pars).QueryRow(&count)
- return
- }
- type RevokeReq struct {
- Mobile string
- }
- type DelReq struct {
- ApprovalId int
- }
- type RejectReq struct {
- ApprovalId int
- RejectReason string
- }
- func ResubmitTrialNoReasons(userName, companyName, position string, approvalId int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE eta_trial_approval SET approval_status=1,modify_time=NOW(), user_name = ?,company_name=?, position= ?
- WHERE approval_id=? `
- _, err = o.Raw(sql, userName, companyName, position, approvalId).Exec()
- return
- }
- func ResubmitTrial(approvalId int, applyReasons string) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE eta_trial_approval SET approval_status=1,modify_time=NOW(), apply_reasons = ?
- WHERE approval_id=? `
- _, err = o.Raw(sql, applyReasons, approvalId).Exec()
- return
- }
|