ziwen 2 years ago
parent
commit
44050c7990

+ 15 - 3
controller/contract/pre_payment.go

@@ -40,7 +40,7 @@ func (rg *PrePaymentController) List(c *gin.Context) {
 
 	cond := `1 = 1`
 	pars := make([]interface{}, 0)
-	// 合同编号/客户姓名/销售/实际使用方
+	// 客户姓名/销售
 	if req.Keyword != "" {
 		kw := "%" + req.Keyword + "%"
 		cond += ` AND (company_name LIKE ? OR seller_name LIKE ? )`
@@ -53,6 +53,19 @@ func (rg *PrePaymentController) List(c *gin.Context) {
 		pars = append(pars, st, ed)
 	}
 
+	// 货币列表
+	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)
@@ -65,9 +78,8 @@ func (rg *PrePaymentController) List(c *gin.Context) {
 		resp.FailMsg("获取失败", "获取预登记列表失败, Err: "+e.Error(), c)
 		return
 	}
-	registerIds := make([]int, 0)
 	for i := range list {
-		registerIds = append(registerIds, list[i].ContractRegisterId)
+		list[i].UnitName = unitMap[list[i].CurrencyUnit]
 	}
 
 	page.SetTotal(total)

+ 8 - 3
controller/contract/register.go

@@ -273,9 +273,14 @@ func (rg *RegisterController) Add(c *gin.Context) {
 	}
 
 	// 新增合同及套餐
-	if e = fms.CreateContractRegisterAndServices(ob, serviceList); e != nil {
-		resp.FailMsg("操作失败", "新增合同及套餐失败, Err: "+e.Error(), c)
-		return
+	if req.Supplement == 1 {
+		//TODO
+		//新增合同信息以及到款记录以及操作日志
+	}else {
+		if e = fms.CreateContractRegisterAndServices(ob, serviceList); e != nil {
+			resp.FailMsg("操作失败", "新增合同及套餐失败, Err: "+e.Error(), c)
+			return
+		}
 	}
 
 	// 操作日志

+ 1 - 1
models/fms/contract_invoice.go

@@ -144,7 +144,7 @@ func (c *ContractInvoice) DeleteAndCreateNewInvoice(contractRegisterId, invoiceT
 // ContractInvoiceSaveReq 合同开票-请求体
 type ContractInvoiceSaveReq struct {
 	ContractRegisterId int                        `json:"contract_register_id" binding:"required,gte=1" description:"登记ID"`
-	InvoiceType        int                        `json:"invoice_type" binding:"oneof=1 2" description:"类型: 1-开票登记; 2-到款登记"`
+	InvoiceType        int                        `json:"invoice_type" binding:"oneof=1 2 3" description:"类型: 1-开票登记; 2-到款登记; 3-预到款登记"`
 	AmountList         []*ContractInvoiceSaveItem `json:"amount_list"`
 }
 

+ 3 - 1
models/fms/contract_pre_payment.go

@@ -35,6 +35,7 @@ type ContractPrePaymentRespItem struct {
 	Amount             float64 `gorm:"column:amount" json:"amount" description:"换算后的金额(人民币)"`
 	OriginAmount       float64 `gorm:"column:origin_amount" json:"origin_amount" description:"到款金额"`
 	CurrencyUnit       string  `gorm:"column:currency_unit" json:"currency_unit" description:"货币国际代码"`
+	UnitName           string  `gorm:"unit_name" json:"unit_name" description:"单位名称"`
 	SellerId           int     `gorm:"column:seller_id" json:"seller_id" description:"销售ID"`
 	SellerName         string  `gorm:"column:seller_name" json:"seller_name" description:"销售名称"`
 	AdminId            int     `gorm:"column:admin_id" json:"admin_id" description:"操作人ID"`
@@ -42,7 +43,7 @@ type ContractPrePaymentRespItem struct {
 	Remark             string  `gorm:"column:remark" json:"remark" description:"备注信息"`
 	StartDate          string  `gorm:"column:start_date" json:"start_date" description:"约定开始时间"`
 	EndDate            string  `gorm:"column:end_date" json:"end_date" description:"约定结束时间"`
-	NewCompany         int       `gorm:"column:new_company" json:"new_company" description:"是否为新客户: 0-否; 1-是"`
+	NewCompany         int     `gorm:"column:new_company" json:"new_company" description:"是否为新客户: 0-否; 1-是"`
 	CreateTime         string  `gorm:"autoCreateTime;column:create_time" json:"create_time" description:"创建时间"`
 	ModifyTime         string  `gorm:"autoUpdateTime:milli;column:modify_time" json:"modify_time" description:"最后更新时间"`
 }
@@ -141,6 +142,7 @@ type PrepayEditReq struct {
 	PrePayId int `json:"pre_pay_id" binding:"required,gte=1" description:"预付款ID"`
 	PrepayAddReq
 }
+
 // PrepayDelReq 删除到款预登记
 type PrepayDelReq struct {
 	PrePayId int `json:"pre_pay_id" binding:"required,gte=1" description:"预付款ID"`

+ 1 - 0
models/fms/contract_register.go

@@ -176,6 +176,7 @@ type ContractRegisterAddReq struct {
 	ServiceRemark      string                  `json:"service_remark" description:"套餐备注"`
 	HasPayment         int                     `json:"has_payment" description:"是否有代付: 0-无; 1-有"`
 	NewCompany         int                     `json:"new_company" description:"是否为新客户: 0-否; 1-是"`
+	Supplement         int                     `json:"supplement" description:"是否为补录合同: 0-否; 1-是"`
 	Services           []ContractServiceAddReq `json:"services" description:"服务套餐内容"`
 }