Browse Source

update

tmp
dengbiao 6 months ago
parent
commit
f96042f321
1 changed files with 18 additions and 25 deletions
  1. +18
    -25
      app/admin/svc/enterprise_manage/svc_self_support_for_school.go

+ 18
- 25
app/admin/svc/enterprise_manage/svc_self_support_for_school.go View File

@@ -745,14 +745,14 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
}

sess1 := db.Db.Where("1=1")
sqlStr1 := "SELECT self_support_for_school_ord.user_identity_id 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 "
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)
sqlStr1 += fmt.Sprintf(" and self_support_for_school_ord.enterprise_id = %d", 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)
@@ -760,7 +760,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
sess6.And("self_support_for_school_ord.enterprise_id =?", req.EnterpriseId)
}
if req.StartDate != "" {
sess1.And("self_support_for_school_ord.face_time >= ?", req.StartDate)
sqlStr1 += fmt.Sprintf(" and self_support_for_school_ord.face_time >= %s", 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)
@@ -768,7 +768,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
sess6.And("self_support_for_school_ord.face_time >= ?", req.StartDate)
}
if req.EndDate != "" {
sess1.And("self_support_for_school_ord.face_time <= ?", req.EndDate)
sqlStr1 += fmt.Sprintf(" and self_support_for_school_ord.face_time <= %s", 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)
@@ -776,7 +776,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
sess6.And("self_support_for_school_ord.face_time <= ?", req.EndDate)
}
if req.OrderStatus != 0 {
sess1.And("self_support_for_school_ord.order_status = ?", req.OrderStatus)
sqlStr1 += fmt.Sprintf(" and self_support_for_school_ord.order_status = %d", 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)
@@ -784,7 +784,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
sess6.And("self_support_for_school_ord.order_status = ?", req.OrderStatus)
}
if req.OutTradeNo != "" {
sess1.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%")
sqlStr1 += " 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+"%")
@@ -792,7 +792,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
sess6.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%")
}
if req.EnterpriseKind != 0 {
sess1.And("enterprise.kind = ?", req.EnterpriseKind)
sqlStr1 += fmt.Sprintf(" and enterprise.kind = %d", req.EnterpriseKind)
sqlStr += fmt.Sprintf(" and enterprise.kind = %d", req.EnterpriseKind)
sess3.And("enterprise.kind = ?", req.EnterpriseKind)
sess4.And("enterprise.kind = ?", req.EnterpriseKind)
@@ -801,7 +801,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
if req.IsTeacher != 0 {
if req.IsTeacher == 1 {
sess1.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher)
sqlStr1 += fmt.Sprintf(" and user_identity.identity = %d", 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)
@@ -809,7 +809,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
sess6.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher)
}
if req.IsTeacher == 2 {
sess1.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher)
sqlStr1 += fmt.Sprintf(" and user_identity.identity != %d", 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)
@@ -819,7 +819,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}

if req.Name != "" {
sess1.And("user_identity.name like ?", "%"+req.Name+"%")
sqlStr1 += " 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+"%")
@@ -827,7 +827,7 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
sess6.And("user_identity.name like ?", "%"+req.Name+"%")
}
if req.Phone != "" {
sess1.And("user.phone like ?", "%"+req.Phone+"%")
sqlStr1 += " 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+"%")
@@ -836,8 +836,8 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
if len(classWithUserIdentityIdsOne) > 0 {
userIdentityStr := php2go.Implode(",", classWithUserIdentityIdsOneStr)
sqlStr1 += fmt.Sprintf(" and user_identity.id In (%s)", userIdentityStr)
sqlStr += fmt.Sprintf(" and user_identity.id In (%s)", userIdentityStr)
sess1.In("user_identity.id", classWithUserIdentityIdsOne)
sess3.In("user_identity.id", classWithUserIdentityIdsOne)
sess4.In("user_identity.id", classWithUserIdentityIdsOne)
sess5.In("user_identity.id", classWithUserIdentityIdsOne)
@@ -845,33 +845,26 @@ func SelfSupportForSchoolOrdStatistics(req md.SelfSupportForSchoolOrdListReq) (p
}
if len(classWithUserIdentityIdsTwo) > 0 {
userIdentityStr := php2go.Implode(",", classWithUserIdentityIdsTwoStr)
sqlStr1 += fmt.Sprintf(" and user_identity.id In (%s)", userIdentityStr)
sqlStr += fmt.Sprintf(" and user_identity.id In (%s)", userIdentityStr)
sess1.In("user_identity.id", classWithUserIdentityIdsTwo)
sess3.In("user_identity.id", classWithUserIdentityIdsTwo)
sess4.In("user_identity.id", classWithUserIdentityIdsTwo)
sess5.In("user_identity.id", classWithUserIdentityIdsTwo)
sess6.In("user_identity.id", classWithUserIdentityIdsTwo)
}

var m []*db.SelfSupportForSchoolOrdWithUserIdentity
personNum, err = sess1.
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").
GroupBy("self_support_for_school_ord.user_identity_id").
FindAndCount(&m)
sqlStr1 += " GROUP BY self_support_for_school_ord.user_identity_id"
mapArr1, err := db.QueryNativeString(db.Db, sqlStr1)
if err != nil {
return 0, 0, 0, 0, 0, 0, err
}
count = utils.StrToInt64(mapArr1[0]["user_identity_id"])

mapArr1, err := db.QueryNativeString(db.Db, sqlStr)
mapArr, err := db.QueryNativeString(db.Db, sqlStr)
if err != nil {
return 0, 0, 0, 0, 0, 0, err
}
count = utils.StrToInt64(mapArr1[0]["total"])
count = utils.StrToInt64(mapArr[0]["total"])

var mm db.SelfSupportForSchoolOrdWithUserIdentity
consumeAmount, err = sess3.


Loading…
Cancel
Save