@@ -0,0 +1,37 @@ | |||
package enum | |||
type AdminState int32 | |||
const ( | |||
AdminStateForNormal = 1 | |||
AdminStateForFreeze = 2 | |||
) | |||
func (gt AdminState) String() string { | |||
switch gt { | |||
case AdminStateForNormal: | |||
return "正常" | |||
case AdminStateForFreeze: | |||
return "冻结" | |||
default: | |||
return "未知" | |||
} | |||
} | |||
type IsSuperAdministrator int32 | |||
const ( | |||
IsSuperAdministratorTure = 1 | |||
IsSuperAdministratorFalse = 2 | |||
) | |||
func (gt IsSuperAdministrator) String() string { | |||
switch gt { | |||
case IsSuperAdministratorTure: | |||
return "超管" | |||
case IsSuperAdministratorFalse: | |||
return "非超管" | |||
default: | |||
return "未知" | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
package enum | |||
type CompanyState int32 | |||
const ( | |||
CompanyStateForNormal = 1 | |||
CompanyStateForFreeze = 2 | |||
) | |||
func (gt CompanyState) String() string { | |||
switch gt { | |||
case CompanyStateForNormal: | |||
return "正常" | |||
case CompanyStateForFreeze: | |||
return "冻结" | |||
default: | |||
return "未知" | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
package enum | |||
type PermissionGroupState int32 | |||
const ( | |||
PermissionGroupStateForNormal = 1 | |||
PermissionGroupStateForDiscard = 2 | |||
) | |||
func (gt PermissionGroupState) String() string { | |||
switch gt { | |||
case PermissionGroupStateForNormal: | |||
return "正常" | |||
case PermissionGroupStateForDiscard: | |||
return "废弃" | |||
default: | |||
return "未知" | |||
} | |||
} |
@@ -0,0 +1,67 @@ | |||
package enum | |||
type QrcodeBatchState int32 | |||
const ( | |||
QrcodeBatchStateForUseIng = 1 | |||
QrcodeBatchStateForUseAlready = 2 | |||
QrcodeBatchStateForExpire = 3 | |||
QrcodeBatchStateForCancel = 4 | |||
) | |||
func (gt QrcodeBatchState) String() string { | |||
switch gt { | |||
case QrcodeBatchStateForUseIng: | |||
return "使用中" | |||
case QrcodeBatchStateForUseAlready: | |||
return "使用完" | |||
case QrcodeBatchStateForExpire: | |||
return "已过期" | |||
case QrcodeBatchStateForCancel: | |||
return "已作废" | |||
default: | |||
return "未知" | |||
} | |||
} | |||
type QrcodeWithBatchRecordsSate int32 | |||
const ( | |||
QrcodeWithBatchRecordsStateForWait = 1 | |||
QrcodeWithBatchRecordsStateForAlready = 2 | |||
QrcodeWithBatchRecordsStateForExpire = 3 | |||
QrcodeWithBatchRecordsStateForCancel = 4 | |||
) | |||
func (gt QrcodeWithBatchRecordsSate) String() string { | |||
switch gt { | |||
case QrcodeWithBatchRecordsStateForWait: | |||
return "待使用" | |||
case QrcodeWithBatchRecordsStateForAlready: | |||
return "已使用" | |||
case QrcodeWithBatchRecordsStateForExpire: | |||
return "已过期" | |||
case QrcodeWithBatchRecordsStateForCancel: | |||
return "已作废" | |||
default: | |||
return "未知" | |||
} | |||
} | |||
type QrcodeSate int32 | |||
const ( | |||
QrcodeSateAllowUse = 1 | |||
QrcodeSateAllowNotUse = 2 | |||
) | |||
func (gt QrcodeSate) String() string { | |||
switch gt { | |||
case QrcodeSateAllowUse: | |||
return "可使用" | |||
case QrcodeSateAllowNotUse: | |||
return "不可用" | |||
default: | |||
return "未知" | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
package enum | |||
type RoleState int32 | |||
const ( | |||
RoleStateForNormal = 1 | |||
RoleStateForFreeze = 2 | |||
) | |||
func (gt RoleState) String() string { | |||
switch gt { | |||
case RoleStateForNormal: | |||
return "正常" | |||
case RoleStateForFreeze: | |||
return "冻结" | |||
default: | |||
return "未知" | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
package enum | |||
type WxOfficialAccountRequest string | |||
const ( | |||
GetAccessToken = "cgi-bin/token" | |||
QrcodeCreate = "cgi-bin/qrcode/create" | |||
) | |||
func (gt WxOfficialAccountRequest) String() string { | |||
switch gt { | |||
case GetAccessToken: | |||
return "获取 Access token" | |||
case QrcodeCreate: | |||
return "生成带参二维码" | |||
default: | |||
return "未知" | |||
} | |||
} |
@@ -0,0 +1,128 @@ | |||
package hdl | |||
import ( | |||
"applet/app/admin/lib/validate" | |||
"applet/app/admin/md" | |||
"applet/app/admin/svc" | |||
svc2 "applet/app/admin/svc/enterprise_manage" | |||
"applet/app/db" | |||
"applet/app/e" | |||
"applet/app/enum" | |||
"applet/app/utils" | |||
"github.com/gin-gonic/gin" | |||
) | |||
func EnterpriseManageInfo(c *gin.Context) { | |||
enterpriseId := c.DefaultQuery("enterprise_id", "") | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(utils.StrToInt(enterpriseId)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
var resp interface{} | |||
//判断校企类型 | |||
if enterprise.Pvd == enum.EnterprisePvdForOnlinePayment && enterprise.Mode == enum.EnterpriseModeForSchool { | |||
err, resp = svc.CentralKitchenForSchoolInfo(utils.StrToInt(enterpriseId)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} | |||
if enterprise.Pvd == enum.EnterprisePvdForFaceScanPayment && enterprise.Mode == enum.EnterpriseModeForSchool { | |||
err, resp = svc.SelfSupportForSchoolInfo(utils.StrToInt(enterpriseId)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} | |||
if enterprise.Kind == enum.EnterpriseKindByNursingHome { | |||
err, resp = svc.NursingHomeInfo(utils.StrToInt(enterpriseId)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"info": resp, | |||
"kind": []map[string]interface{}{ | |||
{ | |||
"name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForSchool).String(), | |||
"value": enum.EnterpriseKindByCentralKitchenForSchool, | |||
}, | |||
{ | |||
"name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForFactory).String(), | |||
"value": enum.EnterpriseKindByCentralKitchenForFactory, | |||
}, | |||
{ | |||
"name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForSchool).String(), | |||
"value": enum.EnterpriseKindBySelfSupportForSchool, | |||
}, | |||
{ | |||
"name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForFactory).String(), | |||
"value": enum.EnterpriseKindBySelfSupportForFactory, | |||
}, | |||
{ | |||
"name": enum.EnterpriseKind(enum.EnterpriseKindByNursingHome).String(), | |||
"value": enum.EnterpriseKindByNursingHome, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func UserIdentityList(c *gin.Context) { | |||
var req md.EnterpriseUserListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
var resp interface{} | |||
//判断校企类型 | |||
if enterprise.Pvd == enum.EnterprisePvdForOnlinePayment && enterprise.Mode == enum.EnterpriseModeForSchool { | |||
resp, err = svc2.EnterpriseUserListByCentralKitchenForSchool(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} | |||
if enterprise.Pvd == enum.EnterprisePvdForFaceScanPayment && enterprise.Mode == enum.EnterpriseModeForSchool { | |||
resp, err = svc2.EnterpriseUserListByCentralKitchenForSchool(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} | |||
if enterprise.Kind == enum.EnterpriseKindByNursingHome { | |||
resp, err = svc2.EnterpriseUserListByNursingHome(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} | |||
e.OutSuc(c, resp, nil) | |||
return | |||
} |
@@ -0,0 +1,742 @@ | |||
package hdl | |||
import ( | |||
"applet/app/admin/lib/validate" | |||
"applet/app/admin/md" | |||
"applet/app/admin/svc" | |||
svc2 "applet/app/admin/svc/enterprise_manage" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/e" | |||
"applet/app/enum" | |||
"applet/app/utils" | |||
"github.com/gin-gonic/gin" | |||
"time" | |||
) | |||
func NursingHomeUserUpdate(c *gin.Context) { | |||
var req md.NursingHomeUserUpdateReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
err = svc2.NursingHomeUserUpdate(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func NursingHomeUserDelete(c *gin.Context) { | |||
var req md.NursingHomeUserDeleteReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
err = svc2.NursingHomeUserDelete(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func GetNursingHomeWithSpec(c *gin.Context) { | |||
enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0")) | |||
nursingHomeWithSpec := db.NursingHomeWithSpec{} | |||
nursingHomeWithSpec.Set(enterpriseId) | |||
data, err := nursingHomeWithSpec.GetNursingHomeWithSpec() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"data": data, | |||
}, nil) | |||
return | |||
} | |||
func SetNursingHomeWithSpec(c *gin.Context) { | |||
var req md.SetNursingHomeWithSpecReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
nursingHomeWithSpec := db.NursingHomeWithSpec{} | |||
nursingHomeWithSpec.Set(req.EnterpriseId) | |||
spec, err := nursingHomeWithSpec.GetNursingHomeWithSpec() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
_, err = nursingHomeWithSpec.NursingHomeWithSpecDelete() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
now := time.Now() | |||
if spec != nil { | |||
insertConfirm, err1 := nursingHomeWithSpec.NursingHomeWithSpecInsert(&model.NursingHomeWithSpec{ | |||
IsOpenBreakfast: spec.IsOpenBreakfast, | |||
IsOpenLunch: spec.IsOpenLunch, | |||
IsOpenDinner: spec.IsOpenDinner, | |||
EnterpriseId: req.EnterpriseId, | |||
BreakfastUnitPrice: req.BreakfastUnitPrice, | |||
LunchUnitPrice: req.LunchUnitPrice, | |||
DinnerUnitPrice: req.DinnerUnitPrice, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
if insertConfirm <= 0 { | |||
e.OutErr(c, e.ERR_DB_ORM, "新增数据失败") | |||
return | |||
} | |||
} else { | |||
insertConfirm, err1 := nursingHomeWithSpec.NursingHomeWithSpecInsert(&model.NursingHomeWithSpec{ | |||
EnterpriseId: req.EnterpriseId, | |||
BreakfastUnitPrice: req.BreakfastUnitPrice, | |||
LunchUnitPrice: req.LunchUnitPrice, | |||
DinnerUnitPrice: req.DinnerUnitPrice, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
if insertConfirm <= 0 { | |||
e.OutErr(c, e.ERR_DB_ORM, "新增数据失败") | |||
return | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func ListNursingHomePackage(c *gin.Context) { | |||
var req md.ListNursingHomePackageReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
nursingHomePackageDb := db.NursingHomePackageDb{} | |||
nursingHomePackageDb.Set() | |||
list, total, err := nursingHomePackageDb.NursingHomePackageList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": list, | |||
"total": total, | |||
"state_list": []map[string]interface{}{ | |||
{ | |||
"name": "可用", | |||
"value": 1, | |||
}, | |||
{ | |||
"name": "不可用", | |||
"value": 2, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func DetailNursingHomePackage(c *gin.Context) { | |||
packageId := utils.StrToInt(c.DefaultQuery("package_id", "")) | |||
nursingHomePackageDb := db.NursingHomePackageDb{} | |||
nursingHomePackageDb.Set() | |||
NursingHomePackage, err := nursingHomePackageDb.GetNursingHomePackage(packageId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if NursingHomePackage == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
nursingHomePackageWithDayDb := db.NursingHomePackageWithDayDb{} | |||
nursingHomePackageWithDayDb.Set(packageId) | |||
nursingHomePackageWithDay, err := nursingHomePackageWithDayDb.FindNursingHomePackageWithDay() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
var resp = md.SaveNursingHomePackageReq{ | |||
PackageId: NursingHomePackage.Id, | |||
EnterpriseId: NursingHomePackage.EnterpriseId, | |||
Year: NursingHomePackage.Year, | |||
Month: NursingHomePackage.Month, | |||
StartDate: NursingHomePackage.StartDate, | |||
EndDate: NursingHomePackage.EndDate, | |||
DateList: nil, | |||
} | |||
for _, v := range *nursingHomePackageWithDay { | |||
resp.DateList = append(resp.DateList, struct { | |||
Date string `json:"date"` | |||
IsOpenBreakfast int32 `json:"is_open_breakfast"` | |||
IsOpenLunch int32 `json:"is_open_lunch"` | |||
IsOpenDinner int32 `json:"is_open_dinner"` | |||
IsOpenReplenish int32 `json:"is_open_replenish"` | |||
}{Date: v.Date, IsOpenBreakfast: int32(v.IsOpenBreakfast), IsOpenLunch: int32(v.IsOpenLunch), IsOpenDinner: int32(v.IsOpenDinner), IsOpenReplenish: int32(v.IsOpenReplenish)}) | |||
} | |||
e.OutSuc(c, resp, nil) | |||
return | |||
} | |||
func SaveNursingHomePackage(c *gin.Context) { | |||
var req md.SaveNursingHomePackageReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
//判断是新增 / 编辑 | |||
if req.PackageId > 0 { | |||
err = svc.UpdateNursingHomePackage(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} else { | |||
err = svc.AddNursingHomePackage(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func SetBasicNursingHome(c *gin.Context) { | |||
var req md.SetBasicNursingHomeReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
now := time.Now() | |||
//1、更新 nursing_home_set | |||
nursingHomeSetDb := db.NursingHomeSetDb{} | |||
nursingHomeSetDb.Set(req.EnterpriseId) | |||
set, err := nursingHomeSetDb.GetNursingHomeSet() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if set != nil { | |||
set.IsOpenReportMealForYear = req.IsOpenReportMealForYear | |||
set.IsOpenReportMealForDay = req.IsOpenReportMealForDay | |||
set.IsOpenReportMealForMonth = req.IsOpenReportMealForMonth | |||
set.UpdateAt = now.Format("2006-01-02 15:04:05") | |||
_, err2 := nursingHomeSetDb.NursingHomeSetUpdate(set.Id, set, "is_open_report_meal_for_day", "is_open_report_meal_for_month", "is_open_report_meal_for_year", "update_at") | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
return | |||
} | |||
} else { | |||
_, err2 := nursingHomeSetDb.NursingHomeSetInsert(&model.NursingHomeSet{ | |||
EnterpriseId: req.EnterpriseId, | |||
IsOpenReportMealForYear: req.IsOpenReportMealForYear, | |||
IsOpenReportMealForDay: req.IsOpenReportMealForDay, | |||
IsOpenReportMealForMonth: req.IsOpenReportMealForMonth, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
return | |||
} | |||
} | |||
//2、更新 nursing_home_with_spec | |||
nursingHomeWithSpec := db.NursingHomeWithSpec{} | |||
nursingHomeWithSpec.Set(req.EnterpriseId) | |||
spec, err := nursingHomeWithSpec.GetNursingHomeWithSpec() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if spec != nil { | |||
spec.IsOpenBreakfast = req.IsOpenBreakfast | |||
spec.IsOpenLunch = req.IsOpenLunch | |||
spec.IsOpenDinner = req.IsOpenDinner | |||
spec.UpdateAt = now.Format("2006-01-02 15:04:05") | |||
_, err2 := nursingHomeWithSpec.NursingHomeWithSpecUpdate(spec.Id, spec, "is_open_breakfast", "is_open_lunch", "is_open_dinner", "update_at") | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
return | |||
} | |||
} else { | |||
_, err2 := nursingHomeWithSpec.NursingHomeWithSpecInsert(&model.NursingHomeWithSpec{ | |||
EnterpriseId: req.EnterpriseId, | |||
IsOpenBreakfast: req.IsOpenBreakfast, | |||
IsOpenLunch: req.IsOpenLunch, | |||
IsOpenDinner: req.IsOpenDinner, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
return | |||
} | |||
} | |||
//3、更新 `enterprise` | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
enterprise.Name = req.Name | |||
enterprise.State = req.State | |||
enterprise.UpdateAt = now.Format("2006-01-02 15:04:05") | |||
_, err = enterpriseDb.EnterpriseUpdate(enterprise, "name", "state", "update_at") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func GetBasicNursingHome(c *gin.Context) { | |||
enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0")) | |||
//1、获取 nursing_home_set | |||
nursingHomeSetDb := db.NursingHomeSetDb{} | |||
nursingHomeSetDb.Set(enterpriseId) | |||
set, err := nursingHomeSetDb.GetNursingHomeSet() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if set == nil { | |||
set = &model.NursingHomeSet{ | |||
EnterpriseId: enterpriseId, | |||
IsOpenReportMealForDay: 0, | |||
IsOpenReportMealForMonth: 0, | |||
IsOpenReportMealForYear: 0, | |||
CreateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
} | |||
_, err2 := nursingHomeSetDb.NursingHomeSetInsert(set) | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
return | |||
} | |||
} | |||
//2、获取 nursing_home_with_spec | |||
nursingHomeWithSpec := db.NursingHomeWithSpec{} | |||
nursingHomeWithSpec.Set(enterpriseId) | |||
spec, err := nursingHomeWithSpec.GetNursingHomeWithSpec() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if spec == nil { | |||
spec = &model.NursingHomeWithSpec{ | |||
EnterpriseId: enterpriseId, | |||
IsOpenBreakfast: 0, | |||
IsOpenLunch: 0, | |||
IsOpenDinner: 0, | |||
BreakfastUnitPrice: "0", | |||
LunchUnitPrice: "0", | |||
DinnerUnitPrice: "0", | |||
CreateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
} | |||
_, err2 := nursingHomeWithSpec.NursingHomeWithSpecInsert(spec) | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
return | |||
} | |||
} | |||
//3、更新 `enterprise` | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(enterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"central_kitchen_for_school_set": set, | |||
"central_kitchen_for_school_with_spec": spec, | |||
"enterprise": enterprise, | |||
}, nil) | |||
return | |||
} | |||
func NursingHomeOrdList(c *gin.Context) { | |||
var req md.NursingHomeOrdListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
resp, total, err := svc2.NursingHomeOrdList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": resp, | |||
"total": total, | |||
"kind_list": []map[string]string{ | |||
{ | |||
"name": "按年购买", | |||
"value": "1", | |||
}, | |||
{ | |||
"name": "按月购买", | |||
"value": "2", | |||
}, | |||
{ | |||
"name": "按天购买", | |||
"value": "3", | |||
}, | |||
{ | |||
"name": "补餐", | |||
"value": "4", | |||
}, | |||
}, | |||
"state_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForWait), | |||
"value": enum.NursingHomePackageOrdStateForWait, | |||
}, | |||
{ | |||
"name": enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForSuccess), | |||
"value": enum.NursingHomePackageOrdStateForSuccess, | |||
}, | |||
{ | |||
"name": enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForFail), | |||
"value": enum.NursingHomePackageOrdStateForFail, | |||
}, | |||
}, | |||
"ord_state_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForWait), | |||
"value": enum.NursingHomePackageOrdOrdStateForWait, | |||
}, | |||
{ | |||
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForSuccess), | |||
"value": enum.NursingHomePackageOrdOrdStateForSuccess, | |||
}, | |||
{ | |||
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForRefunding), | |||
"value": enum.NursingHomePackageOrdOrdStateForRefunding, | |||
}, | |||
{ | |||
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForPartRefunded), | |||
"value": enum.NursingHomePackageOrdOrdStateForPartRefunded, | |||
}, | |||
{ | |||
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForRefunded), | |||
"value": enum.NursingHomePackageOrdOrdStateForRefunded, | |||
}, | |||
{ | |||
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForComplete), | |||
"value": enum.NursingHomePackageOrdOrdStateForComplete, | |||
}, | |||
}, | |||
"user_identity_kind_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForStudent), | |||
"value": enum.UserIdentityForCentralKitchenForStudent, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForTeacher), | |||
"value": enum.UserIdentityForCentralKitchenForTeacher, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForWorker), | |||
"value": enum.UserIdentityForCentralKitchenForWorker, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent), | |||
"value": enum.UserIdentityForSelfSupportForStudent, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher), | |||
"value": enum.UserIdentityForSelfSupportForTeacher, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForWorker), | |||
"value": enum.UserIdentityForSelfSupportForWorker, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func NursingHomeReserveList(c *gin.Context) { | |||
var req md.NursingHomeReserveListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
resp, total, err := svc2.NursingHomeReserveList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": resp, | |||
"total": total, | |||
"kind_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForBreakfast), | |||
"value": enum.NursingHomeUserWithDayKindForBreakfast, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForLunch), | |||
"value": enum.NursingHomeUserWithDayKindForLunch, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForDinner), | |||
"value": enum.NursingHomeUserWithDayKindForDinner, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func NursingHomeReserveDetail(c *gin.Context) { | |||
id := c.DefaultQuery("id", "") | |||
NursingHomePackageOrdForReserveDb := db.NursingHomePackageOrdForReserve{} | |||
NursingHomePackageOrdForReserveDb.Set("") | |||
NursingHomePackageOrdForReserve, err := NursingHomePackageOrdForReserveDb.GetNursingHomePackageOrdForReserveById(utils.StrToInt(id)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if NursingHomePackageOrdForReserve == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到相应记录") | |||
return | |||
} | |||
var m []model.NursingHomeUserWithDay | |||
err = db.Db.Where("ord_no =?", NursingHomePackageOrdForReserve.OutTradeNo). | |||
And("date >=? and date <=?", NursingHomePackageOrdForReserve.MealTimeStart, NursingHomePackageOrdForReserve.MealTimeEnd). | |||
Find(&m) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": m, | |||
"kind_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForBreakfast), | |||
"value": enum.NursingHomeUserWithDayKindForBreakfast, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForLunch), | |||
"value": enum.NursingHomeUserWithDayKindForLunch, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForDinner), | |||
"value": enum.NursingHomeUserWithDayKindForDinner, | |||
}, | |||
}, | |||
"state_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForWait), | |||
"value": enum.NursingHomeUserWithDayStateForWait, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForAlready), | |||
"value": enum.NursingHomeUserWithDayStateForAlready, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForCanceling), | |||
"value": enum.NursingHomeUserWithDayStateForCanceling, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForCancel), | |||
"value": enum.NursingHomeUserWithDayStateForCancel, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func NursingHomeOrdRefund(c *gin.Context) { | |||
var req md.NursingHomeOrdRefundReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
err = svc2.NursingHomeOrdRefund(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func NursingHomeOrdDetail(c *gin.Context) { | |||
outTradeNo := c.DefaultQuery("out_trade_no", "") | |||
nursingHomePackageOrd := db.NursingHomePackageOrd{} | |||
nursingHomePackageOrd.Set(outTradeNo) | |||
ord, err := nursingHomePackageOrd.GetNursingHomePackageOrd() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if ord == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应订单记录") | |||
return | |||
} | |||
nursingHomeUserWithDayDb := db.NursingHomeUserWithDayDb{} | |||
nursingHomeUserWithDayDb.Set(0) | |||
list, err := nursingHomeUserWithDayDb.FindNursingHomeUserWithDayByOrdNo(ord.OutTradeNo) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": list, | |||
"kind_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForBreakfast), | |||
"value": enum.NursingHomeUserWithDayKindForBreakfast, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForLunch), | |||
"value": enum.NursingHomeUserWithDayKindForLunch, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForDinner), | |||
"value": enum.NursingHomeUserWithDayKindForDinner, | |||
}, | |||
}, | |||
"state_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForWait), | |||
"value": enum.NursingHomeUserWithDayStateForWait, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForAlready), | |||
"value": enum.NursingHomeUserWithDayStateForAlready, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForCanceling), | |||
"value": enum.NursingHomeUserWithDayStateForCanceling, | |||
}, | |||
{ | |||
"name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForCancel), | |||
"value": enum.NursingHomeUserWithDayStateForCancel, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func DeleteNursingHomePackage(c *gin.Context) { | |||
packageId := c.Param("id") | |||
err := svc.DeleteNursingHomePackage(utils.StrToInt(packageId)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} |
@@ -0,0 +1,13 @@ | |||
package hdl | |||
import ( | |||
"applet/app/admin/svc" | |||
"applet/app/e" | |||
"github.com/gin-gonic/gin" | |||
) | |||
func UserInfo(c *gin.Context) { | |||
admInfo := svc.GetUser(c) | |||
e.OutSuc(c, admInfo, nil) | |||
return | |||
} |
@@ -0,0 +1,394 @@ | |||
package hdl | |||
import ( | |||
"applet/app/admin/lib/validate" | |||
"applet/app/admin/md" | |||
svc "applet/app/admin/svc/enterprise_manage" | |||
svc2 "applet/app/admin/svc/order" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/e" | |||
"applet/app/enum" | |||
"applet/app/utils" | |||
"applet/app/utils/cache" | |||
"applet/app/utils/logx" | |||
"errors" | |||
"github.com/gin-gonic/gin" | |||
"time" | |||
) | |||
func CentralKitchenForSchoolOrderRefundList(c *gin.Context) { | |||
var req md.CentralKitchenForSchoolOrderRefundListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
list, total, err := svc2.CentralKitchenForSchoolOrderRefundList(c, req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": list, | |||
"total": total, | |||
"audit_kind_list": []map[string]interface{}{ | |||
{ | |||
"name": "同意", | |||
"value": 1, | |||
}, | |||
{ | |||
"name": "拒绝", | |||
"value": 2, | |||
}, | |||
}, | |||
"order_by_name_list": []map[string]interface{}{ | |||
{ | |||
"name": "按姓名升序", | |||
"value": 1, | |||
}, | |||
{ | |||
"name": "按姓名降序", | |||
"value": 2, | |||
}, | |||
}, | |||
"kind_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForBreakfast), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForBreakfast, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForLunch), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForLunch, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForDinner), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForDinner, | |||
}, | |||
}, | |||
"state_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForAuditing), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForAuditing, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForAuditPass), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForAuditPass, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForAuditReject), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForAuditReject, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForAuditComplete), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForAuditComplete, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForRefundIng), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForRefundIng, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForRefundErr), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForRefundErr, | |||
}, | |||
}, | |||
"user_identity_kind_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForStudent), | |||
"value": enum.UserIdentityForCentralKitchenForStudent, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForTeacher), | |||
"value": enum.UserIdentityForCentralKitchenForTeacher, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForWorker), | |||
"value": enum.UserIdentityForCentralKitchenForWorker, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent), | |||
"value": enum.UserIdentityForSelfSupportForStudent, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher), | |||
"value": enum.UserIdentityForSelfSupportForTeacher, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForWorker), | |||
"value": enum.UserIdentityForSelfSupportForWorker, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) { | |||
var req md.CentralKitchenForSchoolOrderRefundAuditReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
//限制500条 | |||
if len(req.Ids) > 500 { | |||
e.OutErr(c, e.ERR, errors.New("受理数据过长,请分批次处理")) | |||
return | |||
} | |||
//TODO:: 加锁 Redis 锁,防并发 | |||
getString, _ := cache.GetString(md.AuditLockKeyForCentralKitchenLockKey) | |||
if getString != "" { | |||
e.OutErr(c, e.ERR, "请稍等,存在其他退款处理中!") | |||
return | |||
} | |||
cache.Set(md.AuditLockKeyForCentralKitchenLockKey, "running") | |||
utils.FilePutContents("DealCentralKitchenForSchoolOrderRefundAudit", "退款处理,开始时间:::"+time.Now().Format("2006-01-02 15:04:05")) | |||
//先将所有申请单改成 审核通过 状态 | |||
session := db.Db.NewSession() | |||
defer session.Close() | |||
session.Begin() | |||
centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{} | |||
centralKitchenForSchoolUserRefundDayDb.Set(0) | |||
centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{} | |||
centralKitchenForSchoolUserWithDayDb.Set(0) | |||
var recordsId = map[int]bool{} | |||
for _, v := range req.Ids { | |||
returnDay, err1 := centralKitchenForSchoolUserRefundDayDb.GetCentralKitchenForSchoolUserRefundDay(utils.StrToInt(v)) | |||
if returnDay == nil { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
e.OutErr(c, e.ERR_DB_ORM, "记录id:【"+v+"】不存在") | |||
return | |||
} | |||
if err1 != nil { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
if returnDay.State != enum.CentralKitchenForSchoolUserRefundDayStateForAuditing && returnDay.State != enum.CentralKitchenForSchoolUserRefundDayStateForRefundErr { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
_ = session.Rollback() | |||
e.OutErr(c, e.ERR, "请勿重复审核申请单!") | |||
return | |||
} | |||
if recordsId[returnDay.RecordsId] { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
_ = session.Rollback() | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(0) | |||
identity, err11 := userIdentityDb.GetUserIdentity(returnDay.IdentityId) | |||
if err11 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err11.Error()) | |||
return | |||
} | |||
e.OutErr(c, e.ERR, "当前含有重复退订餐记录【身份名称:"+identity.Name+"】;"+"记录id:【"+v+"】!") | |||
return | |||
} | |||
recordsId[returnDay.RecordsId] = true | |||
//1、更新状态 | |||
if req.State == 1 { | |||
returnDay.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditPass | |||
} else { | |||
userWithDay, err3 := centralKitchenForSchoolUserWithDayDb.GetCentralKitchenForSchoolUserWithDay(returnDay.RecordsId) | |||
if err3 != nil { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
_ = session.Rollback() | |||
e.OutErr(c, e.ERR_DB_ORM, err3.Error()) | |||
return | |||
} | |||
returnDay.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditReject | |||
userWithDay.State = enum.CentralKitchenForSchoolUserWithDayStateForWait | |||
updateAck1, err4 := centralKitchenForSchoolUserWithDayDb.CentralKitchenForSchoolUserWithDayUpdateBySess(session, userWithDay.Id, userWithDay, "state") | |||
if err4 != nil { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
_ = session.Rollback() | |||
e.OutErr(c, e.ERR_DB_ORM, err4.Error()) | |||
return | |||
} | |||
if updateAck1 <= 0 { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
_ = session.Rollback() | |||
e.OutErr(c, e.ERR_DB_ORM, errors.New("更新退款就餐记录状态失败2")) | |||
return | |||
} | |||
//2、处理订单状态 | |||
err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo) | |||
if err5 != nil { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
_ = session.Rollback() | |||
e.OutErr(c, e.ERR, err5.Error()) | |||
return | |||
} | |||
} | |||
returnDay.Memo = req.Memo | |||
updateAck, err2 := centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayUpdateBySess(session, returnDay.Id, returnDay, "state", "memo") | |||
if err2 != nil { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
_ = session.Rollback() | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
return | |||
} | |||
if updateAck <= 0 { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
_ = session.Rollback() | |||
e.OutErr(c, e.ERR_DB_ORM, errors.New("更新退款订单记录状态失败1")) | |||
return | |||
} | |||
} | |||
err = session.Commit() | |||
if err != nil { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if req.State == 1 { | |||
//TODO::审核通过,进行退款处理 | |||
go func() { | |||
err1 := svc2.CentralKitchenForSchoolOrderRefundAudit(c, req) | |||
if err1 != nil { | |||
logx.Error(err1) | |||
println("<<<<CentralKitchenForSchoolOrderRefundAudit>>>>>Error:::", err1.Error()) | |||
var m model.CentralKitchenForSchoolUserRefundDay | |||
m.Memo = "退款处理失败:(" + err1.Error() + ")" | |||
m.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditing | |||
db.Db.In("id", req.Ids).Cols("memo", "state").Update(&m) | |||
} | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
utils.FilePutContents("DealCentralKitchenForSchoolOrderRefundAudit", "退款处理,结束时间:::"+time.Now().Format("2006-01-02 15:04:05")) | |||
}() | |||
} else { | |||
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func NursingHomeOrderRefundList(c *gin.Context) { | |||
var req md.NursingHomeOrderRefundListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
list, total, err := svc2.NursingHomeOrderRefundList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": list, | |||
"total": total, | |||
"audit_kind_list": []map[string]interface{}{ | |||
{ | |||
"name": "同意", | |||
"value": 1, | |||
}, | |||
{ | |||
"name": "拒绝", | |||
"value": 2, | |||
}, | |||
}, | |||
"kind_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForBreakfast), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForBreakfast, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForLunch), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForLunch, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForDinner), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForDinner, | |||
}, | |||
}, | |||
"state_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForAuditing), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForAuditing, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForAuditPass), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForAuditPass, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForAuditReject), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForAuditReject, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForAuditComplete), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForAuditComplete, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForRefundIng), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForRefundIng, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserRefundDayState.String(enum.CentralKitchenForSchoolUserRefundDayStateForRefundErr), | |||
"value": enum.CentralKitchenForSchoolUserRefundDayStateForRefundErr, | |||
}, | |||
}, | |||
"user_identity_kind_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForStudent), | |||
"value": enum.UserIdentityForCentralKitchenForStudent, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForTeacher), | |||
"value": enum.UserIdentityForCentralKitchenForTeacher, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForWorker), | |||
"value": enum.UserIdentityForCentralKitchenForWorker, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent), | |||
"value": enum.UserIdentityForSelfSupportForStudent, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher), | |||
"value": enum.UserIdentityForSelfSupportForTeacher, | |||
}, | |||
{ | |||
"name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForWorker), | |||
"value": enum.UserIdentityForSelfSupportForWorker, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func NursingHomeOrderRefundAudit(c *gin.Context) { | |||
var req md.NursingHomeOrderRefundAuditReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
err = svc2.NursingHomeOrderRefundAudit(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} |
@@ -0,0 +1,135 @@ | |||
package hdl | |||
import ( | |||
"applet/app/admin/lib/validate" | |||
"applet/app/admin/md" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/e" | |||
"applet/app/utils" | |||
"github.com/gin-gonic/gin" | |||
"time" | |||
) | |||
func BannerList(c *gin.Context) { | |||
bannerDb := db.BannerDb{} | |||
bannerDb.Set() | |||
banners, err := bannerDb.FindBanner(0, 0) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": banners, | |||
}, nil) | |||
return | |||
} | |||
func BannerSort(c *gin.Context) { | |||
var args struct { | |||
Ids []string `json:"ids" binding:"required"` | |||
} | |||
if err := c.ShouldBindJSON(&args); err != nil { | |||
e.OutErr(c, e.ERR_INVALID_ARGS, err) | |||
return | |||
} | |||
bannerDb := db.BannerDb{} | |||
bannerDb.Set() | |||
banners, err := bannerDb.FindBannerById(args.Ids) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
for k, v := range *banners { | |||
v.Sort = k | |||
_, err1 := bannerDb.BannerUpdate(&v, "sort") | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
} | |||
func BannerAdd(c *gin.Context) { | |||
var req md.BannerAddReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
bannerDb := db.BannerDb{} | |||
bannerDb.Set() | |||
now := time.Now() | |||
banner := model.Banner{ | |||
Name: req.Name, | |||
ImgUrl: req.ImgUrl, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
} | |||
_, err = bannerDb.BannerInsert(&banner) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func BannerUpdate(c *gin.Context) { | |||
var req md.BannerUpdateReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
bannerDb := db.BannerDb{} | |||
bannerDb.Set() | |||
banner, err := bannerDb.GetBanner(req.Id) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if banner == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
now := time.Now() | |||
banner.Name = req.Name | |||
banner.ImgUrl = req.ImgUrl | |||
banner.UpdateAt = now.Format("2006-01-02 15:04:05") | |||
_, err = bannerDb.BannerUpdate(banner, "name", "content", "update_at") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func BannerDelete(c *gin.Context) { | |||
id := c.Param("id") | |||
bannerDb := db.BannerDb{} | |||
bannerDb.Set() | |||
company, err := bannerDb.GetBanner(utils.StrToInt(id)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if company == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
_, err = bannerDb.BannerDelete(id) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} |
@@ -0,0 +1,109 @@ | |||
package hdl | |||
import ( | |||
"applet/app/admin/enum" | |||
"applet/app/admin/md" | |||
"applet/app/admin/svc" | |||
"applet/app/db" | |||
"applet/app/e" | |||
"applet/app/utils" | |||
"github.com/gin-gonic/gin" | |||
) | |||
func MenuList(c *gin.Context) { | |||
admin := svc.GetUser(c) | |||
qrcodeWithBatchRecordsDb := db.PermissionGroupDb{} | |||
qrcodeWithBatchRecordsDb.Set() | |||
groupList, err := qrcodeWithBatchRecordsDb.FindPermissionGroupV2() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
//1、查询出当前用户所有角色 | |||
adminRoleDb := db.AdminRoleDb{} | |||
adminRoleDb.Set() | |||
roles, err := adminRoleDb.FindAdminRole(admin.AdmId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
roleDb := db.RoleDb{} | |||
roleDb.Set(0) | |||
var adminHasPermissionGroupIds []string | |||
for _, v := range *roles { | |||
list, _, err1 := roleDb.FindPermissionGroupByRole(v.RoleId) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
for _, v1 := range list { | |||
adminHasPermissionGroupIds = append(adminHasPermissionGroupIds, utils.IntToStr(v1.PermissionGroup.Id)) | |||
} | |||
} | |||
var tempRespMap = map[string]*md.PermissionGroupListResp{} | |||
var tempRespMapKeys []string | |||
for _, v := range *groupList { | |||
var isCheck bool | |||
if admin.IsSuperAdministrator == enum.IsSuperAdministratorTure { | |||
isCheck = true | |||
} else { | |||
isCheck = false | |||
} | |||
if utils.InArr(utils.IntToStr(v.Id), adminHasPermissionGroupIds) { | |||
isCheck = true | |||
} | |||
if v.State == enum.PermissionGroupStateForDiscard { | |||
isCheck = false | |||
} | |||
tempRespMap[utils.IntToStr(v.Id)] = &md.PermissionGroupListResp{ | |||
Id: v.Id, | |||
Name: v.Name, | |||
Key: v.Key, | |||
State: v.State, | |||
ParentId: v.ParentId, | |||
CreateAt: v.CreateAt, | |||
UpdateAt: v.UpdateAt, | |||
IsCheck: isCheck, | |||
} | |||
tempRespMapKeys = append(tempRespMapKeys, utils.IntToStr(v.Id)) | |||
} | |||
for _, v := range tempRespMap { | |||
if v.ParentId != 0 && tempRespMap[utils.IntToStr(v.ParentId)].ParentId != 0 { | |||
tempRespMap[utils.IntToStr(v.ParentId)].SubPermissionGroupList = append(tempRespMap[utils.IntToStr(v.ParentId)].SubPermissionGroupList, *v) | |||
} | |||
} | |||
for _, v := range tempRespMap { | |||
if v.ParentId != 0 && tempRespMap[utils.IntToStr(v.ParentId)].ParentId == 0 { | |||
tempRespMap[utils.IntToStr(v.ParentId)].SubPermissionGroupList = append(tempRespMap[utils.IntToStr(v.ParentId)].SubPermissionGroupList, *v) | |||
} | |||
} | |||
var resp []*md.PermissionGroupListResp | |||
for _, v := range tempRespMapKeys { | |||
if tempRespMap[v].ParentId == 0 { | |||
resp = append(resp, tempRespMap[v]) | |||
} | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": resp, | |||
"state": []map[string]interface{}{ | |||
{ | |||
"name": enum.PermissionGroupState(enum.PermissionGroupStateForNormal).String(), | |||
"value": enum.PermissionGroupStateForNormal, | |||
}, | |||
{ | |||
"name": enum.PermissionGroupState(enum.PermissionGroupStateForDiscard).String(), | |||
"value": enum.PermissionGroupStateForDiscard, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} |
@@ -0,0 +1,127 @@ | |||
package hdl | |||
import ( | |||
"applet/app/admin/enum" | |||
"applet/app/admin/lib/validate" | |||
"applet/app/admin/md" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/e" | |||
"applet/app/utils" | |||
"github.com/gin-gonic/gin" | |||
"time" | |||
) | |||
func CompanyList(c *gin.Context) { | |||
companyDb := db.CompanyDb{} | |||
companyDb.Set() | |||
companies, err := companyDb.FindCompany(0, 0) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": companies, | |||
"state": []map[string]interface{}{ | |||
{ | |||
"name": "正常", | |||
"value": enum.CompanyStateForNormal, | |||
}, | |||
{ | |||
"name": "冻结", | |||
"value": enum.CompanyStateForFreeze, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func CompanyAdd(c *gin.Context) { | |||
var req md.CompanyAddReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
companyDb := db.CompanyDb{} | |||
companyDb.Set() | |||
now := time.Now() | |||
company := model.Company{ | |||
Name: req.Name, | |||
State: enum.CompanyStateForNormal, | |||
Memo: req.Memo, | |||
LeadName: req.LeadName, | |||
LeadPhone: req.LeadPhone, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
} | |||
_, err = companyDb.CompanyInsert(&company) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func CompanyUpdate(c *gin.Context) { | |||
var req md.CompanyUpdateReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
companyDb := db.CompanyDb{} | |||
companyDb.Set() | |||
company, err := companyDb.GetCompany(req.Id) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if company == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
now := time.Now() | |||
company.Name = req.Name | |||
company.LeadName = req.LeadName | |||
company.LeadPhone = req.LeadPhone | |||
if req.State != 0 { | |||
company.State = req.State | |||
} | |||
company.UpdateAt = now.Format("2006-01-02 15:04:05") | |||
_, err = companyDb.CompanyUpdate(company, "name", "memo", "state", "lead_name", "lead_phone", "update_at") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func CompanyDelete(c *gin.Context) { | |||
id := c.Param("id") | |||
companyDb := db.CompanyDb{} | |||
companyDb.Set() | |||
company, err := companyDb.GetCompany(utils.StrToInt(id)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if company == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
_, err = companyDb.CompanyDelete(id) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} |
@@ -0,0 +1,402 @@ | |||
package hdl | |||
import ( | |||
"applet/app/admin/lib/validate" | |||
"applet/app/admin/md" | |||
"applet/app/admin/svc" | |||
"applet/app/db" | |||
"applet/app/e" | |||
"github.com/gin-gonic/gin" | |||
"os" | |||
) | |||
func CentralKitchenForSchoolDataStatisticsList(c *gin.Context) { | |||
var req md.CentralKitchenForSchoolExportRecordsListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
if req.Limit == 0 { | |||
req.Limit = 10 | |||
} | |||
if req.Page == 0 { | |||
req.Page = 10 | |||
} | |||
centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{} | |||
centralKitchenForSchoolExportRecordsDb.Set() | |||
list, total, err := centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": list, | |||
"total": total, | |||
"enterprise_kind_list": md.EnterpriseKindForSchool, | |||
"kind": []map[string]interface{}{ | |||
{ | |||
"name": "订单列表", | |||
"value": 1, | |||
}, | |||
{ | |||
"name": "退款申请表", | |||
"value": 2, | |||
}, | |||
{ | |||
"name": "学校预定统计表", | |||
"value": 3, | |||
}, | |||
{ | |||
"name": "班级明细表", | |||
"value": 4, | |||
}, | |||
{ | |||
"name": "退款明细表", | |||
"value": 5, | |||
}, | |||
{ | |||
"name": "收款统计表", | |||
"value": 6, | |||
}, | |||
{ | |||
"name": "班级收款明细表", | |||
"value": 7, | |||
}, | |||
{ | |||
"name": "学校预定数量统计表", | |||
"value": 8, | |||
}, | |||
{ | |||
"name": "数据对比", | |||
"value": 9, | |||
}, | |||
{ | |||
"name": "就餐数据统计表", | |||
"value": 10, | |||
}, | |||
{ | |||
"name": "教师就餐明细表", | |||
"value": 11, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func CentralKitchenForSchoolDataStatisticsDelete(c *gin.Context) { | |||
var req struct { | |||
Ids []int `json:"ids"` | |||
} | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
for _, id := range req.Ids { | |||
centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{} | |||
centralKitchenForSchoolExportRecordsDb.Set() | |||
centralKitchenForSchoolExportRecords, err0 := centralKitchenForSchoolExportRecordsDb.GetCentralKitchenForSchoolExportRecords(id) | |||
if err0 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err0.Error()) | |||
return | |||
} | |||
if centralKitchenForSchoolExportRecords == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录") | |||
return | |||
} | |||
_, err1 := centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsDelete(id) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func CentralKitchenForSchoolDataStatisticsExport(c *gin.Context) { | |||
var req md.CentralKitchenForSchoolDataStatisticsExportReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
if req.EnterpriseId != 0 { | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
req.EnterpriseName = enterprise.Name | |||
} | |||
go svc.CentralKitchenForSchoolDataStatisticsExport(req) | |||
e.OutSuc(c, map[string]interface{}{ | |||
"msg": "导出成功,请稍后刷新数据列表", | |||
}, nil) | |||
return | |||
} | |||
func CentralKitchenForSchoolDataStatisticsContrast(c *gin.Context) { | |||
var req md.CentralKitchenForSchoolDataStatisticsContrastReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
if req.EnterpriseId != 0 { | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
req.EnterpriseName = enterprise.Name | |||
} | |||
go svc.CentralKitchenForSchoolDataStatisticsContrast(req) | |||
e.OutSuc(c, map[string]interface{}{ | |||
"msg": "导出成功,请稍后刷新数据列表", | |||
}, nil) | |||
return | |||
} | |||
func NursingHomeDataStatisticsList(c *gin.Context) { | |||
var req md.NursingHomeExportRecordsListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
if req.Limit == 0 { | |||
req.Limit = 10 | |||
} | |||
if req.Page == 0 { | |||
req.Page = 10 | |||
} | |||
nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{} | |||
nursingHomeExportRecordsDb.Set() | |||
list, total, err := nursingHomeExportRecordsDb.NursingHomeExportRecordsList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": list, | |||
"total": total, | |||
"kind": []map[string]interface{}{ | |||
{ | |||
"name": "订单列表", | |||
"value": 1, | |||
}, | |||
{ | |||
"name": "退款申请表", | |||
"value": 2, | |||
}, | |||
{ | |||
"name": "预定统计表", | |||
"value": 3, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func NursingHomeDataStatisticsDelete(c *gin.Context) { | |||
var req struct { | |||
Ids []int `json:"ids"` | |||
} | |||
err := c.ShouldBindJSON(&req) | |||