|
@@ -168,6 +168,7 @@ func Detail(ctx context.Context, param model.OrderDetailParams) (map[string]inte
|
|
|
} else {
|
|
|
m["isRed"] = false
|
|
|
}
|
|
|
+ m["totalPeriod"] = TotalPeriod(filter)
|
|
|
m["final_price"] = gconv.Int(m["final_price"]) + productRed[gconv.Int(m["id"])]
|
|
|
if productName := gconv.String(filter["productName"]); productName == "" { //历史订单中的类型不做匹配处理
|
|
|
productItem, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT jpi.name,jpc.auto,jpc.code,jpc.attribute FROM jy_product_item jpi
|
|
@@ -723,3 +724,72 @@ func VipFilterFmt(m map[string]interface{}) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// 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季度
|
|
|
+func TotalPeriod(filterMap map[string]interface{}) string {
|
|
|
+ var (
|
|
|
+ year, month, day int
|
|
|
+ totalPeriodStr []string
|
|
|
+ buyCycle = gconv.Int(filterMap["buy_cycle"])
|
|
|
+ giveCycle = gconv.Int(filterMap["give_cycle"])
|
|
|
+ activityGiveCycle = gconv.Int(filterMap["activity_give_cycle"])
|
|
|
+ )
|
|
|
+ switch gconv.Int(filterMap["buy_type"]) {
|
|
|
+ case 1:
|
|
|
+ day += buyCycle
|
|
|
+ case 2:
|
|
|
+ month += buyCycle
|
|
|
+ case 3:
|
|
|
+ year += buyCycle
|
|
|
+ case 4:
|
|
|
+ month += buyCycle * 3
|
|
|
+ }
|
|
|
+
|
|
|
+ switch gconv.Int(filterMap["give_type"]) {
|
|
|
+ case 1:
|
|
|
+ day += giveCycle
|
|
|
+ case 2:
|
|
|
+ month += giveCycle
|
|
|
+ case 3:
|
|
|
+ year += giveCycle
|
|
|
+ case 4:
|
|
|
+ month += giveCycle * 3
|
|
|
+ }
|
|
|
+
|
|
|
+ switch gconv.Int(filterMap["activity_give_type"]) {
|
|
|
+ case 1:
|
|
|
+ day += activityGiveCycle
|
|
|
+ case 2:
|
|
|
+ month += activityGiveCycle
|
|
|
+ case 3:
|
|
|
+ year += activityGiveCycle
|
|
|
+ case 4:
|
|
|
+ month += activityGiveCycle * 3
|
|
|
+ }
|
|
|
+
|
|
|
+ if day >= 30 {
|
|
|
+ month += day / 30
|
|
|
+ day = day % 30
|
|
|
+ }
|
|
|
+ if month >= 12 {
|
|
|
+ year += month / 12
|
|
|
+ month = month % 12
|
|
|
+ }
|
|
|
+ if year > 0 {
|
|
|
+ totalPeriodStr = append(totalPeriodStr, fmt.Sprintf("%d年", year))
|
|
|
+ }
|
|
|
+
|
|
|
+ if month > 0 {
|
|
|
+ totalPeriodStr = append(totalPeriodStr, fmt.Sprintf("%d月", month))
|
|
|
+ }
|
|
|
+
|
|
|
+ if day > 0 {
|
|
|
+ totalPeriodStr = append(totalPeriodStr, fmt.Sprintf("%d天", day))
|
|
|
+ }
|
|
|
+
|
|
|
+ return strings.Join(totalPeriodStr, "")
|
|
|
+}
|