@@ -477,6 +477,24 @@ func BindAdminRole(c *gin.Context) { | |||||
return | 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) { | func AdminInfo(c *gin.Context) { | ||||
admId := c.DefaultQuery("adm_id", "") | admId := c.DefaultQuery("adm_id", "") | ||||
admDb := db.AdminDb{} | admDb := db.AdminDb{} | ||||
@@ -84,3 +84,8 @@ type BindAdminRoleReq struct { | |||||
AdmId int `json:"adm_id" binding:"required" label:"管理员id"` | AdmId int `json:"adm_id" binding:"required" label:"管理员id"` | ||||
RoleIds []int `json:"role_ids" 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"` | |||||
} |
@@ -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() | |||||
} |
@@ -1023,17 +1023,19 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD | |||||
for _, v := range *userIdentities { | for _, v := range *userIdentities { | ||||
userIdentityIds = append(userIdentityIds, utils.IntToStr(v.Id)) | 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 //表头被第一行用了,只能从第二行开始 | j := 2 //表头被第一行用了,只能从第二行开始 | ||||
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.Name, income, refund}) | xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.Name, income, refund}) | ||||
@@ -244,6 +244,7 @@ func rRole(r *gin.RouterGroup) { | |||||
r.DELETE("/deleteAdmin/:adm_id", hdl2.DeleteAdmin) //删除管理员 | r.DELETE("/deleteAdmin/:adm_id", hdl2.DeleteAdmin) //删除管理员 | ||||
r.GET("/adminInfo", hdl2.AdminInfo) //获取管理员信息 | r.GET("/adminInfo", hdl2.AdminInfo) //获取管理员信息 | ||||
r.POST("/bindAdminRole", hdl2.BindAdminRole) //绑定角色 | r.POST("/bindAdminRole", hdl2.BindAdminRole) //绑定角色 | ||||
r.POST("/bindAdminWithEnterprise", hdl2.BindAdminWithEnterprise) //绑定校企 | |||||
} | } | ||||
func AdminRoute(r *gin.RouterGroup) { | func AdminRoute(r *gin.RouterGroup) { | ||||