|
|
@@ -10,6 +10,13 @@ import (
|
|
|
"ERP_storage/models/Contract"
|
|
|
"ERP_storage/models/Stock"
|
|
|
"fmt"
|
|
|
+ "math"
|
|
|
+ "net/url"
|
|
|
+ "os"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+
|
|
|
"github.com/beego/beego/v2/adapter/orm"
|
|
|
beego "github.com/beego/beego/v2/server/web"
|
|
|
"github.com/robfig/cron/v3"
|
|
|
@@ -17,12 +24,6 @@ import (
|
|
|
natslibs "gogs.baozhida.cn/zoie/ERP_libs/Nats"
|
|
|
userlibs "gogs.baozhida.cn/zoie/ERP_libs/User"
|
|
|
"gogs.baozhida.cn/zoie/ERP_libs/lib"
|
|
|
- "math"
|
|
|
- "net/url"
|
|
|
- "os"
|
|
|
- "strconv"
|
|
|
- "strings"
|
|
|
- "time"
|
|
|
)
|
|
|
|
|
|
type ContractController struct {
|
|
|
@@ -593,15 +594,16 @@ func (c *ContractController) VerifyContract_List() {
|
|
|
page_z = conf.Page_size
|
|
|
}
|
|
|
T_customer_id := c.GetString("T_customer_id")
|
|
|
+ T_customer_name := c.GetString("T_customer_name")
|
|
|
|
|
|
// 查询
|
|
|
T_name := c.GetString("T_name")
|
|
|
|
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
|
Account.Read_User_All_Map(userList)
|
|
|
-
|
|
|
+ Contract.Read_VerifyContract_All_Map()
|
|
|
ContractDao := Contract.NewContract(orm.NewOrm())
|
|
|
- R_List, R_cnt := ContractDao.Read_VerifyContract_List(T_name, T_customer_id, page, page_z)
|
|
|
+ R_List, R_cnt := ContractDao.Read_VerifyContract_List(T_name, T_customer_id, T_customer_name, page, page_z)
|
|
|
|
|
|
var r_jsons lib.R_JSONS
|
|
|
r_jsons.Num = R_cnt
|
|
|
@@ -660,14 +662,15 @@ func (c *ContractController) VerifyContract_Add() {
|
|
|
ContractDao := Contract.NewContract(o)
|
|
|
ContractProductDao := Contract.NewContractProduct(o)
|
|
|
|
|
|
- _, err := ContractDao.Read_Contract_ByT_date(T_customer_id, T_start_date, T_end_date)
|
|
|
- if err == nil {
|
|
|
- o.Rollback()
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "合同签约时间重复!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
- _, err = ContractDao.Read_Contract_ByT_number(T_number)
|
|
|
+ // 暂时屏蔽验证合同时间检查
|
|
|
+ //_, err := ContractDao.Read_Contract_ByT_date(T_customer_id, T_start_date, T_end_date)
|
|
|
+ //if err == nil {
|
|
|
+ // o.Rollback()
|
|
|
+ // c.Data["json"] = lib.JSONS{Code: 202, Msg: "合同签约时间重复!"}
|
|
|
+ // c.ServeJSON()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ _, err := ContractDao.Read_Contract_ByT_number(T_number)
|
|
|
if err == nil {
|
|
|
o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "合同编号重复!"}
|
|
|
@@ -1136,9 +1139,47 @@ func Update_VerifyContract_State(T_customer_id, flag string) error {
|
|
|
VerifyContractDao := Contract.NewVerifyContract(o)
|
|
|
vcn := ContractDao.Read_VerifyContract_Newest(T_customer_id)
|
|
|
vc, err := VerifyContractDao.Read_VerifyContract_ByT_customer_id(T_customer_id)
|
|
|
+
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
+
|
|
|
+ contractList, _ := ContractDao.Read_VerifyContract_List("", T_customer_id, "", 1, 9999)
|
|
|
+ var (
|
|
|
+ earliestStart time.Time
|
|
|
+ latestEnd time.Time
|
|
|
+ earliestStartStr string
|
|
|
+ latestEndStr string
|
|
|
+ hasStart bool
|
|
|
+ hasEnd bool
|
|
|
+ )
|
|
|
+ for _, info := range contractList {
|
|
|
+ if len(info.T_start_date) > 0 {
|
|
|
+ if startTime, ok := lib.DateStrToTime(info.T_start_date); ok {
|
|
|
+ if !hasStart || startTime.Before(earliestStart) {
|
|
|
+ hasStart = true
|
|
|
+ earliestStart = startTime
|
|
|
+ earliestStartStr = info.T_start_date
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(info.T_end_date) > 0 {
|
|
|
+ if endTime, ok := lib.DateStrToTime(info.T_end_date); ok {
|
|
|
+ if !hasEnd || endTime.After(latestEnd) {
|
|
|
+ hasEnd = true
|
|
|
+ latestEnd = endTime
|
|
|
+ latestEndStr = info.T_end_date
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(earliestStartStr) > 0 {
|
|
|
+ vc.T_start_date = earliestStartStr
|
|
|
+ }
|
|
|
+ if len(latestEndStr) > 0 {
|
|
|
+ vc.T_end_date = latestEndStr
|
|
|
+ }
|
|
|
if vcn.Id == 0 {
|
|
|
vc.T_sign_times = 0
|
|
|
vc.T_start_date = ""
|
|
|
@@ -1152,15 +1193,13 @@ func Update_VerifyContract_State(T_customer_id, flag string) error {
|
|
|
} else if flag == "DELETE" {
|
|
|
vc.T_sign_times -= 1
|
|
|
}
|
|
|
- if len(vc.T_start_date) == 0 {
|
|
|
- vc.T_start_date = vcn.T_start_date
|
|
|
- }
|
|
|
- if vc.T_end_date != vcn.T_end_date {
|
|
|
- vc.T_end_date = vcn.T_end_date
|
|
|
- }
|
|
|
nowTime := time.Now()
|
|
|
now := time.Date(nowTime.Year(), nowTime.Month(), nowTime.Day(), 0, 0, 0, 0, time.Local)
|
|
|
- end, _ := lib.DateStrToTime(vcn.T_end_date)
|
|
|
+ targetEndDate := vc.T_end_date
|
|
|
+ if len(targetEndDate) == 0 {
|
|
|
+ targetEndDate = vcn.T_end_date
|
|
|
+ }
|
|
|
+ end, _ := lib.DateStrToTime(targetEndDate)
|
|
|
now2Month := now.AddDate(0, 2, 0)
|
|
|
// 1-未签约 2-已作废 3-已签约 4-即将到期
|
|
|
state := 1
|
|
|
@@ -1551,7 +1590,7 @@ func Cron_VerifyContract_ChangeState() {
|
|
|
func UpdateVerifyContract_RecoveriesInvoice_Money() {
|
|
|
ContractDao := Contract.NewContract(orm.NewOrm())
|
|
|
|
|
|
- R_List, _ := ContractDao.Read_VerifyContract_List("", "", 0, 9999)
|
|
|
+ R_List, _ := ContractDao.Read_VerifyContract_List("", "", "", 0, 9999)
|
|
|
|
|
|
for _, verify := range R_List {
|
|
|
R := Contract.Contract{Id: verify.Id}
|
|
|
@@ -1567,7 +1606,7 @@ func UpdateVerifyContract_RecoveriesInvoice_Money() {
|
|
|
func UpdateVerifyContract_RecoveriesInvoice_Time() {
|
|
|
ContractDao := Contract.NewContract(orm.NewOrm())
|
|
|
|
|
|
- R_List, _ := ContractDao.Read_VerifyContract_List("", "", 0, 9999)
|
|
|
+ R_List, _ := ContractDao.Read_VerifyContract_List("", "", "", 0, 9999)
|
|
|
|
|
|
for _, verify := range R_List {
|
|
|
R := Contract.Contract{Id: verify.Id}
|