From a6de6bb37905b437692a3eab9b0cfd3e9e7a2631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Thu, 30 Dec 2021 15:55:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=9C=E6=96=B9=E7=89=A9?= =?UTF-8?q?=E8=81=94=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/eastiot/Iot_api.get_all_sim_type.go | 37 +++++ service/eastiot/Iot_api.go | 142 ------------------ .../eastiot/Iot_api.query_ordered_pkgInfo.go | 46 ++++++ service/eastiot/Iot_api.query_sim_pkgInfo.go | 53 +++++++ service/eastiot/Iot_api.query_user_pkgInfo.go | 47 ++++++ service/eastiot/Iot_api.recharge_sim.go | 34 +++++ service/eastiot/lot_api.query_user_balance.go | 35 +++++ 7 files changed, 252 insertions(+), 142 deletions(-) create mode 100644 service/eastiot/Iot_api.get_all_sim_type.go delete mode 100644 service/eastiot/Iot_api.go create mode 100644 service/eastiot/Iot_api.query_ordered_pkgInfo.go create mode 100644 service/eastiot/Iot_api.query_sim_pkgInfo.go create mode 100644 service/eastiot/Iot_api.query_user_pkgInfo.go create mode 100644 service/eastiot/Iot_api.recharge_sim.go create mode 100644 service/eastiot/lot_api.query_user_balance.go diff --git a/service/eastiot/Iot_api.get_all_sim_type.go b/service/eastiot/Iot_api.get_all_sim_type.go new file mode 100644 index 00000000..ed4aac82 --- /dev/null +++ b/service/eastiot/Iot_api.get_all_sim_type.go @@ -0,0 +1,37 @@ +package eastiot + +import ( + "encoding/json" + "net/http" +) + +type IotApiGetAllSimTypeResponse struct { + Code int `json:"code"` + Data []struct { + Type int `json:"type"` // 卡类型 + Name string `json:"name"` // 类型名 + MOrder int `json:"mOrder"` // 是否支持单次充值多个流量包,0:不支持 1:支持 + } `json:"data"` + Msg string `json:"msg"` +} + +type IotApiGetAllSimTypeResult struct { + Result IotApiGetAllSimTypeResponse // 结果 + Body []byte // 内容 + Err error // 错误 +} + +func NewIotApiGetAllSimTypeResult(result IotApiGetAllSimTypeResponse, body []byte, err error) *IotApiGetAllSimTypeResult { + return &IotApiGetAllSimTypeResult{Result: result, Body: body, Err: err} +} + +// IotApiGetAllSimType 卡类型列表查询 +// https://www.showdoc.com.cn/916774523755909/4858492092033167 +func (app *App) IotApiGetAllSimType() *IotApiGetAllSimTypeResult { + // 请求 + body, err := app.request("http://m2m.eastiot.net/Api/IotApi/getAllSimType", map[string]interface{}{}, http.MethodPost) + // 定义 + var response IotApiGetAllSimTypeResponse + err = json.Unmarshal(body, &response) + return NewIotApiGetAllSimTypeResult(response, body, err) +} diff --git a/service/eastiot/Iot_api.go b/service/eastiot/Iot_api.go deleted file mode 100644 index aceedcbb..00000000 --- a/service/eastiot/Iot_api.go +++ /dev/null @@ -1,142 +0,0 @@ -package eastiot - -import "net/http" - -// IotApiQueryUserBalanceResult 返回参数 -type IotApiQueryUserBalanceResult struct { - Code int `json:"code"` - Data struct { - Balance float64 `json:"balance"` - } `json:"data"` - Msg string `json:"msg"` -} - -// IotApiQueryUserBalance 余额查询 -// https://www.showdoc.com.cn/916774523755909/4857910459512420 -func (app *App) IotApiQueryUserBalance() (body []byte, err error) { - // 请求 - body, err = app.request("http://m2m.eastiot.net/Api/IotApi/queryUserBalance", map[string]interface{}{}, http.MethodPost) - return body, err -} - -type IotApiGetAllSimTypeResult struct { - Code int `json:"code"` - Data []struct { - Type int `json:"type"` // 卡类型 - Name string `json:"name"` // 类型名 - MOrder int `json:"mOrder"` // 是否支持单次充值多个流量包,0:不支持 1:支持 - } `json:"data"` - Msg string `json:"msg"` -} - -// IotApiGetAllSimType 卡类型列表查询 -// https://www.showdoc.com.cn/916774523755909/4858492092033167 -func (app *App) IotApiGetAllSimType() (body []byte, err error) { - // 请求 - body, err = app.request("http://m2m.eastiot.net/Api/IotApi/getAllSimType", map[string]interface{}{}, http.MethodPost) - return body, err -} - -type IotApiQueryUserPkgInfoResult struct { - Code int `json:"code"` - Data []struct { - Type int `json:"type"` - PkgId int64 `json:"pkgId"` - PkgName string `json:"pkgName"` - Price float64 `json:"price"` - Sprice float64 `json:"sprice"` - Traffic int `json:"traffic"` - Caltype int `json:"caltype"` - SimType int `json:"simType"` - Isdm int `json:"isdm"` - Isnm int `json:"isnm"` - Istest int `json:"istest"` - Isimm int `json:"isimm"` - Daynum int `json:"daynum"` - } `json:"data"` - Msg string `json:"msg"` -} - -// IotApiQueryUserPkgInfo 账户可用流量包查询 -// https://www.showdoc.com.cn/916774523755909/4850094776758927 -func (app *App) IotApiQueryUserPkgInfo() (body []byte, err error) { - // 请求 - body, err = app.request("http://m2m.eastiot.net/Api/IotApi/queryUserPkgInfo", map[string]interface{}{}, http.MethodPost) - return body, err -} - -type IotApiRechargeSimResult struct { - Code int `json:"code"` - Msg string `json:"msg"` -} - -// IotApiRechargeSim 单卡流量充值 -// https://www.showdoc.com.cn/916774523755909/4880284631482420 -func (app *App) IotApiRechargeSim(notMustParams ...Params) (body []byte, err error) { - // 参数 - params := app.NewParamsWith(notMustParams...) - // 请求 - body, err = app.request("http://m2m.eastiot.net/Api/IotApi/rechargeSim", params, http.MethodPost) - return body, err -} - -type IotApiQuerySimPkgInfoResult struct { - Code int `json:"code"` - Istest int `json:"istest"` - Data []struct { - PkgId int `json:"pkgId"` // 流量包ID - PkgName string `json:"pkgName"` // 流量包名字 - Price float64 `json:"price"` // 流量包成本价格,单位: 元 - Sprice float64 `json:"sprice"` // 流量包零售价格,单位: 元 - Traffic int `json:"traffic"` // 流量包大小,单位: MB - Type int `json:"type"` // 流量包类型,1:叠加包 2:单月套餐 3:季度套餐 4:半年套餐 5:全年套餐 6:每月套餐 (3个月) 7:每月套餐(6个月) 8:每月套餐(12个月) 0:N天套餐 - Isdm int `json:"isdm"` // 是否依赖主套餐,此字段只有套餐类型为叠加包时有效; 1:依赖主套餐 0:独立 - Isnm int `json:"isnm"` // 是否支持次月生效,此字段只有套餐类型为独立叠加包时有效; 1:支持 0:不支持 - Istest int `json:"istest"` // 是否为体验包; 1:是 0:否 - Isimm int `json:"isimm"` // 订购后是否立即叠加生效; 1:是 0:否 - Stime string `json:"stime"` // 套餐的生效起始日期 - Etime string `json:"etime"` // 套餐的生效结束日期 - Daynum int `json:"daynum"` // 当type=0时,表示套餐有效天数;当type=8 且 daynum>0 时,表示套餐的有效年数 - } `json:"data"` - Msg string `json:"msg"` -} - -// IotApiQuerySimPkgInfo 流量卡可用流量包查询 -// https://www.showdoc.com.cn/916774523755909/4880284631482420 -func (app *App) IotApiQuerySimPkgInfo(simId string, sd int) (body []byte, err error) { - // 参数 - param := NewParams() - param.Set("simId", simId) - param.Set("sd", sd) - params := app.NewParamsWith(param) - // 请求 - body, err = app.request("http://m2m.eastiot.net/Api/IotApi/querySimPkgInfo", params, http.MethodPost) - return body, err -} - -type IotApiQueryOrderedPkgInfoResult struct { - Code int `json:"code"` - Istest int `json:"istest"` - Data []struct { - Name string `json:"name"` // 流量包名字 - PkgId int64 `json:"pkgId"` // 流量包ID - Traffic int `json:"traffic"` // 流量大小,单位:MB - Ntraffic float64 `json:"ntraffic"` // 已用量,单位:MB - Starttime int `json:"starttime"` // 流量生效起始时间时间戳 - Endtime int `json:"endtime"` // 流量生效结束时间时间戳 - Addtime int `json:"addtime"` // 订购时间时间戳 - } `json:"data"` - Msg string `json:"msg"` -} - -// IotApiQueryOrderedPkgInfo 查询流量卡已订购流量包 -// https://www.showdoc.com.cn/916774523755909/5092045889939625 -func (app *App) IotApiQueryOrderedPkgInfo(simId string) (body []byte, err error) { - // 参数 - param := NewParams() - param.Set("simId", simId) - params := app.NewParamsWith(param) - // 请求 - body, err = app.request("http://m2m.eastiot.net/Api/IotApi/queryOrderedPkgInfo", params, http.MethodPost) - return body, err -} diff --git a/service/eastiot/Iot_api.query_ordered_pkgInfo.go b/service/eastiot/Iot_api.query_ordered_pkgInfo.go new file mode 100644 index 00000000..759319b4 --- /dev/null +++ b/service/eastiot/Iot_api.query_ordered_pkgInfo.go @@ -0,0 +1,46 @@ +package eastiot + +import ( + "encoding/json" + "net/http" +) + +type IotApiQueryOrderedPkgInfoResponse struct { + Code int `json:"code"` + Istest int `json:"istest"` + Data []struct { + Name string `json:"name"` // 流量包名字 + PkgId int64 `json:"pkgId"` // 流量包ID + Traffic int `json:"traffic"` // 流量大小,单位:MB + Ntraffic float64 `json:"ntraffic"` // 已用量,单位:MB + Starttime int `json:"starttime"` // 流量生效起始时间时间戳 + Endtime int `json:"endtime"` // 流量生效结束时间时间戳 + Addtime int `json:"addtime"` // 订购时间时间戳 + } `json:"data"` + Msg string `json:"msg"` +} + +type IotApiQueryOrderedPkgInfoResult struct { + Result IotApiQueryOrderedPkgInfoResponse // 结果 + Body []byte // 内容 + Err error // 错误 +} + +func NewIotApiQueryOrderedPkgInfoResult(result IotApiQueryOrderedPkgInfoResponse, body []byte, err error) *IotApiQueryOrderedPkgInfoResult { + return &IotApiQueryOrderedPkgInfoResult{Result: result, Body: body, Err: err} +} + +// IotApiQueryOrderedPkgInfo 查询流量卡已订购流量包 +// https://www.showdoc.com.cn/916774523755909/5092045889939625 +func (app *App) IotApiQueryOrderedPkgInfo(simId string) *IotApiQueryOrderedPkgInfoResult { + // 参数 + param := NewParams() + param.Set("simId", simId) + params := app.NewParamsWith(param) + // 请求 + body, err := app.request("http://m2m.eastiot.net/Api/IotApi/queryOrderedPkgInfo", params, http.MethodPost) + // 定义 + var response IotApiQueryOrderedPkgInfoResponse + err = json.Unmarshal(body, &response) + return NewIotApiQueryOrderedPkgInfoResult(response, body, err) +} diff --git a/service/eastiot/Iot_api.query_sim_pkgInfo.go b/service/eastiot/Iot_api.query_sim_pkgInfo.go new file mode 100644 index 00000000..27b9286c --- /dev/null +++ b/service/eastiot/Iot_api.query_sim_pkgInfo.go @@ -0,0 +1,53 @@ +package eastiot + +import ( + "encoding/json" + "net/http" +) + +type IotApiQuerySimPkgInfoResponse struct { + Code int `json:"code"` + Istest int `json:"istest"` + Data []struct { + PkgId int `json:"pkgId"` // 流量包ID + PkgName string `json:"pkgName"` // 流量包名字 + Price float64 `json:"price"` // 流量包成本价格,单位: 元 + Sprice float64 `json:"sprice"` // 流量包零售价格,单位: 元 + Traffic int `json:"traffic"` // 流量包大小,单位: MB + Type int `json:"type"` // 流量包类型,1:叠加包 2:单月套餐 3:季度套餐 4:半年套餐 5:全年套餐 6:每月套餐 (3个月) 7:每月套餐(6个月) 8:每月套餐(12个月) 0:N天套餐 + Isdm int `json:"isdm"` // 是否依赖主套餐,此字段只有套餐类型为叠加包时有效; 1:依赖主套餐 0:独立 + Isnm int `json:"isnm"` // 是否支持次月生效,此字段只有套餐类型为独立叠加包时有效; 1:支持 0:不支持 + Istest int `json:"istest"` // 是否为体验包; 1:是 0:否 + Isimm int `json:"isimm"` // 订购后是否立即叠加生效; 1:是 0:否 + Stime string `json:"stime"` // 套餐的生效起始日期 + Etime string `json:"etime"` // 套餐的生效结束日期 + Daynum int `json:"daynum"` // 当type=0时,表示套餐有效天数;当type=8 且 daynum>0 时,表示套餐的有效年数 + } `json:"data"` + Msg string `json:"msg"` +} + +type IotApiQuerySimPkgInfoResult struct { + Result IotApiQuerySimPkgInfoResponse // 结果 + Body []byte // 内容 + Err error // 错误 +} + +func NewIotApiQuerySimPkgInfoResult(result IotApiQuerySimPkgInfoResponse, body []byte, err error) *IotApiQuerySimPkgInfoResult { + return &IotApiQuerySimPkgInfoResult{Result: result, Body: body, Err: err} +} + +// IotApiQuerySimPkgInfo 流量卡可用流量包查询 +// https://www.showdoc.com.cn/916774523755909/4880284631482420 +func (app *App) IotApiQuerySimPkgInfo(simId string, sd int) *IotApiQuerySimPkgInfoResult { + // 参数 + param := NewParams() + param.Set("simId", simId) + param.Set("sd", sd) + params := app.NewParamsWith(param) + // 请求 + body, err := app.request("http://m2m.eastiot.net/Api/IotApi/querySimPkgInfo", params, http.MethodPost) + // 定义 + var response IotApiQuerySimPkgInfoResponse + err = json.Unmarshal(body, &response) + return NewIotApiQuerySimPkgInfoResult(response, body, err) +} diff --git a/service/eastiot/Iot_api.query_user_pkgInfo.go b/service/eastiot/Iot_api.query_user_pkgInfo.go new file mode 100644 index 00000000..78088610 --- /dev/null +++ b/service/eastiot/Iot_api.query_user_pkgInfo.go @@ -0,0 +1,47 @@ +package eastiot + +import ( + "encoding/json" + "net/http" +) + +type IotApiQueryUserPkgInfoResponse struct { + Code int `json:"code"` + Data []struct { + Type int `json:"type"` + PkgId int64 `json:"pkgId"` + PkgName string `json:"pkgName"` + Price float64 `json:"price"` + Sprice float64 `json:"sprice"` + Traffic int `json:"traffic"` + Caltype int `json:"caltype"` + SimType int `json:"simType"` + Isdm int `json:"isdm"` + Isnm int `json:"isnm"` + Istest int `json:"istest"` + Isimm int `json:"isimm"` + Daynum int `json:"daynum"` + } `json:"data"` + Msg string `json:"msg"` +} + +type IotApiQueryUserPkgInfoResult struct { + Result IotApiQueryUserPkgInfoResponse // 结果 + Body []byte // 内容 + Err error // 错误 +} + +func NewIotApiQueryUserPkgInfoResult(result IotApiQueryUserPkgInfoResponse, body []byte, err error) *IotApiQueryUserPkgInfoResult { + return &IotApiQueryUserPkgInfoResult{Result: result, Body: body, Err: err} +} + +// IotApiQueryUserPkgInfo 账户可用流量包查询 +// https://www.showdoc.com.cn/916774523755909/4850094776758927 +func (app *App) IotApiQueryUserPkgInfo() *IotApiQueryUserPkgInfoResult { + // 请求 + body, err := app.request("http://m2m.eastiot.net/Api/IotApi/queryUserPkgInfo", map[string]interface{}{}, http.MethodPost) + // 定义 + var response IotApiQueryUserPkgInfoResponse + err = json.Unmarshal(body, &response) + return NewIotApiQueryUserPkgInfoResult(response, body, err) +} diff --git a/service/eastiot/Iot_api.recharge_sim.go b/service/eastiot/Iot_api.recharge_sim.go new file mode 100644 index 00000000..bf661a02 --- /dev/null +++ b/service/eastiot/Iot_api.recharge_sim.go @@ -0,0 +1,34 @@ +package eastiot + +import ( + "encoding/json" + "net/http" +) + +type IotApiRechargeSimResponse struct { + Code int `json:"code"` + Msg string `json:"msg"` +} + +type IotApiRechargeSimResult struct { + Result IotApiRechargeSimResponse // 结果 + Body []byte // 内容 + Err error // 错误 +} + +func NewIotApiRechargeSimResult(result IotApiRechargeSimResponse, body []byte, err error) *IotApiRechargeSimResult { + return &IotApiRechargeSimResult{Result: result, Body: body, Err: err} +} + +// IotApiRechargeSim 单卡流量充值 +// https://www.showdoc.com.cn/916774523755909/4880284631482420 +func (app *App) IotApiRechargeSim(notMustParams ...Params) *IotApiRechargeSimResult { + // 参数 + params := app.NewParamsWith(notMustParams...) + // 请求 + body, err := app.request("http://m2m.eastiot.net/Api/IotApi/rechargeSim", params, http.MethodPost) + // 定义 + var response IotApiRechargeSimResponse + err = json.Unmarshal(body, &response) + return NewIotApiRechargeSimResult(response, body, err) +} diff --git a/service/eastiot/lot_api.query_user_balance.go b/service/eastiot/lot_api.query_user_balance.go new file mode 100644 index 00000000..4e825fe8 --- /dev/null +++ b/service/eastiot/lot_api.query_user_balance.go @@ -0,0 +1,35 @@ +package eastiot + +import ( + "encoding/json" + "net/http" +) + +type IotApiQueryUserBalanceResponse struct { + Code int `json:"code"` + Data struct { + Balance float64 `json:"balance"` + } `json:"data"` + Msg string `json:"msg"` +} + +type IotApiQueryUserBalanceResult struct { + Result IotApiQueryUserBalanceResponse // 结果 + Body []byte // 内容 + Err error // 错误 +} + +func NewIotApiQueryUserBalanceResult(result IotApiQueryUserBalanceResponse, body []byte, err error) *IotApiQueryUserBalanceResult { + return &IotApiQueryUserBalanceResult{Result: result, Body: body, Err: err} +} + +// IotApiQueryUserBalance 余额查询 +// https://www.showdoc.com.cn/916774523755909/4857910459512420 +func (app *App) IotApiQueryUserBalance() *IotApiQueryUserBalanceResult { + // 请求 + body, err := app.request("http://m2m.eastiot.net/Api/IotApi/queryUserBalance", map[string]interface{}{}, http.MethodPost) + // 定义 + var response IotApiQueryUserBalanceResponse + err = json.Unmarshal(body, &response) + return NewIotApiQueryUserBalanceResult(response, body, err) +}