Commit ebd6fd46 by zhangjie

1. TCP没分离的版本

parent 7cfe5f2a
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="Go" enabled="true">
<buildTags>
<option name="customFlags">
<array>
<option value="debug" />
</array>
</option>
</buildTags>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
......
c18e885783a60274ab3edc848f6ef538
\ No newline at end of file
......@@ -150,10 +150,13 @@ func CardBind(c *gin.Context) {
// 操作数据库
if dbcurd.UpdateUSimInfoCardUserID(reqData.Code, cardUserID) {
// 写 cardUserMap
if cache.UpdateCardUserMap(cardUserID, &model.CacheUpdateCardUserStruct{
if !cache.UpdateCardUserMap(cardUserID, &model.CacheUpdateCardUserStruct{
SimCardID: &reqData.Code,
}) {
fmt.Println("CardBind 写缓存失败", cardUserID, reqData.Code)
logger.Log.Error("CardBind 写缓存失败",
zap.Uint32("simInfo.cardUserID", cardUserID),
zap.String("reqData.Code", reqData.Code))
}
if cache.UpdateSimInfo(reqData.Code, &model.CacheUpdateSimInfoStruct{CardUserID: &cardUserID}) {
......
......@@ -27,7 +27,7 @@ func Qr2CardID(c *gin.Context) {
return
}
cardID,err := util.DecryptBase64URLToBytes(qrCode, "keyQR123@dcrym01")
cardID, err := util.DecryptBase64URLToBytes(qrCode, "keyQR123@dcrym01")
if err != nil {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorReqPara,
......@@ -36,10 +36,10 @@ func Qr2CardID(c *gin.Context) {
return
}
for i:=0;i<26;i++ {
for i := 0; i < 26; i++ {
cardID[i] -= uint8(i)%3 + 0x18
}
cardID[11],cardID[25],cardID[20],cardID[22],cardID[9],cardID[24],cardID[21],cardID[12],cardID[0] = cardID[0],cardID[9],cardID[11],cardID[12],cardID[20],cardID[21],cardID[22],cardID[24],cardID[25]
cardID[11], cardID[25], cardID[20], cardID[22], cardID[9], cardID[24], cardID[21], cardID[12], cardID[0] = cardID[0], cardID[9], cardID[11], cardID[12], cardID[20], cardID[21], cardID[22], cardID[24], cardID[25]
if cardID[20] != 0x16 || cardID[21] != 0x11 || cardID[22] != 0x03 || !util.CheckCRC(cardID) {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorReqPara,
......@@ -55,14 +55,13 @@ func Qr2CardID(c *gin.Context) {
}
// CardID2Qr 根据卡号返回二维码
// @Tags 家长微信-卡操作
// @Tags 测试用
// @Summary 根据卡号返回二维码[complete]-测试用,正式上线此接口关闭或移至后台管理系统
// @Description 根据卡号返回二维码
// @Produce json
// @Param cardid path string true "cardID"
// @Success 0 {object} string "卡号"
// @Router /we/cardid2qr/{cardid} [GET]
// @Security ApiKeyAuth
// @Router /test/cardid2qr/{cardid} [GET]
func CardID2Qr(c *gin.Context) {
cardID := []byte(c.Param("cardid"))
if len(cardID) != 20 {
......@@ -72,10 +71,10 @@ func CardID2Qr(c *gin.Context) {
})
return
}
cardID = append(cardID,[]byte{0x16,0x11,0x03,uint8(time.Now().UnixNano()),0,0}...)
util.GetCRC(cardID,24)
cardID[0],cardID[9],cardID[11],cardID[12],cardID[20],cardID[21],cardID[22],cardID[24],cardID[25] = cardID[11],cardID[25],cardID[20],cardID[22],cardID[9],cardID[24],cardID[21],cardID[12],cardID[0]
for i:=0;i<26;i++ {
cardID = append(cardID, []byte{0x16, 0x11, 0x03, uint8(time.Now().UnixNano()), 0, 0}...)
util.GetCRC(cardID, 24)
cardID[0], cardID[9], cardID[11], cardID[12], cardID[20], cardID[21], cardID[22], cardID[24], cardID[25] = cardID[11], cardID[25], cardID[20], cardID[22], cardID[9], cardID[24], cardID[21], cardID[12], cardID[0]
for i := 0; i < 26; i++ {
cardID[i] += uint8(i)%3 + 0x18
}
......@@ -83,4 +82,4 @@ func CardID2Qr(c *gin.Context) {
"code": api.Success,
"data": util.EncryptBytesToBase64URL(cardID, "keyQR123@dcrym01"),
})
}
\ No newline at end of file
}
......@@ -16,10 +16,11 @@ const tokenExpiryTimeS = uint32(48 * 3600)
type weLoginRes struct {
// weUserListStruct
WePhone bool `json:"wePhone"` // 是否已获取到微信电话,为false则需要获取
WeInfo bool `json:"weInfo"` // 是否已获取到微信用户信息,为false则需要获取
Token string `json:"token"`
Expiry uint32 `json:"expiry"` //到期时间,10位时间戳
WePhone bool `json:"wePhone"` // 是否已获取到微信电话,为false则需要获取
Nickname *string `json:"nickname"` // 如果为null就是需要用户授权
Avatar *string `json:"avatar"` // 头像地址
Token string `json:"token"`
Expiry uint32 `json:"expiry"` //到期时间,10位时间戳
}
type weLoginReq struct {
......@@ -64,7 +65,7 @@ func WeLogin(c *gin.Context) {
weUserInfo = cache.GetWeUserInfoFromMapAndDB(weUserID) //cache.GetWechatCustomerInfoAndCacheUpdateTokenTime(weUserID, nowTime)
cache.WechatCustomerTokenCreateTime.Store(weUserID, nowTime)
if weUserInfo != nil {
dbcurd.UpdateUWeCustomerLoginTime(weUserID) // todo 改成每天半夜来记录
dbcurd.UpdateUWeCustomerLoginTime(weUserID) // todoN 改成每天半夜来记录
}
}
......@@ -108,7 +109,7 @@ func WeLogin(c *gin.Context) {
weUserInfo = cache.GetWeUserInfoFromMapAndDB(weUserID)
cache.WechatCustomerTokenCreateTime.Store(weUserID, nowTime)
if weUserInfo != nil {
dbcurd.UpdateUWeCustomerLoginTime(weUserID) // todo 改成每天半夜来记录
dbcurd.UpdateUWeCustomerLoginTime(weUserID) // todoN 改成每天半夜来记录
} else {
fmt.Println(time.Now(), "严重错误:微信用户ID", unionID, weUserID, "在WechatCustomerUnionIDToIDMAP有,而其他地方没有,已删除")
cache.WechatCustomerUnionIDToIDMAP.Delete(unionID)
......@@ -144,8 +145,12 @@ func WeLogin(c *gin.Context) {
res.WePhone = true
}
if len(weUserInfo.Nickname) > 0 /* && len(weUserInfo.AvatarURL) > 0 */ { // 有些人本来就没得头像
res.WeInfo = true
if len(weUserInfo.Nickname) > 0 { // 有些人本来就没得头像
res.Nickname = &weUserInfo.Nickname
}
if len(weUserInfo.AvatarURL) > 0 {
res.Avatar = &weUserInfo.AvatarURL
}
c.JSON(http.StatusOK, gin.H{
......
......@@ -47,14 +47,14 @@ func WeLoginTest(c *gin.Context) {
var weUserInfo *model.CacheWeCustomerStruct
if weUserID != 0 {
weUserInfo = cache.GetWeUserInfoFromMapAndDB(weUserID) //cache.GetWechatCustomerInfoAndCacheUpdateTokenTime(weUserID, nowTime)
cache.WechatCustomerTokenCreateTime.Store(weUserID,nowTime)
cache.WechatCustomerTokenCreateTime.Store(weUserID, nowTime)
if weUserInfo != nil {
dbcurd.UpdateUWeCustomerLoginTime(weUserID) // todo 改成每天半夜来记录
}
}
if weUserInfo == nil { // 微信服务器登录
unionID,openID,_ := tencent.WechatCode2SessionTest(reqData.Code) //也不去校验reqData.Code长度了,多半是对的
unionID, openID, _ := tencent.WechatCode2SessionTest(reqData.Code) //也不去校验reqData.Code长度了,多半是对的
if len(unionID) == 0 {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorTencentErr,
......@@ -65,7 +65,7 @@ func WeLoginTest(c *gin.Context) {
weUserID = cache.GetWechatCustomerUserIDByUnionID(unionID)
if weUserID == 0 { // 原来没有,只有注册
var res uint8
weUserID, res = dbcurd.InsertUWeCustomerUnionID(unionID,openID) //插入
weUserID, res = dbcurd.InsertUWeCustomerUnionID(unionID, openID) //插入
if res == dbcurd.InsertSysErr {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorSystemBusy,
......@@ -88,14 +88,14 @@ func WeLoginTest(c *gin.Context) {
}
cache.CreatWechatCustomerMap(weUserID, weUserInfo) //cache.wechatCustomerMap.Store(weUserID, *weUserInfo)
cache.WechatCustomerUnionIDToIDMAP.Store(unionID, weUserID)
cache.WechatCustomerTokenCreateTime.Store(weUserID,nowTime)
cache.WechatCustomerTokenCreateTime.Store(weUserID, nowTime)
} else { // 已有用户
weUserInfo = cache.GetWeUserInfoFromMapAndDB(weUserID)
cache.WechatCustomerTokenCreateTime.Store(weUserID,nowTime)
cache.WechatCustomerTokenCreateTime.Store(weUserID, nowTime)
if weUserInfo != nil {
dbcurd.UpdateUWeCustomerLoginTime(weUserID) //todo 改成每天半夜来记录
} else {
fmt.Println(time.Now(), "严重错误:微信用户ID",unionID, weUserID, "在WechatCustomerUnionIDToIDMAP有,而其他地方没有,已删除")
fmt.Println(time.Now(), "严重错误:微信用户ID", unionID, weUserID, "在WechatCustomerUnionIDToIDMAP有,而其他地方没有,已删除")
cache.WechatCustomerUnionIDToIDMAP.Delete(unionID)
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorSystemErr,
......@@ -129,8 +129,12 @@ func WeLoginTest(c *gin.Context) {
res.WePhone = true
}
if len(weUserInfo.Nickname)>0 && len(weUserInfo.AvatarURL) > 0 {
res.WeInfo = true
if len(weUserInfo.Nickname) > 0 { // 有些人本来就没得头像
res.Nickname = &weUserInfo.Nickname
}
if len(weUserInfo.AvatarURL) > 0 {
res.Avatar = &weUserInfo.AvatarURL
}
c.JSON(http.StatusOK, gin.H{
......
......@@ -97,7 +97,7 @@ func AddFamilyNum(c *gin.Context) {
http.StatusOK,
gin.H{
"code": api.ErrorUserNotHavePhoneCard,
"message": api.CodeMsg[api.ErrorUserNotHavePhoneCard] + ",请先绑定话卡",
"message": api.CodeMsg[api.ErrorUserNotHavePhoneCard] + ",请先绑定话卡",
},
)
return
......@@ -133,13 +133,14 @@ func AddFamilyNum(c *gin.Context) {
}
}
// 找移动添加亲情号
if err = chinamobile.AddMemberVoiceWhiteList(cardUserInfo.SimCardID, reqData.Phone); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorSystemBusy,
"message": err.Error(),
})
return
if simInfoP.Type == 1 { // 找移动添加亲情号
if err = chinamobile.AddMemberVoiceWhiteList(cardUserInfo.SimCardID, reqData.Phone); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorSystemBusy,
"message": err.Error(),
})
return
}
}
// 写库
......
......@@ -101,8 +101,8 @@ func AddFamilyNumTest(c *gin.Context) {
c.JSON(
http.StatusOK,
gin.H{
"code": api.ErrorUserNotHavePhoneCard,
"message": api.CodeMsg[api.ErrorUserNotHavePhoneCard] + ",请先绑定话卡",
"code": api.ErrorUserNotHavePhoneCard,
"message": api.CodeMsg[api.ErrorUserNotHavePhoneCard] + ",请先绑定话卡",
},
)
return
......@@ -119,10 +119,10 @@ func AddFamilyNumTest(c *gin.Context) {
}
if len(simInfoP.FamilyNum) >= setting.MaxFamilyNum {
fmt.Println("居然已经>=" ,setting.MaxFamilyNum , "个号了还在添加", cardUserInfo.SimCardID, simInfoP)
fmt.Println("居然已经>=", setting.MaxFamilyNum, "个号了还在添加", cardUserInfo.SimCardID, simInfoP)
c.JSON(http.StatusOK, gin.H{
"code": api.ErrorReqPara,
"message": "一张卡最多可绑定" + strconv.FormatUint(uint64(setting.MaxFamilyNum),10) + "个亲情号码,请删除一个已有的再添加",
"message": "一张卡最多可绑定" + strconv.FormatUint(uint64(setting.MaxFamilyNum), 10) + "个亲情号码,请删除一个已有的再添加",
})
return
}
......
......@@ -63,7 +63,7 @@ func DeleteFamilyNum(c *gin.Context) {
http.StatusOK,
gin.H{
"code": api.ErrorUserNotHavePhoneCard,
"message": api.CodeMsg[api.ErrorUserNotHavePhoneCard] + ",请先绑定话卡",
"message": api.CodeMsg[api.ErrorUserNotHavePhoneCard] + ",请先绑定话卡",
},
)
return
......
......@@ -60,7 +60,7 @@ func PutFamilyNickName(c *gin.Context) {
http.StatusOK,
gin.H{
"code": api.ErrorUserNotHavePhoneCard,
"message": api.CodeMsg[api.ErrorUserNotHavePhoneCard] + ",请先绑定话卡",
"message": api.CodeMsg[api.ErrorUserNotHavePhoneCard] + ",请先绑定话卡",
},
)
return
......
//go:build !debug
// +build !debug
package router
func swaggerInit(interface{}) {
}
......@@ -11,15 +11,12 @@ import (
"dc_golang_server_1/api/api_we/api_we_slave"
"dc_golang_server_1/api/api_we/api_we_student"
"dc_golang_server_1/dev_product/dcphone20"
_ "dc_golang_server_1/docs"
"dc_golang_server_1/logger"
"dc_golang_server_1/thirdapi/allinpay"
"dc_golang_server_1/util/setting"
"fmt"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
"github.com/unrolled/secure"
"time"
)
......@@ -86,8 +83,10 @@ func InitRouter() { //*gin.Engine{
r.Use(TlsHandler())
// }
swaggerInit(r)
// if setting.HttpServerSwagger {
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
//r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
//r.StaticFS("/log", gin.Dir(setting.LogPath, true))
//
//fmt.Println(setting.HttpServerMainHost + setting.HttpServerPort + "/swagger/index.html")
......@@ -108,6 +107,9 @@ func InitRouter() { //*gin.Engine{
r.POST("we/login", api_we_login_we_info.WeLogin)
r.POST("we/logintest", api_we_login_we_info.WeLoginTest)
r.GET("test/cardid2qr/:cardid", api_we_card_operate.CardID2Qr) // CardID2Qr 根据卡号返回二维码,测试用,正式上线此接口关闭或移至后台管理系统
wechat := r.Group("we/").Use(api.JeffWTWechat())
{ // 需要token的stulist
wechat.GET("areaname/:id", api_we_student.GetAreaName) // 根据区域ID查询区域名字
......@@ -134,7 +136,6 @@ func InitRouter() { //*gin.Engine{
wechat.DELETE("slaveweuser/:id", api_we_slave.DeleteSlaveWeUser) //删除副家长(仅主家长有权限)
wechat.GET("qr2cardid/:qrcode", api_we_card_operate.Qr2CardID) // Qr2CardID 根据二维码,返回卡号信息
wechat.GET("cardid2qr/:cardid", api_we_card_operate.CardID2Qr) // CardID2Qr 根据卡号返回二维码,测试用,正式上线此接口关闭或移至后台管理系统
wechat.PUT("cardloss/:id", api_we_card_operate.CardLoss) //卡挂失/解挂
wechat.PUT("cardbind/:id", api_we_card_operate.CardBind) //绑定卡
wechat.DELETE("cardbind/:id", api_we_card_operate.DeleteCardBind) //解绑卡
......
//go:build debug
// +build debug
package router
import (
_ "dc_golang_server_1/docs"
"fmt"
"github.com/gin-gonic/gin"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
)
func swaggerInit(router gin.IRoutes) {
fmt.Println("swagger is true")
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}
set GOARCH=amd64
set GOOS=linux
swag init
go build -o customerServer.new -ldflags "-w -s" main.go
\ No newline at end of file
go build -tags=debug -o z8_output_test/customerServer.new -ldflags "-w -s" main.go
\ No newline at end of file
......@@ -10,9 +10,13 @@ MaxFamilyNum = 2
[database]
#ECS外网
dbDSN = user=postgres password=buzhidao123. dbname=jeff host=60.205.190.129 port=59999 sslmode=disable
#ECS内网
#dbDSN = user=postgres password=buzhidao123. dbname=jeff host=127.0.0.1 port=59999 sslmode=disable
#dbDSN = user=postgres password=buzhidao123. dbname=jeff host=60.205.190.129 port=59999 sslmode=disable
#温江外网
#dbDSN = user=postgres password=xinruo1103 dbname=postgres host=k12t.shero.plus port=3043 sslmode=disable
#温江内网
dbDSN = user=postgres password=xinruo1103 dbname=postgres host=192.168.1.43 port=3030 sslmode=disable
[http_server]
# k12m.dcrym.com
......
......@@ -15,7 +15,7 @@ import (
func initSimInfoMap() { // 查询绑定了校区的有效卡
fmt.Println(time.Now(), "cache: initFamilyNumToSimInfoMap begin")
rows, err := dbcurd.PgDb.Query("SELECT sim_id,card_user_id,area_service_id,month_talk_minutes,month_package_minutes,status,family_delete_count,expiry_at FROM u_sim_info WHERE area_service_id!=0 AND status!=0")
rows, err := dbcurd.PgDb.Query("SELECT sim_id,card_user_id,area_service_id,month_talk_minutes,month_package_minutes,status,family_delete_count,expiry_at,type FROM u_sim_info WHERE area_service_id!=0 AND status!=0")
if err != nil {
log.Panicln("Select u_sim_info To Map rows", err)
}
......@@ -23,7 +23,7 @@ func initSimInfoMap() { // 查询绑定了校区的有效卡
var simID string
var temp model.CacheSimInfoStruct
for rows.Next() {
err = rows.Scan(&simID, &temp.CardUserID, &temp.AreaServiceID, &temp.MonthTalkMinutes, &temp.MonthPackageMinutes, &temp.Status, &temp.FamilyDeleteCount, &temp.ExpiryAt)
err = rows.Scan(&simID, &temp.CardUserID, &temp.AreaServiceID, &temp.MonthTalkMinutes, &temp.MonthPackageMinutes, &temp.Status, &temp.FamilyDeleteCount, &temp.ExpiryAt, &temp.Type)
if err != nil {
log.Panicln("initCardUserMapAndSimInfoMapNoFamilyNum rows.Scan", err)
}
......@@ -158,6 +158,8 @@ func UpdateSimInfo(simID string, newData *model.CacheUpdateSimInfoStruct) bool {
data.FamilyDeleteCount = *newData.FamilyDeleteCount
}
//if newData. todo
simInfoMap.Store(simID, data)
return true
}
......@@ -252,3 +254,10 @@ func CreatSimInfoMap(simId string, data *model.CacheSimInfoStruct) bool {
simInfoMap.Store(simId, *data)
return true //nil
}
// DeleteSimInfoMap 删除sim卡 GRPC调用
func DeleteSimInfoMap(simId []string) {
for _, v := range simId {
simInfoMap.Delete(v)
}
}
......@@ -32,11 +32,11 @@ func InitDb() {
panic("数据库连接失败" + err.Error())
}
//PgDb.SetConnMaxLifetime()
//PgDb.SetConnMaxIdleTime()
//PgDb.SetMaxOpenConns()
//PgDb.SetMaxIdleConns()
//PgDb.Stats()
PgDb.SetConnMaxLifetime(0) // 连接不会因为旧了就关闭了
PgDb.SetConnMaxIdleTime(0) // 空闲连接超时时间,0不超时关闭
PgDb.SetMaxOpenConns(0) // 最大连接数 0 不限制
PgDb.SetMaxIdleConns(10) // 空闲连接数
// PgDb.Stats()
// 硬件通讯流水
stmtInsertDevCommandRecord, err = PgDb.Prepare("INSERT INTO d_command_record(device_id,dev_utc,ctrl_code,data_len,data_hex,ciphertext,direction)VALUES($1,$2,$3,$4,$5,$6,$7)")
......
......@@ -14,14 +14,16 @@ func SelectUSimInfoBySimID(simId string) *model.CacheSimInfoStruct {
var cacheData model.CacheSimInfoStruct
var err error
for i := 0; i < 5; i++ {
err = PgDb.QueryRow("SELECT card_user_id,area_service_id,month_talk_minutes,month_package_minutes,status,expiry_at FROM u_sim_info WHERE sim_id=$1 AND area_service_id!=0 AND status!=0",
err = PgDb.QueryRow("SELECT card_user_id,area_service_id,month_talk_minutes,month_package_minutes,status,family_delete_count,expiry_at,type FROM u_sim_info WHERE sim_id=$1 AND area_service_id!=0 AND status!=0",
simId).Scan(
&cacheData.CardUserID,
&cacheData.AreaServiceID,
&cacheData.MonthTalkMinutes,
&cacheData.MonthPackageMinutes,
&cacheData.Status,
&cacheData.ExpiryAt)
&cacheData.FamilyDeleteCount,
&cacheData.ExpiryAt,
&cacheData.Type)
if err == nil {
return &cacheData
}
......
......@@ -100,6 +100,7 @@ type CacheSimInfoStruct struct {
ExpiryAt time.Time `json:"-"` // 数据库必须非空
FamilyNum []CacheFamilyOnePerson `json:"family"` // 亲情号列表
FamilyDeleteCount int8 `json:"deleteable"` // 本月剩余可删除亲情号次数
Type uint8 `json:"-"` // 0 测试卡(不调任何接口) 1 中移物联网(增删亲情号调接口) 其他预留
}
type CacheFamilyOnePerson struct {
Phone string `json:"phone"` // 必填
......
......@@ -261,7 +261,6 @@ func (dev *DCPhone20) response(data *dev_product.HexData) {
}
case 0x3f: // 0x3f:"ctrl/dev_restart_login",// 开机注册
if data.Length > 75 {
// todoN 考虑第0字节增加模组选择
processDevHexResetRecord(data)
} else {
logger.Log.Error("data.Length error",
......@@ -367,7 +366,7 @@ func (dev *DCPhone20) response(data *dev_product.HexData) {
data.Length = uint8(len(data.Data))
return
}
if s.Status == 0 { // 这张卡不对,显示 未查询到亲情号码
if s.Status == 0 { //
fmt.Println("case 0x60: s.Status==0")
data.Data[0] = 0xff
errMessage := enc.ConvertString("无效卡")
......@@ -547,7 +546,7 @@ func (dev *DCPhone20) response(data *dev_product.HexData) {
if s.MonthTalkMinutes < s.MonthPackageMinutes {
temp = s.MonthPackageMinutes - s.MonthTalkMinutes
}
errMessage := fmt.Sprintf("月套餐:%3d 分钟\n本月剩余:%3d 分钟\n服务到期时间:%s",
errMessage := fmt.Sprintf("月套餐:%3d 分钟\n本月剩余:%3d 分钟\n服务到期时间:%s\n\n\n 请摘下听筒开始拨号",
s.MonthPackageMinutes,
temp,
s.ExpiryAt.Format("2006-01-02"))
......
......@@ -429,6 +429,35 @@ var doc = `{
}
}
},
"/test/cardid2qr/{cardid}": {
"get": {
"description": "根据卡号返回二维码",
"produces": [
"application/json"
],
"tags": [
"测试用"
],
"summary": "根据卡号返回二维码[complete]-测试用,正式上线此接口关闭或移至后台管理系统",
"parameters": [
{
"type": "string",
"description": "cardID",
"name": "cardid",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "卡号",
"schema": {
"type": "string"
}
}
}
}
},
"/we/areaname/{id}": {
"get": {
"security": [
......@@ -750,40 +779,6 @@ var doc = `{
}
}
},
"/we/cardid2qr/{cardid}": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "根据卡号返回二维码",
"produces": [
"application/json"
],
"tags": [
"家长微信-卡操作"
],
"summary": "根据卡号返回二维码[complete]-测试用,正式上线此接口关闭或移至后台管理系统",
"parameters": [
{
"type": "string",
"description": "cardID",
"name": "cardid",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "卡号",
"schema": {
"type": "string"
}
}
}
}
},
"/we/cardloss/{id}": {
"put": {
"security": [
......@@ -1805,16 +1800,20 @@ var doc = `{
"api_we_login_we_info.weLoginRes": {
"type": "object",
"properties": {
"avatar": {
"description": "头像地址",
"type": "string"
},
"expiry": {
"description": "到期时间,10位时间戳",
"type": "integer"
},
"token": {
"nickname": {
"description": "如果为null就是需要用户授权",
"type": "string"
},
"weInfo": {
"description": "是否已获取到微信用户信息,为false则需要获取",
"type": "boolean"
"token": {
"type": "string"
},
"wePhone": {
"description": "weUserListStruct",
......@@ -1838,6 +1837,9 @@ var doc = `{
"api_we_login_we_info.wechatUserBindWePhoneStruct": {
"type": "object",
"properties": {
"SCode": {
"type": "string"
},
"code": {
"type": "string"
},
......
......@@ -414,6 +414,35 @@
}
}
},
"/test/cardid2qr/{cardid}": {
"get": {
"description": "根据卡号返回二维码",
"produces": [
"application/json"
],
"tags": [
"测试用"
],
"summary": "根据卡号返回二维码[complete]-测试用,正式上线此接口关闭或移至后台管理系统",
"parameters": [
{
"type": "string",
"description": "cardID",
"name": "cardid",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "卡号",
"schema": {
"type": "string"
}
}
}
}
},
"/we/areaname/{id}": {
"get": {
"security": [
......@@ -735,40 +764,6 @@
}
}
},
"/we/cardid2qr/{cardid}": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "根据卡号返回二维码",
"produces": [
"application/json"
],
"tags": [
"家长微信-卡操作"
],
"summary": "根据卡号返回二维码[complete]-测试用,正式上线此接口关闭或移至后台管理系统",
"parameters": [
{
"type": "string",
"description": "cardID",
"name": "cardid",
"in": "path",
"required": true
}
],
"responses": {
"0": {
"description": "卡号",
"schema": {
"type": "string"
}
}
}
}
},
"/we/cardloss/{id}": {
"put": {
"security": [
......@@ -1790,16 +1785,20 @@
"api_we_login_we_info.weLoginRes": {
"type": "object",
"properties": {
"avatar": {
"description": "头像地址",
"type": "string"
},
"expiry": {
"description": "到期时间,10位时间戳",
"type": "integer"
},
"token": {
"nickname": {
"description": "如果为null就是需要用户授权",
"type": "string"
},
"weInfo": {
"description": "是否已获取到微信用户信息,为false则需要获取",
"type": "boolean"
"token": {
"type": "string"
},
"wePhone": {
"description": "weUserListStruct",
......@@ -1823,6 +1822,9 @@
"api_we_login_we_info.wechatUserBindWePhoneStruct": {
"type": "object",
"properties": {
"SCode": {
"type": "string"
},
"code": {
"type": "string"
},
......
......@@ -81,14 +81,17 @@ definitions:
type: object
api_we_login_we_info.weLoginRes:
properties:
avatar:
description: 头像地址
type: string
expiry:
description: 到期时间,10位时间戳
type: integer
nickname:
description: 如果为null就是需要用户授权
type: string
token:
type: string
weInfo:
description: 是否已获取到微信用户信息,为false则需要获取
type: boolean
wePhone:
description: weUserListStruct
type: boolean
......@@ -104,6 +107,8 @@ definitions:
type: object
api_we_login_we_info.wechatUserBindWePhoneStruct:
properties:
SCode:
type: string
code:
type: string
encryptedData:
......@@ -801,6 +806,25 @@ paths:
summary: 获取当前系统运行状态
tags:
- 运维-系统状态
/test/cardid2qr/{cardid}:
get:
description: 根据卡号返回二维码
parameters:
- description: cardID
in: path
name: cardid
required: true
type: string
produces:
- application/json
responses:
"0":
description: 卡号
schema:
type: string
summary: 根据卡号返回二维码[complete]-测试用,正式上线此接口关闭或移至后台管理系统
tags:
- 测试用
/we/areaname/{id}:
get:
description: 根据区域ID查询区域名字
......@@ -1005,27 +1029,6 @@ paths:
summary: 绑定卡 [complete]
tags:
- 家长微信-卡操作
/we/cardid2qr/{cardid}:
get:
description: 根据卡号返回二维码
parameters:
- description: cardID
in: path
name: cardid
required: true
type: string
produces:
- application/json
responses:
"0":
description: 卡号
schema:
type: string
security:
- ApiKeyAuth: []
summary: 根据卡号返回二维码[complete]-测试用,正式上线此接口关闭或移至后台管理系统
tags:
- 家长微信-卡操作
/we/cardloss/{id}:
put:
description: 传学生id及卡类型至后台,后台返回成功失败
......
......@@ -8,13 +8,12 @@ require (
github.com/gin-gonic/gin v1.7.4
github.com/lib/pq v1.10.3
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/qiniu/go-sdk/v7 v7.11.0
github.com/shirou/gopsutil v3.21.10+incompatible
github.com/swaggo/gin-swagger v1.3.2
github.com/swaggo/swag v1.7.3
github.com/unrolled/secure v1.0.9
github.com/wechatpay-apiv3/wechatpay-go v0.2.9
go.uber.org/zap v1.19.1
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
google.golang.org/grpc v1.42.0
google.golang.org/protobuf v1.27.1
gopkg.in/ini.v1 v1.63.2
......@@ -49,9 +48,7 @@ require (
github.com/ugorji/go/codec v1.2.6 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/net v0.0.0-20210421230115-4e50805a0758 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20211020174200-9d6173849985 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.5 // indirect
......
......@@ -12,8 +12,6 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/agiledragon/gomonkey v2.0.2+incompatible h1:eXKi9/piiC3cjJD1658mEE2o3NjkJ5vDLgYjCQu0Xlw=
github.com/agiledragon/gomonkey v2.0.2+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ=
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIgjX4RBBcHnJ05h//6/k6foqmgE45jTQtxg=
......@@ -82,7 +80,6 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk=
github.com/go-playground/validator/v10 v10.9.0 h1:NgTtmN58D0m8+UuxtYmGztBJB7VnPgjj221I1QHci2A=
github.com/go-playground/validator/v10 v10.9.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
......@@ -161,10 +158,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/qiniu/dyn v1.3.0/go.mod h1:E8oERcm8TtwJiZvkQPbcAh0RL8jO1G0VXJMW3FAWdkk=
github.com/qiniu/go-sdk/v7 v7.11.0 h1:Cdx/1E3ybv0OFKnkGwoDN/t6bCCntjrWhwWuRaqI3XQ=
github.com/qiniu/go-sdk/v7 v7.11.0/go.mod h1:btsaOc8CA3hdVloULfFdDgDc+g4f3TDZEFsDY0BLE+w=
github.com/qiniu/x v1.10.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
......@@ -205,8 +198,6 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/wechatpay-apiv3/wechatpay-go v0.2.9 h1:FnFdYLquHWEB0pBacOHC9BePgXcf26vZfn2X3uYbo0c=
github.com/wechatpay-apiv3/wechatpay-go v0.2.9/go.mod h1:W8ucVAOCKOii933cWROLaDLmRQ2cg/vHHVF4vGAVq9Q=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
......@@ -259,8 +250,6 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
......
......@@ -9,36 +9,42 @@ import (
"time"
)
func (s *Server) CacheAddSimInfoNoBindStudentAndFamily( ctx context.Context,reqs *myGRPC.CacheAddNewSim) (*myGRPC.Strings,error) {
func (s *Server) CacheAddSimInfoNoBindStudentAndFamily(ctx context.Context, reqs *myGRPC.CacheAddNewSim) (*myGRPC.Strings, error) {
if reqs.Rows == nil {
return nil,errors.New("入参不能为空")
return nil, errors.New("入参不能为空")
}
res := new(myGRPC.Strings)
for _,req := range reqs.Rows {
for _, req := range reqs.Rows {
if len(req.SimID) == 0 {
continue
}
if req.AreaServiceID == 0 {
continue
}
if req.Status == 0 || req.Status > 2{
if req.Status == 0 || req.Status > 2 {
continue
}
newExpiry, err := time.Parse("2006-01-02", req.ExpiryAt)
if err != nil {
continue
}
if cache.CreatSimInfoMap(req.SimID,&model.CacheSimInfoStruct{
AreaServiceID: req.AreaServiceID,
Status: uint8(req.Status),
MonthTalkMinutes: uint16(req.MonthTalkMinutes),
if cache.CreatSimInfoMap(req.SimID, &model.CacheSimInfoStruct{
AreaServiceID: req.AreaServiceID,
Status: uint8(req.Status),
MonthTalkMinutes: uint16(req.MonthTalkMinutes),
MonthPackageMinutes: uint16(req.MonthPackageMinutes),
ExpiryAt: newExpiry,
FamilyDeleteCount: int8(req.FamilyDeleteCount),
ExpiryAt: newExpiry,
FamilyDeleteCount: int8(req.FamilyDeleteCount),
Type: uint8(req.Type),
}) {
res.Strings = append(res.Strings,req.SimID)
res.Strings = append(res.Strings, req.SimID)
}
}
// fmt.Println(res.Strings)
return res,nil
}
\ No newline at end of file
return res, nil
}
func (s *Server) CacheDeleteSimInfo(ctx context.Context, reqs *myGRPC.Strings) (*myGRPC.Empty, error) {
cache.DeleteSimInfoMap(reqs.Strings)
return new(myGRPC.Empty), nil
}
{"ts":"2022-02-17 17:59:35.710","msg":"read error","Src":"TCP-SERVER-connectionHandle","DevID":0,"Conn":"127.0.0.1:52696","error":"read tcp4 127.0.0.1:8010->127.0.0.1:52696: i/o timeout"}
{"ts":"2022-02-17 18:07:50.197","msg":"read error","Src":"TCP-SERVER-connectionHandle","DevID":0,"Conn":"127.0.0.1:52770","error":"EOF"}
{"ts":"2022-02-18 20:30:22.544","msg":"read error","Src":"TCP-SERVER-connectionHandle","DevID":0,"Conn":"127.0.0.1:57132","error":"EOF"}
{"ts":"2022-02-18 20:30:38.775","msg":"read error","Src":"TCP-SERVER-connectionHandle","DevID":0,"Conn":"127.0.0.1:50860","error":"EOF"}
{"ts":"2022-02-18 20:30:56.130","msg":"read error","Src":"TCP-SERVER-connectionHandle","DevID":0,"Conn":"127.0.0.1:54929","error":"EOF"}
//go:build debug
// +build debug
package logger
import (
......@@ -13,8 +16,8 @@ import (
"time"
)
var Log *zap.Logger // 系统日志
var logGin *zap.Logger // gin 的http日志
var Log *zap.Logger // 系统日志
var logGin *zap.Logger // gin 的http日志
var LogHttpClient *zap.Logger // 第三方API请求日志
// var LogAllinPay *zap.Logger // 支付回调或查询支付订单日志
......@@ -80,7 +83,7 @@ func Init() {
zapcore.NewCore(zapcore.NewJSONEncoder(config), zapcore.AddSync(errorWriter), errorLevel), //
// zapcore.NewCore(zapcore.NewJSONEncoder(encoder), zapcore.NewMultiWriteSyncer(zapcore.AddSync(os.Stdout)), logLevel),//同时将日志输出到控制台,NewJSONEncoder 是结构化输出
)
Log = zap.New(core/*, zap.AddStacktrace(zap.ErrorLevel)*/)
Log = zap.New(core /*, zap.AddStacktrace(zap.ErrorLevel)*/)
infoWriter = &lumberjack.Logger{
Filename: setting.LogPath + "gInfo.log",
......@@ -109,8 +112,7 @@ func Init() {
zapcore.NewCore(zapcore.NewJSONEncoder(config), zapcore.AddSync(errorWriter), errorLevel), //
// zapcore.NewCore(zapcore.NewJSONEncoder(config), zapcore.NewMultiWriteSyncer(zapcore.AddSync(os.Stdout)), infoLevel),//同时将日志输出到控制台,NewJSONEncoder 是结构化输出
)
logGin = zap.New(core/*, zap.AddStacktrace(zap.ErrorLevel)*/)
logGin = zap.New(core /*, zap.AddStacktrace(zap.ErrorLevel)*/)
debugWriter := &lumberjack.Logger{
Filename: setting.LogPath + "cDebug.log",
......@@ -147,11 +149,12 @@ func Init() {
zapcore.NewCore(zapcore.NewJSONEncoder(config), zapcore.AddSync(errorWriter), errorLevel), //
//zapcore.NewCore(zapcore.NewJSONEncoder(encoder), zapcore.NewMultiWriteSyncer(zapcore.AddSync(os.Stdout)), logLevel),//同时将日志输出到控制台,NewJSONEncoder 是结构化输出
)
LogHttpClient = zap.New(core/*, zap.AddStacktrace(zap.ErrorLevel)*/)
LogHttpClient = zap.New(core /*, zap.AddStacktrace(zap.ErrorLevel)*/)
}
// test
var testid uint32
type CustomResponseWriter struct {
gin.ResponseWriter
body *bytes.Buffer
......@@ -166,27 +169,26 @@ func (w CustomResponseWriter) WriteString(s string) (int, error) {
w.body.WriteString(s)
return w.ResponseWriter.WriteString(s)
}
/////////
var GinHttpReqNum int32
func HttpGinLog() gin.HandlerFunc { //logger *log.Log
return func(c *gin.Context) {
atomic.AddInt32(&GinHttpReqNum,1)
atomic.AddInt32(&GinHttpReqNum, 1)
//test
blw := &CustomResponseWriter{body: bytes.NewBufferString(""), ResponseWriter: c.Writer}
c.Writer = blw
testid++
buf, _ := ioutil.ReadAll(c.Request.Body)
rdr := ioutil.NopCloser(bytes.NewBuffer(buf))
c.Request.Body = rdr
fmt.Println("----->",testid,time.Now(),string(buf),c.Request.Method,c.Request.RequestURI)
fmt.Println("----->", testid, time.Now(), string(buf), c.Request.Method, c.Request.RequestURI)
///
startTime := time.Now().UnixMilli()
c.Next()
spendTime := time.Now().UnixMilli() - startTime
......@@ -205,7 +207,7 @@ func HttpGinLog() gin.HandlerFunc { //logger *log.Log
path := c.Request.RequestURI
//test
fmt.Println(" <-----",c.Writer.Status(), blw.body.String())
fmt.Println(" <-----", c.Writer.Status(), blw.body.String())
///
//para := c.Params
......@@ -264,7 +266,7 @@ func HttpGinLog() gin.HandlerFunc { //logger *log.Log
zap.Int("DataSize", dataSize),
zap.String("Agent", userAgent))
}
atomic.AddInt32(&GinHttpReqNum,-1)
atomic.AddInt32(&GinHttpReqNum, -1)
}
}
......
......@@ -84,7 +84,3 @@ func main() { //
// 定时任务:
// 1. 每月最后一天晚上11点半开始,统一从移动系统删除亲情号,然后更新亲情号可修改次数,然后更新套餐分钟数。
// 2. 每晚校验缓存,同时更新用户登录次数和时间
// 3. 每晚校验缓存里面充值到期项,是不是到期了,到期了就删掉,并且要提示运营商修改
// @//Description GET /we/replacecardfee/phone/:aid GET增加接口,用于查询补卡费
// @//Description POST /we/payreplacecard/phone/:aid/:cid 用于补卡缴费
......@@ -76,6 +76,7 @@ message CacheAddNewSimStruct {
uint32 MonthPackageMinutes = 5;
string ExpiryAt = 6;
uint32 FamilyDeleteCount = 7;
uint32 Type = 8; // 0 测试卡(不调任何接口) 1 中移物联网(增删亲情号调接口) 其他预留
}
message CacheAddNewSim {
repeated CacheAddNewSimStruct Rows = 1;
......@@ -132,6 +133,7 @@ service MyGrpc{
// sim_card_info
rpc CacheAddSimInfoNoBindStudentAndFamily(CacheAddNewSim) returns(Strings); // 添加status不为0,但是有AreaServiceID,未绑学生和亲情号的新卡,返回值为成功的simID
rpc CacheDeleteSimInfo(Strings) returns(Empty); // 从缓存里删除sim卡
// dev_phone20
rpc CacheAddDevPhone20WhereAreaServiceIDNot0(CacheAddPhone20) returns(Uint32s);
......
......@@ -34,6 +34,7 @@ type MyGrpcClient interface {
CacheUpdateUWeCustomerTestRole(ctx context.Context, in *CacheUWeCustomerTestRole, opts ...grpc.CallOption) (*Empty, error)
// sim_card_info
CacheAddSimInfoNoBindStudentAndFamily(ctx context.Context, in *CacheAddNewSim, opts ...grpc.CallOption) (*Strings, error)
CacheDeleteSimInfo(ctx context.Context, in *Strings, opts ...grpc.CallOption) (*Empty, error)
// dev_phone20
CacheAddDevPhone20WhereAreaServiceIDNot0(ctx context.Context, in *CacheAddPhone20, opts ...grpc.CallOption) (*Uint32S, error)
CheckDevPhone20Online(ctx context.Context, in *Uint32S, opts ...grpc.CallOption) (*BoolS, error)
......@@ -133,6 +134,15 @@ func (c *myGrpcClient) CacheAddSimInfoNoBindStudentAndFamily(ctx context.Context
return out, nil
}
func (c *myGrpcClient) CacheDeleteSimInfo(ctx context.Context, in *Strings, opts ...grpc.CallOption) (*Empty, error) {
out := new(Empty)
err := c.cc.Invoke(ctx, "/my_grpc.MyGrpc/CacheDeleteSimInfo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *myGrpcClient) CacheAddDevPhone20WhereAreaServiceIDNot0(ctx context.Context, in *CacheAddPhone20, opts ...grpc.CallOption) (*Uint32S, error) {
out := new(Uint32S)
err := c.cc.Invoke(ctx, "/my_grpc.MyGrpc/CacheAddDevPhone20WhereAreaServiceIDNot0", in, out, opts...)
......@@ -207,6 +217,7 @@ type MyGrpcServer interface {
CacheUpdateUWeCustomerTestRole(context.Context, *CacheUWeCustomerTestRole) (*Empty, error)
// sim_card_info
CacheAddSimInfoNoBindStudentAndFamily(context.Context, *CacheAddNewSim) (*Strings, error)
CacheDeleteSimInfo(context.Context, *Strings) (*Empty, error)
// dev_phone20
CacheAddDevPhone20WhereAreaServiceIDNot0(context.Context, *CacheAddPhone20) (*Uint32S, error)
CheckDevPhone20Online(context.Context, *Uint32S) (*BoolS, error)
......@@ -249,6 +260,9 @@ func (UnimplementedMyGrpcServer) CacheUpdateUWeCustomerTestRole(context.Context,
func (UnimplementedMyGrpcServer) CacheAddSimInfoNoBindStudentAndFamily(context.Context, *CacheAddNewSim) (*Strings, error) {
return nil, status.Errorf(codes.Unimplemented, "method CacheAddSimInfoNoBindStudentAndFamily not implemented")
}
func (UnimplementedMyGrpcServer) CacheDeleteSimInfo(context.Context, *Strings) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method CacheDeleteSimInfo not implemented")
}
func (UnimplementedMyGrpcServer) CacheAddDevPhone20WhereAreaServiceIDNot0(context.Context, *CacheAddPhone20) (*Uint32S, error) {
return nil, status.Errorf(codes.Unimplemented, "method CacheAddDevPhone20WhereAreaServiceIDNot0 not implemented")
}
......@@ -442,6 +456,24 @@ func _MyGrpc_CacheAddSimInfoNoBindStudentAndFamily_Handler(srv interface{}, ctx
return interceptor(ctx, in, info, handler)
}
func _MyGrpc_CacheDeleteSimInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Strings)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MyGrpcServer).CacheDeleteSimInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/my_grpc.MyGrpc/CacheDeleteSimInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MyGrpcServer).CacheDeleteSimInfo(ctx, req.(*Strings))
}
return interceptor(ctx, in, info, handler)
}
func _MyGrpc_CacheAddDevPhone20WhereAreaServiceIDNot0_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CacheAddPhone20)
if err := dec(in); err != nil {
......@@ -594,6 +626,10 @@ var MyGrpc_ServiceDesc = grpc.ServiceDesc{
Handler: _MyGrpc_CacheAddSimInfoNoBindStudentAndFamily_Handler,
},
{
MethodName: "CacheDeleteSimInfo",
Handler: _MyGrpc_CacheDeleteSimInfo_Handler,
},
{
MethodName: "CacheAddDevPhone20WhereAreaServiceIDNot0",
Handler: _MyGrpc_CacheAddDevPhone20WhereAreaServiceIDNot0_Handler,
},
......
set GOARCH=amd64
set GOOS=linux
go build -tags=!debug -o z9_output_release/customerServer.new -ldflags "-w -s" main.go
\ No newline at end of file
set GOOS=windows
swag init
go run main.go
\ No newline at end of file
go run -tags=debug main.go
\ No newline at end of file
......@@ -5,7 +5,6 @@ import (
"dc_golang_server_1/thirdapi"
"encoding/json"
"errors"
"fmt"
"go.uber.org/zap"
"sync"
"time"
......@@ -131,7 +130,7 @@ func QueryMemberVoiceWhitelist(iccId string) ([]string, bool) {
zap.Error(err))
return nil, false
}
fmt.Println("oneLink查询成员语音白名单:", iccId, memberVoiceWhitelist) // todo
// fmt.Println("oneLink查询成员语音白名单:", iccId, memberVoiceWhitelist) //
//if memberVoiceWhitelist.Result != nil && len(memberVoiceWhitelist.Result) > 0 {
// //fmt.Println()
// //ws := make([]string, totalCount)
......
......@@ -6,6 +6,7 @@ import (
"dc_golang_server_1/util/setting"
"encoding/json"
"go.uber.org/zap"
"strings"
)
var testTemp = map[string]string{
......@@ -64,3 +65,72 @@ func WechatCode2Session(code string) (unionID, openID, sessionKey string) {
return "", "", ""
}
}
//var accessToken string
//var accessTokenExpiry uint32
func WechatGetPhone(code string) (phone string) {
url := "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" +
setting.WechatAppID + "&secret=" + setting.WechatAppSecret
ret := thirdapi.HttpGet(url)
if ret == nil {
return ""
}
var res struct {
AccessToken string `json:"access_token"`
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}
if err := json.Unmarshal(ret, &res); err != nil {
logger.LogHttpClient.Error("WechatGetPhone",
zap.String("code", code),
zap.String("ret", string(ret)),
zap.Error(err))
return ""
}
if res.ErrCode != 0 {
logger.LogHttpClient.Error("WechatCode2Session",
zap.String("code", code),
zap.Int32("ErrCode", res.ErrCode),
zap.String("ErrMsg", res.ErrMsg))
return ""
}
ret = thirdapi.HttpPost("https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token="+res.AccessToken,
"application/json",
strings.NewReader("{\"code\": \""+code+"\"}"))
if ret == nil {
return ""
}
var res2 struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
PhoneInfo struct {
// PhoneNumber string `json:"phoneNumber"` // 用户绑定的手机号(国外手机号会有区号)
PurePhoneNumber string `json:"purePhoneNumber"` // 没有区号的手机号
// CountryCode int `json:"countryCode"` // 区号
//Watermark struct {
// Timestamp int `json:"timestamp"`
// Appid string `json:"appid"`
//} `json:"watermark"`
} `json:"phone_info"`
}
if err := json.Unmarshal(ret, &res2); err != nil {
logger.LogHttpClient.Error("WechatGetPhone 2",
zap.String("code", code),
zap.String("ret", string(ret)),
zap.Error(err))
return ""
}
if res2.ErrCode != 0 {
logger.LogHttpClient.Error("WechatCode2Session 2",
zap.String("code", code),
zap.Int32("ErrCode", res2.ErrCode),
zap.String("ErrMsg", res2.ErrMsg))
return ""
}
return res2.PhoneInfo.PurePhoneNumber
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment