|
@@ -232,6 +232,39 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 查询销售信息
|
|
|
+ var (
|
|
|
+ sellerId int
|
|
|
+ raiSellerId int
|
|
|
+ sellerName string
|
|
|
+ raiSellerName string
|
|
|
+ )
|
|
|
+
|
|
|
+ if req.SellerIds != "" {
|
|
|
+ admin := new(crm.Admin)
|
|
|
+ sellerIds := strings.Split(req.SellerIds, ",")
|
|
|
+ if len(sellerIds) > 2 {
|
|
|
+ resp.Fail("最多只能选择两个销售", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var pars []interface{}
|
|
|
+ cond := ` admin_id in (?) `
|
|
|
+ pars = append(pars, sellerIds)
|
|
|
+ sellers, e := admin.List(cond, pars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("获取销售信息失败", "获取销售信息失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range sellers {
|
|
|
+ if v.DepartmentId == crm.SellerDepartmentId {
|
|
|
+ sellerId = v.AdminId
|
|
|
+ sellerName = v.AdminName
|
|
|
+ }else if v.DepartmentId == crm.RaiSellerDepartmentId {
|
|
|
+ raiSellerId = v.AdminId
|
|
|
+ raiSellerName = v.AdminName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
nowTime := time.Now().Local()
|
|
|
ob.ContractCode = req.ContractCode
|
|
|
ob.RelateContractCode = req.RelateContractCode
|
|
@@ -240,10 +273,10 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
ob.CompanyName = req.CompanyName
|
|
|
ob.ActualCompanyName = req.ActualCompanyName
|
|
|
ob.ProductIds = req.ProductIds
|
|
|
- ob.SellerId = req.SellerId
|
|
|
- ob.SellerName = req.SellerName
|
|
|
- ob.RaiSellerId = req.RaiSellerId
|
|
|
- ob.RaiSellerName = req.RaiSellerName
|
|
|
+ ob.SellerId = sellerId
|
|
|
+ ob.SellerName = sellerName
|
|
|
+ ob.RaiSellerId = raiSellerId
|
|
|
+ ob.RaiSellerName = raiSellerName
|
|
|
ob.ContractType = req.ContractType
|
|
|
ob.ContractAmount = req.ContractAmount
|
|
|
ob.CurrencyUnit = req.CurrencyUnit
|
|
@@ -463,6 +496,41 @@ func (rg *RegisterController) Edit(c *gin.Context) {
|
|
|
resp.FailMsg("操作失败", "获取合同登记信息失败, Err:"+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ // 查询销售信息
|
|
|
+ var (
|
|
|
+ sellerId int
|
|
|
+ raiSellerId int
|
|
|
+ sellerName string
|
|
|
+ raiSellerName string
|
|
|
+ )
|
|
|
+
|
|
|
+ if req.SellerIds != "" {
|
|
|
+ admin := new(crm.Admin)
|
|
|
+ sellerIds := strings.Split(req.SellerIds, ",")
|
|
|
+ if len(sellerIds) > 2 {
|
|
|
+ resp.Fail("最多只能选择两个销售", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var pars []interface{}
|
|
|
+ cond := ` admin_id in (?) `
|
|
|
+ pars = append(pars, sellerIds)
|
|
|
+ sellers, e := admin.List(cond, pars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("获取销售信息失败", "获取销售信息失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range sellers {
|
|
|
+ if v.DepartmentId == crm.SellerDepartmentId {
|
|
|
+ sellerId = v.AdminId
|
|
|
+ sellerName = v.AdminName
|
|
|
+ }else if v.DepartmentId == crm.RaiSellerDepartmentId {
|
|
|
+ raiSellerId = v.AdminId
|
|
|
+ raiSellerName = v.AdminName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 是否存在相同合同编号的登记
|
|
|
existCond := `contract_code = ?`
|
|
|
existPars := make([]interface{}, 0)
|
|
@@ -491,10 +559,10 @@ func (rg *RegisterController) Edit(c *gin.Context) {
|
|
|
item.ContractSource = req.ContractSource
|
|
|
item.CompanyName = req.CompanyName
|
|
|
item.ActualCompanyName = req.ActualCompanyName
|
|
|
- item.SellerId = req.SellerId
|
|
|
- item.SellerName = req.SellerName
|
|
|
- item.RaiSellerId = req.RaiSellerId
|
|
|
- item.RaiSellerName = req.RaiSellerName
|
|
|
+ item.SellerId = sellerId
|
|
|
+ item.SellerName = sellerName
|
|
|
+ item.RaiSellerId = raiSellerId
|
|
|
+ item.RaiSellerName = raiSellerName
|
|
|
item.ContractType = req.ContractType
|
|
|
item.ContractAmount = req.ContractAmount
|
|
|
item.StartDate = startDate
|
|
@@ -1826,7 +1894,7 @@ func ExportInvoiceList(c *gin.Context, req fms.ContractInvoiceListReq, results *
|
|
|
sheet.AddRow()
|
|
|
|
|
|
// 列表数据表头
|
|
|
- titles := []string{"合同编号", fmt.Sprintf("%s金额", listName), "金额单位", "换算金额(元)",
|
|
|
+ titles := []string{"合同编号", "套餐类型", fmt.Sprintf("%s金额", listName), "金额单位", "换算金额(元)",
|
|
|
fmt.Sprintf("%s日期", listName), "销售", "备注"}
|
|
|
titleRow := sheet.AddRow()
|
|
|
titleRow.SetHeight(40)
|
|
@@ -1835,12 +1903,16 @@ func ExportInvoiceList(c *gin.Context, req fms.ContractInvoiceListReq, results *
|
|
|
c.SetString(titles[i])
|
|
|
c.SetStyle(style)
|
|
|
}
|
|
|
-
|
|
|
+ ServiceTemplateStrMap := map[int]string{
|
|
|
+ crm.CompanyProductFicc: "FICC套餐",
|
|
|
+ crm.CompanyProductRai: "权益套餐",
|
|
|
+ }
|
|
|
// 单元格赋值
|
|
|
for _, v := range list {
|
|
|
dataRow := sheet.AddRow()
|
|
|
dataRow.SetHeight(20)
|
|
|
dataRow.AddCell().SetString(v.ContractCode) // 合同编号
|
|
|
+ dataRow.AddCell().SetString(ServiceTemplateStrMap[v.ServiceProductId]) // 套餐类型
|
|
|
dataRow.AddCell().SetString(fmt.Sprint(v.OriginAmount)) // 开票金额
|
|
|
dataRow.AddCell().SetString(v.UnitName) // 金额单位
|
|
|
dataRow.AddCell().SetString(fmt.Sprint(v.Amount)) // 换算金额(元)
|