|
@@ -1,6 +1,7 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
+ "encoding/json"
|
|
|
"log"
|
|
|
// "log"
|
|
|
"math"
|
|
@@ -534,14 +535,18 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
|
|
|
}
|
|
|
|
|
|
p1.InfoFiled = make(map[string]InfoFiled)
|
|
|
- p1.InfoFiled[thisinfo.Id] =
|
|
|
- InfoFiled{
|
|
|
- budget: thisinfo.Budget,
|
|
|
- bidamount: thisinfo.Bidamount,
|
|
|
- projectName: thisinfo.ProjectName,
|
|
|
- contractCode: thisinfo.ContractCode,
|
|
|
- projectCode: thisinfo.ProjectCode,
|
|
|
- bidstatus: bs,
|
|
|
+ infofiled := InfoFiled{
|
|
|
+ Budget: thisinfo.Budget,
|
|
|
+ Bidamount: thisinfo.Bidamount,
|
|
|
+ ContractCode: thisinfo.ContractCode,
|
|
|
+ ProjectName: thisinfo.ProjectName,
|
|
|
+ ProjectCode: thisinfo.ProjectCode,
|
|
|
+ Bidstatus: bs,
|
|
|
+ }
|
|
|
+ p1.InfoFiled[thisinfo.Id] = infofiled
|
|
|
+ res := StructToMap(infofiled)
|
|
|
+ set["infofield"] = map[string]interface{}{
|
|
|
+ thisinfo.Id: res,
|
|
|
}
|
|
|
|
|
|
push := p.PushListInfo(tmp, thisinfo.Id)
|
|
@@ -816,6 +821,18 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
|
|
|
CountAmount(pInfo, thisinfo)
|
|
|
set["budget"] = pInfo.Budget
|
|
|
set["bidamount"] = pInfo.Bidamount
|
|
|
+ infofiled := InfoFiled{
|
|
|
+ Budget: thisinfo.Budget,
|
|
|
+ Bidamount: thisinfo.Bidamount,
|
|
|
+ ContractCode: thisinfo.ContractCode,
|
|
|
+ ProjectName: thisinfo.ProjectName,
|
|
|
+ ProjectCode: thisinfo.ProjectCode,
|
|
|
+ Bidstatus: bs,
|
|
|
+ }
|
|
|
+ pInfo.InfoFiled[thisinfo.Id] = infofiled
|
|
|
+ set["infofield"] = map[string]interface{}{
|
|
|
+ thisinfo.Id: StructToMap(infofiled),
|
|
|
+ }
|
|
|
|
|
|
set["mpn"] = pInfo.MPN
|
|
|
set["mpc"] = pInfo.MPC
|
|
@@ -1022,9 +1039,9 @@ func CountAmount(project *ProjectInfo, info *Info) {
|
|
|
flag := false
|
|
|
if project.InfoFiled != nil && len(project.InfoFiled) > 0 {
|
|
|
for _, res := range project.InfoFiled {
|
|
|
- if res.projectName == info.ProjectName {
|
|
|
- if res.budget < info.Budget {
|
|
|
- project.Budget = project.Budget - res.budget + info.Budget
|
|
|
+ if res.ProjectName == info.ProjectName {
|
|
|
+ if res.Budget < info.Budget {
|
|
|
+ project.Budget = project.Budget - res.Budget + info.Budget
|
|
|
}
|
|
|
flag = true
|
|
|
break
|
|
@@ -1078,18 +1095,18 @@ func CountAmount(project *ProjectInfo, info *Info) {
|
|
|
flag := false
|
|
|
if project.InfoFiled != nil && len(project.InfoFiled) > 0 {
|
|
|
for _, res := range project.InfoFiled {
|
|
|
- if res.bidstatus == "合同" && res.contractCode != "" && info.SubType == "合同" && info.ContractCode != "" {
|
|
|
- if res.contractCode == info.ContractCode {
|
|
|
- if res.bidamount < info.Bidamount {
|
|
|
- project.Bidamount = project.Bidamount - res.bidamount + info.Bidamount
|
|
|
+ if res.Bidstatus == "合同" && res.ContractCode != "" && info.SubType == "合同" && info.ContractCode != "" {
|
|
|
+ if res.ContractCode == info.ContractCode {
|
|
|
+ if res.Bidamount < info.Bidamount {
|
|
|
+ project.Bidamount = project.Bidamount - res.Bidamount + info.Bidamount
|
|
|
}
|
|
|
flag = true
|
|
|
break
|
|
|
}
|
|
|
}else {
|
|
|
- if res.projectName == info.ProjectName {
|
|
|
- if res.bidamount < info.Bidamount {
|
|
|
- project.Bidamount = project.Bidamount - res.bidamount + info.Bidamount
|
|
|
+ if res.ProjectName == info.ProjectName {
|
|
|
+ if res.Bidamount < info.Bidamount {
|
|
|
+ project.Bidamount = project.Bidamount - res.Bidamount + info.Bidamount
|
|
|
}
|
|
|
flag = true
|
|
|
break
|
|
@@ -1104,12 +1121,17 @@ func CountAmount(project *ProjectInfo, info *Info) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- project.InfoFiled[info.Id] = InfoFiled{
|
|
|
- budget: info.Budget,
|
|
|
- bidamount: info.Bidamount,
|
|
|
- contractCode: info.ContractCode,
|
|
|
- projectName: info.ProjectName,
|
|
|
- projectCode: info.ProjectCode,
|
|
|
- bidstatus: info.SubType,
|
|
|
- }
|
|
|
+}
|
|
|
+
|
|
|
+//结构体转map
|
|
|
+func StructToMap(filed InfoFiled) map[string]interface{} {
|
|
|
+ //先转json
|
|
|
+ result, err := json.Marshal(filed)
|
|
|
+ if err != nil {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ //json转map
|
|
|
+ res := make(map[string]interface{})
|
|
|
+ err = json.Unmarshal(result, &res)
|
|
|
+ return res
|
|
|
}
|