|
@@ -175,8 +175,6 @@ func (rg *PreRegisterController) Add(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
//新增合同
|
|
|
ob := new(fms.ContractRegister)
|
|
@@ -568,7 +566,6 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
|
|
|
resp.Ok("操作成功", c)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// Del
|
|
|
// @Title 删除到款预登记
|
|
|
// @Description 删除到款预登记
|
|
@@ -588,42 +585,59 @@ func (rg *PreRegisterController) Del(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- ob := new(fms.ContractInvoice)
|
|
|
- item, e := ob.Fetch(req.InvoiceId)
|
|
|
+ if req.InvoiceId != 0 {
|
|
|
+ ob := new(fms.ContractInvoice)
|
|
|
+ item, e := ob.Fetch(req.InvoiceId)
|
|
|
+ if e != nil {
|
|
|
+ if e == utils.ErrNoRow {
|
|
|
+ resp.Fail("合同登记不存在或已被删除", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailMsg("获取合同登记失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ e = item.Delete()
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("删除记录失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.ArriveId != 0 {
|
|
|
+ ob := new(fms.ContractInvoice)
|
|
|
+ item, e := ob.Fetch(req.ArriveId)
|
|
|
+ if e != nil {
|
|
|
+ if e == utils.ErrNoRow {
|
|
|
+ resp.Fail("合同登记不存在或已被删除", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailMsg("获取合同登记失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ e = item.Delete()
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("删除记录失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ob := new(fms.ContractPreRegister)
|
|
|
+ item, e := ob.Fetch(req.PreRegisterId)
|
|
|
if e != nil {
|
|
|
if e == utils.ErrNoRow {
|
|
|
- resp.Fail("合同登记不存在或已被删除", c)
|
|
|
+ resp.Fail("预登记记录不存在或已被删除", c)
|
|
|
return
|
|
|
}
|
|
|
- resp.FailMsg("获取合同登记失败", "Err:"+e.Error(), c)
|
|
|
+ resp.FailMsg("获取预登记失败", "Err:"+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
e = item.Delete()
|
|
|
if e != nil {
|
|
|
- resp.FailMsg("删除记录失败", "Err:"+e.Error(), c)
|
|
|
+ resp.FailMsg("删除预登记记录失败", "Err:"+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // 操作日志
|
|
|
- //go func() {
|
|
|
- // opData := ""
|
|
|
- // opDataByte, e := json.Marshal(req)
|
|
|
- // if e != nil {
|
|
|
- // return
|
|
|
- // }
|
|
|
- // opData = string(opDataByte)
|
|
|
- //
|
|
|
- // logItem := new(fms.ContractRegisterLog)
|
|
|
- // logItem.ContractRegisterId = req.ContractRegisterId
|
|
|
- // logItem.AdminId = int(adminInfo.AdminId)
|
|
|
- // logItem.AdminName = adminInfo.RealName
|
|
|
- // logItem.OpData = opData
|
|
|
- // logItem.OpType = fms.ContractRegisterOpTypeDel
|
|
|
- // logItem.CreateTime = nowTime
|
|
|
- // if e = logItem.Create(); e != nil {
|
|
|
- // return
|
|
|
- // }
|
|
|
- //}()
|
|
|
+ //todo 合同看情况要不要删
|
|
|
|
|
|
resp.Ok("操作成功", c)
|
|
|
}
|
|
@@ -658,18 +672,126 @@ func (rg *PreRegisterController) Detail(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ nItme := fms.ContractRegisterItem{
|
|
|
+ ContractRegisterId: item.ContractRegisterId,
|
|
|
+ ContractCode: item.ContractCode,
|
|
|
+ RelateContractCode: item.RelateContractCode,
|
|
|
+ CrmContractId: item.CrmContractId,
|
|
|
+ ContractSource: item.ContractSource,
|
|
|
+ CompanyName: item.CompanyName,
|
|
|
+ ActualCompanyName: item.ActualCompanyName,
|
|
|
+ ProductIds: item.ProductIds,
|
|
|
+ SellerId: item.SellerId,
|
|
|
+ SellerName: item.SellerName,
|
|
|
+ RaiSellerId: item.RaiSellerId,
|
|
|
+ RaiSellerName: item.RaiSellerName,
|
|
|
+ ContractType: item.ContractType,
|
|
|
+ ContractAmount: item.ContractAmount,
|
|
|
+ InvoicedAmount: item.InvoicedAmount,
|
|
|
+ PaymentAmount: item.PaymentAmount,
|
|
|
+ CurrencyUnit: item.CurrencyUnit,
|
|
|
+ RMBRate: item.RMBRate,
|
|
|
+ StartDate: item.StartDate.Format(utils.FormatDate),
|
|
|
+ EndDate: item.EndDate.Format(utils.FormatDate),
|
|
|
+ SignDate: item.SignDate.Format(utils.FormatDate),
|
|
|
+ AgreedPayTime: item.AgreedPayTime,
|
|
|
+ ContractStatus: item.ContractStatus,
|
|
|
+ RegisterStatus: item.RegisterStatus,
|
|
|
+ Remark: item.Remark,
|
|
|
+ ServiceRemark: item.ServiceRemark,
|
|
|
+ HasPayment: item.HasPayment,
|
|
|
+ NewCompany: item.NewCompany,
|
|
|
+ CreateTime: item.CreateTime.Format(utils.FormatDateTime),
|
|
|
+ }
|
|
|
+
|
|
|
cond := `contract_register_id = ? AND invoice_type = ? `
|
|
|
pars := make([]interface{}, 0)
|
|
|
pars = append(pars, req.ContractRegisterId, req.InvoiceType)
|
|
|
- list, e := fms.GetContractInvoiceItemList(cond, pars)
|
|
|
+ list, e := fms.GetContractInvoiceDetailItemList(cond, pars)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ //获取ficc小套餐品种
|
|
|
+ sysConf := new(system.SysConfig)
|
|
|
+ confCond := `config_code = ?`
|
|
|
+ confPars := make([]interface{}, 0)
|
|
|
+ confPars = append(confPars, system.ConfigKeyCrmPermissionFiccClassify)
|
|
|
+ confItem, e := sysConf.FetchByCondition(confCond, confPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailData("获取失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if confItem.ConfigValue == "" {
|
|
|
+ resp.FailData("获取失败", "FICC品种分类配置为空", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ classifyArr := strings.Split(confItem.ConfigValue, ",")
|
|
|
+ if len(classifyArr) == 0 {
|
|
|
+ resp.FailData("获取失败", "FICC品种分类配置为空", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 获取FICC权限
|
|
|
+ ficcCond := `enabled = 1 AND permission_type = 0 AND product_id = ? AND classify_name IN ?`
|
|
|
+ ficcPars := make([]interface{}, 0)
|
|
|
+ ficcPars = append(ficcPars, 1, classifyArr)
|
|
|
+ items, e := crm.GetPermissionSetItemsByCondition(ficcCond, ficcPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailData("获取失败", "获取FICC权限信息失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ficcItemMap := make(map[string][]*crm.PermissionSetItem, 0)
|
|
|
+ for i := range items {
|
|
|
+ if ficcItemMap[items[i].ClassifyName] == nil {
|
|
|
+ ficcItemMap[items[i].ClassifyName] = make([]*crm.PermissionSetItem, 0)
|
|
|
+ }
|
|
|
+ ficcItemMap[items[i].ClassifyName] = append(ficcItemMap[items[i].ClassifyName], items[i])
|
|
|
+ }
|
|
|
+
|
|
|
+ sTempIdMap := make(map[string]int, 0)
|
|
|
+
|
|
|
+ for i := range classifyArr {
|
|
|
+ if classifyArr[i] == "市场策略" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ checkList := make([]int, 0)
|
|
|
+ if classifyArr[i] == "宏观经济" {
|
|
|
+ checkList = append(checkList, 1)
|
|
|
+ }
|
|
|
+
|
|
|
+ pItem := fms.ContractServiceTemplateItem{
|
|
|
+ ServiceTemplateId: 90000 + i*100,
|
|
|
+ }
|
|
|
+
|
|
|
+ ficcItems := ficcItemMap[classifyArr[i]]
|
|
|
+ for _, ficcItem := range ficcItems {
|
|
|
+ sTempIdMap[strconv.Itoa(ficcItem.ChartPermissionId)] = pItem.ServiceTemplateId + ficcItem.ChartPermissionId
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ services, e := fms.GetContractServiceAndDetailList(req.ContractRegisterId)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf(fmt.Sprint("查找合同服务异常", e))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ serviceTemplateIdSlice := make([]string, 0)
|
|
|
+ for _, service := range services {
|
|
|
+ if service.Title == "FICC小套餐" {
|
|
|
+ serviceTemplateIdSlice = strings.Split(service.ChartPermissionIds,",")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ serviceTemplateIds := make([]int, 0)
|
|
|
+ for _, v := range serviceTemplateIdSlice {
|
|
|
+ serviceTemplateIds = append(serviceTemplateIds, sTempIdMap[v])
|
|
|
+ }
|
|
|
respItem := fms.ContractPreRegisterDetail{
|
|
|
- ContractRegister: item,
|
|
|
- List: list,
|
|
|
+ ContractRegisterItem: &nItme,
|
|
|
+ List: list,
|
|
|
+ Services: services,
|
|
|
+ ServiceTemplateIds: serviceTemplateIds,
|
|
|
}
|
|
|
|
|
|
resp.OkData("获取成功", respItem, c)
|