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
|
var value string
|
||||||
if content.Control == "Selector" {
|
if content.Control == "Selector" {
|
||||||
for _, v := range content.Value.Selector.Options[0].Value {
|
value = content.Value.Selector.Options[0].Value[0].Text
|
||||||
if v.Text != "" {
|
|
||||||
value = v.Text
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if content.Control == "Text" || content.Control == "Textarea" {
|
} else if content.Control == "Text" || content.Control == "Textarea" {
|
||||||
value = content.Value.Text
|
value = content.Value.Text
|
||||||
} else if content.Control == "Date" {
|
} else if content.Control == "Date" {
|
||||||
|
|
|
@ -8,9 +8,7 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/smbrave/goutil"
|
"github.com/smbrave/goutil"
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
"gorm.io/gorm/utils"
|
"gorm.io/gorm/utils"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,7 +16,6 @@ type UserCheckIn struct {
|
||||||
Day string
|
Day string
|
||||||
Month string
|
Month string
|
||||||
UserId string
|
UserId string
|
||||||
UserName string
|
|
||||||
Exception string
|
Exception string
|
||||||
Rawdata string
|
Rawdata string
|
||||||
StartTime int64
|
StartTime int64
|
||||||
|
@ -121,7 +118,6 @@ func (q *AppCheckin) GetCheckinData(startDay, endDay string, userIds []string) (
|
||||||
key := fmt.Sprintf("%s_%s", userid, checkDay)
|
key := fmt.Sprintf("%s_%s", userid, checkDay)
|
||||||
var userData *UserCheckIn = nil
|
var userData *UserCheckIn = nil
|
||||||
var ok bool
|
var ok bool
|
||||||
|
|
||||||
if userData, ok = checkData[key]; !ok {
|
if userData, ok = checkData[key]; !ok {
|
||||||
userData = new(UserCheckIn)
|
userData = new(UserCheckIn)
|
||||||
userData.UserId = userid
|
userData.UserId = userid
|
||||||
|
@ -133,14 +129,11 @@ func (q *AppCheckin) GetCheckinData(startDay, endDay string, userIds []string) (
|
||||||
userData.Exception += goutil.If(userData.Exception != "", ",", "")
|
userData.Exception += goutil.If(userData.Exception != "", ",", "")
|
||||||
userData.Exception += checkinType + ":" + exceptionType
|
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 == "上班打卡" {
|
if checkinType == "上班打卡" {
|
||||||
userData.StartTime = goutil.If(userData.StartTime == 0 || checkinTime < userData.StartTime, checkinTime, userData.StartTime)
|
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 == "下班打卡" {
|
} else if checkinType == "下班打卡" {
|
||||||
userData.EndTime = goutil.If(checkinTime > userData.EndTime, checkinTime, userData.EndTime)
|
userData.EndTime = goutil.If(checkinTime > userData.EndTime, checkinTime, userData.EndTime)
|
||||||
userData.EndTime = goutil.If(strings.Contains(exceptionType, "未打卡"), 0, userData.EndTime)
|
|
||||||
} else {
|
} else {
|
||||||
log.Errorf("不支持的打卡类型:%s %s", checkinType, goutil.EncodeJSON(dat))
|
log.Errorf("不支持的打卡类型:%s %s", checkinType, goutil.EncodeJSON(dat))
|
||||||
}
|
}
|
||||||
|
@ -155,73 +148,3 @@ func (q *AppCheckin) GetCheckinData(startDay, endDay string, userIds []string) (
|
||||||
}
|
}
|
||||||
return userDatas, nil
|
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
|
|
||||||
}
|
|
||||||
|
|
|
@ -12,8 +12,6 @@ import (
|
||||||
var (
|
var (
|
||||||
urlQyWeixinHrGetAllField = "https://qyapi.weixin.qq.com/cgi-bin/hr/get_fields"
|
urlQyWeixinHrGetAllField = "https://qyapi.weixin.qq.com/cgi-bin/hr/get_fields"
|
||||||
urlQyWeixinHrGetStaffInfo = "https://qyapi.weixin.qq.com/cgi-bin/hr/get_staff_info"
|
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"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AppHr struct {
|
type AppHr struct {
|
||||||
|
@ -21,13 +19,6 @@ type AppHr struct {
|
||||||
config *AppConfig
|
config *AppConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type Department struct {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
Pid int64 `json:"pid"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Leader []string `json:"leader"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type StaffInfo struct {
|
type StaffInfo struct {
|
||||||
UserName string
|
UserName string
|
||||||
RealName string
|
RealName string
|
||||||
|
@ -35,11 +26,15 @@ type StaffInfo struct {
|
||||||
Phone string
|
Phone string
|
||||||
StaffType string
|
StaffType string
|
||||||
Idno string
|
Idno string
|
||||||
|
Salary float64
|
||||||
|
PerfSalary float64
|
||||||
|
Stock float64
|
||||||
EntryDate string
|
EntryDate string
|
||||||
BirthDate string
|
BirthDate string
|
||||||
OfficialDate string
|
OfficialDate string
|
||||||
BankName string
|
BankName string
|
||||||
BankCard string
|
BankCard string
|
||||||
|
AlipayUid string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAppHr(cfg *AppConfig) *AppHr {
|
func NewAppHr(cfg *AppConfig) *AppHr {
|
||||||
|
@ -81,7 +76,8 @@ func (h *AppHr) GetStaffInfo(userId string) (*StaffInfo, error) {
|
||||||
|
|
||||||
staff.UserName = userId
|
staff.UserName = userId
|
||||||
staff.RealName = userInfo.RealName
|
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.Phone = cast.ToString(h.getFieldValue(fieldMap["17003"]))
|
||||||
staff.StaffType = cast.ToString(h.getFieldValue(fieldMap["12003"]))
|
staff.StaffType = cast.ToString(h.getFieldValue(fieldMap["12003"]))
|
||||||
staff.Idno = cast.ToString(h.getFieldValue(fieldMap["11015"]))
|
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.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.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.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
|
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 {
|
func (h *AppHr) getFieldValue(fieldInfo map[string]interface{}) string {
|
||||||
valueType := cast.ToInt(fieldInfo["value_type"])
|
valueType := cast.ToInt(fieldInfo["value_type"])
|
||||||
if valueType == 1 {
|
if valueType == 1 {
|
||||||
|
|
|
@ -113,7 +113,7 @@ func (s *Minio) Url(objectName string, expire time.Duration) string {
|
||||||
return err.Error()
|
return err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
if expire > time.Hour*24*7 || expire == -1 {
|
if expire > time.Hour*24*7 {
|
||||||
expire = time.Hour * 24 * 7
|
expire = time.Hour * 24 * 7
|
||||||
}
|
}
|
||||||
var params url.Values
|
var params url.Values
|
||||||
|
|
|
@ -121,10 +121,7 @@ func (s *Sdk) Match(c *Request) (*Result, error) {
|
||||||
params.Add("channel", c.Channel)
|
params.Add("channel", c.Channel)
|
||||||
params.Add("version", c.Version)
|
params.Add("version", c.Version)
|
||||||
params.Add("os_version", c.OsVersion)
|
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", strconv.FormatBool(c.Active))
|
||||||
params.Add("active_time", c.ActiveTime)
|
|
||||||
if c.Extra != nil {
|
if c.Extra != nil {
|
||||||
extra, _ := json.Marshal(c.Extra)
|
extra, _ := json.Marshal(c.Extra)
|
||||||
params.Add("extra", string(extra))
|
params.Add("extra", string(extra))
|
||||||
|
|
|
@ -11,7 +11,6 @@ type BaseResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Request struct {
|
type Request struct {
|
||||||
Package string //安装包的包名
|
|
||||||
Channel string //安装包的渠道
|
Channel string //安装包的渠道
|
||||||
Version string //安装包版本
|
Version string //安装包版本
|
||||||
Os string //手机系统类别 android、ioss
|
Os string //手机系统类别 android、ioss
|
||||||
|
@ -25,11 +24,9 @@ type Request struct {
|
||||||
Paid string //客户端的广告id,ios时候有效(百度特有)
|
Paid string //客户端的广告id,ios时候有效(百度特有)
|
||||||
Oaid string //客户端的广告id,android时有效
|
Oaid string //客户端的广告id,android时有效
|
||||||
Imei string //设备唯一识别码
|
Imei string //设备唯一识别码
|
||||||
Did string //设备唯一识别码,android是android_id,ios是idfv
|
|
||||||
OsVersion string //操作系统版本号
|
OsVersion string //操作系统版本号
|
||||||
Extra map[string]string //其他额外数据
|
Extra map[string]string //其他额外数据
|
||||||
Active bool // 是否直接激活
|
Active bool // 是否直接激活
|
||||||
ActiveTime string //用户真实激活时间
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Result struct {
|
type Result struct {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.u8t.cn/open/gosdk/util"
|
"git.u8t.cn/open/gosdk/util"
|
||||||
"net/url"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -177,7 +176,7 @@ func (p *Pay) RefundOrder(req *RefundOrderReq) error {
|
||||||
errors.New("outTradeNo is nil")
|
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{
|
result, err := util.HttpDelete(reqUrl, map[string]string{
|
||||||
"x-token": p.token,
|
"x-token": p.token,
|
||||||
})
|
})
|
||||||
|
@ -201,7 +200,7 @@ func (p *Pay) RefundPartnerOrder(req *RefundOrderReq) error {
|
||||||
errors.New("outTradeNo is nil")
|
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{
|
result, err := util.HttpDelete(reqUrl, map[string]string{
|
||||||
"x-token": p.token,
|
"x-token": p.token,
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,7 +15,6 @@ const (
|
||||||
accessTokenUrl string = "https://api.weixin.qq.com/cgi-bin/token"
|
accessTokenUrl string = "https://api.weixin.qq.com/cgi-bin/token"
|
||||||
userPhoneNumberUrl string = "https://api.weixin.qq.com/wxa/business/getuserphonenumber"
|
userPhoneNumberUrl string = "https://api.weixin.qq.com/wxa/business/getuserphonenumber"
|
||||||
getWxACodeUnLimitUrl string = "https://api.weixin.qq.com/wxa/getwxacodeunlimit"
|
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"
|
code2UserinfoUrl string = "https://api.weixin.qq.com/sns/userinfo"
|
||||||
oaQrCodeCreateUrl string = "https://api.weixin.qq.com/cgi-bin/qrcode/create"
|
oaQrCodeCreateUrl string = "https://api.weixin.qq.com/cgi-bin/qrcode/create"
|
||||||
userInfoByOpenid string = "https://api.weixin.qq.com/cgi-bin/user/info"
|
userInfoByOpenid string = "https://api.weixin.qq.com/cgi-bin/user/info"
|
||||||
|
|
|
@ -108,43 +108,3 @@ func (o *MpSdk) GetUnlimitedQRCode(params map[string]interface{}) ([]byte, error
|
||||||
|
|
||||||
return body, nil
|
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
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue