|
@@ -145,6 +145,10 @@ func (rg *PreRegisterController) Add(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ var currencyUnit string
|
|
|
+ if len(req.List) > 0{
|
|
|
+ currencyUnit = req.List[0].CurrencyUnit
|
|
|
+ }
|
|
|
// 获取销售分组信息
|
|
|
sellerList, e := crmService.GetSellerDepartmentListWithGroupAndTeam()
|
|
|
if e != nil {
|
|
@@ -184,6 +188,7 @@ func (rg *PreRegisterController) Add(c *gin.Context) {
|
|
|
ob.StartDate = startDate
|
|
|
ob.EndDate = endDate
|
|
|
ob.Set()
|
|
|
+ ob.CurrencyUnit = currencyUnit
|
|
|
if req.RegisterType == fms.ContractInvoiceTypePreMake {
|
|
|
//sellerItem := sellerMap[r.SellerId]
|
|
|
//if sellerItem == nil {
|
|
@@ -284,10 +289,8 @@ func (rg *PreRegisterController) Add(c *gin.Context) {
|
|
|
ContractRegisterId: ob.ContractRegisterId,
|
|
|
CompanyName: req.CompanyName,
|
|
|
InvoiceType: req.RegisterType,
|
|
|
- InvoiceDate: registerDate,
|
|
|
AdminId: int(adminInfo.AdminId),
|
|
|
AdminName: adminInfo.AdminName,
|
|
|
- Remark: r.Remark,
|
|
|
ServiceProductId: r.ServiceProductId,
|
|
|
IsPrePay: 1,
|
|
|
StartDate: startDate,
|
|
@@ -303,7 +306,7 @@ func (rg *PreRegisterController) Add(c *gin.Context) {
|
|
|
pp.OriginAmount = r.Amount
|
|
|
a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", pp.OriginAmount/rate), 64)
|
|
|
pp.Amount = a
|
|
|
-
|
|
|
+ pp.Remark = r.Remark
|
|
|
sellerItem := sellerMap[r.SellerId]
|
|
|
if sellerItem == nil {
|
|
|
resp.Fail("销售信息异常", c)
|
|
@@ -323,6 +326,7 @@ func (rg *PreRegisterController) Add(c *gin.Context) {
|
|
|
pp.ArriveOriginAmount = r.Amount
|
|
|
a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", pp.ArriveOriginAmount/rate), 64)
|
|
|
pp.ArriveAmount = a
|
|
|
+ pp.ArriveRemark = r.Remark
|
|
|
}
|
|
|
|
|
|
// 新增开票到款记录
|
|
@@ -330,6 +334,12 @@ func (rg *PreRegisterController) Add(c *gin.Context) {
|
|
|
resp.FailMsg("操作失败", "新增预登记失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ v.PreRegisterId = pp.PreRegisterId
|
|
|
+ if e = v.Update([]string{"PreRegisterId"}); e != nil {
|
|
|
+ fmt.Println("更新开票登记失败, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 开票到款汇总
|
|
@@ -374,6 +384,12 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ var currencyUnit string
|
|
|
+ if len(req.List) > 0{
|
|
|
+ currencyUnit = req.List[0].CurrencyUnit
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 获取销售分组信息
|
|
|
sellerList, e := crmService.GetSellerDepartmentListWithGroupAndTeam()
|
|
|
if e != nil {
|
|
@@ -413,6 +429,7 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
|
|
|
ob.StartDate = startDate
|
|
|
ob.EndDate = endDate
|
|
|
ob.ModifyTime = time.Now().Local()
|
|
|
+ ob.CurrencyUnit = currencyUnit
|
|
|
if req.RegisterType == fms.ContractInvoiceTypePreMake {
|
|
|
//sellerItem := sellerMap[r.SellerId]
|
|
|
//if sellerItem == nil {
|
|
@@ -439,11 +456,10 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
|
|
|
}
|
|
|
updateCols := []string{
|
|
|
"ProductIds", "CompanyName", "SellerId", "SellerName", "StartDate", "EndDate",
|
|
|
- "RaiSellerId", "RaiSellerName", "ModifyTime",
|
|
|
+ "RaiSellerId", "RaiSellerName", "ModifyTime","CurrencyUnit",
|
|
|
}
|
|
|
|
|
|
invoiceList := make([]*fms.ContractInvoice, 0)
|
|
|
- ppList := make([]*fms.ContractPreRegister, 0)
|
|
|
for _, r := range req.List {
|
|
|
// 货币及汇率
|
|
|
rateList, e := fmsService.GetTodayCurrencyRateList()
|
|
@@ -504,17 +520,14 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
|
|
|
v.SellerTeamName = sellerItem.TeamName
|
|
|
}
|
|
|
|
|
|
- invoiceList = append(invoiceList, v)
|
|
|
-
|
|
|
//预登记列表
|
|
|
pp := &fms.ContractPreRegister{
|
|
|
- PreRegisterId: req.PreRegisterId,
|
|
|
+ PreRegisterId: r.PreRegisterId,
|
|
|
ContractRegisterId: ob.ContractRegisterId,
|
|
|
CompanyName: req.CompanyName,
|
|
|
InvoiceType: req.RegisterType,
|
|
|
AdminId: int(adminInfo.AdminId),
|
|
|
AdminName: adminInfo.AdminName,
|
|
|
- Remark: r.Remark,
|
|
|
ServiceProductId: r.ServiceProductId,
|
|
|
IsPrePay: 1,
|
|
|
StartDate: startDate,
|
|
@@ -526,6 +539,7 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
|
|
|
ppUpdateCols := make([]string, 0)
|
|
|
if pp.InvoiceType == fms.ContractInvoiceTypePreMake {
|
|
|
//开票走开票字段
|
|
|
+ pp.Remark = r.Remark
|
|
|
pp.InvoiceDate = registerDate
|
|
|
pp.OriginAmount = r.Amount
|
|
|
a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", pp.OriginAmount/rate), 64)
|
|
@@ -547,27 +561,38 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
|
|
|
"SellerName", "SellerGroupId", "SellerGroupName", "SellerTeamId", "SellerTeamName")
|
|
|
} else {
|
|
|
//到款
|
|
|
+ pp.ArriveRemark = r.Remark
|
|
|
pp.ArriveDate = registerDate
|
|
|
pp.ArriveOriginAmount = r.Amount
|
|
|
a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", pp.ArriveOriginAmount/rate), 64)
|
|
|
pp.ArriveAmount = a
|
|
|
ppUpdateCols = append(ppUpdateCols, "CurrencyUnit", "ArriveDate", "ArriveAmount", "ArriveOriginAmount")
|
|
|
}
|
|
|
- ppList = append(ppList, pp)
|
|
|
- ppUpdateCols = append(ppUpdateCols,
|
|
|
- "CurrencyUnit", "CompanyName", "AdminId", "AdminName", "Remark",
|
|
|
- "ServiceProductId", "CurrencyUnit", "StartDate", "EndDate", "ModifyTime")
|
|
|
- if e = pp.Update(ppUpdateCols); e != nil {
|
|
|
- resp.FailMsg("操作失败", "更新预登记记录失败, Err: "+e.Error(), c)
|
|
|
- return
|
|
|
+
|
|
|
+ if pp.PreRegisterId == 0 {
|
|
|
+ if e = pp.Create(); e != nil {
|
|
|
+ resp.FailMsg("操作失败", "新增预登记失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ v.PreRegisterId = pp.PreRegisterId
|
|
|
+ } else {
|
|
|
+ ppUpdateCols = append(ppUpdateCols,
|
|
|
+ "CurrencyUnit", "CompanyName", "Remark", "ArriveRemark","InvoiceTime","ArriveTime",
|
|
|
+ "ServiceProductId", "CurrencyUnit", "StartDate", "EndDate", "ModifyTime")
|
|
|
+ if e = pp.Update(ppUpdateCols); e != nil {
|
|
|
+ resp.FailMsg("操作失败", "更新预登记记录失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ invoiceList = append(invoiceList, v)
|
|
|
}
|
|
|
invoiceUpdateCols := []string{
|
|
|
- "CurrencyUnit", "Amount", "InvoiceDate", "AdminId", "AdminName", "Remark",
|
|
|
+ "CurrencyUnit", "OriginAmount", "Amount", "InvoiceDate", "AdminId", "AdminName", "Remark",
|
|
|
"ServiceProductId", "StartDate", "EndDate", "ModifyTime",
|
|
|
}
|
|
|
// 更新合同登记、套餐、开票到款
|
|
|
- if e = fms.UpdateContractPreRegister(ob, updateCols, serviceList, invoiceList, invoiceUpdateCols); e != nil {
|
|
|
+ if e = fms.UpdateContractPreRegister(ob, updateCols, serviceList, invoiceList, invoiceUpdateCols, req.DelInvoiceIds, req.DelPreRegisterIds); e != nil {
|
|
|
resp.FailMsg("操作失败", "更新合同及套餐失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
@@ -1006,7 +1031,6 @@ func (rg *PreRegisterController) Save(c *gin.Context) {
|
|
|
InvoiceDate: registerDate,
|
|
|
AdminId: int(adminInfo.AdminId),
|
|
|
AdminName: adminInfo.AdminName,
|
|
|
- Remark: r.Remark,
|
|
|
ServiceProductId: r.ServiceProductId,
|
|
|
IsPrePay: 1,
|
|
|
StartDate: startDate,
|
|
@@ -1017,6 +1041,7 @@ func (rg *PreRegisterController) Save(c *gin.Context) {
|
|
|
pp.CurrencyUnit = r.CurrencyUnit
|
|
|
if pp.InvoiceType == fms.ContractInvoiceTypePreMake {
|
|
|
//开票走开票字段
|
|
|
+ pp.Remark = r.Remark
|
|
|
pp.InvoiceId = v.ContractInvoiceId
|
|
|
pp.InvoiceDate = registerDate
|
|
|
pp.OriginAmount = r.Amount
|
|
@@ -1039,6 +1064,7 @@ func (rg *PreRegisterController) Save(c *gin.Context) {
|
|
|
"SellerName", "SellerGroupId", "SellerGroupName", "SellerTeamId", "SellerTeamName")
|
|
|
} else {
|
|
|
//到款
|
|
|
+ pp.ArriveRemark = r.Remark
|
|
|
pp.ArriveDate = registerDate
|
|
|
pp.ArriveOriginAmount = r.Amount
|
|
|
a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", pp.ArriveOriginAmount/rate), 64)
|