|
@@ -29,7 +29,7 @@ func ServiceOpen(context *admin.Context) (interface{}, error) {
|
|
|
return nil, err
|
|
|
}
|
|
|
//查询订单
|
|
|
- order := util.JysqlDB.FindOne("dataexport_order", map[string]interface{}{"order_code": param.OrderCode}, "id,order_status,user_phone,product_type,vip_type,vip_endtime,vip_starttime,filter", "")
|
|
|
+ order := util.JysqlDB.FindOne("dataexport_order", map[string]interface{}{"order_code": param.OrderCode}, "", "")
|
|
|
if order == nil {
|
|
|
return nil, errors.New("为查询到订单信息")
|
|
|
}
|
|
@@ -125,7 +125,7 @@ func ServiceOpen(context *admin.Context) (interface{}, error) {
|
|
|
return nil, err
|
|
|
}
|
|
|
var vipStartTime, vipEndTime time.Time
|
|
|
- vipStartTime, vipEndTime = GetStartAndEndTime(time.Unix(param.StartTime, 0).Format(cm.Date_Full_Layout), cm.IntAll(filterMap["cyclecount"]), cm.IntAll(filterMap["cycleunit"]))
|
|
|
+ vipStartTime, vipEndTime = GetStartAndEndTime(time.Unix(param.StartTime, 0).Format(cm.Date_Short_Layout), cm.IntAll(filterMap["cyclecount"]), cm.IntAll(filterMap["cycleunit"]))
|
|
|
VipServiceOpen(userId, param.Phone, filterMap, vipStartTime, vipEndTime, cm.IntAll((*order)["buy_subject"]), entId)
|
|
|
updateMap["vip_starttime"] = vipStartTime.Format(cm.Date_Full_Layout)
|
|
|
updateMap["vip_endtime"] = vipEndTime.Format(cm.Date_Full_Layout)
|
|
@@ -137,9 +137,11 @@ func ServiceOpen(context *admin.Context) (interface{}, error) {
|
|
|
if createType == 1 { //1-新建 2-补充 3-延期
|
|
|
bigStartTime := time.Unix(param.StartTime, 0)
|
|
|
bigEndTime := GetDATE(cm.IntAll(filterMap["cycle"]), cm.IntAll(filterMap["cycleType"]), param.StartTime)
|
|
|
- if bigEndTime.Unix() > time.Now().Unix() {
|
|
|
+ if bigEndTime.Unix() < time.Now().Unix() {
|
|
|
return nil, errors.New("订单已失效")
|
|
|
}
|
|
|
+ updateMap["vip_starttime"] = bigStartTime.Format(cm.Date_Full_Layout)
|
|
|
+ updateMap["vip_endtime"] = bigEndTime.Format(cm.Date_Full_Layout)
|
|
|
var sName string
|
|
|
if cm.IntAll(filterMap["comboId"]) != 0 {
|
|
|
if cm.IntAll(filterMap["comboId"]) == 5 {
|
|
@@ -153,15 +155,15 @@ func ServiceOpen(context *admin.Context) (interface{}, error) {
|
|
|
}
|
|
|
// 企业主体判断是否开通权益
|
|
|
if cm.IntAll((*order)["buy_subject"]) == 2 {
|
|
|
- entService, userCount = EntServiceOpen(cm.IntAll((*order)["entId"]), param.Phone, fmt.Sprintf("%s%s", "大会员", sName), param.StartTime)
|
|
|
+ entService, userCount = EntServiceOpen(cm.IntAll((*order)["ent_id"]), param.Phone, fmt.Sprintf("%s%s", "大会员", sName), param.StartTime)
|
|
|
orderId := cm.IntAll((*order)["id"])
|
|
|
- if cm.IntAll((*order)["entId"]) != 0 && param.StartTime != 4070880000 && cm.IntAll((*order)["buy_count"]) > 0 {
|
|
|
+ if cm.IntAll((*order)["ent_id"]) != 0 && param.StartTime != 4070880000 && cm.IntAll((*order)["buy_count"]) > 0 {
|
|
|
regRuler := "^1[3456789]{1}\\d{9}$"
|
|
|
reg := regexp.MustCompile(regRuler)
|
|
|
if cm.IntAll((*order)["order_status"]) == 1 && reg.MatchString(param.Phone) {
|
|
|
st := cm.FormatDate(&bigStartTime, cm.Date_Full_Layout)
|
|
|
et := cm.FormatDate(&bigEndTime, cm.Date_Full_Layout)
|
|
|
- err := EntLicense(cm.IntAll((*order)["entId"]), cm.IntAll((*order)["buy_count"]), cm.IntAll(cm.If(cm.IntAll(filterMap["areaCount"]) > 0, cm.IntAll(filterMap["areaCount"]), -1)), orderId, userCount, fmt.Sprintf("%s%s", "大会员", sName), st, et, param.Phone)
|
|
|
+ err := EntLicense(cm.IntAll((*order)["ent_id"]), cm.IntAll((*order)["buy_count"]), cm.IntAll(cm.If(cm.IntAll(filterMap["areaCount"]) > 0, cm.IntAll(filterMap["areaCount"]), -1)), orderId, userCount, fmt.Sprintf("%s%s", "大会员", sName), st, et, param.Phone)
|
|
|
if err != nil {
|
|
|
log.Printf("EntLicense 创建企业授权信息失败:code:%s,err:%s", param.OrderCode, err.Error())
|
|
|
}
|
|
@@ -171,6 +173,7 @@ func ServiceOpen(context *admin.Context) (interface{}, error) {
|
|
|
return nil, errors.New("企业不存在")
|
|
|
}
|
|
|
}
|
|
|
+ ClearBigVipUserPower(fmt.Sprint((*order)["user_id"])) //订单创建成功后默认清空权限缓存
|
|
|
status := cm.If(bigStartTime.Unix() > time.Now().Unix(), 0, 1)
|
|
|
err := NewBigOpenService(filterMap, userId, bigStartTime, bigEndTime, cm.IntAll(status), cm.IntAll((*order)["buy_count"]))
|
|
|
if err != nil {
|
|
@@ -354,7 +357,7 @@ func GetStartAndEndTime(startTime string, cycleCount, cycleUnit int) (vipStartTi
|
|
|
} else if cycleUnit == 4 {
|
|
|
month = cycleCount * 3
|
|
|
}
|
|
|
- vipStartTime, _ = time.ParseInLocation(cm.Date_Short_Layout, startTime, time.Local)
|
|
|
+ vipStartTime, _ = time.Parse(cm.Date_Short_Layout, startTime)
|
|
|
if cycleUnit == 3 {
|
|
|
_endTime := vipStartTime.AddDate(0, 0, cycleCount)
|
|
|
t := _endTime.Format(cm.Date_Short_Layout) + " 23:59:59"
|
|
@@ -395,7 +398,7 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
|
|
|
if productType == "VIP订阅" {
|
|
|
vipType := cm.IntAll(orderInfo["vip_type"])
|
|
|
if vipType == 0 {
|
|
|
- vipStartTime, vipEndTime := GetStartAndEndTime(time.Now().Format(cm.Date_Full_Layout), cm.IntAll(filterMap["cyclecount"]), cm.IntAll(filterMap["cycleunit"]))
|
|
|
+ vipStartTime, vipEndTime := GetStartAndEndTime(time.Now().Format(cm.Date_Short_Layout), cm.IntAll(filterMap["cyclecount"]), cm.IntAll(filterMap["cycleunit"]))
|
|
|
VipServiceOpen(userId, cm.ObjToString(orderInfo["user_phone"]), filterMap, vipStartTime, vipEndTime, cm.IntAll(orderInfo["buy_subject"]), cm.IntAll(orderInfo["ent_id"]))
|
|
|
updateOrder["vip_starttime"] = vipStartTime.Format(cm.Date_Full_Layout)
|
|
|
updateOrder["vip_endtime"] = vipEndTime.Format(cm.Date_Full_Layout)
|
|
@@ -411,16 +414,6 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
|
|
|
"i_vip_status": 2,
|
|
|
}
|
|
|
if vipEndTime.Unix() < time.Now().Unix() { //原服务已过期
|
|
|
- //查询回款记录,最近一笔回款时间
|
|
|
- /*newReturnMoneyTime, checkPassTime, err := GetReturnTimeAndCheckTime(orderCode)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if newReturnMoneyTime.Unix() > checkPassTime.Unix() {
|
|
|
- newStartTime = newReturnMoneyTime
|
|
|
- } else {
|
|
|
- newStartTime = checkPassTime
|
|
|
- }*/
|
|
|
newStartTime = time.Now()
|
|
|
set["l_vip_starttime"] = newStartTime.Unix()
|
|
|
|
|
@@ -428,8 +421,8 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
|
|
|
//开始时间为:原服务结束日期+1天
|
|
|
newStartTime = vipEndTime.AddDate(0, 0, 1)
|
|
|
}
|
|
|
+ _, newEndTime = GetStartAndEndTime(newStartTime.Format(cm.Date_Short_Layout), cm.IntAll(filterMap["cyclecount"]), cm.IntAll(filterMap["cycleunit"]))
|
|
|
set["l_vip_endtime"] = newEndTime.Unix()
|
|
|
- _, newEndTime = GetStartAndEndTime(newStartTime.Format(cm.Date_Full_Layout), cm.IntAll(filterMap["cyclecount"]), cm.IntAll(filterMap["cycleunit"]))
|
|
|
if !util.MQFW.UpdateById("user", userId,
|
|
|
bson.M{"$set": set}) {
|
|
|
return errors.New(fmt.Sprintf("%s更新结束%d日期出错", userId, vipEndTime.Unix()))
|