|
@@ -1,12 +1,13 @@
|
|
|
package dataexport
|
|
|
|
|
|
import (
|
|
|
- qutil "app.yhyue.com/moapp/jybase/common"
|
|
|
- "app.yhyue.com/moapp/jybase/mysql"
|
|
|
- "app.yhyue.com/moapp/jybase/redis"
|
|
|
"fmt"
|
|
|
"strings"
|
|
|
"sync"
|
|
|
+
|
|
|
+ qutil "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/mysql"
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
)
|
|
|
|
|
|
const (
|
|
@@ -16,32 +17,14 @@ const (
|
|
|
)
|
|
|
|
|
|
// GetLastExportPhoneAndMail 数据导出联想上次导出手机号和邮箱查询
|
|
|
-func GetLastExportPhoneAndMail(mysqlSess *mysql.Mysql, userId, entUserId string) (phone, email string) {
|
|
|
- var searchSql []string
|
|
|
- var searchValue []interface{}
|
|
|
-
|
|
|
- if userId != "" {
|
|
|
- //个人直接支付数据导出
|
|
|
- searchSql = append(searchSql, `(SELECT user_phone AS phone,user_mail AS mail,UNIX_TIMESTAMP(create_time) AS exportDate FROM dataexport_order where user_mail IS NOT NULL and user_phone is NOT NULL AND user_id =? AND product_type ='历史数据' ORDER BY create_time DESC LIMIT 1)`)
|
|
|
- searchValue = append(searchValue, userId)
|
|
|
-
|
|
|
- //每日限量包和个人线上数据包
|
|
|
- searchSql = append(searchSql, `(SELECT phone,mail,date AS exportDate FROM datapacket_record WHERE phone IS NOT NULL AND mail IS NOT NULL AND useid = ? ORDER BY id DESC LIMIT 1)`)
|
|
|
- searchValue = append(searchValue, userId)
|
|
|
-
|
|
|
+func GetLastExportPhoneAndMail(mysqlSess *mysql.Mysql, userId string) (phone, mail string) {
|
|
|
+ datas1 := mysqlSess.SelectBySql(`SELECT phone FROM datapacket_record WHERE useid=? AND phone IS NOT NULL AND phone<>'' ORDER BY date DESC LIMIT 1`, userId)
|
|
|
+ if datas1 != nil && len(*datas1) == 1 {
|
|
|
+ phone = (*datas1)[0]["phone"].(string)
|
|
|
}
|
|
|
-
|
|
|
- //企业数据导出查询
|
|
|
- if entUserId != "" {
|
|
|
- searchSql = append(searchSql, `(SELECT export_phone AS phone,export_mail AS mail,UNIX_TIMESTAMP(export_time) AS exportDate FROM entniche_export_log WHERE export_phone IS NOT NULL AND export_mail IS NOT NULL AND user_id =? ORDER BY id desc limit 1)`)
|
|
|
- searchValue = append(searchValue, entUserId)
|
|
|
- }
|
|
|
-
|
|
|
- //log.Println(fmt.Sprintf(`SELECT phone,mail FROM ( %s ) AS allData ORDER BY exportDate DESC limit 1`, strings.Join(searchSql, ` UNION ALL `)))
|
|
|
- res := mysqlSess.Query(fmt.Sprintf(`SELECT phone,mail FROM ( %s ) AS allData ORDER BY exportDate DESC limit 1`, strings.Join(searchSql, ` UNION ALL `)), searchValue...)
|
|
|
- if res != nil && len(*res) > 0 {
|
|
|
- phone, _ = (*res)[0]["phone"].(string)
|
|
|
- email, _ = (*res)[0]["mail"].(string)
|
|
|
+ datas2 := mysqlSess.SelectBySql(`SELECT mail FROM datapacket_record WHERE useid=? AND mail IS NOT NULL AND mail<>'' ORDER BY date DESC LIMIT 1`, userId)
|
|
|
+ if datas2 != nil && len(*datas2) == 1 {
|
|
|
+ mail = (*datas2)[0]["mail"].(string)
|
|
|
}
|
|
|
return
|
|
|
}
|