删除无关代码

This commit is contained in:
hoteas
2022-03-13 00:24:36 +08:00
parent 730a2e41f5
commit 2b8816c54b
1154 changed files with 0 additions and 415516 deletions
-473
View File
@@ -1,473 +0,0 @@
package app
import (
. "../../../hotime"
. "../../common"
"fmt"
"github.com/xuri/excelize"
"os"
"sort"
"time"
)
var analyseCtr = Ctr{
"home_data": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
if orgId == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Get("org_analyse", "*", Map{"org_id": orgId})
if res == nil {
this.Display(4, "找不到该数据")
return
}
res["home_data"] = res.GetMap("home_data")
res["six_item_data"] = res.GetMap("six_item_data")
res["three_item_data"] = res.GetMap("three_item_data")
res["n_item_data"] = res.GetMap("n_item_data")
this.Display(0, res)
},
"home_excel": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
if orgId == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Get("org_analyse", "*", Map{"org_id": orgId})
if res == nil {
this.Display(4, "找不到该数据")
return
}
homeData := res.GetMap("home_data")
sixItemData := res.GetMap("six_item_data")
threeItemData := res.GetMap("three_item_data")
nItemData := res.GetMap("n_item_data")
filePath := "temp/home" + ObjToStr(orgId) + ".xlsx"
f, e := excelize.OpenFile(this.Config.GetString("tpt") + "/" + filePath)
if e != nil {
f = excelize.NewFile()
// 创建一个工作表
f.NewSheet("IEDC全局分析")
// 创建一个工作表
f.NewSheet("“6”项量化")
f.NewSheet("“3”项定性")
f.NewSheet("“N”项特色")
f.DeleteSheet("Sheet1")
// 设置单元格的值
f.SetCellValue("IEDC全局分析", "A1", "指标项")
f.SetCellValue("IEDC全局分析", "B1", "指标值")
// 设置单元格的值
f.SetCellValue("“6”项量化", "A1", "指标项")
f.SetCellValue("“6”项量化", "B1", "指标值")
// 设置单元格的值
f.SetCellValue("“3”项定性", "A1", "指标项")
f.SetCellValue("“3”项定性", "B1", "指标值")
// 设置单元格的值
f.SetCellValue("“N”项特色", "A1", "指标项")
f.SetCellValue("“N”项特色", "B1", "指标值")
os.MkdirAll(this.Config.GetString("tpt")+"/temp/", os.ModeDir)
// 根据指定路径保存文件
if err := f.SaveAs(this.Config.GetString("tpt") + "/" + filePath); err != nil {
fmt.Println(err)
this.Display(4, "输出异常")
return
}
}
run := func(str string, data Map, f *excelize.File) {
var keys []string
for k := range data {
keys = append(keys, k)
}
//按字典升序排列
sort.Strings(keys)
for k, v := range keys {
// 设置单元格的值
f.SetCellValue(str, "A"+ObjToStr(k+2), v)
f.SetCellValue(str, "B"+ObjToStr(k+2), data[v])
}
}
run("IEDC全局分析", homeData, f)
run("“6”项量化", sixItemData, f)
run("“3”项定性", threeItemData, f)
run("“N”项特色", nItemData, f)
//f.SetCellValue("Sheet1", "B2", 100)
f.Save()
this.Resp.Header().Set("Location", "/"+filePath)
this.Resp.WriteHeader(307) //关键在这里!
this.Display(0, filePath)
},
"home1_data": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
if orgId == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Get("org_analyse", "*", Map{"org_id": orgId})
if res == nil {
this.Display(4, "找不到该数据")
return
}
res["home1_data"] = res.GetMap("home1_data")
res["six_item_data"] = res.GetMap("six_item_data")
res["three_item_data"] = res.GetMap("three_item_data")
res["n_item_data"] = res.GetMap("n_item_data")
this.Display(0, res)
},
"ctg": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
ctgID := ObjToInt(this.Req.FormValue("ctg_id"))
if orgId == 0 || ctgID == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Get("category_analyse", "*", Map{"AND": Map{"org_id": orgId, "category_id": ctgID}})
if res == nil {
this.Display(4, "找不到该数据")
return
}
res["data"] = res.GetMap("data")
res1 := this.Db.Get("org_analyse", "home_data", Map{"org_id": orgId})
res["home"] = res1.GetMap("home_data")
this.Display(0, res)
},
"industrys": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
if orgId == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Select("industry_analyse", "industry_id,name", Map{"org_id": orgId})
if res == nil {
this.Display(4, "找不到该数据")
return
}
this.Display(0, res)
},
"industry": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
industryId := ObjToInt(this.Req.FormValue("industry_id"))
if orgId == 0 || industryId == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Get("industry_analyse", "*", Map{"AND": Map{"org_id": orgId, "industry_id": industryId}})
if res == nil {
this.Display(4, "找不到该数据")
return
}
res["data"] = res.GetMap("data")
res1 := this.Db.Get("org_analyse", "name,home_data", Map{"org_id": orgId})
res["home"] = res1.GetMap("home_data")
res["home_name"] = res1.GetString("name")
this.Display(0, res)
},
"industry_excel": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
industryId := ObjToInt(this.Req.FormValue("industry_id"))
if orgId == 0 || industryId == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Get("industry_analyse", "*", Map{"AND": Map{"org_id": orgId, "industry_id": industryId}})
if res == nil {
this.Display(4, "找不到该数据")
return
}
res["data"] = res.GetMap("data")
//res1 := this.Db.Get("org_analyse", "name,home_data", Map{"org_id": orgId})
//res["home"] = res1.GetMap("home_data")
//res["home_name"] = res1.GetString("name")
filePath := "temp/industry" + ObjToStr(industryId) + "x" + ObjToStr(orgId) + ".xlsx"
f, e := excelize.OpenFile(this.Config.GetString("tpt") + "/" + filePath)
if e != nil {
f = excelize.NewFile()
// 创建一个工作表
f.NewSheet(res.GetString("name"))
f.DeleteSheet("Sheet1")
// 设置单元格的值
f.SetCellValue(res.GetString("name"), "A1", "指标项")
f.SetCellValue(res.GetString("name"), "B1", "指标值")
os.MkdirAll(this.Config.GetString("tpt")+"/temp/", os.ModeDir)
// 根据指定路径保存文件
if err := f.SaveAs(this.Config.GetString("tpt") + "/" + filePath); err != nil {
fmt.Println(err)
this.Display(4, "输出异常")
return
}
}
run := func(str string, data Map, f *excelize.File) {
var keys []string
for k := range data {
keys = append(keys, k)
}
//按字典升序排列
sort.Strings(keys)
for k, v := range keys {
// 设置单元格的值
f.SetCellValue(str, "A"+ObjToStr(k+2), v)
f.SetCellValue(str, "B"+ObjToStr(k+2), data[v])
}
}
run(res.GetString("name"), res.GetMap("data"), f)
//f.SetCellValue("Sheet1", "B2", 100)
f.Save()
this.Resp.Header().Set("Location", "/"+filePath)
this.Resp.WriteHeader(307) //关键在这里!
this.Display(0, filePath)
},
"map": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
industryId := ObjToInt(this.Req.FormValue("industry_id"))
//if orgId == 0 || industryId == 0 {
// this.Display(3, "参数错误")
// return
//}
page := ObjToInt(this.Req.FormValue("page"))
pageSize := ObjToInt(this.Req.FormValue("pageSize"))
search := this.Req.FormValue("search")
where := Map{}
levelStr := this.Req.FormValue("level")
if levelStr != "" {
where["level"] = ObjToInt(levelStr)
}
if orgId != 0 {
where["org_id"] = orgId
}
if industryId != 0 {
where["industry_id"] = industryId
}
if search != "" {
where["name[~]"] = search
}
if len(where) > 1 {
where = Map{"AND": where}
}
if page == 0 {
page = 1
}
if pageSize == 0 {
pageSize = 10
}
count := this.Db.Count("company", where)
companys := this.Db.Page(page, pageSize).PageSelect("company", Map{"[><]industry": "company.industry_id=industry.id"},
"company.id,company.collect_data,company.name,company.level,company.address,company.score,company.lat,company.lng,company.category_id,industry.name AS industry_name,company.industry_id",
where)
for _, res := range companys {
res["collect_data"] = res.GetMap("collect_data")
//if res.GetMap("collect_data") == nil {
// path := "company/" + Md5(res.GetString("name")) + time.Now().Format("/200601021504.json")
//
// data := getCompany(res.GetString("name"), this.Config.GetString("tpt")+"/"+path)
//
// if len(data) != 0 {
// data["path"] = path
// re := this.Db.Update("company", Map{"collect_data": data.ToJsonString(),
// "address": data.GetString("companyAddress"),
// "sn": data.GetString("creditNo"),
// "unit": data.GetString("authority"),
// }, Map{"id": res.GetCeilInt("id")})
// fmt.Println(re)
// res["collect_data"] = data
// res["address"] = data.GetString("companyAddress")
// res["sn"] = data.GetString("creditNo")
// res["unit"] = data.GetString("authority")
// }
//}
}
this.Display(0, Map{"count": count, "pageSize": pageSize, "data": companys})
},
"updateCompany": func(this *Context) {
lng := ObjToFloat64(this.Req.FormValue("lng"))
lat := ObjToFloat64(this.Req.FormValue("lat"))
id := ObjToInt(this.Req.FormValue("id"))
if lng == 0 || lat == 0 || id == 0 {
this.Display(3, "请求异常")
return
}
re := this.Db.Update("company", Map{"lng": lng, "lat": lat}, Map{"id": id})
if re == 0 {
this.Display(4, "更新失败")
return
}
this.Display(0, "更新成功")
},
"companys": func(this *Context) {
page := ObjToInt(this.Req.FormValue("page"))
pageSize := ObjToInt(this.Req.FormValue("pageSize"))
orgId := ObjToInt(this.Req.FormValue("org_id"))
search := this.Req.FormValue("search")
sort := this.Req.FormValue("sort")
where := Map{"state": 0}
levelStr := this.Req.FormValue("level")
if levelStr != "" {
where["level"] = ObjToInt(levelStr)
}
industryId := ObjToInt(this.Req.FormValue("industry_id"))
if industryId != 0 {
where["industry_id"] = industryId
}
if orgId != 0 {
where["org_id"] = orgId
}
if search != "" {
where["name[~]"] = search
}
if len(where) > 1 {
where = Map{"AND": where}
}
if sort != "" {
where["ORDER"] = sort
} else {
where["ORDER"] = "score DESC"
}
if page == 0 {
page = 1
}
if pageSize == 0 {
pageSize = 10
}
count := this.Db.Count("company", where)
companys := this.Db.Page(page, pageSize).PageSelect("company",
"*",
where)
for _, res := range companys {
analyse := res.GetMap("analyse")
if analyse != nil {
for k, v := range analyse {
if ADataType[k] != nil {
analyse[ADataType.GetString(k)] = v
}
}
res["analyse"] = analyse
}
res["upload_data"] = res.GetMap("upload_data")
res["collect_data"] = res.GetMap("collect_data")
res["collect_data"] = res.GetMap("collect_data")
//if res.GetMap("collect_data") == nil && page == 1 {
// go func(res Map, this *Context) {
// path := "company/" + Md5(res.GetString("name")) + time.Now().Format("/200601021504.json")
//
// data := getCompany(res.GetString("name"), this.Config.GetString("tpt")+"/"+path)
//
// if len(data) != 0 {
// data["path"] = path
// this.Db.Update("company", Map{"collect_data": data.ToJsonString(),
// "address": data.GetString("companyAddress"),
// "sn": data.GetString("creditNo"),
// "unit": data.GetString("authority"),
// }, Map{"id": res.GetCeilInt("id")})
// res["collect_data"] = data
// }
// }(res, this)
//}
}
this.Display(0, Map{"count": count, "pageSize": pageSize, "data": companys})
},
"company": func(this *Context) {
id := ObjToInt(this.Req.FormValue("id"))
if id == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Get("company", "*", Map{"id": id})
if res == nil {
this.Display(4, "找不到该数据")
return
}
analyse := res.GetMap("analyse")
if analyse != nil {
for k, v := range analyse {
if ADataType[k] != nil {
analyse[ADataType.GetString(k)] = v
}
}
res["analyse"] = analyse
}
analyse1 := res.GetMap("analyse1")
if analyse1 != nil {
for k, v := range analyse1 {
if ADataType[k] != nil {
analyse1[ADataType.GetString(k)] = v
}
}
res["analyse1"] = analyse1
}
res["upload_data"] = res.GetMap("upload_data")
res["collect_data"] = res.GetMap("collect_data")
if res.GetMap("collect_data") == nil {
go func(res Map) {
path := "company/" + Md5(res.GetString("name")) + time.Now().Format("/200601021504.json")
data := getCompany(res.GetString("name"), this.Config.GetString("tpt")+"/"+path)
if len(data) != 0 {
data["path"] = path
this.Db.Update("company", Map{"collect_data": data.ToJsonString()}, Map{"id": res.GetCeilInt("id")})
res["collect_data"] = data
}
}(res)
}
this.Display(0, res)
},
"company_upload": func(this *Context) {
id := ObjToInt(this.Req.FormValue("id"))
if id == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Get("company", "upload_data,org_id", Map{"id": id})
if res == nil {
this.Display(4, "找不到该数据")
return
}
uploadData := res.GetMap("upload_data")
tags := this.Db.Select("tag", "name,sn,`unit`,description", Map{"AND": Map{"type": 0, "org_id": res.GetCeilInt("org_id")}})
for _, v := range tags {
v["value"] = uploadData[v.GetString("sn")]
}
this.Display(0, tags)
},
}
-19
View File
@@ -1,19 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
//"strings"
)
var Category = Ctr{
//获取列表
"list": func(this *Context) {
re := this.Db.Select("category", "*", Map{"parent_id": 1})
this.Display(0, re)
},
}
-161
View File
@@ -1,161 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
"../../dri/aliyun"
"../../dri/tencent"
"fmt"
"github.com/silenceper/wechat"
"github.com/silenceper/wechat/cache"
"gopkg.in/chanxuehong/wechat.v2/mch/core"
"gopkg.in/chanxuehong/wechat.v2/mch/pay"
"io/ioutil"
"os"
"path/filepath"
"time"
)
// Project 管理端项目
var Project = Proj{
//"user": UserCtr,
"tag": tagCtr,
"analyse": analyseCtr,
"user": User,
"wechat": Wechat,
"question": Question,
"category": Category,
"sms": Sms,
}
var weixin *wechat.Wechat //微信登录实例
//var appIns = Application{}
var wxpayClient *core.Client
//生成随机码的4位随机数
func getCode() string {
//res := ""
//for i := 0; i < 4; i++ {
res := ObjToStr(RandX(1000, 9999))
//}
return res
}
func getCompany(name, path string) Map {
os.Setenv("ZONEINFO", "config/data.zip")
res := tencent.GetCompany("AKIDklZa1qBr3B0x1G643cg8B6UO5JZm2KX8o43G", "tdda7oro526h96dvicYkep1xsWFmHkt33xvqs2K", name)
c := Map{}
base := Map{}
if res.GetInt("code") != 200 {
return base
}
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")
base["ProfileTags"] = data.GetSlice("ProfileTags")
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
}
//微信获取个人信息
func Weixin(this *Context) *wechat.Wechat {
if weixin == nil {
cache1 := cache.Cache(WechatCache{this.CacheIns})
config := wechat.Config{Cache: cache1, AppID: this.Config.GetString("wechatAppID"), AppSecret: this.Config.GetString("wechatAppSecret")}
weixin = wechat.NewWechat(&config)
}
return weixin
}
//微信获取个人信息
func WxPayClient(this *Context, sn string, money int64, openid string) Map {
if wxpayClient == nil {
wxpayClient = core.NewClient(this.Config.GetString("wechatAppID"), this.Config.GetString("wechatChid"), this.Config.GetString("wechatChkey"), nil)
}
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{
"appId": this.Config.Get("wechatAppID"),
"timeStamp": ObjToStr(time.Now().Unix()),
"nonceStr": getSn(),
"package": "prepay_id=" + res.PrepayId,
"signType": "MD5",
}
wcpay["paySign"] = core.JsapiSign(this.Config.GetString("wechatAppID"), wcpay.GetString("timeStamp"), wcpay.GetString("nonceStr"), wcpay.GetString("package"), "MD5", this.Config.GetString("wechatChkey"))
return wcpay
}
//生成随机码的6位md5
func getSn() string {
x := Rand(8)
return Substr(Md5(ObjToStr(int64(x)+time.Now().UnixNano()+int64(Rand(6)))), 0, 6)
}
-87
View File
@@ -1,87 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
"fmt"
"time"
//"strings"
)
var Question = Ctr{
//获取个人信息
"update": func(this *Context) {
if this.Session("user_id").Data == nil {
this.Display(2, "还没有登录")
return
}
questionCompanyId := ObjToInt(this.Req.FormValue("id"))
if questionCompanyId == 0 {
this.Display(3, "参数错误")
return
}
data := this.Req.FormValue("question_data")
if data == "" {
this.Display(3, "没有上传数据")
return
}
status := ObjToInt(this.Req.FormValue("status"))
re := this.Db.Update("question_company", Map{"question_data": data, "status": status}, Map{"id": questionCompanyId})
if re == 0 {
//this.Display(4, "没有更新信息!")
fmt.Println(4, "没有更新信息!")
//return
}
this.Display(0, "更新成功")
},
//获取列表
"list": func(this *Context) {
if this.Session("user_id").Data == nil {
this.Display(2, "还没有登录")
return
}
user := this.Db.Get("user", "*", Map{"id": this.Session("user_id").Data})
t := time.Now().Unix()
questions := this.Db.Select("question", "*", Map{"AND": Map{"org_id": user.GetCeilInt("org_id"), "start_time[>=]": t, "end_time[<=]": t, "state": 0}})
re := []Map{}
for _, v := range questions {
questionCompany := this.Db.Get("question_company", "*", Map{"AND": Map{"question_id": v.GetCeilInt("id"), "company_id": user.GetCeilInt("company_id")}})
if questionCompany == nil {
questionCompany = Map{
"name": v.GetString("name"),
"question_data": v.GetString("question_data"),
"org_id": v.GetString("org_id"),
"question_id": v.GetString("id"),
"company_id": user.GetCeilInt("company_id"),
"user_id": user.GetString("id"),
"create_time": t,
"modify_time": t,
"status": 0,
"state": 0,
}
questionCompany["id"] = this.Db.Insert("question_company", questionCompany)
if questionCompany.GetCeilInt("id") == 0 {
this.Display(4, "无法创建调查数据")
return
}
}
delete(v, "question")
questionCompany["question"] = v
re = append(re, questionCompany)
}
//user["questions"]=re
this.Display(0, re)
},
}
-33
View File
@@ -1,33 +0,0 @@
package app
import (
. "../../../hotime"
"../../dri/ddsms"
)
var Sms = Ctr{
//只允许微信验证过的或者登录成功的发送短信
"send": func(this *Context) {
//if this.Session("uid").Data == nil && this.Session("wechatInfo").Data == nil {
// this.Display(2, "没有授权")
// return
//}
//if len(this.Req.FormValue("token")) != 32 {
// this.Display(2, "没有授权")
// return
//}
phone := this.Req.FormValue("phone")
if len(phone) < 11 {
this.Display(3, "手机号格式错误")
return
}
code := getCode()
this.Session("phone", phone)
this.Session("code", code)
ddsms.DefaultDDY.SendYZM(phone, this.Config.GetString("smsLogin"), map[string]string{"code": code})
this.Display(0, "发送成功")
},
}
-43
View File
@@ -1,43 +0,0 @@
package app
import (
. "../../../hotime"
. "../../common"
)
var tagCtr = Ctr{
"ctg_tree": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
if orgId == 0 {
this.Display(3, "参数错误")
return
}
data := Map{}
run := func(t int) []Map {
//upCtg:=this.Db.Select("tag_ctg","*",Map{"parent_id":id})
//for _,v:=range upCtg{
upTag := this.Db.Select("tag", "*", Map{"AND": Map{"type": t, "org_id": 2}})
upTag1 := this.Db.Select("tag", "*", Map{"AND": Map{"type": t, "org_id": orgId}})
for _, v := range upTag {
check := true
for _, v1 := range upTag1 {
if v1.GetString("sn") == v.GetString("sn") {
check = false
break
}
}
if check {
upTag1 = append(upTag1, v)
}
}
return upTag1
}
data["upload"] = run(0)
data["api"] = run(1)
data["analyse"] = run(2)
this.Display(0, data)
},
}
-116
View File
@@ -1,116 +0,0 @@
package app
import (
. "../../common"
)
var ADataType = Map{
"PJ": "评级",
"ZDF": "总得分",
"NZDF": "N项总得分",
"JGTZDF": "技改投资得分",
"JGTZ": "技改投资金额",
"ZJTXQLDF": "专精特新潜力得分",
"JBZJTXQYJCYQDF": "具备专精特新企业基础要求得分",
"JBZJTXQYYQCPDF": "具备专精特新企业要求产品得分",
"JBZJTXHJJTJDF": "具备专精特新环境及条件得分",
"JBZJTXZSCQYQDF": "具备专精特新知识产权要求得分",
"YFZBDF": "2年研发占比得分",
"KYRYZBDF": "科研人员占比得分",
"ZCFZLDF": "资产负债率得分",
"CYRCDF": "产业人才得分",
"SXZBDF": "3项指标",
"XZFZZBDF": "协作发展指标得分",
"FHDQZDCYDF": "符合地区重点产业得分",
"QYZDQYDF": "区域重点企业",
"SJ100HZDQYDF": "市级100户重点企业得分",
"CYL30HDF": "产业链30户得分",
"LSAQZBDF": "绿色安全指标",
"AQSCGLDF": "安全生产管理得分",
"QYAQSCDBDF": "企业安全生产是否达标得分",
"QYFXYHSKTXJSDF": "企业风险隐患双预控体系建设得分",
"AQSGDF": "安全事故得分",
"AQJCDF": "安全检查得分",
"LSSCGYDF": "绿色生产工艺得分",
"JPJSSJDF": "减排技术升级改造得分",
"HBJCDF": "环保检查得分",
"FZZLZBZDF": "发展质量指标总分",
"QYYLNLZDF": "企业盈利能力总得分",
"KSDF": "企业连续3年亏损得分",
"QYLRL": "企业利润率",
"DNLRZEDF": "当年利润总额得分",
"LXSNYLDF": "连续3年盈利得分",
"ZSCQDF": "知识产权总得分",
"TGMLDF": "推广目录得分",
"ZLDF": "专利得分",
"STTDF": "首台(套)、首批次、首版次企业得分",
"MJSR": "亩均收入",
"MJSRDF": "亩均收入得分",
"MJSS": "亩均税收",
"MJSSDF": "亩均税收得分",
"RJSR": "人均收入",
"RJSRDF": "人均收入得分",
"YFJFTRQD": "研发经费投入强度",
"YFJFTRQDDF": "研发经费投入强度得分",
"DWNHSS": "单位能耗税收",
"DWNHSSDF": "单位能耗税收得分",
"ZYWRWSS": "主要污染物税收",
"ZYWRWSSDF": "主要污染物税收得分",
"NXZBDF": "6项指标得分",
"DJSDLQYDF": "独角兽、瞪羚企业得分",
"JSZXDF": "企业获得技术中心得分",
"YFFYDF": "研发费用得分",
"GXJSQYDF": "高新技术企业得分",
"FZQLDF": "发展潜力总分",
}
-394
View File
@@ -1,394 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
"../../../hotime/dri/download"
"../../../hotime/dri/tencent"
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"strings"
"time"
//"strings"
)
var User = Ctr{
"token": func(this *Context) {
this.Display(0, this.SessionId)
},
"test": func(this *Context) {
fmt.Println(this.SessionId)
this.Session("user_id", 1)
wechat := this.Db.Get("wechat", "*")
this.Session("wechatInfo", wechat)
this.Display(0, "开始测试")
},
//获取个人信息
"info": func(this *Context) {
//this.Session("user_id", 1)
//wechat:=this.Db.Get("wechat","*")
//this.Session("wechatInfo",wechat)
if this.Session("user_id").Data == nil {
if this.Session("wechatInfo").Data != nil {
wechat := this.Db.Get("wechat", "status", Map{"id": this.Session("wechatInfo").ToMap().GetCeilInt("id")})
if wechat.GetCeilInt("status") == 0 {
this.Display(6, "需要认证")
return
}
}
this.Display(2, "还没有登录")
return
}
user := this.Db.Get("user", "*", Map{"id": this.Session("user_id").Data})
if user == nil {
fmt.Println(this.Session("user_id").Data, ":fsdfsd")
this.Display(4, "找不到该用户")
return
}
org := this.Db.Get("org", "contact", Map{"id": user.GetCeilInt("org_id")})
user["org"] = org
company := this.Db.Get("company", "id,name,status", Map{"id": user.GetCeilInt("company_id")})
user["company"] = company
t := time.Now().Unix()
questions := this.Db.Select("question", "*", Map{"AND": Map{"org_id": user.GetCeilInt("org_id"), "state": 0}})
re := []Map{}
for _, v := range questions {
questionCompany := this.Db.Get("question_company", "*", Map{"AND": Map{"question_id": v.GetCeilInt("id"), "company_id": user.GetCeilInt("company_id")}})
if questionCompany == nil {
questionCompany = Map{
"name": v.GetString("name"),
"question_data": v.GetString("question_data"),
"org_id": v.GetString("org_id"),
"question_id": v.GetString("id"),
"company_id": user.GetCeilInt("company_id"),
"user_id": user.GetString("id"),
"create_time": t,
"modify_time": t,
"status": 0,
"state": 0,
}
questionCompany["id"] = this.Db.Insert("question_company", questionCompany)
if questionCompany.GetCeilInt("id") == 0 {
this.Display(4, "无法创建调查数据")
return
}
}
delete(v, "question_data")
questionCompany["question"] = v
questionCompany["question_data"] = questionCompany.GetSlice("question_data")
re = append(re, questionCompany)
}
user["questions"] = re
this.Display(0, user)
},
//身份认证
"auth": func(this *Context) {
wechat := this.Session("wechatInfo").ToMap()
if wechat == nil {
if this.Session("user_id").Data == nil {
this.Display(6, "还没有登录")
return
}
wechat := this.Db.Get("wechat", "*", Map{"user_id": this.Session("user_id").ToCeilInt()})
if wechat == nil {
this.Display(6, "没有微信登录")
return
}
}
if this.Session("code").Data == nil {
this.Display(8, "验证码没有获取")
return
}
//orgId := ObjToInt(this.Req.FormValue("org_id"))
////questionCompanyId:=ObjToInt(this.Req.FormValue("id"))
//if orgId == 0 {
// this.Display(3, "没有选择组织")
// return
//}
name := this.Req.FormValue("name")
phone := this.Req.FormValue("phone")
code := this.Req.FormValue("code")
authImg := this.Req.FormValue("auth_img")
categoryId := ObjToInt(this.Req.FormValue("category_id"))
companyImg := this.Req.FormValue("company_img")
companyName := this.Req.FormValue("company_name")
companySn := this.Req.FormValue("company_sn")
if code != this.Session("code").ToStr() {
this.Display(8, "验证码错误")
return
}
if name == "" || phone == "" || authImg == "" || categoryId == 0 || companyImg == "" || companyName == "" || companySn == "" {
this.Display(3, "参数异常")
return
}
t := time.Now().Unix()
orgId := wechat.GetInt("org_id")
company := this.Db.Get("company", "id", Map{"sn": companySn})
if company == nil {
company = Map{
"name": companyName,
"sn": companySn,
"create_time": t,
"category_id": categoryId,
//"org_id": orgId,
"modify_time": t,
"status": 1,
"state": 0,
"img": companyImg,
}
if wechat.GetInt("status") == 0 && orgId != 0 {
company["org_id"] = orgId
}
company["id"] = this.Db.Insert("company", company)
if company.GetCeilInt("id") == 0 {
this.Display(4, "无法创建企业")
return
}
} else {
company["status"] = 1
company["modify_time"] = t
company["img"] = companyImg
company["name"] = companyName
company["img"] = companyImg
if wechat.GetInt("status") == 0 && orgId != 0 {
company["org_id"] = orgId
}
re := this.Db.Update("company", company, Map{"id": company.GetCeilInt("id")})
if re == 0 {
this.Display(4, "无法更新企业")
return
}
}
user := this.Db.Get("user", "*", Map{"phone": phone})
data := Map{"name": name,
"phone": phone,
//"org_id": orgId,
//"idcard": idcard,
//"idcard_front_img": idcardFrontImg,
"company_id": company.GetCeilInt("id"),
//"idcard_back_img": idcardBackImg,
"auth_img": authImg,
"modify_time": t,
"status": 1,
"company_img": companyImg}
if wechat.GetInt("status") == 0 && orgId != 0 {
data["org_id"] = orgId
}
//用户已经注册则更新
if user != nil {
re := this.Db.Update("user", data, Map{"id": user.GetCeilInt("id")})
if re == 0 {
this.Display(4, "无法更新用户")
return
}
} else {
data["create_time"] = t
if wechat != nil {
data["nickname"] = wechat.GetString("nickname")
path := time.Now().Format(this.Config.GetString("imgPath"))
filename := Md5(ObjToStr(t)) + ".jpg"
down := download.Down(wechat.GetString("avatar"), this.Config.GetString("tpt")+"/"+path, filename)
if down {
data["avatar"] = path + filename
}
}
user = data
user["id"] = this.Db.Insert("user", data)
if user.GetCeilInt("id") == 0 {
this.Display(4, "无法创建用户")
return
}
}
this.Db.Update("wechat", Map{"status": 1, "user_id": user.GetCeilInt("id")}, Map{"id": wechat.GetInt("id")})
this.Session("user_id", user.GetCeilInt("id"))
this.Display(0, this.SessionId)
},
//修改密码g
"forget": func(this *Context) {
if this.Session("code").Data == nil {
this.Display(8, "验证码没有获取")
return
}
if this.Req.FormValue("code") == "" || this.Req.FormValue("umobile") == "" {
this.Display(3, "验证码或者手机号没有输入")
return
}
if this.Req.FormValue("umobile") != this.Session("umobile").ToStr() ||
this.Req.FormValue("code") != this.Session("code").ToStr() {
this.Display(14, "验证码验证失败")
return
}
if len(this.Req.FormValue("upwd")) < 6 {
this.Display(3, "密码没有输入")
return
}
res := this.Db.Update("user", Map{"upwd": Md5(this.Req.FormValue("upwd"))}, Map{"umobile": this.Req.FormValue("umobile")})
if res == 0 {
this.Display(5, "找不到该用户")
return
}
this.Display(0, "成功")
},
"upload": func(this *Context) {
file := this.Req.FormValue("file")
if len(file) < 100 {
this.Display(3, "图片上传错误")
return
}
//fmt.Println(uimg)
btes, e := base64.StdEncoding.DecodeString(file[strings.Index(file, ",")+1:]) //成图片文件并把文件写入到buffer
//btes, e := base64.StdEncoding.DecodeString(file) //成图片文件并把文件写入到buffer
if e != nil {
this.Display(3, "无法解析图片")
return
}
//uimgPath:=time.Now().Format(this.Config.GetString("uimgPath"))
path := time.Now().Format(this.Config.GetString("wxFilePath"))
os.MkdirAll(this.Config.GetString("tpt")+"/"+path, os.ModeDir)
filePath := path + Md5(ObjToStr(time.Now().Unix())) + ".jpg"
err2 := ioutil.WriteFile(this.Config.GetString("tpt")+"/"+filePath, btes, 0666) //buffer输出到jpg文件中(不做处理,直接写到文件)
if err2 != nil {
this.Display(3, "图片保存失败")
return
}
tp := this.Req.FormValue("type")
if tp == "company" {
data := tencent.OCRCOMPANY(file)
c := ObjToMap(data)
if c != nil {
c = c.GetMap("Response")
c["url"] = filePath
} else {
c = Map{"url": filePath}
}
this.Display(0, c)
return
}
if tp == "common" {
data := tencent.OCR(file)
c := ObjToMap(data)
if c != nil {
c = c.GetMap("Response")
c["url"] = filePath
} else {
c = Map{"url": filePath}
}
this.Display(0, c)
return
}
this.Display(0, filePath)
},
//"upload": func(this *Context) {
//
// //读取网络文件
// fi, fheader, err := this.Req.FormFile("file")
// if err != nil {
// this.Display(3, err)
// return
//
// }
// filePath := this.Config.GetString("wxFilePath")
// if filePath == "" {
// filePath = "file/2006/01/02/"
// }
//
// path := time.Now().Format(filePath)
// e := os.MkdirAll(this.Config.GetString("tpt")+"/"+path, os.ModeDir)
//
// if e != nil {
// this.Display(3, e)
// return
// }
//
// filePath = path + Md5(ObjToStr(RandX(100000, 9999999))) + fheader.Filename[strings.LastIndex(fheader.Filename, "."):]
// newFile, e := os.Create(this.Config.GetString("tpt") + "/" + filePath)
//
// if e != nil {
// this.Display(3, e)
// return
// }
//
// _, e = io.Copy(newFile, fi)
//
// if e != nil {
// this.Display(3, e)
// return
// }
//
// //this.Display(0, filePath)
//
// //读取excel
// //fmt.Println(Org[orgId],OrgId)
//
//
// this.Display(0, filePath)
//
//},
//更新个人资料
"update": func(this *Context) {
if this.Req.Form["email"] == nil ||
this.Req.Form["name"] == nil ||
//this.Req.Form["phone"] == nil ||
this.Req.Form["avatar"] == nil ||
this.Req.Form["idcard"] == nil {
this.Display(3, "参数不足")
}
//更新代码
update := Map{
"email": this.Req.FormValue("email"),
"idcard": this.Req.FormValue("idcard"),
"avatar": this.Req.FormValue("avatar"),
"name": this.Req.FormValue("name"),
}
this.Db.Update("user", update, Map{"id": this.Session("user_id").Data})
this.Display(0, "ok")
},
}
-177
View File
@@ -1,177 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/cache"
. "../../../hotime/common"
"fmt"
"github.com/silenceper/wechat"
"github.com/silenceper/wechat/cache"
"time"
)
type WechatCache struct {
CacheIns
}
func (this WechatCache) Get(key string) interface{} {
return this.Cache("x" + key).Data
//return nil
}
func (this WechatCache) Set(key string, val interface{}, timeout time.Duration) error {
this.Cache("x"+key, val, ObjToInt64(timeout.Seconds()))
return nil
}
func (this WechatCache) IsExist(key string) bool {
c := this.Cache("x" + key).Data
if c != nil {
return true
}
return false
}
func (this WechatCache) Delete(key string) error {
this.Cache("x"+key, nil)
return nil
}
var Wechat = Ctr{
"user": func(this *Context) {
if this.Session("wechatInfo").Data == nil {
this.Display(2, "没有登录")
}
this.Display(0, this.Session("wechatInfo").ToMap())
},
//微信注册,0已经完整的注册了,1还没有注册
"codebase": func(this *Context) {
wx := Weixin(this)
auth := wx.GetOauth(this.Req, this.Resp)
resToken, err := auth.GetUserAccessToken(this.Req.FormValue("code"))
if err != nil {
this.Display(6, "code错误")
return
}
//判断用户是否已经注册
user := this.Db.Get("wechat", Map{"[><]user": "wechat.user_id=user.id"}, "user.id,user.state", Map{"openid": resToken.OpenID})
if user != nil {
this.Session("user_id", user.Get("id"))
this.Display(0, 0)
return
}
user_id := this.Db.Insert("user", Map{"time": time.Now().Unix(), "state": 2})
if user_id == 0 {
this.Display(4, "创建用户失败")
return
}
wid := this.Db.Insert("wechat", Map{"openid": resToken.OpenID, "appid": this.Config.GetString("wechatAppID"), "state": 1, "user_id": user_id})
if wid == 0 {
this.Display(4, "关联微信失败!")
return
}
this.Session("user_id", user.Get("id"))
this.Display(0, 1)
},
//微信注册,0已经完整的注册了,1还没有注册
"code": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
//if orgId==0{
// this.Display(3, "缺少组织id")
// return
//}
wx := Weixin(this)
auth := wx.GetOauth(this.Req, this.Resp)
resToken, err := auth.GetUserAccessToken(this.Req.FormValue("code"))
if err != nil {
this.Display(5, "code错误")
return
}
//判断用户是否已经注册
user := this.Db.Get("wechat", Map{"[><]user": "wechat.user_id=user.id"}, "user.id,user.state", Map{"openid": resToken.OpenID})
if user != nil && user.GetCeilInt("id") != 0 && user.GetCeilInt("state") == 0 {
this.Session("user_id", user.Get("id"))
this.Display(0, Map{"type": 0, "token": this.SessionId})
return
}
//getUserInfo
userInfo, err := auth.GetUserInfo(resToken.AccessToken, resToken.OpenID)
if err != nil {
this.Display(6, "微信个人信息无法获取")
return
}
//wechatInfo := ObjToMap(userInfo)
t := time.Now().Unix()
wechatInfo := Map{
"openid": userInfo.OpenID,
"acttoken": resToken.AccessToken,
"retoken": resToken.RefreshToken,
"appid": this.Config.GetString("wechatAppID"),
"unionid": userInfo.Unionid,
"nickname": userInfo.Nickname,
"avatar": userInfo.HeadImgURL,
}
if orgId != 0 {
wechatInfo["org_id"] = orgId
wechatInfo["status"] = 0
}
wechatDb := this.Db.Get("wechat", "*", Map{"openid": wechatInfo.GetString("openid")})
if wechatDb != nil {
this.Db.Update("wechat", wechatInfo, Map{"id": wechatDb.GetCeilInt("id")})
//userInfo["wid"]=wechatDb.GetCeilInt("wid")
} else {
wechatInfo["create_time"] = t
wechatInfo["id"] = this.Db.Insert("wechat", wechatInfo)
}
wechatDb = this.Db.Get("wechat", "*", Map{"openid": wechatInfo.GetString("openid")})
this.Session("wechatInfo", wechatDb)
fmt.Println(wechatDb)
fmt.Println(this.Session("wechatInfo"))
//this.Display(0, 1)
this.Display(0, Map{"type": 1, "token": this.SessionId})
},
//网页签名
"sign": func(this *Context) {
if this.Req.FormValue("sign_url") == "" {
this.Display(2, "参数不足")
return
}
if weixin == nil {
cache1 := cache.Cache(WechatCache{this.CacheIns})
config := wechat.Config{Cache: cache1, AppID: this.Config.GetString("wechatAppID"), AppSecret: this.Config.GetString("wechatAppSecret")}
weixin = wechat.NewWechat(&config)
}
js := weixin.GetJs(this.Req, this.Resp)
cfg, e := js.GetConfig(this.Req.FormValue("sign_url"))
if e != nil {
this.Display(7, e)
return
}
sign := Map{
"appId": cfg.AppID,
"timestamp": cfg.TimeStamp,
"nonceStr": cfg.NonceStr,
"signature": cfg.Signature,
}
this.Display(0, sign)
},
}