|
@@ -6,9 +6,11 @@ import (
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
|
"log"
|
|
|
"math"
|
|
|
"mongodb"
|
|
|
+ m "mongodb"
|
|
|
"net/http"
|
|
|
qutil "qfw/util"
|
|
|
"qfw/util/redis"
|
|
@@ -17,8 +19,6 @@ import (
|
|
|
"strings"
|
|
|
"time"
|
|
|
"util"
|
|
|
-
|
|
|
- "go.mongodb.org/mongo-driver/bson"
|
|
|
)
|
|
|
|
|
|
const (
|
|
@@ -30,6 +30,7 @@ const (
|
|
|
RedisMenuKeyWX = "jy_workdesktopmenu_10000_WX_%s" //剑鱼appid:10000
|
|
|
RedisMenuKeyAPP = "jy_workdesktopmenu_10000_APP_%s" //剑鱼appid:10000
|
|
|
UserPowerRedisKey = "jy_userpowerredis_10000_%d_%s" //工作桌面 用户功能缓存(类似bigmember_power_3_%s)
|
|
|
+
|
|
|
)
|
|
|
|
|
|
// 插入合同表信息和订单表信息
|
|
@@ -130,12 +131,14 @@ func createOtherOrder(param *CreateOtherOrderParams, code string) bool {
|
|
|
}
|
|
|
if param.BuySubject == "2" {
|
|
|
insertData["buy_subject"] = 2
|
|
|
- entId, err := AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus)
|
|
|
+ entId, err, userPositionId := AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus, param.UserId)
|
|
|
if err != nil {
|
|
|
log.Printf("AutomaticallyCreatingEnt 自动创建企业信息失败:code:%s,err:%s", code, err.Error())
|
|
|
return false
|
|
|
} else {
|
|
|
insertData["ent_id"] = entId
|
|
|
+ param.UserId = fmt.Sprint(qutil.Int64All(userPositionId))
|
|
|
+ insertData["user_id"] = userPositionId
|
|
|
}
|
|
|
} else {
|
|
|
insertData["buy_subject"] = 1
|
|
@@ -309,12 +312,14 @@ func createEntnicheOrder(param *CreateOtherOrderParams, code string) bool {
|
|
|
}
|
|
|
if param.BuySubject == "2" {
|
|
|
insertData["buySubject"] = 2
|
|
|
- entId, err := AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus)
|
|
|
+ entId, err, userPositionId := AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus, param.UserId)
|
|
|
if err != nil {
|
|
|
log.Printf("AutomaticallyCreatingEnt 自动创建企业信息失败:code:%s,err:%s", code, err.Error())
|
|
|
return false
|
|
|
} else {
|
|
|
insertData["entId"] = entId
|
|
|
+ insertData["user_id"] = userPositionId
|
|
|
+ param.UserId = userPositionId
|
|
|
}
|
|
|
} else {
|
|
|
insertData["buySubject"] = 1
|
|
@@ -407,12 +412,14 @@ func updateOtherOrder(param *CreateOtherOrderParams, code string, returnStatus i
|
|
|
}
|
|
|
if param.BuySubject == "2" {
|
|
|
insertData["buySubject"] = 2
|
|
|
- entId, err := AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus)
|
|
|
+ entId, err, userPositionId := AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus, param.UserId)
|
|
|
if err != nil {
|
|
|
log.Printf("AutomaticallyCreatingEnt 自动创建企业信息失败:code:%s,err:%s", code, err.Error())
|
|
|
return false
|
|
|
} else {
|
|
|
insertData["entId"] = entId
|
|
|
+ param.UserId = userPositionId
|
|
|
+ insertData["user_id"] = userPositionId
|
|
|
}
|
|
|
} else {
|
|
|
insertData["buySubject"] = 1
|
|
@@ -573,12 +580,14 @@ func updateEntnicheOrder(param *CreateOtherOrderParams, code string, returnStatu
|
|
|
}
|
|
|
if param.BuySubject == "2" {
|
|
|
insertData["buySubject"] = 2
|
|
|
- entId, err := AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus)
|
|
|
+ entId, err, userPositionId := AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus, param.UserId)
|
|
|
if err != nil {
|
|
|
log.Printf("AutomaticallyCreatingEnt 自动创建企业信息失败:code:%s,err:%s", code, err.Error())
|
|
|
return false
|
|
|
} else {
|
|
|
insertData["entId"] = entId
|
|
|
+ param.UserId = userPositionId
|
|
|
+ insertData["user_id"] = userPositionId
|
|
|
}
|
|
|
} else {
|
|
|
insertData["buySubject"] = 1
|
|
@@ -769,11 +778,12 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
|
|
|
payWay = ""
|
|
|
}
|
|
|
var (
|
|
|
- entId int
|
|
|
- err error
|
|
|
+ entId int
|
|
|
+ err error
|
|
|
+ userPositionId string
|
|
|
)
|
|
|
if param.BuySubject == "2" {
|
|
|
- entId, err = AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus)
|
|
|
+ entId, err, userPositionId = AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus, userId)
|
|
|
if err != nil {
|
|
|
log.Printf("AutomaticallyCreatingEnt 自动创建企业信息失败:code:%s,err:%s", code, err.Error())
|
|
|
return false, "自动创建企业信息失败"
|
|
@@ -865,6 +875,7 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
|
|
|
if param.BuySubject == "2" {
|
|
|
insertData["buy_subject"] = 2
|
|
|
insertData["ent_id"] = entId
|
|
|
+ insertData["user_id"] = userPositionId
|
|
|
} else {
|
|
|
insertData["buy_subject"] = 1
|
|
|
}
|
|
@@ -887,9 +898,9 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
|
|
|
if strings.Contains(param.VipStartTime, "2099") {
|
|
|
ss = 4070880000
|
|
|
}
|
|
|
- entService, userCount = EntServiceOpen(userId, param.BuySubject, ss)
|
|
|
_d := util.JysqlDB.FindOne("dataexport_order", map[string]interface{}{"order_code": code}, "id,ent_id", "")
|
|
|
if _d != nil && len(*_d) > 0 {
|
|
|
+ entService, userCount = EntServiceOpen(qutil.IntAll((*_d)["ent_id"]), param.Phone, param.ProductType, ss)
|
|
|
orderId := qutil.IntAll((*_d)["id"])
|
|
|
if qutil.IntAll((*_d)["ent_id"]) != 0 && param.Open && param.VipStartTime != "2099-01-01" && param.BuyCount > 0 {
|
|
|
regRuler := "^1[3456789]{1}\\d{9}$"
|
|
@@ -921,7 +932,24 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
|
|
|
isTrial = true
|
|
|
}
|
|
|
//log.Println(areaCount)
|
|
|
- isOk := StartSubVip(param.Phone, buyArea, newBuySet, vipStartTime, endTime, isTrial, userId)
|
|
|
+ isOk := false
|
|
|
+ set := map[string]interface{}{
|
|
|
+ "o_vipjy.i_trial": -1, //已激活试用
|
|
|
+ "o_vipjy.o_area": buyArea, //设置地区
|
|
|
+ "o_vipjy.o_buyset": newBuySet, //购买内容 城市、省份、行业数量
|
|
|
+ "l_vip_starttime": vipStartTime.Unix(), //开始时间
|
|
|
+ "l_vip_endtime": endTime.Unix(), //结束时间
|
|
|
+ "i_vip_status": qutil.If(isTrial, -2, 2), //1试用 2正式 -2 试用到期
|
|
|
+ "i_vip_expire_tip": 0, //消息提示初始化
|
|
|
+ "o_vipjy.a_buyerclass": []interface{}{}, //设置行业
|
|
|
+ }
|
|
|
+ if param.BuySubject == "1" {
|
|
|
+ isOk = StartSubVip(set, userId)
|
|
|
+ } else {
|
|
|
+ isOk = UpdateRule(entId, map[string]interface{}{
|
|
|
+ "$set": set,
|
|
|
+ }, param.Phone)
|
|
|
+ }
|
|
|
return isOk, qutil.FormatDate(&endTime, qutil.Date_Full_Layout)
|
|
|
}
|
|
|
// 续费和升级 我的订单-创建订单只生成订单信息不开通权益
|
|
@@ -934,6 +962,13 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
|
|
|
"i_vip_expire_tip": 0,
|
|
|
"i_vip_status": 2,
|
|
|
}
|
|
|
+ if param.BuySubject != "2" {
|
|
|
+ if !util.MQFW.UpdateById("user", userId,
|
|
|
+ bson.M{"$set": set}) {
|
|
|
+ log.Printf("%s更新结束%d日期出错\n", userId, endTime.Unix())
|
|
|
+ return false, ""
|
|
|
+ }
|
|
|
+ }
|
|
|
if !util.MQFW.UpdateById("user", userId,
|
|
|
bson.M{"$set": set}) {
|
|
|
log.Printf("%s更新结束%d日期出错\n", userId, endTime.Unix())
|
|
@@ -954,7 +989,6 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
|
|
|
}
|
|
|
updata := map[string]interface{}{
|
|
|
"o_vipjy.o_buyset": newBuySet,
|
|
|
- // "l_vip_endtime": endTime.Unix(),//升级不再续费
|
|
|
"i_vip_expire_tip": 0,
|
|
|
"i_vip_status": 2,
|
|
|
}
|
|
@@ -964,9 +998,13 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
|
|
|
if vms.Industry != nil {
|
|
|
updata["o_vipjy.a_buyerclass"] = vms.Industry //设置行业
|
|
|
}
|
|
|
- if ok := util.MQFW.UpdateById("user", userId, map[string]interface{}{
|
|
|
- "$set": updata,
|
|
|
- }); !ok {
|
|
|
+ isOk := true
|
|
|
+ if param.BuySubject != "2" {
|
|
|
+ isOk = util.MQFW.UpdateById("user", userId, map[string]interface{}{
|
|
|
+ "$set": updata,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if !isOk {
|
|
|
log.Printf("%s更新用户出错 %+v\n", userId, updata)
|
|
|
return false, ""
|
|
|
} else {
|
|
@@ -1053,6 +1091,8 @@ func updateVipOrder(param *CreateOtherOrderParams, code string, returnStatus int
|
|
|
if param.Badge != "" {
|
|
|
vms.Badge = param.Badge
|
|
|
}
|
|
|
+ var vst, vet string
|
|
|
+ userId := ""
|
|
|
userData := &map[string]interface{}{}
|
|
|
ok := false
|
|
|
if param.UserId == "" {
|
|
@@ -1060,8 +1100,6 @@ func updateVipOrder(param *CreateOtherOrderParams, code string, returnStatus int
|
|
|
} else {
|
|
|
userData, ok = util.MQFW.FindOne("user", map[string]interface{}{"_id": mongodb.StringTOBsonId(param.UserId)})
|
|
|
}
|
|
|
- userId := ""
|
|
|
- var vet string
|
|
|
if ok && userData != nil && len(*userData) > 0 {
|
|
|
userId = mongodb.BsonIdToSId((*userData)["_id"])
|
|
|
// st := qutil.Int64All((*userData)["l_vip_starttime"])
|
|
@@ -1099,15 +1137,17 @@ func updateVipOrder(param *CreateOtherOrderParams, code string, returnStatus int
|
|
|
}
|
|
|
}
|
|
|
var (
|
|
|
- entId int
|
|
|
- err error
|
|
|
+ entId int
|
|
|
+ err error
|
|
|
+ userPositionId string
|
|
|
)
|
|
|
if param.BuySubject == "2" {
|
|
|
- entId, err = AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus)
|
|
|
+ entId, err, userPositionId = AutomaticallyCreatingEnt(param.CompanyName, param.Phone, code, param.OrderStatus, userId)
|
|
|
if err != nil {
|
|
|
log.Printf("AutomaticallyCreatingEnt 自动创建企业信息失败:code:%s,err:%s", code, err.Error())
|
|
|
return false, "自动创建企业信息失败"
|
|
|
}
|
|
|
+ userId = userPositionId
|
|
|
}
|
|
|
|
|
|
b := util.JysqlDB.ExecTx("修改订单信息和合同信息", func(tx *sql.Tx) bool {
|
|
@@ -1188,6 +1228,7 @@ func updateVipOrder(param *CreateOtherOrderParams, code string, returnStatus int
|
|
|
if param.BuySubject == "2" {
|
|
|
insertData["ent_id"] = entId
|
|
|
insertData["buy_subject"] = 2
|
|
|
+ insertData["user_id"] = userPositionId
|
|
|
} else {
|
|
|
insertData["buy_subject"] = 1
|
|
|
}
|
|
@@ -1215,9 +1256,9 @@ func updateVipOrder(param *CreateOtherOrderParams, code string, returnStatus int
|
|
|
if strings.Contains(param.StartTime, "2099") {
|
|
|
ss = 4070880000
|
|
|
}
|
|
|
- entService, userCount = EntServiceOpen(userId, param.BuySubject, ss)
|
|
|
_d := util.JysqlDB.FindOne("dataexport_order", map[string]interface{}{"order_code": code}, "id,ent_id", "")
|
|
|
if _d != nil && len(*_d) > 0 {
|
|
|
+ entService, userCount = EntServiceOpen(qutil.IntAll((*_d)["ent_id"]), param.Phone, param.ProductType, ss)
|
|
|
orderId := qutil.IntAll((*_d)["id"])
|
|
|
if qutil.IntAll((*_d)["ent_id"]) != 0 && param.VipStartTime != "2099-01-01" && param.BuyCount > 0 {
|
|
|
regRuler := "^1[3456789]{1}\\d{9}$"
|
|
@@ -1234,7 +1275,6 @@ func updateVipOrder(param *CreateOtherOrderParams, code string, returnStatus int
|
|
|
ClearBigVipUserPower(userId)
|
|
|
return true, ""
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
//0 购买 1 续费 2 升级
|
|
|
if param.VipType == 0 {
|
|
@@ -1249,16 +1289,20 @@ func updateVipOrder(param *CreateOtherOrderParams, code string, returnStatus int
|
|
|
"i_vip_expire_tip": 0, //消息提示初始化
|
|
|
"o_vipjy.a_buyerclass": []interface{}{}, //设置行业
|
|
|
}
|
|
|
- util.MQFW.UpdateById("user", userId, bson.M{
|
|
|
- "$set": set,
|
|
|
- })
|
|
|
- jyRedis := config.SysConfigs.JyRedis
|
|
|
- redis.Del("newother", jyRedis+userId)
|
|
|
- //log.Println("err",err)
|
|
|
- redis.Del("newother", "pl_indexMessage_"+userId)
|
|
|
- return true, ""
|
|
|
+ if param.BuySubject == "1" {
|
|
|
+ util.MQFW.UpdateById("user", userId, bson.M{
|
|
|
+ "$set": set,
|
|
|
+ })
|
|
|
+ ClearBigVipUserPower(userId)
|
|
|
+ return true, ""
|
|
|
+ } else {
|
|
|
+ UpdateRule(entId, map[string]interface{}{
|
|
|
+ "$set": set,
|
|
|
+ }, param.Phone)
|
|
|
+ ClearBigVipUserPower(userId)
|
|
|
+ return true, ""
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
//为用户开通超级订阅权限
|
|
|
//是否开通超级订阅 -1 试用到期 -2 正式到期 1 试用 2 开通
|
|
|
isTrial := false
|
|
@@ -1266,7 +1310,24 @@ func updateVipOrder(param *CreateOtherOrderParams, code string, returnStatus int
|
|
|
isTrial = true
|
|
|
}
|
|
|
if param.UpdateType == 0 {
|
|
|
- isOk := StartSubVip(param.Phone, buyArea, newBuySet, vipStartTime, endTime, isTrial, userId)
|
|
|
+ set := map[string]interface{}{
|
|
|
+ "o_vipjy.i_trial": -1, //已激活试用
|
|
|
+ "o_vipjy.o_area": buyArea, //设置地区
|
|
|
+ "o_vipjy.o_buyset": newBuySet, //购买内容 城市、省份、行业数量
|
|
|
+ "l_vip_starttime": vipStartTime.Unix(), //开始时间
|
|
|
+ "l_vip_endtime": endTime.Unix(), //结束时间
|
|
|
+ "i_vip_status": qutil.If(isTrial, -2, 2), //1试用 2正式 -2 试用到期
|
|
|
+ "i_vip_expire_tip": 0, //消息提示初始化
|
|
|
+ "o_vipjy.a_buyerclass": []interface{}{}, //设置行业
|
|
|
+ }
|
|
|
+ isOk := false
|
|
|
+ if param.BuySubject == "1" {
|
|
|
+ isOk = StartSubVip(set, userId)
|
|
|
+ } else {
|
|
|
+ isOk = UpdateRule(entId, map[string]interface{}{
|
|
|
+ "$set": set,
|
|
|
+ }, param.Phone)
|
|
|
+ }
|
|
|
return isOk, qutil.FormatDate(&endTime, qutil.Date_Full_Layout)
|
|
|
} else {
|
|
|
return true, ""
|
|
@@ -1286,6 +1347,43 @@ func ClearBigVipUserPower(userId string) bool {
|
|
|
|
|
|
// 当大会员状态改变时清除此状态
|
|
|
func ClearBigVipUserPower(userId string) {
|
|
|
+ if mongodb.IsObjectIdHex(userId) {
|
|
|
+ user_id := userId
|
|
|
+ //大会员主账号清理
|
|
|
+ userDatas, ok := util.MQFW.Find("user", map[string]interface{}{"s_member_mainid": user_id, "i_member_sub_status": 1}, nil, nil, false, -1, -1)
|
|
|
+ if ok && userDatas != nil && len(*userDatas) > 0 {
|
|
|
+ for _, v := range *userDatas {
|
|
|
+ user_id := m.BsonIdToSId(v["_id"])
|
|
|
+ userData, ok := util.MQFW.FindById("user", user_id, `"base_user_id":1`)
|
|
|
+ if userData != nil && len(*userData) > 0 && ok {
|
|
|
+ baseUserId := qutil.Int64All((*userData)["base_user_id"])
|
|
|
+ positionData := util.BaseDB.FindOne(util.BasePosition, map[string]interface{}{
|
|
|
+ "type": 0,
|
|
|
+ "ent_id": 0,
|
|
|
+ "user_id": baseUserId,
|
|
|
+ }, "id", "")
|
|
|
+ if positionData != nil && len(*positionData) > 0 {
|
|
|
+ user_id = fmt.Sprint(qutil.Int64All((*positionData)["id"]))
|
|
|
+ redis.Del("newother", config.SysConfigs.BigmemberKey+user_id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //通过mongo查找职位标识
|
|
|
+ userData, ok := util.MQFW.FindById("user", userId, `"base_user_id":1`)
|
|
|
+ if userData != nil && len(*userData) > 0 && ok {
|
|
|
+ baseUserId := qutil.Int64All((*userData)["base_user_id"])
|
|
|
+ positionData := util.BaseDB.FindOne(util.BasePosition, map[string]interface{}{
|
|
|
+ "type": 0,
|
|
|
+ "ent_id": 0,
|
|
|
+ "user_id": baseUserId,
|
|
|
+ }, "id", "")
|
|
|
+ if positionData != nil && len(*positionData) > 0 {
|
|
|
+ userId = fmt.Sprint(qutil.Int64All((*positionData)["id"]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
cacheKey := fmt.Sprintf(PowerCacheKey, userId)
|
|
|
baseInfoCacheKey := fmt.Sprintf(IsGetUserBaseInfoRedisKey, userId)
|
|
|
redisMenuKeyPC := fmt.Sprintf(RedisMenuKeyPC, userId)
|
|
@@ -1293,32 +1391,27 @@ func ClearBigVipUserPower(userId string) {
|
|
|
redisMenuKeyAPP := fmt.Sprintf(RedisMenuKeyAPP, userId)
|
|
|
userPowerRedisKey := fmt.Sprintf(UserPowerRedisKey, time.Now().Day(), userId)
|
|
|
redis.Del(NewOther, cacheKey)
|
|
|
+ redis.Del("newother", config.SysConfigs.BigmemberKey+userId)
|
|
|
+ redis.Del(NewOther, fmt.Sprintf("jy_workdesktopmenu_10000_menu1_%s", userId))
|
|
|
+ redis.Del(NewOther, fmt.Sprintf("jy_userpowerredis_10000_17_%s", userId))
|
|
|
+ redis.Del(NewOther, fmt.Sprintf("jy_workdesktopmenu_10000_menu2_%s", userId))
|
|
|
+ redis.Del(NewOther, fmt.Sprintf("user_power_info_%s", userId))
|
|
|
redis.Del(NewOther, baseInfoCacheKey)
|
|
|
redis.Del(NewOther, redisMenuKeyPC)
|
|
|
redis.Del(NewOther, redisMenuKeyWX)
|
|
|
redis.Del(NewOther, redisMenuKeyAPP)
|
|
|
redis.Del(NewOther, userPowerRedisKey)
|
|
|
+ redis.Del(NewOther, "pl_indexMessage_"+userId)
|
|
|
}
|
|
|
|
|
|
// 开始使用超级订阅
|
|
|
-func StartSubVip(phone string, area map[string]interface{}, newBuyset SubvipBuySet, startTime, endTime time.Time, isTrial bool, userId string) bool {
|
|
|
- set := map[string]interface{}{
|
|
|
- "o_vipjy.i_trial": -1, //已激活试用
|
|
|
- "o_vipjy.o_area": area, //设置地区
|
|
|
- "o_vipjy.o_buyset": newBuyset, //购买内容 城市、省份、行业数量
|
|
|
- "l_vip_starttime": startTime.Unix(), //开始时间
|
|
|
- "l_vip_endtime": endTime.Unix(), //结束时间
|
|
|
- "i_vip_status": qutil.If(isTrial, -2, 2), //1试用 2正式 -2 试用到期
|
|
|
- "i_vip_expire_tip": 0, //消息提示初始化
|
|
|
- "o_vipjy.a_buyerclass": []interface{}{}, //设置行业
|
|
|
- }
|
|
|
+func StartSubVip(set map[string]interface{}, userId string) bool {
|
|
|
isOk := util.MQFW.UpdateById("user", userId, bson.M{
|
|
|
"$set": set,
|
|
|
})
|
|
|
go func() {
|
|
|
MergeKws(userId)
|
|
|
}()
|
|
|
- redis.Del(NewOther, "pl_indexMessage_"+userId)
|
|
|
ClearBigVipUserPower(userId)
|
|
|
if isOk {
|
|
|
return true
|
|
@@ -1343,6 +1436,7 @@ func MergeKws(userId string) {
|
|
|
"$set": bson.M{"o_vipjy.i_matchway": 1, "o_vipjy.i_ratemode": 1, "o_vipjy.i_wxpush": 1, "o_vipjy.i_apppush": 1, "o_vipjy.i_projectmatch": 0, "o_vipjy.a_infotype": []string{}, "o_vipjy.a_items": []string{}, "o_vipjy.l_modifydate": time.Now().Unix()},
|
|
|
})
|
|
|
log.Println(a)
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1389,7 +1483,6 @@ func UpdateReturnInfo(param *UpdateReturnParams, orderData map[string]interface{
|
|
|
invoiceStatus = 3
|
|
|
}
|
|
|
return util.JysqlDB.ExecTx("编辑回款信息", func(tx *sql.Tx) bool {
|
|
|
-
|
|
|
insertData := map[string]interface{}{
|
|
|
"order_code": param.OrderCode,
|
|
|
"return_time": param.ReturnTime,
|
|
@@ -1813,6 +1906,92 @@ func GetNameList(name string) (rs *[]map[string]interface{}) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+// 企业订阅时间修改
|
|
|
+func UpdateRule(entId int, update map[string]interface{}, phone string) bool {
|
|
|
+ ok := false
|
|
|
+ if entId > 0 && phone != "" {
|
|
|
+ //查找之前数据是否存在
|
|
|
+ userData := util.JysqlDB.FindOne("entniche_user", map[string]interface{}{
|
|
|
+ "ent_id": entId,
|
|
|
+ "phone": phone,
|
|
|
+ }, `id`, "")
|
|
|
+ if userData == nil {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ up1, up2 := map[string]interface{}{}, map[string]interface{}{}
|
|
|
+ var tp int
|
|
|
+ for k, v := range update {
|
|
|
+ vm, ok := v.(map[string]interface{})
|
|
|
+ if !ok {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ up11, up22 := map[string]interface{}{}, map[string]interface{}{}
|
|
|
+ key := ""
|
|
|
+ for kk, vv := range vm {
|
|
|
+ if (key == "" || key == "o_jy") && (kk == "o_jy" || strings.HasPrefix(kk, "o_jy.")) {
|
|
|
+ key = "o_jy"
|
|
|
+ up22[strings.ReplaceAll(kk, key, "o_entniche")] = vv
|
|
|
+ tp = 2
|
|
|
+ } else if (key == "" || key == "o_vipjy") && (kk == "o_vipjy" || strings.HasPrefix(kk, "o_vipjy.")) {
|
|
|
+ key = "o_vipjy"
|
|
|
+ up22[strings.ReplaceAll(kk, key, "o_entniche")] = vv
|
|
|
+ tp = 1
|
|
|
+ } else if (key == "" || key == "o_member_jy") && (kk == "o_member_jy" || strings.HasPrefix(kk, "o_member_jy.")) {
|
|
|
+ key = "o_member_jy"
|
|
|
+ up22[strings.ReplaceAll(kk, key, "o_entniche")] = vv
|
|
|
+ tp = 1
|
|
|
+ } else if (key == "" || key == "o_entniche") && (kk == "o_entniche" || strings.HasPrefix(kk, "o_entniche.")) {
|
|
|
+ key = "o_entniche"
|
|
|
+ up22[strings.ReplaceAll(kk, key, "o_entniche")] = vv
|
|
|
+ tp = 0
|
|
|
+ } else {
|
|
|
+ up11[kk] = vv
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(up11) > 0 {
|
|
|
+ up1[k] = up11
|
|
|
+ }
|
|
|
+ if len(up22) > 0 {
|
|
|
+ up2[k] = up22
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ok1, ok2 := false, false
|
|
|
+ //查看之前是否有数据
|
|
|
+ data, ok := util.MQFW.Find("entniche_rule", map[string]interface{}{
|
|
|
+ "i_entid": entId,
|
|
|
+ "i_userid": (*userData)["id"],
|
|
|
+ "i_type": tp,
|
|
|
+ }, `{"i_time":-1}`, nil, false, -1, -1)
|
|
|
+ if ok && len(*data) == 0 {
|
|
|
+ up3 := map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{"o_entniche.i_matchway": 1, "o_entniche.i_ratemode": 1, "o_entniche.i_wxpush": 1, "o_entniche.i_apppush": 1, "o_entniche.i_projectmatch": 0, "o_entniche.a_infotype": []string{}, "o_entniche.a_items": []string{}, "o_entniche.l_modifydate": time.Now().Unix()},
|
|
|
+ }
|
|
|
+ util.MQFW.Update("entniche_rule", map[string]interface{}{
|
|
|
+ "i_entid": entId,
|
|
|
+ "i_userid": (*userData)["id"],
|
|
|
+ "i_type": tp,
|
|
|
+ }, up3, true, false)
|
|
|
+ }
|
|
|
+ if len(up1) > 0 {
|
|
|
+ ok1 = util.MQFW.Update("ent_user", map[string]interface{}{
|
|
|
+ "i_entid": entId,
|
|
|
+ "i_userid": (*userData)["id"],
|
|
|
+ }, up1, true, false)
|
|
|
+ }
|
|
|
+ if len(up2) > 0 {
|
|
|
+ ok2 = util.MQFW.Update("entniche_rule", map[string]interface{}{
|
|
|
+ "i_entid": entId,
|
|
|
+ "i_userid": (*userData)["id"],
|
|
|
+ "i_type": tp,
|
|
|
+ }, up2, true, false)
|
|
|
+ }
|
|
|
+ //默认数据处理
|
|
|
+
|
|
|
+ return ok1 || ok2
|
|
|
+ }
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
var productMap = map[string]interface{}{
|
|
|
"1": "广告",
|
|
|
"2": "结构化数据",
|