Files
kami_boss/internal/models/merchant/merchant_deploy_info.go
danial c3906e940e refactor(account): 重构账户管理页面布局和样式
-精简HTML结构,优化`account.html`,`apple-card/account.html`,和`t-mall-game/account.html`中iframe的布局。
- 调整CSS样式,以增强用户界面的一致性和可读性。
- 优化`account_history.html`中的表格和搜索栏的样式与对齐。

fix(controller): 修正新增控制器参数顺序

- 修正`addController.go`中的参数顺序,确保交易类型正确传递给服务层。
- 更新数据库插入操作,确保UUID正确分配给新记录,防止SQL错误。
2024-09-04 09:54:18 +08:00

148 lines
3.7 KiB
Go

package merchant
import (
"encoding/json"
"fmt"
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"time"
)
type MerchantDeployInfo struct {
Id int
Status string
MerchantUid string
PayType string
SingleRoadUid string
SingleRoadName string
SingleRoadPlatformRate string
SingleRoadAgentRate float64
RollRoadCode string
RollRoadName string
RollRoadPlatformRate float64
RollRoadAgentRate float64
IsLoan string
LoanRate float64
LoanDays int
UnfreezeHour int
WaitUnfreezeAmount float64
LoanAmount float64
UpdateTime time.Time
CreateTime time.Time
}
type ProfitMargin struct {
Label string `json:"label"`
LinkID string `json:"linkID"`
Value int `json:"value"`
}
const MERCHANT_DEPLOY_INFO = "merchant_deploy_info"
func (m *MerchantDeployInfo) GetSingleRoadPlatformRateMapping() (map[int]float64, error) {
myMap := make(map[int]float64)
// 使用json.Unmarshal函数解码JSON字符串到map中
err := json.Unmarshal([]byte(m.SingleRoadPlatformRate), &myMap)
if err != nil {
fmt.Println("Error decoding JSON:", err)
return myMap, err
}
return myMap, err
}
func (m *MerchantDeployInfo) GetSingleRoadPlatformRateByPrice(price int) (float64, error) {
mapping, err := m.GetSingleRoadPlatformRateMapping()
if err != nil {
return 0.0, err
}
for k, v := range mapping {
if k == price {
return v, nil
}
}
return 0.0, nil
}
func CheckNumberMappingValid(str string) bool {
myMap := make(map[int]float64)
// 使用json.Unmarshal函数解码JSON字符串到map中
err := json.Unmarshal([]byte(str), &myMap)
if err != nil {
fmt.Println("Error decoding JSON:", str, err)
return false
}
return true
}
func CheckMarginValid(str string) bool {
var m []ProfitMargin
err := json.Unmarshal([]byte(str), &m)
if err != nil {
fmt.Println("Error decoding JSON:", err, str)
return false
}
return true
}
func InsertMerchantDeployInfo(merchantDeployInfo MerchantDeployInfo) bool {
o := orm.NewOrm()
_, err := o.Insert(&merchantDeployInfo)
if err != nil {
logs.Error("insert merchant deploy info fail: ", err)
return false
}
return true
}
func IsExistByUidAndPayType(uid, payType string) bool {
o := orm.NewOrm()
isEixst := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", uid).Filter("pay_type", payType).Exist()
return isEixst
}
func GetMerchantDeployByUidAndPayType(uid, payType string) MerchantDeployInfo {
o := orm.NewOrm()
var merchantDeployInfo MerchantDeployInfo
_, err := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", uid).
Filter("pay_type", payType).Limit(1).
All(&merchantDeployInfo)
if err != nil {
logs.Error("get merchant deploy by uid and paytype fail:", err)
}
return merchantDeployInfo
}
func DeleteMerchantDeployByUidAndPayType(uid, payType string) bool {
o := orm.NewOrm()
_, err := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", uid).Filter("pay_type", payType).Delete()
if err != nil {
logs.Error("delete merchant deploy by uid and payType fail: ", err)
return false
}
return true
}
func DeleteOtherMerchantDeployInfo(deployInfo MerchantDeployInfo) {
o := orm.NewOrm()
_, err := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", deployInfo.MerchantUid).
Filter("id__ne", deployInfo.Id).Delete()
if err != nil {
logs.Error("delete other merchant deploy by uid and payType fail: ", err)
}
}
func UpdateMerchantDeploy(merchantDeploy MerchantDeployInfo) bool {
o := orm.NewOrm()
_, err := o.Update(&merchantDeploy)
if err != nil {
logs.Error("update merchant deploy fail: ", err)
return false
}
return true
}