|
@@ -15,6 +15,7 @@ import (
|
|
|
"hongze/fms_api/models/fms"
|
|
|
"hongze/fms_api/models/system"
|
|
|
"hongze/fms_api/services/alarm_msg"
|
|
|
+ crmService "hongze/fms_api/services/crm"
|
|
|
fmsService "hongze/fms_api/services/fms"
|
|
|
"hongze/fms_api/utils"
|
|
|
"net/http"
|
|
@@ -679,6 +680,17 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
noChangeInvoiceIds := make([]int, 0)
|
|
|
newInvoice := make([]*fms.ContractInvoice, 0)
|
|
|
if len(req.AmountList) > 0 {
|
|
|
+ // 获取销售分组信息
|
|
|
+ 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]
|
|
|
+ }
|
|
|
+
|
|
|
for i := range req.AmountList {
|
|
|
if req.AmountList[i].Amount <= 0 {
|
|
|
resp.Fail("登记金额有误", c)
|
|
@@ -688,6 +700,11 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
resp.Fail("请选择日期", c)
|
|
|
return
|
|
|
}
|
|
|
+ // 开票登记销售必填
|
|
|
+ if req.InvoiceType == fms.ContractInvoiceTypeMake && req.AmountList[i].SellerId <= 0 {
|
|
|
+ resp.Fail("请选择销售", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
t, e := time.ParseInLocation(utils.FormatDate, req.AmountList[i].InvoiceDate, time.Local)
|
|
|
if e != nil {
|
|
|
resp.FailData("日期格式有误", "Err:"+e.Error(), c)
|
|
@@ -695,7 +712,8 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
}
|
|
|
if req.AmountList[i].InvoiceId > 0 {
|
|
|
noChangeInvoiceIds = append(noChangeInvoiceIds, req.AmountList[i].InvoiceId)
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ if req.AmountList[i].InvoiceId == 0 {
|
|
|
v := &fms.ContractInvoice{
|
|
|
ContractRegisterId: req.ContractRegisterId,
|
|
|
ContractCode: item.ContractCode,
|
|
@@ -707,6 +725,18 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
Remark: req.AmountList[i].Remark,
|
|
|
}
|
|
|
v.Set()
|
|
|
+ // 销售信息
|
|
|
+ if req.InvoiceType == fms.ContractInvoiceTypeMake {
|
|
|
+ sellerItem := sellerMap[req.AmountList[i].SellerId]
|
|
|
+ if sellerItem == nil {
|
|
|
+ resp.Fail("销售信息异常", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ v.SellerId = sellerItem.SellerId
|
|
|
+ v.SellerName = sellerItem.SellerName
|
|
|
+ v.SellerGroupId = sellerItem.GroupId
|
|
|
+ v.SellerTeamId = sellerItem.TeamId
|
|
|
+ }
|
|
|
newInvoice = append(newInvoice, v)
|
|
|
}
|
|
|
}
|