|
@@ -429,6 +429,7 @@ func (this *EtaBusinessController) Add() {
|
|
|
contractItem := new(eta_business.EtaBusinessContract)
|
|
|
contractItem.SigningTime = signTime
|
|
|
contractItem.ExpiredTime = expiredTime
|
|
|
+ contractItem.IsFirst = 1
|
|
|
contractItem.CreateTime = now
|
|
|
contractItem.ModifyTime = now
|
|
|
if e = eta_business.CreateEtaBusinessAndContract(businessItem, contractItem); e != nil {
|
|
@@ -579,7 +580,7 @@ func (this *EtaBusinessController) Edit() {
|
|
|
|
|
|
// Signing
|
|
|
// @Title 签约续约
|
|
|
-// @Description 签约续约
|
|
|
+// @Description 签约续约(业务上仅用于续约, 兼容首次签约)
|
|
|
// @Param request body eta_business.EtaBusinessSigningReq true "type json string"
|
|
|
// @Success 200 Ret=200 操作成功
|
|
|
// @router /signing [post]
|
|
@@ -660,6 +661,23 @@ func (this *EtaBusinessController) Signing() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 续约不可早于当前生效合约的到期时间
|
|
|
+ if business.ContractId > 0 {
|
|
|
+ {
|
|
|
+ ob := new(eta_business.EtaBusinessContract)
|
|
|
+ item, e := ob.GetItemById(business.ContractId)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "获取商家当前合同失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !signTime.After(item.ExpiredTime) {
|
|
|
+ br.Msg = "签约时间不可早于当前合同的到期时间"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 获取历史签约, 签约日期不可交叠
|
|
|
contract := new(eta_business.EtaBusinessContract)
|
|
|
cond := fmt.Sprintf(` AND %s = ?`, eta_business.EtaBusinessContractColumns.EtaBusinessId)
|
|
@@ -672,22 +690,11 @@ func (this *EtaBusinessController) Signing() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // 本次签约是否属于终止期
|
|
|
- now := time.Now().Local()
|
|
|
- isTerminate := true
|
|
|
- if now.Equal(signTime) || now.Equal(expiredTime) {
|
|
|
- isTerminate = false
|
|
|
- }
|
|
|
- if now.After(signTime) && now.Before(expiredTime) {
|
|
|
- isTerminate = false
|
|
|
- }
|
|
|
-
|
|
|
- // 是否为首次签约
|
|
|
- isFirst := true
|
|
|
+ // 校验签约时间是否重叠
|
|
|
+ isFirst := true // 是否为首次签约
|
|
|
if len(contracts) > 0 {
|
|
|
isFirst = false
|
|
|
for _, c := range contracts {
|
|
|
- // 校验签约时间是否重叠
|
|
|
pass := false
|
|
|
if expiredTime.Before(c.SigningTime) {
|
|
|
pass = true
|
|
@@ -699,37 +706,6 @@ func (this *EtaBusinessController) Signing() {
|
|
|
br.Msg = "签约时间在存续期内, 请检查"
|
|
|
return
|
|
|
}
|
|
|
- // 上面判断若为终止, 则判断是否在历史签约存续期间
|
|
|
- if !isTerminate {
|
|
|
- continue
|
|
|
- }
|
|
|
- if now.Equal(c.SigningTime) || now.Equal(c.ExpiredTime) {
|
|
|
- isTerminate = false
|
|
|
- continue
|
|
|
- }
|
|
|
- if now.After(c.SigningTime) && now.Before(c.ExpiredTime) {
|
|
|
- isTerminate = false
|
|
|
- continue
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 是否更新签约状态
|
|
|
- status := eta_business.EtaBusinessSigningStatusContinue
|
|
|
- if isTerminate {
|
|
|
- status = eta_business.EtaBusinessSigningStatusTerminate
|
|
|
- }
|
|
|
- if !isTerminate && isFirst {
|
|
|
- status = eta_business.EtaBusinessSigningStatusFirst
|
|
|
- }
|
|
|
- if business.SigningStatus != status {
|
|
|
- business.SigningStatus = status
|
|
|
- business.ModifyTime = now
|
|
|
- cols := []string{"SigningStatus", "ModifyTime"}
|
|
|
- if e = business.Update(cols); e != nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "更新签约状态失败, Err: " + e.Error()
|
|
|
- return
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -737,14 +713,22 @@ func (this *EtaBusinessController) Signing() {
|
|
|
contract.EtaBusinessId = req.EtaBusinessId
|
|
|
contract.SigningTime = signTime
|
|
|
contract.ExpiredTime = expiredTime
|
|
|
- contract.CreateTime = now
|
|
|
- contract.ModifyTime = now
|
|
|
+ contract.CreateTime = time.Now().Local()
|
|
|
+ contract.ModifyTime = time.Now().Local()
|
|
|
+ if isFirst {
|
|
|
+ contract.IsFirst = 1
|
|
|
+ }
|
|
|
if e = contract.Create(); e != nil {
|
|
|
br.Msg = "操作失败"
|
|
|
br.ErrMsg = "新增签约失败, Err: " + e.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 签约后续操作
|
|
|
+ go func() {
|
|
|
+ _ = etaBusinessService.UpdateEtaBusinessAfterSigning(business.EtaBusinessId)
|
|
|
+ }()
|
|
|
+
|
|
|
// 续约操作日志
|
|
|
if !isFirst {
|
|
|
go func() {
|