|
@@ -324,7 +324,7 @@ func UserSubDetail(context *admin.Context) (interface{}, error) {
|
|
param := new(struct {
|
|
param := new(struct {
|
|
utils.Page
|
|
utils.Page
|
|
UserId string `form:"userId"` //用户id
|
|
UserId string `form:"userId"` //用户id
|
|
- ServiceId int `form:"serviceId"` //功能
|
|
|
|
|
|
+ ServiceId string `form:"serviceId"` //功能
|
|
Phone string `form:"keyword"`
|
|
Phone string `form:"keyword"`
|
|
})
|
|
})
|
|
err := context.Form(param)
|
|
err := context.Form(param)
|
|
@@ -333,15 +333,23 @@ func UserSubDetail(context *admin.Context) (interface{}, error) {
|
|
}
|
|
}
|
|
data := map[string]interface{}{}
|
|
data := map[string]interface{}{}
|
|
if param.UserId != "" {
|
|
if param.UserId != "" {
|
|
- query := map[string]interface{}{"s_master_userid": param.UserId}
|
|
|
|
|
|
+ sql := "select * from bigmember_consume where s_master_userid = '" + param.UserId + "'"
|
|
|
|
+ sqls := "select count(1) from bigmember_consume where s_master_userid = '" + param.UserId + "'"
|
|
if param.Phone != "" {
|
|
if param.Phone != "" {
|
|
- query["s_phone"] = param.Phone
|
|
|
|
|
|
+ sql += " and s_phone = '" + param.Phone + "'"
|
|
|
|
+ sqls += " and s_phone = '" + param.Phone + "'"
|
|
}
|
|
}
|
|
- if param.ServiceId != 0 {
|
|
|
|
- query["s_serviceid"] = param.ServiceId
|
|
|
|
|
|
+ if param.ServiceId != "" {
|
|
|
|
+ sql += " and s_serviceid = '" + param.ServiceId + "'"
|
|
|
|
+ sqls += " and s_serviceid = '" + param.ServiceId + "'"
|
|
|
|
+ } else {
|
|
|
|
+ sql += " and (s_serviceid = '11' or s_serviceid = '15')"
|
|
|
|
+ sqls += " and (s_serviceid = '11' or s_serviceid = '15')"
|
|
}
|
|
}
|
|
- subData := JysqlDB.Find("bigmember_consume", query, "s_phone,s_serviceid,l_createtime", "l_createtime desc", param.Offset, param.PageSize)
|
|
|
|
- count := JysqlDB.Count("bigmember_consume", query)
|
|
|
|
|
|
+ count := JysqlDB.CountBySql(sqls)
|
|
|
|
+ sql += " order by l_createtime desc"
|
|
|
|
+ sql += " limit " + fmt.Sprint(param.Offset) + "," + fmt.Sprint(param.PageSize)
|
|
|
|
+ subData := JysqlDB.SelectBySql(sql)
|
|
data = map[string]interface{}{
|
|
data = map[string]interface{}{
|
|
"lists": subData,
|
|
"lists": subData,
|
|
"total": count,
|
|
"total": count,
|
|
@@ -398,7 +406,7 @@ func SubAdd(context *admin.Context) (interface{}, error) {
|
|
return nil, nil
|
|
return nil, nil
|
|
}
|
|
}
|
|
if param.Phone != "" {
|
|
if param.Phone != "" {
|
|
- userId, memberStatus, bigEnd := "", 0, int64(0)
|
|
|
|
|
|
+ userId, memberStatus, bigStart, bigEnd := "", 0, int64(0), int64(0)
|
|
now := time.Now()
|
|
now := time.Now()
|
|
userData, ok := MQFW.FindOne("user", map[string]interface{}{"s_phone": param.Phone})
|
|
userData, ok := MQFW.FindOne("user", map[string]interface{}{"s_phone": param.Phone})
|
|
if ok && len(*userData) > 0 {
|
|
if ok && len(*userData) > 0 {
|
|
@@ -454,9 +462,13 @@ func SubAdd(context *admin.Context) (interface{}, error) {
|
|
pay := qutil.IntAll((*data)["i_pay_sub_num"])
|
|
pay := qutil.IntAll((*data)["i_pay_sub_num"])
|
|
free := qutil.IntAll((*data)["i_free_sub_num"])
|
|
free := qutil.IntAll((*data)["i_free_sub_num"])
|
|
subCount := pay + free
|
|
subCount := pay + free
|
|
|
|
+ bigStart = qutil.Int64All((*data)["i_member_starttime"])
|
|
if openCount >= subCount && param.SubStatus == 1 {
|
|
if openCount >= subCount && param.SubStatus == 1 {
|
|
return nil, errors.New("启用子账号数量已达上限")
|
|
return nil, errors.New("启用子账号数量已达上限")
|
|
}
|
|
}
|
|
|
|
+ if param.SubStatus == 1 && time.Now().Unix() < bigStart {
|
|
|
|
+ return nil, errors.New("主账号未生效,无法启用子账号")
|
|
|
|
+ }
|
|
set := map[string]interface{}{}
|
|
set := map[string]interface{}{}
|
|
if param.SubStatus == 0 {
|
|
if param.SubStatus == 0 {
|
|
set = map[string]interface{}{
|
|
set = map[string]interface{}{
|
|
@@ -543,6 +555,9 @@ func SubOpenClose(context *admin.Context) (interface{}, error) {
|
|
} else {
|
|
} else {
|
|
return nil, errors.New("主账号信息未找到,请重试")
|
|
return nil, errors.New("主账号信息未找到,请重试")
|
|
}
|
|
}
|
|
|
|
+ if time.Now().Unix() < buyStart && param.SubStatus == 1 {
|
|
|
|
+ return nil, errors.New("主账号未生效,无法启用子账号")
|
|
|
|
+ }
|
|
if memberStatus > 0 && subStatus == 0 {
|
|
if memberStatus > 0 && subStatus == 0 {
|
|
return nil, errors.New("已有大会员权限,不能启用")
|
|
return nil, errors.New("已有大会员权限,不能启用")
|
|
}
|
|
}
|