ソースを参照

Merge branch 'master' into factory

factory
DengBiao 1年前
コミット
3b441204c7
5個のファイルの変更218行の追加16行の削除
  1. +14
    -12
      app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go
  2. +21
    -0
      app/admin/hdl/hdl_device.go
  3. +2
    -2
      app/admin/svc/svc_data_statisstics.go
  4. +26
    -0
      app/customer/hdl/hdl_demo.go
  5. +155
    -2
      app/customer/svc/svc_curl_smart_pay.go

+ 14
- 12
app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go ファイルの表示

@@ -916,6 +916,19 @@ func SelfSupportForSchoolImportTeacher(c *gin.Context) {
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
return
}

selfSupportForSchoolInfoDb := db.SelfSupportForSchoolInfoDb{}
selfSupportForSchoolInfoDb.Set(enterpriseId)
selfSupportForSchoolInfo, err1 := selfSupportForSchoolInfoDb.GetSelfSupportForSchoolInfo()
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if selfSupportForSchoolInfo == nil {
e.OutErr(c, e.ERR, "当前学校暂未完成《一脸通行入驻》")
return
}

files, _ := c.FormFile("file")
dst := "./static/upload/" + files.Filename
err = c.SaveUploadedFile(files, dst)
@@ -982,17 +995,6 @@ func SelfSupportForSchoolImportTeacher(c *gin.Context) {
return
}
if info == nil {
selfSupportForSchoolInfoDb := db.SelfSupportForSchoolInfoDb{}
selfSupportForSchoolInfoDb.Set(enterpriseId)
selfSupportForSchoolInfo, err1 := selfSupportForSchoolInfoDb.GetSelfSupportForSchoolInfo()
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if selfSupportForSchoolInfo == nil {
e.OutErr(c, e.ERR, "当前学校暂未完成《一脸通行入驻》")
return
}
info = &model.SelfSupportForUserFaceInfo{
EnterpriseId: enterpriseId,
UserIdentityId: insertAffected,
@@ -1058,7 +1060,7 @@ func ImportV2(c *gin.Context) {
}

func SelfSupportForSchoolDownloadTemplateExcel(c *gin.Context) {
e.OutSuc(c, "/template/自营学校(教师信息导入模板).xls", nil)
e.OutSuc(c, "/template/自营学校(教师信息导入模板).xlsx", nil)
return
}



+ 21
- 0
app/admin/hdl/hdl_device.go ファイルの表示

@@ -1,8 +1,10 @@
package hdl

import (
enum2 "applet/app/admin/enum"
"applet/app/admin/lib/validate"
"applet/app/admin/md"
svc3 "applet/app/admin/svc"
"applet/app/db"
model2 "applet/app/db/model"
"applet/app/e"
@@ -27,6 +29,25 @@ func DeviceList(c *gin.Context) {
}

sess := db.Db.Desc("device.id")
admin := svc3.GetUser(c)
if admin.IsSuperAdministrator != enum2.IsSuperAdministratorTure {
adminWithEnterpriseDb := db.AdminWithEnterpriseDb{}
adminWithEnterpriseDb.Set()
adminWithEnterprise, err1 := adminWithEnterpriseDb.FindAdminWithEnterprise(admin.AdmId)
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
var enterPriseIds []int
for _, v1 := range *adminWithEnterprise {
enterPriseIds = append(enterPriseIds, v1.EnterpriseId)
}
if len(enterPriseIds) == 0 {
return
}
sess.In("device.enterprise_id", enterPriseIds)
}

if req.Name != "" {
sess.And("device.name like ?", "%"+req.Name+"%")
}


+ 2
- 2
app/admin/svc/svc_data_statisstics.go ファイルの表示

@@ -539,7 +539,7 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta

//查询出所有的设备
var deviceList []*model.Device
if req.EnterpriseId != 0 {
if req.EnterpriseId == 0 {
err := db.Db.Where("enterprise_id != 0").Find(&deviceList)
if err != nil {
logx.Error(err)
@@ -576,7 +576,7 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
for _, v := range deviceList {
deviceListMapping[v.DeviceSn] = *v
var m []*db.SelfSupportForSchoolOrdWithUserIdentityV2
sess := db.Db.Where("device_sn = ?", v.DeviceSn).Desc("self_support_for_school_ord.id")
sess := db.Db.Where("device_sn = ?", v.DeviceSn).And("enterprise_id =?", req.EnterpriseId).Desc("self_support_for_school_ord.id")
if req.EnterpriseId != 0 {
sess.And("self_support_for_school_ord.enterprise_id =?", req.EnterpriseId)
}


+ 26
- 0
app/customer/hdl/hdl_demo.go ファイルの表示

@@ -6,6 +6,7 @@ import (
"applet/app/customer/md"
"applet/app/customer/svc"
"applet/app/db"
"applet/app/db/model"
"applet/app/e"
"applet/app/enum"
svc3 "applet/app/svc"
@@ -104,6 +105,31 @@ func WxPay(c *gin.Context) {
}

func Demo(c *gin.Context) {
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAppid, enum.OpenAppletAppPrivateKey, enum.OpenAppletPublicKey)
err, info := svc.CurlEducateSceneTokenQueryV2(md.CurlEducateSceneTokenReq{
Config: struct {
AliAppId string `json:"ali_app_id" label:"支付宝开放平台-小程序-appid"`
AliPrivateKey string `json:"ali_private_key" label:"支付宝开放平台-小程序-应用私钥"`
AliPublicKey string `json:"ali_public_key" label:"支付宝开放平台-小程序-支付宝公钥"`
}{
AliAppId: sysCfg[enum.OpenAppletAppid],
AliPrivateKey: sysCfg[enum.OpenAppletAppPrivateKey],
AliPublicKey: sysCfg[enum.OpenAppletPublicKey],
},
CertType: "A",
CertNo: "440881201010205523",
StudentName: "龙佩滢",
OutUserId: "1001",
SchoolStdCode: "12440403MB2D752515",
}, &model.UserIdentity{}, "", "")
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
e.OutSuc(c, info, nil)
return
ordNo := c.DefaultQuery("ord_no", "")
svc2.JudgePackageOrdOrdState(ordNo)
e.OutSuc(c, nil, nil)


+ 155
- 2
app/customer/svc/svc_curl_smart_pay.go ファイルの表示

@@ -194,8 +194,8 @@ func CurlEducateSceneTokenQuery(args md.CurlEducateSceneTokenReq, userIdentity *
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
utils.FilePutContents("CurlEducateSceneTokenCreate", utils.SerializeStr(result))
err1 = json.Unmarshal(bytes, &result)
utils.FilePutContents("CurlEducateSceneTokenCreate", utils.SerializeStr(result))
if err1 != nil {
return
}
@@ -232,8 +232,158 @@ func CurlEducateSceneTokenQuery(args md.CurlEducateSceneTokenReq, userIdentity *
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
err = json.Unmarshal(bytes, &result1)
utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(result1))
if err != nil {
return
}
if result1.Code != 0 {
if result1.Msg != "" {
err = errors.New(result1.Msg)
return
}
err = errors.New("请求智慧餐厅支付 异常/失败")
return
}
// 更新/新增 `self_support_for_user_facel_info`
selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
selfSupportForUserFaceInfoDb.Set(userIdentity.Id)
info, err := selfSupportForUserFaceInfoDb.GetSelfSupportForUserFaceInfo()
if err != nil {
return
}

now := time.Now().Format("2006-01-02 15:04:05")
var res map[string]string
utils.Unserialize([]byte(utils.SerializeStr(result1.Data)), &res)

if info == nil {
var concentrateSchoolFacePassStatus = 1
if res["school_face_pass_status"] == "OPEN" {
concentrateSchoolFacePassStatus = 3
}
info = &model.SelfSupportForUserFaceInfo{
EnterpriseId: userIdentity.EnterpriseId,
UserIdentityId: userIdentity.Id,
CollectFaceType: 1,
SchoolCode: res["school_code"],
SchoolStdCode: res["school_std_code"],
ParentUserId: res["parent_user_id"],
ParentLogonId: res["parent_logon_id"],
UserId: res["user_id"],
SchoolFacePassStatus: res["school_face_pass_status"],
SchoolFacePaymentStatus: res["school_face_payment_status"],
ConcentrateSchoolFacePassStatus: concentrateSchoolFacePassStatus,
CreateAt: now,
UpdateAt: now,
}
_, err2 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoInsert(info)
if err2 != nil {
return err2, nil
}
} else {
var concentrateSchoolFacePassStatus = info.ConcentrateSchoolFacePassStatus
if res["school_face_pass_status"] == "OPEN" {
concentrateSchoolFacePassStatus = 3
}
info.ParentUserId = res["parent_user_id"]
info.ParentLogonId = res["parent_logon_id"]
info.UserId = res["user_id"]
info.SchoolFacePassStatus = res["school_face_pass_status"]
info.SchoolFacePaymentStatus = res["school_face_payment_status"]
info.ConcentrateSchoolFacePassStatus = concentrateSchoolFacePassStatus
info.UpdateAt = now
_, err2 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoUpdate(info, "parent_user_id", "parent_logon_id", "user_id", "school_face_pass_status", "school_face_payment_status", "concentrate_school_face_pass_status", "update_at")
if err2 != nil {
return err2, nil
}
}

//TODO:: school_face_pass_status && school_face_payment_status 都为 open 状态,则 签约信息同步“alipay.planet.ecocampus.api.roster.signUpInfo” 至 行业云
CurlAlipayPlanetEcocampusApiRosterSignUpInfo(md.CurlAlipayPlanetEcocampusApiRosterSignUpInfoReq{
FaceUid: info.UserId,
ParentUid: info.ParentUserId,
ParentLogonId: info.ParentLogonId,
RosterName: args.StudentName,
OutRosterCode: args.OutUserId,
SchoolCode: info.SchoolCode,
SchoolName: schoolName,
ScanFacePayStatus: "ON",
FaceOpenStatus: "ON",
})
return nil, result1.Data

}

func CurlEducateSceneTokenQueryV2(args md.CurlEducateSceneTokenReq, userIdentity *model.UserIdentity, userToken, schoolName string) (err error, resp interface{}) {
utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(map[string]interface{}{
"args": args,
}))

if userToken == "" {
//1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token)
url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenCreate"
bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{
"config": map[string]string{
"ali_app_id": args.Config.AliAppId,
"ali_private_key": args.Config.AliPrivateKey,
"ali_public_key": args.Config.AliPublicKey,
},
"cert_no": args.CertNo,
"school_std_code": args.SchoolStdCode,
"student_name": args.StudentName,
"out_user_id": args.OutUserId,
"cert_type": args.CertType,
"sub_code": "SCHOOL_FACE_PASS_QUERY",
}), nil)
if err1 != nil {
return
}
var result struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
err1 = json.Unmarshal(bytes, &result)
utils.FilePutContents("CurlEducateSceneTokenCreate", utils.SerializeStr(result))
if err1 != nil {
return
}
if result.Code != 0 {
if result.Msg != "" {
err1 = errors.New(result.Msg)
return
}
err1 = errors.New("请求智慧餐厅支付 异常/失败")
return
}
resultMap, ok := result.Data.(map[string]interface{})
if !ok {
err1 = errors.New("获取 user_token 失败")
return
}
if resultMap["code"].(string) != "10000" {
return nil, resultMap
}
userToken = resultMap["token"].(string)
}

//2、TODO::查询用户一脸通行开通状态:根据获取到的用户信息token,使用 alipay.commerce.educate.scene.token.query 接口查询用户人脸采集状态
url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateSceneTokenQuery"
bytes, err := utils.CurlPost(url, utils.Serialize(map[string]string{
"user_token": userToken,
}), nil)
if err != nil {
return
}

var result1 struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
err = json.Unmarshal(bytes, &result1)
utils.FilePutContents("CurlEducateSceneTokenQuery", utils.SerializeStr(result1))
if err != nil {
return
}
@@ -245,6 +395,9 @@ func CurlEducateSceneTokenQuery(args md.CurlEducateSceneTokenReq, userIdentity *
err = errors.New("请求智慧餐厅支付 异常/失败")
return
}

return nil, result1.Data

// 更新/新增 `self_support_for_user_facel_info`
selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
selfSupportForUserFaceInfoDb.Set(userIdentity.Id)
@@ -433,11 +586,11 @@ func CurlEducateSceneTokenCreateForApplet(args md.CurlEducateSceneTokenReq) (err
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
utils.FilePutContents("CurlEducateSceneTokenCreateForApplet", utils.SerializeStr(result))
err = json.Unmarshal(bytes, &result)
if err != nil {
return
}
utils.FilePutContents("CurlEducateSceneTokenCreateForApplet", utils.SerializeStr(result))
if result.Code != 0 {
if result.Msg != "" {
err = errors.New(result.Msg)


読み込み中…
キャンセル
保存