add supply_chain chaincode

parent 8c84d3e5
This diff is collapsed.
bean @ 0de10c54
Subproject commit 0de10c54a09fe9f5a0e8b43b2936e5c96ac2a4db
...@@ -200,4 +200,11 @@ func TestAddActivityInfo(t *testing.T) { ...@@ -200,4 +200,11 @@ func TestAddActivityInfo(t *testing.T) {
}else if print{ }else if print{
fmt.Println(string(resSearch.Payload)) fmt.Println(string(resSearch.Payload))
} }
resSearch1 := stub.MockInvoke("invoke1",[][]byte{[]byte("searchRespectInfo"),[]byte("1102"),[]byte("89")})
if resSearch1.Status != 200{
//testResult = false
t.Error(resSearch1.Message)
}else if print{
fmt.Println(string(resSearch1.Payload))
}
} }
\ No newline at end of file
...@@ -78,7 +78,6 @@ type DetectionInfo struct { ...@@ -78,7 +78,6 @@ type DetectionInfo struct {
Contacts string `json:"contacts"` //联系人 Contacts string `json:"contacts"` //联系人
ContactPhone string `json:"contactPhone"` //联系电话 ContactPhone string `json:"contactPhone"` //联系电话
Status int `json:"status"` //状态 Status int `json:"status"` //状态
} }
/* /*
...@@ -347,7 +346,6 @@ type SalesInfo struct { ...@@ -347,7 +346,6 @@ type SalesInfo struct {
PrincipalId string `json:"principalId"` //负责人ID PrincipalId string `json:"principalId"` //负责人ID
Principal string `json:"principal"` //负责人 Principal string `json:"principal"` //负责人
CommissionRatio float32 `json:"commissionRatio"` //返佣比例 CommissionRatio float32 `json:"commissionRatio"` //返佣比例
} }
/* /*
...@@ -561,7 +559,7 @@ func AddCompanyInfo(args []string, stub shim.ChaincodeStubInterface) pb.Response ...@@ -561,7 +559,7 @@ func AddCompanyInfo(args []string, stub shim.ChaincodeStubInterface) pb.Response
comInfo := &CompanyInfo{} comInfo := &CompanyInfo{}
err := json.Unmarshal([]byte(args[0]), comInfo) err := json.Unmarshal([]byte(args[0]), comInfo)
if err != nil { if err != nil {
return shim.Error(fmt.Sprintf("Unmarshal CompanyInfo fail,err %s ", err)) return shim.Error(fmt.Sprintf("Unmarshal CompanyInfo fail,err %s ,info is %s", err,args[0]))
} }
if comInfo.Cid == " " || len(comInfo.Cid) == 0 { if comInfo.Cid == " " || len(comInfo.Cid) == 0 {
return shim.Error("company info cid can not is null") return shim.Error("company info cid can not is null")
...@@ -1057,18 +1055,26 @@ func SearchRespectInfo(args []string, stub shim.ChaincodeStubInterface) pb.Respo ...@@ -1057,18 +1055,26 @@ func SearchRespectInfo(args []string, stub shim.ChaincodeStubInterface) pb.Respo
return shim.Error("create respect show composite key err: " + err.Error()) return shim.Error("create respect show composite key err: " + err.Error())
} }
showByte, err := getStateByte(showKey, stub) showByte, err := getStateByte(showKey, stub)
qr := &SearchQrCode{}
if showByte != nil{ if showByte != nil{
return shim.Success(showByte)
} err = json.Unmarshal(showByte,qr)
qrcode,err := getQrcode(args,stub) if err !=nil{
if err!=nil{ return shim.Error(err.Error())
return shim.Error(err.Error()) }
} qr.Count+=1
searchShow,err := extractRespectShowInfo(qrcode,stub) }else{
if err != nil{ qrcode,err := getQrcode(args,stub)
return shim.Error("extract RespectShow info err: " +err.Error()) if err!=nil{
return shim.Error(err.Error())
}
qr,err = extractRespectShowInfo(qrcode,stub)
if err != nil{
return shim.Error("extract RespectShow info err: " +err.Error())
}
} }
valueByte, err := json.Marshal(searchShow)
valueByte, err := json.Marshal(qr)
if err != nil { if err != nil {
return shim.Error(fmt.Sprintf("json marshal data fail,err: %s", err)) return shim.Error(fmt.Sprintf("json marshal data fail,err: %s", err))
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment