Compare commits
No commits in common. "master" and "rzh" have entirely different histories.
|
@ -1,104 +0,0 @@
|
|||
package push
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.u8t.cn/open/gosdk/util"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/smbrave/goutil"
|
||||
"github.com/spf13/cast"
|
||||
"time"
|
||||
)
|
||||
|
||||
type GetuiSms struct {
|
||||
appid string
|
||||
appkey string
|
||||
masterSecret string
|
||||
templateId string
|
||||
token string
|
||||
}
|
||||
|
||||
func NewGetuiSms(appid, appkey, masterSecret, templateId string) *GetuiSms {
|
||||
return &GetuiSms{
|
||||
appkey: appkey,
|
||||
appid: appid,
|
||||
masterSecret: masterSecret,
|
||||
templateId: templateId,
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GetuiSms) getResult(rspBody []byte) (map[string]interface{}, error) {
|
||||
result := make(map[string]interface{})
|
||||
|
||||
if err := json.Unmarshal(rspBody, &result); err != nil {
|
||||
log.Errorf("json[%s] error :%s", string(rspBody), err.Error())
|
||||
return nil, err
|
||||
}
|
||||
code := cast.ToInt(result["result"])
|
||||
data := cast.ToStringMap(result["data"])
|
||||
|
||||
if code == 20000 {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
if code != 0 {
|
||||
log.Errorf("json[%s] rsp error", string(rspBody))
|
||||
return nil, errors.New(string(rspBody))
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (g *GetuiSms) Token() string {
|
||||
|
||||
timestamp := cast.ToString(time.Now().UnixMilli())
|
||||
signStr := fmt.Sprintf("%s%s%s", g.appkey, timestamp, g.masterSecret)
|
||||
reqUrl := "https://openapi-smsp.getui.com/v1/sps/auth_sign"
|
||||
params := make(map[string]string)
|
||||
params["timestamp"] = timestamp
|
||||
params["appId"] = g.appid
|
||||
params["sign"] = util.Sha256(signStr)
|
||||
reqBody, _ := json.Marshal(params)
|
||||
rspBody, err := HttpPostJson(reqUrl, nil, reqBody)
|
||||
if err != nil {
|
||||
log.Errorf("http post [%s] error :%s", string(reqBody), err.Error())
|
||||
return ""
|
||||
}
|
||||
|
||||
result, err := g.getResult(rspBody)
|
||||
if err != nil {
|
||||
log.Errorf("get Result error :%s", err.Error())
|
||||
return ""
|
||||
}
|
||||
|
||||
token := cast.ToString(result["authToken"])
|
||||
|
||||
g.token = token
|
||||
|
||||
return g.token
|
||||
}
|
||||
|
||||
func (g *GetuiSms) Send(phone string, data map[string]string) (interface{}, error) {
|
||||
|
||||
reqUrl := "https://openapi-smsp.getui.com/v1/sps/push_sms_list"
|
||||
params := make(map[string]interface{})
|
||||
params["authToken"] = g.Token()
|
||||
params["appId"] = g.appid
|
||||
params["smsTemplateId"] = g.templateId
|
||||
params["smsParam"] = data
|
||||
params["recNum"] = []string{goutil.Md5(phone)}
|
||||
reqBody, _ := json.Marshal(params)
|
||||
rspBody, err := HttpPostJson(reqUrl, nil, reqBody)
|
||||
if err != nil {
|
||||
log.Errorf("http post [%s] error :%s", string(reqBody), err.Error())
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println(string(reqBody), string(rspBody))
|
||||
_, err = g.getResult(rspBody)
|
||||
if err != nil {
|
||||
log.Errorf("get Result error :%s", err.Error())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
|
@ -104,11 +104,7 @@ func (d *ApproveDetail) GetValue(title string) string {
|
|||
|
||||
var value string
|
||||
if content.Control == "Selector" {
|
||||
for _, v := range content.Value.Selector.Options[0].Value {
|
||||
if v.Text != "" {
|
||||
value = v.Text
|
||||
}
|
||||
}
|
||||
value = content.Value.Selector.Options[0].Value[0].Text
|
||||
} else if content.Control == "Text" || content.Control == "Textarea" {
|
||||
value = content.Value.Text
|
||||
} else if content.Control == "Date" {
|
||||
|
|
|
@ -8,9 +8,7 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
"github.com/smbrave/goutil"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/tidwall/gjson"
|
||||
"gorm.io/gorm/utils"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -18,7 +16,6 @@ type UserCheckIn struct {
|
|||
Day string
|
||||
Month string
|
||||
UserId string
|
||||
UserName string
|
||||
Exception string
|
||||
Rawdata string
|
||||
StartTime int64
|
||||
|
@ -121,7 +118,6 @@ func (q *AppCheckin) GetCheckinData(startDay, endDay string, userIds []string) (
|
|||
key := fmt.Sprintf("%s_%s", userid, checkDay)
|
||||
var userData *UserCheckIn = nil
|
||||
var ok bool
|
||||
|
||||
if userData, ok = checkData[key]; !ok {
|
||||
userData = new(UserCheckIn)
|
||||
userData.UserId = userid
|
||||
|
@ -133,14 +129,11 @@ func (q *AppCheckin) GetCheckinData(startDay, endDay string, userIds []string) (
|
|||
userData.Exception += goutil.If(userData.Exception != "", ",", "")
|
||||
userData.Exception += checkinType + ":" + exceptionType
|
||||
}
|
||||
|
||||
userData.Rawdata += goutil.If(userData.Rawdata == "", "", "\n") + goutil.EncodeJSON(dat)
|
||||
userData.Rawdata = goutil.If(userData.Rawdata == "", "", "\n") + goutil.EncodeJSON(dat)
|
||||
if checkinType == "上班打卡" {
|
||||
userData.StartTime = goutil.If(userData.StartTime == 0 || checkinTime < userData.StartTime, checkinTime, userData.StartTime)
|
||||
userData.StartTime = goutil.If(strings.Contains(exceptionType, "未打卡"), 0, userData.StartTime)
|
||||
} else if checkinType == "下班打卡" {
|
||||
userData.EndTime = goutil.If(checkinTime > userData.EndTime, checkinTime, userData.EndTime)
|
||||
userData.EndTime = goutil.If(strings.Contains(exceptionType, "未打卡"), 0, userData.EndTime)
|
||||
} else {
|
||||
log.Errorf("不支持的打卡类型:%s %s", checkinType, goutil.EncodeJSON(dat))
|
||||
}
|
||||
|
@ -155,73 +148,3 @@ func (q *AppCheckin) GetCheckinData(startDay, endDay string, userIds []string) (
|
|||
}
|
||||
return userDatas, nil
|
||||
}
|
||||
|
||||
func (q *AppCheckin) GetCheckinDataV2(startDay, endDay string, userIds []string) ([]*UserCheckIn, error) {
|
||||
|
||||
dayTime, _ := time.ParseInLocation("2006-01-02", startDay, time.Local)
|
||||
endTime, _ := time.ParseInLocation("2006-01-02", endDay, time.Local)
|
||||
|
||||
reqData := make(map[string]interface{})
|
||||
reqData["starttime"] = dayTime.Unix()
|
||||
reqData["endtime"] = endTime.Unix() + 86400 - 1
|
||||
reqData["useridlist"] = userIds
|
||||
reqUrl := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckin_daydata?access_token=%s", q.GetToken())
|
||||
rspBody, err := util.HttpPostJson(reqUrl, nil, []byte(goutil.EncodeJSON(reqData)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
g := gjson.ParseBytes(rspBody)
|
||||
if g.Get("errcode").Int() != 0 {
|
||||
log.Errorf("http url[%s] result[%s] error ", reqUrl, string(rspBody))
|
||||
return nil, errors.New(string(rspBody))
|
||||
}
|
||||
|
||||
userDatas := make([]*UserCheckIn, 0)
|
||||
for _, dat := range g.Get("datas").Array() {
|
||||
|
||||
ruleCheckinTimes := dat.Get("base_info.rule_info.checkintime").Array()
|
||||
if len(ruleCheckinTimes) < 1 {
|
||||
continue
|
||||
}
|
||||
userData := new(UserCheckIn)
|
||||
dayTimestamp := dat.Get("base_info.date").Int()
|
||||
userId := dat.Get("base_info.acctid").String()
|
||||
userName := dat.Get("base_info.name").String()
|
||||
summaryInfo := dat.Get("summary_info").Map()
|
||||
earliestTime := summaryInfo["earliest_time"].Int()
|
||||
lastestTime := summaryInfo["lastest_time"].Int()
|
||||
userData.Day = time.Unix(dayTimestamp, 0).Format("2006-01-02")
|
||||
userData.Month = time.Unix(dayTimestamp, 0).Format("200601")
|
||||
userData.UserId = userId
|
||||
userData.UserName = userName
|
||||
userData.Rawdata = dat.Raw
|
||||
|
||||
if earliestTime > 0 {
|
||||
userData.StartTime = dayTimestamp + earliestTime
|
||||
}
|
||||
if lastestTime > 0 {
|
||||
userData.EndTime = dayTimestamp + lastestTime
|
||||
}
|
||||
|
||||
if lastestTime == 0 || earliestTime == 0 {
|
||||
userData.Exception = "上班未打卡;下班未打卡"
|
||||
userDatas = append(userDatas, userData)
|
||||
continue
|
||||
}
|
||||
|
||||
if earliestTime == lastestTime {
|
||||
if earliestTime <= ruleCheckinTimes[0].Get("off_work_sec").Int() {
|
||||
userData.Exception = "下班未打卡"
|
||||
} else {
|
||||
userData.Exception = "上班未打卡"
|
||||
}
|
||||
} else {
|
||||
if dat.Get("summary_info.regular_work_sec").Int() < dat.Get("summary_info.standard_work_sec").Int() {
|
||||
userData.Exception = "出勤异常"
|
||||
}
|
||||
}
|
||||
userDatas = append(userDatas, userData)
|
||||
}
|
||||
|
||||
return userDatas, nil
|
||||
}
|
||||
|
|
|
@ -10,10 +10,8 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
urlQyWeixinHrGetAllField = "https://qyapi.weixin.qq.com/cgi-bin/hr/get_fields"
|
||||
urlQyWeixinHrGetStaffInfo = "https://qyapi.weixin.qq.com/cgi-bin/hr/get_staff_info"
|
||||
urlQyWeixinHrGetDepartment = "https://qyapi.weixin.qq.com/cgi-bin/department/list"
|
||||
urlQyWeixinHrGetDepartmentUser = "https://qyapi.weixin.qq.com/cgi-bin/user/list"
|
||||
urlQyWeixinHrGetAllField = "https://qyapi.weixin.qq.com/cgi-bin/hr/get_fields"
|
||||
urlQyWeixinHrGetStaffInfo = "https://qyapi.weixin.qq.com/cgi-bin/hr/get_staff_info"
|
||||
)
|
||||
|
||||
type AppHr struct {
|
||||
|
@ -21,13 +19,6 @@ type AppHr struct {
|
|||
config *AppConfig
|
||||
}
|
||||
|
||||
type Department struct {
|
||||
Id int64 `json:"id"`
|
||||
Pid int64 `json:"pid"`
|
||||
Name string `json:"name"`
|
||||
Leader []string `json:"leader"`
|
||||
}
|
||||
|
||||
type StaffInfo struct {
|
||||
UserName string
|
||||
RealName string
|
||||
|
@ -35,11 +26,15 @@ type StaffInfo struct {
|
|||
Phone string
|
||||
StaffType string
|
||||
Idno string
|
||||
Salary float64
|
||||
PerfSalary float64
|
||||
Stock float64
|
||||
EntryDate string
|
||||
BirthDate string
|
||||
OfficialDate string
|
||||
BankName string
|
||||
BankCard string
|
||||
AlipayUid string
|
||||
}
|
||||
|
||||
func NewAppHr(cfg *AppConfig) *AppHr {
|
||||
|
@ -81,7 +76,8 @@ func (h *AppHr) GetStaffInfo(userId string) (*StaffInfo, error) {
|
|||
|
||||
staff.UserName = userId
|
||||
staff.RealName = userInfo.RealName
|
||||
|
||||
staff.Salary = cast.ToFloat64(h.getFieldValue(fieldMap["20001"]))
|
||||
staff.Stock = cast.ToFloat64(h.getFieldValue(fieldMap["20002"]))
|
||||
staff.Phone = cast.ToString(h.getFieldValue(fieldMap["17003"]))
|
||||
staff.StaffType = cast.ToString(h.getFieldValue(fieldMap["12003"]))
|
||||
staff.Idno = cast.ToString(h.getFieldValue(fieldMap["11015"]))
|
||||
|
@ -90,57 +86,13 @@ func (h *AppHr) GetStaffInfo(userId string) (*StaffInfo, error) {
|
|||
staff.EntryDate = time.Unix(cast.ToInt64(h.getFieldValue(fieldMap["12018"])), 0).Format("2006-01-02")
|
||||
staff.BirthDate = time.Unix(cast.ToInt64(h.getFieldValue(fieldMap["11005"])), 0).Format("2006-01-02")
|
||||
staff.OfficialDate = time.Unix(cast.ToInt64(h.getFieldValue(fieldMap["12023"])), 0).Format("2006-01-02")
|
||||
staff.AlipayUid = cast.ToString(h.getFieldValue(fieldMap["20004"]))
|
||||
staff.PerfSalary = cast.ToFloat64(h.getFieldValue(fieldMap["20004"]))
|
||||
|
||||
//fmt.Println(goutil.EncodeJSON(staff))
|
||||
return staff, nil
|
||||
}
|
||||
|
||||
func (h *AppHr) GetDepartment(id int64) ([]*Department, error) {
|
||||
reqUrl := fmt.Sprintf("%s?access_token=%s&id=%d", urlQyWeixinHrGetDepartment, h.GetToken(), id)
|
||||
rspBody, err := util.HttpGet(reqUrl, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := h.GetResult(rspBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make([]*Department, 0)
|
||||
|
||||
departments := cast.ToSlice(resp["department"])
|
||||
for _, dd := range departments {
|
||||
d := cast.ToStringMap(dd)
|
||||
r := new(Department)
|
||||
r.Name = cast.ToString(d["name"])
|
||||
r.Leader = cast.ToStringSlice(d["department_leader"])
|
||||
r.Id = cast.ToInt64(d["id"])
|
||||
r.Pid = cast.ToInt64(d["parentid"])
|
||||
result = append(result, r)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (h *AppHr) GetDepartmentUserId(id int64) ([]string, error) {
|
||||
reqUrl := fmt.Sprintf("%s?access_token=%s&department_id=%d", urlQyWeixinHrGetDepartmentUser, h.GetToken(), id)
|
||||
rspBody, err := util.HttpGet(reqUrl, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := h.GetResult(rspBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make([]string, 0)
|
||||
|
||||
userlist := cast.ToSlice(resp["userlist"])
|
||||
for _, dd := range userlist {
|
||||
d := cast.ToStringMap(dd)
|
||||
result = append(result, cast.ToString(d["userid"]))
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (h *AppHr) getFieldValue(fieldInfo map[string]interface{}) string {
|
||||
valueType := cast.ToInt(fieldInfo["value_type"])
|
||||
if valueType == 1 {
|
||||
|
|
|
@ -113,7 +113,7 @@ func (s *Minio) Url(objectName string, expire time.Duration) string {
|
|||
return err.Error()
|
||||
}
|
||||
|
||||
if expire > time.Hour*24*7 || expire == -1 {
|
||||
if expire > time.Hour*24*7 {
|
||||
expire = time.Hour * 24 * 7
|
||||
}
|
||||
var params url.Values
|
||||
|
|
|
@ -121,10 +121,7 @@ func (s *Sdk) Match(c *Request) (*Result, error) {
|
|||
params.Add("channel", c.Channel)
|
||||
params.Add("version", c.Version)
|
||||
params.Add("os_version", c.OsVersion)
|
||||
params.Add("package", c.Package)
|
||||
params.Add("did", c.Did)
|
||||
params.Add("active", strconv.FormatBool(c.Active))
|
||||
params.Add("active_time", c.ActiveTime)
|
||||
if c.Extra != nil {
|
||||
extra, _ := json.Marshal(c.Extra)
|
||||
params.Add("extra", string(extra))
|
||||
|
|
|
@ -11,25 +11,22 @@ type BaseResponse struct {
|
|||
}
|
||||
|
||||
type Request struct {
|
||||
Package string //安装包的包名
|
||||
Channel string //安装包的渠道
|
||||
Version string //安装包版本
|
||||
Os string //手机系统类别 android、ioss
|
||||
Ip string //客户端的外网ip
|
||||
Ipv6 string //客户端的外网ipv6
|
||||
Ua string //客户端的user-agent
|
||||
Brand string // 客户端手机品牌
|
||||
Model string //客户端的手机型号,如:NOH-AN00
|
||||
Cid string //广告带过来的点击ID,小红书是click_id、百度是bdvid
|
||||
Idfa string //客户端的广告id,ios时候有效
|
||||
Paid string //客户端的广告id,ios时候有效(百度特有)
|
||||
Oaid string //客户端的广告id,android时有效
|
||||
Imei string //设备唯一识别码
|
||||
Did string //设备唯一识别码,android是android_id,ios是idfv
|
||||
OsVersion string //操作系统版本号
|
||||
Extra map[string]string //其他额外数据
|
||||
Active bool // 是否直接激活
|
||||
ActiveTime string //用户真实激活时间
|
||||
Channel string //安装包的渠道
|
||||
Version string //安装包版本
|
||||
Os string //手机系统类别 android、ioss
|
||||
Ip string //客户端的外网ip
|
||||
Ipv6 string //客户端的外网ipv6
|
||||
Ua string //客户端的user-agent
|
||||
Brand string // 客户端手机品牌
|
||||
Model string //客户端的手机型号,如:NOH-AN00
|
||||
Cid string //广告带过来的点击ID,小红书是click_id、百度是bdvid
|
||||
Idfa string //客户端的广告id,ios时候有效
|
||||
Paid string //客户端的广告id,ios时候有效(百度特有)
|
||||
Oaid string //客户端的广告id,android时有效
|
||||
Imei string //设备唯一识别码
|
||||
OsVersion string //操作系统版本号
|
||||
Extra map[string]string //其他额外数据
|
||||
Active bool // 是否直接激活
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"git.u8t.cn/open/gosdk/util"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -177,7 +176,7 @@ func (p *Pay) RefundOrder(req *RefundOrderReq) error {
|
|||
errors.New("outTradeNo is nil")
|
||||
}
|
||||
|
||||
reqUrl := fmt.Sprintf("%s/api/pay/order?outTradeNo=%s&reason=%s&refundFee=%d", p.address, req.OutTradeNo, url.QueryEscape(req.Reason), req.RefundFee)
|
||||
reqUrl := fmt.Sprintf("%s/api/pay/order?outTradeNo=%s&reason=%s&refundFee=%d", p.address, req.OutTradeNo, req.Reason, req.RefundFee)
|
||||
result, err := util.HttpDelete(reqUrl, map[string]string{
|
||||
"x-token": p.token,
|
||||
})
|
||||
|
@ -201,7 +200,7 @@ func (p *Pay) RefundPartnerOrder(req *RefundOrderReq) error {
|
|||
errors.New("outTradeNo is nil")
|
||||
}
|
||||
|
||||
reqUrl := fmt.Sprintf("%s/api/pay/partner/order?outTradeNo=%s&reason=%s&refundFee=%d", p.address, req.OutTradeNo, url.QueryEscape(req.Reason), req.RefundFee)
|
||||
reqUrl := fmt.Sprintf("%s/api/pay/partner/order?outTradeNo=%s&reason=%s&refundFee=%d", p.address, req.OutTradeNo, req.Reason, req.RefundFee)
|
||||
result, err := util.HttpDelete(reqUrl, map[string]string{
|
||||
"x-token": p.token,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue