Kaynağa Gözat

fix:权益分配修改

duxin 2 ay önce
ebeveyn
işleme
0b88078910
2 değiştirilmiş dosya ile 47 ekleme ve 6 silme
  1. 15 0
      entity/entity.go
  2. 32 6
      service/service.go

+ 15 - 0
entity/entity.go

@@ -45,6 +45,21 @@ type VipSimpleMsg struct {
 	Remark           string                   `json:"remark"`           //备注字段
 }
 
+type VipCycleFilter struct {
+	BuyAccountCount  int `json:"buyAccountCount"`  //购买数量(仅购买主体是企业)
+	GiftAccountCount int `json:"giftAccountCount"` //赠送数量 要算售价(仅购买主体是企业)
+	CutAccount       int `json:"cutAccount"`       //不计入成本的子账号数量(仅购买主体是企业)
+	BuyCycle         int `json:"buy_cycle"`        //购买周期
+	BuyType          int `json:"buy_type"`         //购买周期 类型 1天 2月 3年 4季度
+	GiftCycle        int `json:"give_cycle"`       //赠送周期
+	GiftType         int `json:"give_type"`        //赠送周期 类型 1天 2月 3年 4季度
+
+	FinalAccountCount int `json:"finalAccountCount"` //当前套餐最终
+	FinalAreaCount    int `json:"finalAreaCount"`
+
+	Supplement string `json:"supplement" doc:"补充服务"`
+}
+
 // 购买内容
 type SubvipBuySet struct {
 	Upgrade         int   `json:"upgrade"`         //是否是升级版;1是 其他不是

+ 32 - 6
service/service.go

@@ -3,7 +3,9 @@ package service
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
 	"log"
+	"math"
 	"strconv"
 	"strings"
 	"time"
@@ -221,7 +223,7 @@ func BuyProductList(this *entmanageapplication.BuyProductListReq) *entmanageappl
 func addPower(waitEmpowerId int64, identity *usercenter.Identity) {
 	data := JyMysql.FindOne(EntnicheOrder, map[string]interface{}{"wait_empower_id": waitEmpowerId}, "", "")
 	if data != nil && len(*data) > 0 {
-		orderId := common.Int64All((*data)["product_id"])
+		orderId := common.Int64All((*data)["order_detail_id"])
 		orderData := JyMysql.FindOne(JyOrderDetail, map[string]interface{}{"id": orderId}, "", "")
 		if orderData != nil && len(*orderData) > 0 {
 			productType := common.ObjToString((*orderData)["product_type"])
@@ -385,11 +387,18 @@ func vipSetMap(orderData map[string]interface{}) (set map[string]interface{}, se
 	setEntUser["i_vip_status"] = common.If(isTrial, -2, 2) //1试用 2正式 -2 试用到期
 	vms := VipSimpleMsg{}
 	json.Unmarshal([]byte(common.ObjToString(orderData["filter"])), &vms)
-
+	if vms.NewBuyset == nil { //704改版后新订单不包含此类信息
+		newVms := VipCycleFilter{}
+		json.Unmarshal([]byte(common.ObjToString(orderData["filter"])), &newVms)
+		vms.NewBuyset = &SubvipBuySet{
+			Upgrade:   1,
+			AreaCount: newVms.FinalAreaCount,
+		}
+	}
 	set = map[string]interface{}{
 		"o_entniche": map[string]interface{}{
-			"i_trial":      -1,              //已激活试用
-			"o_area":       *vms.Area,       //设置地区
+			"i_trial": -1, //已激活试用
+			//"o_area":       *vms.Area,       //设置地区
 			"o_buyset":     *vms.NewBuyset,  //购买内容 城市、省份、行业数量
 			"a_buyerclass": []interface{}{}, //设置行业
 		},
@@ -399,12 +408,29 @@ func vipSetMap(orderData map[string]interface{}) (set map[string]interface{}, se
 	return
 }
 
+func month(num, ty int) int {
+	//BuyType    int      `json:"buy_type"`   //购买周期 类型 1天 2月 3年 4季度
+	switch ty {
+	case 2:
+		return num
+	case 1:
+		return gconv.Int(math.Ceil(float64(num) / 30))
+	case 3:
+		return num * 12
+	case 4:
+		return num * 3
+	}
+	return 0
+}
+
 func memberSetMap(userId, waitEmpowerId int64, orderData map[string]interface{}) (set map[string]interface{}, setEntUser map[string]interface{}) {
 	set, setEntUser = map[string]interface{}{}, map[string]interface{}{}
 	filterMap := common.ObjToMap(orderData["filter"])
-	level := common.IntAll((*filterMap)["level"])
 	comboId := common.IntAll((*filterMap)["comboId"])
-	payCycle := common.IntAll((*filterMap)["cycle"])
+	level := common.If(comboId == 0, 5, comboId).(int)
+	payCycle := month(common.IntAll((*filterMap)["buy_cycle"]), common.IntAll((*filterMap)["buy_type"])) + month(common.IntAll((*filterMap)["give_cycle"]), common.IntAll((*filterMap)["give_type"]))
+
+	//payCycle := common.IntAll((*filterMap)["cycle"])
 	serversId := common.ObjToString((*filterMap)["serversId"])
 	startTime := common.ObjToString(orderData["service_starttime"])
 	endTime := common.ObjToString(orderData["service_endtime"])