Переглянути джерело

修改微信小程序二维码跳转页面,收单sql改成template

icole 4 роки тому
батько
коміт
627d65f3c0

+ 1 - 0
etc/i2bill-api.yaml

@@ -14,6 +14,7 @@ Transform:
 Weixin:
   Appid: wxb8a763ab9e81d0cb
   Secret: 95dc14b89d32fe91709bba8916f30f74
+  SharePage: pages/stuInput/stuInput
 JwtAuth:
   AccessSecret: 6hy789iu87
   AccessExpire: 604800

+ 3 - 2
internal/config/config.go

@@ -7,8 +7,9 @@ import (
 )
 
 type Weixin struct {
-	Appid  string
-	Secret string
+	Appid     string
+	Secret    string
+	SharePage string
 }
 type Config struct {
 	rest.RestConf

+ 1 - 1
internal/handler/acquirer_student/acquirer_student_total_handler.go

@@ -12,7 +12,7 @@ func AcquirerStudentTotalHandler(ctx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 
 		l := logic.NewAcquirerStudentTotalLogic(r.Context(), ctx)
-		resp, err := l.AcquirerStudentTotal()
+		resp, err := l.AcquirerStudentTotal(r)
 		if err != nil {
 			httpx.Error(w, err)
 		} else {

+ 1 - 1
internal/logic/acquirer_mkt_qr/acquirer_mkt_qr_update_logic.go

@@ -110,7 +110,7 @@ func (l *AcquirerMktQrUpdateLogic) AcquirerMktQrUpdate(r *http.Request) (*types.
 	//生成二维码
 	//scene, _ := utils.AesEncrypt([]byte(fmt.Sprintf("%d", userId)), []byte(l.svcCtx.Config.AesSecret))
 	sceneStr := fmt.Sprintf("%d", userId)
-	atr, err := l.svcCtx.Wechat.GenQrCode(sceneStr, "pages/code/code")
+	atr, err := l.svcCtx.Wechat.GenQrCode(sceneStr, l.svcCtx.Config.Weixin.SharePage)
 	if err != nil {
 		logx.Error(err.Error())
 		return &types.Response{500, err.Error(), nil}, nil

+ 31 - 24
internal/logic/acquirer_student/acquirer_student_total_logic.go

@@ -2,6 +2,8 @@ package logic
 
 import (
 	"context"
+	"git.i2edu.net/i2/i2-bill-erp/utils"
+	"net/http"
 	"time"
 
 	"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
+	r.ParseForm()
+	totalSta := r.Form.Get("create_time_sta")
+	totalEnd := r.Form.Get("create_time_end")
 	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 {
 		logx.Error(err.Error())
 		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 {
 		logx.Error(err.Error())
 		return &types.Response{500, err.Error(), nil}, nil
@@ -72,6 +77,8 @@ func (l *AcquirerStudentTotalLogic) AcquirerStudentTotal() (*types.Response, err
 			valide += t["total"].(int64)
 		case 58:
 			invalide += t["total"].(int64)
+		default:
+			untreated += t["total"].(int64)
 		}
 	}
 	res["invalide"] = invalide

+ 1 - 1
internal/logic/user/jz_qr_code_logic.go

@@ -37,7 +37,7 @@ func (l *JzQrCodeLogic) JzQrCode() (*types.JzQrcodeResponse, error) {
 	//	return nil, err
 	//}
 	userId := l.svcCtx.GetUserIdByJwt(l.ctx)
-	attr, err := l.svcCtx.Wechat.GenQrCode(fmt.Sprintf("%d", userId), "/pages/code/code")
+	attr, err := l.svcCtx.Wechat.GenQrCode(fmt.Sprintf("%d", userId), l.svcCtx.Config.Weixin.SharePage)
 	tx := l.svcCtx.DB.NewSession()
 	_, err = tx.Where("user_id = ?", userId).Update(map[string]interface{}{"qr": attr.Url})
 	if err != nil {

+ 1 - 1
internal/svc/wechat.go

@@ -133,7 +133,7 @@ func (wc *Wechat) GenQrCode(scene, page string) (*model.I2billSysAttachment, err
 		return nil, err
 	}
 	req := utils.Post("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + token)
-	req.JSONBody(map[string]interface{}{"scene": scene, "page": page})
+	req.JSONBody(map[string]interface{}{"scene": scene, "page": page, "is_hyaline": true})
 	resp, err := req.Response()
 	if err != nil {
 		return nil, err

+ 21 - 0
sqlconfig/i2bill_acquirer_student/i2bill_acquirer_student_total_check_select.tpl

@@ -0,0 +1,21 @@
+SELECT
+    count(*) total
+{{if .group_by }}
+        ,check_state
+{{end}}
+FROM
+    i2bill_acquirer_student
+WHERE
+    del_flag = 0
+    {{if .user_id}}
+        and user_id = '{{.user_id}}'
+    {{end}}
+    {{if  .create_time_sta }}
+        and create_time >= "{{.create_time_sta}}"
+    {{end}}
+    {{if .create_time_end }}
+        and create_time between '0000-00-00 00:00:00' and "{{.create_time_end}}"
+    {{end}}
+{{if .group_by }}
+GROUP BY   {{.group_by}}
+{{end}}

+ 3 - 3
sqlconfig/punch_clock/i2bill_acquirer_attendance_record_page_count.tpl

@@ -4,12 +4,12 @@ from
     i2bill_acquirer_attendance_record
 where
 del_flag = 0
-{{if ne .user_id ""}}
+{{if .user_id}}
     and user_id = {{.user_id}}
 {{end}}
-{{if ne .date_sta ""}}
+{{if .date_sta }}
     and date >= "{{.date_sta}}"
 {{end}}
-{{if ne .date_end ""}}
+{{if .date_end}}
     and date between '0000-00-00 00:00:00' and "{{.date_end}}"
 {{end}}

+ 3 - 3
sqlconfig/punch_clock/i2bill_acquirer_attendance_record_page_select.tpl

@@ -4,14 +4,14 @@ FROM
     i2bill_acquirer_attendance_record
 WHERE
     del_flag = 0
-    {{if ne .user_id ""}}
+    {{if .user_id }}
 
      and user_id = '{{.user_id}}'
     {{end}}
-    {{if ne .date_sta ""}}
+    {{if  .date_sta }}
     and date >= "{{.date_sta}}"
     {{end}}
-    {{if ne .date_end ""}}
+    {{if  .date_end }}
      and date between '0000-00-00 00:00:00' and "{{.date_end}}"
     {{end}}
 LIMIT {{.rows}} OFFSET {{.offset}}