|
@@ -1636,33 +1636,6 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- //如果是开票,强制修改到款记录的销售
|
|
|
- if len(newInvoice) > 0 && req.InvoiceType == fms.ContractInvoiceTypeMake {
|
|
|
- invoiceItem, err := fms.GetContractInvoiceByRegisterIdAndType(req.ContractRegisterId)
|
|
|
- if err != nil && err != utils.ErrNoRow {
|
|
|
- resp.FailMsg("获取到款数据失败", "获取到款数据失败, Err: "+err.Error(), c)
|
|
|
- return
|
|
|
- }
|
|
|
- if err == nil {
|
|
|
- sellerItem := sellerMap[newInvoice[0].SellerId]
|
|
|
- if sellerItem == nil {
|
|
|
- resp.Fail("销售信息异常", c)
|
|
|
- return
|
|
|
- }
|
|
|
- invoiceItem.SellerId = sellerItem.SellerId
|
|
|
- invoiceItem.SellerName = sellerItem.SellerName
|
|
|
- invoiceItem.SellerGroupId = sellerItem.GroupId
|
|
|
- invoiceItem.SellerGroupName = sellerItem.GroupName
|
|
|
- invoiceItem.SellerTeamId = sellerItem.TeamId
|
|
|
- invoiceItem.SellerTeamName = sellerItem.TeamName
|
|
|
- e = invoiceItem.Update([]string{"SellerId", "SellerName", "SellerGroupId", "SellerGroupName", "SellerTeamId", "SellerTeamName"})
|
|
|
- if e != nil {
|
|
|
- resp.FailMsg("更新到款销售失败", "更新到款销售失败, Err: "+e.Error(), c)
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// todo 判断是否符合均分金额的条件,如果符合,需要生成金额分配记录表
|
|
|
if req.InvoiceType == fms.ContractInvoiceTypePay {
|
|
|
err = fmsService.CalculatePaymentServiceAmount(req.ContractRegisterId)
|
|
@@ -1676,7 +1649,38 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
go fmsService.CheckContractRegisterAmount(req.ContractRegisterId)
|
|
|
|
|
|
// 开票到款汇总
|
|
|
- go fmsService.SummaryInvoicePaymentByContractRegisterId(req.ContractRegisterId)
|
|
|
+ fmsService.SummaryInvoicePaymentByContractRegisterId(req.ContractRegisterId)
|
|
|
+
|
|
|
+ //如果是开票,强制修改到款记录的销售
|
|
|
+ if len(newInvoice) > 0 && req.InvoiceType == fms.ContractInvoiceTypeMake {
|
|
|
+ for _, invoice := range newInvoice {
|
|
|
+ summaryItem, err := fms.GetInvoicePaymentSummaryByRegisterIdAndInvoiceId(req.ContractRegisterId, invoice.ContractInvoiceId)
|
|
|
+ if err != nil {
|
|
|
+ resp.FailMsg("获取汇总数据失败", "修改到款销售时获取汇总数据失败, Err: "+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sellerItem := sellerMap[invoice.SellerId]
|
|
|
+ if sellerItem == nil {
|
|
|
+ resp.Fail("销售信息异常", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if summaryItem.PaymentId > 0 {
|
|
|
+ paymentItem := fms.ContractInvoice{}
|
|
|
+ paymentItem.ContractInvoiceId = summaryItem.PaymentId
|
|
|
+ paymentItem.SellerId = sellerItem.SellerId
|
|
|
+ paymentItem.SellerName = sellerItem.SellerName
|
|
|
+ paymentItem.SellerGroupId = sellerItem.GroupId
|
|
|
+ paymentItem.SellerGroupName = sellerItem.GroupName
|
|
|
+ paymentItem.SellerTeamId = sellerItem.TeamId
|
|
|
+ paymentItem.SellerTeamName = sellerItem.TeamName
|
|
|
+ e = paymentItem.Update([]string{"SellerId", "SellerName", "SellerGroupId", "SellerGroupName", "SellerTeamId", "SellerTeamName"})
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("更新到款销售失败", "更新到款销售失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 操作日志
|
|
|
go func() {
|