|
@@ -1,11 +1,13 @@
|
|
|
package product
|
|
|
|
|
|
import (
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
|
"context"
|
|
|
"fmt"
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
type (
|
|
@@ -41,11 +43,11 @@ func GetBigFilter(data map[string]interface{}) (g.Map, string, int, error) {
|
|
|
if vs, ok := filter["recordPayType"]; ok && vs != nil {
|
|
|
recordPayType = gconv.Int(filter["recordPayType"])
|
|
|
} else {
|
|
|
- if gconv.Int(filter["createType"]) == 2 {
|
|
|
+ if gconv.Int(filter["createType"]) == 2 { //升级
|
|
|
recordPayType = 3
|
|
|
- } else if gconv.Int(filter["createType"]) == 3 {
|
|
|
+ } else if gconv.Int(filter["createType"]) == 3 { //续费
|
|
|
recordPayType = 1
|
|
|
- } else {
|
|
|
+ } else { //购买
|
|
|
recordPayType = gconv.Int(filter["createType"])
|
|
|
}
|
|
|
}
|
|
@@ -76,6 +78,14 @@ func GetBigFilter(data map[string]interface{}) (g.Map, string, int, error) {
|
|
|
bigFilter["serviceIds"] = strings.Split(gconv.String(filter["serversId"]), ",")
|
|
|
switch gconv.String(data["product_type"]) {
|
|
|
case "大会员", "大会员-子账号":
|
|
|
+ var (
|
|
|
+ finalAccountCount int64
|
|
|
+ )
|
|
|
+ if gconv.Int(data["buy_subject"]) == 2 {
|
|
|
+ finalAccountCount, _, _, _ = entUserCountAndTime(gconv.Int64(data["id"]))
|
|
|
+ } else if gconv.Int(data["buy_subject"]) == 1 {
|
|
|
+ finalAccountCount, _, _ = userCountAndTime(gconv.String(data["user_id"]))
|
|
|
+ }
|
|
|
bigFilter["buy_cycle"] = gconv.Int(filter["cycle"])
|
|
|
if gconv.Int(filter["level"]) == 4 || gconv.Int(filter["cycleType"]) == 1 {
|
|
|
bigFilter["buy_type"] = 1
|
|
@@ -84,21 +94,44 @@ func GetBigFilter(data map[string]interface{}) (g.Map, string, int, error) {
|
|
|
} else {
|
|
|
bigFilter["buy_type"] = 3
|
|
|
}
|
|
|
- bigFilter["buyAccountCount"] = gconv.Int(data["buy_count"]) //购买账号数
|
|
|
- if gconv.Int(filter["pay_sub_num"]) > 0 { //老订单购买的付费账号
|
|
|
- bigFilter["buyAccountCount"] = gconv.Int(bigFilter["buyAccountCount"]) + gconv.Int(filter["pay_sub_num"])
|
|
|
+ if finalAccountCount == 0 {
|
|
|
+ bigFilter["buyAccountCount"] = gconv.Int(data["buy_count"]) //购买账号数
|
|
|
+ if gconv.Int(filter["pay_sub_num"]) > 0 { //老订单购买的付费账号
|
|
|
+ bigFilter["buyAccountCount"] = gconv.Int(bigFilter["buyAccountCount"]) + gconv.Int(filter["pay_sub_num"])
|
|
|
+ }
|
|
|
+ bigFilter["freeAccountCount"] = gconv.Int(filter["free_sub_num"])
|
|
|
+ finalAccountCount = gconv.Int64(bigFilter["buyAccountCount"]) + gconv.Int64(bigFilter["freeAccountCount"])
|
|
|
}
|
|
|
- bigFilter["freeAccountCount"] = gconv.Int(filter["free_sub_num"])
|
|
|
- bigFilter["finalAccountCount"] = gconv.Int(bigFilter["buyAccountCount"]) + gconv.Int(bigFilter["freeAccountCount"])
|
|
|
+
|
|
|
+ bigFilter["finalAccountCount"] = finalAccountCount
|
|
|
|
|
|
switch gconv.Int(filter["createType"]) {
|
|
|
case 2:
|
|
|
+ if oldSerName := gconv.String(filter["oldSerName"]); oldSerName != "" {
|
|
|
+ bigFilter["oldServiceListName"] = oldSerName
|
|
|
+ }
|
|
|
if supServiceId := gconv.String(filter["new_serverArr"]); supServiceId != "" {
|
|
|
+ serverDataArr, _ := g.DB().Query(ctx, `SELECT id, CASE
|
|
|
+ WHEN id = 1 THEN "基础服务"
|
|
|
+ ELSE s_new_name
|
|
|
+ END AS s_new_name FROM bigmember_service WHERE id in (%s)`, gconv.String(filter["serversId"]))
|
|
|
+ if !serverDataArr.IsEmpty() {
|
|
|
+ var newSerName []string
|
|
|
+ for _, m2 := range serverDataArr.List() {
|
|
|
+ for _, s := range strings.Split(gconv.String(supServiceId), ",") {
|
|
|
+ if common.InterfaceToStr(m2["id"]) == s {
|
|
|
+ newSerName = append(newSerName, common.InterfaceToStr(m2["s_new_name"]))
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bigFilter["supServiceListName"] = strings.Join(newSerName, ",")
|
|
|
+ }
|
|
|
bigFilter["supServiceIds"] = strings.Split(supServiceId, ",")
|
|
|
bigFilter["serviceIds"] = strings.Split(gconv.String(filter["serversId"]), ",")
|
|
|
} else {
|
|
|
bigFilter["supServiceIds"] = strings.Split(gconv.String(filter["serversId"]), ",")
|
|
|
- ids, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT GROUP_CONCAT(DISTINCT s_serviceid SEPARATOR ',') AS concatenated_ids FROM bigmember_service_user WHERE s_userid ='%s'`, gconv.String(data["user_id"])))
|
|
|
+ ids, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT GROUP_CONCAT(DISTINCT s_serviceid SEPARATOR ',') AS concatenated_ids FROM bigmember_service_user WHERE s_userid ='%s' and i_status in (0,1)`, gconv.String(data["user_id"])))
|
|
|
if !ids.IsEmpty() {
|
|
|
bigFilter["serviceIds"] = strings.Split(gconv.String(ids.Map()["concatenated_ids"]), ",")
|
|
|
}
|
|
@@ -135,7 +168,6 @@ func OrderSeal() error {
|
|
|
applicant_id = append(applicant_id, gconv.String(res11.Map()["id"]))
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
res2, _ := g.DB().GetOne(context.Background(), `SELECT phone FROM cadmin.admin_user where id =? `, i2["salesman_id"])
|
|
|
if !res1.IsEmpty() {
|
|
@@ -153,3 +185,29 @@ func OrderSeal() error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+func userCountAndTime(userId string) (userCount int64, sTime, eTime string) {
|
|
|
+ data, _ := MG.DB().FindById("user", userId, "")
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
+ userCount = gconv.Int64((*data)["i_free_sub_num"]) + gconv.Int64((*data)["i_pay_sub_num"])
|
|
|
+ if gconv.Int64((*data)["i_member_endtime"]) < time.Now().Unix() || gconv.Int64((*data)["i_member_status"]) < 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ eTime = time.Unix(gconv.Int64((*data)["i_member_endtime"]), 0).Format("2006-01-02 15:04:05")
|
|
|
+ sTime = time.Unix(gconv.Int64((*data)["i_member_starttime"]), 0).Format("2006-01-02 15:04:05")
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func entUserCountAndTime(orderId int64) (userCount, areaCount int64, sTime, eTime string) {
|
|
|
+ data, _ := g.DB().GetOne(context.Background(), `SELECT * FROM entniche_wait_empower ewe
|
|
|
+INNER JOIN entniche_order eo on ewe.id = eo.wait_empower_id
|
|
|
+WHERE eo.order_id = ?`, orderId)
|
|
|
+ if !data.IsEmpty() {
|
|
|
+ userCount = gconv.Int64(data.Map()["empower_count"])
|
|
|
+ areaCount = gconv.Int64(data.Map()["province_count"])
|
|
|
+ sTime = gconv.String(data.Map()["start_time"])
|
|
|
+ eTime = gconv.String(data.Map()["end_time"])
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|