|
@@ -15,7 +15,7 @@ import (
|
|
|
)
|
|
|
|
|
|
// // RegisterController 合同登记
|
|
|
-type PrePaymentController struct{}
|
|
|
+type PreRegisterController struct{}
|
|
|
|
|
|
// List
|
|
|
// @Title 到款预登记列表
|
|
@@ -26,7 +26,7 @@ type PrePaymentController struct{}
|
|
|
// @Param SortType query string true "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
|
|
|
// @Success 200 {object} fms.ContractRegisterItem
|
|
|
// @router /contract/pre_pay/list [get]
|
|
|
-func (rg *PrePaymentController) List(c *gin.Context) {
|
|
|
+func (rg *PrePaymentController) List1(c *gin.Context) {
|
|
|
var req fms.PrePayListReq
|
|
|
if e := c.BindQuery(&req); e != nil {
|
|
|
err, ok := e.(validator.ValidationErrors)
|
|
@@ -89,6 +89,74 @@ func (rg *PrePaymentController) List(c *gin.Context) {
|
|
|
resp.OkData("获取成功", baseData, c)
|
|
|
}
|
|
|
|
|
|
+// InvoiceList
|
|
|
+// @Title 开票/到款列表
|
|
|
+// @Description 开票/到款列表
|
|
|
+// @Param Keyword query string false "关键词"
|
|
|
+// @Success 200 {object} fms.ContractInvoiceItem
|
|
|
+// @router /contract/pre_register/list [get]
|
|
|
+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.GetPrePayItemPageList(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)
|
|
|
+}
|
|
|
+
|
|
|
// Add
|
|
|
// @Title 新增到款预登记
|
|
|
// @Description 新增到款预登记
|
|
@@ -140,7 +208,7 @@ func (rg *PrePaymentController) Add(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- payDate,err := time.Parse(utils.FormatDate,req.PaymentDate)
|
|
|
+ payDate, err := time.Parse(utils.FormatDate, req.PaymentDate)
|
|
|
if e != nil {
|
|
|
resp.FailMsg("日期转换失败", "日期转换失败, Err: "+e.Error(), c)
|
|
|
return
|
|
@@ -160,7 +228,6 @@ func (rg *PrePaymentController) Add(c *gin.Context) {
|
|
|
ob.PaymentDate = payDate
|
|
|
ob.Set()
|
|
|
|
|
|
-
|
|
|
// 新增合同及套餐
|
|
|
if e = ob.Create(); e != nil {
|
|
|
resp.FailMsg("操作失败", "新增合同及套餐失败, Err: "+e.Error(), c)
|
|
@@ -243,7 +310,7 @@ func (rg *PrePaymentController) Edit(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- payDate,err := time.Parse(utils.FormatDate,req.PaymentDate)
|
|
|
+ payDate, err := time.Parse(utils.FormatDate, req.PaymentDate)
|
|
|
if e != nil {
|
|
|
resp.FailMsg("日期转换失败", "日期转换失败, Err: "+e.Error(), c)
|
|
|
return
|
|
@@ -259,12 +326,12 @@ func (rg *PrePaymentController) Edit(c *gin.Context) {
|
|
|
item.OriginAmount = req.Amount
|
|
|
item.CurrencyUnit = req.CurrencyUnit
|
|
|
item.Remark = req.Remark
|
|
|
- item.PaymentDate = payDate
|
|
|
+ item.PaymentDate = payDate
|
|
|
item.ModifyTime = time.Now().Local()
|
|
|
|
|
|
updateCols := []string{
|
|
|
"ContractCode", "CompanyName", "SellerId", "SellerName", "Amount", "StartDate", "EndDate",
|
|
|
- "Remark", "ModifyTime","NewCompany", "OriginAmount", "CurrencyUnit", "PaymentDate",
|
|
|
+ "Remark", "ModifyTime", "NewCompany", "OriginAmount", "CurrencyUnit", "PaymentDate",
|
|
|
}
|
|
|
if e = item.Update(updateCols); e != nil {
|
|
|
resp.FailMsg("操作失败", "更新到预款登记失败, Err:"+e.Error(), c)
|