|
|
@@ -617,6 +617,138 @@ func SelfSupportForSchoolOrdList(req md.SelfSupportForSchoolOrdListReq) (resp [] |
|
|
|
return nil, 0, err |
|
|
|
} |
|
|
|
|
|
|
|
//查询出所有的设备 |
|
|
|
var deviceList []*model.Device |
|
|
|
err = db.Db.Where("enterprise_id != 0").Find(&deviceList) |
|
|
|
if err != nil { |
|
|
|
return nil, 0, err |
|
|
|
} |
|
|
|
var deviceListMapping = map[string]model.Device{} |
|
|
|
for _, v := range deviceList { |
|
|
|
deviceListMapping[v.DeviceSn] = *v |
|
|
|
} |
|
|
|
|
|
|
|
for _, v := range m { |
|
|
|
resp = append(resp, md.SelfSupportForSchoolOrdListResp{ |
|
|
|
EnterpriseId: v.UserIdentity.EnterpriseId, |
|
|
|
EnterpriseName: v.Enterprise.Name, |
|
|
|
Uid: v.UserIdentity.Uid, |
|
|
|
UserIdentityId: v.UserIdentity.Id, |
|
|
|
UserIdentityName: v.SelfSupportForSchoolOrd.Consumer, |
|
|
|
TotalPrice: v.SelfSupportForSchoolOrd.TradeAmount, |
|
|
|
OutTradeNo: v.SelfSupportForSchoolOrd.OutOrderNo, |
|
|
|
TradeNo: v.SelfSupportForSchoolOrd.TradeNo, |
|
|
|
OrderStatus: v.SelfSupportForSchoolOrd.OrderStatus, |
|
|
|
FaceTime: v.SelfSupportForSchoolOrd.FaceTime, |
|
|
|
Phone: v.User.Phone, |
|
|
|
Name: v.UserIdentity.Name, |
|
|
|
Grade: v.Grade.Name, |
|
|
|
GradeId: v.Grade.Id, |
|
|
|
Class: v.Class.Name, |
|
|
|
ClassId: v.Class.Id, |
|
|
|
DeviceSn: v.SelfSupportForSchoolOrd.DeviceSn, |
|
|
|
ShopName: deviceListMapping[v.SelfSupportForSchoolOrd.DeviceSn].Name, |
|
|
|
}) |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func SelfSupportForSchoolOrdListExport(req md.SelfSupportForSchoolOrdListReq) (resp []md.SelfSupportForSchoolOrdListResp, err error) { |
|
|
|
var classWithUserIdentityIdsOne []int |
|
|
|
var classWithUserIdentityIdsTwo []int |
|
|
|
classWithUserDb := db.ClassWithUserDb{} |
|
|
|
classWithUserDb.Set() |
|
|
|
if req.ClassId != 0 { |
|
|
|
classWithUsers, err2 := classWithUserDb.FindUserIdentity(req.ClassId) |
|
|
|
if err2 != nil { |
|
|
|
return nil, err2 |
|
|
|
} |
|
|
|
for _, v := range *classWithUsers { |
|
|
|
classWithUserIdentityIdsOne = append(classWithUserIdentityIdsOne, v.UserIdentityId) |
|
|
|
} |
|
|
|
} |
|
|
|
if req.GradeId != 0 { |
|
|
|
classDb := db.ClassDb{} |
|
|
|
classDb.Set(req.GradeId) |
|
|
|
classes, err3 := classDb.FindClass() |
|
|
|
if err3 != nil { |
|
|
|
return nil, err3 |
|
|
|
} |
|
|
|
var classesId []int |
|
|
|
for _, v := range *classes { |
|
|
|
classesId = append(classesId, v.Id) |
|
|
|
} |
|
|
|
classWithUsers, err4 := classWithUserDb.FindUserIdentity(classesId) |
|
|
|
if err4 != nil { |
|
|
|
return nil, err4 |
|
|
|
} |
|
|
|
for _, v := range *classWithUsers { |
|
|
|
classWithUserIdentityIdsTwo = append(classWithUserIdentityIdsTwo, v.UserIdentityId) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sess := db.Db.Desc("self_support_for_school_ord.id") |
|
|
|
if req.EnterpriseId != 0 { |
|
|
|
sess.And("self_support_for_school_ord.enterprise_id =?", req.EnterpriseId) |
|
|
|
} |
|
|
|
if req.StartDate != "" { |
|
|
|
sess.And("self_support_for_school_ord.face_time >= ?", req.StartDate) |
|
|
|
} |
|
|
|
if req.EndDate != "" { |
|
|
|
sess.And("self_support_for_school_ord.face_time <= ?", req.EndDate) |
|
|
|
} |
|
|
|
if req.OrderStatus != 0 { |
|
|
|
sess.And("self_support_for_school_ord.order_status = ", req.OrderStatus) |
|
|
|
} |
|
|
|
if req.OutTradeNo != "" { |
|
|
|
sess.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%") |
|
|
|
} |
|
|
|
if req.IsTeacher != 0 { |
|
|
|
if req.IsTeacher == 1 { |
|
|
|
sess.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
} |
|
|
|
if req.IsTeacher == 2 { |
|
|
|
sess.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if req.Name != "" { |
|
|
|
sess.And("user_identity.name like ?", "%"+req.Name+"%") |
|
|
|
} |
|
|
|
if req.Phone != "" { |
|
|
|
sess.And("user.phone like ?", "%"+req.Phone+"%") |
|
|
|
} |
|
|
|
if len(classWithUserIdentityIdsOne) > 0 { |
|
|
|
sess.In("user_identity.id", classWithUserIdentityIdsOne) |
|
|
|
} |
|
|
|
if len(classWithUserIdentityIdsTwo) > 0 { |
|
|
|
sess.In("user_identity.id", classWithUserIdentityIdsTwo) |
|
|
|
} |
|
|
|
|
|
|
|
var m []*db.SelfSupportForSchoolOrdWithUserIdentity |
|
|
|
err = sess. |
|
|
|
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"). |
|
|
|
Desc("self_support_for_school_ord.face_time").Find(&m) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
//查询出所有的设备 |
|
|
|
var deviceList []*model.Device |
|
|
|
err = db.Db.Where("enterprise_id != 0").Find(&deviceList) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
var deviceListMapping = map[string]model.Device{} |
|
|
|
for _, v := range deviceList { |
|
|
|
deviceListMapping[v.DeviceSn] = *v |
|
|
|
} |
|
|
|
|
|
|
|
for _, v := range m { |
|
|
|
resp = append(resp, md.SelfSupportForSchoolOrdListResp{ |
|
|
|
EnterpriseId: v.UserIdentity.EnterpriseId, |
|
|
@@ -636,6 +768,7 @@ func SelfSupportForSchoolOrdList(req md.SelfSupportForSchoolOrdListReq) (resp [] |
|
|
|
Class: v.Class.Name, |
|
|
|
ClassId: v.Class.Id, |
|
|
|
DeviceSn: v.SelfSupportForSchoolOrd.DeviceSn, |
|
|
|
ShopName: deviceListMapping[v.SelfSupportForSchoolOrd.DeviceSn].Name, |
|
|
|
}) |
|
|
|
} |
|
|
|
return |
|
|
|