master
howell 4 years ago
parent e4885158f1
commit f3c4108ab6

@ -71,6 +71,12 @@ func (i *Income) Profit(c *gin.Context) {
back.Suc(c, "获取成功", res)
}
func (i *Income) Team(c *gin.Context) {
userId, _ := common.GetAppUserId(c)
res := user.IncomeLogic.Team(userId)
back.Suc(c, "获取成功", res)
}
type argsDayIncome struct {
Month string `json:"month" form:"month"`
}

@ -48,6 +48,46 @@ type Profit struct {
ETotal decimal.Decimal
}
type Person struct {
HeadImgUrl string
Nickname string
Phone string
WechatNo string
RemarkName string
Count int
Flag int
Amount decimal.Decimal
}
func (i *incomeLogic) Team(userID uint) (data []Person) {
if userID == 0 {
return
}
var self user.RecookUserInfoModel
mysql.Db.First(&self, "id = ?", userID)
if self.Level != 2{
return
}
var u1 []user.RecookUserInfoModel
mysql.Db.Preload("OrderList", "status = 4").Where("parent_id = ?", userID).Find(&u1)
for _, v := range u1 {
amount := decimal.Zero
for _, j := range v.OrderList {
amount = amount.Add(j.ActualTotalAmount)
}
data = append(data, Person{
HeadImgUrl: v.HeadImgUrl,
Nickname: v.Nickname,
Phone: v.Mobile,
WechatNo: v.WechatNo,
RemarkName: v.RemarkName,
Count: len(v.OrderList),
Amount: amount,
})
}
return
}
func (i *incomeLogic) Profit(userID uint) (res Profit) {
var pr []order.Profit
mysql.Db.Find(&pr, "user_id = ? and status <> 1 and base > 0 and income > 0", userID)

@ -5,6 +5,7 @@ import (
"github.com/jinzhu/gorm"
"recook/internal/model/user"
"recook/internal/v2/lib/db"
manage "recook/internal/v2/model/recook/order"
)
type RecookUserInfoModel struct {
@ -27,12 +28,13 @@ type RecookUserInfoModel struct {
IDCard string
Province string
City string
Wallet user.Wallet `gorm:"foreignKey:UserID"`
Level int `json:"level"`
ParentID uint `json:"parent_id"`
UpgradeTime1 formatime.Second `json:"upgrade_time1"`
UpgradeTime2 formatime.Second `json:"upgrade_time2"`
AgentID uint `json:"agent_id"`
Wallet user.Wallet `gorm:"foreignKey:UserID"`
Level int `json:"level"`
ParentID uint `json:"parent_id"`
UpgradeTime1 formatime.Second `json:"upgrade_time1"`
UpgradeTime2 formatime.Second `json:"upgrade_time2"`
AgentID uint `json:"agent_id"`
OrderList []manage.RecookOrderInfoModel `json:"-" gorm:"foreignKey:user_id"`
}
// TableName sets the insert table name for this struct type

@ -58,6 +58,7 @@ func routerApp(appRouter *gin.RouterGroup) {
{
userRouter.POST("profit", incomeController.Profit)
userRouter.POST("team", incomeController.Team)
//userRouter.POST("income/accumulate", incomeController.Accumulate) // 累计收益
//userRouter.POST("income/month_income", incomeController.MonthIncome) // 年度月收益
userRouter.POST("income/purchase_accumulate", incomeController.PurchaseAccumulate) // 累计自购收益

Loading…
Cancel
Save