...
|
...
|
@@ -3,11 +3,8 @@ package service |
|
|
import (
|
|
|
"crypto/md5"
|
|
|
"encoding/hex"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
"unsafe"
|
|
|
|
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command"
|
...
|
...
|
@@ -19,6 +16,8 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
// CooperationContractService 共创合约服务
|
...
|
...
|
@@ -982,10 +981,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
}
|
|
|
|
|
|
// 获取待更新的共创合约
|
|
|
cooperationContract, err8 := cooperationContractRepository.FindOne(map[string]interface{}{
|
|
|
cooperationContract, err9 := cooperationContractRepository.FindOne(map[string]interface{}{
|
|
|
"cooperationContractId": updateCooperationContractCommand.CooperationContractId,
|
|
|
})
|
|
|
if err8 != nil {
|
|
|
if err9 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
|
|
|
}
|
|
|
if cooperationContract == nil {
|
...
|
...
|
@@ -993,8 +992,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
}
|
|
|
|
|
|
// 更新合约基础信息
|
|
|
if err9 := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err9 != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err9.Error())
|
|
|
if err10 := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err10 != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err10.Error())
|
|
|
}
|
|
|
|
|
|
// 更新发起人
|
...
|
...
|
@@ -1270,18 +1269,33 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
} else if cooperationContractFound.IncentivesType == cooperationContract.IncentivesType { // 2.激励规则内容变更
|
|
|
if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 业绩分红规则内容变更
|
|
|
// 计算原合约哈希值
|
|
|
cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.DividendsIncentivesRules))
|
|
|
cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundByte)
|
|
|
// cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.DividendsIncentivesRules))
|
|
|
var cooperationContractFoundBytes []byte
|
|
|
for _, rule := range cooperationContractFound.DividendsIncentivesRules {
|
|
|
jsons, errs := json.Marshal(rule)
|
|
|
if errs != nil {
|
|
|
fmt.Println(errs.Error())
|
|
|
}
|
|
|
cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...)
|
|
|
}
|
|
|
cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundBytes)
|
|
|
cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:])
|
|
|
|
|
|
// 计算更新后的合约哈希值
|
|
|
cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.DividendsIncentivesRules))
|
|
|
cooperationContractHashValue := md5.Sum(cooperationContractByte)
|
|
|
// cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.DividendsIncentivesRules))
|
|
|
var cooperationContractBytes []byte
|
|
|
for _, rule := range cooperationContract.DividendsIncentivesRules {
|
|
|
jsons, errs := json.Marshal(rule)
|
|
|
if errs != nil {
|
|
|
fmt.Println(errs.Error())
|
|
|
}
|
|
|
cooperationContractBytes = append(cooperationContractBytes, jsons...)
|
|
|
}
|
|
|
cooperationContractHashValue := md5.Sum(cooperationContractBytes)
|
|
|
cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:])
|
|
|
|
|
|
if cooperationContractFoundHashString != cooperationContractHashString {
|
|
|
// 业绩分红-->业绩分红
|
|
|
|
|
|
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContract.IncentivesType))
|
|
|
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
|
|
|
// 原业绩分红激励规则
|
...
|
...
|
@@ -1311,13 +1325,29 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
}
|
|
|
} else if cooperationContractFound.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 金额激励规则内容变更
|
|
|
// 计算原合约哈希值
|
|
|
cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.MoneyIncentivesRules))
|
|
|
cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundByte)
|
|
|
//cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.MoneyIncentivesRules))
|
|
|
var cooperationContractFoundBytes []byte
|
|
|
for _, rule := range cooperationContractFound.MoneyIncentivesRules {
|
|
|
jsons, errs := json.Marshal(rule)
|
|
|
if errs != nil {
|
|
|
fmt.Println(errs.Error())
|
|
|
}
|
|
|
cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...)
|
|
|
}
|
|
|
cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundBytes)
|
|
|
cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:])
|
|
|
|
|
|
// 计算更新后的合约哈希值
|
|
|
cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.MoneyIncentivesRules))
|
|
|
cooperationContractHashValue := md5.Sum(cooperationContractByte)
|
|
|
//cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.MoneyIncentivesRules))
|
|
|
var cooperationContractBytes []byte
|
|
|
for _, rule := range cooperationContract.MoneyIncentivesRules {
|
|
|
jsons, errs := json.Marshal(rule)
|
|
|
if errs != nil {
|
|
|
fmt.Println(errs.Error())
|
|
|
}
|
|
|
cooperationContractBytes = append(cooperationContractBytes, jsons...)
|
|
|
}
|
|
|
cooperationContractHashValue := md5.Sum(cooperationContractBytes)
|
|
|
cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:])
|
|
|
|
|
|
if cooperationContractFoundHashString != cooperationContractHashString {
|
...
|
...
|
@@ -1327,7 +1357,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
var moneyIncentivesRuleOriginal string
|
|
|
for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
|
|
|
moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN +
|
|
|
":" +
|
|
|
":" + fmt.Sprint(moneyIncentivesRule.MoneyIncentivesAmount) +
|
|
|
"," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") +
|
|
|
"," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
|
|
|
"," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
|
...
|
...
|
@@ -1337,7 +1367,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
var moneyIncentivesRuleChanged string
|
|
|
for _, moneyIncentivesRule := range cooperationContract.MoneyIncentivesRules {
|
|
|
moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
|
|
|
":" +
|
|
|
":" + fmt.Sprint(moneyIncentivesRule.MoneyIncentivesAmount) +
|
|
|
"," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") +
|
|
|
"," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
|
|
|
"," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
|
...
|
...
|
@@ -1351,13 +1381,28 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
|
|
|
/*********************************************** 承接人变更 *****************************************************/
|
|
|
// 计算原合约哈希值
|
|
|
cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.Undertakers))
|
|
|
cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundByte)
|
|
|
//cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.Undertakers))
|
|
|
var cooperationContractFoundBytes []byte
|
|
|
for _, undertaker := range cooperationContractFound.Undertakers {
|
|
|
jsons, errs := json.Marshal(undertaker)
|
|
|
if errs != nil {
|
|
|
fmt.Println(errs.Error())
|
|
|
}
|
|
|
cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...)
|
|
|
}
|
|
|
cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundBytes)
|
|
|
cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:])
|
|
|
|
|
|
// 计算更新后的合约哈希值
|
|
|
cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.Undertakers))
|
|
|
cooperationContractHashValue := md5.Sum(cooperationContractByte)
|
|
|
var cooperationContractBytes []byte
|
|
|
for _, undertaker := range cooperationContract.Undertakers {
|
|
|
jsons, errs := json.Marshal(undertaker) //转换成JSON返回的是byte[]
|
|
|
if errs != nil {
|
|
|
fmt.Println(errs.Error())
|
|
|
}
|
|
|
cooperationContractBytes = append(cooperationContractBytes, jsons...)
|
|
|
}
|
|
|
cooperationContractHashValue := md5.Sum(cooperationContractBytes)
|
|
|
cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:])
|
|
|
|
|
|
if cooperationContractFoundHashString != cooperationContractHashString { // 【1(张三,李四,王五)2(买买买,,)】变更为【1(张三,,)】
|
...
|
...
|
|