|
@@ -2,6 +2,8 @@ package logic
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"context"
|
|
"context"
|
|
|
|
|
+ "git.i2edu.net/i2/i2-bill-erp/utils"
|
|
|
|
|
+ "net/http"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
"git.i2edu.net/i2/i2-bill-api/internal/svc"
|
|
"git.i2edu.net/i2/i2-bill-api/internal/svc"
|
|
@@ -24,38 +26,41 @@ func NewAcquirerStudentTotalLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (l *AcquirerStudentTotalLogic) AcquirerStudentTotal() (*types.Response, error) {
|
|
|
|
|
|
|
+func (l *AcquirerStudentTotalLogic) AcquirerStudentTotal(r *http.Request) (*types.Response, error) {
|
|
|
// todo: add your logic here and delete this line
|
|
// todo: add your logic here and delete this line
|
|
|
|
|
+ r.ParseForm()
|
|
|
|
|
+ totalSta := r.Form.Get("create_time_sta")
|
|
|
|
|
+ totalEnd := r.Form.Get("create_time_end")
|
|
|
userId := l.svcCtx.GetUserIdByJwt(l.ctx)
|
|
userId := l.svcCtx.GetUserIdByJwt(l.ctx)
|
|
|
- sqlTotalByCheck := `
|
|
|
|
|
- SELECT
|
|
|
|
|
- count(*) total ,check_state
|
|
|
|
|
- FROM
|
|
|
|
|
- i2bill_mkt_part_time_user
|
|
|
|
|
- WHERE
|
|
|
|
|
- del_flag = 0
|
|
|
|
|
- and user_id = ?
|
|
|
|
|
- GROUP BY check_state`
|
|
|
|
|
|
|
+ if totalEnd != "" {
|
|
|
|
|
+ end, err := time.Parse("2006-01-02", totalEnd)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return &types.Response{500, err.Error(), nil}, nil
|
|
|
|
|
+ }
|
|
|
|
|
+ totalEnd = end.Add(time.Second*24*60*60 - 1*time.Second).Format("2006-01-02 15:04:05")
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ totalParams := make(map[string]interface{})
|
|
|
|
|
+ totalParams["create_time_sta"] = totalSta
|
|
|
|
|
+ totalParams["create_time_end"] = totalEnd
|
|
|
|
|
+ totalParams["user_id"] = userId
|
|
|
|
|
+ totalParams["group_by"] = "check_state"
|
|
|
|
|
|
|
|
- sqlTotalByToDay := `
|
|
|
|
|
- SELECT
|
|
|
|
|
- count(*) total
|
|
|
|
|
- FROM
|
|
|
|
|
- i2bill_mkt_part_time_user
|
|
|
|
|
- WHERE
|
|
|
|
|
- del_flag = 0
|
|
|
|
|
- and user_id = ?
|
|
|
|
|
- and create_time between ? and ?`
|
|
|
|
|
|
|
+ timeNow := time.Now()
|
|
|
|
|
+ start := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local)
|
|
|
|
|
+ end := start.Add(24*60*60*time.Second - 1*time.Second)
|
|
|
|
|
+ todayParams := make(map[string]interface{})
|
|
|
|
|
+ todayParams["create_time_sta"] = start
|
|
|
|
|
+ todayParams["create_time_end"] = end
|
|
|
|
|
+ todayParams["user_id"] = userId
|
|
|
|
|
|
|
|
- totalByCheck, err := l.svcCtx.DB.NewSession().SQL(sqlTotalByCheck, userId).Query().List()
|
|
|
|
|
|
|
+ totalByCheck, err := utils.AllSearch(l.svcCtx.DB, "i2bill_acquirer_student", "total_check", "i2bill_acquirer_student", totalParams)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
logx.Error(err.Error())
|
|
logx.Error(err.Error())
|
|
|
return &types.Response{500, err.Error(), nil}, nil
|
|
return &types.Response{500, err.Error(), nil}, nil
|
|
|
}
|
|
}
|
|
|
- timeNow := time.Now()
|
|
|
|
|
- start := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local)
|
|
|
|
|
- end := start.Add(24*60*60*time.Second - 1*time.Second)
|
|
|
|
|
- totalDay, err := l.svcCtx.DB.NewSession().SQL(sqlTotalByToDay, userId, start, end).Query().List()
|
|
|
|
|
|
|
+
|
|
|
|
|
+ totalDay, err := utils.AllSearch(l.svcCtx.DB, "i2bill_acquirer_student", "total_check", "i2bill_acquirer_student", todayParams)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
logx.Error(err.Error())
|
|
logx.Error(err.Error())
|
|
|
return &types.Response{500, err.Error(), nil}, nil
|
|
return &types.Response{500, err.Error(), nil}, nil
|
|
@@ -72,6 +77,8 @@ func (l *AcquirerStudentTotalLogic) AcquirerStudentTotal() (*types.Response, err
|
|
|
valide += t["total"].(int64)
|
|
valide += t["total"].(int64)
|
|
|
case 58:
|
|
case 58:
|
|
|
invalide += t["total"].(int64)
|
|
invalide += t["total"].(int64)
|
|
|
|
|
+ default:
|
|
|
|
|
+ untreated += t["total"].(int64)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
res["invalide"] = invalide
|
|
res["invalide"] = invalide
|