|
@@ -6,6 +6,7 @@ import (
|
|
|
"mongodb"
|
|
|
qutil "qfw/util"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
"util"
|
|
|
|
|
|
"github.com/baiy/Cadmin-server-go/admin"
|
|
@@ -132,3 +133,97 @@ func FindUserAccount(context *admin.Context) (interface{}, error) {
|
|
|
}
|
|
|
return map[string]interface{}{"data": userData}, nil
|
|
|
}
|
|
|
+
|
|
|
+func HelpVipInfo(context *admin.Context) (interface{}, error) {
|
|
|
+ param := new(struct {
|
|
|
+ Phone string `form:"phone"`
|
|
|
+ RegType string `form:"regType"`
|
|
|
+ })
|
|
|
+ err := context.Form(param)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ willEffect, regType := false, "s_phone"
|
|
|
+ //先判断用户是否有即将生效的超级订阅订单
|
|
|
+ if strings.Contains(param.RegType, "微信") && !strings.Contains(param.RegType, "APP") {
|
|
|
+ regType = "s_m_phone"
|
|
|
+ }
|
|
|
+ query := map[string]interface{}{
|
|
|
+ regType: param.Phone,
|
|
|
+ "l_vip_starttime": map[string]interface{}{
|
|
|
+ "$gt": time.Now().Unix(),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ count1 := util.MQFW.Count("user", query)
|
|
|
+ if count1 > 0 {
|
|
|
+ willEffect = true
|
|
|
+ }
|
|
|
+ // 增加如若存在订单审核状态为“待一审”、“待二审”、“已退回”的超级订阅订单的则不允许创建
|
|
|
+ if ExistProcessOrder(param.Phone, SUPERSUB, "") {
|
|
|
+ willEffect = true
|
|
|
+ }
|
|
|
+ if willEffect {
|
|
|
+ return map[string]interface{}{
|
|
|
+ "willEffect": true,
|
|
|
+ }, nil
|
|
|
+ }
|
|
|
+ //判断用户购买过超级订阅并且在有效期内 i_vip_status 开启状态:0-暂不使用vip订阅 1-试用 2-正式 -1-试用到期 -2-正式到期
|
|
|
+ userInfo := map[string]interface{}{}
|
|
|
+ userData, ok := util.MQFW.FindOneByField("user", map[string]interface{}{regType: param.Phone, "i_vip_status": 2}, `{"_id":1,"i_vip_expire_tip":1,"i_vip_status":1,"l_vip_endtime":1,"l_vip_starttime":1,"o_vipjy":1}`)
|
|
|
+ if ok && userData != nil && len(*userData) > 0 {
|
|
|
+ userInfo = *userData
|
|
|
+ } else {
|
|
|
+ return map[string]interface{}{
|
|
|
+ "willEffect": false,
|
|
|
+ "userData": nil,
|
|
|
+ "vipExist": false,
|
|
|
+ }, nil
|
|
|
+ }
|
|
|
+ if userInfo != nil && len(userInfo) > 0 {
|
|
|
+ userId := mongodb.BsonIdToSId(userInfo["_id"])
|
|
|
+ //查询订单信息获取客户名称
|
|
|
+ orderInfo := util.JysqlDB.SelectBySql("SELECT c.customer_name,d.company_name FROM dataexport_order d LEFT JOIN contract c ON c.order_code = d.order_code WHERE product_type = 'VIP订阅' and user_id = ? ORDER BY d.id DESC", userId)
|
|
|
+ if len(*orderInfo) == 0 {
|
|
|
+ return nil, errors.New("查询订单表没有查到订单信息")
|
|
|
+ }
|
|
|
+ vipInfo := qutil.ObjToMap(userInfo["o_vipjy"])
|
|
|
+ buySet := qutil.ObjToMap((*vipInfo)["o_buyset"])
|
|
|
+ areaCount := qutil.IntAll((*buySet)["areacount"])
|
|
|
+ //判断购买区域是否是全国
|
|
|
+ nationwide := false
|
|
|
+ if areaCount == -1 {
|
|
|
+ nationwide = true
|
|
|
+ }
|
|
|
+ if areaCount == -1 {
|
|
|
+ areaCount = 0
|
|
|
+ }
|
|
|
+ //area := qutil.ObjToMap((*vipInfo)["o_area"])
|
|
|
+ userInfo["areaCount"] = areaCount
|
|
|
+ //判断是新版超级订阅还是老版超级订阅
|
|
|
+ newVip := false
|
|
|
+ if qutil.IntAll((*buySet)["upgrade"]) == 1 {
|
|
|
+ newVip = true
|
|
|
+ }
|
|
|
+ t := qutil.Int64All(userInfo["l_vip_endtime"])
|
|
|
+ _t := time.Unix(t, 0)
|
|
|
+ userInfo["vipStartTime"] = (_t.AddDate(0, 0, 1)).Format(qutil.Date_Short_Layout)
|
|
|
+ data := map[string]interface{}{
|
|
|
+ "willEffect": false,
|
|
|
+ "vipExist": true,
|
|
|
+ "nationwide": nationwide,
|
|
|
+ "userData": userInfo,
|
|
|
+ "newVip": newVip,
|
|
|
+ }
|
|
|
+ if len((*orderInfo)) > 0 {
|
|
|
+ data["orderInfo"] = (*orderInfo)[0]
|
|
|
+ }
|
|
|
+ return data, nil
|
|
|
+ }
|
|
|
+ return map[string]interface{}{
|
|
|
+ "willEffect": false,
|
|
|
+ "userData": nil,
|
|
|
+ "vipExist": false,
|
|
|
+ "nationwide": false,
|
|
|
+ "new": false,
|
|
|
+ }, nil
|
|
|
+}
|