add supply_chain chaincode

parent 8c84d3e5
This diff is collapsed.
bean @ 0de10c54
Subproject commit 0de10c54a09fe9f5a0e8b43b2936e5c96ac2a4db
......@@ -200,4 +200,11 @@ func TestAddActivityInfo(t *testing.T) {
}else if print{
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 {
Contacts string `json:"contacts"` //联系人
ContactPhone string `json:"contactPhone"` //联系电话
Status int `json:"status"` //状态
}
/*
......@@ -347,7 +346,6 @@ type SalesInfo struct {
PrincipalId string `json:"principalId"` //负责人ID
Principal string `json:"principal"` //负责人
CommissionRatio float32 `json:"commissionRatio"` //返佣比例
}
/*
......@@ -561,7 +559,7 @@ func AddCompanyInfo(args []string, stub shim.ChaincodeStubInterface) pb.Response
comInfo := &CompanyInfo{}
err := json.Unmarshal([]byte(args[0]), comInfo)
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 {
return shim.Error("company info cid can not is null")
......@@ -1057,18 +1055,26 @@ func SearchRespectInfo(args []string, stub shim.ChaincodeStubInterface) pb.Respo
return shim.Error("create respect show composite key err: " + err.Error())
}
showByte, err := getStateByte(showKey, stub)
qr := &SearchQrCode{}
if showByte != nil{
return shim.Success(showByte)
}
qrcode,err := getQrcode(args,stub)
if err!=nil{
return shim.Error(err.Error())
}
searchShow,err := extractRespectShowInfo(qrcode,stub)
if err != nil{
return shim.Error("extract RespectShow info err: " +err.Error())
err = json.Unmarshal(showByte,qr)
if err !=nil{
return shim.Error(err.Error())
}
qr.Count+=1
}else{
qrcode,err := getQrcode(args,stub)
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 {
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