|
- package financial_center
-
- import (
- "applet/app/db"
- "applet/app/e"
- md "applet/app/md/financial_center"
- "applet/app/utils"
- "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
- "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
- md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
- "github.com/gin-gonic/gin"
- "time"
- )
-
- // GetWithdrawSetting
- // @Summary 财务中心-提现-基础设置(获取)
- // @Tags 提现
- // @Description 基础设置(获取)
- // @Accept json
- // @Produce json
- // @param Authorization header string true "验证参数Bearer和token空格拼接"
- // @Success 200 {object} md.GetWithdrawSettingResp "具体数据"
- // @Failure 400 {object} md.Response "具体错误"
- // @Router /api/financialCenter/withdraw/setting [get]
- func GetWithdrawSetting(c *gin.Context) {
- settingDb := implement.NewFinWithdrawSettingDb(db.Db)
- setting, err := settingDb.FinWithdrawSettingGetOne()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- // 不存在则初始化
- if setting == nil {
- now := time.Now()
- frequency := md2.WithdrawFrequencySettingStruct{
- Duration: 0,
- Num: 0,
- }
- frequencyStr := utils.SerializeStr(frequency)
- m := model.FinWithdrawSetting{
- FrequencySet: frequencyStr,
- WithdrawType: 0,
- VipLevelLimit: 0,
- IsRealName: 0,
- WithdrawNumsLimit: 0,
- WithdrawAmountLimit: "",
- WithdrawMultipleLimit: "",
- IsSupportDecimalPoint: 0,
- IsAuto: 0,
- WithdrawTimeInterval: "",
- WithdrawFeeSet: "",
- CreateAt: now.Format("2006-01-02 15:04:05"),
- UpdateAt: "",
- }
- _, err2 := settingDb.FinWithdrawSettingInsert(&m)
- if err2 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err2.Error())
- return
- }
-
- setting, err = settingDb.FinWithdrawSettingGetOne()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- }
- var frequency md2.WithdrawFrequencySettingStruct
- utils.Unserialize([]byte(setting.FrequencySet), &frequency)
- resp := md.GetWithdrawSettingResp{
- Id: setting.Id,
- FrequencySet: frequency,
- WithdrawType: setting.WithdrawType,
- VipLevelLimit: setting.VipLevelLimit,
- IsRealName: setting.IsRealName,
- WithdrawNumsLimit: setting.WithdrawNumsLimit,
- WithdrawAmountLimit: setting.WithdrawAmountLimit,
- WithdrawMultipleLimit: setting.WithdrawMultipleLimit,
- IsSupportDecimalPoint: setting.IsSupportDecimalPoint,
- IsAuto: setting.IsAuto,
- WithdrawTimeInterval: setting.WithdrawTimeInterval,
- WithdrawFeeSet: setting.WithdrawFeeSet,
- CreateAt: setting.CreateAt,
- UpdateAt: setting.UpdateAt,
- }
-
- e.OutSuc(c, resp, nil)
- }
-
- // UpdateWithdrawSetting
- // @Summary 财务中心-提现-基础设置(更新)
- // @Tags 提现
- // @Description 基础设置(更新)
- // @Accept json
- // @Produce json
- // @param Authorization header string true "验证参数Bearer和token空格拼接"
- // @Param req body md.UpdateWithdrawSettingReq true "id 必填"
- // @Success 200 {int} "修改数据条数"
- // @Failure 400 {object} md.Response "具体错误"
- // @Router /api/financialCenter/withdraw/updateWithdrawSetting [POST]
- func UpdateWithdrawSetting(c *gin.Context) {
- var req *md.UpdateWithdrawSettingReq
- if err1 := c.ShouldBindJSON(&req); err1 != nil {
- e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
- return
- }
- frequencyStr := utils.SerializeStr(req.FrequencySet)
- m := model.FinWithdrawSetting{
- Id: req.Id,
- FrequencySet: frequencyStr,
- WithdrawType: req.WithdrawType,
- VipLevelLimit: req.VipLevelLimit,
- IsRealName: req.IsRealName,
- WithdrawNumsLimit: req.WithdrawNumsLimit,
- WithdrawAmountLimit: req.WithdrawAmountLimit,
- WithdrawMultipleLimit: req.WithdrawMultipleLimit,
- IsSupportDecimalPoint: req.IsSupportDecimalPoint,
- IsAuto: req.IsAuto,
- WithdrawTimeInterval: req.WithdrawTimeInterval,
- WithdrawFeeSet: req.WithdrawFeeSet,
- }
-
- forceColumns := []string{"withdraw_type", "is_real_name", "withdraw_nums_limit", "withdraw_amount_limit", "withdraw_multiple_limit", "is_support_decimal_point", "is_auto"}
- settingDb := implement.NewFinWithdrawSettingDb(db.Db)
- affected, err := settingDb.FinWithdrawSettingUpdate(req.Id, &m, forceColumns...)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- e.OutSuc(c, affected, nil)
- }
|