ziwen 2 years ago
parent
commit
b479ada6e9
2 changed files with 74 additions and 22 deletions
  1. 73 21
      controller/contract/register.go
  2. 1 1
      models/fms/contract_register.go

+ 73 - 21
controller/contract/register.go

@@ -36,7 +36,7 @@ type RegisterController struct{}
 // @Param   StartDate		query	string	false	"合同开始日期"
 // @Param   EndDate			query	string	false	"合同结束日期"
 // @Param   ServiceType		query	int		false	"套餐类型"
-// @Param   ContractType	query	int		false	"合同类型"
+// @Param   ContractType	query	string	false	"合同类型"
 // @Param   RegisterStatus	query	int		false	"登记状态"
 // @Success 200 {object} fms.ContractRegisterItem
 // @router /contract/register/list [get]
@@ -66,9 +66,33 @@ func (rg *RegisterController) List(c *gin.Context) {
 		cond += ` AND (create_time BETWEEN ? AND ?)`
 		pars = append(pars, st, ed)
 	}
-	if req.ContractType != 0 {
-		cond += ` AND contract_type = ?`
-		pars = append(pars, req.ContractType)
+	if req.ContractType != "" {
+		newCond := ""
+		typeSlices := strings.Split(req.ContractType, ",")
+		for _, v := range typeSlices {
+			if v[:1] == "0" {
+				//自付
+				if v[1:] == "1"{
+					newCond += ` (contract_type = 1 AND has_payment=0) `
+				} else if v[1:] == "2" {
+					newCond += ` (contract_type = 2 AND has_payment=0) `
+				} else {
+					newCond += ` (contract_type = 4 AND has_payment=0) `
+				}
+			} else {
+				//代付
+				if v[1:] == "1"{
+					newCond += ` (contract_type = 1 AND has_payment=1) `
+				} else if v[1:] == "2" {
+					newCond += ` (contract_type = 2 AND has_payment=1) `
+				} else {
+					newCond += ` (contract_type = 4 AND has_payment=1) `
+				}
+			}
+			newCond += " OR "
+		}
+		newCond = strings.TrimRight(newCond, "OR ")
+		cond += " AND " + "(" +newCond + ")"
 	}
 	if req.RegisterStatus != 0 {
 		cond += ` AND register_status = ?`
@@ -147,14 +171,18 @@ func (rg *RegisterController) List(c *gin.Context) {
 			//代付
 			if list[i].ContractType == 1 {
 				v.ContractTypeString = "代付合同(新签)"
-			}else {
+			} else if list[i].ContractType == 2 {
 				v.ContractTypeString = "代付合同(续约)"
+			} else {
+				v.ContractTypeString = "代付合同(补充)"
 			}
 		} else {
 			if list[i].ContractType == 1 {
 				v.ContractTypeString = "自付合同(新签)"
-			}else {
+			} else if list[i].ContractType == 2 {
 				v.ContractTypeString = "自付合同(续约)"
+			} else {
+				v.ContractTypeString = "自付合同(补充)"
 			}
 		}
 		v.ContractRegisterItem = list[i]
@@ -318,10 +346,10 @@ func (rg *RegisterController) Add(c *gin.Context) {
 	ob.HasPayment = req.HasPayment
 	ob.Set()
 	updateCols := []string{
-		"ContractCode","RelateContractCode", "RelateContractMainCode","CrmContractId","ContractSource",
+		"ContractCode", "RelateContractCode", "RelateContractMainCode", "CrmContractId", "ContractSource",
 		"ProductIds", "CompanyName", "SellerId", "SellerName", "StartDate", "EndDate",
-		"RaiSellerId", "RaiSellerName", "ModifyTime","ContractType","ContractAmount","CurrencyUnit","RMBRate",
-		"SignDate","AgreedPayTime","ContractStatus","RegisterStatus", "Remark", "HasPayment",
+		"RaiSellerId", "RaiSellerName", "ModifyTime", "ContractType", "ContractAmount", "CurrencyUnit", "RMBRate",
+		"SignDate", "AgreedPayTime", "ContractStatus", "RegisterStatus", "Remark", "HasPayment",
 	}
 	// 存在代付的直接完成登记, 且不允许进行开票/到款登记
 	if req.HasPayment == 1 || req.ContractStatus == fms.ContractStatusEnd {
@@ -401,7 +429,7 @@ func (rg *RegisterController) Add(c *gin.Context) {
 				SellerName:         ppItem.SellerName,
 				SellerGroupId:      ppItem.SellerGroupId,
 				SellerGroupName:    ppItem.SellerGroupName,
-				SellerTeamId:      ppItem.SellerTeamId,
+				SellerTeamId:       ppItem.SellerTeamId,
 				SellerTeamName:     ppItem.SellerTeamName,
 				AdminId:            int(adminInfo.AdminId),
 				AdminName:          adminInfo.RealName,
@@ -464,7 +492,7 @@ func (rg *RegisterController) Add(c *gin.Context) {
 			resp.FailMsg("获取预登记失败", "Err:"+e.Error(), c)
 			return
 		}
-		e  = item.Delete()
+		e = item.Delete()
 		if e != nil {
 			resp.FailMsg("删除预登记失败", "Err:"+e.Error(), c)
 			return
@@ -634,7 +662,7 @@ func (rg *RegisterController) Edit(c *gin.Context) {
 
 	updateCols := []string{
 		"ProductIds", "ContractCode", "RelateContractCode", "CrmContractId", "ContractSource", "CompanyName",
-		"SellerId", "SellerName", "ContractType", "ContractAmount", "StartDate", "EndDate", "SignDate", "AgreedPayTime","RaiSellerId","RaiSellerName",
+		"SellerId", "SellerName", "ContractType", "ContractAmount", "StartDate", "EndDate", "SignDate", "AgreedPayTime", "RaiSellerId", "RaiSellerName",
 		"ContractStatus", "RegisterStatus", "Remark", "ServiceRemark", "HasPayment", "ModifyTime",
 	}
 	nowTime := time.Now().Local()
@@ -896,7 +924,7 @@ func (rg *RegisterController) Detail(c *gin.Context) {
 			item.SellerIds = strconv.Itoa(item.RaiSellerId)
 		}
 	}
-	
+
 	item.SellerIds = strings.Trim(item.SellerIds, ",")
 	result.ContractRegisterItem = item
 
@@ -1228,7 +1256,7 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
 			return
 		}
 	}
-	
+
 	// 校验金额-是否修改状态
 	go fmsService.CheckContractRegisterAmount(req.ContractRegisterId)
 
@@ -1252,7 +1280,7 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
 // @Param   StartDate		query	string	false	"合同开始日期"
 // @Param   EndDate			query	string	false	"合同结束日期"
 // @Param   ServiceType		query	int		false	"套餐类型"
-// @Param   ContractType	query	int		false	"合同类型"
+// @Param   ContractType	query	string	false	"合同类型"
 // @Param   RegisterStatus	query	int		false	"登记状态"
 // @Param   ListParam		query	int		false	"套餐类型: 0-全部; 1-ficc; 2-权益"
 // @Success 200 string "操作成功"
@@ -1283,9 +1311,33 @@ func (rg *RegisterController) Export(c *gin.Context) {
 		cond += ` AND (create_time BETWEEN ? AND ?)`
 		pars = append(pars, st, ed)
 	}
-	if req.ContractType != 0 {
-		cond += ` AND contract_type = ?`
-		pars = append(pars, req.ContractType)
+	if req.ContractType != "" {
+		newCond := ""
+		typeSlices := strings.Split(req.ContractType, ",")
+		for _, v := range typeSlices {
+			if v[:1] == "0" {
+				//自付
+				if v[1:] == "1"{
+					newCond += ` (contract_type = 1 AND has_payment=0) `
+				} else if v[1:] == "2" {
+					newCond += ` (contract_type = 2 AND has_payment=0) `
+				} else {
+					newCond += ` (contract_type = 4 AND has_payment=0) `
+				}
+			} else {
+				//代付
+				if v[1:] == "1"{
+					newCond += ` (contract_type = 1 AND has_payment=1) `
+				} else if v[1:] == "2" {
+					newCond += ` (contract_type = 2 AND has_payment=1) `
+				} else {
+					newCond += ` (contract_type = 4 AND has_payment=1) `
+				}
+			}
+			newCond += " OR "
+		}
+		newCond = strings.TrimRight(newCond, "OR ")
+		cond += " AND " + "(" +newCond + ")"
 	}
 	if req.RegisterStatus != 0 {
 		cond += ` AND register_status = ?`
@@ -1307,7 +1359,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
 	}
 	if req.ListParam == 1 {
 		cond += ` AND product_ids = '2' `
-	}else if req.ListParam == 2 {
+	} else if req.ListParam == 2 {
 		cond += ` AND product_ids = '2' `
 	}
 	// 获取列表数据
@@ -1750,10 +1802,10 @@ func (rg *RegisterController) Export(c *gin.Context) {
 		dataRow.AddCell().SetString(v.CurrencyUnit)                                      // 货币单位
 		if ficcAmount != nil {
 			dataRow.AddCell().SetString(fmt.Sprint("¥", ficcAmount.ServiceAmount)) // FICC套餐总金额
-			dataRow.AddCell().SetString("") // 权益套餐总金额
+			dataRow.AddCell().SetString("")                                        // 权益套餐总金额
 		}
 		if raiAmount != nil {
-			dataRow.AddCell().SetString("") // 权益套餐总金额
+			dataRow.AddCell().SetString("")                                       // 权益套餐总金额
 			dataRow.AddCell().SetString(fmt.Sprint("¥", raiAmount.ServiceAmount)) // FICC套餐总金额
 		}
 		if ficcAmount == nil && raiAmount == nil {

+ 1 - 1
models/fms/contract_register.go

@@ -103,7 +103,7 @@ type ContractRegisterListReq struct {
 	StartDate      string `json:"start_date" form:"start_date" binding:"omitempty,datetime=2006-01-02" description:"合同开始日期"`
 	EndDate        string `json:"end_date" form:"end_date" binding:"omitempty,datetime=2006-01-02" description:"合同结束日期"`
 	ServiceTypes   string `json:"service_types" form:"service_types" description:"套餐类型"`
-	ContractType   int    `json:"contract_type" form:"contract_type" description:"合同类型"`
+	ContractType   string    `json:"contract_type" form:"contract_type" description:"合同类型"`
 	RegisterStatus int    `json:"register_status" form:"register_status" description:"登记状态"`
 	ListParam      int    `json:"list_param" form:"list_param" description:"套餐类型: 0-全部; 1-ficc; 2-权益"`
 	base.PageReq