DengBiao 1 anno fa
parent
commit
8544f7d9a9
4 ha cambiato i file con 174 aggiunte e 0 eliminazioni
  1. +39
    -0
      app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go
  2. +1
    -0
      app/admin/md/md_enterprise_manage.go
  3. +133
    -0
      app/admin/svc/enterprise_manage/svc_self_support_for_school.go
  4. +1
    -0
      app/router/admin_router.go

+ 39
- 0
app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go Vedi File

@@ -17,6 +17,7 @@ import (
"github.com/gin-gonic/gin"
"net/http"
"os"
"strconv"
"time"
)

@@ -1033,6 +1034,44 @@ func SelfSupportForSchoolOrdList(c *gin.Context) {
return
}

func SelfSupportForSchoolOrdListExport(c *gin.Context) {
var req md.SelfSupportForSchoolOrdListReq
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.SelfSupportForSchoolOrdListExport(req)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}

titleList := []string{"订单编号", "支付交易号", "家长电话", "就餐人姓名", "学校名称", "年级", "班级", "总金额", "支付状态", "就餐时间", "设备编号", "消费档口"}
xlsx := excelize.NewFile()
xlsx.SetSheetRow("Sheet1", "A1", &titleList)
//表头被第一行用了,只能从第二行开始
j := 2
for _, v := range resp {
stateName := "支付成功"
if v.OrderStatus == 1 {
stateName = "待支付"
}
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.OutTradeNo, v.TradeNo, v.Phone, v.Name, v.EnterpriseName, v.Class, v.Grade, v.TotalPrice, stateName, v.FaceTime, v.DeviceSn, v.ShopName})
j++
}

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) {
var req md.SelfSupportForSchoolArrearsOrdListReq
err := c.ShouldBindJSON(&req)


+ 1
- 0
app/admin/md/md_enterprise_manage.go Vedi File

@@ -527,6 +527,7 @@ type SelfSupportForSchoolOrdListResp struct {
Class string `json:"class" label:"班级"`
ClassId int `json:"class_id" label:"班级id"`
DeviceSn string `json:"device_sn" label:"设备编号"`
ShopName string `json:"shop_name" label:"消费档口"`
CpMerchantId string `json:"cp_merchant_id" label:"商户编码"`
DebtBusinessMsg string `json:"debt_business_msg" label:"欠款原因"`
}


+ 133
- 0
app/admin/svc/enterprise_manage/svc_self_support_for_school.go Vedi File

@@ -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


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

@@ -216,6 +216,7 @@ func rEnterpriseManage(r *gin.RouterGroup) {
r.POST("/selfSupportForSchool/importTeacher", hdl.SelfSupportForSchoolImportTeacher) //"自营-学校"导入老师
r.GET("/selfSupportForSchool/downloadTemplateExcel", hdl.SelfSupportForSchoolDownloadTemplateExcel) //"自营-学校"下载表格模板
r.POST("/selfSupportForSchool/ordList", hdl.SelfSupportForSchoolOrdList) //"自营-学校"订单列表
r.POST("/selfSupportForSchool/ordListExport", hdl.SelfSupportForSchoolOrdListExport) //"自营-学校"订单列表-导出
r.POST("/selfSupportForSchool/arrearsOrdList", hdl.SelfSupportForSchoolArrearsOrdList) //"自营-学校"订单欠费列表
r.POST("/selfSupportForSchool/blackList", hdl.SelfSupportForSchoolBlackList) //"自营-学校"黑名单列表
r.POST("/selfSupportForSchool/arrearsOrdDebtRepay", hdl.SelfSupportForSchoolArrearsOrdDebtRepay) //"自营-学校"订单欠费催缴


Caricamento…
Annulla
Salva