|
@@ -265,6 +265,17 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //新老客户判断
|
|
|
+ /*newCompany := req.NewCompany
|
|
|
+ if req.ContractType == 1 {
|
|
|
+ newCompany = 1
|
|
|
+ }else if req.ContractType == 2 || req.ContractType == 3 {
|
|
|
+ newCompany = 0
|
|
|
+ }
|
|
|
+ if newCompany != req.NewCompany {
|
|
|
+ resp.Fail("请输入正确的客户类型", c)
|
|
|
+ return
|
|
|
+ }*/
|
|
|
nowTime := time.Now().Local()
|
|
|
ob.ContractCode = req.ContractCode
|
|
|
ob.RelateContractCode = req.RelateContractCode
|
|
@@ -296,7 +307,6 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
if req.HasPayment == 1 || req.ContractStatus == fms.ContractStatusEnd {
|
|
|
ob.RegisterStatus = fms.ContractRegisterStatusComplete
|
|
|
}
|
|
|
-
|
|
|
// 新增套餐金额详情内容
|
|
|
serviceAmountMap := make(map[int]float64)
|
|
|
serviceAmountList, e := fmsService.HandleContractServiceAmount(req.ServiceAmount, serviceAmountMap, req.CurrencyUnit)
|
|
@@ -304,6 +314,17 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
resp.FailMsg("操作失败", "新增合同套餐金额信息失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
+ //判断产品信息
|
|
|
+ productIds := make(map[int]struct{})
|
|
|
+ productIdsStr := ""
|
|
|
+ for _, v := range serviceAmountList {
|
|
|
+ productIds[v.ProductId] = struct{}{}
|
|
|
+ }
|
|
|
+ for proId, _ := range productIds {
|
|
|
+ productIdsStr += strconv.Itoa(proId)+","
|
|
|
+ }
|
|
|
+ productIdsStr = strings.Trim(productIdsStr, ",")
|
|
|
+ ob.ProductIds = productIdsStr
|
|
|
// 套餐信息
|
|
|
serviceList, e := fmsService.HandleContractServiceAndDetail(req.Services, true, serviceAmountMap)
|
|
|
if e != nil {
|
|
@@ -643,6 +664,18 @@ func (rg *RegisterController) Edit(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ //判断产品信息
|
|
|
+ productIds := make(map[int]struct{})
|
|
|
+ productIdsStr := ""
|
|
|
+ for _, v := range serviceAmountList {
|
|
|
+ productIds[v.ProductId] = struct{}{}
|
|
|
+ }
|
|
|
+ for proId, _ := range productIds {
|
|
|
+ productIdsStr += strconv.Itoa(proId)+","
|
|
|
+ }
|
|
|
+ productIdsStr = strings.Trim(productIdsStr, ",")
|
|
|
+ item.ProductIds = productIdsStr
|
|
|
+
|
|
|
// 套餐信息
|
|
|
serviceList, e := fmsService.HandleContractServiceAndDetail(req.Services, true, serviceAmountMap)
|
|
|
if e != nil {
|
|
@@ -2834,3 +2867,71 @@ func (rg *RegisterController) CurrencyList(c *gin.Context) {
|
|
|
}
|
|
|
resp.OkData("获取成功", list, c)
|
|
|
}
|
|
|
+
|
|
|
+// CheckContractName
|
|
|
+// @Title 货币单位列表
|
|
|
+// @Description 货币单位列表
|
|
|
+// @Success 200 {object} fms.CheckContractNameResp
|
|
|
+// @router /contract/register/check_contract_code [get]
|
|
|
+func (rg *RegisterController) CheckContractName(c *gin.Context) {
|
|
|
+ var req fms.CheckContractNameReq
|
|
|
+ if e := c.BindQuery(&req); e != nil {
|
|
|
+ err, ok := e.(validator.ValidationErrors)
|
|
|
+ if !ok {
|
|
|
+ resp.FailData("参数解析失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailData("参数解析失败", err.Translate(global.Trans), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ existCond :=""
|
|
|
+ existPars := make([]interface{}, 0)
|
|
|
+ if req.CompanyName != "" {
|
|
|
+ // 是否存在相同的合同名称的登记
|
|
|
+ existCond = ` company_name = ?`
|
|
|
+ existPars = append(existPars, req.CompanyName)
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.StartDate != "" && req.EndDate != "" {
|
|
|
+ // 日期校验
|
|
|
+ startDate, e := time.ParseInLocation(utils.FormatDate, req.StartDate, time.Local)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("合同开始日期格式有误", "合同开始日期格式有误, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ endDate, e := time.ParseInLocation(utils.FormatDate, req.EndDate, time.Local)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("合同结束日期格式有误", "合同结束日期格式有误, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if existCond != "" {
|
|
|
+ existCond += ` or (start_date =? and end_date=?)`
|
|
|
+ }else{
|
|
|
+ existCond = ` start_date = ? and end_date=?`
|
|
|
+ }
|
|
|
+
|
|
|
+ existPars = append(existPars, startDate, endDate)
|
|
|
+ }
|
|
|
+ if existCond == "" {
|
|
|
+ resp.Fail("请输入合同名称或者合同有效期", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 是否存在相同合同名称的登记
|
|
|
+ ob := new(fms.ContractRegister)
|
|
|
+ data := fms.CheckContractNameResp{
|
|
|
+ Exist: 0,
|
|
|
+ }
|
|
|
+ _, e := ob.FetchByCondition(existCond, existPars)
|
|
|
+ if e != nil {
|
|
|
+ if e == utils.ErrNoRow {
|
|
|
+ resp.OkData("查询成功", data, c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailMsg("查询失败", "查询相同登记号失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ data.Exist = 1
|
|
|
+ resp.OkData("查询成功", data, c)
|
|
|
+ return
|
|
|
+}
|