应用和支付方式修改不能修改商户id

This commit is contained in:
wolter 2024-08-02 13:54:25 +08:00
parent 7a3823a2a7
commit f8f0ac2913
4 changed files with 27 additions and 43 deletions

View File

@ -50,7 +50,7 @@ type AppCreateRequest struct {
PrivateKey string `json:"private_key" validate:"required" label:"应用私钥"`
MerchantPublicKey string `json:"merchant_public_key" label:"商户公钥"`
WhiteIp string `json:"white_ip"`
NotifyUrl string `json:"notify_url"`
NotifyUrl string `json:"notify_url" validate:"required" label:"通知地址"`
}
func (a *AppCreateRequest) RequestToDb() (db appmodel.App) {
@ -69,13 +69,12 @@ func (a *AppCreateRequest) RequestToDb() (db appmodel.App) {
type AppUpdateRequest struct {
Id int64 `json:"id" validate:"required" label:"应用ID"`
MerchantId int64 `json:"merchant_id" validate:"required" label:"商户ID"`
AppName string `json:"app_name" validate:"required" label:"应用名称"`
AppName string `json:"app_name" label:"应用名称"`
AppRemark string `json:"app_remark" label:"应用备注"`
Status int `json:"status" validate:"oneof=0 1 2" label:"应用状态"`
KeyType int `json:"key_type" validate:"required" label:"应用密钥类型"`
PublicKey string `json:"public_key" validate:"required" label:"应用公钥"`
PrivateKey string `json:"private_key" validate:"required" label:"应用私钥"`
Status int `json:"status" label:"应用状态"`
KeyType int `json:"key_type" label:"应用密钥类型"`
PublicKey string `json:"public_key" label:"应用公钥"`
PrivateKey string `json:"private_key" label:"应用私钥"`
MerchantPublicKey string `json:"merchant_public_key" label:"商户公钥"`
WhiteIp string `json:"white_ip"`
NotifyUrl string `json:"notify_url"`
@ -83,7 +82,6 @@ type AppUpdateRequest struct {
func (a *AppUpdateRequest) RequestToDb() (db appmodel.App) {
db.Id = a.Id
db.MerchantId = a.MerchantId
db.AppName = a.AppName
db.AppRemark = a.AppRemark
db.Status = a.Status

View File

@ -91,14 +91,18 @@ type PayChannelListRequest struct {
}
type PayChannelUpdateRequest struct {
Id int64 `json:"id" validate:"required"`
PayChannelCreateRequest
Id int64 `json:"id" validate:"required"`
PayName string `json:"pay_name" validate:"required" label:"支付渠道名称"`
ChannelType int `json:"channel_type" validate:"required" label:"支付渠道"` //支付渠道枚举,1微信JSAPI2微信H53微信app4微信Native5微信小程序6支付宝网页&移动应用7支付宝小程序8支付宝JSAPI
AppId string `json:"app_id" validate:"required" label:"应用appId"`
ExpireTime string `json:"expire_time"`
AliPayPayChannel AliPayPayChannel `json:"ali_pay_pay_channel,omitempty"`
WechatPayChannel WechatPayChannel `json:"wechat_pay_channel,omitempty"`
}
func (p PayChannelUpdateRequest) RequestToDb() (db paychannelmodel.PayChannel, err error) {
db.Id = p.Id
db.PayName = p.PayName
db.MerchantId = p.MerchantId
db.ChannelType = p.ChannelType
db.AppId = p.AppId
if p.ExpireTime != "" {

View File

@ -26,13 +26,13 @@ func AppList(req backend.AppListRequest) (result []appmodel.App, total int64, co
return appList, count, code
}
func AppCreate(App *appmodel.App) (code int) {
func AppCreate(app *appmodel.App) (code int) {
db := paychannelmodel.GetInstance().GetDb()
repo := data.NewAppRepo(db)
merchantRepo := data.NewMerchantRepo(db)
// 拼接查询条件
conn := builder.NewCond()
conn = conn.And(builder.Eq{"id": App.MerchantId})
conn = conn.And(builder.Eq{"id": app.MerchantId})
merchant := merchantmodel.Merchant{}
has, err := merchantRepo.MerchantDetail(&merchant, conn)
if err != nil {
@ -42,31 +42,25 @@ func AppCreate(App *appmodel.App) (code int) {
return errorcode.MerchantNotFound
}
_, err = repo.AppInsertOne(App)
_, err = repo.AppInsertOne(app)
code = handErr(err)
return
}
func AppUpdate(App *appmodel.App) (code int) {
func AppUpdate(app *appmodel.App) (code int) {
var err error
db := paychannelmodel.GetInstance().GetDb()
repo := data.NewAppRepo(db)
merchantRepo := data.NewMerchantRepo(db)
// 拼接查询条件
conn := builder.NewCond()
conn = conn.And(builder.Eq{"id": App.MerchantId})
merchant := merchantmodel.Merchant{}
has, err := merchantRepo.MerchantDetail(&merchant, conn)
if err != nil {
return handErr(err)
}
if !has {
return errorcode.MerchantNotFound
}
// 拼接查询条件
uconn := builder.NewCond()
uconn = uconn.And(builder.Eq{"Id": App.Id})
_, err = repo.AppUpdate(App, uconn, "app_remark")
conn := builder.NewCond()
conn = conn.And(builder.Eq{"Id": app.Id})
if app.AppName != "" {
// 编辑页面更新备注和白名单IP可更新为空
_, err = repo.AppUpdate(app, conn, "app_remark", "white_ip")
} else {
_, err = repo.AppUpdate(app, conn)
}
code = handErr(err)
return

View File

@ -49,23 +49,11 @@ func PayChannelCreate(payChannel *paychannelmodel.PayChannel) (code int) {
func PayChannelUpdate(payChannel *paychannelmodel.PayChannel) (code int) {
db := paychannelmodel.GetInstance().GetDb()
repo := data.NewPayChannelRepo(db)
merchantRepo := data.NewMerchantRepo(db)
// 拼接查询条件
conn := builder.NewCond()
conn = conn.And(builder.Eq{"id": payChannel.MerchantId})
merchant := merchantmodel.Merchant{}
has, err := merchantRepo.MerchantDetail(&merchant, conn)
if err != nil {
return handErr(err)
}
if !has {
return errorcode.MerchantNotFound
}
// 拼接查询条件
uconn := builder.NewCond()
uconn = uconn.And(builder.Eq{"Id": payChannel.Id})
_, err = repo.PayChannelUpdate(payChannel, uconn, "white_ip")
_, err := repo.PayChannelUpdate(payChannel, uconn, "white_ip")
code = handErr(err)
return