diff --git a/boss/views/bank_card.html b/boss/views/bank_card.html index d2c2e5e..dcbf8c2 100644 --- a/boss/views/bank_card.html +++ b/boss/views/bank_card.html @@ -77,7 +77,7 @@ 序列号 - 用户名称 + 商户名称(UID) 银行名称 银行编码 对账卡类型 @@ -121,8 +121,9 @@
- 用户名称: - + 商户名称: +
银行编码: @@ -442,6 +443,27 @@ } }); }); + + function setAccount() { + $.ajax({ + url: "/get/all/account", + success: function (res) { + if (res.Code == 404) { + window.parent.location = "/login.html"; + } else { + let str = ''; + for (let i = 0; i < res.AccountList.length; i ++) { + let account = res.AccountList[i]; + str = str + ''; + } + $("#select-self-name").html(str); + } + } + }); + } + $(function () { + setAccount(); + }); \ No newline at end of file diff --git a/boss/views/merchant_payfor.html b/boss/views/merchant_payfor.html index 44f57c3..750c948 100644 --- a/boss/views/merchant_payfor.html +++ b/boss/views/merchant_payfor.html @@ -219,6 +219,7 @@ }); } function merchantList(dataJSON) { + if (JSONIsEmpty(dataJSON)) { dataJSON = getCutPagesValues(); } diff --git a/legend/controllers/base/baseController.go b/legend/controllers/base/baseController.go index adebb89..90bfcd7 100644 --- a/legend/controllers/base/baseController.go +++ b/legend/controllers/base/baseController.go @@ -1,7 +1,7 @@ package base import ( - "github.com/astaxie/beego/logs" + "github.com/beego/beego/v2/core/logs" "github.com/beego/beego/v2/server/web" "legend/models/fast" ) @@ -21,8 +21,8 @@ func (c *BasicController) Prepare() { userInfo := fast.GetMerchantInfoByUserName(userName) if userInfo.LoginAccount != "" { c.Data["nickName"] = userInfo.MerchantName + c.Data["merchantUid"] = userInfo.MerchantUid } } else { - c.Data["nickName"] = "史蒂芬-库里" } } diff --git a/legend/controllers/logoutController.go b/legend/controllers/logoutController.go index 5923ae5..147dd6c 100644 --- a/legend/controllers/logoutController.go +++ b/legend/controllers/logoutController.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/astaxie/beego/logs" + "github.com/beego/beego/v2/core/logs" "github.com/beego/beego/v2/server/web" ) diff --git a/legend/controllers/showPageController.go b/legend/controllers/showPageController.go index 18a503f..1e38e5c 100644 --- a/legend/controllers/showPageController.go +++ b/legend/controllers/showPageController.go @@ -48,28 +48,34 @@ func (c *ShowPageController) MerchantKeyPage() { userName := c.GetSession("userName").(string) merchantService := new(service.MerchantService) - userInfo, bankInfo, payConfigInfo := merchantService.GetMerchantBankInfo(userName) + userInfo, bankInfo := merchantService.GetMerchantBankInfo(userName) c.Data["currentTime"] = utils.GetNowTime() c.Data["userName"] = userName c.Data["userInfo"] = userInfo c.Data["bankInfo"] = bankInfo - c.Data["payConfigInfo"] = payConfigInfo c.TplName = "merchant-key.html" } /** ** 比例模板 */ -func (c *ShowPageController) ScaleTempletePage() { - c.TplName = "scale-templete.html" +func (c *ShowPageController) ScaleTemplatePage() { + c.TplName = "scale-template.html" } /** ** 增加模板 */ -func (c *ShowPageController) TempleteAdd() { - c.TplName = "templete-add.html" +func (c *ShowPageController) TemplateAdd() { + c.TplName = "template-add.html" +} + +func (c *ShowPageController) TemplateEdit() { + templateName := c.GetString("templateName") + fmt.Println(templateName) + c.Data["scaleTemplateName"] = templateName + c.TplName = "template-edit.html" } /** diff --git a/legend/controllers/templeteController.go b/legend/controllers/templeteController.go new file mode 100644 index 0000000..19d0cec --- /dev/null +++ b/legend/controllers/templeteController.go @@ -0,0 +1,86 @@ +package controllers + +import ( + "fmt" + "github.com/beego/beego/v2/core/logs" + "legend/controllers/base" + "legend/request" + "legend/service" + "legend/utils" + "strings" +) + +type TemplateController struct { + base.BasicController +} + +func (c *TemplateController) TemplateAdd() { + + addTemplate := new(request.AddTemplateReq) + if err := c.ParseForm(addTemplate); err != nil { + logs.Error("错误:", err) + } + + addTemplate.FixPrices = utils.StringToFloats(c.GetString("fixPrices")) + addTemplate.PresentFixMoneys = utils.StringToFloats(c.GetString("presentFixMoneys")) + addTemplate.PresentFixPresentMoneys = utils.StringToFloats(c.GetString("presentFixPresentMoneys")) + addTemplate.PresentScaleMoneys = utils.StringToFloats(c.GetString("presentScaleMoneys")) + addTemplate.PresentScales = utils.StringToFloats(c.GetString("presentScales")) + + addTemplate.FixUids = strings.Split(c.GetString("fixUids"), ",") + addTemplate.GoodsNames = strings.Split(c.GetString("goodsNames"), ",") + addTemplate.GoodsNos = strings.Split(c.GetString("goodsNos"), ",") + + addTemplate.PresentFixUids = strings.Split(c.GetString("presentFixUids"), ",") + addTemplate.PresentScaleUids = strings.Split(c.GetString("presentScaleUids"), ",") + addTemplate.Limits = utils.StringToInt(c.GetString("limits")) + + se := new(service.TemplateService) + merchantUid := c.Data["merchantUid"].(string) + t := c.GetString("type") + if t == "edit" { + c.Data["json"] = se.UpdateTemplate(addTemplate, merchantUid) + } else { + c.Data["json"] = se.AddTemplate(addTemplate, merchantUid) + } + + _ = c.ServeJSON() +} + +func (c *TemplateController) TemplateList() { + + page, _ := c.GetInt("page") + limit, _ := c.GetInt("limit") + + se := new(service.TemplateService) + list := se.GetTemplateList(page, limit) + + c.Data["json"] = list + _ = c.ServeJSON() +} + +func (c *TemplateController) TemplateDelete() { + templateName := c.GetString("TemplateName") + + logs.Debug("template TemplateName :", templateName) + + se := new(service.TemplateService) + baseResp := se.DeleteTemplate(templateName) + + c.Data["json"] = baseResp + _ = c.ServeJSON() +} + +func (c *TemplateController) TemplateAllInfo() { + templateName := c.GetString("scaleTemplateName") + logs.Debug("获取到的scaleTemplateName:", templateName) + + se := new(service.TemplateService) + allInfo := se.AllTemplateInfo(templateName) + + logs.Debug("scale template all info:", fmt.Sprintf("%+v", allInfo)) + + c.Data["json"] = allInfo + + _ = c.ServeJSON() +} diff --git a/legend/filter/loginFilter.go b/legend/filter/loginFilter.go index e223858..8a31a0c 100644 --- a/legend/filter/loginFilter.go +++ b/legend/filter/loginFilter.go @@ -14,10 +14,14 @@ var LoginFilter = func(ctx *context.Context) { _, ok := ctx.Input.Session("userName").(string) if !ok { + if ctx.Request.RequestURI == "/login.html" { + return + } + if !strings.Contains(ctx.Request.RequestURI, "/login") { ctx.Redirect(302, "/login.html") } else { - logs.Info("该用户没有登录.......") + logs.Error("该用户没有登录.......") } } diff --git a/legend/go.mod b/legend/go.mod index 7f057bc..c68734c 100644 --- a/legend/go.mod +++ b/legend/go.mod @@ -5,7 +5,6 @@ go 1.13 require github.com/beego/beego/v2 v2.0.1 require ( - github.com/astaxie/beego v1.12.3 github.com/go-sql-driver/mysql v1.5.0 github.com/smartystreets/goconvey v1.6.4 ) diff --git a/legend/models/fast/accountInfoDao.go b/legend/models/fast/accountInfoDao.go index d6b66e2..5046512 100644 --- a/legend/models/fast/accountInfoDao.go +++ b/legend/models/fast/accountInfoDao.go @@ -1,8 +1,8 @@ package fast import ( - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/client/orm" + "github.com/beego/beego/v2/core/logs" ) type AccountInfo struct { diff --git a/legend/models/fast/bankCardInfoDao.go b/legend/models/fast/bankCardInfoDao.go new file mode 100644 index 0000000..7d6d6b8 --- /dev/null +++ b/legend/models/fast/bankCardInfoDao.go @@ -0,0 +1,39 @@ +package fast + +import ( + "github.com/beego/beego/v2/client/orm" + "github.com/beego/beego/v2/core/logs" +) + +type BankCardInfo struct { + Id string `orm:"pk;column(id)"` + Uid string + UserName string + BankName string + BankCode string + BankAccountType string + AccountName string + BankNo string + IdentifyCard string + CertificateNo string + PhoneNo string + BankAddress string + CreateTime string + UpdateTime string +} + +const BANKCARDINFO = "bank_card_info" + +func (c *BankCardInfo) TableName() string { + return BANKCARDINFO +} + +func GetBankCardInfoByUserNo(merchantNo string) *BankCardInfo { + o := orm.NewOrm() + bankCardInfo := new(BankCardInfo) + if _, err := o.QueryTable(BANKCARDINFO).Filter("user_name", merchantNo).Limit(1).All(bankCardInfo); err != nil { + + logs.Error("获取用户银行卡信息失败:", err) + } + return bankCardInfo +} diff --git a/legend/models/fast/merchantDeployInfo.go b/legend/models/fast/merchantDeployInfo.go new file mode 100644 index 0000000..9894e0f --- /dev/null +++ b/legend/models/fast/merchantDeployInfo.go @@ -0,0 +1,32 @@ +package fast + +import ( + "github.com/beego/beego/v2/client/orm" + "github.com/beego/beego/v2/core/logs" +) + +type MerchantDeployInfo struct { + Id string `orm:"pk;column(id)"` + Status string + MerchantUid string + PayType string + SingleRoadUid string + SingleRoadName string +} + +const MERCHANTDEPLOYINFO = "merchant_deploy_info" + +func (c *MerchantDeployInfo) TableName() string { + return MERCHANTDEPLOYINFO +} + +func GetUserPayConfigByUserNo(userNo string) *MerchantDeployInfo { + o := orm.NewOrm() + userPayConfig := new(MerchantDeployInfo) + _, err := o.QueryTable(MERCHANTDEPLOYINFO).Filter("user_no", userNo).All(userPayConfig) + if err != nil { + logs.Error("获取用户支付配置错误:", err) + } + + return userPayConfig +} diff --git a/legend/models/fast/userInfoDao.go b/legend/models/fast/merchantInfoDao.go similarity index 97% rename from legend/models/fast/userInfoDao.go rename to legend/models/fast/merchantInfoDao.go index ce2d3f1..005100f 100644 --- a/legend/models/fast/userInfoDao.go +++ b/legend/models/fast/merchantInfoDao.go @@ -1,8 +1,8 @@ package fast import ( - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/client/orm" + "github.com/beego/beego/v2/core/logs" ) type MerchantInfo struct { diff --git a/legend/models/fast/userBankAccountDao.go b/legend/models/fast/userBankAccountDao.go deleted file mode 100644 index 0d75b05..0000000 --- a/legend/models/fast/userBankAccountDao.go +++ /dev/null @@ -1,44 +0,0 @@ -package fast - -import ( - "github.com/astaxie/beego/logs" - "github.com/beego/beego/v2/client/orm" -) - -type RpUserBankAccount struct { - Id string `orm:"pk;column(id)"` - CreateTime string - EditTime string - Version string - Remark string - Status string - UserNo string - BankName string - BankCode string - BankAccountName string - BankAccountNo string - CardType string - CardNo string - MobileNo string - IsDefault string - Province string - City string - Areas string - Street string - BankAccountType string -} - -func (c *RpUserBankAccount) TableName() string { - return "rp_user_bank_account" -} - -func GetBankInfoByUserNo(userNo string) *RpUserBankAccount { - o := orm.NewOrm() - userBankAccount := new(RpUserBankAccount) - if _, err := o.QueryTable("rp_user_bank_account"). - Filter("user_no", userNo). - All(userBankAccount); err != nil { - logs.Error("获取用户银行卡信息失败:", err) - } - return userBankAccount -} diff --git a/legend/models/fast/userPayConfigDao.go b/legend/models/fast/userPayConfigDao.go deleted file mode 100644 index 1b94765..0000000 --- a/legend/models/fast/userPayConfigDao.go +++ /dev/null @@ -1,34 +0,0 @@ -package fast - -import ( - "github.com/astaxie/beego/logs" - "github.com/beego/beego/v2/client/orm" -) - -type RpUserPayConfig struct { - Id string `orm:"pk;column(id)"` - UserNo string - UserName string - Status string - PayKey string - PaySecret string -} - -func (c *RpUserPayConfig) TableName() string { - return "rp_user_pay_config" -} - -func getTableName() string { - return "rp_user_pay_config" -} - -func GetUserPayConfigByUserNo(userNo string) *RpUserPayConfig { - o := orm.NewOrm() - userPayConfig := new(RpUserPayConfig) - _, err := o.QueryTable(getTableName()).Filter("user_no", userNo).All(userPayConfig) - if err != nil { - logs.Error("获取用户支付配置错误:", err) - } - - return userPayConfig -} diff --git a/legend/models/init.go b/legend/models/init.go index 8587cf1..4047e6f 100644 --- a/legend/models/init.go +++ b/legend/models/init.go @@ -7,6 +7,7 @@ import ( "github.com/beego/beego/v2/server/web" _ "github.com/go-sql-driver/mysql" "legend/models/fast" + "legend/models/legend" "os" ) @@ -43,11 +44,18 @@ func initLegend() { orm.SetMaxIdleConns("default", 30) orm.RegisterModel(new(fast.MerchantInfo)) - orm.RegisterModel(new(fast.RpUserPayConfig)) - orm.RegisterModel(new(fast.RpUserBankAccount)) + orm.RegisterModel(new(fast.MerchantDeployInfo)) + orm.RegisterModel(new(fast.BankCardInfo)) orm.RegisterModel(new(fast.AccountInfo)) orm.RegisterModel(new(fast.OrderInfo)) + orm.RegisterModel(new(legend.AnyMoney)) + orm.RegisterModel(new(legend.FixMoney)) + orm.RegisterModel(new(legend.FixPresent)) + orm.RegisterModel(new(legend.ScalePresent)) + orm.RegisterModel(new(legend.ScaleTemplate)) + orm.RegisterModel(new(legend.Group)) + logs.Info("init legend success ......") } diff --git a/legend/models/legend/legendAnyMoneyDao.go b/legend/models/legend/legendAnyMoneyDao.go new file mode 100644 index 0000000..68de7a1 --- /dev/null +++ b/legend/models/legend/legendAnyMoneyDao.go @@ -0,0 +1,62 @@ +package legend + +import ( + "github.com/beego/beego/v2/client/orm" + "github.com/beego/beego/v2/core/logs" +) + +type AnyMoney struct { + Id int `orm:"pk;column(id)"` + TemplateName string + GameMoneyName string + GameMoneyScale int + LimitLow float64 + UpdateTime string + CreateTime string +} + +const ANYMONEY = "legend_any_money" + +func (c *AnyMoney) TableName() string { + return ANYMONEY +} + +func InsertAnyMoney(anyMoney *AnyMoney) bool { + o := orm.NewOrm() + if _, err := o.Insert(anyMoney); err != nil { + logs.Error("insert any money info err: ", err) + return false + } + + return true +} + +func GetAnyMoneyByName(name string) *AnyMoney { + o := orm.NewOrm() + anyMoney := new(AnyMoney) + if _, err := o.QueryTable(ANYMONEY).Filter("template_name", name).Limit(1).All(anyMoney); err != nil { + logs.Error("get any money err:", err) + } + return anyMoney +} + +func DeleteAnyMoney(templateName string) bool { + o := orm.NewOrm() + _, err := o.QueryTable(ANYMONEY).Filter("template_name", templateName).Delete() + if err != nil { + logs.Error("delete any money err:", err) + return false + } + + return true +} + +func UpdateAnyMoney(anyMoney *AnyMoney) bool { + o := orm.NewOrm() + if _, err := o.Update(anyMoney); err != nil { + logs.Error("update any money err: ", err) + return false + } + + return true +} diff --git a/legend/models/legend/legendFixMoneyDao.go b/legend/models/legend/legendFixMoneyDao.go new file mode 100644 index 0000000..c1e3544 --- /dev/null +++ b/legend/models/legend/legendFixMoneyDao.go @@ -0,0 +1,84 @@ +package legend + +import ( + "github.com/beego/beego/v2/client/orm" + "github.com/beego/beego/v2/core/logs" +) + +type FixMoney struct { + Id int `orm:"pk;column(id)"` + Uid string + TemplateName string + Price float64 + GoodsName string + GoodsNo string + BuyTimes int + UpdateTime string + CreateTime string +} + +const FIXMONEY = "legend_fix_money" + +func (c *FixMoney) TableName() string { + return FIXMONEY +} + +func InsertFixMoney(fixMoney *FixMoney) bool { + o := orm.NewOrm() + if _, err := o.Insert(fixMoney); err != nil { + logs.Error("insert fix money err: ", err) + return false + } + + return true +} + +func GetFixMoneyByName(name string) []FixMoney { + o := orm.NewOrm() + var fixMoneys []FixMoney + if _, err := o.QueryTable(FIXMONEY).Filter("template_name", name).Limit(-1).All(&fixMoneys); err != nil { + logs.Error("get fix money err:", err) + } + + return fixMoneys +} + +func GetFixMoneyByUid(uid string) *FixMoney { + o := orm.NewOrm() + fixMoney := new(FixMoney) + if _, err := o.QueryTable(FIXMONEY).Filter("uid", uid).Limit(1).All(fixMoney); err != nil { + logs.Error("get fix Money by uid err:", err) + } + + return fixMoney +} + +func DeleteFixMoney(templateName string) bool { + o := orm.NewOrm() + if _, err := o.QueryTable(FIXMONEY).Filter("template_name", templateName).Delete(); err != nil { + logs.Error("delete fix money err:", err) + return false + } + + return true +} + +func DeleteFixMoneyByUid(uid string) bool { + o := orm.NewOrm() + if _, err := o.QueryTable(FIXMONEY).Filter("uid", uid).Delete(); err != nil { + logs.Error("delete fix money err:", err) + return false + } + + return true +} + +func UpdateFixMoney(fixMoney *FixMoney) bool { + o := orm.NewOrm() + if _, err := o.Update(fixMoney); err != nil { + logs.Error("update fix money err: ", err) + return false + } + + return true +} diff --git a/legend/models/legend/legendFixPresentDao.go b/legend/models/legend/legendFixPresentDao.go new file mode 100644 index 0000000..9ce5237 --- /dev/null +++ b/legend/models/legend/legendFixPresentDao.go @@ -0,0 +1,82 @@ +package legend + +import ( + "github.com/beego/beego/v2/client/orm" + "github.com/beego/beego/v2/core/logs" +) + +type FixPresent struct { + Id int `orm:"pk;column(id)"` + Uid string + TemplateName string + Money float64 + PresentMoney float64 + UpdateTime string + CreateTime string +} + +const FIXPRESENT = "legend_fix_present" + +func (c *FixPresent) TableName() string { + return FIXPRESENT +} + +func InsertFixPresent(fixPresnet *FixPresent) bool { + o := orm.NewOrm() + if _, err := o.Insert(fixPresnet); err != nil { + logs.Error("insert fix present err:", err) + return false + } + + return true +} + +func GetFixPresentsByName(name string) []FixPresent { + o := orm.NewOrm() + var fixPresents []FixPresent + if _, err := o.QueryTable(FIXPRESENT).Filter("template_name", name).Limit(-1).All(&fixPresents); err != nil { + logs.Error("get fix presents err:", err) + } + + return fixPresents +} + +func GetFixPresentByUid(uid string) *FixPresent { + o := orm.NewOrm() + fixPresent := new(FixPresent) + if _, err := o.QueryTable(FIXPRESENT).Filter("uid", uid).Limit(1).All(fixPresent); err != nil { + logs.Error("get fix present err:", err) + } + + return fixPresent +} + +func DeleteFixPresent(templateName string) bool { + o := orm.NewOrm() + if _, err := o.QueryTable(FIXPRESENT).Filter("template_name", templateName).Delete(); err != nil { + logs.Error("delete fix present err: ", err) + return false + } + + return true +} + +func DeleteFixPresentByUid(uid string) bool { + o := orm.NewOrm() + if _, err := o.QueryTable(FIXPRESENT).Filter("uid", uid).Delete(); err != nil { + logs.Error("delete fix present by uid err:", err) + return false + } + + return true +} + +func UpdatePresentFixMoney(present *FixPresent) bool { + o := orm.NewOrm() + if _, err := o.Update(present); err != nil { + logs.Error("update fix present err: ", err) + return false + } + + return true +} diff --git a/legend/models/legend/legendGroup.go b/legend/models/legend/legendGroup.go new file mode 100644 index 0000000..2b0da2f --- /dev/null +++ b/legend/models/legend/legendGroup.go @@ -0,0 +1,30 @@ +package legend + +import ( + "github.com/beego/beego/v2/client/orm" + "github.com/beego/beego/v2/core/logs" +) + +type Group struct { + Id int `orm:"pk;column(id)"` + GroupName string + Uid string + UpdateTime string + CreateTime string +} + +const GROUP = "legend_group" + +func (c *Group) TableName() string { + return GROUP +} + +func InsertGroup(group *Group) bool { + o := orm.NewOrm() + if _, err := o.Insert(group); err != nil { + logs.Error("insert group err:", err) + return false + } + + return true +} diff --git a/legend/models/legend/legendScalePresentDao.go b/legend/models/legend/legendScalePresentDao.go new file mode 100644 index 0000000..23b8dae --- /dev/null +++ b/legend/models/legend/legendScalePresentDao.go @@ -0,0 +1,82 @@ +package legend + +import ( + "github.com/beego/beego/v2/client/orm" + "github.com/beego/beego/v2/core/logs" +) + +type ScalePresent struct { + Id int `orm:"pk;column(id)"` + Uid string + TemplateName string + Money float64 + PresentScale float64 + UpdateTime string + CreateTime string +} + +const SCALEPRESENT = "legend_scale_present" + +func (c *ScalePresent) TableName() string { + return SCALEPRESENT +} + +func InsertScalePresent(scalePresent *ScalePresent) bool { + o := orm.NewOrm() + if _, err := o.Insert(scalePresent); err != nil { + logs.Error("insert scale present err:", err) + return false + } + + return true +} + +func GetScalePresentsByName(name string) []ScalePresent { + o := orm.NewOrm() + var scalePresents []ScalePresent + if _, err := o.QueryTable(SCALEPRESENT).Filter("template_name", name).Limit(-1).All(&scalePresents); err != nil { + logs.Error("get scale present err:", err) + } + + return scalePresents +} + +func GetScalePresentByUid(uid string) *ScalePresent { + o := orm.NewOrm() + scalePresent := new(ScalePresent) + if _, err := o.QueryTable(SCALEPRESENT).Filter("uid", uid).Limit(1).All(scalePresent); err != nil { + logs.Error("get scale present err:", err) + } + + return scalePresent +} + +func DeleteScalePresent(templateName string) bool { + o := orm.NewOrm() + if _, err := o.QueryTable(SCALEPRESENT).Filter("template_name", templateName).Delete(); err != nil { + logs.Error("delete scale present err:", err) + return false + } + + return true +} + +func DeleteScalePresentByUid(uid string) bool { + o := orm.NewOrm() + if _, err := o.QueryTable(SCALEPRESENT).Filter("uid", uid).Delete(); err != nil { + logs.Error("delete scale present by uid err:", err) + return false + } + + return true +} + +func UpdateScalePresent(present *ScalePresent) bool { + o := orm.NewOrm() + if _, err := o.Update(present); err != nil { + logs.Error("update scale present err: ", err) + return false + } + + return true +} diff --git a/legend/models/legend/legendScaleTempleteDao.go b/legend/models/legend/legendScaleTempleteDao.go new file mode 100644 index 0000000..b8e4cf8 --- /dev/null +++ b/legend/models/legend/legendScaleTempleteDao.go @@ -0,0 +1,101 @@ +package legend + +import ( + "github.com/beego/beego/v2/client/orm" + "github.com/beego/beego/v2/core/logs" +) + +type ScaleTemplate struct { + Id int `orm:"pk;column(id)"` + MerchantUid string + TemplateName string + UserUid string + UserWarn string + MoneyType string + PresentType string + UpdateTime string + CreateTime string +} + +const SCALETMPLETE = "legend_scale_template" + +func (c *ScaleTemplate) TableName() string { + return SCALETMPLETE +} + +func InsertScaleTemplate(scaleTemplate *ScaleTemplate) bool { + o := orm.NewOrm() + + if _, err := o.Insert(scaleTemplate); err != nil { + logs.Error("insert scale template err: ", err) + return false + } + + return true +} + +func IsExistsScaleTemplateByName(name string) bool { + o := orm.NewOrm() + return o.QueryTable(SCALETMPLETE).Filter("template_name", name).Exist() +} + +func GetScaleTemplateList(offset, limit int) []ScaleTemplate { + o := orm.NewOrm() + + var scaleTemplates []ScaleTemplate + if _, err := o.QueryTable(SCALETMPLETE).Limit(limit, offset).OrderBy("-create_time").All(&scaleTemplates); err != nil { + logs.Error("get scale template list err : ", err) + } + + return scaleTemplates +} + +func GetScaleTemplateAll() int { + o := orm.NewOrm() + count, err := o.QueryTable(SCALETMPLETE).Count() + if err != nil { + logs.Error("get scale template all err:", err) + } + return int(count) +} + +func GetScaleTemplateByName(name string) *ScaleTemplate { + o := orm.NewOrm() + scaleTemplate := new(ScaleTemplate) + if _, err := o.QueryTable(SCALETMPLETE).Filter("template_name", name).Limit(1).All(scaleTemplate); err != nil { + logs.Error("get scale template by name err:", err) + } + + return scaleTemplate +} + +func GetScaleTemplateByNameAndMerchantUid(name, merchantUid string) *ScaleTemplate { + o := orm.NewOrm() + scaleTemplate := new(ScaleTemplate) + if _, err := o.QueryTable(SCALETMPLETE).Filter("template_name", name). + Filter("merchant_uid", merchantUid).Limit(1).All(scaleTemplate); err != nil { + logs.Error("get scale template by name and merchantUid err:", err) + } + + return scaleTemplate +} + +func DeleteScaleTemplate(templateName string) bool { + o := orm.NewOrm() + if _, err := o.QueryTable(SCALETMPLETE).Filter("template_name", templateName).Delete(); err != nil { + logs.Error("delete template err:", err) + return false + } + + return true +} + +func UpdateScaleTemplate(template *ScaleTemplate) bool { + o := orm.NewOrm() + if _, err := o.Update(template); err != nil { + logs.Error("update scale template err: ", err) + return false + } + + return true +} diff --git a/legend/routers/router.go b/legend/routers/router.go index 8de2956..e1aaef8 100644 --- a/legend/routers/router.go +++ b/legend/routers/router.go @@ -23,8 +23,9 @@ func pageInit() { web.Router("/welcome.html", &controllers.ShowPageController{}, "*:WelcomePage") web.Router("/merchantKey.html", &controllers.ShowPageController{}, "*:MerchantKeyPage") web.Router("/orderList.html", &controllers.ShowPageController{}, "*:OrderListPage") - web.Router("/scaleTemplete.html", &controllers.ShowPageController{}, "*:ScaleTempletePage") - web.Router("/templeteAdd.html", &controllers.ShowPageController{}, "*:TempleteAdd") + web.Router("/scaleTemplate.html", &controllers.ShowPageController{}, "*:ScaleTemplatePage") + web.Router("/templateAdd.html", &controllers.ShowPageController{}, "*:TemplateAdd") + web.Router("/templateEdit.html", &controllers.ShowPageController{}, "*:TemplateEdit") web.Router("/groupList.html", &controllers.ShowPageController{}, "*:GroupListPage") web.Router("/areaList.html", &controllers.ShowPageController{}, "*:AreaListPage") web.Router("/imitateOrder.html", &controllers.ShowPageController{}, "*:ImitateChargePage") @@ -44,5 +45,9 @@ func logicInit() { web.Router("/logout.html", &controllers.LogoutController{}, "*:Logout") web.Router("/switch/login", &controllers.LogoutController{}, "*:SwitchLogin") web.Router("/person/password", &controllers.LoginController{}, "*:PersonPassword") + web.Router("/add/template", &controllers.TemplateController{}, "*:TemplateAdd") + web.Router("/template/list", &controllers.TemplateController{}, "*:TemplateList") + web.Router("/delete/template", &controllers.TemplateController{}, "*:TemplateDelete") + web.Router("/template/info", &controllers.TemplateController{}, "*:TemplateAllInfo") web.InsertFilter("/*", web.BeforeRouter, filter.LoginFilter) } diff --git a/legend/service/accountService.go b/legend/service/accountService.go index 1751fc7..fd6a876 100644 --- a/legend/service/accountService.go +++ b/legend/service/accountService.go @@ -2,6 +2,7 @@ package service import ( "legend/models/fast" + "legend/utils" ) type AccountService struct { @@ -16,3 +17,15 @@ func (c *AccountService) GetAccountInfo(userName string) *fast.AccountInfo { return accountInfo } + +/** +** 获取当天的充值金额 + */ +func (c *AccountService) GetTodayIncome() float64 { + startTime := utils.GetNowDate() + " 00:00:00" + endTime := utils.GetNowDate() + " 23:59:59" + + todayIncome := fast.GetRangeDateIncome(startTime, endTime) + + return todayIncome +} diff --git a/legend/service/merchantService.go b/legend/service/merchantService.go index a419b01..cc12b3c 100644 --- a/legend/service/merchantService.go +++ b/legend/service/merchantService.go @@ -1,7 +1,7 @@ package service import ( - "github.com/astaxie/beego/logs" + "github.com/beego/beego/v2/core/logs" "legend/models/fast" ) @@ -9,19 +9,18 @@ type MerchantService struct { BaseService } -func (c *MerchantService) GetMerchantBankInfo(mobile string) (*fast.MerchantInfo, *fast.RpUserBankAccount, *fast.RpUserPayConfig) { +func (c *MerchantService) GetMerchantBankInfo(mobile string) (*fast.MerchantInfo, *fast.BankCardInfo) { - userInfo := fast.GetMerchantInfoByUserName(mobile) - bankInfo := fast.GetBankInfoByUserNo(userInfo.LoginAccount) - userPayConfig := fast.GetUserPayConfigByUserNo(userInfo.LoginAccount) + merchantInfo := fast.GetMerchantInfoByUserName(mobile) + bankInfo := fast.GetBankCardInfoByUserNo(merchantInfo.MerchantUid) - return userInfo, bankInfo, userPayConfig + return merchantInfo, bankInfo } /** ** 获取商户的密钥等信息 */ -func (c *MerchantService) UserPayConfig(userName string) map[string]string { +/*func (c *MerchantService) UserPayConfig(userName string) map[string]string { merchantMapData := make(map[string]string) @@ -39,7 +38,7 @@ func (c *MerchantService) UserPayConfig(userName string) map[string]string { } return merchantMapData -} +}*/ /** ** 获取商户信息 diff --git a/legend/service/templeteService.go b/legend/service/templeteService.go new file mode 100644 index 0000000..ca9deab --- /dev/null +++ b/legend/service/templeteService.go @@ -0,0 +1,516 @@ +package service + +import ( + "fmt" + "github.com/beego/beego/v2/core/logs" + "legend/models/legend" + "legend/request" + "legend/response" + "legend/utils" +) + +type TemplateService struct { + BaseService +} + +/** +** 添加比例模板 + */ +func (c *TemplateService) AddTemplate(req *request.AddTemplateReq, merchantUid string) *response.AddTemplateResp { + + template := new(legend.ScaleTemplate) + template.MerchantUid = merchantUid + template.TemplateName = req.ScaleTemplateName + template.UserUid = req.ScaleUserName + template.UserWarn = req.ScaleUserNamePoint + template.MoneyType = req.MoneyType + template.PresentType = req.PresentType + template.UpdateTime = utils.GetNowTime() + template.CreateTime = utils.GetNowTime() + + addTemplateResp := new(response.AddTemplateResp) + addTemplateResp.Code = -1 + + if template.TemplateName == "" { + addTemplateResp.Msg = "模板名称不能为空" + return addTemplateResp + } + + if legend.IsExistsScaleTemplateByName(template.TemplateName) { + addTemplateResp.Msg = "模板名称重复,请换一个名称!" + return addTemplateResp + } + + if legend.InsertScaleTemplate(template) { + addTemplateResp.Code = 0 + addTemplateResp.Msg = "添加比例模板成功" + if !c.AddRandMoney(req) { + addTemplateResp.Code = -1 + addTemplateResp.Msg = "随机金额添加失败,请检查参数是否合理" + } + if !c.AddFixMoney(req) { + addTemplateResp.Code = -1 + addTemplateResp.Msg = "添加固定金额失败,请检查参数是否合理" + } + if !c.AddPresentFixMoney(req) { + addTemplateResp.Code = -1 + addTemplateResp.Msg = "添加固定金额赠送失败,请检查参数是否合理" + } + if !c.AddPresentScaleMoney(req) { + addTemplateResp.Code = -1 + addTemplateResp.Msg = "添加金额比例赠送失败,请检查参数是否合理" + } + + // 只要有一个添加失败,全部删除 + if addTemplateResp.Code == -1 { + legend.DeleteScaleTemplate(template.TemplateName) + legend.DeleteAnyMoney(template.TemplateName) + legend.DeleteFixMoney(template.TemplateName) + legend.DeleteFixPresent(template.TemplateName) + legend.DeleteScalePresent(template.TemplateName) + } + } else { + addTemplateResp.Msg = "添加比例模板失败" + } + + return addTemplateResp +} + +/** +** 编辑比例模板逻辑 + */ +func (c *TemplateService) UpdateTemplate(req *request.AddTemplateReq, merchantUid string) *response.BaseResp { + resp := new(response.BaseResp) + resp.Code = -1 + resp.Msg = "更新失败" + + template := legend.GetScaleTemplateByNameAndMerchantUid(req.ScaleTemplateName, merchantUid) + template.UserUid = req.ScaleUserName + template.UserWarn = req.ScaleUserNamePoint + template.MoneyType = req.MoneyType + template.PresentType = req.PresentType + template.UpdateTime = utils.GetNowTime() + + if !legend.UpdateScaleTemplate(template) { + logs.Error("更新比例模板基础数据失败") + return resp + } + + if !c.updateAnyMoney(req) { + logs.Error("更新任意金额数据失败") + return resp + } + + if !c.updateFixMoney(req) { + logs.Error("更新固定金额数据失败") + return resp + } + + if !c.updateFixPresent(req) { + logs.Error("更新赠送固定金额失败") + return resp + } + + if !c.updateScalePresent(req) { + logs.Error("更新赠送比例数据失败") + return resp + } + + resp.Code = 0 + resp.Msg = "更新成功" + + return resp + +} + +/** +** 更新任意金额 + */ +func (c *TemplateService) updateAnyMoney(req *request.AddTemplateReq) bool { + if req.GameMoneyScale <= 0 && req.LimitLowMoney <= 0 { + logs.Debug("任意金额的2个关键参数均小于等于0") + anyMoney := legend.GetAnyMoneyByName(req.ScaleTemplateName) + if anyMoney != nil && anyMoney.TemplateName != "" { + return legend.DeleteAnyMoney(req.ScaleTemplateName) + } else { + logs.Error("不存在这样的任意金额") + return false + } + } else { + anyMoney := legend.GetAnyMoneyByName(req.ScaleTemplateName) + anyMoney.GameMoneyScale = req.GameMoneyScale + anyMoney.GameMoneyName = req.GameMoneyName + anyMoney.LimitLow = req.LimitLowMoney + anyMoney.UpdateTime = utils.GetNowTime() + anyMoney.CreateTime = utils.GetNowTime() + + return legend.UpdateAnyMoney(anyMoney) + } + +} + +/** +** 更新固定金额 + */ +func (c *TemplateService) updateFixMoney(req *request.AddTemplateReq) bool { + + for _, fixMoney := range legend.GetFixMoneyByName(req.ScaleTemplateName) { + if !c.isExist(fixMoney.Uid, req.FixUids) { + // 假如不存在了,那么需要删除这条记录 + legend.DeleteFixMoneyByUid(fixMoney.Uid) + } + } + + for i, _ := range req.FixUids { + if req.FixUids[i] == "" { + continue + } + + fixMoney := legend.GetFixMoneyByUid(req.FixUids[i]) + + fixMoney.UpdateTime = utils.GetNowTime() + fixMoney.Uid = req.FixUids[i] + fixMoney.Price = req.FixPrices[i] + fixMoney.GoodsName = req.GoodsNames[i] + fixMoney.GoodsNo = req.GoodsNos[i] + fixMoney.BuyTimes = req.Limits[i] + + if fixMoney.TemplateName == "" { + fixMoney.CreateTime = utils.GetNowTime() + fixMoney.TemplateName = req.ScaleTemplateName + legend.InsertFixMoney(fixMoney) + } else { + legend.UpdateFixMoney(fixMoney) + } + + } + + return true +} + +/** +** 更新固定金额赠送参数 + */ +func (c *TemplateService) updateFixPresent(req *request.AddTemplateReq) bool { + + for _, fixPresentMoney := range legend.GetFixPresentsByName(req.ScaleTemplateName) { + if !c.isExist(fixPresentMoney.Uid, req.PresentFixUids) { + legend.DeleteFixPresentByUid(fixPresentMoney.Uid) + } + } + + for i, _ := range req.PresentFixUids { + if req.PresentFixUids[i] == "" { + continue + } + + fixPresent := legend.GetFixPresentByUid(req.PresentFixUids[i]) + + fixPresent.UpdateTime = utils.GetNowTime() + fixPresent.Uid = req.PresentFixUids[i] + fixPresent.Money = req.PresentFixMoneys[i] + fixPresent.PresentMoney = req.PresentFixPresentMoneys[i] + + if fixPresent.TemplateName == "" { + fixPresent.CreateTime = utils.GetNowTime() + fixPresent.TemplateName = req.ScaleTemplateName + legend.InsertFixPresent(fixPresent) + } else { + legend.UpdatePresentFixMoney(fixPresent) + } + } + + return true +} + +/** +** 更新比例赠送参数 + */ +func (c *TemplateService) updateScalePresent(req *request.AddTemplateReq) bool { + + for _, scalePresent := range legend.GetScalePresentsByName(req.ScaleTemplateName) { + if !c.isExist(scalePresent.Uid, req.PresentScaleUids) { + legend.DeleteScalePresentByUid(scalePresent.Uid) + } + } + + for i, _ := range req.PresentScaleUids { + if req.PresentScaleUids[i] == "" { + continue + } + + scalePresent := legend.GetScalePresentByUid(req.PresentScaleUids[i]) + + scalePresent.UpdateTime = utils.GetNowTime() + scalePresent.Uid = req.PresentScaleUids[i] + scalePresent.Money = req.PresentScaleMoneys[i] + scalePresent.PresentScale = req.PresentScales[i] + + if scalePresent.TemplateName == "" { + scalePresent.TemplateName = req.ScaleTemplateName + scalePresent.CreateTime = utils.GetNowTime() + legend.InsertScalePresent(scalePresent) + } else { + legend.UpdateScalePresent(scalePresent) + } + } + return true +} + +func (c *TemplateService) isExist(j string, ss []string) bool { + for _, s := range ss { + if s == j { + return true + } + } + + return false +} + +/** +** 添加随机金额 + */ +func (c *TemplateService) AddRandMoney(req *request.AddTemplateReq) bool { + + if req.LimitLowMoney < 0 { + logs.Error("随机金额中的最低充值金额不能小于0") + return false + } + if req.GameMoneyName == "" && req.GameMoneyScale <= 0 { + logs.Info("不需要添加随机金额选项") + return true + } + + anyMoney := new(legend.AnyMoney) + anyMoney.TemplateName = req.ScaleTemplateName + anyMoney.GameMoneyName = req.GameMoneyName + anyMoney.GameMoneyScale = req.GameMoneyScale + anyMoney.LimitLow = req.LimitLowMoney + anyMoney.UpdateTime = utils.GetNowTime() + anyMoney.CreateTime = utils.GetNowTime() + + if legend.InsertAnyMoney(anyMoney) { + logs.Info("添加随机金额成功!") + } else { + return false + } + return true +} + +/** +**添加固定金额 + */ +func (c *TemplateService) AddFixMoney(req *request.AddTemplateReq) bool { + + l := len(req.FixUids) + + if l == 0 || (l == 1 && req.FixUids[0] == "") { + logs.Error("该模板没有添加固定金额选项") + return true + } + + if l != len(req.GoodsNames) || l != len(req.FixPrices) || l != len(req.GoodsNos) || l != len(req.Limits) { + logs.Error("固定金额参数有误,长度不一致") + return false + } + + for i := 0; i < l; i++ { + fixUid := req.FixUids[i] + fixPrice := req.FixPrices[i] + goodName := req.GoodsNames[i] + goodNo := req.GoodsNos[i] + limit := req.Limits[i] + + if fixUid == "0" && fixPrice <= 0 && goodName == "0" && goodNo == "0" && limit <= 0 { + logs.Error("固定金额4个参数都为空!") + continue + } + + if fixUid == "0" || fixPrice <= 0 || goodName == "0" || goodNo == "0" || limit <= 0 { + logs.Error("固定金额参数中有一个缺失: ", fmt.Sprintf("fixUid = %s, fixPrice = %f, goodName = %s, goodNo = %s, limit = %d", + fixUid, fixPrice, goodName, goodNo, limit)) + return false + } + + fixMoney := new(legend.FixMoney) + fixMoney.Uid = fixUid + fixMoney.TemplateName = req.ScaleTemplateName + fixMoney.Price = fixPrice + fixMoney.GoodsName = goodName + fixMoney.GoodsNo = goodNo + fixMoney.BuyTimes = limit + fixMoney.UpdateTime = utils.GetNowTime() + fixMoney.CreateTime = utils.GetNowTime() + + if !legend.InsertFixMoney(fixMoney) { + logs.Error("该次固定金额插入数据库失败") + } + + } + return true +} + +/** +** 添加赠送固定金额赠送 + */ +func (c *TemplateService) AddPresentFixMoney(req *request.AddTemplateReq) bool { + + l := len(req.PresentFixUids) + if l == 0 || (l == 1 && req.PresentScaleUids[0] == "") { + logs.Error("该模板没有添加固定金额赠送选项") + return true + } + + if l != len(req.PresentFixMoneys) || l != len(req.PresentFixPresentMoneys) { + logs.Error("固定金额赠送选项参数个数不一致") + return false + } + + for i := 0; i < l; i++ { + uid := req.PresentFixUids[i] + fixMoney := req.PresentFixMoneys[i] + presentMoney := req.PresentFixPresentMoneys[i] + + if uid == "0" && fixMoney <= 0 && presentMoney <= 0 { + continue + + } + + if uid == "0" || fixMoney <= 0 || presentMoney <= 0 { + logs.Error("固定金额参数中有一个缺失: ", fmt.Sprintf("fixUid = %s, fixPrice = %f, presentMoney = %f", + uid, fixMoney, presentMoney)) + return false + + } + + fixPresent := new(legend.FixPresent) + fixPresent.Uid = uid + fixPresent.TemplateName = req.ScaleTemplateName + fixPresent.Money = fixMoney + fixPresent.PresentMoney = presentMoney + fixPresent.UpdateTime = utils.GetNowTime() + fixPresent.CreateTime = utils.GetNowTime() + + if !legend.InsertFixPresent(fixPresent) { + logs.Error("该次固定金额赠送插入数据库失败") + } + } + return true +} + +/** +** 添加赠送金额比例 + */ +func (c *TemplateService) AddPresentScaleMoney(req *request.AddTemplateReq) bool { + l := len(req.PresentScaleUids) + if l == 0 || (l == 1 && req.PresentScaleUids[0] == "") { + logs.Error("该模板没有添加按百分比赠送") + return true + } + + if l != len(req.PresentScaleMoneys) || l != len(req.PresentScales) { + logs.Error("按百分比赠送选项参数个数不一致") + return false + } + + for i := 0; i < l; i++ { + uid := req.PresentScaleUids[i] + money := req.PresentScaleMoneys[i] + scale := req.PresentScales[i] + + if money <= 0 { + logs.Error("金额不能等于0") + return false + } + + if uid == "0" && money <= 0 && scale <= 0 { + continue + } + + if uid == "0" || money <= 0 || scale <= 0 { + logs.Error("百分比赠送缺失参数: ", fmt.Sprintf("uid = %s, money = %f, scale = %f", + uid, money, scale)) + + return false + + } + + scalePresent := new(legend.ScalePresent) + scalePresent.Uid = uid + scalePresent.TemplateName = req.ScaleTemplateName + scalePresent.Money = money + scalePresent.PresentScale = scale + scalePresent.UpdateTime = utils.GetNowTime() + scalePresent.CreateTime = utils.GetNowTime() + + if !legend.InsertScalePresent(scalePresent) { + logs.Error("该次固定金额赠送插入数据库失败") + } + } + return true +} + +func (c *TemplateService) GetTemplateList(page, limit int) *response.TemplateListResp { + + offset := utils.CountOffset(page, limit) + count := legend.GetScaleTemplateAll() + scaleTemplates := legend.GetScaleTemplateList(offset, limit) + + for i, _ := range scaleTemplates { + scaleTemplates[i].Id = offset + i + 1 + } + + templateListResp := new(response.TemplateListResp) + templateListResp.Count = count + templateListResp.Code = 0 + templateListResp.Data = scaleTemplates + + return templateListResp +} + +/** +** 删除比例模板的所有内容 + */ +func (c *TemplateService) DeleteTemplate(templateName string) *response.BaseResp { + + baseResp := new(response.BaseResp) + baseResp.Code = -1 + + b := true + if !legend.DeleteScaleTemplate(templateName) { + b = false + } + if !legend.DeleteAnyMoney(templateName) { + b = false + } + if !legend.DeleteFixMoney(templateName) { + b = false + } + if !legend.DeleteFixPresent(templateName) { + b = false + } + if !legend.DeleteFixPresent(templateName) { + b = false + } + + if b { + baseResp.Msg = "删除成功" + baseResp.Code = 0 + } else { + baseResp.Msg = "删除失败" + } + + return baseResp +} + +func (c *TemplateService) AllTemplateInfo(templateName string) *response.TemplateAllInfoResp { + + templateAllInfo := new(response.TemplateAllInfoResp) + templateAllInfo.TemplateInfo = legend.GetScaleTemplateByName(templateName) + templateAllInfo.AnyMoneyInfo = legend.GetAnyMoneyByName(templateName) + templateAllInfo.FixMoneyInfos = legend.GetFixMoneyByName(templateName) + templateAllInfo.PresentFixMoneyInfos = legend.GetFixPresentsByName(templateName) + templateAllInfo.PresentScaleMoneyInfos = legend.GetScalePresentsByName(templateName) + + return templateAllInfo +} diff --git a/legend/static/data/area.json b/legend/static/data/area.json index 6054d33..c7d378f 100644 --- a/legend/static/data/area.json +++ b/legend/static/data/area.json @@ -1,11 +1,12 @@ { - "code":0,"msg":"", + "code":0, + "msg":"", "count":10, "data":[ { "id": 1, "areaname": "狗日的1-2区", - "usetemplete": "狗日", + "usetemplate": "狗日", "currencyname": "元宝", "rechargescale": 10, "areastatus": "开放", @@ -14,7 +15,7 @@ { "id": 2, "areaname": "猪日1-2区", - "usetemplete": "猪日", + "usetemplate": "猪日", "currencyname": "元宝", "rechargescale": 10, "areastatus": "开放", @@ -23,7 +24,7 @@ { "id": 3, "areaname": "牛日1-2区", - "usetemplete": "牛日", + "usetemplate": "牛日", "currencyname": "元宝", "rechargescale": 10, "areastatus": "开放", @@ -32,7 +33,7 @@ { "id": 4, "areaname": "鸡日1-2区", - "usetemplete": "鸡日", + "usetemplate": "鸡日", "currencyname": "元宝", "rechargescale": 10, "areastatus": "开放", @@ -41,7 +42,7 @@ { "id": 5, "areaname": "鸭日1-2区", - "usetemplete": "鸭日", + "usetemplate": "鸭日", "currencyname": "元宝", "rechargescale": 10, "areastatus": "开放", @@ -50,7 +51,7 @@ { "id": 6, "areaname": "蚯蚓1-2区", - "usetemplete": "蚯蚓日", + "usetemplate": "蚯蚓日", "currencyname": "元宝", "rechargescale": 10, "areastatus": "开放", @@ -59,7 +60,7 @@ { "id": 7, "areaname": "蛇日1-2区", - "usetemplete": "蛇日", + "usetemplate": "蛇日", "currencyname": "元宝", "rechargescale": 10, "areastatus": "开放", @@ -68,7 +69,7 @@ { "id": 8, "areaname": "人日1-2区", - "usetemplete": "人日", + "usetemplate": "人日", "currencyname": "元宝", "rechargescale": 10, "areastatus": "开放", @@ -77,7 +78,7 @@ { "id": 9, "areaname": "苍蝇1-2区", - "usetemplete": "苍蝇日", + "usetemplate": "苍蝇日", "currencyname": "元宝", "rechargescale": 10, "areastatus": "开放", @@ -86,7 +87,7 @@ { "id": 10, "areaname": "蚊子1-2区", - "usetemplete": "蚊子日", + "usetemplate": "蚊子日", "currencyname": "元宝", "rechargescale": 10, "areastatus": "开放", diff --git a/legend/utils/strongToFloat.go b/legend/utils/strongToFloat.go new file mode 100644 index 0000000..26fad99 --- /dev/null +++ b/legend/utils/strongToFloat.go @@ -0,0 +1,47 @@ +package utils + +import ( + "github.com/beego/beego/v2/core/logs" + "strconv" + "strings" +) + +func StringToFloats(s string) []float64 { + + fs := make([]float64, 0) + if s == "" || len(s) == 0 { + return fs + } + str := strings.Split(s, ",") + for i := 0; i < len(str); i++ { + s := str[i] + logs.Debug("string to float:", s) + if f, err := strconv.ParseFloat(s, 64); err != nil { + logs.Error("string to float64 err:", err) + fs = append(fs, 0) + } else { + fs = append(fs, f) + } + } + + return fs +} + +func StringToInt(s string) []int { + is := make([]int, 0) + if s == "" || len(s) == 0 { + return is + } + + ss := strings.Split(s, ",") + for i := 0; i < len(ss); i++ { + if a, err := strconv.Atoi(ss[i]); err != nil { + logs.Error("string to int err:", err) + is = append(is, 0) + } else { + is = append(is, a) + } + } + + return is +} diff --git a/legend/utils/tableTool.go b/legend/utils/tableTool.go new file mode 100644 index 0000000..9226cb6 --- /dev/null +++ b/legend/utils/tableTool.go @@ -0,0 +1,12 @@ +package utils + +/** +** 计算偏移量 + */ +func CountOffset(page, limit int) int { + if page > 0 { + return (page - 1) * limit + } else { + return limit + } +} diff --git a/legend/views/area-add.html b/legend/views/area-add.html index a4565cb..7f79d82 100644 --- a/legend/views/area-add.html +++ b/legend/views/area-add.html @@ -56,7 +56,7 @@
- diff --git a/legend/views/area-list.html b/legend/views/area-list.html index 80c889b..86ff0a9 100644 --- a/legend/views/area-list.html +++ b/legend/views/area-list.html @@ -62,7 +62,7 @@ ,cols: [[ //表头 {field: 'id', title: 'ID', sort: true, fixed: 'left'} ,{field: 'areaname', title: '分区名称'} - ,{field: 'usetemplete', title: '使用模板', sort: true} + ,{field: 'usetemplate', title: '使用模板', sort: true} ,{field: 'currencyname', title: '货币名称', sort:false} ,{field: 'rechargescale', title: '充值比例', sort: true} ,{field: 'areastatus', title: '分区状态', sort: true} diff --git a/legend/views/index.html b/legend/views/index.html index 18c9b96..0e9a84f 100644 --- a/legend/views/index.html +++ b/legend/views/index.html @@ -66,7 +66,7 @@
  • - + 比例模板 diff --git a/legend/views/merchant-key.html b/legend/views/merchant-key.html index ea5c689..234f89a 100644 --- a/legend/views/merchant-key.html +++ b/legend/views/merchant-key.html @@ -33,36 +33,34 @@

    {{.userName}}

    商户账户号:

    - {{.userInfo.UserNo}} + {{.userInfo.MerchantUid}} +

    商户密钥:

    -

    {{.payConfigInfo.PaySecret}}

    +

    {{.userInfo.MerchantSecret}}

    商户KEY:

    -

    {{.payConfigInfo.PayKey}}

    +

    {{.userInfo.MerchantKey}}

    - -

    邮箱地址:

    -

    {{.userInfo.Email}}

    银行开户名:

    -

    {{.bankInfo.BankAccountName}}

    +

    {{.bankInfo.AccountName}}

    开户银行:

    {{.bankInfo.BankName}}

    银行卡号:

    -

    {{.bankInfo.BankAccountNo}}

    +

    {{.bankInfo.BankNo}}

    银行编码:

    {{.bankInfo.BankCode}}

    手机号码:

    -

    {{.userInfo.Mobile}}

    +

    {{.bankInfo.PhoneNo}}

  • diff --git a/legend/views/scale-templete.html b/legend/views/scale-template.html similarity index 59% rename from legend/views/scale-templete.html rename to legend/views/scale-template.html index 3a57f9e..ff29e08 100644 --- a/legend/views/scale-templete.html +++ b/legend/views/scale-template.html @@ -15,32 +15,27 @@ - - +
    -{{/*
    首页 / 比例模板
    */}}
    @@ -51,21 +46,17 @@ //第一个实例 table.render({ elem: '#demo' - ,height: 500 + ,height: 460 // ,width: 480 - ,url: '/static/data/json.json' //数据接口 + ,url: '/template/list' //数据接口 ,page: true //开启分页 ,limits: [10, 20, 30, 50, 100, 200] ,cols: [[ //表头 - {field: 'id', title: 'ID', sort: true, fixed: 'left'} - ,{field: 'username', title: '用户名', width:80} - ,{field: 'sex', title: '性别', sort: true} - ,{field: 'city', title: '城市'} - ,{field: 'sign', title: '签名'} - ,{field: 'experience', title: '积分', sort: true} - ,{field: 'score', title: '评分', sort: true} - ,{field: 'classify', title: '职业'} - ,{field: 'wealth', title: '财富', sort: true} + {field: 'Id', title: 'ID', sort: true, fixed: 'left'} + ,{field: 'TemplateName', title: '模板名称'} + ,{field: 'UserUid', title: '用户标识'} + ,{field: 'UserWarn', title: '提醒标语'} + ,{field: 'CreateTime', title: '创建时间', sort: true} ,{fixed: 'right', title: "操作", width:180, align:'center', toolbar: '#toolbarDemo'} ]] ,toolbar: "#toolbarHead" @@ -75,8 +66,8 @@ table.on('toolbar(test)', function (obj) { let event = obj.event; // 头工具栏的监听事件 - if (event === "create-templete") { - location.href = "/templeteAdd.html"; + if (event === "create-template") { + location.href = "/templateAdd.html" } }); @@ -87,18 +78,37 @@ let event = obj.event; // 编辑行内容 - if (event === "edit-templete") { - layer.msg("编辑该行的内容"); + if (event === "edit-template") { + location.href = "/templateEdit.html?templateName=" + data.TemplateName; } // 删除该行 - if (event === "delete-templete") { + if (event === "delete-template") { layer.confirm("确定删除该行?", function (index) { - obj.del(); + $.ajax({ + url: "/delete/template", + data: { + "TemplateName": data.TemplateName + }, + success: function (res) { + console.log(res) + if (res.Code === 0) { + obj.del() + table.reload('demo', { + url: "/template/list" + }) + } else { + alert(res.Msg) + } + }, + error: function () { + alert("系统异常") + } + }) layer.close(index); }) } - }) + }); });
    diff --git a/legend/views/templete-add.html b/legend/views/template-add.html similarity index 61% rename from legend/views/templete-add.html rename to legend/views/template-add.html index 069af8e..5711166 100644 --- a/legend/views/templete-add.html +++ b/legend/views/template-add.html @@ -27,29 +27,31 @@
    配置模板
    -
    +

    基础配置

    +
    - +
    取名保证唯一性
    +
    - +
    可填写角色名、或者角色ID;不可为空
    - +
    此提示会在充值页面显示,提示玩家如何查看用户标识
    @@ -57,8 +59,8 @@
    - - + +
    @@ -68,7 +70,7 @@
    - +
    默认是元宝,也可以是钻石、点券
    @@ -76,7 +78,7 @@
    - +
    默认是100,既充值1元人命币转为100游戏币
    @@ -84,7 +86,7 @@
    - +
    默认最低为10元
    @@ -92,24 +94,6 @@
    -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    删除
    -
    -
    -
    添加商品
    @@ -126,58 +110,34 @@
    - - - + + +
    -
    - -
    - -
    -
    - -
    -
    -
    删除
    -
    -
    添加
    -
    - -
    - -
    -
    - -
    -
    -
    删除
    -
    -
    添加
    - +
    +
    +
    + +
    返回当前页
    -
    -
    - - -
    +
    @@ -186,9 +146,12 @@ // 动态添加固定金额赠送input框 function addPresentTypeMoneyStyle() { + let s = randomString(20) let str = '
    ' + - '
    ' + - '' + + '' + + '' + + '
    ' + + '' + '
    删除
    '; $("#present-type-money-child-style").append(str); @@ -196,9 +159,11 @@ // 动态添加按百分比赠送input框 function addPresentTypeScaleStyle() { + let s = randomString(20) let str = '
    ' + - '' + - '
    ' + + '' + + '' + + '
    ' + '
    删除
    '; $("#present-type-scale-child-style").append(str); @@ -206,19 +171,22 @@ // 动态添加固定金额的input输入框 function addFixedMoenyStyle() { + let s = randomString(20) let str = '
    ' + '
    ' + - '' + + '' + + '' + '
    ' + - '' + + '' + '
    ' + - '' + - '
    ' + + '' + + '
    ' + '
    ' + '
    删除
    '; $("#fixed-money-child-style").append(str); + // $(".fix-uid").val(randomString(20)) } // 删除固金额input @@ -228,14 +196,16 @@ layui.use(['form', 'layer', 'element'], function() { - // 启动element木块 let element = layui.element; $ = layui.jquery; - var form = layui.form, + let form = layui.form, layer = layui.layer; // 进入该页面首先做的事情 $(document).ready(function () { - $("#fixed-money-style").toggle(); + // $("#fixed-money-style").toggle(); + $("#fixed-money-style").hide(); + $("#any-money-style").show(); + $("#present-type-money-style").hide(); $("#present-type-scale-style").hide(); }) @@ -264,7 +234,7 @@ } else if ("fixed-money-present" === radioValue) { $("#present-type-money-style").show(); $("#present-type-scale-style").hide(); - } else if ("fscale-present" === radioValue) { + } else if ("scale-present" === radioValue) { $("#present-type-money-style").hide(); $("#present-type-scale-style").show(); } @@ -273,39 +243,99 @@ // 监听金额类型的radio form.on('radio(money-type-filter)', function (data) { let value = data.value; - if ("any-monty" === value) { + if ("radio-any-money" === value) { //处理任何金额 - $("#any-money-style").toggle(); - $("#fixed-money-style").toggle(); + $("#any-money-style").show(); + $("#fixed-money-style").hide(); } else { // 处理固定金额 - $("#any-money-style").toggle(); - $("#fixed-money-style").toggle(); + $("#any-money-style").hide(); + $("#fixed-money-style").show(); } }) //监听提交 form.on('submit(add)', function(data) { - console.log(data); + + let jsonObj = {} + jsonObj.scaleTemplateName = data.field.scaleTemplateName + jsonObj.scaleUserName = data.field.scaleUserName + jsonObj.scaleUserNamePoint = data.field.scaleUserNamePoint + jsonObj.moneyType = data.field.moneyType + jsonObj.gameMoneyName = data.field.gameMoneyName + jsonObj.gameMoneyScale = data.field.gameMoneyScale + if (data.field.limitLowMoney === "" || data.field.limitLowMoney === null) { + jsonObj.limitLowMoney = "10" + } else { + jsonObj.limitLowMoney = data.field.limitLowMoney + } + jsonObj.presentType = data.field.presentType + jsonObj.fixPrices = getArrays(".fix-price") + jsonObj.goodsNames = getArrays(".fix-goods-name") + jsonObj.goodsNos = getArrays(".fix-goods-no") + jsonObj.limits = getArrays(".fix-limit-low") + jsonObj.presentFixMoneys = getArrays(".present-fix-money") + jsonObj.presentFixPresentMoneys = getArrays(".present-fix-present-money") + jsonObj.presentScaleMoneys =getArrays(".present-scale-money") + jsonObj.presentScales = getArrays(".present-scale") + jsonObj.fixUids = getArrays(".fix-uid") + jsonObj.presentScaleUids = getArrays(".present-scale-uid") + jsonObj.presentFixUids = getArrays(".present-fix-uid") + + console.log(JSON.stringify(jsonObj)) + //发异步,把数据提交给php - layer.alert("增加成功", { - icon: 6 - }, - function() { - // 获得frame索引 - var index = parent.layer.getFrameIndex(window.name); - //关闭当前frame - parent.layer.close(index); + $.ajax({ + url: "/add/template", + data: jsonObj, + + success: function (res) { + alert(res.Msg) + if (res.Code === 0) { + window.history.back(-1); + } + }, + error: function () { + layer.alert("系统异常") + } }); + return false; }); - form.on('submit(back)', - function () { - window.history.back(-1); - }); }); + + function getArrays(obj) { + + let arrays = [] + $(obj).each(function () { + let v = $(this).val(); + if (v === null || v.length <=0) { + arrays.push(0) + } else { + arrays.push(v) + } + }) + + return arrays.join(",") + } + + function back() { + window.history.back(-1); + } + + function randomString(n) { + let chars = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']; + let res = ""; + for(let i = 0; i < n ; i ++) { + let id = Math.ceil(Math.random()*35); + res += chars[id]; + } + return res; + } + + diff --git a/legend/views/template-edit.html b/legend/views/template-edit.html new file mode 100644 index 0000000..9e71200 --- /dev/null +++ b/legend/views/template-edit.html @@ -0,0 +1,484 @@ + + + + + + 充值商户后台 + + + + + + + + + + + + + + + +
    +
    +
    编辑模板
    +
    +
    +
    +
    +
    +

    基础配置

    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    可填写角色名、或者角色ID;不可为空
    +
    +
    + +
    + +
    +
    此提示会在充值页面显示,提示玩家如何查看用户标识
    +
    + +
    + +
    + + +
    +
    + + + +
    +
    + +
    + +
    +
    默认是元宝,也可以是钻石、点券
    +
    + +
    + +
    + +
    +
    默认是100,既充值1元人命币转为100游戏币
    +
    + +
    + +
    + +
    +
    默认最低为10元
    +
    +
    + + +
    +
    + +
    添加
    +

    说明:请根据游戏内设置的商品道具进行设置,切勿乱填

    可购次数填0代表不限,填1代表一个帐号仅可购买一次,依此类推

    +
    + +
    +
    + + +
    +

    激励赠送

    +
    +
    + +
    + + + +
    +
    + + +
    +
    +
    添加
    +
    + + +
    +
    +
    添加
    +
    +
    +
    +
    +
    +
    + +
    返回当前页
    +
    +
    +
    + +
    +
    +
    + + + + + \ No newline at end of file