wangchuanjin 5 жил өмнө
parent
commit
1e8804c2c2

+ 162 - 0
src/jfw/modules/distribution/src/service/action/capital.go

@@ -0,0 +1,162 @@
+//注销
+package action
+
+import (
+	. "api"
+	"fmt"
+	"qfw/util"
+	. "service/config"
+	"sort"
+	"strings"
+	"time"
+
+	"github.com/go-xweb/xweb"
+)
+
+type Capital struct {
+	*xweb.Action
+	list xweb.Mapper `xweb:"/capital/list"` //资金列表
+}
+
+type CapitalList struct {
+	Type     string //提现、上月结算、佣金、实名认证、代扣个税
+	Money    string //
+	Date     string //
+	Status   string //已申请、未结算
+	TaxCash  string //代扣个税
+	AuthCash string //实名认证
+}
+
+type SortList []*CapitalList
+
+func (s SortList) Len() int {
+	return len(s)
+}
+
+func (s SortList) Less(i, j int) bool {
+	a, _ := time.ParseInLocation(util.Date_Full_Layout, s[i].Date, time.Local)
+	b, _ := time.ParseInLocation(util.Date_Full_Layout, s[j].Date, time.Local)
+	return a.Unix() > b.Unix()
+}
+
+func (s SortList) Swap(i, j int) {
+	s[i], s[j] = s[j], s[i]
+}
+
+func init() {
+	xweb.AddAction(&Capital{})
+}
+
+//资金列表
+func (l *Capital) List() {
+	userId, _ := l.GetSession("userId").(string)
+	sl := SortList{}
+	dis_sale := Mysql.SelectBySql(`select commission,sale_status,createtime from dis_sale where uid=?`, userId)
+	if dis_sale != nil {
+		for _, v := range *dis_sale {
+			sl = append(sl, &CapitalList{
+				Type:   "佣金",
+				Money:  fmt.Sprintf("+%.2f", util.Float64All(v["commission"])/100),
+				Date:   util.ObjToString(v["createtime"]),
+				Status: "",
+			})
+		}
+	}
+	dis_count := Mysql.SelectBySql(`select count_cash,auth_cash,tax_cash,createtime from dis_count where uid=?`, userId)
+	if dis_count != nil {
+		for _, v := range *dis_count {
+			cl := &CapitalList{
+				Type: "上月结算",
+				Date: util.ObjToString(v["createtime"]),
+			}
+			if count_cash := util.Float64All(v["count_cash"]); count_cash > 0 {
+				cl.Money = fmt.Sprintf("¥%.2f", count_cash/100)
+			}
+			if tax_cash := util.Float64All(v["tax_cash"]); tax_cash > 0 {
+				cl.TaxCash = fmt.Sprintf("-%.2f", tax_cash/100)
+			}
+			if auth_cash := util.Float64All(v["auth_cash"]); auth_cash > 0 {
+				cl.AuthCash = fmt.Sprintf("-%.2f", auth_cash/100)
+			}
+			if cl.Money != "" || cl.TaxCash != "" || cl.AuthCash != "" {
+				sl = append(sl, cl)
+			}
+		}
+	}
+	dis_cashout := Mysql.SelectBySql(`select money,cashout_status,createtime from dis_cashout where uid=?`, userId)
+	if dis_cashout != nil {
+		for _, v := range *dis_cashout {
+			status := ""
+			cashout_status := util.IntAll(v["cashout_status"])
+			if cashout_status == 0 {
+				status = "已申请"
+			} else if cashout_status == -1 {
+				continue
+			}
+			if money := util.Float64All(v["money"]); money > 0 {
+				sl = append(sl, &CapitalList{
+					Type:   "提现",
+					Money:  fmt.Sprintf("-%.2f", money/100),
+					Date:   util.ObjToString(v["createtime"]),
+					Status: status,
+				})
+			}
+		}
+	}
+	sort.Sort(sl)
+	all := []M{}
+	array := []M{}
+	prevDate := ""
+	for k, v := range sl {
+		dates := strings.Split(strings.Split(v.Date, " ")[0], "-")
+		if len(dates) != 3 {
+			continue
+		}
+		yearMonth := fmt.Sprintf("%s年 %s月", dates[0], dates[1])
+		day := fmt.Sprintf("%s日", dates[2])
+		if prevDate == "" {
+			prevDate = yearMonth
+		}
+		if prevDate != yearMonth {
+			all = append(all, M{
+				"date": yearMonth,
+				"list": array,
+			})
+			array = []M{}
+			prevDate = yearMonth
+		}
+		if v.AuthCash != "" {
+			array = append(array, M{
+				"day":    day,
+				"type":   "实名认证",
+				"status": "",
+				"money":  v.AuthCash,
+			})
+		}
+		if v.TaxCash != "" {
+			array = append(array, M{
+				"day":    day,
+				"type":   "代扣个税",
+				"status": "",
+				"money":  v.TaxCash,
+			})
+		}
+		array = append(array, M{
+			"day":    day,
+			"type":   v.Type,
+			"status": v.Status,
+			"money":  v.Money,
+		})
+		if k == len(sl)-1 {
+			all = append(all, M{
+				"date": yearMonth,
+				"list": array,
+			})
+			array = []M{}
+			prevDate = yearMonth
+		}
+	}
+	l.ServeJson(Result{
+		Data: all,
+	})
+}

+ 0 - 2
src/jfw/modules/distribution/src/service/action/logoff.go

@@ -12,14 +12,12 @@ import (
 	"github.com/go-xweb/xweb"
 )
 
-//申请成为伙伴接口
 type Logoff struct {
 	*xweb.Action
 	accountinfo xweb.Mapper `xweb:"/logoff/accountinfo"` //账户详情
 	sure        xweb.Mapper `xweb:"/logoff/sure"`        //注销
 }
 
-//申请接口(个人和企业)
 func init() {
 	xweb.AddAction(&Logoff{})
 }

+ 9 - 4
src/jfw/modules/distribution/src/timetask/timetask.go

@@ -47,6 +47,7 @@ func init() {
 	go func() {
 		for _, v := range []string{"超级订阅", "数据导出", "数据报告", "线上课程"} {
 			shareCount(v)
+			time.Sleep(50 * time.Millisecond)
 		}
 	}()
 }
@@ -318,11 +319,15 @@ func shareCount(product string) {
 		if inc < inc_min {
 			inc += inc_min
 		}
-		duration := r.Intn(duration_max)
-		if duration < duration_min {
-			duration += duration_min
+		duration_m := r.Intn(duration_max)
+		if duration_m < duration_min {
+			duration_m += duration_min
 		}
-		d := time.Duration(duration) * time.Minute
+		duration_s := r.Intn(duration_max)
+		if duration_s < duration_min {
+			duration_s += duration_min
+		}
+		d := time.Duration(duration_m)*time.Minute + time.Duration(duration_s)*time.Second
 		MQFW.Update("dis_product", map[string]interface{}{
 			"s_name": product,
 		}, map[string]interface{}{