Browse Source

git fix

master
dengbiao 2 months ago
parent
commit
4df55ec2e1
25 changed files with 5106 additions and 999 deletions
  1. +2
    -2
      app/enum/enum_qualification.go
  2. +1
    -1
      app/hdl/hdl_agent_qualification.go
  3. +51
    -0
      app/hdl/hdl_applet_application.go
  4. +51
    -0
      app/hdl/hdl_applet_application_ad_space_list.go
  5. +123
    -0
      app/hdl/hdl_medium_agent.go
  6. +1
    -1
      app/hdl/hdl_medium_qualification.go
  7. +54
    -0
      app/hdl/hdl_set_center.go
  8. +52
    -0
      app/md/md__applet_application.go
  9. +54
    -0
      app/md/md__applet_application_ad_space_list.go
  10. +3
    -0
      app/md/md_agent_qualification.go
  11. +32
    -0
      app/md/md_medium.go
  12. +3
    -0
      app/md/md_medium_qualification.go
  13. +8
    -0
      app/md/md_set_center.go
  14. +7
    -0
      app/md/qiniuyun.go
  15. +6
    -0
      app/md/sms.go
  16. +20
    -0
      app/router/router.go
  17. +21
    -5
      app/svc/svc_agent_qualification.go
  18. +231
    -0
      app/svc/svc_applet_application.go
  19. +217
    -0
      app/svc/svc_applet_application_ad_space.go
  20. +156
    -0
      app/svc/svc_medium_agent.go
  21. +21
    -4
      app/svc/svc_medium_qualification.go
  22. +0
    -78
      app/svc/svc_sys_cfg_get.go
  23. +1571
    -418
      docs/docs.go
  24. +1571
    -418
      docs/swagger.json
  25. +850
    -72
      docs/swagger.yaml

+ 2
- 2
app/enum/enum_qualification.go View File

@@ -13,11 +13,11 @@ func (gt QualificationState) String() string {
case QualificationStateForNormal:
return "审核成功"
case QualificationStateForFail:
return "审核失败"
return "审核拒绝"
case QualificationStateForWait:
return "待审核"
default:
return "待审核"
return "待提交"
}
}



+ 1
- 1
app/hdl/hdl_agent_qualification.go View File

@@ -28,7 +28,7 @@ func AgentQualificationEnterprise(c *gin.Context) {
e.OutErr(c, err1.Code, err1.Error())
return
}
res := svc.AgentQualificationEnterprise(c, req)
res := svc.AgentQualificationEnterprise(c, 1, req)
e.OutSuc(c, res, nil)
return
}


+ 51
- 0
app/hdl/hdl_applet_application.go View File

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

import (
"applet/app/svc"
"github.com/gin-gonic/gin"
)

// AppletApplicationMediumList
// @Summary 媒体列表
// @Tags 媒体中心------嘉俊
// @Description 媒体中心-媒体列表
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.AppletApplicationMediumListReq true "请求参数"
// @Success 200 {object} md.AppletApplicationMediumListRes "具体看返回内容---这是data里面的数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/applet/application/medium/list [POST]
func AppletApplicationMediumList(c *gin.Context) {
svc.AppletApplicationMediumList(c)
}

// AppletApplicationList
// @Summary 应用列表
// @Tags 媒体中心------嘉俊
// @Description 小程序应用-列表数据
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.AppletApplicationListReq true "请求参数"
// @Success 200 {object} md.AppletApplicationListRes "具体看返回内容---这是data里面的数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/applet/application/list [POST]
func AppletApplicationList(c *gin.Context) {
svc.AppletApplicationList(c)
}

// AppletApplicationAudit
// @Summary 审核
// @Tags 媒体中心------嘉俊
// @Description 小程序应用-审核
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.AppletApplicationSaveReq true "请求参数"
// @Success 200 {string} "具体看返回内容"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/applet/application/audit [POST]
func AppletApplicationAudit(c *gin.Context) {
svc.AppletApplicationAudit(c)
}

+ 51
- 0
app/hdl/hdl_applet_application_ad_space_list.go View File

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

import (
"applet/app/svc"
"github.com/gin-gonic/gin"
)

// AppletApplicationAdSpaceMediumList
// @Summary 媒体列表
// @Tags 媒体中心------嘉俊
// @Description 媒体中心-媒体列表
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.AppletApplicationAdSpaceMediumListReq true "请求参数"
// @Success 200 {object} md.AppletApplicationAdSpaceMediumListRes "具体看返回内容---这是data里面的数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/applet/application/ad/space/list [POST]
func AppletApplicationAdSpaceMediumList(c *gin.Context) {
svc.AppletApplicationAdSpaceMediumList(c)
}

// AppletApplicationAdSpaceList
// @Summary 广告位列表
// @Tags 媒体中心------嘉俊
// @Description 小程序应用-广告位列表
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.AppletApplicationAdSpaceListReq true "请求参数"
// @Success 200 {object} md.AppletApplicationAdSpaceListRes "具体看返回内容---这是data里面的数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/applet/application/ad/space/save [POST]
func AppletApplicationAdSpaceList(c *gin.Context) {
svc.AppletApplicationAdSpaceList(c)
}

// AppletApplicationAdSpaceAudit
// @Summary 广告位审核
// @Tags 媒体中心------嘉俊
// @Description 小程序应用-广告位审核
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.AppletApplicationAdSpaceSaveReq true "请求参数"
// @Success 200 {string} "具体看返回内容"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/applet/application/ad/space/audit [POST]
func AppletApplicationAdSpaceAudit(c *gin.Context) {
svc.AppletApplicationAdSpaceAudit(c)
}

+ 123
- 0
app/hdl/hdl_medium_agent.go View File

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

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

// AgentList
// @Summary 代理列表
// @Tags 媒体中心------嘉俊
// @Description 媒体中心-代理列表
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.AgentQualificationEnterpriseReq true "请求参数"
// @Success 200 {object} md.AgentQualificationEnterpriseRes "具体看返回内容 这是data里面的数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/agent/list [POST]
func AgentList(c *gin.Context) {
var req md.AgentQualificationEnterpriseReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
res := svc.AgentQualificationEnterprise(c, 0, req)
e.OutSuc(c, res, nil)
return
}

// AgentBindMediumList
// @Summary 代理绑定媒体列表
// @Tags 媒体中心------嘉俊
// @Description 媒体中心-代理绑定媒体列表
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.MediumListReq true "请求参数"
// @Success 200 {object} md.MediumListRes "具体看返回内容 这是data里面的数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/agent/bind/medium/list [POST]
func AgentBindMediumList(c *gin.Context) {
svc.AgentBindMediumList(c)
return
}

// MediumList
// @Summary 媒体列表
// @Tags 媒体中心------嘉俊
// @Description 媒体中心-媒体列表
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.MediumQualificationEnterpriseReq true "请求参数"
// @Success 200 {object} md.MediumQualificationEnterpriseRes "具体看返回内容 这是data里面的数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/medium/list [POST]
func MediumList(c *gin.Context) {
var req md.MediumQualificationEnterpriseReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
res := svc.MediumQualificationEnterprise(c, 0, req)
e.OutSuc(c, res, nil)
return
}

// MediumBindAgentList
// @Summary 媒体绑定代理列表
// @Tags 媒体中心------嘉俊
// @Description 媒体中心-媒体绑定代理列表
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.MediumListReq true "请求参数"
// @Success 200 {object} md.MediumListRes "具体看返回内容 这是data里面的数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/medium/bind/agent/list [POST]
func MediumBindAgentList(c *gin.Context) {
svc.MediumBindAgentList(c)
return
}

// MediumBindAgentSave
// @Summary 媒体绑定代理操作
// @Tags 媒体中心------嘉俊
// @Description 媒体中心-媒体绑定代理操作
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.MediumListSaveReq true "请求参数"
// @Success 200 {string} "具体看返回内容 "
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/medium/bind/agent/save [POST]
func MediumBindAgentSave(c *gin.Context) {
svc.MediumBindAgentSave(c)
return
}

// MediumBindAgentDel
// @Summary 媒体绑定代理删除
// @Tags 媒体中心------嘉俊
// @Description 媒体中心-媒体绑定代理删除
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.MediumListDelReq true "请求参数"
// @Success 200 {string} "具体看返回内容 "
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/mediumCenter/medium/bind/agent/del [POST]
func MediumBindAgentDel(c *gin.Context) {
svc.MediumBindAgentDel(c)
return
}

+ 1
- 1
app/hdl/hdl_medium_qualification.go View File

@@ -28,7 +28,7 @@ func MediumQualificationEnterprise(c *gin.Context) {
e.OutErr(c, err1.Code, err1.Error())
return
}
res := svc.MediumQualificationEnterprise(c, req)
res := svc.MediumQualificationEnterprise(c, 1, req)
e.OutSuc(c, res, nil)
return
}


+ 54
- 0
app/hdl/hdl_set_center.go View File

@@ -461,3 +461,57 @@ func ShareIndex(c *gin.Context) {
}, nil)
return
}

// SetMob
// @Summary mob设置
// @Tags 设置中心-基础设置
// @Description 基础设置-mob设置
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Param args body md.SetMobReq true "请求参数"
// @Success 200 {string} "success"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/setCenter/basic/setMob [POST]
func SetMob(c *gin.Context) {
var req md.SetMobReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
masterId := svc.GetMasterId(c)
engine := db.DBs[masterId]
sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
sysCfgDb.SysCfgUpdate("mob_app_key", req.MobAppKey)
sysCfgDb.SysCfgUpdate("mob_app_secret", req.MobAppSecret)
e.OutSuc(c, "success", nil)
return
}

// GetMob
// @Summary mob获取
// @Tags 设置中心-基础设置
// @Description 基础设置-mob获取
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Accept json
// @Produce json
// @Success 200 {object} md.SetOssResp
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/setCenter/basic/getMob [GET]
func GetMob(c *gin.Context) {
masterId := svc.GetMasterId(c)
engine := db.DBs[masterId]
sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
res := sysCfgDb.SysCfgFindWithDb("mob_app_key", "mob_app_secret")

e.OutSuc(c, md.SetMobResp{
Data: md.SetMobReq{
MobAppSecret: res["mob_app_secret"],
MobAppKey: res["mob_app_key"],
},
}, nil)
return
}

+ 52
- 0
app/md/md__applet_application.go View File

@@ -0,0 +1,52 @@
package md

type AppletApplicationMediumListReq struct {
Limit string `json:"limit"`
Page string `json:"page" `
Name string `json:"name" example:"媒体名称"`
Account string `json:"account" example:"媒体账号"`
}
type AppletApplicationMediumListRes struct {
List []AppletApplicationMediumListData `json:"list"`
Total int64 `json:"total"`
}
type AppletApplicationMediumListData struct {
Id string `json:"id" example:"id"`
MediumId string `json:"medium_id" example:"媒体id"`
Name string `json:"name" example:"名称"`
Account string `json:"account" example:"账号"`
ContactName string `json:"contact_name" example:"联系人"`
Phone string `json:"phone" example:"联系电话"`
Count string `json:"count" example:"应用数量"`
}
type AppletApplicationListReq struct {
Limit string `json:"limit"`
Page string `json:"page" `
Name string `json:"name"`
MediumId string `json:"medium_id" example:"媒体id"`
CooperateState string `json:"cooperate_state" example:"合作状态"`
Platform string `json:"platform"`
}
type AppletApplicationListRes struct {
List []AppletApplicationListData `json:"list"`
Total int64 `json:"total"`
State []SelectData `json:"state"`
CooperateState []SelectData `json:"cooperate_state"`
Platform []SelectData `json:"platform"`
}
type AppletApplicationListData struct {
Id string `json:"id" example:"id"`
Name string `json:"name" example:"应用名称"`
Platform string `json:"platform" example:"平台"`
Memo string `json:"memo" example:"备注"`
Logo string `json:"logo" example:"logo"`
AppId string `json:"app_id" example:"小程序appid"`
OriginalId string `json:"original_id" example:"小程序id"`
State string `json:"state" example:"应用状态 state=3 才能再次编辑"`
CooperateState string `json:"cooperate_state" example:"合作状态"`
}
type AppletApplicationSaveReq struct {
Id string `json:"id" example:"id 多个逗号隔开"`
State string `json:"state" example:"审核状态"`
Memo string `json:"memo" example:"备注"`
}

+ 54
- 0
app/md/md__applet_application_ad_space_list.go View File

@@ -0,0 +1,54 @@
package md

type AppletApplicationAdSpaceMediumListReq struct {
Limit string `json:"limit"`
Page string `json:"page" `
Name string `json:"name" example:"媒体名称"`
Account string `json:"account" example:"媒体账号"`
}
type AppletApplicationAdSpaceMediumListRes struct {
List []AppletApplicationAdSpaceMediumListData `json:"list"`
Total int64 `json:"total"`
}
type AppletApplicationAdSpaceMediumListData struct {
Id string `json:"id" example:"id"`
MediumId string `json:"medium_id" example:"媒体id"`
Name string `json:"name" example:"名称"`
Account string `json:"account" example:"账号"`
ContactName string `json:"contact_name" example:"联系人"`
Phone string `json:"phone" example:"联系电话"`
Count string `json:"count" example:"广告位数量"`
}
type AppletApplicationAdSpaceListReq struct {
MediumId string `json:"medium_id" example:"媒体id"`
Limit string `json:"limit"`
Page string `json:"page" `
Name string `json:"name"`
CooperateState string `json:"cooperate_state" example:"合作状态"`
Platform string `json:"platform"`
}
type AppletApplicationAdSpaceListRes struct {
List []AppletApplicationAdSpaceListData `json:"list"`
Total int64 `json:"total"`
State []SelectData `json:"state"`
CooperateState []SelectData `json:"cooperate_state"`
Platform []SelectData `json:"platform"`
AdType []SelectData `json:"ad_type"`
}
type AppletApplicationAdSpaceListData struct {
Id string `json:"id" example:"id"`
Name string `json:"name" example:"应用名称"`
Platform string `json:"platform" example:"平台"`
Kind string `json:"kind" example:"广告位类型"`
Memo string `json:"memo" example:"备注"`
Logo string `json:"logo" example:"logo"`
AppId string `json:"app_id" example:"小程序appid"`
AdId string `json:"ad_id" example:"广告位id"`
State string `json:"state" example:"应用状态 state=2 才能再次编辑"`
CooperateState string `json:"cooperate_state" example:"合作状态"`
}
type AppletApplicationAdSpaceSaveReq struct {
Id string `json:"id" example:"id 多个逗号隔开"`
State string `json:"state" example:"审核状态"`
Memo string `json:"memo" example:"备注"`
}

+ 3
- 0
app/md/md_agent_qualification.go View File

@@ -42,6 +42,7 @@ type AgentQualificationEnterpriseData struct {
BusinessLicenseAddress string `json:"business_license_address" example:"营业执照地址"`
CertificateValidity string `json:"certificate_validity" example:"证件有效期"`
Memo string `json:"memo" example:"备注 审核时填写的"`
Account string `json:"account" example:"账号"`
}
type AgentQualificationBankRes struct {
State []SelectData `json:"state" `
@@ -63,6 +64,7 @@ type AgentQualificationBankData struct {
Memo string `json:"memo" example:"备注 审核时填写的"`
State string `json:"state" example:"状态(0:待提交 1:待审核 2:审核通过 3:审核拒绝)"`
UnifiedSocialCreditCode string `json:"unified_social_credit_code" example:"统一社会信用代码"`
Account string `json:"account" example:"账号"`
}

type AgentQualificationContactRes struct {
@@ -81,4 +83,5 @@ type AgentQualificationContactData struct {
Name string `json:"name" example:"联系人"`
Phone string `json:"phone" example:"联系电话"`
State string `json:"state" example:"状态(0:待提交 1:待审核 2:审核通过 3:审核拒绝)"`
Account string `json:"account" example:"账号"`
}

+ 32
- 0
app/md/md_medium.go View File

@@ -0,0 +1,32 @@
package md

type MediumListReq struct {
Id string `json:"id"`
Limit string `json:"limit"`
Page string `json:"page" `
Name string `json:"name"`
State string `json:"state"`
}
type MediumListRes struct {
State []SelectData `json:"state" `
List []MediumListData `json:"list"`
Total int64 `json:"total"`
}
type MediumListData struct {
MediumId string `json:"medium_id" example:"媒体id"`
CompanyName string `json:"company_name" example:"公司名称"`
Id string `json:"id" example:"id"`
Memo string `json:"memo" example:"备注 审核时填写的"`
State string `json:"state" example:"状态(0:待提交 1:待审核 2:审核通过 3:审核拒绝)"`
UnifiedSocialCreditCode string `json:"unified_social_credit_code" example:"统一社会信用代码"`
LegalRepresentative string `json:"legal_representative" example:"法定代表人"`
Account string `json:"account" example:"媒体账号"`
BusinessLicenseAddress string `json:"business_license_address" example:"营业执照地址"`
}
type MediumListSaveReq struct {
Username string `json:"username"`
MediumId string `json:"medium_id"`
}
type MediumListDelReq struct {
Id string `json:"id" example:"列表id"`
}

+ 3
- 0
app/md/md_medium_qualification.go View File

@@ -42,6 +42,7 @@ type MediumQualificationEnterpriseData struct {
BusinessLicenseAddress string `json:"business_license_address" example:"营业执照地址"`
CertificateValidity string `json:"certificate_validity" example:"证件有效期"`
Memo string `json:"memo" example:"备注 审核时填写的"`
Account string `json:"account" example:"账号"`
}
type MediumQualificationBankRes struct {
State []SelectData `json:"state" `
@@ -63,6 +64,7 @@ type MediumQualificationBankData struct {
Memo string `json:"memo" example:"备注 审核时填写的"`
State string `json:"state" example:"状态(0:待提交 1:待审核 2:审核通过 3:审核拒绝)"`
UnifiedSocialCreditCode string `json:"unified_social_credit_code" example:"统一社会信用代码"`
Account string `json:"account" example:"账号"`
}

type MediumQualificationContactRes struct {
@@ -81,4 +83,5 @@ type MediumQualificationContactData struct {
Name string `json:"name" example:"联系人"`
Phone string `json:"phone" example:"联系电话"`
State string `json:"state" example:"状态(0:待提交 1:待审核 2:审核通过 3:审核拒绝)"`
Account string `json:"account" example:"账号"`
}

+ 8
- 0
app/md/md_set_center.go View File

@@ -47,3 +47,11 @@ type ShareIndexResp struct {
AgentDomain string `json:"agent_domain" example:"代理分享地址"`
MediumDomain string `json:"medium_domain" example:"媒体分享地址"`
}

type SetMobReq struct {
MobAppKey string `json:"mob_app_key"`
MobAppSecret string `json:"mob_app_secret"`
}
type SetMobResp struct {
Data SetMobReq `json:"data"` //数据内容
}

+ 7
- 0
app/md/qiniuyun.go View File

@@ -0,0 +1,7 @@
package md

type ImgReqUpload struct {
Dir string `json:"dir"`
FileName string `json:"file_name"`
FileSize int64 `json:"file_size"` // 文件大小, 单位byte
}

+ 6
- 0
app/md/sms.go View File

@@ -0,0 +1,6 @@
package md

type SmsReq struct {
Username string `json:"username"`
Type string `json:"type" example:"手机号登陆:fast_login 注册:register"`
}

+ 20
- 0
app/router/router.go View File

@@ -67,6 +67,7 @@ func route(r *gin.RouterGroup) {
rAgentQualification(r.Group("/agentQualification")) //渠道-资质
rMediumQualification(r.Group("/mediumQualification")) //媒体-资质
rSetCenter(r.Group("/setCenter")) //设置中心
rMedium(r.Group("/mediumCenter")) //媒体中心
}

func rRole(r *gin.RouterGroup) {
@@ -108,6 +109,8 @@ func rSetCenter(r *gin.RouterGroup) {
rBasicSetCenter.GET("/getOss", hdl.GetOss)
rBasicSetCenter.POST("/wxOpenSet", hdl.WxOpenSet)
rBasicSetCenter.GET("/wxOpenGet", hdl.WxOpenGet)
rBasicSetCenter.POST("/setMob", hdl.SetMob)
rBasicSetCenter.GET("/getMob", hdl.GetMob)
}
rAppletSetCenter := r.Group("/applet")
{
@@ -124,3 +127,20 @@ func rSetCenter(r *gin.RouterGroup) {
}

}
func rMedium(r *gin.RouterGroup) {
r.POST("/applet/application/medium/list", hdl.AppletApplicationMediumList) //应用管理-媒体列表
r.POST("/applet/application/list", hdl.AppletApplicationList) //小程序应用-列表数据
r.POST("/applet/application/audit", hdl.AppletApplicationAudit) //小程序应用-审核

r.POST("/applet/application/ad/space/medium/list", hdl.AppletApplicationAdSpaceMediumList) //广告管理-媒体列表
r.POST("/applet/application/ad/space/list", hdl.AppletApplicationAdSpaceList) //小程序应用-广告位列表数据
r.POST("/applet/application/ad/space/audit", hdl.AppletApplicationAdSpaceAudit) //小程序应用-广告位审核

r.POST("/medium/list", hdl.MediumList) //媒体列表
r.POST("/medium/bind/agent/list", hdl.MediumBindAgentList) //媒体绑定代理列表
r.POST("/medium/bind/agent/save", hdl.MediumBindAgentSave) //媒体绑定代理操作
r.POST("/medium/bind/agent/del", hdl.MediumBindAgentDel) //媒体绑定代理删除

r.POST("/agent/list", hdl.AgentList) //代理列表
r.POST("/agent/bind/medium/list", hdl.AgentBindMediumList) //代理绑定媒体列表
}

+ 21
- 5
app/svc/svc_agent_qualification.go View File

@@ -6,18 +6,20 @@ import (
"applet/app/md"
"applet/app/utils"
db "code.fnuoos.com/zhimeng/model.git/src"
implement2 "code.fnuoos.com/zhimeng/model.git/src/implement"
"code.fnuoos.com/zhimeng/model.git/src/super/implement"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
)

func AgentQualificationEnterprise(c *gin.Context, req md.AgentQualificationEnterpriseReq) md.AgentQualificationEnterpriseRes {
func AgentQualificationEnterprise(c *gin.Context, minState int, req md.AgentQualificationEnterpriseReq) md.AgentQualificationEnterpriseRes {

engine := db.Db
agentListDb := implement.NewAgentListDb(engine)
agentList, total, _ := agentListDb.FindAgentList(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
agentList, total, _ := agentListDb.FindAgentList(c.GetString("mid"), req.Name, req.State, minState, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.AgentQualificationEnterpriseData, 0)
if len(agentList) > 0 {
NewAgentDb := implement2.NewAgentDb(MasterDb(c))
for _, v := range agentList {
var tmp md.AgentQualificationEnterpriseData
copier.Copy(&tmp, &v)
@@ -33,6 +35,10 @@ func AgentQualificationEnterprise(c *gin.Context, req md.AgentQualificationEnter
tmp.RegisteredAddressCityId = utils.IntToStr(v.RegisteredAddressCityId)
tmp.RegisteredAddressCountyId = utils.IntToStr(v.RegisteredAddressCountyId)
tmp.State = utils.IntToStr(v.State)
agent := NewAgentDb.GetSuperAdmin(v.AgentId)
if agent != nil {
tmp.Account = agent.Username
}
data = append(data, tmp)
}
}
@@ -86,10 +92,10 @@ func AgentQualificationEnterpriseAudit(c *gin.Context, req md.AgentQualification
func AgentQualificationBank(c *gin.Context, req md.AgentQualificationEnterpriseReq) md.AgentQualificationBankRes {
engine := db.Db
agentListDb := implement.NewAgentBankInfoDb(engine)
agentList, total, _ := agentListDb.FindAgentBankInfoList(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))

agentList, total, _ := agentListDb.FindAgentBankInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
list := make([]md.AgentQualificationBankData, 0)
if agentList != nil {
NewAgentDb := implement2.NewAgentDb(MasterDb(c))
for _, v := range agentList {
tmp := md.AgentQualificationBankData{
Id: utils.IntToStr(v.AgentBankInfo.Id),
@@ -105,6 +111,10 @@ func AgentQualificationBank(c *gin.Context, req md.AgentQualificationEnterpriseR
BankNo: v.BankNo,
Licence: v.Licence,
}
agent := NewAgentDb.GetSuperAdmin(v.AgentBankInfo.AgentId)
if agent != nil {
tmp.Account = agent.Username
}
list = append(list, tmp)
}
}
@@ -162,10 +172,11 @@ func AgentQualificationBankAudit(c *gin.Context, req md.AgentQualificationEnterp
func AgentQualificationContactInfo(c *gin.Context, req md.AgentQualificationEnterpriseReq) md.AgentQualificationContactRes {
engine := db.Db
agentListDb := implement.NewAgentContactInfoDb(engine)
agentList, total, _ := agentListDb.FindAgentContactInfoList(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
agentList, total, _ := agentListDb.FindAgentContactInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))

list := make([]md.AgentQualificationContactData, 0)
if agentList != nil {
NewAgentDb := implement2.NewAgentDb(MasterDb(c))
for _, v := range agentList {
tmp := md.AgentQualificationContactData{
Id: utils.IntToStr(v.AgentContactInfo.Id),
@@ -179,6 +190,11 @@ func AgentQualificationContactInfo(c *gin.Context, req md.AgentQualificationEnte
Phone: v.AgentContactInfo.Phone,
Address: v.AgentContactInfo.Address,
}

agent := NewAgentDb.GetSuperAdmin(v.AgentContactInfo.AgentId)
if agent != nil {
tmp.Account = agent.Username
}
list = append(list, tmp)
}
}


+ 231
- 0
app/svc/svc_applet_application.go View File

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

import (
"applet/app/e"
"applet/app/lib/validate"
"applet/app/lib/wechat"
"applet/app/lib/wechat/enum"
"applet/app/md"
"applet/app/utils"
db "code.fnuoos.com/zhimeng/model.git/src"
"code.fnuoos.com/zhimeng/model.git/src/implement"
"code.fnuoos.com/zhimeng/model.git/src/model"
implement2 "code.fnuoos.com/zhimeng/model.git/src/super/implement"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
"strings"
)

func AppletApplicationMediumList(c *gin.Context) {
var req md.AppletApplicationMediumListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
engine := MasterDb(c)
NewMediumDb := implement.NewMediumDb(engine)

list, total, _ := NewMediumDb.FindSuperAdmin(req.Account, req.Name, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.AppletApplicationMediumListData, 0)
if len(list) > 0 {
for _, v := range list {
var tmp = md.AppletApplicationMediumListData{
Id: utils.IntToStr(v.Id),
MediumId: utils.IntToStr(v.MediumId),
Name: v.Memo,
Account: v.Username,
ContactName: "",
Phone: "",
Count: "",
}
NewMediumContactInfoDb := implement2.NewMediumContactInfoDb(db.Db)
infoList, _ := NewMediumContactInfoDb.GetMediumContactInfoList(v.MediumId)
if infoList != nil {
tmp.ContactName = infoList.Name
tmp.Phone = infoList.Phone
}
count, _ := engine.Where("medium_id=?", v.MediumId).Count(&model.AppletApplication{})
tmp.Count = utils.Int64ToStr(count)
data = append(data, tmp)
}
}
res := md.AppletApplicationMediumListRes{
List: data,
Total: total,
}
e.OutSuc(c, res, nil)
return
}
func AppletApplicationList(c *gin.Context) {
var req md.AppletApplicationListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
engine := MasterDb(c)
NewAppletApplicationDb := implement.NewAppletApplicationDb(engine)
state := make([]string, 0)
if req.CooperateState != "" {
if req.CooperateState == "0" {
state = []string{"0", "1"}
} else {
state = []string{req.CooperateState}
}
}
appletApplicationList, total, _ := NewAppletApplicationDb.FindAppletApplicationList(req.Name, req.Platform, state, utils.StrToInt(req.MediumId), utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.AppletApplicationListData, 0)
if len(appletApplicationList) > 0 {
for _, v := range appletApplicationList {
var tmp md.AppletApplicationListData
copier.Copy(&tmp, &v)
tmp.Id = utils.IntToStr(v.Id)
tmp.State = utils.IntToStr(v.State)
if v.State == 1 {
v.State = 0
}
tmp.CooperateState = utils.IntToStr(v.State)
data = append(data, tmp)
}
}
res := md.AppletApplicationListRes{
List: data,
Total: total,
Platform: []md.SelectData{
{
Name: "微信小程序",
Value: "wx_applet",
},
},
State: []md.SelectData{
{
Name: "待审核",
Value: "0",
},
{
Name: "审核中",
Value: "1",
},
{
Name: "审核通过",
Value: "2",
},
{
Name: "审核拒绝",
Value: "3",
},
{
Name: "封禁中",
Value: "4",
},
},
CooperateState: []md.SelectData{
{
Name: "未运行",
Value: "0",
},
{
Name: "运行中",
Value: "2",
},
{
Name: "审核拒绝",
Value: "3",
},
{
Name: "封禁中",
Value: "4",
},
},
}
e.OutSuc(c, res, nil)
return
}
func AppletApplicationAudit(c *gin.Context) {
var req md.AppletApplicationSaveReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
NewAppletApplicationDb := implement.NewAppletApplicationDb(MasterDb(c))
list, _ := NewAppletApplicationDb.FindAppletApplicationListByIds(strings.Split(req.Id, ","))
if list != nil {
masterId := GetMasterId(c)
wxOpenThirdPartyAppListDb := implement2.NewWxOpenThirdPartyAppListDb(db.Db)
wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId))
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
if wxOpenThirdPartyAppList == nil {
e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录")
return
}
wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
userWxAppletListDb := implement2.NewUserWxAppletListDb(db.Db)
userWxAppletList, _ := userWxAppletListDb.GetUserWxAppletList(c.GetString("mid"))
appId := ""
if userWxAppletList != nil {
appId = userWxAppletList.Appid
}
for _, v := range *list {
v.State = utils.StrToInt(req.State)
v.Memo = req.Memo
err := changeWx(c, wxApiService, appId, v.State, v.MediumId)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
MasterDb(c).Where("id=?", v.Id).Cols("state,memo").Update(&v)
}
}
e.OutSuc(c, "success", nil)
return
}
func changeWx(c *gin.Context, wxApiService wechat.WxApiService, appId string, state, mediumId int) error {
if state != 2 && state != 4 {
return nil
}
NewAppletApplicationAdSpaceListDb := implement.NewAppletApplicationAdSpaceListDb(MasterDb(c))
list, _ := NewAppletApplicationAdSpaceListDb.FindAppletApplicationAdSpaceListByMediumId(mediumId)
if list != nil {
for _, v := range *list { //全部恢复 全部封禁
if v.State != 2 && v.State != 4 {
continue
}
if v.AppId != "" {
onOff := ""
if state == 4 { //禁用
onOff = enum.AdunitStatusForOff
v.UseState = 2
v.State = 3
}
if state == 2 { //恢复
onOff = enum.AdunitStatusForOn
v.UseState = 1
v.State = 1
}
if onOff != "" && v.AdId != "" && appId != "" {
err := wxApiService.AgencyUpdateAdunit(appId, v.AdId, v.Name, enum.AdunitType(v.Kind), enum.AdunitStatus(onOff))
if err != nil {
return err
}
}
MasterDb(c).Where("id=?", v.Id).Cols("state,use_state").Update(&v)
}
}
}
return nil
}

+ 217
- 0
app/svc/svc_applet_application_ad_space.go View File

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

import (
"applet/app/e"
"applet/app/lib/validate"
"applet/app/lib/wechat"
"applet/app/lib/wechat/enum"
"applet/app/md"
"applet/app/utils"
db "code.fnuoos.com/zhimeng/model.git/src"
"code.fnuoos.com/zhimeng/model.git/src/implement"
"code.fnuoos.com/zhimeng/model.git/src/model"
implement2 "code.fnuoos.com/zhimeng/model.git/src/super/implement"
"github.com/gin-gonic/gin"
"strings"
)

func AppletApplicationAdSpaceMediumList(c *gin.Context) {
var req md.AppletApplicationAdSpaceMediumListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
engine := MasterDb(c)
NewMediumDb := implement.NewMediumDb(engine)

list, total, _ := NewMediumDb.FindSuperAdmin(req.Account, req.Name, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.AppletApplicationAdSpaceMediumListData, 0)
if len(list) > 0 {
for _, v := range list {
var tmp = md.AppletApplicationAdSpaceMediumListData{
Id: utils.IntToStr(v.Id),
MediumId: utils.IntToStr(v.MediumId),
Name: v.Memo,
Account: v.Username,
ContactName: "",
Phone: "",
Count: "",
}
NewMediumContactInfoDb := implement2.NewMediumContactInfoDb(engine)
infoList, _ := NewMediumContactInfoDb.GetMediumContactInfoList(v.MediumId)
if infoList != nil {
tmp.ContactName = infoList.Name
tmp.Phone = infoList.Phone
}
count, _ := engine.Where("medium_id=?", v.MediumId).Count(&model.AppletApplicationAdSpaceList{})
tmp.Count = utils.Int64ToStr(count)
data = append(data, tmp)
}
}
res := md.AppletApplicationAdSpaceMediumListRes{
List: data,
Total: total,
}
e.OutSuc(c, res, nil)
return
}

func AppletApplicationAdSpaceList(c *gin.Context) {
var req md.AppletApplicationAdSpaceListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
engine := MasterDb(c)
NewAppletApplicationDb := implement.NewAppletApplicationAdSpaceListDb(engine)
appletApplicationList, total, _ := NewAppletApplicationDb.FindAppletApplicationAdSpaceList(req.Name, req.Platform, req.CooperateState, utils.StrToInt(req.MediumId), utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.AppletApplicationAdSpaceListData, 0)
if len(appletApplicationList) > 0 {
for _, v := range appletApplicationList {
var tmp = md.AppletApplicationAdSpaceListData{
Id: utils.IntToStr(v.AppletApplicationAdSpaceList.Id),
Name: v.AppletApplicationAdSpaceList.Name,
Platform: v.Platform,
Kind: v.Kind,
Memo: v.AppletApplicationAdSpaceList.Memo,
Logo: v.Logo,
AppId: v.AppletApplicationAdSpaceList.AppId,
AdId: v.AppletApplicationAdSpaceList.AdId,
State: utils.IntToStr(v.AppletApplicationAdSpaceList.State),
CooperateState: utils.IntToStr(v.AppletApplicationAdSpaceList.State),
}
data = append(data, tmp)
}
}
res := md.AppletApplicationAdSpaceListRes{
List: data,
Total: total,
AdType: []md.SelectData{
{Name: "banner", Value: enum.AdunitTypeForBanner},
{Name: "激励视频", Value: enum.AdunitTypeForRewardVideo},
{Name: "插屏广告", Value: enum.AdunitTypeForInterstitial},
{Name: "视频广告", Value: enum.AdunitTypeForVideoFeeds},
//{Name: "视频贴片广告", Value: "5"},
},
Platform: []md.SelectData{
{
Name: "微信小程序",
Value: "wx_applet",
},
},
State: []md.SelectData{
{
Name: "待审核",
Value: "0",
},
{
Name: "审核通过",
Value: "1",
},
{
Name: "审核拒绝",
Value: "2",
},
{
Name: "封禁中",
Value: "3",
},
},
CooperateState: []md.SelectData{
{
Name: "未运行",
Value: "0",
},
{
Name: "运行中",
Value: "1",
},
{
Name: "审核拒绝",
Value: "2",
},
{
Name: "封禁中",
Value: "3",
},
},
}
e.OutSuc(c, res, nil)
return
}
func AppletApplicationAdSpaceAudit(c *gin.Context) {
var req md.AppletApplicationAdSpaceSaveReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
masterId := GetMasterId(c)
wxOpenThirdPartyAppListDb := implement2.NewWxOpenThirdPartyAppListDb(db.Db)
wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId))
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
if wxOpenThirdPartyAppList == nil {
e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录")
return
}
wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
userWxAppletListDb := implement2.NewUserWxAppletListDb(db.Db)
userWxAppletList, _ := userWxAppletListDb.GetUserWxAppletList(c.GetString("mid"))
appId := ""
if userWxAppletList != nil {
appId = userWxAppletList.Appid
}
NewAppletApplicationAdSpaceListDb := implement.NewAppletApplicationAdSpaceListDb(MasterDb(c))
list, _ := NewAppletApplicationAdSpaceListDb.FindAppletApplicationAdSpaceListByIds(strings.Split(req.Id, ","))
if list != nil {

for _, v := range *list {
v.State = utils.StrToInt(req.State)
v.Memo = req.Memo
if v.AdId == "" && v.State == 1 && appId != "" {
err, v.AdId = wxApiService.AgencyCreateAdunit(appId, v.Name, enum.AdunitType(v.Kind))
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
v.UseState = 1
}
if v.AppId != "" {
onOff := ""
if v.State == 3 && v.UseState != 2 { //禁用
onOff = enum.AdunitStatusForOff
v.UseState = 2
}
if v.State == 1 && v.UseState == 2 { //恢复
onOff = enum.AdunitStatusForOn
v.UseState = 1
}
if onOff != "" && v.AdId != "" && appId != "" {
err = wxApiService.AgencyUpdateAdunit(appId, v.AdId, v.Name, enum.AdunitType(v.Kind), enum.AdunitStatus(onOff))
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
}
}
MasterDb(c).Where("id=?", v.Id).Cols("state,memo,ad_id,use_state").Update(&v)
}
}
e.OutSuc(c, "success", nil)
return
}

+ 156
- 0
app/svc/svc_medium_agent.go View File

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

import (
"applet/app/e"
"applet/app/lib/validate"
"applet/app/md"
"applet/app/utils"
db "code.fnuoos.com/zhimeng/model.git/src"
implement2 "code.fnuoos.com/zhimeng/model.git/src/implement"
"code.fnuoos.com/zhimeng/model.git/src/super/implement"
"code.fnuoos.com/zhimeng/model.git/src/super/model"
"github.com/gin-gonic/gin"
"strings"
"time"
)

func AgentBindMediumList(c *gin.Context) { //代理 查旗下 媒体
var req md.MediumListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
engine := db.Db
agentWithMediumDb := implement.NewAgentWithMediumDb(engine)
data, total, _ := agentWithMediumDb.FindAgentWithMediumList(req.Name, req.State, utils.StrToInt(req.Id), 0, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))

list := make([]md.MediumListData, 0)
NewMediumDb := implement2.NewMediumDb(MasterDb(c))

if data != nil {
for _, v := range data {
tmp := md.MediumListData{
Id: utils.IntToStr(v.AgentWithMedium.Id),
MediumId: utils.IntToStr(v.AgentWithMedium.MediumId),
CompanyName: v.MediumList.CompanyName,
UnifiedSocialCreditCode: v.MediumList.UnifiedSocialCreditCode,
State: utils.IntToStr(v.MediumList.State),
Memo: v.MediumList.Memo,
LegalRepresentative: v.MediumList.LegalRepresentative,
BusinessLicenseAddress: v.MediumList.BusinessLicenseAddress,
}
medium := NewMediumDb.GetSuperAdmin(v.AgentWithMedium.MediumId)
if medium != nil {
tmp.Account = medium.Username
}
list = append(list, tmp)
}
}
res := md.MediumListRes{
List: list,
Total: total,
State: []md.SelectData{
{Name: "待提交", Value: "0"},
{Name: "待审核", Value: "1"},
{Name: "审核通过", Value: "2"},
{Name: "审核拒绝", Value: "3"},
},
}
e.OutSuc(c, res, nil)
return
}
func MediumBindAgentList(c *gin.Context) {
var req md.MediumListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
engine := db.Db
agentWithMediumDb := implement.NewAgentWithMediumDb(engine)
data, total, _ := agentWithMediumDb.FindAgentWithMediumList(req.Name, req.State, 0, utils.StrToInt(req.Id), utils.StrToInt(req.Page), utils.StrToInt(req.Limit))

list := make([]md.MediumListData, 0)
NewAgentDb := implement2.NewAgentDb(MasterDb(c))

if data != nil {
for _, v := range data {
tmp := md.MediumListData{
Id: utils.IntToStr(v.AgentWithMedium.Id),
MediumId: utils.IntToStr(v.AgentWithMedium.AgentId),
CompanyName: v.AgentList.CompanyName,
UnifiedSocialCreditCode: v.AgentList.UnifiedSocialCreditCode,
State: utils.IntToStr(v.AgentList.State),
Memo: v.AgentList.Memo,
LegalRepresentative: v.AgentList.LegalRepresentative,
BusinessLicenseAddress: v.AgentList.BusinessLicenseAddress,
}
agent := NewAgentDb.GetSuperAdmin(v.AgentWithMedium.AgentId)
if agent != nil {
tmp.Account = agent.Username
}
list = append(list, tmp)
}
}
res := md.MediumListRes{
List: list,
Total: total,
State: []md.SelectData{
{Name: "待提交", Value: "0"},
{Name: "待审核", Value: "1"},
{Name: "审核通过", Value: "2"},
{Name: "审核拒绝", Value: "3"},
},
}
e.OutSuc(c, res, nil)
return
}
func MediumBindAgentSave(c *gin.Context) {
var req md.MediumListSaveReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
agentDb := implement2.NewAgentDb(MasterDb(c))
username, _ := agentDb.GetSuperAgentByUsername(req.Username)
if username == nil {
e.OutErr(c, 400, e.NewErr(400, "渠道代理不存在"))
return
}
mediumDb := implement.NewAgentWithMediumDb(db.Db)
data := mediumDb.GetAgentWithMediumByMediumIdAndAgentId(utils.StrToInt(req.MediumId), username.AgentId)
if data != nil {
e.OutErr(c, 400, e.NewErr(400, "已绑定过该渠道代理"))
return
}
var tmp = model.AgentWithMedium{
AgentId: username.AgentId,
MediumId: utils.StrToInt(req.MediumId),
CreateAt: time.Now(),
UpdateAt: time.Now(),
}
db.Db.InsertOne(&tmp)
e.OutSuc(c, "success", nil)
return
}
func MediumBindAgentDel(c *gin.Context) {
var req md.MediumListDelReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
db.Db.In("id", strings.Split(req.Id, ",")).Delete(&model.AgentWithMedium{})
e.OutSuc(c, "success", nil)
return
}

+ 21
- 4
app/svc/svc_medium_qualification.go View File

@@ -6,18 +6,20 @@ import (
"applet/app/md"
"applet/app/utils"
db "code.fnuoos.com/zhimeng/model.git/src"
implement2 "code.fnuoos.com/zhimeng/model.git/src/implement"
"code.fnuoos.com/zhimeng/model.git/src/super/implement"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
)

func MediumQualificationEnterprise(c *gin.Context, req md.MediumQualificationEnterpriseReq) md.MediumQualificationEnterpriseRes {
func MediumQualificationEnterprise(c *gin.Context, minState int, req md.MediumQualificationEnterpriseReq) md.MediumQualificationEnterpriseRes {

engine := db.Db
MediumListDb := implement.NewMediumListDb(engine)
MediumList, total, _ := MediumListDb.FindMediumList(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
MediumList, total, _ := MediumListDb.FindMediumList(c.GetString("mid"), req.Name, req.State, minState, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
data := make([]md.MediumQualificationEnterpriseData, 0)
if len(MediumList) > 0 {
NewMediumDb := implement2.NewMediumDb(MasterDb(c))
for _, v := range MediumList {
var tmp md.MediumQualificationEnterpriseData
copier.Copy(&tmp, &v)
@@ -33,6 +35,10 @@ func MediumQualificationEnterprise(c *gin.Context, req md.MediumQualificationEnt
tmp.RegisteredAddressCityId = utils.IntToStr(v.RegisteredAddressCityId)
tmp.RegisteredAddressCountyId = utils.IntToStr(v.RegisteredAddressCountyId)
tmp.State = utils.IntToStr(v.State)
medium := NewMediumDb.GetSuperAdmin(v.MediumId)
if medium != nil {
tmp.Account = medium.Username
}
data = append(data, tmp)
}
}
@@ -86,10 +92,11 @@ func MediumQualificationEnterpriseAudit(c *gin.Context, req md.MediumQualificati
func MediumQualificationBank(c *gin.Context, req md.MediumQualificationEnterpriseReq) md.MediumQualificationBankRes {
engine := db.Db
MediumListDb := implement.NewMediumBankInfoDb(engine)
MediumList, total, _ := MediumListDb.FindMediumBankInfoList(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
MediumList, total, _ := MediumListDb.FindMediumBankInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))

list := make([]md.MediumQualificationBankData, 0)
if MediumList != nil {
NewMediumDb := implement2.NewMediumDb(MasterDb(c))
for _, v := range MediumList {
tmp := md.MediumQualificationBankData{
Id: utils.IntToStr(v.MediumBankInfo.Id),
@@ -105,6 +112,11 @@ func MediumQualificationBank(c *gin.Context, req md.MediumQualificationEnterpris
BankNo: v.BankNo,
Licence: v.Licence,
}

medium := NewMediumDb.GetSuperAdmin(v.MediumBankInfo.MediumId)
if medium != nil {
tmp.Account = medium.Username
}
list = append(list, tmp)
}
}
@@ -163,10 +175,11 @@ func MediumQualificationContactInfo(c *gin.Context, req md.MediumQualificationEn

engine := db.Db
MediumListDb := implement.NewMediumContactInfoDb(engine)
MediumList, total, _ := MediumListDb.FindMediumContactInfoList(req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))
MediumList, total, _ := MediumListDb.FindMediumContactInfoList(c.GetString("mid"), req.Name, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit))

list := make([]md.MediumQualificationContactData, 0)
if MediumList != nil {
NewMediumDb := implement2.NewMediumDb(MasterDb(c))
for _, v := range MediumList {
tmp := md.MediumQualificationContactData{
Id: utils.IntToStr(v.MediumContactInfo.Id),
@@ -180,6 +193,10 @@ func MediumQualificationContactInfo(c *gin.Context, req md.MediumQualificationEn
Phone: v.MediumContactInfo.Phone,
Address: v.MediumContactInfo.Address,
}
medium := NewMediumDb.GetSuperAdmin(v.MediumContactInfo.MediumId)
if medium != nil {
tmp.Account = medium.Username
}
list = append(list, tmp)
}
}


+ 0
- 78
app/svc/svc_sys_cfg_get.go View File

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

import (
"applet/app/db/implement"
db "code.fnuoos.com/zhimeng/model.git/src"
"github.com/gin-gonic/gin"
"xorm.io/xorm"

"applet/app/md"
"applet/app/utils/cache"
)

// 单挑记录获取
func SysCfgGet(c *gin.Context, key string) string {
masterId := GetMasterId(c)
eg := db.DBs[masterId]
sysCfgDb := implement.NewSysCfgDb(eg, masterId)
return sysCfgDb.SysCfgGetWithDb(key)
}

// 多条记录获取
func SysCfgFind(c *gin.Context, keys ...string) map[string]string {
var masterId string
if c == nil {
masterId = ""
} else {
masterId = GetMasterId(c)
}
tmp := SysCfgFindComm(masterId, keys...)
return tmp
}
func SysCfgFindComm(masterId string, keys ...string) map[string]string {
var eg *xorm.Engine
if masterId == "" {
eg = db.Db
} else {
eg = db.DBs[masterId]
}
res := map[string]string{}
//TODO::判断keys长度(大于10个直接查数据库)
sysCfgDb := implement.NewSysCfgDb(eg, masterId)
if len(keys) > 10 {
cfgList, _ := sysCfgDb.SysCfgGetAll()
if cfgList == nil {
return nil
}
for _, v := range *cfgList {
res[v.K] = v.V
}
} else {
for _, key := range keys {
res[key] = sysCfgDb.SysCfgGetWithDb(key)
}
}
return res
}

// 清理系统配置信息
func SysCfgCleanCache() {
cache.Del(md.KEY_SYS_CFG_CACHE)
}

// 写入系统设置
func SysCfgSet(c *gin.Context, key, val, memo string) bool {
masterId := GetMasterId(c)
eg := db.DBs[masterId]
sysCfgDb := implement.NewSysCfgDb(eg, masterId)

cfg, err := sysCfgDb.SysCfgGetOne(key)
if err != nil || cfg == nil {
return sysCfgDb.SysCfgInsert(key, val, memo)
}
if memo != "" && cfg.Memo != memo {
cfg.Memo = memo
}
SysCfgCleanCache()
return sysCfgDb.SysCfgUpdate(key, val)
}

+ 1571
- 418
docs/docs.go
File diff suppressed because it is too large
View File


+ 1571
- 418
docs/swagger.json
File diff suppressed because it is too large
View File


+ 850
- 72
docs/swagger.yaml
File diff suppressed because it is too large
View File


Loading…
Cancel
Save