|
@@ -3281,3 +3281,78 @@ func (rg *RegisterController) CheckContractName(c *gin.Context) {
|
|
|
resp.OkData("查询成功", data, c)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+// CheckContract
|
|
|
+// @Title 货币单位列表
|
|
|
+// @Description 货币单位列表
|
|
|
+// @Success 200 {object} fms.CheckContractNameResp
|
|
|
+// @router /contract/register/check_contract_duplicate [post]
|
|
|
+func (rg *RegisterController) CheckContractDuplicate(c *gin.Context) {
|
|
|
+ var req fms.CheckContractDuplicateReq
|
|
|
+ if e := c.ShouldBind(&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 += ` AND (start_date =? and end_date=?)`
|
|
|
+ } else {
|
|
|
+ existCond = ` start_date = ? and end_date=?`
|
|
|
+ }
|
|
|
+
|
|
|
+ existPars = append(existPars, startDate, endDate)
|
|
|
+ }
|
|
|
+ if len(req.Services) > 0 {
|
|
|
+ //serviceList, e := fmsService.HandleContractServiceAndDetail(req.Services, true, serviceAmountMap)
|
|
|
+ //if e != nil {
|
|
|
+ // resp.FailMsg("操作失败", "获取合同套餐详情失败, Err: "+e.Error(), c)
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if existCond == "" {
|
|
|
+ resp.Fail("请输入合同名称或者合同有效期", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 是否存在相同合同名称的登记
|
|
|
+ list, e := fms.CheckContractDuplicate(existCond, existPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("操作失败", "查询重复合同失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ data := fms.CheckContractDuplicateResp{
|
|
|
+ Exist: 0,
|
|
|
+ }
|
|
|
+ if len(list) > 0 {
|
|
|
+ data.Exist = 1
|
|
|
+ }
|
|
|
+ resp.OkData("查询成功", data, c)
|
|
|
+ return
|
|
|
+}
|