|
|
@@ -5,6 +5,7 @@ import (
|
|
|
"database/sql"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "time"
|
|
|
|
|
|
basedao "dashoo.cn/micro/app/dao/base"
|
|
|
dao "dashoo.cn/micro/app/dao/contract"
|
|
|
@@ -305,6 +306,10 @@ func (s CtrContractService) Add(ctx context.Context, req *model.CtrContractAddRe
|
|
|
return 0, myerrors.NewMsgError(nil, validErr.Current().Error())
|
|
|
}
|
|
|
|
|
|
+ if req.ContractCode == "" {
|
|
|
+ req.ContractCode = time.Now().Format("20060102150405")
|
|
|
+ }
|
|
|
+
|
|
|
c, err := s.Dao.Where("contract_code = ?", req.ContractCode).One()
|
|
|
if err != nil {
|
|
|
return 0, err
|
|
|
@@ -349,6 +354,8 @@ func (s CtrContractService) Add(ctx context.Context, req *model.CtrContractAddRe
|
|
|
InchargeName: req.InchargeName,
|
|
|
SignatoryId: req.SignatoryId,
|
|
|
SignatoryName: req.SignatoryName,
|
|
|
+ CustSignatoryId: req.CustSignatoryId,
|
|
|
+ CustSignatoryName: req.CustSignatoryName,
|
|
|
DistributorId: req.DistributorId,
|
|
|
DistributorName: req.DistributorName,
|
|
|
Remark: req.Remark,
|
|
|
@@ -395,15 +402,15 @@ func (s CtrContractService) Update(ctx context.Context, req *model.CtrContractUp
|
|
|
return myerrors.NewMsgError(nil, fmt.Sprintf("合同不存在: %d", req.Id))
|
|
|
}
|
|
|
|
|
|
- if req.ContractCode != "" {
|
|
|
- exist, err := s.Dao.Where("contract_code = ?", req.ContractCode).One()
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if exist != nil && exist.Id != req.Id {
|
|
|
- return myerrors.NewMsgError(nil, fmt.Sprintf("合同编号:%s 已存在", req.ContractCode))
|
|
|
- }
|
|
|
- }
|
|
|
+ // if req.ContractCode != "" {
|
|
|
+ // exist, err := s.Dao.Where("contract_code = ?", req.ContractCode).One()
|
|
|
+ // if err != nil {
|
|
|
+ // return err
|
|
|
+ // }
|
|
|
+ // if exist != nil && exist.Id != req.Id {
|
|
|
+ // return myerrors.NewMsgError(nil, fmt.Sprintf("合同编号:%s 已存在", req.ContractCode))
|
|
|
+ // }
|
|
|
+ // }
|
|
|
if req.ContractName != "" {
|
|
|
exist, err := s.Dao.Where("contract_name = ?", req.ContractName).One()
|
|
|
if err != nil {
|
|
|
@@ -426,9 +433,9 @@ func (s CtrContractService) Update(ctx context.Context, req *model.CtrContractUp
|
|
|
}
|
|
|
|
|
|
toupdate := map[string]interface{}{}
|
|
|
- if req.ContractCode != "" {
|
|
|
- toupdate["contract_code"] = req.ContractCode
|
|
|
- }
|
|
|
+ // if req.ContractCode != "" {
|
|
|
+ // toupdate["contract_code"] = req.ContractCode
|
|
|
+ // }
|
|
|
if req.ContractName != "" {
|
|
|
toupdate["contract_name"] = req.ContractName
|
|
|
}
|
|
|
@@ -471,6 +478,12 @@ func (s CtrContractService) Update(ctx context.Context, req *model.CtrContractUp
|
|
|
if req.SignatoryName != "" {
|
|
|
toupdate["signatory_name"] = req.SignatoryName
|
|
|
}
|
|
|
+ if req.CustSignatoryId != 0 {
|
|
|
+ toupdate["cust_signatory_id"] = req.CustSignatoryId
|
|
|
+ }
|
|
|
+ if req.CustSignatoryName != "" {
|
|
|
+ toupdate["cust_signatory_name"] = req.CustSignatoryName
|
|
|
+ }
|
|
|
if req.DistributorId != 0 {
|
|
|
toupdate["distributor_id"] = req.DistributorId
|
|
|
}
|