DengBiao пре 1 година
родитељ
комит
39c6b2ba23
26 измењених фајлова са 318 додато и 255 уклоњено
  1. +1
    -0
      .gitignore
  2. +15
    -11
      app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go
  3. +82
    -26
      app/admin/hdl/hdl_enterprise.go
  4. +2
    -1
      app/admin/hdl/hdl_sys_cfg.go
  5. +0
    -85
      app/admin/lib/wx/wx_official_account.go
  6. +2
    -0
      app/admin/md/md_enterprise.go
  7. +7
    -1
      app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go
  8. +8
    -0
      app/customer/hdl/hdl_central_kitchen_for_school_order.go
  9. +27
    -0
      app/customer/hdl/hdl_demo.go
  10. +1
    -1
      app/customer/hdl/hdl_enterprise.go
  11. +2
    -1
      app/customer/hdl/hdl_sys_cfg.go
  12. +20
    -2
      app/customer/hdl/hdl_user.go
  13. +16
    -115
      app/customer/hdl/hdl_user_identity.go
  14. +1
    -0
      app/customer/md/md_curl_smart_pay.go
  15. +16
    -0
      app/customer/md/md_order.go
  16. +1
    -1
      app/customer/md/md_pay.go
  17. +45
    -1
      app/customer/svc/order/svc_central_kitchen_for_school_order.go
  18. +9
    -2
      app/customer/svc/svc_pay.go
  19. +7
    -6
      app/db/db_central_kitchen_for_school_user_with_day.go
  20. +20
    -0
      app/db/db_class.go
  21. +20
    -0
      app/db/db_grade.go
  22. +1
    -1
      app/db/model/central_kitchen_for_school_package_ord.go
  23. +2
    -0
      app/db/model/self_support_for_school_info.go
  24. +12
    -0
      app/router/admin_router.go
  25. +1
    -0
      app/router/customer_router.go
  26. +0
    -1
      etc/cfg.yml

+ 1
- 0
.gitignore Прегледај датотеку

@@ -44,3 +44,4 @@ nginx.conf
/tmp/*
.idea/*
/.idea/modules.xml
/etc/*

+ 15
- 11
app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go Прегледај датотеку

@@ -677,17 +677,17 @@ func CentralKitchenForSchoolOrdList(c *gin.Context) {
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
}
//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
//}

resp, total, err := svc2.CentralKitchenForSchoolOrdList(req)
if err != nil {
@@ -710,6 +710,10 @@ func CentralKitchenForSchoolOrdList(c *gin.Context) {
"name": "按天购买",
"value": "3",
},
{
"name": "补餐",
"value": "4",
},
},
"state_list": []map[string]interface{}{
{


+ 82
- 26
app/admin/hdl/hdl_enterprise.go Прегледај датотеку

@@ -204,45 +204,101 @@ func EnterpriseUpdate(c *gin.Context) {
return
}

//2、更新 grade && class 数据

//2、删除 grade && class 数据
gradeDb := db.GradeDb{}
gradeDb.Set(req.Id)
_, err = gradeDb.ClassDeleteBySessionForEnterprise(db.Db.NewSession(), req.Id)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
//_, err = gradeDb.ClassDeleteBySessionForEnterprise(db.Db.NewSession(), req.Id)
//if err != nil {
// e.OutErr(c, e.ERR_DB_ORM, err.Error())
// return
//}
classDb := db.ClassDb{}
classDb.Set(0)
_, err = classDb.ClassDeleteBySessionForEnterprise(db.Db.NewSession(), req.Id)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
//_, err = classDb.ClassDeleteBySessionForEnterprise(db.Db.NewSession(), req.Id)
//if err != nil {
// e.OutErr(c, e.ERR_DB_ORM, err.Error())
// return
//}

//新增 grade 数据 && class 数据
for _, v := range req.GradeList {
insertId, err1 := gradeDb.GradeInsert(&model.Grade{
EnterpriseId: req.Id,
Name: v.Name,
Memo: "",
CreateAt: now,
UpdateAt: now,
})
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
var classes []*model.Class
for _, v1 := range v.ClassList {
classes = append(classes, &model.Class{
Name: v1.Name,
Memo: "",
GradeId: insertId,

if v.Id == 0 {
//TODO::新增
insertId, err1 := gradeDb.GradeInsert(&model.Grade{
EnterpriseId: req.Id,
Name: v.Name,
Memo: "",
CreateAt: now,
UpdateAt: now,
})
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
for _, v1 := range v.ClassList {
classes = append(classes, &model.Class{
Name: v1.Name,
Memo: "",
GradeId: insertId,
EnterpriseId: req.Id,
CreateAt: now,
UpdateAt: now,
})
}

} else {
//TODO::编辑
grade, err3 := gradeDb.GetGrade(v.Id)
if err3 != nil {
e.OutErr(c, e.ERR_DB_ORM, err3.Error())
return
}
if grade == nil {
e.OutErr(c, e.ERR_NO_DATA, "未查询到相关年级信息")
return
}

grade.Name = v.Name
_, err4 := gradeDb.GradeUpdate(grade, "name")
if err4 != nil {
e.OutErr(c, e.ERR_DB_ORM, err4.Error())
return
}

for _, v1 := range v.ClassList {
if v1.Id == 0 {
//新增
classes = append(classes, &model.Class{
Name: v1.Name,
Memo: "",
GradeId: grade.Id,
EnterpriseId: req.Id,
CreateAt: now,
UpdateAt: now,
})
} else {
//编辑
class, err5 := classDb.GetClass(v1.Id)
if err5 != nil {
e.OutErr(c, e.ERR_DB_ORM, err5.Error())
return
}
if class == nil {
e.OutErr(c, e.ERR_NO_DATA, "未查询到相关班级信息")
return
}
class.Name = v1.Name
_, err6 := classDb.ClassUpdate(class, "name")
if err6 != nil {
e.OutErr(c, e.ERR_DB_ORM, err6.Error())
return
}
}
}
}

if len(classes) > 0 {


+ 2
- 1
app/admin/hdl/hdl_sys_cfg.go Прегледај датотеку

@@ -11,7 +11,8 @@ func GetSysCfg(c *gin.Context) {
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
res := sysCfgDb.SysCfgFindWithDb(enum.AppName, enum.OpenAppletPublicKey, enum.OpenAppletAppPublicKey, enum.OpenAppletAppPrivateKey, enum.OpenAppletAesKey,
enum.FileBucket, enum.FileExt, enum.FileAccessKey, enum.FileUserUploadMaxSize, enum.FileSecretKey, enum.FileBucketScheme, enum.FileBucketRegion, enum.FileBucketHost)
enum.FileBucket, enum.FileExt, enum.FileAccessKey, enum.FileUserUploadMaxSize, enum.FileSecretKey, enum.FileBucketScheme, enum.FileBucketRegion, enum.FileBucketHost,
)
e.OutSuc(c, res, nil)
return
}

+ 0
- 85
app/admin/lib/wx/wx_official_account.go Прегледај датотеку

@@ -1,85 +0,0 @@
package wx

import (
"applet/app/admin/db"
enum2 "applet/app/admin/enum"
md2 "applet/app/admin/md"
"applet/app/utils"
"applet/app/utils/cache"
"encoding/json"
"errors"
)

type OfficialAccount struct {
AccessToken string `json:"access_token"`
Appid string `json:"appid"`
Secret string `json:"secret"`
}

func (officialAccount *OfficialAccount) Set() { // set方法
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
officialAccount.Appid = sysCfgDb.SysCfgGetWithDb(enum2.WxOfficialAccountAppId)
officialAccount.Secret = sysCfgDb.SysCfgGetWithDb(enum2.WxOfficialAccountAppSecret)
officialAccount.AccessToken = officialAccount.createToken()
}

func (officialAccount *OfficialAccount) createToken() (accessToken string) {
cacheKey := md2.WxOfficialAccountCacheKey
accessToken, _ = cache.GetString(cacheKey)
if accessToken != "" {
return
}

url := md2.WxOfficialAccountRequestBaseUrl + enum2.GetAccessToken
post, err := utils.CurlPost(url, map[string]string{
"appid": officialAccount.Appid,
"secret": officialAccount.Secret,
"grant_type": "client_credential",
}, nil)

utils.FilePutContents("wx_official_account_create_token", "resp"+string(post))
var data md2.CreateTokenResp
err = json.Unmarshal(post, &data)
if err != nil {
return
}
if data.AccessToken == "" {
panic(errors.New("获取 access_token 失败"))
}

accessToken = data.AccessToken
cache.SetEx(cacheKey, accessToken, int(data.ExpiresIn-3600))
return
}

func (officialAccount *OfficialAccount) QrcodeCreate(sceneStr string) (qrcodeUrl string, err error) {
url := md2.WxOfficialAccountRequestBaseUrl + enum2.QrcodeCreate + "?access_token=" + officialAccount.AccessToken
//post, err := utils.CurlPost(url, map[string]interface{}{
// "action_name": "QR_LIMIT_STR_SCENE",
// "action_info": map[string]interface{}{
// "scene": map[string]string{
// "scene_str": sceneStr,
// },
// },
//}, nil)
requestBody, _ := json.Marshal(map[string]interface{}{
"action_name": "QR_STR_SCENE",
"expire_seconds": "6000",
"action_info": map[string]interface{}{
"scene": map[string]string{
"scene_str": sceneStr,
},
},
})
post, err := utils.CurlPost(url, requestBody, nil)

utils.FilePutContents("wx_official_account_qrcode_create", "resp"+string(post))
var data md2.CreateQrcodeResp
err = json.Unmarshal(post, &data)
if err != nil {
return
}
qrcodeUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + data.Ticket
return
}

+ 2
- 0
app/admin/md/md_enterprise.go Прегледај датотеку

@@ -19,8 +19,10 @@ type EnterpriseUpdateReq struct {
Memo string `json:"memo" label:"备注"`
State int32 `json:"state" label:"状态"`
GradeList []struct {
Id int `json:"id" label:"年级id"`
Name string `json:"name" label:"名称"`
ClassList []struct {
Id int `json:"id" label:"班级id"`
Name string `json:"name" label:"名称"`
} `json:"class_list" label:"班级"`
} `json:"grade_list" label:"年级"`


+ 7
- 1
app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go Прегледај датотеку

@@ -356,7 +356,11 @@ func CentralKitchenForSchoolOrdList(req md.CentralKitchenForSchoolOrdListReq) (r
classWithUserIdentityIdsTwo = append(classWithUserIdentityIdsTwo, v.UserIdentityId)
}
}
sess := db.Db.Where("central_kitchen_for_school_package_ord.enterprise_id =?", req.EnterpriseId)

sess := db.Db.Desc("central_kitchen_for_school_package_ord.id")
if req.EnterpriseId != 0 {
sess.And("central_kitchen_for_school_package_ord.enterprise_id =?", req.EnterpriseId)
}
if req.StartDate != "" {
sess.And("central_kitchen_for_school_package_ord.create_at >= ?", req.StartDate)
}
@@ -497,6 +501,8 @@ func JudgePackageOrdOrdState(outTradeNo string) (err error) {
}
if count == 0 {
ordState = enum2.CentralKitchenForSchoolPackageOrdOrdStateForComplete
} else {
ordState = enum2.CentralKitchenForSchoolPackageOrdOrdStateForSuccess
}

//2、判断是否有 `已退款` / `部分退款`


+ 8
- 0
app/customer/hdl/hdl_central_kitchen_for_school_order.go Прегледај датотеку

@@ -66,6 +66,10 @@ func CentralKitchenForSchoolOrderList(c *gin.Context) {
"name": "按天购买",
"value": "3",
},
{
"name": "补餐",
"value": "4",
},
},
}, nil)
return
@@ -159,6 +163,10 @@ func CentralKitchenForSchoolOrderDetail(c *gin.Context) {
"name": "按天购买",
"value": "3",
},
{
"name": "补餐",
"value": "4",
},
},
}, nil)
return


+ 27
- 0
app/customer/hdl/hdl_demo.go Прегледај датотеку

@@ -0,0 +1,27 @@
package hdl

import (
"applet/app/admin/lib/validate"
"applet/app/customer/md"
"applet/app/customer/svc"
"applet/app/e"
"github.com/gin-gonic/gin"
)

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

+ 1
- 1
app/customer/hdl/hdl_enterprise.go Прегледај датотеку

@@ -85,7 +85,7 @@ func EnterpriseInfo(c *gin.Context) {

sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime)
res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, enum.CentralKitchenForSchoolCancelMealTime)
e.OutSuc(c, map[string]interface{}{
"info": resp,
"set_center": res,


+ 2
- 1
app/customer/hdl/hdl_sys_cfg.go Прегледај датотеку

@@ -11,7 +11,8 @@ func GetSysCfg(c *gin.Context) {
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
res := sysCfgDb.SysCfgFindWithDb(enum.AppName, enum.OpenAppletAppid, enum.OpenAppletPublicKey, enum.OpenAppletAppPublicKey, enum.OpenAppletAppPrivateKey, enum.OpenAppletAesKey,
enum.FileBucket, enum.FileExt, enum.FileAccessKey, enum.FileUserUploadMaxSize, enum.FileSecretKey, enum.FileBucketScheme, enum.FileBucketRegion, enum.FileBucketHost)
enum.FileBucket, enum.FileExt, enum.FileAccessKey, enum.FileUserUploadMaxSize, enum.FileSecretKey, enum.FileBucketScheme, enum.FileBucketRegion, enum.FileBucketHost,
)
e.OutSuc(c, res, nil)
return
}

+ 20
- 2
app/customer/hdl/hdl_user.go Прегледај датотеку

@@ -21,12 +21,30 @@ func UserInfo(c *gin.Context) {
return
}
var identityList []map[string]interface{}
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
for _, v := range *identity {
identityList = append(identityList, map[string]interface{}{
var tmp = map[string]interface{}{
"identity": v.UserIdentity,
"enterprise": v.Enterprise,
})
"grade": nil,
"class": nil,
}
if v.UserIdentity.Identity == enum.UserIdentityForCentralKitchenForStudent || v.UserIdentity.Identity == enum.UserIdentityForSelfSupportForStudent {
//央厨学生 or 自营学生
data, err1 := classWithUserDb.GetInfoByUserIdentityId(v.UserIdentity.Id)
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
if data != nil {
tmp["grade"] = data.Grade
tmp["class"] = data.Class
}
}
identityList = append(identityList, tmp)
}

e.OutSuc(c, map[string]interface{}{
"user_info": userInfo,
"user_identity": identityList,


+ 16
- 115
app/customer/hdl/hdl_user_identity.go Прегледај датотеку

@@ -4,10 +4,12 @@ import (
"applet/app/customer/lib/validate"
"applet/app/customer/md"
"applet/app/customer/svc"
svc2 "applet/app/customer/svc/order"
"applet/app/db"
"applet/app/db/model"
"applet/app/e"
"applet/app/enum"
"applet/app/utils"
"github.com/gin-gonic/gin"
"time"
)
@@ -35,7 +37,7 @@ func SaveCentralKitchenForSchoolUserIdentity(c *gin.Context) {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if isHasUserIdentity != nil {
if isHasUserIdentity.Uid != 0 && isHasUserIdentity.Uid != user.Id {
e.OutErr(c, e.ERR, "当前身份信息已被绑定使用")
return
}
@@ -157,7 +159,7 @@ func SaveSelfSupportForSchoolUserIdentity(c *gin.Context) {
}
}
} else {
if isHasUserIdentity.Uid != 0 {
if isHasUserIdentity.Uid != 0 && isHasUserIdentity.Uid != user.Id {
e.OutErr(c, e.ERR, "当前身份信息已被绑定使用")
return
}
@@ -205,123 +207,22 @@ func SaveSelfSupportForSchoolUserIdentity(c *gin.Context) {
}

func CentralKitchenForSchoolMyReserve(c *gin.Context) {
//user := svc.GetUser(c)
var req md.SaveSelfSupportForSchoolUserIdentityReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
date := c.DefaultQuery("date", "")
userIdentityId := c.DefaultQuery("user_identity_id", "")
if date == "" {
e.OutErr(c, e.ERR_INVALID_ARGS, "日期不能为空")
return
}
user := svc.GetUser(c)
now := time.Time{}
var identity = enum.UserIdentityForSelfSupportForStudent
var kind = enum.UserIdentityKindForCommon
if req.Kind == enum.UserIdentityKindForWorker {
kind = enum.UserIdentityKindForWorker
identity = enum.UserIdentityForSelfSupportForWorker
} else {
if req.IsTeacher {
identity = enum.UserIdentityForCentralKitchenForTeacher
}
}

//1、判断当前身份是否已绑定
userIdentityDb := db.UserIdentityDb{}
userIdentityDb.Set(user.Id)
isHasUserIdentity, err := userIdentityDb.UserIdentityExist(req.EnterpriseId, req.IdNo)
startDate := date + "-01"
startDateTime, _ := time.Parse("2006-01-02", startDate)
endDate := startDateTime.AddDate(0, 1, -1).Format("2006-01-02")
err, resp := svc2.CentralKitchenForSchoolMyReserve(utils.StrToInt(userIdentityId), date, startDate, endDate)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
e.OutErr(c, e.ERR, err.Error())
return
}

if isHasUserIdentity == nil {
if identity != enum.UserIdentityForSelfSupportForStudent {
e.OutErr(c, e.ERR_NO_DATA, "当前身份信息不存在")
return
}
//2、新增身份信息
userIdentity := &model.UserIdentity{
Uid: user.Id,
Name: req.Name,
IdNo: req.IdNo,
Kind: kind,
Identity: identity,
EnterpriseId: req.EnterpriseId,
State: enum.UserIdentityStateForNormal,
Memo: "",
CreateAt: now,
UpdateAt: now,
}
insertAffected, err := userIdentityDb.UserIdentityInsert(userIdentity)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if insertAffected <= 0 {
e.OutErr(c, e.ERR_DB_ORM, "新增身份数据失败")
return
}
//3、新增 class_with_user 记录
if !req.IsTeacher {
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
_, err = classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{
UserIdentityId: insertAffected,
ClassId: req.ClassId,
CreateAt: now,
UpdateAt: now,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
}
} else {
if isHasUserIdentity.Uid != 0 {
e.OutErr(c, e.ERR, "当前身份信息已被绑定使用")
return
}
//4、修改身份信息
isHasUserIdentity.Uid = user.Id
isHasUserIdentity.Name = req.Name
_, err = userIdentityDb.UserIdentityUpdate(isHasUserIdentity.Id, isHasUserIdentity, "uid", "name")
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

if identity == enum.UserIdentityForSelfSupportForStudent {
//5、修改 class_with_user 记录
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
classWithUser, err1 := classWithUserDb.GetClassWithUserByUserIdentityId(isHasUserIdentity.Id)
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
if classWithUser == nil {
_, err2 := classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{
UserIdentityId: isHasUserIdentity.Id,
ClassId: req.ClassId,
CreateAt: now,
UpdateAt: now,
})
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}
} else {
classWithUser.ClassId = req.ClassId
_, err2 := classWithUserDb.ClassWithUserUpdateByUserIdentity(isHasUserIdentity.Id, classWithUser, "class_id")
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}
}
}
}
e.OutSuc(c, "success", nil)
e.OutSuc(c, map[string]interface{}{
"info": resp,
}, nil)
return
}

+ 1
- 0
app/customer/md/md_curl_smart_pay.go Прегледај датотеку

@@ -14,6 +14,7 @@ type CurlAlipayTradeCreateReq struct {
PayAliPrivateKey string `json:"pay_ali_private_key" binding:"required" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"`
PayAliPublicKey string `json:"pay_ali_public_key" binding:"required" label:"支付宝开放平台-第三方应用-接口加签-支付宝公钥"`
} `json:"config" binding:"required" label:"配置信息"`
OpAppId string `json:"op_app_id" binding:"required" label:"小程序支付中,商户实际经营主体的小程序应用的appid,也即最终唤起收银台支付所在的小程序的应用id"`
BuyerId string `json:"buyer_id" binding:"required" label:"买家支付宝用户ID"`
TotalAmount string `json:"total_amount" binding:"required" label:"订单总金额"`
OutTradeNo string `json:"out_trade_no" binding:"required" label:"商户订单号"`


+ 16
- 0
app/customer/md/md_order.go Прегледај датотеку

@@ -29,3 +29,19 @@ type CentralKitchenForSchoolOrderRefundListResp struct {
Memo string `json:"memo" label:"备注"`
Amount string `json:"amount" label:"退款金额"`
}

type CentralKitchenForSchoolMyReserveResp struct {
Date string `json:"date" label:"日期"`
BreakfastTotal int `json:"breakfast_total" label:"早餐-总计"`
LunchTotal int `json:"lunch_total" label:"午餐-总计"`
DinnerTotal int `json:"dinner_total" label:"晚餐-总计"`
Total int `json:"total" label:"数量-总计"`
List []CentralKitchenForSchoolMyReserveRespList `json:"list" label:"列表"`
}

type CentralKitchenForSchoolMyReserveRespList struct {
Date string `json:"date" label:"日期"`
BreakfastTotal int `json:"breakfast_total" label:"早餐-总计"`
LunchTotal int `json:"lunch_total" label:"午餐-总计"`
DinnerTotal int `json:"dinner_total" label:"晚餐-总计"`
}

+ 1
- 1
app/customer/md/md_pay.go Прегледај датотеку

@@ -4,7 +4,7 @@ type BuyPackageReq struct {
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"`
UserIdentityId int `json:"user_identity_id" binding:"required" label:"用户身份id"`
PackageId int `json:"package_id" label:"套餐ID"`
Kind int `json:"kind" binding:"required" label:"购买类型(1:按学期购买 2:按月购买 3:按天购买)"`
Kind int `json:"kind" binding:"required" label:"购买类型(1:按学期购买 2:按月购买 3:按天购买 4:补餐)"`
IsBuyBreakfast int `json:"is_buy_breakfast" label:"是否购买早餐(1:是 2:否)"`
IsBuyLunch int `json:"is_buy_lunch" label:"是否购买午餐(1:是 2:否)"`
IsBuyDinner int `json:"is_buy_dinner" label:"是否购买晚餐(1:是 2:否)"`


+ 45
- 1
app/customer/svc/order/svc_central_kitchen_for_school_order.go Прегледај датотеку

@@ -99,7 +99,7 @@ func CentralKitchenForSchoolOrderRefund(req md.CentralKitchenForSchoolOrderRefun
func CentralKitchenForSchoolOrderRefundList(req md.CentralKitchenForSchoolOrderRefundListReq) (resp []md.CentralKitchenForSchoolOrderRefundListResp, total int64, err error) {
var m []*db.CentralKitchenForSchoolUserRefundDayWithCentralKitchenForSchoolUserWithDay
sess := db.Db.Where("central_kitchen_for_school_user_refund_day.identity_id =?", req.UserIdentityId)
total, err = sess.
total, err = sess.Desc("central_kitchen_for_school_user_refund_day.id").
Join("LEFT", "central_kitchen_for_school_user_with_day", "central_kitchen_for_school_user_refund_day.records_id = central_kitchen_for_school_user_with_day.id").
Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
if err != nil {
@@ -120,3 +120,47 @@ func CentralKitchenForSchoolOrderRefundList(req md.CentralKitchenForSchoolOrderR
}
return
}

func CentralKitchenForSchoolMyReserve(userIdentityId int, date, startDate, endDate string) (err error, resp md.CentralKitchenForSchoolMyReserveResp) {
resp.Date = date
//1、查询出对应时间段,所有 "待就餐"、 "已就餐" 记录
centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{}
centralKitchenForSchoolUserWithDayDb.Set(userIdentityId)
list, err := centralKitchenForSchoolUserWithDayDb.FindCentralKitchenForSchoolUserWithDayByDate(startDate, endDate)
if err != nil {
return
}

//2、构造数据
var totalBreakfast, totalLunch, totalDinner, total int
var dateMap = map[string]*md.CentralKitchenForSchoolMyReserveRespList{}
for _, v := range *list {
if v.State == enum.CentralKitchenForSchoolUserWithDayStateForWait || v.State == enum.CentralKitchenForSchoolUserWithDayStateForAlready {
if dateMap[v.Date] == nil {
dateMap[v.Date] = &md.CentralKitchenForSchoolMyReserveRespList{}
}
dateMap[v.Date].Date = v.Date
total++
if v.Kind == enum.CentralKitchenForSchoolUserWithDayKindForBreakfast {
totalBreakfast++
dateMap[v.Date].BreakfastTotal++
}
if v.Kind == enum.CentralKitchenForSchoolUserWithDayKindForLunch {
totalLunch++
dateMap[v.Date].LunchTotal++
}
if v.Kind == enum.CentralKitchenForSchoolUserWithDayKindForDinner {
dateMap[v.Date].DinnerTotal++
totalDinner++
}
}
}
resp.Total = total
resp.LunchTotal = totalLunch
resp.DinnerTotal = totalDinner
resp.BreakfastTotal = totalBreakfast
for _, v := range dateMap {
resp.List = append(resp.List, *v)
}
return
}

+ 9
- 2
app/customer/svc/svc_pay.go Прегледај датотеку

@@ -37,7 +37,7 @@ func BuyPackage(c *gin.Context, req md.BuyPackageReq) (outTradeNo, tradeNo, tota
isTeacher = true
}

//2、计算数据(1:按学期购买 2:按月购买 3:按天购买)
//2、计算数据(1:按学期购买 2:按月购买 3:按天购买 4:补餐)
var totalPrice float64
var data []*model.CentralKitchenForSchoolUserWithDay
if req.Kind == 1 {
@@ -58,6 +58,12 @@ func BuyPackage(c *gin.Context, req md.BuyPackageReq) (outTradeNo, tradeNo, tota
return
}
}
if req.Kind == 4 {
totalPrice, data, err = CalcByDay(user.Id, isTeacher, req)
if err != nil {
return
}
}
total = utils.Float64ToStr(totalPrice)

//3、生成订单号
@@ -66,7 +72,7 @@ func BuyPackage(c *gin.Context, req md.BuyPackageReq) (outTradeNo, tradeNo, tota
//4、请求 alipay.trade.create(统一收单交易创建接口)
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
sysCfg := sysCfgDb.SysCfgFindWithDb(enum2.OpenAlipayAppid, enum2.OpenAlipayAppPrivateKey, enum2.OpenAlipayPublicKey, enum2.JsapiPayAppAutToken)
sysCfg := sysCfgDb.SysCfgFindWithDb(enum2.OpenAppletAppid, enum2.OpenAlipayAppid, enum2.OpenAlipayAppPrivateKey, enum2.OpenAlipayPublicKey, enum2.JsapiPayAppAutToken)
err, resp := CurlAlipayTradeCreate(md.CurlAlipayTradeCreateReq{
Config: struct {
PayAliAppId string `json:"pay_ali_app_id" binding:"required" label:"支付宝开放平台-第三方应用-appid"`
@@ -77,6 +83,7 @@ func BuyPackage(c *gin.Context, req md.BuyPackageReq) (outTradeNo, tradeNo, tota
PayAliPrivateKey: sysCfg[enum2.OpenAlipayAppPrivateKey],
PayAliPublicKey: sysCfg[enum2.OpenAlipayPublicKey],
},
OpAppId: sysCfg[enum2.OpenAppletAppid],
BuyerId: user.UserId,
TotalAmount: total,
OutTradeNo: outTradeNo,


+ 7
- 6
app/db/db_central_kitchen_for_school_user_with_day.go Прегледај датотеку

@@ -8,13 +8,13 @@ import (
)

type CentralKitchenForSchoolUserWithDayDb struct {
Db *xorm.Engine `json:"db"`
Uid int `json:"uid"`
Db *xorm.Engine `json:"db"`
IdentityId int `json:"identity_id"`
}

func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) Set(uid int) { // set方法
func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) Set(identityId int) { // set方法
centralKitchenForSchoolUserWithDayDb.Db = Db
centralKitchenForSchoolUserWithDayDb.Uid = uid
centralKitchenForSchoolUserWithDayDb.IdentityId = identityId
}

func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) GetCentralKitchenForSchoolUserWithDay(id int) (m *model.CentralKitchenForSchoolUserWithDay, err error) {
@@ -29,9 +29,10 @@ func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb
return m, nil
}

func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) FindCentralKitchenForSchoolUserWithDay() (*[]model.CentralKitchenForSchoolUserWithDay, error) {
func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) FindCentralKitchenForSchoolUserWithDayByDate(sDate, eDate string) (*[]model.CentralKitchenForSchoolUserWithDay, error) {
var m []model.CentralKitchenForSchoolUserWithDay
if err := centralKitchenForSchoolUserWithDayDb.Db.Where("uid =?", centralKitchenForSchoolUserWithDayDb.Uid).Desc("id").Find(&m); err != nil {
if err := centralKitchenForSchoolUserWithDayDb.Db.Where("identity_id =?", centralKitchenForSchoolUserWithDayDb.IdentityId).
And("date >= ? And date <= ?", sDate, eDate).Desc("id").Find(&m); err != nil {
return nil, logx.Error(err)
}
return &m, nil


+ 20
- 0
app/db/db_class.go Прегледај датотеку

@@ -70,3 +70,23 @@ func (classDb *ClassDb) CountClassForEnterprise(enterpriseId int) (total int64,
}
return
}

func (classDb *ClassDb) ClassUpdate(m *model.Class, columns ...string) (int64, error) {
affected, err := classDb.Db.Where("id =?", m.Id).Cols(columns...).Update(m)
if err != nil {
return 0, err
}
return affected, nil
}

func (classDb *ClassDb) GetClass(id int) (m *model.Class, err error) {
m = new(model.Class)
has, err := classDb.Db.Where("id =?", id).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

+ 20
- 0
app/db/db_grade.go Прегледај датотеку

@@ -48,3 +48,23 @@ func (gradeDb *GradeDb) GradeInsert(m *model.Grade) (int, error) {
}
return m.Id, nil
}

func (gradeDb *GradeDb) GradeUpdate(m *model.Grade, columns ...string) (int64, error) {
affected, err := gradeDb.Db.Where("id =?", m.Id).Cols(columns...).Update(m)
if err != nil {
return 0, err
}
return affected, nil
}

func (gradeDb *GradeDb) GetGrade(id int) (m *model.Grade, err error) {
m = new(model.Grade)
has, err := gradeDb.Db.Where("id =?", id).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

+ 1
- 1
app/db/model/central_kitchen_for_school_package_ord.go Прегледај датотеку

@@ -6,7 +6,7 @@ type CentralKitchenForSchoolPackageOrd struct {
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"`
UserIdentityId int `json:"user_identity_id" xorm:"not null default 0 comment('用户身份id') INT(11)"`
TotalPrice string `json:"total_price" xorm:"not null default 0.00 comment('总价') DECIMAL(8,2)"`
Kind int `json:"kind" xorm:"not null default 1 comment('购买类型(1:按学期购买 2:按月购买 3:按天购买)') TINYINT(1)"`
Kind int `json:"kind" xorm:"not null default 1 comment('购买类型(1:按学期购买 2:按月购买 3:按天购买 4:补餐)') TINYINT(1)"`
OutTradeNo string `json:"out_trade_no" xorm:"not null default '' comment('商户订单号') VARCHAR(255)"`
TradeNo string `json:"trade_no" xorm:"not null default '' comment('支付宝交易号') VARCHAR(255)"`
State int `json:"state" xorm:"not null default 0 comment('支付状态(0:待支付 1:支付成功 2:支付失败)') TINYINT(1)"`


+ 2
- 0
app/db/model/self_support_for_school_info.go Прегледај датотеку

@@ -9,6 +9,8 @@ type SelfSupportForSchoolInfo struct {
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('单位id') INT(11)"`
SchoolCode string `json:"school_code" xorm:"not null default '' comment('学校内标') VARCHAR(255)"`
SchoolStdCode string `json:"school_std_code" xorm:"not null default '' comment('学校外标') VARCHAR(255)"`
GroupKey string `json:"group_key" xorm:"not null default '' comment('学校人脸库ID') VARCHAR(255)"`
Memo string `json:"memo" xorm:"not null default '' VARCHAR(255)"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 12
- 0
app/router/admin_router.go Прегледај датотеку

@@ -70,11 +70,19 @@ func rSetCenter(r *gin.RouterGroup) {
r.GET("/get", hdl2.GetCenter) // 设置中心-获取
r.POST("/set", hdl2.SetCenter) // 设置中心-设置
}

func rAuditCenter(r *gin.RouterGroup) {
r.POST("/centralKitchenForSchoolOrderRefundList", hdl2.CentralKitchenForSchoolOrderRefundList) //审核中心-央厨-学校-订单退款列表
r.POST("/centralKitchenForSchoolOrderRefundAudit", hdl2.CentralKitchenForSchoolOrderRefundAudit) //审核中心-央厨-学校-订单退款审核
}

func rFinanceManage(r *gin.RouterGroup) {
r.POST("/centralKitchenForSchool/ordList", hdl.CentralKitchenForSchoolOrdList) //财务管理-(央厨-学校)订单列表
r.GET("/centralKitchenForSchool/ordDetail", hdl.CentralKitchenForSchoolOrdDetail) //财务管理-(央厨-学校)订单详情
r.POST("/centralKitchenForSchool/ordRefund", hdl.CentralKitchenForSchoolOrdRefund) //财务管理-(央厨-学校)订单退款

}

func rUser(r *gin.RouterGroup) {
r.POST("/list", hdl2.UserList) //列表
r.POST("/update", hdl2.UserUpdate) //编辑
@@ -111,6 +119,9 @@ func rEnterpriseManage(r *gin.RouterGroup) {
r.GET("/centralKitchenForSchool/ordDetail", hdl.CentralKitchenForSchoolOrdDetail) //"央厨-学校"订单详情
r.POST("/centralKitchenForSchool/ordRefund", hdl.CentralKitchenForSchoolOrdRefund) //"央厨-学校"订单退款

r.POST("/centralKitchenForSchoolOrderRefundList", hdl2.CentralKitchenForSchoolOrderRefundList) //"央厨-学校"订单退款列表
r.POST("/centralKitchenForSchoolOrderRefundAudit", hdl2.CentralKitchenForSchoolOrderRefundAudit) //"央厨-学校"订单退款审核

r.POST("/setBasicCentralKitchenForSchool", hdl.SetBasicCentralKitchenForSchool) //"央厨-学校"设置基础设置
r.GET("/getBasicCentralKitchenForSchool", hdl.GetBasicCentralKitchenForSchool) //"央厨-学校"获取基础设置
r.POST("/setCentralKitchenForSchoolWithSpec", hdl.SetCentralKitchenForSchoolWithSpec) //设置"央厨-学校-规格"
@@ -162,4 +173,5 @@ func AdminRoute(r *gin.RouterGroup) {
rSetCenter(r.Group("/setCenter")) //设置中心
rUser(r.Group("/user")) //用户管理
rAuditCenter(r.Group("/auditCenter")) //审核中心
rFinanceManage(r.Group("/financeManage")) //财务管理
}

+ 1
- 0
app/router/customer_router.go Прегледај датотеку

@@ -12,6 +12,7 @@ func CustomerInit(r *gin.RouterGroup) {
rCentralKitchenForSchoolOrder(r.Group("/order/centralKitchenForSchool"))
rSelfSupportForSchool(r.Group("/selfSupportForSchool"))

r.POST("/curlAlipayPlanetEcocampusApiRosterSignUpInfoTest", hdl.CurlAlipayPlanetEcocampusApiRosterSignUpInfo)
r.POST("/login", hdl.Login)
r.POST("/register", hdl.Register)
r.POST("/aesDecrypt", hdl.AesDecrypt)


+ 0
- 1
etc/cfg.yml Прегледај датотеку

@@ -33,5 +33,4 @@ log:
file_max_age: 1
file_name: 'debug.log'


smart_canteen_pay: 'http://smartCanteenPay.com'

Loading…
Откажи
Сачувај