Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["const.go"],
importpath = "go-common/app/interface/main/app-wall/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/interface/main/app-wall/model/mobile:all-srcs",
"//app/interface/main/app-wall/model/operator:all-srcs",
"//app/interface/main/app-wall/model/telecom:all-srcs",
"//app/interface/main/app-wall/model/unicom:all-srcs",
"//app/interface/main/app-wall/model/wall:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,82 @@
package model
import (
"crypto/md5"
"encoding/hex"
"net"
)
const (
TypeIOS = "ios"
TypeAndriod = "android"
GdtIOSAppID = "736536022"
GdtAndroidAppID = "100951776"
ChannelToutiao = "toutiao"
ChannelShike = "2883"
ChannelDontin = "415209141"
)
type GdtKey struct {
Encrypt string
Sign string
}
var (
ChannelGdt = map[string]*GdtKey{
"1439767": &GdtKey{Encrypt: "BAAAAAAAAAAAFfgX", Sign: "ee358e8dccbbc4ba"},
"406965": &GdtKey{Encrypt: "BAAAAAAAAAAABjW1", Sign: "a45cbd2d4c5344b3"},
"7799673": &GdtKey{Encrypt: "BAAAAAAAAAAAdwN5", Sign: "54b6deffcd64b6b0"},
}
AppIDGdt = map[string]string{
TypeIOS: GdtIOSAppID,
TypeAndriod: GdtAndroidAppID,
}
)
func GdtIMEI(imei string) (gdtImei string) {
if imei == "" {
return
}
bs := md5.Sum([]byte(imei))
gdtImei = hex.EncodeToString(bs[:])
return
}
// InetAtoN conver ip addr to uint32.
func InetAtoN(s string) (sum uint32) {
ip := net.ParseIP(s)
if ip == nil {
return
}
ip = ip.To4()
if ip == nil {
return
}
sum += uint32(ip[0]) << 24
sum += uint32(ip[1]) << 16
sum += uint32(ip[2]) << 8
sum += uint32(ip[3])
return sum
}
// InetNtoA conver uint32 to ip addr.
func InetNtoA(sum uint32) string {
ip := make(net.IP, net.IPv4len)
ip[0] = byte((sum >> 24) & 0xFF)
ip[1] = byte((sum >> 16) & 0xFF)
ip[2] = byte((sum >> 8) & 0xFF)
ip[3] = byte(sum & 0xFF)
return ip.String()
}
// IsIPv4 is ipv4
func IsIPv4(addr string) bool {
ipv := net.ParseIP(addr)
if ip := ipv.To4(); ip != nil {
return true
} else {
return false
}
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["mobile.go"],
importpath = "go-common/app/interface/main/app-wall/model/mobile",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/log:go_default_library",
"//library/time:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,118 @@
package mobile
import (
"encoding/xml"
"strconv"
"time"
"go-common/library/log"
xtime "go-common/library/time"
)
type OrderXML struct {
XMLName xml.Name `xml:"SyncFlowPkgOrderReq"`
*MobileXML
}
type FlowXML struct {
XMLName xml.Name `xml:"SyncFlowPkgLeftQuotaReq"`
*MobileXML
}
type MobileXML struct {
Orderid string `xml:"OrderID"`
Userpseudocode string `xml:"UserPseudoCode"`
Channelseqid string `xml:"ChannelSeqId"`
Price string `xml:"Price"`
Actiontime string `xml:"ActionTime"`
Actionid string `xml:"ActionID"`
Effectivetime string `xml:"EffectiveTime"`
Expiretime string `xml:"ExpireTime"`
Channelid string `xml:"ChannelId"`
Productid string `xml:"ProductId"`
Ordertype string `xml:"OrderType"`
Threshold string `xml:"Threshold"`
Resulttime string `xml:"ResultTime"`
}
type Mobile struct {
Orderid string `json:"-"`
Userpseudocode string `json:"-"`
Channelseqid string `json:"-"`
Price int `json:"-"`
Actionid int `json:"actionid"`
Effectivetime xtime.Time `json:"starttime,omitempty"`
Expiretime xtime.Time `json:"endtime,omitempty"`
Channelid string `json:"-"`
Productid string `json:"productid,omitempty"`
Ordertype int `json:"-"`
Threshold int `json:"flow"`
Resulttime xtime.Time `json:"-"`
MobileType int `json:"orderstatus,omitempty"`
ProductType int `json:"product_type,omitempty"`
}
type MobileIP struct {
IPStartUint uint32 `json:"-"`
IPEndUint uint32 `json:"-"`
}
type MobileUserIP struct {
IPStr string `json:"ip"`
IsValide bool `json:"is_valide"`
}
// MobileChange
func (u *Mobile) MobileChange() {
if u.Effectivetime.Time().IsZero() {
u.Effectivetime = 0
}
if u.Expiretime.Time().IsZero() {
u.Expiretime = 0
}
switch u.Productid {
case "100000000028":
u.ProductType = 1
case "100000000030":
u.ProductType = 2
}
}
type Msg struct {
Xmlns string `xml:"xmlns,attr"`
MsgType string `xml:"MsgType"`
Version string `xml:"Version"`
HRet string `xml:"hRet"`
}
type OrderMsgXML struct {
XMLName xml.Name `xml:"SyncFlowPkgOrderResp"`
*Msg
}
type FlowMsgXML struct {
XMLName xml.Name `xml:"SyncFlowPkgLeftQuotaResp"`
*Msg
}
// MobileXMLMobile
func (u *Mobile) MobileXMLMobile(uxml *MobileXML) {
u.Actionid, _ = strconv.Atoi(uxml.Actionid)
u.Effectivetime = timeStrToInt(uxml.Effectivetime)
u.Expiretime = timeStrToInt(uxml.Expiretime)
u.Threshold, _ = strconv.Atoi(uxml.Threshold)
u.Productid = uxml.Productid
u.MobileChange()
}
// timeStrToInt
func timeStrToInt(timeStr string) (timeInt xtime.Time) {
var err error
timeLayout := "20060102"
loc, _ := time.LoadLocation("Local")
theTime, _ := time.ParseInLocation(timeLayout, timeStr, loc)
if err = timeInt.Scan(theTime); err != nil {
log.Error("timeInt.Scan error(%v)", err)
}
return
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["operator.go"],
importpath = "go-common/app/interface/main/app-wall/model/operator",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/log:go_default_library",
"//library/time:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,33 @@
package operator
import (
"time"
"go-common/library/log"
xtime "go-common/library/time"
)
type Reddot struct {
StartTime xtime.Time `json:"start_time,omitempty"`
EndTime xtime.Time `json:"end_time,omitempty"`
}
// ReddotChange Reddot change
func (r *Reddot) ReddotChange(startStr, endStr string) {
if startStr != "" && endStr != "" {
r.StartTime = timeStrToInt(startStr)
r.EndTime = timeStrToInt(endStr)
}
}
// timeStrToInt string to int
func timeStrToInt(timeStr string) (timeInt xtime.Time) {
var err error
timeLayout := "2006-01-02 15:04:05"
loc, _ := time.LoadLocation("Local")
theTime, _ := time.ParseInLocation(timeLayout, timeStr, loc)
if err = timeInt.Scan(theTime); err != nil {
log.Error("timeInt.Scan error(%v)", err)
}
return
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["telecom.go"],
importpath = "go-common/app/interface/main/app-wall/model/telecom",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/log:go_default_library",
"//library/time:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,163 @@
package telecom
import (
"strconv"
"time"
"go-common/library/log"
xtime "go-common/library/time"
)
type TelecomJSON struct {
FlowpackageID int `json:"flowPackageId"`
FlowPackageSize int `json:"flowPackageSize"`
FlowPackageType int `json:"flowPackageType"`
TrafficAttribution int `json:"trafficAttribution"`
BeginTime string `json:"beginTime"`
EndTime string `json:"endTime"`
IsMultiplyOrder int `json:"isMultiplyOrder"`
SettlementType int `json:"settlementType"`
Operator int `json:"operator"`
OrderStatus int `json:"orderStatus"`
RemainedRebindNum int `json:"remainedRebindNum"`
MaxbindNum int `json:"maxBindNum"`
OrderID string `json:"orderId"`
SignNo string `json:"signNo"`
AccessToken string `json:"accessToken"`
PhoneID string `json:"phoneId"`
IsRepeatOrder int `json:"isRepeatOrder"`
PayStatus int `json:"payStatus"`
PayTime string `json:"payTime"`
PayChannel int `json:"payChannel"`
SignStatus string `json:"signStatus "`
RefundStatus int `json:"refundStatus"`
PayResult *PayResultJSON `json:"payResult,omitempty"`
}
type PayResultJSON struct {
IsRepeatOrder int `json:"isRepeatOrder"`
RefundStatus int `json:"refundStatus"`
PayStatus int `json:"payStatus"`
PayChannel int `json:"payChannel"`
}
type TelecomOrderJson struct {
RequestNo string `json:"requestNo"`
ResultType int `json:"resultType"`
Detail *TelecomJSON `json:"detail"`
}
type TelecomRechargeJson struct {
RequestNo string `json:"requestNo"`
ResultType int `json:"resultType"`
Detail *RechargeJSON `json:"detail"`
}
type RechargeJSON struct {
RequestNo string `json:"requestNo"`
FcRechargeNo string `json:"fcRechargeNo"`
RechargeStatus int `json:"rechargeStatus"`
OrderTotalSize int `json:"orderTotalSize"`
FlowBalance int `json:"flowBalance"`
}
type OrderInfo struct {
PhoneID int `json:"phone"`
OrderID int64 `json:"orderid"`
OrderState int `json:"order_status"`
IsRepeatorder int `json:"isrepeatorder"`
SignNo string `json:"sign_no"`
Begintime xtime.Time `json:"begintime"`
Endtime xtime.Time `json:"endtime"`
}
type Pay struct {
OrderID int64 `json:"orderid"`
RequestNo int64 `json:"requestno,omitempty"`
PayURL string `json:"pay_url,omitempty"`
}
type SucOrder struct {
FlowPackageID string `json:"flowPackageId,omitempty"`
Domain string `json:"domain"`
Port string `json:"port,omitempty"`
PortInt int `json:"portInt"`
KeyEffectiveDuration int `json:"keyEffectiveDuration"`
OrderKey string `json:"orderKey"`
FlowBalance int `json:"flowBalance"`
FlowPackageSize int `json:"flowPackageSize"`
AccessToken string `json:"accessToken"`
OrderIDStr string `json:"orderId,omitempty"`
OrderID int64 `json:"orderid"`
}
type OrderFlow struct {
FlowBalance int `json:"flowBalance"`
}
type PhoneConsent struct {
Consent int `json:"consent"`
}
type TelecomMessageJSON struct {
PhoneID string `json:"phoneId"`
ResultType int `json:"resultType"`
ResultMessage string `json:"resultMsg"`
}
type OrderState struct {
FlowBalance int `json:"flowBalance,omitempty"`
FlowSize int `json:"flow_size"`
OrderState int `json:"order_state"`
Endtime xtime.Time `json:"endtime,omitempty"`
IsRepeatorder int `json:"is_repeatorder"`
}
type OrderPhoneState struct {
FlowPackageID int `json:"flowPackageId"`
FlowSize int `json:"flowPackageSize"`
OrderState int `json:"orderStatus"`
PhoneStr string `json:"phoneId"`
}
func (s *TelecomJSON) TelecomJSONChange() {
if s.PayResult != nil {
s.IsRepeatOrder = s.PayResult.IsRepeatOrder
s.RefundStatus = s.PayResult.RefundStatus
s.PayStatus = s.PayResult.PayStatus
s.PayChannel = s.PayResult.PayChannel
}
}
func (t *OrderInfo) OrderInfoJSONChange(tjson *TelecomJSON) {
t.PhoneID, _ = strconv.Atoi(tjson.PhoneID)
t.OrderID, _ = strconv.ParseInt(tjson.OrderID, 10, 64)
t.OrderState = tjson.OrderStatus
t.IsRepeatorder = tjson.IsRepeatOrder
t.SignNo = tjson.SignNo
t.Begintime = timeStrToInt(tjson.BeginTime)
t.Endtime = timeStrToInt(tjson.EndTime)
t.TelecomChange()
}
// timeStrToInt
func timeStrToInt(timeStr string) (timeInt xtime.Time) {
var err error
timeLayout := "2006-01-02 15:04:05"
loc, _ := time.LoadLocation("Local")
theTime, _ := time.ParseInLocation(timeLayout, timeStr, loc)
if err = timeInt.Scan(theTime); err != nil {
log.Error("timeInt.Scan error(%v)", err)
}
return
}
// TelecomChange
func (t *OrderInfo) TelecomChange() {
if t.Begintime.Time().IsZero() {
t.Begintime = 0
}
if t.Endtime.Time().IsZero() {
t.Endtime = 0
}
}

View File

@@ -0,0 +1,33 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["unicom.go"],
importpath = "go-common/app/interface/main/app-wall/model/unicom",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/app-wall/model:go_default_library",
"//library/log:go_default_library",
"//library/time:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,259 @@
package unicom
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
"go-common/app/interface/main/app-wall/model"
"go-common/library/log"
xtime "go-common/library/time"
)
type Unicom struct {
Id int `json:"-"`
Spid int `json:"spid"`
CardType int `json:"cardtype"`
TypeInt int `json:"type"`
Unicomtype int `json:"unicomtype,omitempty"`
Ordertypes int `json:"-"`
Channelcode int `json:"-"`
Usermob string `json:"-"`
Cpid string `json:"-"`
Ordertime xtime.Time `json:"ordertime"`
Canceltime xtime.Time `json:"canceltime,omitempty"`
Endtime xtime.Time `json:"endtime,omitempty"`
Province string `json:"-"`
Area string `json:"-"`
Videoid string `json:"-"`
Time xtime.Time `json:"-"`
Flowbyte int `json:"flowbyte"`
}
type UnicomJson struct {
Usermob string `json:"usermob"`
Userphone string `json:"userphone"`
Cpid string `json:"cpid"`
Spid string `json:"spid"`
TypeInt string `json:"type"`
Ordertime string `json:"ordertime"`
Canceltime string `json:"canceltime"`
Endtime string `json:"endtime"`
Channelcode string `json:"channelcode"`
Province string `json:"province"`
Area string `json:"area"`
Ordertypes string `json:"ordertype"`
Videoid string `json:"videoid"`
Time string `json:"time"`
FlowbyteStr string `json:"flowbyte"`
}
type UnicomIpJson struct {
Ipbegin string `json:"ipbegin"`
Ipend string `json:"ipend"`
Provinces string `json:"province"`
Isopen string `json:"isopen"`
Opertime string `json:"opertime"`
Sign string `json:"sign"`
}
type UnicomIP struct {
Ipbegin int `json:"-"`
Ipend int `json:"-"`
IPStartUint uint32 `json:"-"`
IPEndUint uint32 `json:"-"`
}
type UnicomUserIP struct {
IPStr string `json:"ip"`
IsValide bool `json:"is_valide"`
}
type BroadbandOrder struct {
Usermob string `json:"userid,omitempty"`
Endtime string `json:"endtime,omitempty"`
Channel string `json:"channel,omitempty"`
}
type UserBind struct {
Usermob string `json:"usermob,omitempty"`
Phone int `json:"phone"`
Mid int64 `json:"mid"`
Name string `json:"name,omitempty"`
State int `json:"state,omitempty"`
Integral int `json:"integral"`
Flow int `json:"flow"`
Monthly time.Time `json:"monthly,omitempty"`
}
type UserPack struct {
ID int64 `json:"id"`
Type int `json:"type"`
Desc string `json:"desc"`
Amount int `json:"amount"`
Capped int8 `json:"capped"`
Integral int `json:"integral"`
Param string `json:"param"`
State int `json:"state,omitempty"`
}
type UserPackLimit struct {
IsLimit int `json:"is_limit"`
Count int `json:"count"`
}
type UnicomUserFlow struct {
Phone int `json:"phone"`
Mid int64 `json:"mid"`
Integral int `json:"integral"`
Flow int `json:"flow"`
Outorderid string `json:"outorderid"`
Orderid string `json:"orderid"`
Desc string `json:"desc"`
}
type UserPackLog struct {
Phone int `json:"phone,omitempty"`
Usermob string `json:"usermob,omitempty"`
Mid int64 `json:"mid,omitempty"`
RequestNo string `json:"request_no,omitempty"`
Type int `json:"pack_type"`
Desc string `json:"-"`
UserDesc string `json:"pack_desc,omitempty"`
Integral int `json:"integral,omitempty"`
}
type UserLog struct {
Phone int `json:"phone,omitempty"`
Integral int `json:"integral,omitempty"`
Desc string `json:"pack_desc,omitempty"`
Ctime string `json:"ctime,omitempty"`
}
type UserBindInfo struct {
MID int64 `json:"mid"`
Phone int `json:"phone"`
Action string `json:"action"`
}
// UnicomChange
func (u *Unicom) UnicomChange() {
if u.Canceltime.Time().IsZero() {
u.Canceltime = 0
}
if u.Endtime.Time().IsZero() {
u.Endtime = 0
}
switch u.Spid {
case 10019:
u.CardType = 1
case 10020:
u.CardType = 2
case 10021:
u.CardType = 3
case 979:
u.CardType = 4
}
}
func (u *UnicomJson) UnicomJSONChange() (err error) {
if u.Ordertypes != "" {
if _, err = strconv.Atoi(u.Ordertypes); err != nil {
log.Error("UnicomJsonChange error(%v)", u)
}
}
return
}
func (u *UnicomIP) UnicomIPChange() {
u.IPStartUint = u.unicomIPTOUint(u.Ipbegin)
u.IPEndUint = u.unicomIPTOUint(u.Ipend)
}
func (u *UnicomIP) unicomIPTOUint(ip int) (ipUnit uint32) {
var (
ip1, ip2, ip3, ip4 int
ipStr string
)
var _initIP = "%d.%d.%d.%d"
ip1 = ip / 1000000000
ip2 = (ip / 1000000) % 1000
ip3 = (ip / 1000) % 1000
ip4 = ip % 1000
ipStr = fmt.Sprintf(_initIP, ip1, ip2, ip3, ip4)
ipUnit = model.InetAtoN(ipStr)
return
}
// UnicomJSONTOUincom
func (u *Unicom) UnicomJSONTOUincom(usermob string, ujson *UnicomJson) {
u.Spid, _ = strconv.Atoi(ujson.Spid)
u.Ordertime = timeStrToInt(ujson.Ordertime)
u.Canceltime = timeStrToInt(ujson.Canceltime)
u.Endtime = timeStrToInt(ujson.Endtime)
u.TypeInt, _ = strconv.Atoi(ujson.TypeInt)
u.Ordertypes, _ = strconv.Atoi(ujson.Ordertypes)
u.Channelcode, _ = strconv.Atoi(ujson.Channelcode)
u.Usermob = usermob
u.Cpid = ujson.Cpid
u.Province = ujson.Province
u.UnicomChange()
}
// timeStrToInt
func timeStrToInt(timeStr string) (timeInt xtime.Time) {
var err error
timeLayout := "20060102150405"
loc, _ := time.LoadLocation("Local")
theTime, _ := time.ParseInLocation(timeLayout, timeStr, loc)
if err = timeInt.Scan(theTime); err != nil {
log.Error("timeInt.Scan error(%v)", err)
}
return
}
func (u *UnicomIP) UnicomIPStrToint(ipstart, ipend string) {
u.Ipbegin = ipToInt(ipstart)
u.Ipend = ipToInt(ipend)
}
// ipToint
func ipToInt(ipString string) (ipInt int) {
tmp := strings.Split(ipString, ".")
if len(tmp) < 4 {
return
}
var ipStr string
for _, tip := range tmp {
var (
ipLen = len(tip)
last int
ip1 string
)
if ipLen < 3 {
last = 3 - ipLen
switch last {
case 1:
ip1 = "0" + tip
case 2:
ip1 = "00" + tip
case 3:
ip1 = "000"
}
} else {
ip1 = tip
}
ipStr = ipStr + ip1
}
ipInt, _ = strconv.Atoi(ipStr)
return
}
func (t *UserLog) UserLogJSONChange(jsonData string) (err error) {
if err = json.Unmarshal([]byte(jsonData), &t); err != nil {
return
}
return
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["wall.go"],
importpath = "go-common/app/interface/main/app-wall/model/wall",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,11 @@
package wall
type Wall struct {
Id int `json:"-"`
Name string `json:"name"`
Package string `json:"package"`
Size string `json:"size"`
Logo string `json:"logo"`
Download string `json:"download"`
Remark string `json:"remark"`
}