|
@@ -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,
|
|
|
+ })
|
|
|
+}
|