|
@@ -247,7 +247,7 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
logItem := new(fms.ContractRegisterLog)
|
|
|
logItem.ContractRegisterId = ob.ContractRegisterId
|
|
|
logItem.AdminId = int(adminInfo.AdminId)
|
|
|
- logItem.AdminName = adminInfo.AdminName
|
|
|
+ logItem.AdminName = adminInfo.RealName
|
|
|
logItem.OpData = opData
|
|
|
logItem.OpType = fms.ContractRegisterOpTypeSave
|
|
|
logItem.CreateTime = nowTime
|
|
@@ -371,7 +371,7 @@ func (rg *RegisterController) Edit(c *gin.Context) {
|
|
|
logItem := new(fms.ContractRegisterLog)
|
|
|
logItem.ContractRegisterId = item.ContractRegisterId
|
|
|
logItem.AdminId = int(adminInfo.AdminId)
|
|
|
- logItem.AdminName = adminInfo.AdminName
|
|
|
+ logItem.AdminName = adminInfo.RealName
|
|
|
logItem.OpData = opData
|
|
|
logItem.OpType = fms.ContractRegisterOpTypeSave
|
|
|
logItem.CreateTime = nowTime
|
|
@@ -434,7 +434,7 @@ func (rg *RegisterController) Del(c *gin.Context) {
|
|
|
logItem := new(fms.ContractRegisterLog)
|
|
|
logItem.ContractRegisterId = req.ContractRegisterId
|
|
|
logItem.AdminId = int(adminInfo.AdminId)
|
|
|
- logItem.AdminName = adminInfo.AdminName
|
|
|
+ logItem.AdminName = adminInfo.RealName
|
|
|
logItem.OpData = opData
|
|
|
logItem.OpType = fms.ContractRegisterOpTypeDel
|
|
|
logItem.CreateTime = nowTime
|
|
@@ -572,7 +572,7 @@ func (rg *RegisterController) UpdateStatus(c *gin.Context) {
|
|
|
logItem := new(fms.ContractRegisterLog)
|
|
|
logItem.ContractRegisterId = req.ContractRegisterId
|
|
|
logItem.AdminId = int(adminInfo.AdminId)
|
|
|
- logItem.AdminName = adminInfo.AdminName
|
|
|
+ logItem.AdminName = adminInfo.RealName
|
|
|
logItem.OpData = opData
|
|
|
logItem.OpType = fms.ContractRegisterOpTypeStatus
|
|
|
logItem.CreateTime = nowTime
|
|
@@ -660,7 +660,7 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
logItem := new(fms.ContractRegisterLog)
|
|
|
logItem.ContractRegisterId = req.ContractRegisterId
|
|
|
logItem.AdminId = int(adminInfo.AdminId)
|
|
|
- logItem.AdminName = adminInfo.AdminName
|
|
|
+ logItem.AdminName = adminInfo.RealName
|
|
|
logItem.OpData = opData
|
|
|
logItem.OpType = opType
|
|
|
logItem.CreateTime = time.Now().Local()
|
|
@@ -671,8 +671,78 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
resp.Ok("操作成功", c)
|
|
|
}
|
|
|
|
|
|
-// 导出
|
|
|
+// Export
|
|
|
+// @Title 合同登记-导出
|
|
|
+// @Description 合同登记-导出
|
|
|
+// @Param Keyword query string false "关键词"
|
|
|
+// @Param StartDate query string false "合同开始日期"
|
|
|
+// @Param EndDate query string false "合同结束日期"
|
|
|
+// @Param ServiceType query int false "套餐类型"
|
|
|
+// @Param ContractType query int false "合同类型"
|
|
|
+// @Param RegisterStatus query int false "登记状态"
|
|
|
+// @Success 200 string "操作成功"
|
|
|
+// @router /contract/register/export [get]
|
|
|
func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
+ var req fms.ContractRegisterListReq
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ cond := `1 = 1`
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+ if req.Keyword != "" {
|
|
|
+ kw := "%" + req.Keyword + "%"
|
|
|
+ cond += ` AND (company_name LIKE ? OR contract_code LIKE ? OR seller_name LIKE ?)`
|
|
|
+ pars = append(pars, kw, kw, kw)
|
|
|
+ }
|
|
|
+ if req.StartDate != "" && req.EndDate != "" {
|
|
|
+ cond += ` AND (create_time BETWEEN ? AND ?)`
|
|
|
+ pars = append(pars, req.StartDate, req.EndDate)
|
|
|
+ }
|
|
|
+ if req.ContractType != 0 {
|
|
|
+ cond += ` AND contract_type = ?`
|
|
|
+ pars = append(pars, req.ContractType)
|
|
|
+ }
|
|
|
+ if req.RegisterStatus != 0 {
|
|
|
+ cond += ` AND register_status = ?`
|
|
|
+ pars = append(pars, req.RegisterStatus)
|
|
|
+ }
|
|
|
+ if req.ServiceType != 0 {
|
|
|
+ registerIds, e := fms.GetContractRegisterIdsByTempId(req.ServiceType)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("获取失败", "获取合同登记IDs失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(registerIds) > 0 {
|
|
|
+ cond += ` AND contract_register_id IN ?`
|
|
|
+ pars = append(pars, registerIds)
|
|
|
+ } else {
|
|
|
+ cond += ` AND 1 = 2`
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取列表数据
|
|
|
+ cr := new(fms.ContractRegister)
|
|
|
+ list, e := cr.List(cond, pars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailData("获取合同列表失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(list) == 0 {
|
|
|
+ resp.Fail("无有效数据可导出", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ registerIds := make([]int, 0)
|
|
|
+ for i := range list {
|
|
|
+ registerIds = append(registerIds, list[i].ContractRegisterId)
|
|
|
+ }
|
|
|
+
|
|
|
// 获取小套餐品种
|
|
|
cpCond := `product_id = ? AND permission_name <> ?`
|
|
|
cpPars := make([]interface{}, 0)
|
|
@@ -696,20 +766,6 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
// return
|
|
|
//}
|
|
|
|
|
|
- // 获取列表数据
|
|
|
- cond := ``
|
|
|
- pars := make([]interface{}, 0)
|
|
|
- cr := new(fms.ContractRegister)
|
|
|
- list, e := cr.List(cond, pars)
|
|
|
- if e != nil {
|
|
|
- resp.FailData("获取合同列表失败", "Err:"+e.Error(), c)
|
|
|
- return
|
|
|
- }
|
|
|
- registerIds := make([]int, 0)
|
|
|
- for i := range list {
|
|
|
- registerIds = append(registerIds, list[i].ContractRegisterId)
|
|
|
- }
|
|
|
-
|
|
|
// 套餐/开票/到款列表
|
|
|
serviceMap := make(map[int][]*fms.ContractService)
|
|
|
serviceChartPermissionsMap := make(map[int][]int)
|
|
@@ -983,7 +1039,6 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 输出文件
|
|
|
var buffer bytes.Buffer
|
|
|
_ = xlsxFile.Write(&buffer)
|