Explorar el Código

fix:格式化日期

Roc hace 1 año
padre
commit
2797898265

+ 6 - 6
models/company/company.go

@@ -176,12 +176,12 @@ func ApplyServiceUpdate(companyId, productId, sellerId, companyContractId int, s
 
 	//产品服务的开始、结束日期(非产品权限)
 	updateStartDate := startDate
-	updateStartDateTime, err := time.Parse(utils.FormatDate, updateStartDate)
+	updateStartDateTime, err := time.ParseInLocation(utils.FormatDate, updateStartDate, time.Local)
 	if err != nil {
 		return
 	}
 	updateEndDate := endDate
-	updateEndDateTime, err := time.Parse(utils.FormatDate, updateEndDate)
+	updateEndDateTime, err := time.ParseInLocation(utils.FormatDate, updateEndDate, time.Local)
 	if err != nil {
 		return
 	}
@@ -203,7 +203,7 @@ func ApplyServiceUpdate(companyId, productId, sellerId, companyContractId int, s
 		nowCompanyReportPermissionMap[pv.ChartPermissionId] = pv
 
 		//校验原始数据中的开始日期是否小于合同内的开始日期,如果小于,那么变更为原先的合同开始日期
-		tmpStartDate, tmpErr := time.Parse(utils.FormatDate, pv.StartDate)
+		tmpStartDate, tmpErr := time.ParseInLocation(utils.FormatDate, pv.StartDate, time.Local)
 		if tmpErr != nil {
 			err = tmpErr
 			return
@@ -213,7 +213,7 @@ func ApplyServiceUpdate(companyId, productId, sellerId, companyContractId int, s
 		}
 
 		//校验原始数据中的结束日期是否大于合同内的结束日期,如果大于,那么变更为原先的合同结束日期
-		tmpEndDate, tmpErr := time.Parse(utils.FormatDate, pv.EndDate)
+		tmpEndDate, tmpErr := time.ParseInLocation(utils.FormatDate, pv.EndDate, time.Local)
 		if tmpErr != nil {
 			err = tmpErr
 			return
@@ -264,12 +264,12 @@ func ApplyServiceUpdate(companyId, productId, sellerId, companyContractId int, s
 			//如果 需要更新 字段 为false,那么再去校验时间
 			if needUpdate == false {
 				//如果当前存该权限,那么去校验是否需要修改
-				nowPermissionEndDateTime, tmpErr := time.Parse(utils.FormatDate, nowPermission.EndDate)
+				nowPermissionEndDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, nowPermission.EndDate, time.Local)
 				if tmpErr != nil {
 					err = tmpErr
 					return
 				}
-				contractPermissionEndDateTime, tmpErr := time.Parse(utils.FormatDate, pv.EndDate)
+				contractPermissionEndDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, pv.EndDate, time.Local)
 				if tmpErr != nil {
 					err = tmpErr
 					return

+ 12 - 9
models/company_product_update_log.go

@@ -7,15 +7,18 @@ import (
 
 // CompanyProductUpdateLog 客户产品变更日志表
 type CompanyProductUpdateLog struct {
-	Id         int       `orm:"column(id);pk"`
-	CompanyId  int       `description:"客户id"`
-	ProductId  int       `description:"产品id"`
-	Status     string    `description:"变更后的状态"`
-	SellerId   int       `description:"销售id"`
-	SellerName string    `description:"销售名称"`
-	IsFormal   int       `description:"是否已经转正式,0是没有转正式,1是已经转过正式"`
-	Source     string    `description:"来源"`
-	CreateTime time.Time `description:"创建时间"`
+	Id          int       `orm:"column(id);pk"`
+	CompanyId   int       `description:"客户id"`
+	ProductId   int       `description:"产品id"`
+	Status      string    `description:"变更后的状态"`
+	SellerId    int       `description:"销售id"`
+	SellerName  string    `description:"销售名称"`
+	IsFormal    int       `description:"是否已经转正式,0是没有转正式,1是已经转过正式"`
+	Source      string    `description:"来源"`
+	StartDate   time.Time `description:"开始日期"`
+	EndDate     time.Time `description:"结束日期"`
+	RealEndDate time.Time `description:"实际结束日期"`
+	CreateTime  time.Time `description:"创建时间"`
 }
 
 // AddCompanyProductUpdateLog 新增客户产品变更日志

+ 4 - 0
services/company_contract/company_contract.go

@@ -107,6 +107,8 @@ func HandleCompanyContract(cont context.Context) (err error) {
 			case 6: //正式客户新增补充协议
 				updateSource = "add_agreement"
 			}
+			tmpStartDate, _ := time.ParseInLocation(utils.FormatDate, v.StartDate, time.Local)
+			tmpEndDate, _ := time.ParseInLocation(utils.FormatDate, v.EndDate, time.Local)
 			companyProductUpdateLog := &models.CompanyProductUpdateLog{
 				Id:         0,
 				CompanyId:  companyProduct.CompanyId,
@@ -116,6 +118,8 @@ func HandleCompanyContract(cont context.Context) (err error) {
 				SellerName: companyProduct.SellerName,
 				Source:     updateSource,
 				IsFormal:   companyProduct.IsFormal, //是否已经转正式,0是没有转正式,1是已经转过正式
+				StartDate:  tmpStartDate,
+				EndDate:    tmpEndDate,
 				CreateTime: time.Now(),
 			}
 			go models.AddCompanyProductUpdateLog(companyProductUpdateLog)