Browse Source

Merge branch 'crm/crm_16.2.2' of http://8.136.199.33:3000/hongze/hz_crm_api into debug

zhangchuanxing 3 months ago
parent
commit
9fbb719ba9
1 changed files with 23 additions and 0 deletions
  1. 23 0
      services/contract/contract.go

+ 23 - 0
services/contract/contract.go

@@ -86,6 +86,29 @@ func AddContract(req request.AddContractReq, sellerId, productId int, sellerName
 		err = errors.New(fmt.Sprint("合同编号生成异常,Err:", err))
 		return
 	}
+
+	//权益的新签合同重新定义,如果合同起始时间在第一份新签合同起始日期 1年之内的,仍为新签合同。
+	if productId == utils.COMPANY_PRODUCT_RAI_ID && req.ContractType == "" {
+		//根据社会信用码获取客户信息
+		companyInfo, err := company.GetCompanyByCreditCode(creditCode)
+		//如果查询异常,且并不是在系统中找不到该社会信用码,那么就异常返回
+		if err != nil {
+			err = errors.New(fmt.Sprint("根据社会信用码获取客户信息,Err:", err))
+			return
+		}
+		totalLastYear, err := GetCompanyContractCountRaiByLastYear(companyInfo.CompanyId, req.StartDate)
+		if err != nil {
+			err = errors.New(fmt.Sprint("获取第一份新签合同起始日期是否1年之内失败,Err:", err))
+			return
+		}
+		if totalLastYear > 0 {
+			req.ContractType = "新签合同"
+		} else {
+			req.ContractType = "续约合同"
+		}
+
+	}
+
 	contractInfo := &contract.Contract{
 		ContractCode:         contractCode,
 		SellerId:             sellerId,