|
@@ -0,0 +1,573 @@
|
|
|
|
+package contract
|
|
|
|
+
|
|
|
|
+import (
|
|
|
|
+ "fmt"
|
|
|
|
+ "github.com/gin-gonic/gin"
|
|
|
|
+ "github.com/go-playground/validator/v10"
|
|
|
|
+ "hongze/fms_api/controller/resp"
|
|
|
|
+ "hongze/fms_api/global"
|
|
|
|
+ "hongze/fms_api/models/base"
|
|
|
|
+ "hongze/fms_api/models/crm"
|
|
|
|
+ "hongze/fms_api/models/fms"
|
|
|
|
+ "hongze/fms_api/models/system"
|
|
|
|
+ crmService "hongze/fms_api/services/crm"
|
|
|
|
+ fmsService "hongze/fms_api/services/fms"
|
|
|
|
+ "hongze/fms_api/utils"
|
|
|
|
+ "strconv"
|
|
|
|
+ "strings"
|
|
|
|
+ "time"
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+type PreRegisterController struct{}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+func (rg *PreRegisterController) List(c *gin.Context) {
|
|
|
|
+ var req fms.PreRegisterListReq
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+ pageSize := req.PageSize
|
|
|
|
+ pageIndex := req.Current
|
|
|
|
+ if pageSize <= 0 {
|
|
|
|
+ pageSize = utils.PageSize20
|
|
|
|
+ }
|
|
|
|
+ if pageIndex <= 0 {
|
|
|
|
+ pageIndex = 1
|
|
|
|
+ }
|
|
|
|
+ cond := ` invoice_type IN (3, 4) `
|
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
|
+ if req.Keyword != "" {
|
|
|
|
+ kw := "%" + req.Keyword + "%"
|
|
|
|
+ cond += ` AND company_name LIKE ? `
|
|
|
|
+ pars = append(pars, kw)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ currencyOB := new(fms.CurrencyUnit)
|
|
|
|
+ currencyCond := `enable = 1`
|
|
|
|
+ currencyPars := make([]interface{}, 0)
|
|
|
|
+ currencyList, e := currencyOB.List(currencyCond, currencyPars)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("获取失败", "获取货币列表失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ unitMap := make(map[string]string)
|
|
|
|
+ for i := range currencyList {
|
|
|
|
+ unitMap[currencyList[i].Code] = currencyList[i].UnitName
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ page := new(base.Page)
|
|
|
|
+ page.SetPageSize(req.PageSize)
|
|
|
|
+ page.SetCurrent(req.Current)
|
|
|
|
+ sortTypeMap := map[int]bool{0: false, 1: true, 2: false}
|
|
|
|
+ page.AddOrderItem(base.OrderItem{Column: "create_time", Asc: sortTypeMap[0]})
|
|
|
|
+
|
|
|
|
+ total, list, e := fms.GetContractInvoiceItemPageList(page, cond, pars)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("获取失败", "获取预登记列表失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for i := range list {
|
|
|
|
+ list[i].UnitName = unitMap[list[i].CurrencyUnit]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ page.SetTotal(total)
|
|
|
|
+ baseData := new(base.BaseData)
|
|
|
|
+ baseData.SetPage(page)
|
|
|
|
+ baseData.SetList(list)
|
|
|
|
+ resp.OkData("获取成功", baseData, c)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+func (rg *PreRegisterController) Add(c *gin.Context) {
|
|
|
|
+ req := new(fms.PreRegisterAddReq)
|
|
|
|
+ err := c.ShouldBind(&req)
|
|
|
|
+ if err != nil {
|
|
|
|
+ errs, ok := err.(validator.ValidationErrors)
|
|
|
|
+ if !ok {
|
|
|
|
+ resp.FailData("参数解析失败", "Err:"+err.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ claims, _ := c.Get("adminInfo")
|
|
|
|
+ adminInfo := claims.(*system.SysAdmin)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var startDate, endDate time.Time
|
|
|
|
+ if req.StartDate != "" && req.EndDate != "" {
|
|
|
|
+ startDate, err = time.ParseInLocation(utils.FormatDate, req.StartDate, time.Local)
|
|
|
|
+ if err != nil {
|
|
|
|
+ resp.FailMsg("约定开始日期格式有误", "合同开始日期格式有误, Err: "+err.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ endDate, err = time.ParseInLocation(utils.FormatDate, req.EndDate, time.Local)
|
|
|
|
+ if err != nil {
|
|
|
|
+ resp.FailMsg("约定结束日期格式有误", "合同结束日期格式有误, Err: "+err.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ sellerList, e := crmService.GetSellerDepartmentListWithGroupAndTeam()
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailData("获取销售失败", "Err:"+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ sellerMap := make(map[int]*crm.SellerAdminWithGroupTeam)
|
|
|
|
+ for i := range sellerList {
|
|
|
|
+ sellerMap[sellerList[i].SellerId] = sellerList[i]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ob := new(fms.ContractRegister)
|
|
|
|
+
|
|
|
|
+ ob.CompanyName = req.CompanyName
|
|
|
|
+ ob.ProductIds = req.ProductIds
|
|
|
|
+ ob.StartDate = startDate
|
|
|
|
+ ob.EndDate = endDate
|
|
|
|
+ ob.Set()
|
|
|
|
+ if req.RegisterType == fms.ContractInvoiceTypePreMake {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for _, v := range sellers {
|
|
|
|
+ if v.DepartmentId == crm.SellerDepartmentId {
|
|
|
|
+ ob.SellerId = v.AdminId
|
|
|
|
+ ob.SellerName = v.AdminName
|
|
|
|
+ } else if v.DepartmentId == crm.RaiSellerDepartmentId {
|
|
|
|
+ ob.RaiSellerId = v.AdminId
|
|
|
|
+ ob.RaiSellerName = v.AdminName
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ serviceAmountMap := make(map[int]float64)
|
|
|
|
+ serviceList, e := fmsService.HandleContractServiceAndDetail(req.Services, true, serviceAmountMap)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("操作失败", "获取合同套餐详情失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if e = fms.CreateContractRegisterAndServicesAndPayMent(ob, serviceList); e != nil {
|
|
|
|
+ resp.FailMsg("操作失败", "新增合同及套餐失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, r := range req.List {
|
|
|
|
+
|
|
|
|
+ rateList, e := fmsService.GetTodayCurrencyRateList()
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("操作失败", "获取今日货币汇率失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var rate float64
|
|
|
|
+ for i := range rateList {
|
|
|
|
+ if r.CurrencyUnit == rateList[i].Code {
|
|
|
|
+ rate = rateList[i].RMBRate
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if rate <= 0 {
|
|
|
|
+ resp.FailMsg("操作失败", "货币汇率信息有误", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ registerDate, e := time.Parse(utils.FormatDate, r.RegisterDate)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("日期转换失败", "日期转换失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ v := &fms.ContractInvoice{
|
|
|
|
+ ContractRegisterId: ob.ContractRegisterId,
|
|
|
|
+ OriginAmount: r.Amount,
|
|
|
|
+ CurrencyUnit: r.CurrencyUnit,
|
|
|
|
+ InvoiceType: req.RegisterType,
|
|
|
|
+ InvoiceDate: registerDate,
|
|
|
|
+ AdminId: int(adminInfo.AdminId),
|
|
|
|
+ AdminName: adminInfo.AdminName,
|
|
|
|
+ Remark: r.Remark,
|
|
|
|
+ ServiceProductId: r.ServiceProductId,
|
|
|
|
+ IsPrePay: 1,
|
|
|
|
+ StartDate: startDate,
|
|
|
|
+ EndDate: endDate,
|
|
|
|
+ TimeBase: base.TimeBase{},
|
|
|
|
+ }
|
|
|
|
+ v.Set()
|
|
|
|
+
|
|
|
|
+ a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", v.OriginAmount/rate), 64)
|
|
|
|
+ v.Amount = a
|
|
|
|
+
|
|
|
|
+ if req.RegisterType == fms.ContractInvoiceTypePreMake {
|
|
|
|
+ sellerItem := sellerMap[r.SellerId]
|
|
|
|
+ if sellerItem == nil {
|
|
|
|
+ resp.Fail("销售信息异常", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ v.SellerId = sellerItem.SellerId
|
|
|
|
+ v.SellerName = sellerItem.SellerName
|
|
|
|
+ v.SellerGroupId = sellerItem.GroupId
|
|
|
|
+ v.SellerGroupName = sellerItem.GroupName
|
|
|
|
+ v.SellerTeamId = sellerItem.TeamId
|
|
|
|
+ v.SellerTeamName = sellerItem.TeamName
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if e = v.Create(); e != nil {
|
|
|
|
+ resp.FailMsg("操作失败", "新增预登记失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ go fmsService.SummaryInvoicePaymentByContractRegisterId(ob.ContractRegisterId)
|
|
|
|
+
|
|
|
|
+ resp.Ok("操作成功", c)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+func (rg *PreRegisterController) Edit(c *gin.Context) {
|
|
|
|
+ req := new(fms.PreRegisterEditReq)
|
|
|
|
+ err := c.ShouldBind(&req)
|
|
|
|
+ if err != nil {
|
|
|
|
+ errs, ok := err.(validator.ValidationErrors)
|
|
|
|
+ if !ok {
|
|
|
|
+ resp.FailData("参数解析失败", "Err:"+err.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ claims, _ := c.Get("adminInfo")
|
|
|
|
+ adminInfo := claims.(*system.SysAdmin)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var startDate, endDate time.Time
|
|
|
|
+ if req.StartDate != "" && req.EndDate != "" {
|
|
|
|
+ startDate, err = time.ParseInLocation(utils.FormatDate, req.StartDate, time.Local)
|
|
|
|
+ if err != nil {
|
|
|
|
+ resp.FailMsg("约定开始日期格式有误", "合同开始日期格式有误, Err: "+err.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ endDate, err = time.ParseInLocation(utils.FormatDate, req.EndDate, time.Local)
|
|
|
|
+ if err != nil {
|
|
|
|
+ resp.FailMsg("约定结束日期格式有误", "合同结束日期格式有误, Err: "+err.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ sellerList, e := crmService.GetSellerDepartmentListWithGroupAndTeam()
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailData("获取销售失败", "Err:"+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ sellerMap := make(map[int]*crm.SellerAdminWithGroupTeam)
|
|
|
|
+ for i := range sellerList {
|
|
|
|
+ sellerMap[sellerList[i].SellerId] = sellerList[i]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ob := new(fms.ContractRegister)
|
|
|
|
+
|
|
|
|
+ ob.ContractRegisterId = req.ContractRegisterId
|
|
|
|
+ ob.CompanyName = req.CompanyName
|
|
|
|
+ ob.ProductIds = req.ProductIds
|
|
|
|
+ ob.StartDate = startDate
|
|
|
|
+ ob.EndDate = endDate
|
|
|
|
+ ob.ModifyTime = time.Now().Local()
|
|
|
|
+ if req.RegisterType == fms.ContractInvoiceTypePreMake {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for _, v := range sellers {
|
|
|
|
+ if v.DepartmentId == crm.SellerDepartmentId {
|
|
|
|
+ ob.SellerId = v.AdminId
|
|
|
|
+ ob.SellerName = v.AdminName
|
|
|
|
+ } else if v.DepartmentId == crm.RaiSellerDepartmentId {
|
|
|
|
+ ob.RaiSellerId = v.AdminId
|
|
|
|
+ ob.RaiSellerName = v.AdminName
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ serviceAmountMap := make(map[int]float64)
|
|
|
|
+ serviceList, e := fmsService.HandleContractServiceAndDetail(req.Services, true, serviceAmountMap)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("操作失败", "获取合同套餐详情失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ updateCols := []string{
|
|
|
|
+ "ProductIds", "CompanyName", "SellerId", "SellerName", "StartDate", "EndDate",
|
|
|
|
+ "RaiSellerId", "RaiSellerName", "ModifyTime",
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ invoiceList := make([]*fms.ContractInvoice, 0)
|
|
|
|
+ for _, r := range req.List {
|
|
|
|
+
|
|
|
|
+ rateList, e := fmsService.GetTodayCurrencyRateList()
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("操作失败", "获取今日货币汇率失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var rate float64
|
|
|
|
+ for i := range rateList {
|
|
|
|
+ if r.CurrencyUnit == rateList[i].Code {
|
|
|
|
+ rate = rateList[i].RMBRate
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if rate <= 0 {
|
|
|
|
+ resp.FailMsg("操作失败", "货币汇率信息有误", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ registerDate, e := time.Parse(utils.FormatDate, r.RegisterDate)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("日期转换失败", "日期转换失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ v := &fms.ContractInvoice{
|
|
|
|
+ ContractInvoiceId: r.InvoiceId,
|
|
|
|
+ ContractRegisterId: ob.ContractRegisterId,
|
|
|
|
+ OriginAmount: r.Amount,
|
|
|
|
+ CurrencyUnit: r.CurrencyUnit,
|
|
|
|
+ InvoiceType: req.RegisterType,
|
|
|
|
+ InvoiceDate: registerDate,
|
|
|
|
+ AdminId: int(adminInfo.AdminId),
|
|
|
|
+ AdminName: adminInfo.AdminName,
|
|
|
|
+ Remark: r.Remark,
|
|
|
|
+ ServiceProductId: r.ServiceProductId,
|
|
|
|
+ IsPrePay: 1,
|
|
|
|
+ StartDate: startDate,
|
|
|
|
+ EndDate: endDate,
|
|
|
|
+ }
|
|
|
|
+ v.TimeBase.ModifyTime = time.Now().Local()
|
|
|
|
+
|
|
|
|
+ a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", v.OriginAmount/rate), 64)
|
|
|
|
+ v.Amount = a
|
|
|
|
+
|
|
|
|
+ if req.RegisterType == fms.ContractInvoiceTypePreMake {
|
|
|
|
+ sellerItem := sellerMap[r.SellerId]
|
|
|
|
+ if sellerItem == nil {
|
|
|
|
+ resp.Fail("销售信息异常", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ v.SellerId = sellerItem.SellerId
|
|
|
|
+ v.SellerName = sellerItem.SellerName
|
|
|
|
+ v.SellerGroupId = sellerItem.GroupId
|
|
|
|
+ v.SellerGroupName = sellerItem.GroupName
|
|
|
|
+ v.SellerTeamId = sellerItem.TeamId
|
|
|
|
+ v.SellerTeamName = sellerItem.TeamName
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ invoiceList = append(invoiceList, v)
|
|
|
|
+ }
|
|
|
|
+ invoiceUpdateCols := []string{
|
|
|
|
+ "CurrencyUnit", "Amount", "InvoiceDate", "AdminId", "AdminName", "Remark",
|
|
|
|
+ "ServiceProductId", "StartDate", "EndDate", "ModifyTime",
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if e = fms.UpdateContractPreRegister(ob, updateCols, serviceList, invoiceList, invoiceUpdateCols); e != nil {
|
|
|
|
+ resp.FailMsg("操作失败", "更新合同及套餐失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ go fmsService.SummaryInvoicePaymentByContractRegisterId(ob.ContractRegisterId)
|
|
|
|
+
|
|
|
|
+ resp.Ok("操作成功", c)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+func (rg *PreRegisterController) Del(c *gin.Context) {
|
|
|
|
+ req := new(fms.PreRegisterDelReq)
|
|
|
|
+ err := c.ShouldBind(&req)
|
|
|
|
+ if err != nil {
|
|
|
|
+ errs, ok := err.(validator.ValidationErrors)
|
|
|
|
+ if !ok {
|
|
|
|
+ resp.FailData("参数解析失败", "Err:"+err.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ resp.Ok("操作成功", c)
|
|
|
|
+}
|