Browse Source

update

add_mode
DengBiao 1 year ago
parent
commit
c83391f61b
5 changed files with 75 additions and 11 deletions
  1. +18
    -0
      app/admin/hdl/hdl_role.go
  2. +5
    -0
      app/admin/md/md_role.go
  3. +38
    -0
      app/admin/svc/svc_admin_with_enterprise.go
  4. +13
    -11
      app/admin/svc/svc_data_statisstics.go
  5. +1
    -0
      app/router/admin_router.go

+ 18
- 0
app/admin/hdl/hdl_role.go View File

@@ -477,6 +477,24 @@ func BindAdminRole(c *gin.Context) {
return
}

func BindAdminWithEnterprise(c *gin.Context) {
var req md.BindAdminWithEnterpriseReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
err = svc.BindAdminWithEnterprise(req)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
e.OutSuc(c, "success", nil)
return
}

func AdminInfo(c *gin.Context) {
admId := c.DefaultQuery("adm_id", "")
admDb := db.AdminDb{}


+ 5
- 0
app/admin/md/md_role.go View File

@@ -84,3 +84,8 @@ type BindAdminRoleReq struct {
AdmId int `json:"adm_id" binding:"required" label:"管理员id"`
RoleIds []int `json:"role_ids" label:"角色id"`
}

type BindAdminWithEnterpriseReq struct {
AdmId int `json:"adm_id" binding:"required" label:"管理员id"`
Ids []int `json:"ids" label:"记录id"`
}

+ 38
- 0
app/admin/svc/svc_admin_with_enterprise.go View File

@@ -0,0 +1,38 @@
package svc

import (
"applet/app/admin/md"
"applet/app/db"
"applet/app/db/model"
)

func BindAdminWithEnterprise(req md.BindAdminWithEnterpriseReq) (err error) {
session := db.Db.NewSession()
defer session.Close()
session.Begin()

//1、删除 `admin_with_enterprise`
adminWithEnterpriseDb := db.AdminWithEnterpriseDb{}
adminWithEnterpriseDb.Set()
_, err = adminWithEnterpriseDb.AdminWithEnterpriseDeleteBySession(session, req.Ids)
if err != nil {
_ = session.Rollback()
return
}

//2、新增 `admin_with_enterprise``
var mm []*model.AdminWithEnterprise
for _, v := range req.Ids {
mm = append(mm, &model.AdminWithEnterprise{
AdmId: req.AdmId,
EnterpriseId: v,
})
}
_, err = adminWithEnterpriseDb.BatchAddAdminWithEnterpriseBySession(session, mm)
if err != nil {
_ = session.Rollback()
return
}

return session.Commit()
}

+ 13
- 11
app/admin/svc/svc_data_statisstics.go View File

@@ -1023,17 +1023,19 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD
for _, v := range *userIdentities {
userIdentityIds = append(userIdentityIds, utils.IntToStr(v.Id))
}
userIdentityStr := php2go.Implode(",", userIdentityIds)
sql2 := fmt.Sprintf("SELECT sum(amount) as total FROM central_kitchen_for_school_user_refund_day where state = %d and identity_id IN (%s) and refund_date >= '%s' and refund_date < '%s'",
enum.CentralKitchenForSchoolUserRefundDayStateForAuditComplete, userIdentityStr, req.StartDate, req.EndDate)
mapArr2, err := db.QueryNativeString(db.Db, sql2)
if err != nil {
logx.Error(err)
println("<<<<CentralKitchenForSchoolDataStatisticsExport6>>>>>Error:::", err.Error())
return
}
if mapArr2 != nil {
refund = mapArr2[0]["total"]
if len(userIdentityIds) != 0 {
userIdentityStr := php2go.Implode(",", userIdentityIds)
sql2 := fmt.Sprintf("SELECT sum(amount) as total FROM central_kitchen_for_school_user_refund_day where state = %d and identity_id IN (%s) and refund_date >= '%s' and refund_date < '%s'",
enum.CentralKitchenForSchoolUserRefundDayStateForAuditComplete, userIdentityStr, req.StartDate, req.EndDate)
mapArr2, err := db.QueryNativeString(db.Db, sql2)
if err != nil {
logx.Error(err)
println("<<<<CentralKitchenForSchoolDataStatisticsExport6>>>>>Error:::", err.Error())
return
}
if mapArr2 != nil {
refund = mapArr2[0]["total"]
}
}
j := 2 //表头被第一行用了,只能从第二行开始
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.Name, income, refund})


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

@@ -244,6 +244,7 @@ func rRole(r *gin.RouterGroup) {
r.DELETE("/deleteAdmin/:adm_id", hdl2.DeleteAdmin) //删除管理员
r.GET("/adminInfo", hdl2.AdminInfo) //获取管理员信息
r.POST("/bindAdminRole", hdl2.BindAdminRole) //绑定角色
r.POST("/bindAdminWithEnterprise", hdl2.BindAdminWithEnterprise) //绑定校企
}

func AdminRoute(r *gin.RouterGroup) {


Loading…
Cancel
Save