Explorar o código

企明星 优惠中的订单详情

wangshan %!s(int64=5) %!d(string=hai) anos
pai
achega
f343e6e7b9
Modificáronse 1 ficheiros con 27 adicións e 3 borrados
  1. 27 3
      core/src/qfw/manage/vipOrder.go

+ 27 - 3
core/src/qfw/manage/vipOrder.go

@@ -8,6 +8,7 @@ import (
 	"qfw/util"
 	"qfw/util/mongodb"
 	"regexp"
+	"strconv"
 	"strings"
 	"time"
 
@@ -160,12 +161,14 @@ func (v *VipOrder) VipPageing() {
 func (v *VipOrder) VipOrderDetail(order_code string) error {
 	qMap := map[string]interface{}{}
 	var filterMap map[string]interface{}
+	var DiscountFlag = false
 	qMap["order_code"] = order_code
 	table := ""
 	res := cutil.Mysql.FindOne("dataexport_order", qMap, "", "create_time desc")
 	if len(*res) > 0 {
 		if cutil.Mysql.CountBySql(`SELECT count(*) FROM prefer_active a WHERE a.order_code = ?`, order_code) > 0 {
-			(*res)["DiscountFlag"] = true
+			DiscountFlag = true
+			(*res)["DiscountFlag"] = DiscountFlag
 		}
 		pay_time := util.ObjToString((*res)["pay_time"])
 		orderMoney := util.Float64All((*res)["order_money"]) / 100
@@ -338,11 +341,15 @@ func (v *VipOrder) VipOrderDetail(order_code string) error {
 			vip_endtime := util.ObjToString((*res)["vip_endtime"])
 			vip_starttime := util.ObjToString((*res)["vip_starttime"])
 			if vip_endtime != "" && vip_starttime != "" {
-				year := 0
 				month := 0
 				//订阅周期
 				vip_starttime_stamp, _ := time.ParseInLocation(util.Date_Full_Layout, vip_starttime, time.Local)
 				vip_endtime_stamp, _ := time.ParseInLocation(util.Date_Full_Layout, vip_endtime, time.Local)
+				if DiscountFlag {
+					d, _ := time.ParseDuration("-" + strconv.Itoa(24*30) + "h")
+					vip_endtime_stamp = vip_endtime_stamp.Add(d)
+				}
+				year := 0
 				start_year := time.Unix(util.Int64All(vip_starttime_stamp.Unix()), 0).Year()
 				end_year := time.Unix(util.Int64All(vip_endtime_stamp.Unix()), 0).Year()
 				start_month := int(time.Unix(util.Int64All(vip_starttime_stamp.Unix()), 0).Month())
@@ -395,7 +402,24 @@ func (v *VipOrder) VipOrderDetail(order_code string) error {
 				}
 				(filterMap)["effective_date"] = effective_date
 			} else {
-
+				if util.IntAll(filterMap["cycleunit"]) == 1 {
+					subscription_cycle = fmt.Sprintf("%d年", util.IntAll(filterMap["cyclecount"]))
+				} else if util.IntAll(filterMap["cycleunit"]) == 2 {
+					subscription_cycle = fmt.Sprintf("%d个月", util.IntAll(filterMap["cyclecount"]))
+				} else if util.IntAll(filterMap["cycleunit"]) == 3 {
+					subscription_cycle = fmt.Sprintf("%d天", util.IntAll(filterMap["cyclecount"]))
+				} else if util.IntAll(filterMap["cycleunit"]) == -1 {
+					subscription_cycle = "不延期"
+				}
+				//升级续费后的根据 不延期 cycleunit,cyclecount=0,0
+				if util.IntAll(filterMap["cycleunit"]) == 0 && util.IntAll(filterMap["cyclecount"]) == 0 {
+					subscription_cycle = "不延期"
+				}
+				if util.ObjToString((*res)["pay_way"]) == "trial" {
+					(filterMap)["subscription_cycle"] = "7天"
+				} else {
+					(filterMap)["subscription_cycle"] = subscription_cycle
+				}
 			}
 		}
 	}