Browse Source

update

add_mode
DengBiao 1 year ago
parent
commit
4d4d04cbb9
3 changed files with 178 additions and 0 deletions
  1. +52
    -0
      app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go
  2. +125
    -0
      app/admin/svc/enterprise_manage/svc_self_support_for_school.go
  3. +1
    -0
      app/router/admin_router.go

+ 52
- 0
app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go View File

@@ -1427,6 +1427,58 @@ func SelfSupportForSchoolOrdListExport(c *gin.Context) {
return return
} }


func SelfSupportForSchoolArrearsOrdListExport(c *gin.Context) {
var req md.SelfSupportForSchoolArrearsOrdListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}

resp, err := svc2.SelfSupportForSchoolArrearsOrdListExport(req)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}

titleList := []string{"订单编号", "家长电话", "就餐人姓名", "学校名称", "年级", "班级", "消费金额", "消费档口", "设备编号", "刷脸时间", "失败原因", "就餐类型"}
xlsx := excelize.NewFile()
xlsx.SetSheetRow("Sheet1", "A1", &titleList)
style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFF00"],"pattern":1}, "alignment":{"horizontal":"center"}}`)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
xlsx.SetCellStyle("Sheet1", "A1", "M1", style)
xlsx.SetColWidth("Sheet1", "A", "A", 35)
xlsx.SetColWidth("Sheet1", "B", "D", 20)
xlsx.SetColWidth("Sheet1", "E", "H", 15)
xlsx.SetColWidth("Sheet1", "I", "I", 25)
xlsx.SetColWidth("Sheet1", "J", "K", 20)
xlsx.SetColWidth("Sheet1", "L", "L", 15)
//表头被第一行用了,只能从第二行开始
j := 2
var totalAmount = 0.00
for _, v := range resp {
totalAmount += utils.StrToFloat64(v.TotalPrice)
mealZh := svc3.JudgeSelfSupportForMealTime(v.FaceTime)
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.OutTradeNo, v.Phone, v.Name, v.EnterpriseName, v.Class, v.Grade, utils.StrToFloat64(v.TotalPrice),
v.ShopName, v.DeviceSn, v.FaceTime, v.DebtBusinessMsg, mealZh})
j++
}

xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{"总计:", "-", "-", "-", "-", "-", totalAmount, "-", "-", "-", "-", "-"})

c.Header("Content-Type", "application/octet-stream")
c.Header("Content-Disposition", "attachment; filename="+"消费记录"+".xlsx")
c.Header("Content-Transfer-Encoding", "binary")
//回写到web 流媒体 形成下载
_ = xlsx.Write(c.Writer)
return
}

func SelfSupportForSchoolArrearsOrdList(c *gin.Context) { func SelfSupportForSchoolArrearsOrdList(c *gin.Context) {
var req md.SelfSupportForSchoolArrearsOrdListReq var req md.SelfSupportForSchoolArrearsOrdListReq
err := c.ShouldBindJSON(&req) err := c.ShouldBindJSON(&req)


+ 125
- 0
app/admin/svc/enterprise_manage/svc_self_support_for_school.go View File

@@ -909,3 +909,128 @@ func SelfSupportForSchoolArrearsOrdList(req md.SelfSupportForSchoolArrearsOrdLis
} }
return return
} }

func SelfSupportForSchoolArrearsOrdListExport(req md.SelfSupportForSchoolArrearsOrdListReq) (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.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.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 = ?", 1) // 支付状态 (1:待支付 2:支付成功)
//}
if req.OutTradeNo != "" {
sess.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%")
}
if req.EnterpriseKind != 0 {
sess.And("enterprise.kind = ?", req.EnterpriseKind)
}

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 = self_support_for_school_ord.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,
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,
CpMerchantId: v.SelfSupportForSchoolOrd.CpMerchantId,
DebtBusinessMsg: v.SelfSupportForSchoolOrd.DebtBusinessMsg,
})
}
return
}

+ 1
- 0
app/router/admin_router.go View File

@@ -224,6 +224,7 @@ func rEnterpriseManage(r *gin.RouterGroup) {
r.POST("/selfSupportForSchool/consumeLimit", hdl.SelfSupportForSchoolConsumeLimit) //"自营-学校"消费限制-编辑 r.POST("/selfSupportForSchool/consumeLimit", hdl.SelfSupportForSchoolConsumeLimit) //"自营-学校"消费限制-编辑
r.POST("/selfSupportForSchool/consumeLimitList", hdl.SelfSupportForSchoolConsumeLimitList) //"自营-学校"消费限制-列表 r.POST("/selfSupportForSchool/consumeLimitList", hdl.SelfSupportForSchoolConsumeLimitList) //"自营-学校"消费限制-列表
r.POST("/selfSupportForSchool/arrearsOrdList", hdl.SelfSupportForSchoolArrearsOrdList) //"自营-学校"订单欠费列表 r.POST("/selfSupportForSchool/arrearsOrdList", hdl.SelfSupportForSchoolArrearsOrdList) //"自营-学校"订单欠费列表
r.Any("/selfSupportForSchool/arrearsOrdListExport", hdl.SelfSupportForSchoolArrearsOrdListExport) //"自营-学校"订单欠费列表-导出
r.POST("/selfSupportForSchool/blackList", hdl.SelfSupportForSchoolBlackList) //"自营-学校"黑名单列表 r.POST("/selfSupportForSchool/blackList", hdl.SelfSupportForSchoolBlackList) //"自营-学校"黑名单列表
r.POST("/selfSupportForSchool/arrearsOrdDebtRepay", hdl.SelfSupportForSchoolArrearsOrdDebtRepay) //"自营-学校"订单欠费催缴 r.POST("/selfSupportForSchool/arrearsOrdDebtRepay", hdl.SelfSupportForSchoolArrearsOrdDebtRepay) //"自营-学校"订单欠费催缴
r.POST("/selfSupportForSchool/arrearsOrdDebtCancel", hdl.SelfSupportForSchoolArrearsOrdDebtCancel) //"自营-学校"撤销欠款 r.POST("/selfSupportForSchool/arrearsOrdDebtCancel", hdl.SelfSupportForSchoolArrearsOrdDebtCancel) //"自营-学校"撤销欠款


Loading…
Cancel
Save