Browse Source

Merge branch 'dev2.10.12' of http://192.168.3.207:10080/qmx/jy into dev2.10.12

wangshan 5 năm trước cách đây
mục cha
commit
13067ed0a6

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

@@ -0,0 +1,169 @@
+//注销
+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 commission,count_cash,auth_cash,tax_cash,count_status,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 util.IntAll(v["count_status"]) == 2 {
+				if commission := util.Float64All(v["commission"]); commission > 0 {
+					cl.Money = fmt.Sprintf("¥%.2f", commission/100)
+				}
+				cl.Status = "未结算"
+			} else {
+				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{})
 }

+ 20 - 13
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)
 		}
 	}()
 }
@@ -107,8 +108,7 @@ func settlement() {
 				log.Println(uid, "佣金异常不进行结算", "佣金", commission)
 				continue
 			}
-			count_code := VarOrderCode.Get() //结算单号
-			var can_cash int64               //可提现金额
+			var can_cash int64 //可提现金额
 			account := Mysql.SelectBySql(`select money from account where uid=?`, uid)
 			if account != nil && len(*account) > 0 {
 				can_cash, _ = (*account)[0]["money"].(int64)
@@ -117,16 +117,20 @@ func settlement() {
 				continue
 			}
 			var sFx *settlementFx
-			var partner_auth_cash int64 //认证费用
+			var partner_auth_cash int64      //认证费用
+			count_code := VarOrderCode.Get() //结算单号
+			nowFormat := util.NowFormat(util.Date_Full_Layout)
 			partner := Mysql.SelectBySql(`select a.name,a.type,a.auth_cost,a.auth_status,b.legal_idcard from dis_partner a left join dis_auth b on (b.auth_status=1 and a.id=b.partner_id) where a.uid=?`, uid)
 			if partner != nil && len(*partner) > 0 {
-				auth_status, _ := (*partner)[0]["auth_status"].(int64)
-				if auth_status == 0 {
-					log.Println(uid, "没有认证,不进行结算")
-					continue
-				}
 				partner_type, _ := (*partner)[0]["type"].(int64)
 				if partner_type == 1 {
+					auth_status, _ := (*partner)[0]["auth_status"].(int64)
+					if auth_status == 0 {
+						Mysql.InsertBySql(`insert into dis_count (uid,code,commission,sale_cash,count_cash,can_cash,auth_cash,tax_cash,count_status,createtime,timestamp) values (?,?,?,?,?,?,?,?,?,?,?)`,
+							uid, count_code, commission, sale_money, 0, can_cash, 0, 0, 2, nowFormat, nowFormat)
+						log.Println(uid, "还没有认证,不进行实际结算,但记录资金流水")
+						continue
+					}
 					sFx = &settlementFx{}
 					sFx.name, _ = (*partner)[0]["name"].(string)           //姓名
 					sFx.idcard, _ = (*partner)[0]["legal_idcard"].(string) //身份证号
@@ -152,7 +156,6 @@ func settlement() {
 				log.Println(uid, "结算金额异常,不进行结算")
 				continue
 			}
-			nowFormat := util.NowFormat(util.Date_Full_Layout)
 			if Mysql.ExecTx("结算定时任务", func(tx *sql.Tx) bool {
 				ok_1 := Mysql.InsertBySqlByTx(tx, `insert into dis_count (uid,code,commission,sale_cash,count_cash,can_cash,auth_cash,tax_cash,count_status,createtime,timestamp) values (?,?,?,?,?,?,?,?,?,?,?)`,
 					uid, count_code, commission, sale_money, count_cash, can_cash, partner_auth_cash, tax_cash, 0, nowFormat, nowFormat)
@@ -318,11 +321,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
+		}
+		duration_s := r.Intn(duration_max)
+		if duration_s < duration_min {
+			duration_s += duration_min
 		}
-		d := time.Duration(duration) * time.Minute
+		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{}{