|
|
@@ -211,6 +211,8 @@ type Useraccount struct {
|
|
|
Auditsrc int32 `json:"auditsrc" xorm:"AUDITSRC"` // 审核来源 - 1:管理端 2:终端
|
|
|
Rootuserid int64 `json:"rootuserid" xorm:"ROOTUSERID"` // 根用户ID
|
|
|
Canrecommend int32 `json:"canrecommend" xorm:"CANRECOMMEND"` // 是否可推荐 - 0:不可 1;可
|
|
|
+
|
|
|
+ TodayRefercount int `json:"todayrefercount" xorm:"-"` // 今日推荐人数
|
|
|
}
|
|
|
|
|
|
// TableName is USERACCOUNT
|
|
|
@@ -633,6 +635,17 @@ func GetUserAccount(userID int) (*Useraccount, error) {
|
|
|
return nil, nil
|
|
|
}
|
|
|
|
|
|
+ // 统计今日推荐人数
|
|
|
+ type tmp struct {
|
|
|
+ TodayRefercount int `xorm:"TODAYREFERCOUNT"`
|
|
|
+ }
|
|
|
+ t := new(tmp)
|
|
|
+ sql := fmt.Sprintf("select count(t.userid) TODAYREFERCOUNT from useraccount t where to_char(t.createtime, 'yyyymmdd') = to_char(sysdate, 'yyyymmdd') and t.REFEREEUSERID = %v", userAccount.Userid)
|
|
|
+ if _, err := engine.SQL(sql).Get(t); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ userAccount.TodayRefercount = t.TodayRefercount
|
|
|
+
|
|
|
return &userAccount, nil
|
|
|
}
|
|
|
|
|
|
@@ -1196,3 +1209,44 @@ func (r *RelatedTaAccount) GetDataEx() (interface{}, error) {
|
|
|
}
|
|
|
return sData, err
|
|
|
}
|
|
|
+
|
|
|
+// 我的推荐列表
|
|
|
+type MyRefer struct {
|
|
|
+ Accountname string `json:"accountname" xorm:"ACCOUNTNAME"` // 用户名(脱敏)
|
|
|
+ Score float64 `json:"score" xorm:"SCORE"` // 积分
|
|
|
+ CREATETIME string `json:"createtime" xorm:"CREATETIME"` // 时间(yyyy-mm-dd)
|
|
|
+
|
|
|
+ UserID int `json:"-" form:"userid" binding:"required"` // 用户ID
|
|
|
+
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyRefer) calc() {
|
|
|
+ r.Accountname = EncryptByStar(r.Accountname)
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyRefer) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+ select
|
|
|
+ u.ACCOUNTNAME,
|
|
|
+ t.SCORE,
|
|
|
+ to_char(t.CREATETIME, 'yyyy-mm-dd') CREATETIME
|
|
|
+ from THJ_USERSCORELOG t
|
|
|
+ inner join useraccount u on u.userid = t.userid
|
|
|
+ where t.RELATEDORDERID = %v
|
|
|
+ order by t.createtime desc
|
|
|
+`
|
|
|
+ sqlId.FormatParam(r.UserID)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyRefer) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
+ sData := make([]MyRefer, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ total := 0
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ total = sData[i].Total
|
|
|
+ }
|
|
|
+ return sData, err, r.Page, r.PageSize, total
|
|
|
+}
|