|
@@ -1,34 +1,36 @@
|
|
package service
|
|
package service
|
|
|
|
|
|
import (
|
|
import (
|
|
- "bytes"
|
|
|
|
- "encoding/json"
|
|
|
|
- "fmt"
|
|
|
|
- "jy/src/jfw/modules/subscribepay/src/config"
|
|
|
|
- "jy/src/jfw/modules/subscribepay/src/entity"
|
|
|
|
- "jy/src/jfw/modules/subscribepay/src/pay"
|
|
|
|
- "jy/src/jfw/modules/subscribepay/src/util"
|
|
|
|
- "log"
|
|
|
|
- "math"
|
|
|
|
- "regexp"
|
|
|
|
- "time"
|
|
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
|
+ "bytes"
|
|
|
|
+ "encoding/json"
|
|
|
|
+ "fmt"
|
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/config"
|
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/entity"
|
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/pay"
|
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/util"
|
|
|
|
+ "log"
|
|
|
|
+ "math"
|
|
|
|
+ "regexp"
|
|
|
|
+ "strings"
|
|
|
|
+ "time"
|
|
|
|
|
|
- . "app.yhyue.com/moapp/jybase/date"
|
|
|
|
- "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/httpsession"
|
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/dataexport"
|
|
|
|
|
|
+ . "app.yhyue.com/moapp/jybase/date"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/httpsession"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/dataexport"
|
|
|
|
|
|
- qutil "app.yhyue.com/moapp/jybase/common"
|
|
|
|
|
|
+ qutil "app.yhyue.com/moapp/jybase/common"
|
|
)
|
|
)
|
|
|
|
|
|
type DataExportPay struct {
|
|
type DataExportPay struct {
|
|
- *xweb.Action
|
|
|
|
- getPrice xweb.Mapper `xweb:"/dataexport/getPrice"` //获取数据导出价格
|
|
|
|
- createOrder xweb.Mapper `xweb:"/dataExport/createOrder"` //移动端创建订单
|
|
|
|
- //vipDailyDataExport xweb.Mapper `xweb:"/dataExport/vipDaily"` //大会员数据包数据导出
|
|
|
|
- //vipDailyDataExportSuccess xweb.Mapper `xweb:"/dataExport/vipDailySuccess"` //大会员数据包导出生成是否成功
|
|
|
|
- historyById xweb.Mapper `xweb:"/dataExport/historyById"` //历史条件
|
|
|
|
|
|
+ *xweb.Action
|
|
|
|
+ getPrice xweb.Mapper `xweb:"/dataexport/getPrice"` //获取数据导出价格
|
|
|
|
+ createOrder xweb.Mapper `xweb:"/dataExport/createOrder"` //移动端创建订单
|
|
|
|
+ //vipDailyDataExport xweb.Mapper `xweb:"/dataExport/vipDaily"` //大会员数据包数据导出
|
|
|
|
+ //vipDailyDataExportSuccess xweb.Mapper `xweb:"/dataExport/vipDailySuccess"` //大会员数据包导出生成是否成功
|
|
|
|
+ historyById xweb.Mapper `xweb:"/dataExport/historyById"` //历史条件
|
|
}
|
|
}
|
|
|
|
|
|
var reg *regexp.Regexp //匹配特殊字符
|
|
var reg *regexp.Regexp //匹配特殊字符
|
|
@@ -36,241 +38,309 @@ var reg *regexp.Regexp //匹配特殊字符
|
|
var DateFullLayout = "2006-01-02 15:04:05"
|
|
var DateFullLayout = "2006-01-02 15:04:05"
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
- reg, _ = regexp.Compile("[^A-Za-z0-9\u4e00-\u9fa5]")
|
|
|
|
|
|
+ reg, _ = regexp.Compile("[^A-Za-z0-9\u4e00-\u9fa5]")
|
|
}
|
|
}
|
|
|
|
|
|
// dataExportPhoneAndMailCheck 数据导出获取邮箱和手机号
|
|
// dataExportPhoneAndMailCheck 数据导出获取邮箱和手机号
|
|
func dataExportPhoneAndMailCheck(sess *httpsession.Session) (phone, mail string, mailCheck bool) {
|
|
func dataExportPhoneAndMailCheck(sess *httpsession.Session) (phone, mail string, mailCheck bool) {
|
|
- mail, _ = sess.Get("DataExportVerifyEmail_val").(string)
|
|
|
|
- phone, _ = sess.Get("DataExportVerifyPhone").(string)
|
|
|
|
- if phone != "" {
|
|
|
|
- sess.Set("DataExportVerifyPhone_val", phone) //提交后下次默认带出手机号
|
|
|
|
- } else {
|
|
|
|
- phone, _ = sess.Get("DataExportVerifyPhone_val").(string)
|
|
|
|
- }
|
|
|
|
- mailCheck = qutil.ObjToString(sess.Get("DataExportVerifyEmail_val")) != ""
|
|
|
|
- return
|
|
|
|
|
|
+ mail, _ = sess.Get("DataExportVerifyEmail_val").(string)
|
|
|
|
+ phone, _ = sess.Get("DataExportVerifyPhone").(string)
|
|
|
|
+ if phone != "" {
|
|
|
|
+ sess.Set("DataExportVerifyPhone_val", phone) //提交后下次默认带出手机号
|
|
|
|
+ } else {
|
|
|
|
+ phone, _ = sess.Get("DataExportVerifyPhone_val").(string)
|
|
|
|
+ }
|
|
|
|
+ mailCheck = qutil.ObjToString(sess.Get("DataExportVerifyEmail_val")) != ""
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
//移动端创建订单
|
|
//移动端创建订单
|
|
func (p *DataExportPay) CreateOrder() {
|
|
func (p *DataExportPay) CreateOrder() {
|
|
- defer qutil.Catch()
|
|
|
|
- openId, _ := p.GetSession("s_m_openid").(string)
|
|
|
|
- userId, _ := p.GetSession("userId").(string)
|
|
|
|
- id := encrypt.SE.Decode4Hex(p.GetString("id"))
|
|
|
|
- if userId == "" || id == "" {
|
|
|
|
- p.ServeJson(map[string]interface{}{
|
|
|
|
- "status": "n",
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- //
|
|
|
|
- data_spec := p.GetString("data_spec")
|
|
|
|
- if data_spec == "standard" {
|
|
|
|
- data_spec = "标准字段包"
|
|
|
|
- } else if data_spec == "senior" {
|
|
|
|
- data_spec = "高级字段包"
|
|
|
|
- }
|
|
|
|
|
|
+ defer qutil.Catch()
|
|
|
|
+ openId, _ := p.GetSession("s_m_openid").(string)
|
|
|
|
+ userId, _ := p.GetSession("userId").(string)
|
|
|
|
+ id := encrypt.SE.Decode4Hex(p.GetString("id"))
|
|
|
|
+ if userId == "" || id == "" {
|
|
|
|
+ p.ServeJson(map[string]interface{}{
|
|
|
|
+ "status": "n",
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //
|
|
|
|
+ data_spec := p.GetString("data_spec")
|
|
|
|
+ if data_spec == "standard" {
|
|
|
|
+ data_spec = "标准字段包"
|
|
|
|
+ } else if data_spec == "senior" {
|
|
|
|
+ data_spec = "高级字段包"
|
|
|
|
+ }
|
|
|
|
|
|
- data_count := dataexport.GetDataExportSearchCountByScdId(util.MQFW, util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch, id)
|
|
|
|
- if data_count > config.ExConf.MsgMaxCount || data_count == -1 {
|
|
|
|
- data_count = config.ExConf.MsgMaxCount
|
|
|
|
- }
|
|
|
|
|
|
+ data_count := dataexport.GetDataExportSearchCountByScdId(util.MQFW, util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch, id)
|
|
|
|
+ if data_count > config.ExConf.MsgMaxCount || data_count == -1 {
|
|
|
|
+ data_count = config.ExConf.MsgMaxCount
|
|
|
|
+ }
|
|
|
|
|
|
- if data_count <= 0 {
|
|
|
|
- p.ServeJson(map[string]interface{}{
|
|
|
|
- "status": "n",
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ if data_count <= 0 {
|
|
|
|
+ p.ServeJson(map[string]interface{}{
|
|
|
|
+ "status": "n",
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
|
|
- user_phone, user_mail, user_mail_status := entity.JyCommonOrderStruct.DataExportPhoneAndMailCheck(p.Session())
|
|
|
|
|
|
+ user_phone, user_mail, user_mail_status := entity.JyCommonOrderStruct.DataExportPhoneAndMailCheck(p.Session())
|
|
|
|
|
|
- order_money_, original_price_ := float64(0), float64(0)
|
|
|
|
- if data_spec == "标准字段包" {
|
|
|
|
- original_price_ = float64(data_count) * config.ExConf.UnitPrice_normal
|
|
|
|
- } else if data_spec == "高级字段包" {
|
|
|
|
- original_price_ = float64(data_count) * config.ExConf.UnitPrice_senior
|
|
|
|
- }
|
|
|
|
- order_money_ = float64(original_price_) * config.ExConf.Discount
|
|
|
|
- if order_money_ < config.ExConf.OrderMinPrice {
|
|
|
|
- order_money_ = config.ExConf.OrderMinPrice
|
|
|
|
- }
|
|
|
|
- if original_price_ < config.ExConf.OrderMinPrice {
|
|
|
|
- original_price_ = config.ExConf.OrderMinPrice
|
|
|
|
- }
|
|
|
|
- order_money := int(order_money_ * 100)
|
|
|
|
- original_price := int(original_price_ * 100)
|
|
|
|
|
|
+ order_money_, original_price_ := float64(0), float64(0)
|
|
|
|
+ if data_spec == "标准字段包" {
|
|
|
|
+ original_price_ = float64(data_count) * config.ExConf.UnitPrice_normal
|
|
|
|
+ } else if data_spec == "高级字段包" {
|
|
|
|
+ original_price_ = float64(data_count) * config.ExConf.UnitPrice_senior
|
|
|
|
+ }
|
|
|
|
+ order_money_ = float64(original_price_) * config.ExConf.Discount
|
|
|
|
+ if order_money_ < config.ExConf.OrderMinPrice {
|
|
|
|
+ order_money_ = config.ExConf.OrderMinPrice
|
|
|
|
+ }
|
|
|
|
+ if original_price_ < config.ExConf.OrderMinPrice {
|
|
|
|
+ original_price_ = config.ExConf.OrderMinPrice
|
|
|
|
+ }
|
|
|
|
+ order_money := int(order_money_ * 100)
|
|
|
|
+ original_price := int(original_price_ * 100)
|
|
|
|
|
|
- filter_keys, filter_publishtime, filter, disWord := "", "", "", ""
|
|
|
|
|
|
+ filter_keys, filter_publishtime, filter, disWord := "", "", "", ""
|
|
|
|
|
|
- isPass := func() bool {
|
|
|
|
- if user_mail == "" || user_phone == "" || !user_mail_status || data_spec == "" || order_money <= 0 || data_count <= 0 || original_price <= 0 {
|
|
|
|
- log.Println("参数不合法! user_mail,user_phone, user_mail_status, data_spec, order_money, data_count, original_price", user_mail, user_phone, user_mail_status, data_spec, order_money, data_count, original_price)
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- userfilter, ok := util.MQFW.FindById("export_search", id, nil)
|
|
|
|
- if ok && userfilter != nil {
|
|
|
|
- keywords, _ := (*userfilter)["keywords"].([]interface{})
|
|
|
|
- var buffer bytes.Buffer
|
|
|
|
- for _, v := range keywords {
|
|
|
|
- vm, _ := v.(map[string]interface{})
|
|
|
|
- if buffer.Len() > 0 {
|
|
|
|
- buffer.WriteString(",")
|
|
|
|
- }
|
|
|
|
- buffer.WriteString(qutil.ObjToString(vm["keyword"]))
|
|
|
|
- }
|
|
|
|
- filter_keys = buffer.String()
|
|
|
|
- filter_publishtime = qutil.ObjToString((*userfilter)["publishtime"])
|
|
|
|
- disWord = qutil.ObjToString((*userfilter)["disWord"])
|
|
|
|
- log.Println("口令:", disWord, config.Config.TermValidity)
|
|
|
|
- delete(*userfilter, "selectIds")
|
|
|
|
- filterByte, _ := json.Marshal(userfilter)
|
|
|
|
- filter = string(filterByte)
|
|
|
|
|
|
+ isPass := func() bool {
|
|
|
|
+ if user_mail == "" || user_phone == "" || !user_mail_status || data_spec == "" || order_money <= 0 || data_count <= 0 || original_price <= 0 {
|
|
|
|
+ log.Println("参数不合法! user_mail,user_phone, user_mail_status, data_spec, order_money, data_count, original_price", user_mail, user_phone, user_mail_status, data_spec, order_money, data_count, original_price)
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ userfilter, ok := util.MQFW.FindById("export_search", id, nil)
|
|
|
|
+ if ok && userfilter != nil {
|
|
|
|
+ keywords, _ := (*userfilter)["keywords"].([]interface{})
|
|
|
|
+ var buffer bytes.Buffer
|
|
|
|
+ for _, v := range keywords {
|
|
|
|
+ vm, _ := v.(map[string]interface{})
|
|
|
|
+ if buffer.Len() > 0 {
|
|
|
|
+ buffer.WriteString(",")
|
|
|
|
+ }
|
|
|
|
+ buffer.WriteString(qutil.ObjToString(vm["keyword"]))
|
|
|
|
+ }
|
|
|
|
+ filter_keys = buffer.String()
|
|
|
|
+ filter_publishtime = qutil.ObjToString((*userfilter)["publishtime"])
|
|
|
|
+ disWord = qutil.ObjToString((*userfilter)["disWord"])
|
|
|
|
+ log.Println("口令:", disWord, config.Config.TermValidity)
|
|
|
|
+ delete(*userfilter, "selectIds")
|
|
|
|
+ filterByte, _ := json.Marshal(userfilter)
|
|
|
|
+ filter = string(filterByte)
|
|
|
|
|
|
- } else {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
- }()
|
|
|
|
- nickname, _ := p.GetSession("s_nickname").(string)
|
|
|
|
- result := map[string]interface{}{
|
|
|
|
- "status": "n",
|
|
|
|
- }
|
|
|
|
- if isPass {
|
|
|
|
- //用户当前使用卡卷
|
|
|
|
- userLotteryId := ""
|
|
|
|
- var discount float64
|
|
|
|
- full_price, reduce_price := 0, 0
|
|
|
|
- //卡卷信息的id
|
|
|
|
- lotteryId := p.GetString("lotteryId")
|
|
|
|
- discount_price := 0
|
|
|
|
- if lotteryId != "" {
|
|
|
|
- full_price, reduce_price, discount, userLotteryId = util.GetCouponInfo(userId, lotteryId, config.CouponConfig.Products["数据导出"])
|
|
|
|
- if full_price <= order_money {
|
|
|
|
- if discount == 100 {
|
|
|
|
- order_money = order_money - reduce_price
|
|
|
|
- discount_price = reduce_price
|
|
|
|
- } else {
|
|
|
|
- //折扣
|
|
|
|
- disCount_int := int(math.Ceil(discount * 100))
|
|
|
|
- discount_price = order_money - order_money*disCount_int/1000
|
|
|
|
- order_money = order_money * disCount_int / 1000
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- userLotteryId = ""
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ordercode := pay.GetOrderCode(openId)
|
|
|
|
- download_url := util.GetExcelFilePath(ordercode)
|
|
|
|
- go func() {
|
|
|
|
- list, err := dataexport.GetDataExportSearchResultByScdId(util.MQFW, util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch, id, qutil.If(data_spec == "高级字段包", "2", "1").(string), data_count)
|
|
|
|
- if err == nil && list != nil && len(*list) > 0 {
|
|
|
|
- list = dataexport.FormatExportData(util.MQFWENT, list, config.Config.WebDomain, qutil.If(data_spec == "高级字段包", "2", "1").(string))
|
|
|
|
- err = util.CreateDataExportExcelFile(list, data_spec == "高级字段包", config.ExConf.ExcelReadyPath+download_url)
|
|
|
|
- }
|
|
|
|
- if err != nil {
|
|
|
|
- errMeg := fmt.Sprintf("数据导出生成订单异常\n用户id:%s\n订单号:%s\n异常信息:%v:", userId, ordercode, err)
|
|
|
|
- util.SendErrNoteToMail(errMeg)
|
|
|
|
- }
|
|
|
|
- }()
|
|
|
|
- now := time.Now()
|
|
|
|
- distributionChannel, orderChannel := util.GetJyOrderChannel(disWord, p.Header("User-Agent"))
|
|
|
|
- entId := qutil.Int64All(p.GetSession("entId"))
|
|
|
|
- buy_subject := 1
|
|
|
|
- if entId > 0 {
|
|
|
|
- buy_subject = 2
|
|
|
|
- }
|
|
|
|
- orderid := util.Mysql.Insert("dataexport_order", map[string]interface{}{
|
|
|
|
- "order_money": order_money,
|
|
|
|
- "order_status": 0,
|
|
|
|
- "service_status": 0,
|
|
|
|
- "user_nickname": nickname,
|
|
|
|
- "user_openid": openId,
|
|
|
|
- "filter": filter,
|
|
|
|
- "order_code": ordercode,
|
|
|
|
- "product_type": "历史数据",
|
|
|
|
- "create_time": FormatDate(&now, Date_Full_Layout),
|
|
|
|
- "original_price": original_price,
|
|
|
|
- "data_spec": data_spec,
|
|
|
|
- "user_mail": user_mail,
|
|
|
|
- "user_phone": user_phone,
|
|
|
|
- "data_count": data_count,
|
|
|
|
- "filter_publishtime": filter_publishtime,
|
|
|
|
- "filter_keys": filter_keys,
|
|
|
|
- "filter_id": id,
|
|
|
|
- "user_id": userId, //20190719 移动端数据导出 生订单添加用户id
|
|
|
|
- "download_url": download_url,
|
|
|
|
- "discount_price": discount_price,
|
|
|
|
- "d_relation_id": userLotteryId,
|
|
|
|
- "dis_word": disWord, //202020817分销口令
|
|
|
|
- "distribution_channel": distributionChannel, //销售渠道
|
|
|
|
- "order_channel": orderChannel, //下单渠道
|
|
|
|
- "audit_status": 3, //默认审核通过
|
|
|
|
- "buy_subject": buy_subject,
|
|
|
|
- "ent_id": entId,
|
|
|
|
- })
|
|
|
|
- if orderid > 0 {
|
|
|
|
- p.SetSession("DataExportVerifyPhone_val", user_phone)
|
|
|
|
- result["status"] = "y"
|
|
|
|
- result["code"] = ordercode
|
|
|
|
- //保存结构化数据信息 记录
|
|
|
|
- go func() {
|
|
|
|
- if p.GetSession("Structed") != nil && p.GetSession("Structed").(bool) {
|
|
|
|
- //姓名 手机号 邮箱
|
|
|
|
- nickname, _ := p.GetSession("s_nickname").(string)
|
|
|
|
- user_mail, _ := p.GetSession("DataExportVerifyEmail_val").(string)
|
|
|
|
- user_phone, _ := p.GetSession("DataExportVerifyPhone").(string)
|
|
|
|
- if user_phone == "" {
|
|
|
|
- user_phone, _ = p.GetSession("DataExportVerifyPhone_val").(string)
|
|
|
|
- }
|
|
|
|
- util.StructedDataByExportData(nickname, user_mail, user_phone)
|
|
|
|
- //清除存储标识
|
|
|
|
- p.DelSession("Structed")
|
|
|
|
- }
|
|
|
|
- }()
|
|
|
|
- //绑定卡卷
|
|
|
|
- if userLotteryId != "" && lotteryId != "" {
|
|
|
|
- go func(userId, userLotteryId, order_code string) {
|
|
|
|
- nickname, _ := p.Session().Get("s_nickname").(string)
|
|
|
|
- phone, _ := p.Session().Get("phone").(string)
|
|
|
|
- if !util.UpdateCouponState(userId, userLotteryId, nickname, phone, order_code, "数据导出", "", 3, 0) {
|
|
|
|
- log.Println(fmt.Sprintf("单号%s-绑定失败-卡卷%s", order_code, userLotteryId))
|
|
|
|
- }
|
|
|
|
- }(userId, userLotteryId, ordercode)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- p.ServeJson(result)
|
|
|
|
|
|
+ } else {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
|
|
+ }()
|
|
|
|
+ nickname, _ := p.GetSession("s_nickname").(string)
|
|
|
|
+ result := map[string]interface{}{
|
|
|
|
+ "status": "n",
|
|
|
|
+ }
|
|
|
|
+ if isPass {
|
|
|
|
+ //用户当前使用卡卷
|
|
|
|
+ userLotteryId := ""
|
|
|
|
+ var discount float64
|
|
|
|
+ full_price, reduce_price := 0, 0
|
|
|
|
+ //卡卷信息的id
|
|
|
|
+ lotteryId := p.GetString("lotteryId")
|
|
|
|
+ discount_price := 0
|
|
|
|
+ if lotteryId != "" {
|
|
|
|
+ full_price, reduce_price, discount, userLotteryId = util.GetCouponInfo(userId, lotteryId, config.CouponConfig.Products["数据导出"])
|
|
|
|
+ if full_price <= order_money {
|
|
|
|
+ if discount == 100 {
|
|
|
|
+ order_money = order_money - reduce_price
|
|
|
|
+ discount_price = reduce_price
|
|
|
|
+ } else {
|
|
|
|
+ //折扣
|
|
|
|
+ disCount_int := int(math.Ceil(discount * 100))
|
|
|
|
+ discount_price = order_money - order_money*disCount_int/1000
|
|
|
|
+ order_money = order_money * disCount_int / 1000
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ userLotteryId = ""
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ordercode := pay.GetOrderCode(openId)
|
|
|
|
+ download_url := util.GetExcelFilePath(ordercode)
|
|
|
|
+ go func() {
|
|
|
|
+ list, err := dataexport.GetDataExportSearchResultByScdId(util.MQFW, util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch, id, qutil.If(data_spec == "高级字段包", "2", "1").(string), data_count)
|
|
|
|
+ if err == nil && list != nil && len(*list) > 0 {
|
|
|
|
+ list = dataexport.FormatExportData(util.MQFWENT, list, config.Config.WebDomain, qutil.If(data_spec == "高级字段包", "2", "1").(string))
|
|
|
|
+ err = util.CreateDataExportExcelFile(list, data_spec == "高级字段包", config.ExConf.ExcelReadyPath+download_url)
|
|
|
|
+ }
|
|
|
|
+ if err != nil {
|
|
|
|
+ errMeg := fmt.Sprintf("数据导出生成订单异常\n用户id:%s\n订单号:%s\n异常信息:%v:", userId, ordercode, err)
|
|
|
|
+ util.SendErrNoteToMail(errMeg)
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+ now := time.Now()
|
|
|
|
+ distributionChannel, orderChannel := util.GetJyOrderChannel(disWord, p.Header("User-Agent"))
|
|
|
|
+ entId := qutil.Int64All(p.GetSession("entId"))
|
|
|
|
+ buy_subject := 1
|
|
|
|
+ if entId > 0 {
|
|
|
|
+ buy_subject = 2
|
|
|
|
+ }
|
|
|
|
+ orderid := util.Mysql.Insert("dataexport_order", map[string]interface{}{
|
|
|
|
+ "order_money": order_money,
|
|
|
|
+ "order_status": 0,
|
|
|
|
+ "service_status": 0,
|
|
|
|
+ "user_nickname": nickname,
|
|
|
|
+ "user_openid": openId,
|
|
|
|
+ "filter": filter,
|
|
|
|
+ "order_code": ordercode,
|
|
|
|
+ "product_type": "历史数据",
|
|
|
|
+ "create_time": FormatDate(&now, Date_Full_Layout),
|
|
|
|
+ "original_price": original_price,
|
|
|
|
+ "data_spec": data_spec,
|
|
|
|
+ "user_mail": user_mail,
|
|
|
|
+ "user_phone": user_phone,
|
|
|
|
+ "data_count": data_count,
|
|
|
|
+ "filter_publishtime": filter_publishtime,
|
|
|
|
+ "filter_keys": filter_keys,
|
|
|
|
+ "filter_id": id,
|
|
|
|
+ "user_id": userId, //20190719 移动端数据导出 生订单添加用户id
|
|
|
|
+ "download_url": download_url,
|
|
|
|
+ "discount_price": discount_price,
|
|
|
|
+ "d_relation_id": userLotteryId,
|
|
|
|
+ "dis_word": disWord, //202020817分销口令
|
|
|
|
+ "distribution_channel": distributionChannel, //销售渠道
|
|
|
|
+ "order_channel": orderChannel, //下单渠道
|
|
|
|
+ "audit_status": 3, //默认审核通过
|
|
|
|
+ "buy_subject": buy_subject,
|
|
|
|
+ "ent_id": entId,
|
|
|
|
+ })
|
|
|
|
+ if orderid > 0 {
|
|
|
|
+ p.SetSession("DataExportVerifyPhone_val", user_phone)
|
|
|
|
+ result["status"] = "y"
|
|
|
|
+ result["code"] = ordercode
|
|
|
|
+ //保存结构化数据信息 记录
|
|
|
|
+ go func() {
|
|
|
|
+ if p.GetSession("Structed") != nil && p.GetSession("Structed").(bool) {
|
|
|
|
+ //姓名 手机号 邮箱
|
|
|
|
+ nickname, _ := p.GetSession("s_nickname").(string)
|
|
|
|
+ user_mail, _ := p.GetSession("DataExportVerifyEmail_val").(string)
|
|
|
|
+ user_phone, _ := p.GetSession("DataExportVerifyPhone").(string)
|
|
|
|
+ if user_phone == "" {
|
|
|
|
+ user_phone, _ = p.GetSession("DataExportVerifyPhone_val").(string)
|
|
|
|
+ }
|
|
|
|
+ util.StructedDataByExportData(nickname, user_mail, user_phone)
|
|
|
|
+ //清除存储标识
|
|
|
|
+ p.DelSession("Structed")
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+ //绑定卡卷
|
|
|
|
+ if userLotteryId != "" && lotteryId != "" {
|
|
|
|
+ go func(userId, userLotteryId, order_code string) {
|
|
|
|
+ nickname, _ := p.Session().Get("s_nickname").(string)
|
|
|
|
+ phone, _ := p.Session().Get("phone").(string)
|
|
|
|
+ if !util.UpdateCouponState(userId, userLotteryId, nickname, phone, order_code, "数据导出", "", 3, 0) {
|
|
|
|
+ log.Println(fmt.Sprintf("单号%s-绑定失败-卡卷%s", order_code, userLotteryId))
|
|
|
|
+ }
|
|
|
|
+ }(userId, userLotteryId, ordercode)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ p.ServeJson(result)
|
|
}
|
|
}
|
|
|
|
|
|
//获取价格
|
|
//获取价格
|
|
func (p *DataExportPay) GetPrice() {
|
|
func (p *DataExportPay) GetPrice() {
|
|
- //获取数量
|
|
|
|
- p.ServeJson(map[string]interface{}{
|
|
|
|
- "unitPrice_normal": config.ExConf.UnitPrice_normal,
|
|
|
|
- "unitPrice_senior": config.ExConf.UnitPrice_senior,
|
|
|
|
- "discount": config.ExConf.Discount,
|
|
|
|
- "orderMinPrice": config.ExConf.OrderMinPrice,
|
|
|
|
- "msgMaxCount": config.ExConf.MsgMaxCount,
|
|
|
|
- })
|
|
|
|
|
|
+ //获取数量
|
|
|
|
+ p.ServeJson(map[string]interface{}{
|
|
|
|
+ "unitPrice_normal": config.ExConf.UnitPrice_normal,
|
|
|
|
+ "unitPrice_senior": config.ExConf.UnitPrice_senior,
|
|
|
|
+ "discount": config.ExConf.Discount,
|
|
|
|
+ "orderMinPrice": config.ExConf.OrderMinPrice,
|
|
|
|
+ "msgMaxCount": config.ExConf.MsgMaxCount,
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
//根据id获取导出条件
|
|
//根据id获取导出条件
|
|
func (p *DataExportPay) HistoryById() {
|
|
func (p *DataExportPay) HistoryById() {
|
|
- id := p.GetString("id")
|
|
|
|
- id = encrypt.SE.Decode4Hex(id)
|
|
|
|
- if id != "" {
|
|
|
|
- data, _ := util.MQFW.FindById("export_search", id, nil)
|
|
|
|
- if data != nil {
|
|
|
|
- delete(*data, "_id")
|
|
|
|
- delete(*data, "comeintime")
|
|
|
|
- delete(*data, "comeinfrom")
|
|
|
|
- delete(*data, "s_openid")
|
|
|
|
- delete(*data, "s_userid")
|
|
|
|
- }
|
|
|
|
- p.ServeJson(data)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- p.ServeJson(map[string]interface{}{})
|
|
|
|
|
|
+ id := p.GetString("id")
|
|
|
|
+ id = encrypt.SE.Decode4Hex(id)
|
|
|
|
+ if id != "" {
|
|
|
|
+ data, _ := util.MQFW.FindById("export_search", id, nil)
|
|
|
|
+ if data != nil {
|
|
|
|
+ delete(*data, "_id")
|
|
|
|
+ delete(*data, "comeintime")
|
|
|
|
+ delete(*data, "comeinfrom")
|
|
|
|
+ delete(*data, "s_openid")
|
|
|
|
+ delete(*data, "s_userid")
|
|
|
|
+ searchMode := qutil.IntAll((*data)["searchMode"]) //搜索模式:0:精准搜索;1:模糊搜索
|
|
|
|
+ wordsMode := qutil.IntAll((*data)["wordsMode"]) //搜索关键词模式;默认0:包含所有,1:包含任意
|
|
|
|
+ if (*data)["keywords"] != nil && (searchMode > 0 || wordsMode > 0) {
|
|
|
|
+ if keywords := qutil.ObjArrToMapArr((*data)["keywords"].([]interface{})); len(keywords) > 0 {
|
|
|
|
+ var (
|
|
|
|
+ kws []map[string]interface{}
|
|
|
|
+ )
|
|
|
|
+ for _, kv := range keywords {
|
|
|
|
+ kw := KeywordExport{}
|
|
|
|
+ b, e := json.Marshal(kv)
|
|
|
|
+ if e != nil {
|
|
|
|
+ log.Println(e.Error())
|
|
|
|
+ }
|
|
|
|
+ json.Unmarshal(b, &kw)
|
|
|
|
+ kws = append(kws, kw.KeywordsFormat(wordsMode, searchMode)...)
|
|
|
|
+ }
|
|
|
|
+ (*data)["keywords"] = kws
|
|
|
|
+ log.Println("kws:", kws)
|
|
|
|
+ } //关键词
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ p.ServeJson(data)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ p.ServeJson(map[string]interface{}{})
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type KeywordExport struct {
|
|
|
|
+ Keyword string `json:"keyword"`
|
|
|
|
+ Appended []string `json:"appended"`
|
|
|
|
+ Exclude []string `json:"exclude"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// KeywordsFormat 关键词处理
|
|
|
|
+func (k *KeywordExport) KeywordsFormat(wordsMode, searchMode int) (res []map[string]interface{}) {
|
|
|
|
+ esAddrS := config.Config.Elasticsearch
|
|
|
|
+ //搜索模式:0:精准搜索;1:模糊搜索
|
|
|
|
+ if searchMode == 1 && esAddrS != "" {
|
|
|
|
+ esAddr := strings.Split(esAddrS, ",")[0]
|
|
|
|
+ if ikWords := jy.HttpEs(k.Keyword, "ik_smart", esAddr); ikWords != "" {
|
|
|
|
+ k.Keyword = strings.ReplaceAll(ikWords, "+", " ")
|
|
|
|
+ }
|
|
|
|
+ if len(k.Appended) > 0 {
|
|
|
|
+ for kai, kav := range k.Appended {
|
|
|
|
+ if ikWords := jy.HttpEs(kav, "ik_smart", esAddr); ikWords != "" {
|
|
|
|
+ k.Appended[kai] = strings.ReplaceAll(ikWords, "+", " ")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //搜索关键词模式;默认0:包含所有,1:包含任意
|
|
|
|
+ if wordsMode == 1 {
|
|
|
|
+ if len(k.Appended) > 0 {
|
|
|
|
+ res = append(res, map[string]interface{}{
|
|
|
|
+ "keyword": k.Keyword,
|
|
|
|
+ "appended": []string{},
|
|
|
|
+ "exclude": k.Exclude,
|
|
|
|
+ })
|
|
|
|
+ for _, kav := range k.Appended {
|
|
|
|
+ res = append(res, map[string]interface{}{
|
|
|
|
+ "keyword": kav,
|
|
|
|
+ "appended": []string{},
|
|
|
|
+ "exclude": k.Exclude,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return res
|
|
|
|
+ }
|
|
|
|
+ return append(res, map[string]interface{}{
|
|
|
|
+ "keyword": k.Keyword,
|
|
|
|
+ "appended": k.Appended,
|
|
|
|
+ "exclude": k.Exclude,
|
|
|
|
+ })
|
|
}
|
|
}
|