2021-08-28 05:06:00 +00:00
|
|
|
|
package app
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
. "../../../hotime"
|
|
|
|
|
. "../../../hotime/common"
|
2022-01-22 21:13:19 +00:00
|
|
|
|
"../../dri/aliyun"
|
|
|
|
|
"../../dri/tencent"
|
2022-02-23 22:26:36 +00:00
|
|
|
|
"fmt"
|
|
|
|
|
"github.com/silenceper/wechat"
|
|
|
|
|
"github.com/silenceper/wechat/cache"
|
|
|
|
|
"gopkg.in/chanxuehong/wechat.v2/mch/core"
|
|
|
|
|
"gopkg.in/chanxuehong/wechat.v2/mch/pay"
|
2022-01-22 21:13:19 +00:00
|
|
|
|
"io/ioutil"
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
2022-02-23 22:26:36 +00:00
|
|
|
|
"time"
|
2021-08-28 05:06:00 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Project 管理端项目
|
|
|
|
|
var Project = Proj{
|
|
|
|
|
//"user": UserCtr,
|
2022-02-23 22:26:36 +00:00
|
|
|
|
"tag": tagCtr,
|
|
|
|
|
"analyse": analyseCtr,
|
|
|
|
|
"user": User,
|
|
|
|
|
"wechat": Wechat,
|
|
|
|
|
"question": Question,
|
2021-08-28 05:06:00 +00:00
|
|
|
|
}
|
2022-02-23 22:26:36 +00:00
|
|
|
|
var weixin *wechat.Wechat //微信登录实例
|
|
|
|
|
//var appIns = Application{}
|
|
|
|
|
var wxpayClient *core.Client
|
2021-08-28 05:06:00 +00:00
|
|
|
|
|
|
|
|
|
//生成随机码的4位随机数
|
|
|
|
|
func getCode() string {
|
|
|
|
|
//res := ""
|
|
|
|
|
//for i := 0; i < 4; i++ {
|
|
|
|
|
res := ObjToStr(RandX(1000, 9999))
|
|
|
|
|
//}
|
|
|
|
|
return res
|
|
|
|
|
}
|
2022-01-22 21:13:19 +00:00
|
|
|
|
|
|
|
|
|
func getCompany(name, path string) Map {
|
2022-02-23 22:26:36 +00:00
|
|
|
|
os.Setenv("ZONEINFO", "config/data.zip")
|
2022-01-22 21:13:19 +00:00
|
|
|
|
res := tencent.GetCompany("AKIDklZa1qBr3B0x1G643cg8B6UO5JZm2KX8o43G", "tdda7oro526h96dvicYkep1xsWFmHkt33xvqs2K", name)
|
|
|
|
|
c := Map{}
|
|
|
|
|
base := Map{}
|
2022-02-14 11:10:58 +00:00
|
|
|
|
if res.GetInt("code") != 200 {
|
|
|
|
|
|
|
|
|
|
return base
|
|
|
|
|
}
|
2022-01-22 21:13:19 +00:00
|
|
|
|
if res.GetInt("code") == 200 {
|
|
|
|
|
c = res.GetMap("data").GetMap("data")
|
|
|
|
|
|
|
|
|
|
base = c.GetMap("base")
|
|
|
|
|
base["allows"] = len(c.GetSlice("allows"))
|
|
|
|
|
base["branches"] = len(c.GetSlice("branches"))
|
|
|
|
|
base["changes"] = len(c.GetSlice("changes"))
|
|
|
|
|
base["employees"] = len(c.GetSlice("employees"))
|
|
|
|
|
base["exceptions"] = len(c.GetSlice("exceptions"))
|
|
|
|
|
|
|
|
|
|
base["mPledges"] = len(c.GetSlice("mPledges"))
|
|
|
|
|
base["originalName"] = len(c.GetSlice("originalName"))
|
|
|
|
|
base["partners"] = len(c.GetSlice("partners"))
|
|
|
|
|
base["pledges"] = len(c.GetSlice("pledges"))
|
|
|
|
|
base["punishes"] = len(c.GetSlice("punishes"))
|
|
|
|
|
|
|
|
|
|
base["shiXinItems"] = len(c.GetSlice("shiXinItems"))
|
|
|
|
|
base["spotChecks"] = len(c.GetSlice("spotChecks"))
|
|
|
|
|
base["taxCreditltems"] = len(c.GetSlice("taxCreditltems"))
|
|
|
|
|
base["zhiXingItems"] = len(c.GetSlice("zhiXingItems"))
|
|
|
|
|
base["contactInfo"] = c["contactInfo"]
|
|
|
|
|
base["industry"] = c["industry"]
|
|
|
|
|
base["liquidation"] = c["liquidation"]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aliyun.DefaultCompany.Init("06c6a07e89dd45c88de040ee1489eef7")
|
|
|
|
|
data := aliyun.DefaultCompany.GetCompanyOtherAll(name)
|
|
|
|
|
|
|
|
|
|
base["OtherCopyrightsInfo"] = data.GetMap("OtherCopyrightsInfo").GetInt("total")
|
|
|
|
|
base["PatentsInfo"] = data.GetMap("PatentsInfo").GetInt("total")
|
2022-02-14 11:10:58 +00:00
|
|
|
|
base["ProfileTags"] = data.GetSlice("ProfileTags")
|
2022-01-22 21:13:19 +00:00
|
|
|
|
base["SoftwareCopyrightsInfo"] = data.GetMap("SoftwareCopyrightsInfo").GetInt("total")
|
|
|
|
|
base["TrademarksInfo"] = data.GetMap("TrademarksInfo").GetInt("total")
|
|
|
|
|
|
|
|
|
|
if res.GetInt("code") == 200 {
|
|
|
|
|
data["base"] = c
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_ = os.MkdirAll(filepath.Dir(path), os.ModeDir)
|
|
|
|
|
ioutil.WriteFile(path, []byte(data.ToJsonString()), os.ModePerm)
|
|
|
|
|
|
|
|
|
|
return base
|
|
|
|
|
}
|
2022-02-23 22:26:36 +00:00
|
|
|
|
|
|
|
|
|
//微信获取个人信息
|
|
|
|
|
func Weixin(this *Context) *wechat.Wechat {
|
|
|
|
|
if weixin == nil {
|
|
|
|
|
cache1 := cache.Cache(WechatCache{this.CacheIns})
|
2022-02-28 00:53:38 +00:00
|
|
|
|
config := wechat.Config{Cache: cache1, AppID: this.Config.GetString("wechatAppID"), AppSecret: this.Config.GetString("wechatAppSecret")}
|
2022-02-23 22:26:36 +00:00
|
|
|
|
weixin = wechat.NewWechat(&config)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return weixin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//微信获取个人信息
|
|
|
|
|
func WxPayClient(this *Context, sn string, money int64, openid string) Map {
|
|
|
|
|
if wxpayClient == nil {
|
2022-02-28 00:53:38 +00:00
|
|
|
|
wxpayClient = core.NewClient(this.Config.GetString("wechatAppID"), this.Config.GetString("wechatChid"), this.Config.GetString("wechatChkey"), nil)
|
2022-02-23 22:26:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res, err := pay.UnifiedOrder2(wxpayClient, &pay.UnifiedOrderRequest{
|
|
|
|
|
|
|
|
|
|
// 必选参数
|
|
|
|
|
Body: "微信充值", // 商品或支付单简要描述
|
|
|
|
|
OutTradeNo: sn, // 商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号
|
|
|
|
|
TotalFee: money, // ObjToInt64(umoney*100), // `xml:"total_fee"` // 订单总金额,单位为分,详见支付金额
|
|
|
|
|
//SpbillCreateIP string `xml:"spbill_create_ip"` // APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。
|
|
|
|
|
NotifyURL: this.Config.GetString("wechatPayCallBack"), // string `xml:"notify_url"` // 接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数。
|
|
|
|
|
TradeType: "JSAPI", // string `xml:"trade_type"` // 取值如下:JSAPI,NATIVE,APP,详细说明见参数规定
|
|
|
|
|
|
|
|
|
|
// 可选参数
|
|
|
|
|
DeviceInfo: "WEB", // string `xml:"device_info"` // 终端设备号(门店号或收银设备ID),注意:PC网页或公众号内支付请传"WEB"
|
|
|
|
|
// NonceStr string `xml:"nonce_str"` // 随机字符串,不长于32位。NOTE: 如果为空则系统会自动生成一个随机字符串。
|
|
|
|
|
//SignType string `xml:"sign_type"` // 签名类型,默认为MD5,支持HMAC-SHA256和MD5。
|
|
|
|
|
// Detail:"充值",// string `xml:"detail"` // 商品名称明细列表
|
|
|
|
|
//Attach string `xml:"attach"` // 附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
|
|
|
|
|
//FeeType string `xml:"fee_type"` // 符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
|
|
|
|
|
//TimeStart time.Time `xml:"time_start"` // 订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则
|
|
|
|
|
//TimeExpire time.Time `xml:"time_expire"` // 订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则
|
|
|
|
|
//GoodsTag string `xml:"goods_tag"` // 商品标记,代金券或立减优惠功能的参数,说明详见代金券或立减优惠
|
|
|
|
|
// ProductId :"CHONGZHI",// string `xml:"product_id"` // trade_type=NATIVE,此参数必传。此id为二维码中包含的商品ID,商户自行定义。
|
|
|
|
|
// LimitPay string `xml:"limit_pay"` // no_credit--指定不能使用信用卡支付
|
|
|
|
|
OpenId: openid, //user.GetString("wuid"), // string `xml:"openid"` // rade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。
|
|
|
|
|
// SubOpenId string `xml:"sub_openid"` // trade_type=JSAPI,此参数必传,用户在子商户appid下的唯一标识。openid和sub_openid可以选传其中之一,如果选择传sub_openid,则必须传sub_appid。
|
|
|
|
|
// SceneInfo string `xml:"scene_info"` // 该字段用于上报支付的场景信息,针对H5支付有以下三种场景,请根据对应场景上报,H5支付不建议在APP端
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
wcpay := Map{
|
2022-02-28 00:53:38 +00:00
|
|
|
|
"appId": this.Config.Get("wechatAppID"),
|
2022-02-23 22:26:36 +00:00
|
|
|
|
"timeStamp": ObjToStr(time.Now().Unix()),
|
|
|
|
|
"nonceStr": getSn(),
|
|
|
|
|
"package": "prepay_id=" + res.PrepayId,
|
|
|
|
|
"signType": "MD5",
|
|
|
|
|
}
|
2022-02-28 00:53:38 +00:00
|
|
|
|
wcpay["paySign"] = core.JsapiSign(this.Config.GetString("wechatAppID"), wcpay.GetString("timeStamp"), wcpay.GetString("nonceStr"), wcpay.GetString("package"), "MD5", this.Config.GetString("wechatChkey"))
|
2022-02-23 22:26:36 +00:00
|
|
|
|
|
|
|
|
|
return wcpay
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//生成随机码的6位md5
|
|
|
|
|
func getSn() string {
|
|
|
|
|
x := Rand(8)
|
|
|
|
|
return Substr(Md5(ObjToStr(int64(x)+time.Now().UnixNano()+int64(Rand(6)))), 0, 6)
|
|
|
|
|
}
|