Merge pull request 'test-kk' (#41) from test-kk into test

Reviewed-on: https://git.oa00.com/recook/backend_v2/pulls/41
master
杨赟 3 years ago
commit 3e3a148c26

@ -27,6 +27,9 @@ var (
"*金额(元)/20",
"*打款备注(20个字符以内)/30",
"打款状态/20",
"*提现金额/20",
"*平台已交税费(元)/20",
"*实际打款金额(元)/20",
}
excelLetters = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
@ -73,6 +76,8 @@ func MapToPtrArray(d *user.Withdraw, u *user.Information) []interface{} {
array = append(array, d.Amount)
array = append(array, "")
array = append(array, "否")
array = append(array, d.TaxFee)
array = append(array, d.ActualAmount)
return array
}

@ -0,0 +1,79 @@
package aliyun
import (
"encoding/json"
"errors"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
)
var Sms = sms{}
type sms struct {
client *sdk.Client
}
const ()
/*
*/
const (
regionId = "cn-hangzhou"
accessKey = "LTAI4Fe9j26vbarEGVZ7Nany"
accessKeySecret = "ysEYgqgpKtPbEJmHwdZ5psKsT15nel"
SUCCESS = "SMS_243631426"
FAIL = "SMS_243616481"
)
func init() {
c, err := sdk.NewClientWithAccessKey(regionId, accessKey, accessKeySecret)
if err != nil {
panic(err)
}
Sms.client = c
}
type AliResp struct {
Message string
RequestId string
BizId string
Code string
}
// SendMessage @Title 短信发送
func (s *sms) SendMessage(mobile, loginTemplateCode string, data map[string]string) error {
marshal, _ := json.Marshal(&data)
request := returnRequest(mobile, string(marshal), loginTemplateCode)
response, err := s.client.ProcessCommonRequest(request)
if err != nil {
return errors.New(err.Error())
}
if response.IsSuccess() {
var p AliResp
if err := json.Unmarshal(response.GetHttpContentBytes(), &p); err != nil {
return errors.New(err.Error())
}
if p.Message != "OK" {
return errors.New("短信发送失败: " + p.Message)
}
return nil
} else {
return errors.New("短信发送失败")
}
}
func returnRequest(mobile string, data string, templateCode string) *requests.CommonRequest {
request := requests.NewCommonRequest()
request.Method = "POST"
request.Scheme = "https"
request.Domain = "dysmsapi.aliyuncs.com"
request.Version = "2017-05-25"
request.ApiName = "SendSms"
request.QueryParams["RegionId"] = regionId
request.QueryParams["SignName"] = "瑞库客"
request.QueryParams["TemplateCode"] = templateCode
request.QueryParams["TemplateParam"] = data
request.QueryParams["PhoneNumbers"] = mobile
return request
}

@ -44,9 +44,6 @@ func (*Personal) Add(c *gin.Context) {
// 开始添加用户
information.Nickname = args.Nickname
information.Level = 10
if err := registerUser.UserAdd(c, &user.Login{}, &information, args.Phone); err != nil {
back.Fail(c, "提交失败")
return
}
registerUser.UserAdd(c, &user.Login{}, &information, args.Phone)
back.Suc(c, "操作成功", nil)
}

@ -5,6 +5,7 @@ import (
"fmt"
"math/rand"
"recook/internal/define"
"recook/internal/libs/aliyun"
"recook/internal/libs/bean"
"recook/internal/service/baseCode"
"recook/internal/v2/model/company"
@ -191,7 +192,7 @@ func (o logic) All() (res []string) {
type CompanySureApply struct {
ID uint `json:"id" validate:"required"`
UserID uint `json:"-"`
UserID uint `json:"user_id"`
}
func (o logic) Sure(args CompanySureApply) error {
@ -226,58 +227,57 @@ func (o logic) Sure(args CompanySureApply) error {
}
if u1.Id > 0 {
return errors.New("手机号已使用")
} else {
mobile := obj.Mobile
rd := fmt.Sprintf("%06v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))
sql := `select max(id)+floor(1+rand()*5) from recook_user_info`
var lastId int64
if err := tx.Raw(sql).Count(&lastId).Error; err != nil {
return err
}
info := user.RecookUserInfoModel{
Id: uint(lastId),
Nickname: obj.ShopName,
Mobile: mobile,
Birthday: formatime.NewSecondFrom(define.DefaultBirthday),
HeadImgUrl: "",
Phone: mobile,
Identifier: time.Now().Format("060102") + rd,
Level: 10,
ParentID: 0,
RootID: 0,
InvitationNo: baseCode.Encode(uint64(lastId)),
IsEnterprise: true,
}
if err := tx.Create(&info).Error; err != nil {
tx.Rollback()
err = fmt.Errorf("创建用户错误101:" + err.Error())
return err
}
}
// 生成邀请码和推荐码
info.InvitationNo = baseCode.Encode(uint64(info.Id))
if err := tx.Save(&info).Error; err != nil {
err = fmt.Errorf("创建用户错误102:" + err.Error())
return err
}
// 建立钱包
wallet := user.RecookUserWalletModel{
UserId: info.Id,
}
if err := tx.Create(&wallet).Error; err != nil {
tx.Rollback()
err = fmt.Errorf("创建用户错误103:" + err.Error())
return err
}
mobile := obj.Mobile
rd := fmt.Sprintf("%06v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))
sql := `select max(id)+floor(1+rand()*5) from recook_user_info`
var lastId int64
if err := tx.Raw(sql).Count(&lastId).Error; err != nil {
return err
}
info := user.RecookUserInfoModel{
Id: uint(lastId),
Nickname: obj.ShopName,
Mobile: mobile,
Birthday: formatime.NewSecondFrom(define.DefaultBirthday),
HeadImgUrl: "",
Phone: mobile,
Identifier: time.Now().Format("060102") + rd,
Level: 10,
ParentID: 0,
RootID: 0,
InvitationNo: baseCode.Encode(uint64(lastId)),
IsEnterprise: true,
}
if err := tx.Model(&obj).Updates(company.Info{
UserID: uint(lastId),
}).Error; err != nil {
return err
}
if err := tx.Create(&info).Error; err != nil {
tx.Rollback()
err = fmt.Errorf("创建用户错误101:" + err.Error())
return err
}
// 生成邀请码和推荐码
info.InvitationNo = baseCode.Encode(uint64(info.Id))
if err := tx.Save(&info).Error; err != nil {
err = fmt.Errorf("创建用户错误102:" + err.Error())
return err
}
// 建立钱包
wallet := user.RecookUserWalletModel{
UserId: info.Id,
}
if err := tx.Create(&wallet).Error; err != nil {
tx.Rollback()
err = fmt.Errorf("创建用户错误103:" + err.Error())
return err
}
if err := tx.Model(&obj).Updates(company.Info{
UserID: uint(lastId),
}).Error; err != nil {
return err
}
aliyun.Sms.SendMessage(info.Mobile, aliyun.SUCCESS, map[string]string{})
return nil
}); err != nil {
return err
@ -314,6 +314,9 @@ func (o logic) Reject(args CompanyRejectApply) error {
}).Error; err != nil {
return err
}
aliyun.Sms.SendMessage(obj.Mobile, aliyun.FAIL, map[string]string{
"remark": args.Reason,
})
return nil
}); err != nil {
return err

@ -19,6 +19,7 @@ type CompanyInfo struct {
Phone string `binding:"required,len=11,startswith=1" label:"手机号"` //手机号
NikeName string `binding:"required" label:"昵称"` //昵称
BusinessLicense string `binding:"required" label:"印业执照"` //营业执照
TaxPhoto string `label:"一般纳税人传的照片"` //一般纳税人传的照片
CorporationName string `binding:"required" label:"企业名"` //企业名
TaxBillType string `binding:"required" label:"纳税类型"` //纳税类型
Taxpayer string `binding:"required" label:"纳税识别号"` //纳税识别号
@ -26,7 +27,7 @@ type CompanyInfo struct {
BankAccount string `binding:"required" label:"银行账户"` //银行账户
MakeTax decimal.Decimal `binding:"required" label:"开票税率"` //开票税率
Linkman string `binding:"required" label:"联系人"` //联系人
ContractMobile string `binding:"required" label:"联系人手机号或者邮箱"` //联系人手机号或者邮箱
ContractMobile string `binding:"required" label:"联系人手机号"` //联系人手机号
}
// Add @Title 添加合伙人
@ -38,6 +39,7 @@ func (c *companyLogic) Add(data CompanyInfo) error {
}
userInfo := user.RecookUserInfoModel{Nickname: data.NikeName}
mysql.Db.Where(&userInfo).First(&userInfoModel)
if userInfo.Id > 0 {
return fmt.Errorf("昵称已存在")
}
@ -56,6 +58,10 @@ func (c *companyLogic) Add(data CompanyInfo) error {
State: company.Wait,
CreatedAt: formatime.NewSecondNow(),
}
if data.TaxBillType == "一般纳税人" {
companyInfo.TaxPhoto = data.TaxPhoto
}
return mysql.Db.Transaction(func(tx *gorm.DB) error {
if tx.Create(&companyInfo).Error != nil {
return errors.New("提交失败")

@ -0,0 +1,71 @@
package message
import (
"encoding/json"
"errors"
"fmt"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"math/rand"
"recook/internal/cache"
"time"
)
var MessageLogin = &messageLogin{}
var client *sdk.Client
type messageLogin struct {
}
const (
regionId = "cn-hangzhou"
SUCCESS = "SMS_243631426"
FAIL = "SMS_243616481"
)
type AliResp struct {
Message string
RequestId string
BizId string
Code string
}
// SendMessage @Title 短信发送
func (m *messageLogin) SendMessage(mobile, loginTemplateCode string) error {
randString := fmt.Sprintf("%04v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000))
request := returnRequest(mobile, randString, loginTemplateCode)
response, err := client.ProcessCommonRequest(request)
if err != nil {
return errors.New(err.Error())
}
if response.IsSuccess() {
cache.SetVerifyMobileSMSCode(mobile, randString)
var p AliResp
if err := json.Unmarshal(response.GetHttpContentBytes(), &p); err != nil {
return errors.New(err.Error())
}
if p.Message != "OK" {
return errors.New("短信发送失败: " + p.Message)
}
return nil
} else {
return errors.New("短信发送失败")
}
}
func returnRequest(mobile string, code string, templateCode string) *requests.CommonRequest {
request := requests.NewCommonRequest()
request.Method = "POST"
request.Scheme = "https"
request.Domain = "dysmsapi.aliyuncs.com"
request.Version = "2017-05-25"
request.ApiName = "SendSms"
request.QueryParams["RegionId"] = regionId
request.QueryParams["SignName"] = "瑞库客"
request.QueryParams["TemplateCode"] = templateCode
request.QueryParams["TemplateParam"] = fmt.Sprintf("{\"code\":\"%v\"}", code)
request.QueryParams["PhoneNumbers"] = mobile
return request
}

@ -58,7 +58,7 @@ type ArgsMore struct {
type ArgsAuditReject struct {
GoodsID []uint `json:"goods_id"`
AdminID uint `json:"-"`
AdminID uint `json:"admin_id"`
Content string `json:"content"`
AuditType int `json:"audit_type"`
}

Loading…
Cancel
Save