|
@@ -123,9 +123,43 @@ func ServiceOpen(context *admin.Context) (interface{}, error) {
|
|
|
if err := json.Unmarshal([]byte(filter.(string)), &filterData); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- var vipStartTime, vipEndTime time.Time
|
|
|
+ var (
|
|
|
+ userCount int
|
|
|
+ entService bool
|
|
|
+ vipStartTime, vipEndTime time.Time
|
|
|
+ )
|
|
|
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)
|
|
|
+ if cm.IntAll((*order)["buy_subject"]) == 2 {
|
|
|
+ entService, userCount = EntServiceOpen(entId, param.Phone, cm.ObjToString((*order)["product_type"]), param.StartTime)
|
|
|
+ orderId := cm.IntAll((*order)["id"])
|
|
|
+ if entId != 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(&vipStartTime, cm.Date_Full_Layout)
|
|
|
+ et := cm.FormatDate(&vipEndTime, cm.Date_Full_Layout)
|
|
|
+ areaCount := -1
|
|
|
+ buyArea := map[string]interface{}{}
|
|
|
+ areaMap := cm.ObjToMap(filterMap["area"])
|
|
|
+ if areaMap != nil && len(*areaMap) > 0 {
|
|
|
+ for k, _ := range *areaMap {
|
|
|
+ buyArea[k] = []interface{}{}
|
|
|
+ }
|
|
|
+ areaCount = len(buyArea)
|
|
|
+ }
|
|
|
+ err := EntLicense(entId, cm.IntAll((*order)["buy_count"]), areaCount, orderId, userCount, cm.ObjToString((*order)["product_type"]), st, et, param.Phone)
|
|
|
+ if err != nil {
|
|
|
+ log.Printf("EntLicense 创建企业授权信息失败:code:%s,err:%s", param.OrderCode, err.Error())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !entService {
|
|
|
+ ClearBigVipUserPower(userId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if entService || cm.IntAll((*order)["buy_subject"]) == 1 {
|
|
|
+ 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)
|
|
|
//updateMap["user_id"] = userId
|
|
@@ -171,16 +205,14 @@ func ServiceOpen(context *admin.Context) (interface{}, error) {
|
|
|
}
|
|
|
if !entService {
|
|
|
ClearBigVipUserPower(userId)
|
|
|
- return map[string]interface{}{
|
|
|
- "status": 1,
|
|
|
- }, nil
|
|
|
}
|
|
|
}
|
|
|
- //ClearBigVipUserPower(fmt.Sprint((*order)["user_id"])) //订单创建成功后默认清空权限缓存
|
|
|
- status := cm.If(bigStartTime.Unix() <= time.Now().Unix(), 0, 1)
|
|
|
- err := NewBigOpenService(filterMap, userId, param.Phone, bigStartTime, bigEndTime, cm.IntAll(status), cm.IntAll((*order)["buy_count"]), cm.IntAll((*order)["buy_subject"]), entId)
|
|
|
- if err != nil {
|
|
|
- return nil, errors.New(fmt.Sprintf("订单编号:%s,手机号:%s开通大会员权益失败", param.OrderCode, param.Phone))
|
|
|
+ if entService || cm.IntAll((*order)["buy_subject"]) == 1 {
|
|
|
+ status := cm.If(bigStartTime.Unix() <= time.Now().Unix(), 0, 1)
|
|
|
+ err := NewBigOpenService(filterMap, userId, param.Phone, bigStartTime, bigEndTime, cm.IntAll(status), cm.IntAll((*order)["buy_count"]), cm.IntAll((*order)["buy_subject"]), entId)
|
|
|
+ if err != nil {
|
|
|
+ return nil, errors.New(fmt.Sprintf("订单编号:%s,手机号:%s开通大会员权益失败", param.OrderCode, param.Phone))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -431,6 +463,10 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
|
|
|
if productType == "VIP订阅" {
|
|
|
vipType := cm.IntAll(orderInfo["vip_type"])
|
|
|
if vipType == 0 {
|
|
|
+ var (
|
|
|
+ entService bool
|
|
|
+ userCount int
|
|
|
+ )
|
|
|
vipStartTime, vipEndTime := GetStartAndEndTime(time.Now().Format(cm.Date_Short_Layout), cm.IntAll(filterMap["cyclecount"]), cm.IntAll(filterMap["cycleunit"]))
|
|
|
if cm.IntAll(orderInfo["buy_subject"]) == 2 { //购买主体是企业,手机号改变,需要重新创建企业
|
|
|
entId, err, userPositionId = AutomaticallyCreatingEnt(cm.ObjToString(orderInfo["company_name"]), cm.ObjToString(orderInfo["user_phone"]), orderCode, 1, userId)
|
|
@@ -439,10 +475,6 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
|
|
|
return err
|
|
|
}
|
|
|
userId = userPositionId
|
|
|
- var (
|
|
|
- entService bool
|
|
|
- userCount int
|
|
|
- )
|
|
|
entService, userCount = EntServiceOpen(entId, cm.ObjToString(orderInfo["user_phone"]), cm.ObjToString(orderInfo["product_type"]), vipStartTime.Unix())
|
|
|
orderId := cm.IntAll(orderInfo["id"])
|
|
|
if entId != 0 && cm.IntAll(orderInfo["buy_count"]) > 0 {
|
|
@@ -461,10 +493,11 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
|
|
|
}
|
|
|
if !entService {
|
|
|
ClearBigVipUserPower(userId)
|
|
|
- return nil
|
|
|
}
|
|
|
}
|
|
|
- VipServiceOpen(userId, cm.ObjToString(orderInfo["user_phone"]), filterMap, vipStartTime, vipEndTime, cm.IntAll(orderInfo["buy_subject"]), entId)
|
|
|
+ if entService || cm.IntAll(orderInfo["buy_subject"]) == 1 {
|
|
|
+ VipServiceOpen(userId, cm.ObjToString(orderInfo["user_phone"]), filterMap, vipStartTime, vipEndTime, cm.IntAll(orderInfo["buy_subject"]), entId)
|
|
|
+ }
|
|
|
updateOrder["vip_starttime"] = vipStartTime.Format(cm.Date_Full_Layout)
|
|
|
updateOrder["vip_endtime"] = vipEndTime.Format(cm.Date_Full_Layout)
|
|
|
updateOrder["ent_id"] = entId
|
|
@@ -532,7 +565,6 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
|
|
|
updateOrder["vip_starttime"] = time.Now().Format(cm.Date_Full_Layout)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
} else if productType == "大会员" {
|
|
|
createType := cm.IntAll(filterMap["createType"])
|
|
|
serverArr := make([]map[string]interface{}, 0)
|
|
@@ -541,6 +573,10 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
|
|
|
serverArr = cm.ObjArrToMapArr(supplys)
|
|
|
}
|
|
|
if createType == 1 {
|
|
|
+ var (
|
|
|
+ entService bool
|
|
|
+ userCount int
|
|
|
+ )
|
|
|
bigStartTime := time.Now()
|
|
|
bigEndTime := GetDATE(cm.IntAll(filterMap["cycle"]), cm.IntAll(filterMap["cycleType"]), bigStartTime.Unix())
|
|
|
status := 0
|
|
@@ -552,6 +588,12 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
|
|
|
return err
|
|
|
}
|
|
|
userId = userPositionId
|
|
|
+ }
|
|
|
+ updateOrder["vip_starttime"] = bigStartTime.Format(cm.Date_Full_Layout)
|
|
|
+ updateOrder["vip_endtime"] = bigEndTime.Format(cm.Date_Full_Layout)
|
|
|
+ updateOrder["ent_id"] = entId
|
|
|
+ updateOrder["user_id"] = userId
|
|
|
+ if cm.IntAll(orderInfo["buy_subject"]) == 2 {
|
|
|
var sName string
|
|
|
if cm.IntAll(filterMap["comboId"]) != 0 {
|
|
|
if cm.IntAll(filterMap["comboId"]) == 5 {
|
|
@@ -565,20 +607,23 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
|
|
|
}
|
|
|
st := cm.FormatDate(&bigStartTime, cm.Date_Full_Layout)
|
|
|
et := cm.FormatDate(&bigEndTime, cm.Date_Full_Layout)
|
|
|
- err := EntLicense(entId, cm.IntAll(orderInfo["buy_count"]), cm.IntAll(cm.If(cm.IntAll(filterMap["areaCount"]) > 0, cm.IntAll(filterMap["areaCount"]), -1)), cm.IntAll(orderInfo["id"]), cm.IntAll(orderInfo["buy_count"]), fmt.Sprintf("%s%s", "大会员", sName), st, et, cm.ObjToString(orderInfo["user_phone"]))
|
|
|
+ entService, userCount = EntServiceOpen(entId, cm.ObjToString(orderInfo["user_phone"]), cm.ObjToString(orderInfo["product_type"]), bigStartTime.Unix())
|
|
|
+ err := EntLicense(entId, cm.IntAll(orderInfo["buy_count"]), cm.IntAll(cm.If(cm.IntAll(filterMap["areaCount"]) > 0, cm.IntAll(filterMap["areaCount"]), -1)), cm.IntAll(orderInfo["id"]), userCount, fmt.Sprintf("%s%s", "大会员", sName), st, et, cm.ObjToString(orderInfo["user_phone"]))
|
|
|
if err != nil {
|
|
|
log.Printf("EntLicense 创建企业授权信息失败:code:%s,err:%s", orderCode, err.Error())
|
|
|
return err
|
|
|
}
|
|
|
+ if !entService {
|
|
|
+ ClearBigVipUserPower(userId)
|
|
|
+ }
|
|
|
}
|
|
|
- err := NewBigOpenService(filterMap, userId, cm.ObjToString(orderInfo["user_phone"]), bigStartTime, bigEndTime, cm.IntAll(status), cm.IntAll(orderInfo["buy_count"]), cm.IntAll(orderInfo["buy_subject"]), entId)
|
|
|
- if err != nil {
|
|
|
- return errors.New(fmt.Sprintf("订单编号:%s,开通大会员权益失败", orderCode))
|
|
|
+ if entService || cm.IntAll(orderInfo["buy_subject"]) == 1 {
|
|
|
+ err := NewBigOpenService(filterMap, userId, cm.ObjToString(orderInfo["user_phone"]), bigStartTime, bigEndTime, cm.IntAll(status), cm.IntAll(orderInfo["buy_count"]), cm.IntAll(orderInfo["buy_subject"]), entId)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New(fmt.Sprintf("订单编号:%s,开通大会员权益失败", orderCode))
|
|
|
+ }
|
|
|
}
|
|
|
- updateOrder["vip_starttime"] = bigStartTime.Format(cm.Date_Full_Layout)
|
|
|
- updateOrder["vip_endtime"] = bigEndTime.Format(cm.Date_Full_Layout)
|
|
|
- updateOrder["ent_id"] = entId
|
|
|
- updateOrder["user_id"] = userId
|
|
|
+
|
|
|
} else { //1-新建 2-补充 3-延期
|
|
|
memberStatus := cm.IntAll(userData["i_member_status"])
|
|
|
bigEndTime := cm.Int64All(userData["i_member_endtime"])
|
|
@@ -602,16 +647,6 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
|
|
|
var newStartTime, newEndTime time.Time
|
|
|
effectState := true
|
|
|
if bmEndTime.Unix() < time.Now().Unix() || cm.IntAll(userData["i_member_status"]) < 0 { //原服务已过期
|
|
|
- /*//查询回款记录,最近一笔回款时间
|
|
|
- newReturnMoneyTime, checkPassTime, err := GetReturnTimeAndCheckTime(orderCode)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if newReturnMoneyTime.Unix() > checkPassTime.Unix() {
|
|
|
- newStartTime = newReturnMoneyTime
|
|
|
- } else {
|
|
|
- newStartTime = checkPassTime
|
|
|
- }*/
|
|
|
newStartTime = time.Now()
|
|
|
effectState = false
|
|
|
cycleCount := cm.IntAll(filterMap["cycle"])
|