Explorar o código

fix:P652管理后台帮助用户下单“销售赠送时长”增加限制

duxin hai 9 meses
pai
achega
3d429d09b1
Modificáronse 1 ficheiros con 26 adicións e 4 borrados
  1. 26 4
      src/jfw/modules/subscribepay/src/service/salesCreateOrder.go

+ 26 - 4
src/jfw/modules/subscribepay/src/service/salesCreateOrder.go

@@ -16,6 +16,7 @@ import (
 	"log"
 	"net/url"
 	"strconv"
+	"strings"
 	"time"
 
 	. "app.yhyue.com/moapp/jybase/api"
@@ -119,11 +120,32 @@ func (this *SalesCreateOrder) CreateBySeller() {
 			saleDep = qutil.ObjToString(sellData["ts"])
 			deptId = qutil.IntAll(sellData["ti"])
 			if inserMap.VipEndTime != "" {
+				tm := qutil.InterfaceToStr(data["time"])
+				var isSend bool
+				switch { //大于一年才赠送
+				case strings.Contains(tm, "年"):
+					dateStr := strings.Replace(tm, "年", "", -1)
+					if qutil.IntAll(dateStr) >= 1 {
+						isSend = true
+					}
+				case strings.Contains(tm, "季"):
+					dateStr := strings.Replace(tm, "季", "", -1)
+					if qutil.IntAll(dateStr) >= 4 {
+						isSend = true
+					}
+				case strings.Contains(tm, "月"):
+					dateStr := strings.Replace(tm, "月", "", -1)
+					if qutil.IntAll(dateStr) >= 12 {
+						isSend = true
+					}
+				}
 				endTime, _ := time.ParseInLocation(Date_Full_Layout, inserMap.VipEndTime, time.Local)
-				if tt == 1 {
-					endTime = endTime.AddDate(0, 0, tn)
-				} else if tt == 2 {
-					endTime = endTime.AddDate(0, tn, 0)
+				if isSend {
+					if tt == 1 {
+						endTime = endTime.AddDate(0, 0, tn)
+					} else if tt == 2 {
+						endTime = endTime.AddDate(0, tn, 0)
+					}
 				}
 				inserMap.VipEndTime = endTime.Format(Date_Full_Layout)
 			}