|
@@ -752,57 +752,114 @@ func CentralKitchenForSchoolOrdStatistics(req md.CentralKitchenForSchoolOrdListR |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
sess := db.Db.Desc("central_kitchen_for_school_package_ord.id") |
|
|
|
|
|
|
|
|
sess1, sess2, sess3, sess4, sess5 := db.Db.Where("1=1"), db.Db.Where("1=1"), db.Db.Where("1=1"), db.Db.Where("1=1"), db.Db.Where("1=1") |
|
|
if req.EnterpriseId != 0 { |
|
|
if req.EnterpriseId != 0 { |
|
|
sess.And("central_kitchen_for_school_package_ord.enterprise_id =?", req.EnterpriseId) |
|
|
|
|
|
|
|
|
sess1.And("central_kitchen_for_school_package_ord.enterprise_id =?", req.EnterpriseId) |
|
|
|
|
|
sess2.And("central_kitchen_for_school_package_ord.enterprise_id =?", req.EnterpriseId) |
|
|
|
|
|
sess3.And("central_kitchen_for_school_package_ord.enterprise_id =?", req.EnterpriseId) |
|
|
|
|
|
sess4.And("central_kitchen_for_school_package_ord.enterprise_id =?", req.EnterpriseId) |
|
|
|
|
|
sess5.And("central_kitchen_for_school_package_ord.enterprise_id =?", req.EnterpriseId) |
|
|
} |
|
|
} |
|
|
if req.IsTeacher != 0 { |
|
|
if req.IsTeacher != 0 { |
|
|
if req.IsTeacher == 1 { |
|
|
if req.IsTeacher == 1 { |
|
|
sess.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
|
|
|
|
|
sess1.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
|
|
sess2.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
|
|
sess3.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
|
|
sess4.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
|
|
sess5.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
} |
|
|
} |
|
|
if req.IsTeacher == 2 { |
|
|
if req.IsTeacher == 2 { |
|
|
sess.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
|
|
|
|
|
sess1.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
|
|
sess2.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
|
|
sess3.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
|
|
sess4.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
|
|
sess5.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if req.StartDate != "" { |
|
|
if req.StartDate != "" { |
|
|
sess.And("central_kitchen_for_school_package_ord.create_at >= ?", req.StartDate) |
|
|
|
|
|
|
|
|
sess1.And("central_kitchen_for_school_package_ord.create_at >= ?", req.StartDate) |
|
|
|
|
|
sess2.And("central_kitchen_for_school_package_ord.create_at >= ?", req.StartDate) |
|
|
|
|
|
sess3.And("central_kitchen_for_school_package_ord.create_at >= ?", req.StartDate) |
|
|
|
|
|
sess4.And("central_kitchen_for_school_package_ord.create_at >= ?", req.StartDate) |
|
|
|
|
|
sess5.And("central_kitchen_for_school_package_ord.create_at >= ?", req.StartDate) |
|
|
} |
|
|
} |
|
|
if req.EndDate != "" { |
|
|
if req.EndDate != "" { |
|
|
sess.And("central_kitchen_for_school_package_ord.create_at <= ?", req.EndDate) |
|
|
|
|
|
|
|
|
sess1.And("central_kitchen_for_school_package_ord.create_at <= ?", req.EndDate) |
|
|
|
|
|
sess2.And("central_kitchen_for_school_package_ord.create_at <= ?", req.EndDate) |
|
|
|
|
|
sess3.And("central_kitchen_for_school_package_ord.create_at <= ?", req.EndDate) |
|
|
|
|
|
sess4.And("central_kitchen_for_school_package_ord.create_at <= ?", req.EndDate) |
|
|
|
|
|
sess5.And("central_kitchen_for_school_package_ord.create_at <= ?", req.EndDate) |
|
|
} |
|
|
} |
|
|
if req.Kind != 0 { |
|
|
if req.Kind != 0 { |
|
|
sess.And("central_kitchen_for_school_package_ord.kind = ?", req.Kind) |
|
|
|
|
|
|
|
|
sess1.And("central_kitchen_for_school_package_ord.kind = ?", req.Kind) |
|
|
|
|
|
sess2.And("central_kitchen_for_school_package_ord.kind = ?", req.Kind) |
|
|
|
|
|
sess3.And("central_kitchen_for_school_package_ord.kind = ?", req.Kind) |
|
|
|
|
|
sess4.And("central_kitchen_for_school_package_ord.kind = ?", req.Kind) |
|
|
|
|
|
sess5.And("central_kitchen_for_school_package_ord.kind = ?", req.Kind) |
|
|
} |
|
|
} |
|
|
if req.Sate != -1 { |
|
|
if req.Sate != -1 { |
|
|
sess.And("central_kitchen_for_school_package_ord.state = ?", req.Sate) |
|
|
|
|
|
|
|
|
sess1.And("central_kitchen_for_school_package_ord.state = ?", req.Sate) |
|
|
|
|
|
sess2.And("central_kitchen_for_school_package_ord.state = ?", req.Sate) |
|
|
|
|
|
sess3.And("central_kitchen_for_school_package_ord.state = ?", req.Sate) |
|
|
|
|
|
sess4.And("central_kitchen_for_school_package_ord.state = ?", req.Sate) |
|
|
|
|
|
sess5.And("central_kitchen_for_school_package_ord.state = ?", req.Sate) |
|
|
} |
|
|
} |
|
|
if req.OrdSate != -1 { |
|
|
if req.OrdSate != -1 { |
|
|
sess.And("central_kitchen_for_school_package_ord.ord_state = ?", req.OrdSate) |
|
|
|
|
|
|
|
|
sess1.And("central_kitchen_for_school_package_ord.ord_state = ?", req.OrdSate) |
|
|
|
|
|
sess2.And("central_kitchen_for_school_package_ord.ord_state = ?", req.OrdSate) |
|
|
|
|
|
sess3.And("central_kitchen_for_school_package_ord.ord_state = ?", req.OrdSate) |
|
|
|
|
|
sess4.And("central_kitchen_for_school_package_ord.ord_state = ?", req.OrdSate) |
|
|
|
|
|
sess5.And("central_kitchen_for_school_package_ord.ord_state = ?", req.OrdSate) |
|
|
} |
|
|
} |
|
|
if req.OutTradeNo != "" { |
|
|
if req.OutTradeNo != "" { |
|
|
sess.And("central_kitchen_for_school_package_ord.out_trade_no like ?", "%"+req.OutTradeNo+"%") |
|
|
|
|
|
|
|
|
sess1.And("central_kitchen_for_school_package_ord.out_trade_no like ?", "%"+req.OutTradeNo+"%") |
|
|
|
|
|
sess2.And("central_kitchen_for_school_package_ord.out_trade_no like ?", "%"+req.OutTradeNo+"%") |
|
|
|
|
|
sess3.And("central_kitchen_for_school_package_ord.out_trade_no like ?", "%"+req.OutTradeNo+"%") |
|
|
|
|
|
sess4.And("central_kitchen_for_school_package_ord.out_trade_no like ?", "%"+req.OutTradeNo+"%") |
|
|
|
|
|
sess5.And("central_kitchen_for_school_package_ord.out_trade_no like ?", "%"+req.OutTradeNo+"%") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if req.Name != "" { |
|
|
if req.Name != "" { |
|
|
sess.And("user_identity.name like ?", "%"+req.Name+"%") |
|
|
|
|
|
|
|
|
sess1.And("user_identity.name like ?", "%"+req.Name+"%") |
|
|
|
|
|
sess2.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+"%") |
|
|
} |
|
|
} |
|
|
if req.Phone != "" { |
|
|
if req.Phone != "" { |
|
|
sess.And("user.phone like ?", "%"+req.Phone+"%") |
|
|
|
|
|
|
|
|
sess1.And("user.phone like ?", "%"+req.Phone+"%") |
|
|
|
|
|
sess2.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+"%") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if req.EnterPriseKind != 0 { |
|
|
if req.EnterPriseKind != 0 { |
|
|
sess.And("enterprise.kind = ?", req.EnterPriseKind) |
|
|
|
|
|
|
|
|
sess1.And("enterprise.kind = ?", req.EnterPriseKind) |
|
|
|
|
|
sess2.And("enterprise.kind = ?", req.EnterPriseKind) |
|
|
|
|
|
sess3.And("enterprise.kind = ?", req.EnterPriseKind) |
|
|
|
|
|
sess4.And("enterprise.kind = ?", req.EnterPriseKind) |
|
|
|
|
|
sess5.And("enterprise.kind = ?", req.EnterPriseKind) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if len(classWithUserIdentityIdsOne) > 0 { |
|
|
if len(classWithUserIdentityIdsOne) > 0 { |
|
|
sess.In("user_identity.id", classWithUserIdentityIdsOne) |
|
|
|
|
|
|
|
|
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) |
|
|
} |
|
|
} |
|
|
if len(classWithUserIdentityIdsTwo) > 0 { |
|
|
if len(classWithUserIdentityIdsTwo) > 0 { |
|
|
sess.In("user_identity.id", classWithUserIdentityIdsTwo) |
|
|
|
|
|
|
|
|
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) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var m []*db.CentralKitchenForSchoolPackageOrdWithUserIdentity |
|
|
var m []*db.CentralKitchenForSchoolPackageOrdWithUserIdentity |
|
|
personNum, err = sess. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
personNum, err = sess1. |
|
|
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). |
|
|
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). |
|
|
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). |
|
|
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). |
|
|
Join("LEFT", "user", "user.id = user_identity.uid"). |
|
|
Join("LEFT", "user", "user.id = user_identity.uid"). |
|
@@ -815,7 +872,7 @@ func CentralKitchenForSchoolOrdStatistics(req md.CentralKitchenForSchoolOrdListR |
|
|
return 0, 0, 0, 0, 0, err |
|
|
return 0, 0, 0, 0, 0, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
orderCountByTerm, err = sess.And("central_kitchen_for_school_package_ord.kind = ?", 1). |
|
|
|
|
|
|
|
|
orderCountByTerm, err = sess2.And("central_kitchen_for_school_package_ord.kind = ?", 1). |
|
|
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). |
|
|
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). |
|
|
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). |
|
|
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). |
|
|
Join("LEFT", "user", "user.id = user_identity.uid"). |
|
|
Join("LEFT", "user", "user.id = user_identity.uid"). |
|
@@ -826,7 +883,8 @@ func CentralKitchenForSchoolOrdStatistics(req md.CentralKitchenForSchoolOrdListR |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return 0, 0, 0, 0, 0, err |
|
|
return 0, 0, 0, 0, 0, err |
|
|
} |
|
|
} |
|
|
orderCountByMonth, err = sess.And("central_kitchen_for_school_package_ord.kind = ?", 2). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orderCountByMonth, err = sess3.And("central_kitchen_for_school_package_ord.kind = ?", 2). |
|
|
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). |
|
|
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). |
|
|
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). |
|
|
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). |
|
|
Join("LEFT", "user", "user.id = user_identity.uid"). |
|
|
Join("LEFT", "user", "user.id = user_identity.uid"). |
|
@@ -837,7 +895,7 @@ func CentralKitchenForSchoolOrdStatistics(req md.CentralKitchenForSchoolOrdListR |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return 0, 0, 0, 0, 0, err |
|
|
return 0, 0, 0, 0, 0, err |
|
|
} |
|
|
} |
|
|
orderCountByDay, err = sess.And("central_kitchen_for_school_package_ord.kind = ?", 3). |
|
|
|
|
|
|
|
|
orderCountByDay, err = sess4.And("central_kitchen_for_school_package_ord.kind = ?", 3). |
|
|
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). |
|
|
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). |
|
|
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). |
|
|
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). |
|
|
Join("LEFT", "user", "user.id = user_identity.uid"). |
|
|
Join("LEFT", "user", "user.id = user_identity.uid"). |
|
@@ -850,7 +908,7 @@ func CentralKitchenForSchoolOrdStatistics(req md.CentralKitchenForSchoolOrdListR |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var mm db.CentralKitchenForSchoolPackageOrdWithUserIdentity |
|
|
var mm db.CentralKitchenForSchoolPackageOrdWithUserIdentity |
|
|
consumeAmount, err = sess. |
|
|
|
|
|
|
|
|
consumeAmount, err = sess5. |
|
|
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). |
|
|
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). |
|
|
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). |
|
|
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). |
|
|
Join("LEFT", "user", "user.id = user_identity.uid"). |
|
|
Join("LEFT", "user", "user.id = user_identity.uid"). |
|
|