dengbiao 5 månader sedan
förälder
incheckning
9ac5050af7
1 ändrade filer med 23 tillägg och 21 borttagningar
  1. +23
    -21
      app/admin/svc/enterprise_manage/svc_self_support_for_school.go

+ 23
- 21
app/admin/svc/enterprise_manage/svc_self_support_for_school.go Visa fil

@@ -9,6 +9,8 @@ import (
enum2 "applet/app/enum"
"applet/app/utils"
"errors"
"fmt"
"github.com/syyongx/php2go"
"time"
)

@@ -707,7 +709,9 @@ func SelfSupportForSchoolOrdList(req md.SelfSupportForSchoolOrdListReq) (resp []

func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (personNum, count int64, consumeAmount, alreadyPayAmount, waitPayAmount, refundPayAmount float64, err error) {
var classWithUserIdentityIdsOne []int
var classWithUserIdentityIdsOneStr []string
var classWithUserIdentityIdsTwo []int
var classWithUserIdentityIdsTwoStr []string
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
if req.ClassId != 0 {
@@ -717,6 +721,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
for _, v := range *classWithUsers {
classWithUserIdentityIdsOne = append(classWithUserIdentityIdsOne, v.UserIdentityId)
classWithUserIdentityIdsOneStr = append(classWithUserIdentityIdsOneStr, utils.IntToStr(v.UserIdentityId))
}
}
if req.GradeId != 0 {
@@ -736,18 +741,19 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
for _, v := range *classWithUsers {
classWithUserIdentityIdsTwo = append(classWithUserIdentityIdsTwo, v.UserIdentityId)
classWithUserIdentityIdsTwoStr = append(classWithUserIdentityIdsTwoStr, utils.IntToStr(v.UserIdentityId))
}
}

sess1 := db.Db.Where("1=1")
sess2 := db.Db.Where("1=1")
sqlStr := "SELECT COUNT(*) as total FROM `self_support_for_school_ord` \nLEFT JOIN `user_identity` ON self_support_for_school_ord.user_identity_id = user_identity.id \nLEFT JOIN `enterprise` ON enterprise.id = user_identity.enterprise_id \nLEFT JOIN `user` ON user.id = user_identity.uid \nLEFT JOIN `class_with_user` ON class_with_user.user_identity_id = user_identity.id \nLEFT JOIN `class` ON class_with_user.class_id = class.id \nLEFT JOIN `grade` ON class.grade_id = grade.id where 1=1 "
sess3 := db.Db.Where("1=1")
sess4 := db.Db.Where("1=1")
sess5 := db.Db.Where("1=1")
sess6 := db.Db.Where("1=1")
if req.EnterpriseId != 0 {
sess1.And("self_support_for_school_ord.enterprise_id =?", req.EnterpriseId)
sess2.And("self_support_for_school_ord.enterprise_id =?", req.EnterpriseId)
sqlStr += fmt.Sprintf(" and self_support_for_school_ord.enterprise_id = %d", req.EnterpriseId)
sess3.And("self_support_for_school_ord.enterprise_id =?", req.EnterpriseId)
sess4.And("self_support_for_school_ord.enterprise_id =?", req.EnterpriseId)
sess5.And("self_support_for_school_ord.enterprise_id =?", req.EnterpriseId)
@@ -755,7 +761,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
if req.StartDate != "" {
sess1.And("self_support_for_school_ord.face_time >= ?", req.StartDate)
sess2.And("self_support_for_school_ord.face_time >= ?", req.StartDate)
sqlStr += fmt.Sprintf(" and self_support_for_school_ord.face_time >= %s", req.StartDate)
sess3.And("self_support_for_school_ord.face_time >= ?", req.StartDate)
sess4.And("self_support_for_school_ord.face_time >= ?", req.StartDate)
sess5.And("self_support_for_school_ord.face_time >= ?", req.StartDate)
@@ -763,7 +769,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
if req.EndDate != "" {
sess1.And("self_support_for_school_ord.face_time <= ?", req.EndDate)
sess2.And("self_support_for_school_ord.face_time <= ?", req.EndDate)
sqlStr += fmt.Sprintf(" and self_support_for_school_ord.face_time <= %s", req.EndDate)
sess3.And("self_support_for_school_ord.face_time <= ?", req.EndDate)
sess4.And("self_support_for_school_ord.face_time <= ?", req.EndDate)
sess5.And("self_support_for_school_ord.face_time <= ?", req.EndDate)
@@ -771,7 +777,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
if req.OrderStatus != 0 {
sess1.And("self_support_for_school_ord.order_status = ?", req.OrderStatus)
sess2.And("self_support_for_school_ord.order_status = ?", req.OrderStatus)
sqlStr += fmt.Sprintf(" and self_support_for_school_ord.order_status = %d", req.OrderStatus)
sess3.And("self_support_for_school_ord.order_status = ?", req.OrderStatus)
sess4.And("self_support_for_school_ord.order_status = ?", req.OrderStatus)
sess5.And("self_support_for_school_ord.order_status = ?", req.OrderStatus)
@@ -779,7 +785,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
if req.OutTradeNo != "" {
sess1.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%")
sess2.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%")
sqlStr += " and self_support_for_school_ord.out_order_no like %" + req.OutTradeNo + "%"
sess3.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%")
sess4.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%")
sess5.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%")
@@ -787,7 +793,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
if req.EnterpriseKind != 0 {
sess1.And("enterprise.kind = ?", req.EnterpriseKind)
sess2.And("enterprise.kind = ?", req.EnterpriseKind)
sqlStr += fmt.Sprintf(" and enterprise.kind = %d", req.EnterpriseKind)
sess3.And("enterprise.kind = ?", req.EnterpriseKind)
sess4.And("enterprise.kind = ?", req.EnterpriseKind)
sess5.And("enterprise.kind = ?", req.EnterpriseKind)
@@ -796,7 +802,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
if req.IsTeacher != 0 {
if req.IsTeacher == 1 {
sess1.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher)
sess2.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher)
sqlStr += fmt.Sprintf(" and user_identity.identity = %d", enum2.UserIdentityForCentralKitchenForTeacher)
sess3.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher)
sess4.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher)
sess5.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher)
@@ -804,7 +810,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
if req.IsTeacher == 2 {
sess1.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher)
sess2.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher)
sqlStr += fmt.Sprintf(" and user_identity.identity != %d", enum2.UserIdentityForCentralKitchenForTeacher)
sess3.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher)
sess4.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher)
sess5.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher)
@@ -814,7 +820,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p

if req.Name != "" {
sess1.And("user_identity.name like ?", "%"+req.Name+"%")
sess2.And("user_identity.name like ?", "%"+req.Name+"%")
sqlStr += " and user_identity.name like %" + req.Name + "%"
sess3.And("user_identity.name like ?", "%"+req.Name+"%")
sess4.And("user_identity.name like ?", "%"+req.Name+"%")
sess5.And("user_identity.name like ?", "%"+req.Name+"%")
@@ -822,23 +828,25 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
if req.Phone != "" {
sess1.And("user.phone like ?", "%"+req.Phone+"%")
sess2.And("user.phone like ?", "%"+req.Phone+"%")
sqlStr += " and user.phone like %" + req.Phone + "%"
sess3.And("user.phone like ?", "%"+req.Phone+"%")
sess4.And("user.phone like ?", "%"+req.Phone+"%")
sess5.And("user.phone like ?", "%"+req.Phone+"%")
sess6.And("user.phone like ?", "%"+req.Phone+"%")
}
if len(classWithUserIdentityIdsOne) > 0 {
userIdentityStr := php2go.Implode(",", classWithUserIdentityIdsOneStr)
sqlStr += fmt.Sprintf(" and user_identity.id In (%s)", userIdentityStr)
sess1.In("user_identity.id", classWithUserIdentityIdsOne)
sess2.In("user_identity.id", classWithUserIdentityIdsOne)
sess3.In("user_identity.id", classWithUserIdentityIdsOne)
sess4.In("user_identity.id", classWithUserIdentityIdsOne)
sess5.In("user_identity.id", classWithUserIdentityIdsOne)
sess6.In("user_identity.id", classWithUserIdentityIdsOne)
}
if len(classWithUserIdentityIdsTwo) > 0 {
userIdentityStr := php2go.Implode(",", classWithUserIdentityIdsTwoStr)
sqlStr += fmt.Sprintf(" and user_identity.id In (%s)", userIdentityStr)
sess1.In("user_identity.id", classWithUserIdentityIdsTwo)
sess2.In("user_identity.id", classWithUserIdentityIdsTwo)
sess3.In("user_identity.id", classWithUserIdentityIdsTwo)
sess4.In("user_identity.id", classWithUserIdentityIdsTwo)
sess5.In("user_identity.id", classWithUserIdentityIdsTwo)
@@ -859,17 +867,11 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
return 0, 0, 0, 0, 0, 0, err
}

count, err = sess2.
Join("LEFT", "user_identity", "self_support_for_school_ord.user_identity_id = user_identity.id").
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id").
Join("LEFT", "user", "user.id = user_identity.uid").
Join("LEFT", "class_with_user", "class_with_user.user_identity_id = user_identity.id").
Join("LEFT", "class", "class_with_user.class_id = class.id").
Join("LEFT", "grade", "class.grade_id = grade.id").
FindAndCount(&m)
mapArr1, err := db.QueryNativeString(db.Db, sqlStr)
if err != nil {
return 0, 0, 0, 0, 0, 0, err
}
count = utils.StrToInt64(mapArr1[0]["total"])

var mm db.SelfSupportForSchoolOrdWithUserIdentity
consumeAmount, err = sess3.


Laddar…
Avbryt
Spara