Compare commits

..

No commits in common. "master" and "rzh" have entirely different histories.
master ... rzh

21 changed files with 147 additions and 555 deletions

View File

@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"git.u8t.cn/open/goutil"
"github.com/smbrave/goutil"
)
type addressRsp struct {

View File

@ -1,56 +0,0 @@
package config
import (
"encoding/json"
"strings"
)
const (
FormTypeInput = "input" //文本输入框
FormTypeText = "text" //多行文本
FormTypeRadio = "radio" //单选框
FormTypeCheckbox = "checkbox" //多选框
FormTypeSwitch = "switch" //开关
FormTypeJson = "json" //JSON输入框
)
type FormOption struct {
Name string `json:"name"` //选项名称
Value string `json:"value"` //选项值
}
type Form struct {
Type string `json:"type"` //表单类型
Name string `json:"name"` //表单名称
Key string `json:"key"` //表单KEY
Value interface{} `json:"value"` //表单值
Disable bool `json:"disable,omitempty"` //是否禁用
Tips string `json:"tips"` //表单提示
Option []*FormOption `json:"option"` //表单选项radio和checkbox需要
}
func NewFroms(tplConfig, saveConfig string) ([]*Form, error) {
var forms []*Form
err := json.Unmarshal([]byte(tplConfig), &forms)
if err != nil {
return nil, err
}
var cfg map[string]interface{}
if strings.TrimSpace(saveConfig) != "" {
err = json.Unmarshal([]byte(saveConfig), &cfg)
if err != nil {
return nil, err
}
}
if cfg == nil {
cfg = make(map[string]interface{})
}
for _, form := range forms {
if _, ok := cfg[form.Key]; ok {
form.Value = cfg[form.Key]
}
}
return forms, err
}

View File

@ -7,7 +7,7 @@ import (
"fmt"
mqtt "github.com/eclipse/paho.mqtt.golang"
log "github.com/sirupsen/logrus"
"git.u8t.cn/open/goutil"
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"github.com/tidwall/gjson"
"strings"

View File

@ -5,7 +5,7 @@ import (
"fmt"
mqtt "github.com/eclipse/paho.mqtt.golang"
log "github.com/sirupsen/logrus"
"git.u8t.cn/open/goutil"
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"strings"
"sync"

64
go.mod
View File

@ -1,64 +1,58 @@
module git.u8t.cn/open/gosdk
go 1.24.0
toolchain go1.24.5
go 1.18
require (
git.u8t.cn/open/goutil v0.0.0-20250905165603-41d47bb16296
github.com/bradfitz/gomemcache v0.0.0-20250403215159-8d39553ac7cf
github.com/eclipse/paho.mqtt.golang v1.5.0
github.com/gin-gonic/gin v1.10.1
github.com/gomodule/redigo v1.9.2
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874
github.com/eclipse/paho.mqtt.golang v1.4.3
github.com/gin-gonic/gin v1.9.1
github.com/gomodule/redigo v1.8.9
github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c
github.com/minio/minio-go v6.0.14+incompatible
github.com/qiniu/go-sdk/v7 v7.25.4
github.com/qiniu/go-sdk/v7 v7.21.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cast v1.10.0
github.com/tidwall/gjson v1.18.0
github.com/wechatpay-apiv3/wechatpay-go v0.2.21
golang.org/x/crypto v0.42.0
gorm.io/gorm v1.30.5
github.com/smbrave/goutil v0.0.0-20240105134047-64fe0dfafba2
github.com/spf13/cast v1.6.0
github.com/tidwall/gjson v1.17.1
github.com/wechatpay-apiv3/wechatpay-go v0.2.18
golang.org/x/crypto v0.25.0
gorm.io/gorm v1.25.6
)
require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/alex-ant/gomath v0.0.0-20160516115720-89013a210a82 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gammazero/toposort v0.1.1 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/matishsiao/goInfo v0.0.0-20210923090445-da2e3fa8d45f // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/speps/go-hashids v2.0.0+incompatible // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.29.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/fileutil v1.0.0 // indirect
)

View File

@ -6,7 +6,7 @@ import (
"fmt"
"git.u8t.cn/open/gosdk/util"
log "github.com/sirupsen/logrus"
"git.u8t.cn/open/goutil"
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"time"
)

View File

@ -1,104 +0,0 @@
package push
import (
"encoding/json"
"errors"
"fmt"
"git.u8t.cn/open/gosdk/util"
log "github.com/sirupsen/logrus"
"git.u8t.cn/open/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
}

View File

@ -11,9 +11,9 @@ import (
"git.u8t.cn/open/gosdk/wechat/cache"
"git.u8t.cn/open/gosdk/wechat/message"
wutil "git.u8t.cn/open/gosdk/wechat/util"
"git.u8t.cn/open/goutil"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"io"
"io/ioutil"
@ -68,12 +68,12 @@ type BaseResponse struct {
}
type AppConfig struct {
Corpid string `json:"corpid"`
Secret string `json:"secret"`
Agent string `json:"agent"`
Token string `json:"token"`
AesKey string `json:"aes_key"`
Replay func(message.MixMessage) *message.Reply `json:"-"`
Corpid string
Secret string
Agent string
Token string
AesKey string
Replay func(message.MixMessage) *message.Reply
}
type App struct {
@ -354,7 +354,7 @@ func (q *App) Callback(ctx *gin.Context) {
_, resp, err := wutil.DecryptMsg(wechatConfig.AppID, ctx.Query("echostr"), wechatConfig.EncodingAESKey)
if err != nil {
log.Errorf("DecryptMsg failed! wechatConfig[%s] error:%s ", goutil.EncodeJSON(q.config), err.Error())
log.Errorf("DecryptMsg failed! appid[%s] aeskey[%s] error:%s ", wechatConfig.AppID, wechatConfig.EncodingAESKey, err.Error())
return
}
ctx.Data(http.StatusOK, "Content-type: text/plain", resp)
@ -371,7 +371,7 @@ func (q *App) Callback(ctx *gin.Context) {
server.SetDebug(true)
err := server.Serve()
if err != nil {
log.Errorf("qiye weixin Service [%s] err:%s", goutil.EncodeJSON(q.config), err.Error())
log.Errorf("qiye weixin Service [%s] err:%s", goutil.EncodeJSON(wechatConfig), err.Error())
return
}
err = server.Send()

View File

@ -4,10 +4,9 @@ import (
"encoding/json"
"fmt"
"git.u8t.cn/open/gosdk/util"
"git.u8t.cn/open/goutil"
log "github.com/sirupsen/logrus"
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"strings"
)
type Applyer struct {
@ -55,7 +54,6 @@ type ApplyValue struct {
Vacation *Vacation `json:"vacation"`
PunchCorrection interface{} `json:"punch_correction"`
BankAccount interface{} `json:"bank_account"`
NewNumber string `json:"new_number"`
}
type ApplyContent struct {
@ -106,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" {
@ -135,68 +129,12 @@ func (d *ApproveDetail) GetValue(title string) string {
} else if content.Control == "BankAccount" {
mp := cast.ToStringMap(content.Value.BankAccount)
value = cast.ToString(mp["account_type"]) + "," + cast.ToString(mp["account_name"]) + "," + cast.ToString(mp["account_number"])
} else if content.Control == "Number" {
value = content.Value.NewNumber
}
return value
}
return ""
}
func (d *ApproveDetail) GetData() map[string]string {
data := make(map[string]string)
for _, content := range d.ApplyData.Contents {
var value string
if content.Control == "Selector" {
if len(content.Value.Selector.Options) > 0 {
values := make([]string, 0)
for _, v := range content.Value.Selector.Options[0].Value {
if v.Text != "" {
values = append(values, v.Text)
}
}
value = strings.Join(values, ",")
}
} else if content.Control == "Text" || content.Control == "Textarea" {
value = content.Value.Text
} else if content.Control == "Date" {
value = content.Value.Date.Timestamp
} else if content.Control == "Money" {
value = content.Value.NewMoney
} else if content.Control == "File" {
if len(content.Value.Files) > 0 {
value = content.Value.Files[0].FileId
}
} else if content.Control == "Vacation" { //请假 请假类型,开始时间,结束时间,请假时长
tp := content.Value.Vacation.Selector.Options[0].Value[0].Text
value = tp + "," + cast.ToString(content.Value.Vacation.Attendance.DateRange.NewBegin) +
"," + cast.ToString(content.Value.Vacation.Attendance.DateRange.NewEnd) +
"," + cast.ToString(content.Value.Vacation.Attendance.DateRange.NewDuration)
} else if content.Control == "PunchCorrection" { //补卡:日期,时间,状态
mp := cast.ToStringMap(content.Value.PunchCorrection)
ddate := cast.ToString(mp["daymonthyear"])
dtime := cast.ToString(mp["time"])
if ddate == "" {
ddate = dtime
}
value = ddate + "," + dtime + "," + cast.ToString(mp["state"])
} else if content.Control == "BankAccount" {
mp := cast.ToStringMap(content.Value.BankAccount)
value = cast.ToString(mp["account_type"]) + "," + cast.ToString(mp["account_name"]) + "," + cast.ToString(mp["account_number"])
} else if content.Control == "Number" {
value = content.Value.NewNumber
}
for _, ti := range content.Title {
if ti.Lang == "zh_CN" {
data[ti.Text] = value
}
}
}
return data
}
func (d *ApproveDetail) String() string {
return goutil.EncodeJSONIndent(d)
}

View File

@ -6,11 +6,9 @@ import (
"fmt"
"git.u8t.cn/open/gosdk/util"
log "github.com/sirupsen/logrus"
"git.u8t.cn/open/goutil"
"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
}

View File

@ -6,7 +6,7 @@ import (
"fmt"
"git.u8t.cn/open/gosdk/util"
"git.u8t.cn/open/gosdk/wechat/message"
"git.u8t.cn/open/goutil"
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"time"
)

View File

@ -4,16 +4,14 @@ import (
"fmt"
"git.u8t.cn/open/gosdk/util"
log "github.com/sirupsen/logrus"
"git.u8t.cn/open/goutil"
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"time"
)
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 {

View File

@ -8,7 +8,7 @@ import (
"fmt"
butil "git.u8t.cn/open/gosdk/util"
log "github.com/sirupsen/logrus"
"git.u8t.cn/open/goutil"
"github.com/smbrave/goutil"
"github.com/spf13/cast"
"github.com/wechatpay-apiv3/wechatpay-go/core"
"github.com/wechatpay-apiv3/wechatpay-go/core/option"

View File

@ -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

View File

@ -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))

View File

@ -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 //客户端的广告idios时候有效
Paid string //客户端的广告idios时候有效百度特有
Oaid string //客户端的广告idandroid时有效
Imei string //设备唯一识别码
Did string //设备唯一识别码android是android_idios是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 //客户端的广告idios时候有效
Paid string //客户端的广告idios时候有效百度特有
Oaid string //客户端的广告idandroid时有效
Imei string //设备唯一识别码
OsVersion string //操作系统版本号
Extra map[string]string //其他额外数据
Active bool // 是否直接激活
}
type Result struct {

View File

@ -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,
})

View File

@ -41,7 +41,6 @@ type CreatePartnerOrderReq struct {
OutTradeNo string `json:"outTradeNo"`
NotifyUrl string `json:"notifyUrl"`
PartnerId string `json:"partnerId"`
PayChannel string `json:"payChannel"`
Extra interface{} `json:"extra"`
}

View File

@ -35,9 +35,8 @@ const (
//MsgTypeTransfer 表示消息消息转发到客服
MsgTypeTransfer = "transfer_customer_service"
//MsgTypeEvent 表示事件推送消息
MsgTypeEvent = "event"
MsgTypeChannels = "channels"
MsgTypeChnageContract = "change_contact"
MsgTypeEvent = "event"
MsgTypeChannels = "channels"
)
const (
@ -84,99 +83,94 @@ const (
// MixMessage 存放所有微信发送过来的消息和事件
type MixMessage struct {
CommonToken `json:"commonToken"`
CommonToken
//基本消息
MsgID int64 `xml:"MsgId" json:"msgID,omitempty"`
Content string `xml:"Content" json:"content,omitempty"`
Recognition string `xml:"Recognition" json:"recognition,omitempty"`
PicURL string `xml:"PicUrl" json:"picURL,omitempty"`
MediaID string `xml:"MediaId" json:"mediaID,omitempty"`
Format string `xml:"Format" json:"format,omitempty"`
ThumbMediaID string `xml:"ThumbMediaId" json:"thumbMediaID,omitempty"`
LocationX float64 `xml:"Location_X" json:"locationX,omitempty"`
LocationY float64 `xml:"Location_Y" json:"locationY,omitempty"`
Scale float64 `xml:"Scale" json:"scale,omitempty"`
Label string `xml:"Label" json:"label,omitempty"`
Title string `xml:"Title" json:"title,omitempty"`
Description string `xml:"Description" json:"description,omitempty"`
URL string `xml:"Url" json:"URL,omitempty"`
MsgID int64 `xml:"MsgId"`
Content string `xml:"Content"`
Recognition string `xml:"Recognition"`
PicURL string `xml:"PicUrl"`
MediaID string `xml:"MediaId"`
Format string `xml:"Format"`
ThumbMediaID string `xml:"ThumbMediaId"`
LocationX float64 `xml:"Location_X"`
LocationY float64 `xml:"Location_Y"`
Scale float64 `xml:"Scale"`
Label string `xml:"Label"`
Title string `xml:"Title"`
Description string `xml:"Description"`
URL string `xml:"Url"`
//事件相关
Event EventType `xml:"Event" json:"event,omitempty"`
EventKey string `xml:"EventKey" json:"eventKey,omitempty"`
Ticket string `xml:"Ticket" json:"ticket,omitempty"`
Latitude string `xml:"Latitude" json:"latitude,omitempty"`
Longitude string `xml:"Longitude" json:"longitude,omitempty"`
Precision string `xml:"Precision" json:"precision,omitempty"`
MenuID string `xml:"MenuId" json:"menuID,omitempty"`
Status string `xml:"Status" json:"status,omitempty"`
SessionFrom string `xml:"SessionFrom" json:"sessionFrom,omitempty"`
Event EventType `xml:"Event"`
EventKey string `xml:"EventKey"`
Ticket string `xml:"Ticket"`
Latitude string `xml:"Latitude"`
Longitude string `xml:"Longitude"`
Precision string `xml:"Precision"`
MenuID string `xml:"MenuId"`
Status string `xml:"Status"`
SessionFrom string `xml:"SessionFrom"`
ScanCodeInfo struct {
ScanType string `xml:"ScanType" json:"scanType,omitempty"`
ScanResult string `xml:"ScanResult" json:"scanResult,omitempty"`
} `xml:"ScanCodeInfo" json:"scanCodeInfo"`
ScanType string `xml:"ScanType"`
ScanResult string `xml:"ScanResult"`
} `xml:"ScanCodeInfo"`
// 企业微信客服相关
OpenKfId string `xml:"OpenKfId" json:"openKfId,omitempty"`
Token string `xml:"Token" json:"token,omitempty"`
OpenKfId string `xml:"OpenKfId"`
Token string `xml:"Token"`
// 企业微信审核相关
ApprovalInfo struct {
SpNo string `xml:"SpNo" json:"spNo,omitempty"`
SpName string `xml:"SpName" json:"spName,omitempty"`
SpStatus int `xml:"SpStatus" json:"spStatus,omitempty"`
TemplateId string `xml:"TemplateId" json:"templateId,omitempty"`
ApplyTime int64 `xml:"ApplyTime" json:"applyTime,omitempty"`
SpNo string `xml:"SpNo"`
SpName string `xml:"SpName"`
SpStatus int `xml:"SpStatus"`
TemplateId string `xml:"TemplateId"`
ApplyTime int64 `xml:"ApplyTime"`
Applyer struct {
UserId string `xml:"UserId" json:"userId,omitempty"`
} `xml:"Applyer" json:"applyer"`
} `xml:"ApprovalInfo" json:"approvalInfo"`
UserId string `xml:"UserId"`
} `xml:"Applyer"`
} `xml:"ApprovalInfo"`
SendPicsInfo struct {
Count int32 `xml:"Count" json:"count,omitempty"`
PicList []EventPic `xml:"PicList>item" json:"picList,omitempty"`
} `xml:"SendPicsInfo" json:"sendPicsInfo"`
Count int32 `xml:"Count"`
PicList []EventPic `xml:"PicList>item"`
} `xml:"SendPicsInfo"`
SendLocationInfo struct {
LocationX float64 `xml:"Location_X" json:"locationX,omitempty"`
LocationY float64 `xml:"Location_Y" json:"locationY,omitempty"`
Scale float64 `xml:"Scale" json:"scale,omitempty"`
Label string `xml:"Label" json:"label,omitempty"`
Poiname string `xml:"Poiname" json:"poiname,omitempty"`
} `json:"sendLocationInfo"`
LocationX float64 `xml:"Location_X"`
LocationY float64 `xml:"Location_Y"`
Scale float64 `xml:"Scale"`
Label string `xml:"Label"`
Poiname string `xml:"Poiname"`
}
// 第三方平台相关
InfoType InfoType `xml:"InfoType" json:"infoType,omitempty"`
AppID string `xml:"AppId" json:"appID,omitempty"`
ComponentVerifyTicket string `xml:"ComponentVerifyTicket" json:"componentVerifyTicket,omitempty"`
AuthorizerAppid string `xml:"AuthorizerAppid" json:"authorizerAppid,omitempty"`
AuthorizationCode string `xml:"AuthorizationCode" json:"authorizationCode,omitempty"`
AuthorizationCodeExpiredTime int64 `xml:"AuthorizationCodeExpiredTime" json:"authorizationCodeExpiredTime,omitempty"`
PreAuthCode string `xml:"PreAuthCode" json:"preAuthCode,omitempty"`
InfoType InfoType `xml:"InfoType"`
AppID string `xml:"AppId"`
ComponentVerifyTicket string `xml:"ComponentVerifyTicket"`
AuthorizerAppid string `xml:"AuthorizerAppid"`
AuthorizationCode string `xml:"AuthorizationCode"`
AuthorizationCodeExpiredTime int64 `xml:"AuthorizationCodeExpiredTime"`
PreAuthCode string `xml:"PreAuthCode"`
// 卡券相关
CardID string `xml:"CardId" json:"cardID,omitempty"`
RefuseReason string `xml:"RefuseReason" json:"refuseReason,omitempty"`
IsGiveByFriend int32 `xml:"IsGiveByFriend" json:"isGiveByFriend,omitempty"`
FriendUserName string `xml:"FriendUserName" json:"friendUserName,omitempty"`
UserCardCode string `xml:"UserCardCode" json:"userCardCode,omitempty"`
OldUserCardCode string `xml:"OldUserCardCode" json:"oldUserCardCode,omitempty"`
OuterStr string `xml:"OuterStr" json:"outerStr,omitempty"`
IsRestoreMemberCard int32 `xml:"IsRestoreMemberCard" json:"isRestoreMemberCard,omitempty"`
UnionID string `xml:"UnionId" json:"unionID,omitempty"`
CardID string `xml:"CardId"`
RefuseReason string `xml:"RefuseReason"`
IsGiveByFriend int32 `xml:"IsGiveByFriend"`
FriendUserName string `xml:"FriendUserName"`
UserCardCode string `xml:"UserCardCode"`
OldUserCardCode string `xml:"OldUserCardCode"`
OuterStr string `xml:"OuterStr"`
IsRestoreMemberCard int32 `xml:"IsRestoreMemberCard"`
UnionID string `xml:"UnionId"`
// 内容审核相关
IsRisky bool `xml:"isrisky" json:"isRisky,omitempty"`
ExtraInfoJSON string `xml:"extra_info_json" json:"extraInfoJSON,omitempty"`
TraceID string `xml:"trace_id" json:"traceID,omitempty"`
StatusCode int `xml:"status_code" json:"statusCode,omitempty"`
//通讯录同步相关
ChangeType string `xml:"ChangeType"`
UserID string `xml:"UserID"`
Department string `xml:"Department"`
IsRisky bool `xml:"isrisky"`
ExtraInfoJSON string `xml:"extra_info_json"`
TraceID string `xml:"trace_id"`
StatusCode int `xml:"status_code"`
}
// EventPic 发图事件推送

View File

@ -15,7 +15,6 @@ const (
accessTokenUrl string = "https://api.weixin.qq.com/cgi-bin/token"
userPhoneNumberUrl string = "https://api.weixin.qq.com/wxa/business/getuserphonenumber"
getWxACodeUnLimitUrl string = "https://api.weixin.qq.com/wxa/getwxacodeunlimit"
getWxScheme string = "https://api.weixin.qq.com/wxa/generatescheme"
code2UserinfoUrl string = "https://api.weixin.qq.com/sns/userinfo"
oaQrCodeCreateUrl string = "https://api.weixin.qq.com/cgi-bin/qrcode/create"
userInfoByOpenid string = "https://api.weixin.qq.com/cgi-bin/user/info"

View File

@ -108,43 +108,3 @@ func (o *MpSdk) GetUnlimitedQRCode(params map[string]interface{}) ([]byte, error
return body, nil
}
func (o *MpSdk) GetScheme(params map[string]interface{}) (string, error) {
newParams := make(map[string]interface{})
jump_wxa := make(map[string]interface{})
if _, ok := params["env_version"]; !ok {
jump_wxa["env_version"] = "release"
} else {
jump_wxa["env_version"] = cast.ToString(params["env_version"])
}
jump_wxa["path"] = cast.ToString(params["path"])
jump_wxa["query"] = cast.ToString(params["query"])
newParams["jump_wxa"] = jump_wxa
newParams["expire_interval"] = 30
newParams["expire_type"] = 1
newParams["is_expire"] = true
marshal, _ := json.Marshal(newParams)
accessToken, err := o.getAccessToken()
if err != nil {
return "", err
}
url := fmt.Sprintf("%s?access_token=%s", getWxScheme, accessToken)
res, _ := http.Post(url, "application/json", bytes.NewBuffer(marshal))
body, err := io.ReadAll(res.Body)
defer res.Body.Close()
if err != nil {
return "", err
}
g := gjson.ParseBytes(body)
errcode := g.Get("errcode").Int()
if errcode != 0 {
return "", fmt.Errorf("%d:%s", errcode, g.Get("errmsg"))
}
return g.Get("openlink").String(), nil
}