|
@@ -1,6 +1,7 @@
|
|
package front
|
|
package front
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "encoding/json"
|
|
"errors"
|
|
"errors"
|
|
"fmt"
|
|
"fmt"
|
|
"jfw/config"
|
|
"jfw/config"
|
|
@@ -19,14 +20,13 @@ import (
|
|
|
|
|
|
type WsDataExport struct {
|
|
type WsDataExport struct {
|
|
*xweb.Action
|
|
*xweb.Action
|
|
- searchExport xweb.Mapper `xweb:"/jyapp/front/wx_dataExport/searchExport"` //微信数据导出
|
|
|
|
- toPreview xweb.Mapper `xweb:"/jyapp/front/wx_dataExport/toPreview/(.*)"` //微信数据导出-预览页面
|
|
|
|
- paySuccessPage xweb.Mapper `xweb:"/jyapp/front/wx_dataExport/paySuccessPage"` //微信数据导出-支付成功页面
|
|
|
|
- getPayParm xweb.Mapper `xweb:"/jyapp/front/wx_dataExport/getPayParm"` //微信数据导出-获取微信支付参数
|
|
|
|
- toCreateOrderPage xweb.Mapper `xweb:"/jyapp/front/wx_dataExport/toCreateOrderPage"` //微信数据导出-订单微信支付
|
|
|
|
- sendMailVerify xweb.Mapper `xweb:"/jyapp/front/dataExport/sendMailVerify"` //发送邮箱验证码
|
|
|
|
- checkMailVerify xweb.Mapper `xweb:"/jyapp/front/dataExport/checkMailVerify"` //验证邮箱验证码
|
|
|
|
- checkPhoneVerify xweb.Mapper `xweb:"/jyapp/front/dataExport/checkPhoneVerify"` //验证手机号
|
|
|
|
|
|
+ searchExport xweb.Mapper `xweb:"/jyapp/front/dataExport/searchExport"` //app数据导出
|
|
|
|
+ paySuccessPage xweb.Mapper `xweb:"/jyapp/front/dataExport/paySuccessPage"` //app数据导出-支付成功页面
|
|
|
|
+ toCreateOrderPage xweb.Mapper `xweb:"/jyapp/front/dataExport/toCreateOrderPage"` //app数据导出-订单支付
|
|
|
|
+ sendMailVerify xweb.Mapper `xweb:"/jyapp/front/dataExport/sendMailVerify"` //发送邮箱验证码
|
|
|
|
+ checkMailVerify xweb.Mapper `xweb:"/jyapp/front/dataExport/checkMailVerify"` //验证邮箱验证码
|
|
|
|
+ checkPhoneVerify xweb.Mapper `xweb:"/jyapp/front/dataExport/checkPhoneVerify"` //验证手机号
|
|
|
|
+ previewData xweb.Mapper `xweb:"/jyapp/front/dataExport/previewData/(.*)"` //app数据导出-数据预览
|
|
}
|
|
}
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
@@ -133,87 +133,60 @@ func (w *WsDataExport) CheckMailVerify() {
|
|
w.ServeJson(&w.T)
|
|
w.ServeJson(&w.T)
|
|
}
|
|
}
|
|
|
|
|
|
-func isEmail(value string) bool {
|
|
|
|
- var emailPattern = regexp.MustCompile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")
|
|
|
|
- return emailPattern.MatchString(value)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//
|
|
|
|
-func (w *WsDataExport) GetPayParm() error {
|
|
|
|
- defer util.Catch()
|
|
|
|
- userid := util.ObjToString(w.GetSession("userId"))
|
|
|
|
- openid := util.ObjToString(w.GetSession("s_m_openid"))
|
|
|
|
- id := util.SE.Decode4Hex(w.GetString("id"))
|
|
|
|
- if userid == "" || id == "" {
|
|
|
|
- log.Println("userid,id 有误!")
|
|
|
|
- w.ServeJson(map[string]interface{}{
|
|
|
|
- "status": 0,
|
|
|
|
- })
|
|
|
|
- return nil
|
|
|
|
|
|
+func (w *WsDataExport) PreviewData(_id string) error {
|
|
|
|
+ userId := util.ObjToString(w.GetSession("userId"))
|
|
|
|
+ if userId == "" {
|
|
|
|
+ return errors.New("未登录")
|
|
}
|
|
}
|
|
- token := w.GetString("token")
|
|
|
|
- fmt.Println(userid, "---", id)
|
|
|
|
- //查看创建过的预支付订单
|
|
|
|
- Order := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
|
|
|
|
- "user_id": userid,
|
|
|
|
- "filter_id": id,
|
|
|
|
- }, "prepay_id,order_code,order_money,id,prepay_time", "")
|
|
|
|
- fmt.Println("Order:", Order)
|
|
|
|
- if Order == nil {
|
|
|
|
- log.Println("查不到订单!")
|
|
|
|
- w.ServeJson(map[string]interface{}{
|
|
|
|
- "status": -1,
|
|
|
|
- })
|
|
|
|
- return nil
|
|
|
|
|
|
+ //数据预览每天限制50次
|
|
|
|
+ incurKey := fmt.Sprintf("PreviewData_%s_%d", w.GetSession("userId"), time.Now().Day())
|
|
|
|
+ times := util.IntAll(redis.Get("other", incurKey))
|
|
|
|
+ if times >= 50 {
|
|
|
|
+ return errors.New("超出预览次数")
|
|
}
|
|
}
|
|
- prepayId := util.ObjToString((*Order)["prepay_id"])
|
|
|
|
- if prepayId == "" {
|
|
|
|
- log.Println("订单有误!")
|
|
|
|
- w.ServeJson(map[string]interface{}{
|
|
|
|
- "status": -2,
|
|
|
|
- })
|
|
|
|
- return nil
|
|
|
|
|
|
+ if times == 0 {
|
|
|
|
+ redis.Put("other", incurKey, 1, 24*60*60)
|
|
|
|
+ } else {
|
|
|
|
+ redis.Incr("other", incurKey)
|
|
}
|
|
}
|
|
- code := util.ObjToString((*Order)["order_code"])
|
|
|
|
- orderid := util.Int64All((*Order)["id"])
|
|
|
|
- orderMoney := util.IntAll((*Order)["order_money"])
|
|
|
|
|
|
+ w.T["id"] = _id
|
|
|
|
+ w.Render("/dataExport/dataExport_previewData.html", &w.T)
|
|
|
|
+ return nil
|
|
|
|
+}
|
|
|
|
|
|
- realToken := public.GetWaitPayToken(orderid, orderMoney, code, "微信", userid)
|
|
|
|
- if realToken != token {
|
|
|
|
- log.Println("token错误!", userid, realToken, token, code, orderMoney, orderid)
|
|
|
|
- return nil
|
|
|
|
- }
|
|
|
|
- prepayTime, err := time.ParseInLocation(util.Date_Full_Layout, util.ObjToString((*Order)["prepay_time"]), time.Local)
|
|
|
|
- surplus_second := prepayTime.Unix() + 7200 - time.Now().Unix()
|
|
|
|
- if err == nil && surplus_second <= 0 {
|
|
|
|
- log.Println("订单过期,重新生成预订单!", userid)
|
|
|
|
- tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "c", w.IP(), openid, "", orderMoney)
|
|
|
|
- if ret != nil {
|
|
|
|
- now := time.Now()
|
|
|
|
- if public.Mysql.Update("dataexport_order", map[string]interface{}{
|
|
|
|
- "id": orderid,
|
|
|
|
- }, map[string]interface{}{
|
|
|
|
- "prepay_time": util.FormatDate(&now, util.Date_Full_Layout),
|
|
|
|
- "prepay_id": (*ret)["prepayid"],
|
|
|
|
- "out_trade_no": tradeno,
|
|
|
|
- }) {
|
|
|
|
- prepayId = (*ret)["prepayid"]
|
|
|
|
- }
|
|
|
|
|
|
+func subUrl(list *[]map[string]interface{}, dataType string) *[]map[string]interface{} {
|
|
|
|
+ for _, v := range *list {
|
|
|
|
+ //加密截取url
|
|
|
|
+ href := util.ObjToString(v["href"])
|
|
|
|
+ url := util.ObjToString(v["url"])
|
|
|
|
+ if len(url) > 40 { //截取剑鱼标讯地址
|
|
|
|
+ v["url"] = url[:40] + "*****" + url[len(url)-10:]
|
|
|
|
+ }
|
|
|
|
+ if len(href) > 40 { //截取原文地址
|
|
|
|
+ v["href"] = href[:40] + "*****" + href[len(href)-10:]
|
|
|
|
+ } else if len(href) > 0 {
|
|
|
|
+ v["href"] = href[:len(href)*8/10] + "*****"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- timestamp := time.Now().Unix()
|
|
|
|
- nonceStr := util.GetRandom(16) + util.GetLetterRandom(16)
|
|
|
|
- sign := util.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", public.WxStruct.Appid, nonceStr, "prepay_id="+prepayId, "MD5", timestamp, public.WxStruct.Key))
|
|
|
|
- w.ServeJson(map[string]interface{}{
|
|
|
|
- "status": 1,
|
|
|
|
- "appId": public.WxStruct.Appid,
|
|
|
|
- "timestamp": fmt.Sprint(timestamp),
|
|
|
|
- "signType": "MD5",
|
|
|
|
- "sign": sign,
|
|
|
|
- "nonceStr": nonceStr,
|
|
|
|
- "prepayId": "prepay_id=" + prepayId,
|
|
|
|
- })
|
|
|
|
- return nil
|
|
|
|
|
|
+ var result []map[string]interface{}
|
|
|
|
+ bytes, marshalErr := json.Marshal(list)
|
|
|
|
+ if marshalErr != nil {
|
|
|
|
+ log.Println("数据导出字体混淆errMarshal", marshalErr)
|
|
|
|
+ return list
|
|
|
|
+ }
|
|
|
|
+ //字体混淆
|
|
|
|
+ hxb := public.GetFontConvertStr(public.ExConf.Font.ConvertVersionDefault, string(bytes), "pc")
|
|
|
|
+ unmarshalErr := json.Unmarshal([]byte(hxb), &result)
|
|
|
|
+ if unmarshalErr != nil {
|
|
|
|
+ log.Println("数据导出字体混淆unmarshalErr", unmarshalErr)
|
|
|
|
+ return list
|
|
|
|
+ }
|
|
|
|
+ return &result
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func isEmail(value string) bool {
|
|
|
|
+ var emailPattern = regexp.MustCompile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")
|
|
|
|
+ return emailPattern.MatchString(value)
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
//
|
|
@@ -226,17 +199,6 @@ func (w *WsDataExport) PaySuccessPage() error {
|
|
return w.Render("/weixin/dataExport/dataExport_paySuccess.html", &w.T)
|
|
return w.Render("/weixin/dataExport/dataExport_paySuccess.html", &w.T)
|
|
}
|
|
}
|
|
|
|
|
|
-//预览
|
|
|
|
-func (w *WsDataExport) ToPreview(_id string) error {
|
|
|
|
- defer util.Catch()
|
|
|
|
- userid, _ := w.Session().Get("userId").(string)
|
|
|
|
- if userid == "" {
|
|
|
|
- return errors.New("未登录")
|
|
|
|
- }
|
|
|
|
- w.T["id"] = _id
|
|
|
|
- return w.Render("/dataExport/dataExport_previewData.html")
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
//创建订单页面
|
|
//创建订单页面
|
|
func (w *WsDataExport) ToCreateOrderPage() error {
|
|
func (w *WsDataExport) ToCreateOrderPage() error {
|
|
defer util.Catch()
|
|
defer util.Catch()
|