118 lines
3.6 KiB
Go
118 lines
3.6 KiB
Go
package api
|
|
|
|
import (
|
|
butil "enterprise/base/util"
|
|
"enterprise/common/model"
|
|
"fmt"
|
|
qrcode "github.com/skip2/go-qrcode"
|
|
"github.com/smbrave/goutil"
|
|
"github.com/spf13/cast"
|
|
)
|
|
|
|
type StaffLoginReq struct {
|
|
Username string `json:"username"`
|
|
Password string `json:"password"`
|
|
}
|
|
|
|
type StaffUser struct {
|
|
Id string `json:"id"`
|
|
Phone string `json:"phone"`
|
|
Idno string `json:"idno"`
|
|
Username string `json:"username"`
|
|
Realname string `json:"realname"`
|
|
EntryDate string `json:"entry_date"`
|
|
OfficialDate string `json:"official_date"`
|
|
LeaveDate string `json:"leave_date"`
|
|
Status string `json:"status"`
|
|
|
|
SalaryBase string `json:"salary_base"`
|
|
SalaryTarget string `json:"salary_target"`
|
|
SalaryCalculator string `json:"salary_calculator"`
|
|
SalaryCalculatorName string `json:"salary_calculator_name"`
|
|
|
|
PayeeBankName string `json:"payee_bank_name"`
|
|
PayeeBankCard string `json:"payee_bank_card"`
|
|
PayeeAlipayUid string `json:"payee_alipay_uid"`
|
|
PayeeAlipayAuthUrl string `json:"payee_alipay_auth_url"`
|
|
PayeeAlipayAuthQrcode string `json:"payee_alipay_auth_qrcode"`
|
|
|
|
Config interface{} `json:"config"`
|
|
Tags []*Tag `json:"tags"`
|
|
}
|
|
|
|
type StaffListReq struct {
|
|
BaseRequest
|
|
Status string `form:"status"`
|
|
Phone string `form:"phone"`
|
|
Idno string `form:"idno"`
|
|
Username string `form:"username"`
|
|
Realname string `form:"realname"`
|
|
}
|
|
|
|
type StaffCreateReq struct {
|
|
Username string `json:"username"`
|
|
}
|
|
|
|
type StaffPayReq struct {
|
|
StaffId string `json:"staff_id"`
|
|
PayType string `json:"pay_type"`
|
|
Title string `json:"title"`
|
|
Amount int64 `json:"amount"`
|
|
}
|
|
|
|
type StaffUpdateReq struct {
|
|
Id string `json:"id"`
|
|
Phone string `json:"phone"`
|
|
Idno string `json:"idno"`
|
|
Username string `json:"username"`
|
|
Realname string `json:"realname"`
|
|
EntryDate string `json:"entry_date"`
|
|
OfficialDate string `json:"official_date"`
|
|
LeaveDate string `json:"leave_date"`
|
|
Status string `json:"status"`
|
|
|
|
SalaryBase string `json:"salary_base"`
|
|
SalaryTarget string `json:"salary_target"`
|
|
SalaryCalculator string `json:"salary_calculator"`
|
|
|
|
PayeeBankName string `json:"payee_bank_name"`
|
|
PayeeBankCard string `json:"payee_bank_card"`
|
|
PayeeAlipayUid string `json:"payee_alipay_uid"`
|
|
|
|
Config string `json:"config"`
|
|
}
|
|
|
|
func (s *StaffUser) From(m *model.StaffUser) {
|
|
goutil.CopyStruct(s, m)
|
|
s.Id = cast.ToString(m.Id)
|
|
s.Status = cast.ToString(m.Status)
|
|
salary := m.GetSalary()
|
|
payee := m.GetPayee()
|
|
s.SalaryBase = salary.Base
|
|
s.SalaryTarget = salary.Target
|
|
s.SalaryCalculator = salary.Calculator
|
|
s.PayeeBankName = payee.BankName
|
|
s.PayeeBankCard = payee.BankCard
|
|
s.PayeeAlipayUid = payee.AlipayUid
|
|
|
|
//s.PayeeAlipayAuthUrl = fmt.Sprintf("https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2021004108682468&scope=auth_base&state=%d&redirect_uri=https://e.batiao8.com/api/payment/auth/alipay", m.Id)
|
|
s.PayeeAlipayAuthUrl = fmt.Sprintf("https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2021004108682468&scope=auth_user&state=%d&redirect_uri=https://e.batiao8.com/api/payment/auth/alipay", m.Id)
|
|
s.PayeeAlipayAuthQrcode, _ = butil.CreateQrcodeBase64V2(s.PayeeAlipayAuthUrl, qrcode.Low, 300)
|
|
|
|
tags := make([]*Tag, 0)
|
|
if payee.BankName != "" && payee.BankCard != "" {
|
|
tags = append(tags, &Tag{Name: "银行卡", Type: "success"})
|
|
}
|
|
if payee.AlipayUid != "" {
|
|
tags = append(tags, &Tag{Name: "支付宝", Type: "success"})
|
|
}
|
|
if m.Phone == "" {
|
|
tags = append(tags, &Tag{Name: "未填手机号", Type: "warning"})
|
|
}
|
|
if m.Idno == "" {
|
|
tags = append(tags, &Tag{Name: "未填身份证号", Type: "warning"})
|
|
}
|
|
|
|
s.Tags = tags
|
|
}
|