package main

import (
	"testing"
	"github.com/hyperledger/fabric/core/chaincode/shim"
	"fmt"
	"encoding/json"
	"encoding/hex"
)

var orgPublicKey = "04e57c3ece2608fd0123c78b5905eac3d22523027ae38500f117472135aafb9c09b83e6c9ee8a5358fc109c92eb2292118d672bd338b3ddbafb2e0f97c6f063e0c"
var orgPrivateKey = "7b22707269765f73657269616c697a65223a223451444d4156526a74496d6674734231626941494261446562542b4b6737374173492f632b7a52554744733d222c22707269765f74797065223a32317d"
var orgCert = `{"public_key_hash_algorithm":21,"public_key_byte":"BOV8Ps4mCP0BI8eLWQXqw9IlIwJ644UA8RdHITWq+5wJuD5snuilNY/BCckusikhGNZyvTOLPduvsuD5fG8GPgw=","publickey":null,"cert_type":2,"extensions":100,"not_before":1590481638,"not_after":1587889638,"cert_hash":"Ha472yKk1K4IzZy2OIX3LRoACEHBvAWgz4Mq2lAL99I=","signature":"HTM2m8T/SXY/76G+F5ha26O4fZFtP4UrgjZkJs0dvUgYGct95CAA5fVFvUAXcuujcLmGiUtC9I/LUthCzMALzQ==","signature_algorithm":16}`

var channelPublicKey = "048d9056afe7afb7f0e9626bec6629832641f3b69a5b211f23a43b59075bdc97c1687f180e09dc01e994b161c046f46e35179bf76f66443d0ebb6f099feb9bf009"
var channelPrivateKey = "7b22707269765f73657269616c697a65223a222f686736796e6e4c366858715357784530456479746f743939526a4e69563835793374585a37464e62616f3d222c22707269765f74797065223a32317d"
var channelCert = `{"public_key_hash_algorithm":21,"public_key_byte":"BI2QVq/nr7fw6WJr7GYpgyZB87aaWyEfI6Q7WQdb3JfBaH8YDgncAemUsWHARvRuNReb929mRD0Ou28Jn+ub8Ak=","publickey":null,"cert_type":2,"extensions":100,"not_before":1590481745,"not_after":1587889745,"cert_hash":"HcVbsa7IyEy28DbuUTSbyG7TqxM7CXd3IQwlD+1QR/A=","signature":"/H74hQgN6hEL7c2+p2hfCgmzKw/uXxVtsMWf5xtxH+FgRAyaz2nLr1pdmcszZRJmEGTeBenR+bU0rtTmog7b6w==","signature_algorithm":16}`

var merchantPublicKey = "041922e1019b52daa86246b1a330efc2e7308f9019000bda3103bd863a05776ff3d6d274b368778bbbfccfcb07179dae39ae55cb79aba3da14ecdbb20bb9239bf7"
var merchantPrivateKey = "7b22707269765f73657269616c697a65223a226e68724c34536c454d6b7431356c2b385651576b466d6d724c516333674b364a62527565757a39594451413d222c22707269765f74797065223a32317d"
var merchantCert = `{"public_key_hash_algorithm":21,"public_key_byte":"BBki4QGbUtqoYkaxozDvwucwj5AZAAvaMQO9hjoFd2/z1tJ0s2h3i7v8z8sHF52uOa5Vy3mro9oU7NuyC7kjm/c=","publickey":null,"cert_type":3,"extensions":100,"not_before":1590482496,"not_after":1587890496,"cert_hash":"C/L+z0ZZPnbPX8mkab88feMYNlSPRx9s5Xsitls7zoU=","signature":"5o/BpTdBedJea7w/yYpIjuj1OJa/g5hh5c2oAYDN0pmOQlHw/nftJTERMpl8GqwU3sEXh5My3tFmuI6WbLyuXA==","signature_algorithm":16}`

//var createCouponsData = `{"expand": {"coup_id": "0001","coup_type": "XJQ","coup_valid": "2017-01-13 23:59:59","coup_available_time": "券可用时间段","coup_description": "券使用说明","coup_quantity": 1000000,"coup_amount": 10.00,"coup_total_amount": 10000000,"floor_amount": 10.00},"to":"org123"}`
//var createCouponsData = `{"value":"{\"coup_id\":\"0001\",\"coup_type\":\"XJQ\",\"coup_valid\":\"2017-01-13 23:59:59\",\"coup_available_time\":\"券可用时间段\",\"coup_description\":\"券描述\",\"coup_quantity\":1000000,\"coup_amount\":10,\"coup_discount\":0.5,\"coup_total_amount\":10000000,\"floor_amount\":10,\"extensions\":null}","fromAddress":"","toAddress":"org123","toPublicKey":""}`
var createCouponsData = `{"value": "{\"uAddress\":\"wwe=rrrrr\",\"mid\":\"0001\"}"}`

var createCouponsDataSign =[]byte{207 ,240, 50, 5, 177, 135, 76 ,137, 236 ,206, 203, 228, 77, 16 ,230, 64 ,57 ,97, 237, 151, 184, 122, 214, 119 ,20, 51, 130 ,35 ,49 ,218, 32, 17, 121 ,70 ,57 ,241 ,163, 172, 191, 6 ,126, 40 ,98, 228, 197, 88 ,44 ,79 ,253 ,13, 245, 85, 129 ,204 ,254, 196 ,26 ,60, 114 ,120, 65, 172, 95 ,200}

var disCouponsData =`{"from":"org123","to":"channel123","to_pub":"04aa7cf4f0950be19033848ab8956160f2ecb461e7034d4d2e95990f233c2166de4969eec6e69988d5cfbcf3461a2a5a53dd131bfab343dcefdc24a466d0faf09e","value":10000}`
var disCouponsDataSign =[]byte{115, 165, 9 ,100, 154 ,56 ,79 ,35 ,146, 86 ,229 ,88 ,160, 82 ,228, 62 ,242 ,32 ,244 ,183, 221 ,174, 172, 186 ,53 ,200, 168, 250, 230, 21, 90, 92 ,128 ,103 ,117 ,234, 168, 145 ,224, 178, 202, 9 ,206, 121, 0 ,139 ,38 ,78, 247, 161, 147 ,60 ,20, 115 ,131, 14, 161, 110, 232, 102, 37, 109, 167, 179}

var applyCouponsData =` {"from":"channel123","to":"user123","to_pub":"123456789"}`
var applyCouponsDataSign =[]byte{154,81,233,239,237,59,16,126,169,142,112,144,255,5,43,22,101,250,208,159,199,203,100,221,24,156,14,194,149,173,47,97,113,75,80,106,37,154,220,231,181,60,150,182,109,53,175,158,175,138,93,165,161,127,39,110,85,119,8,236,143,96,16,160}

var useCouponsData =` {"expand":"订单信息","from":"user123","to":"mert123","to_pub":"123456789"}`
var useCouponsDataSign =[]byte{146,15,96,112,62,182,206,85,28,253,120,129,194,242,121,150,74,147,144,171,164,196,54,187,76,79,69,228,236,208,5,194,112,184,191,20,74,120,48,39,161,14,44,160,238,52,13,1,172,8,155,132,43,145,157,245,253,52,74,48,14,164,10,50}

var getCouponsData = `{"expand": {"coup_id": "0001"}}`

var getCouponsByAddress = `{"from":"mert123"}`

var subsidiesData = `{"to_pub":"048014f3e260f1e202259c0e0dcf9a70478c8d8e808ec91f27af1320c31c4e9183b7a12813a4a524b07b0fa83850babff2194f18e7eed38cd639f3eb6c86b61d50"}`

func TestCreateCoupons(t *testing.T) {

	cc := new(CPSChainCode)
	stub := shim.NewMockStub("CPSCC",cc)
	stub.MockInit("init",nil)
	fmt.Println()
	//fmt.Println("========================================invoke certManagement createOrg============================================")
	//fmt.Println()
	//fmt.Println()
	//responseByPutschema := stub.MockInvoke("invoke1",[][]byte{[]byte("certManagement/createOrg"),[]byte(orgCert),[]byte(orgPublicKey)})
	//fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
	//
	//
	//fmt.Println("========================================invoke certManagement createDitch============================================")
	//fmt.Println()
	//fmt.Println()
	//responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("certManagement/createDitch"),[]byte(orgPublicKey),[]byte(channelCert)})
	//fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
	//
	//fmt.Println("========================================invoke certManagement createMerchantsApi============================================")
	//fmt.Println()
	//fmt.Println()
	//responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("certManagement/createMerchants"),[]byte(orgPublicKey),[]byte(merchantCert)})
	//fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))


	fmt.Println("========================================invoke createTx createCoupons============================================")
	fmt.Println()
	fmt.Println()
	responseByPutschema := stub.MockInvoke("invoke1",[][]byte{[]byte("createTx/updateMertUtxo"), []byte(orgPublicKey),[]byte(createCouponsData),[]byte(createCouponsDataSign)})
	fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))


	//fmt.Println("========================================invoke createTx disCoupon============================================")
	//fmt.Println()
	//fmt.Println()
	//responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("createTx/disCoupon"),[]byte(orgPublicKey),[]byte(disCouponsData),[]byte(disCouponsDataSign)})
	//fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
	//
	//fmt.Println("========================================invoke createTx userApplyCoupon============================================")
	//fmt.Println()
	//fmt.Println()
	//responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("createTx/userApplyCoupon"),[]byte(channelPublicKey),[]byte(applyCouponsData),[]byte(applyCouponsDataSign)})
	//fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
	//
	//fmt.Println("========================================invoke createTx useCoupon============================================")
	//fmt.Println()
	//fmt.Println()
	//responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("createTx/useCoupon"),[]byte(merchantPublicKey),[]byte(useCouponsData),[]byte(useCouponsDataSign)})
	//fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
	//
	//
	//fmt.Println("========================================query getCoupons============================================")
	//fmt.Println()
	//fmt.Println()
	//responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("getCoupons"),[]byte(orgPublicKey),[]byte(getCouponsData),[]byte(useCouponsDataSign)})
	//fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
	//
	//fmt.Println("========================================query getCouponsByAddress============================================")
	//fmt.Println()
	//fmt.Println()
	//responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("getCouponsByAddress"),[]byte(orgPublicKey),[]byte(getCouponsByAddress),[]byte(useCouponsDataSign)})
	//fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
	//
	//fmt.Println("========================================query subsidiesApi============================================")
	//fmt.Println()
	//fmt.Println()
	//responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("subsidies"),[]byte(orgPublicKey),[]byte(subsidiesData),[]byte(useCouponsDataSign)})
	//fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))



}

var orgUser = `{"oid":"1","name":"","cert":"{\"public_key_hash_algorithm\":21,\"public_key_byte\":\"BOV8Ps4mCP0BI8eLWQXqw9IlIwJ644UA8RdHITWq+5wJuD5snuilNY/BCckusikhGNZyvTOLPduvsuD5fG8GPgw=\",\"publickey\":null,\"cert_type\":1,\"extensions\":100,\"not_before\":1590481638,\"not_after\":1587889638,\"cert_hash\":\"Ha472yKk1K4IzZy2OIX3LRoACEHBvAWgz4Mq2lAL99I=\",\"signature\":\"HTM2m8T/SXY/76G+F5ha26O4fZFtP4UrgjZkJs0dvUgYGct95CAA5fVFvUAXcuujcLmGiUtC9I/LUthCzMALzQ==\",\"signature_algorithm\":16}","create_time":"0001-01-01T00:00:00Z"}`
var ditchUser = `{"did":"11","name":"","cert":"{\"public_key_hash_algorithm\":21,\"public_key_byte\":\"BI2QVq/nr7fw6WJr7GYpgyZB87aaWyEfI6Q7WQdb3JfBaH8YDgncAemUsWHARvRuNReb929mRD0Ou28Jn+ub8Ak=\",\"publickey\":null,\"cert_type\":2,\"extensions\":100,\"not_before\":1590481745,\"not_after\":1587889745,\"cert_hash\":\"HcVbsa7IyEy28DbuUTSbyG7TqxM7CXd3IQwlD+1QR/A=\",\"signature\":\"/H74hQgN6hEL7c2+p2hfCgmzKw/uXxVtsMWf5xtxH+FgRAyaz2nLr1pdmcszZRJmEGTeBenR+bU0rtTmog7b6w==\",\"signature_algorithm\":16}","create_time":"0001-01-01T00:00:00Z"}`
var merUser =`{"mid":"111","type":"","name":"","address":"","cert":"{\"public_key_hash_algorithm\":21,\"public_key_byte\":\"BBki4QGbUtqoYkaxozDvwucwj5AZAAvaMQO9hjoFd2/z1tJ0s2h3i7v8z8sHF52uOa5Vy3mro9oU7NuyC7kjm/c=\",\"publickey\":null,\"cert_type\":3,\"extensions\":100,\"not_before\":1590482496,\"not_after\":1587890496,\"cert_hash\":\"C/L+z0ZZPnbPX8mkab88feMYNlSPRx9s5Xsitls7zoU=\",\"signature\":\"5o/BpTdBedJea7w/yYpIjuj1OJa/g5hh5c2oAYDN0pmOQlHw/nftJTERMpl8GqwU3sEXh5My3tFmuI6WbLyuXA==\",\"signature_algorithm\":16}","create_time":"0001-01-01T00:00:00Z"}`
func TestCreateUser(t *testing.T){
	org := &Orgnazation{}
	org.Cert = orgCert
	org.Oid = "1"
	orgByte,err := json.Marshal(org)
	if err!=nil{
		t.Error(err)
	}
	fmt.Println(string(orgByte))
	ditch := &Ditch{}
	ditch.Cert = channelCert
	ditch.Did = "11"
	ditchByte,err := json.Marshal(ditch)
	if err!=nil{
		t.Error(err)
	}
	fmt.Println(string(ditchByte))
	mer := &Merchant{}
	mer.Cert = merchantCert
	mer.Mid = "111"
	merByte,err := json.Marshal(mer)
	if err!=nil{
		t.Error(err)
	}
	fmt.Println(string(merByte))
}
func TestRouterest(t *testing.T) {
	//coupon := &Coupons{
	//	CoupId:"0001",
	//	CoupType:"XJQ",
	//	CoupValid:"2017-01-13 23:59:59",
	//	CoupAvailableTime:"券可用时间段",
	//	CoupDescription:"券描述",
	//	CoupQuantity:1000000,
	//	CoupAmount:10.00,
	//	CoupDiscount:0.5,
	//	CoupTotalAmount:10000000.00,
	//	FloorAmount:10.00,
	//	Extensions:nil,
	//}
	type Test struct {
		UAddress []string `json:"uAddress"`
		Mid string `json:"mid"`
	}
	test := &Test{
		UAddress:[]string{"qqqqq","wwwwww","eeeeee"},
		Mid:"0001",
	}
	couponByte,err  := json.Marshal(test)
	if err!=nil{
		fmt.Println("err",err)
	}
	fmt.Println("couponByte",couponByte)
	tx:= Trans{
		Value:string(couponByte),
	}
	txByte,err  := json.Marshal(tx)
	if err!=nil{
		fmt.Println("err",err)
	}
	fmt.Println(string(txByte))

}

func TestParse(t *testing.T){
	_,err := ParseCertificate([]byte(channelCert))
	if err!=nil{
		t.Error(err)
	}
}

var userPubHex = `04e6496ec8db3af69f1efbe12dc6e6c28402d2ff928e69160040cd4e293402d224785cf12912635306a65dc08f2dc840daa71cc30049fb77d3a95480f09d011c7d`
var usePrivHex = `7b22707269765f73657269616c697a65223a223453384363544476374a4862767867747076516969653961506a784e756c316b46324431496850765574553d222c22707269765f74797065223a32317d`
func TestCreateTx(t *testing.T){
	//coupons:= &Coupons{
	//	CoupId:"c1",
	//	IssueOrgId:"1",
	//	CoupQuantity:100,
	//	UseMerchats:[]string{"111"},
	//}
	//couponsByte,err := json.Marshal(coupons)
	//if err !=nil{
	//	t.Error(err)
	//}
	//disvalue:= make( map[string]interface{})
	//disvalue["did"] = "11"
	//disvalue["amount"] = 99
	//disByte,err := json.Marshal(disvalue)
	//if err !=nil{
	//	t.Error(err)
	//}
  //user:= UserInfo{
  //
  //}
	//userByte,err := json.Marshal(user)
	//if err !=nil{
	//	t.Error(err)
	//}
	//tx := Trans{
	//	Value:string(userByte),
	//	From:"utxo2",
	//To:"utxo3",
	//ToPub:userPubHex,
	//}
	usevalue:= make( map[string]interface{})
	usevalue["privHex"] = usePrivHex
	useByte,err := json.Marshal(usevalue)
	if err !=nil{
		t.Error(err)
	}
	tx := Trans{
			Value:string(useByte),
			From:"utxo3",
		To:"utxo4",
		ToPub:userPubHex,
		}
	txByte,err := json.Marshal(tx)
	if err !=nil{
		t.Error(err)
	}
	fmt.Println(hex.EncodeToString(txByte))
	fmt.Println(string(txByte))
	message := &Message{
		UserId:"1",
		Data:string(txByte),
		Sign:"c384f2bc27a9abc87b07ce798fd4a65323aab9ddbd4aee8b379c1a987e6cf272b9becc5fb4bcd2f3d8495fe715ed4c263c6b4c5ce68067d39922df12fd075fc9",
	}
   messageByte,err := json.Marshal(message)
	if err !=nil{
		t.Error(err)
	}
	fmt.Println(string(messageByte))
}

var createCouponsSign =`e99c297f03c1f3b5bbf1602dc15ff61bb05fb2617abc1e29f28f9d59c8445e39d19d3897827a85567032a7e0e711e20c6092e6e733a3a886de87ab3bf6b9e671`
var createCouponsDate =`{"value":"{\"coup_id\":\"c1\",\"issue_org_id\":\"1\",\"coup_type\":\"\",\"coup_valid\":\"\",\"coup_available_time\":\"\",\"coup_description\":\"\",\"coup_quantity\":100,\"coup_amount\":0,\"coup_discount\":0,\"coup_total_amount\":0,\"floor_amount\":0,\"use_merchats\":[\"111\"],\"use_merchants_type\":null,\"extensions\":null}","fromAddress":"","toAddress":"utxo1","toPublicKey":"1"}`

var disCouponsSign = `54063e3edce3905d44312a7e4038d9a06f819eae0991d04a4b8e944c721d716eaaab47befba449c2bf4e4634847daad3f2c4ed49ae80e50b4f051a1a8675cb99`
var disCouponsDate = `{"value":"{\"amount\":99,\"did\":\"11\"}","fromAddress":"utxo1","toAddress":"utxo2","toPublicKey":"11"}`

var ApplyCouponsSign = `7092dde322c376f5d43541f219ffe3234b8cea365a7e5aa49983865a36516e2c0e7b875cc5750e61b6a1bf3d22e0f004ae42d73aaad655fe972047b70ff91246`
var ApplyCouponsDate = `{"value":"{\"uid\":\"\",\"name\":\"\",\"number\":\"\",\"phone\":\"\",\"create_time\":\"0001-01-01T00:00:00Z\"}","fromAddress":"utxo2","toAddress":"utxo3","toPublicKey":"04e6496ec8db3af69f1efbe12dc6e6c28402d2ff928e69160040cd4e293402d224785cf12912635306a65dc08f2dc840daa71cc30049fb77d3a95480f09d011c7d"}`

var useCouponsSign = `a0a253661923245cdc2eef15ab665d96fd7383608587a652baa68303687f1b6e5fb86fe2bda2b94b68e9bf5478793154c7420c3688d61996c95d87d43a49649b`
var useCouponsDate = `{"value":"{\"privHex\":\"7b22707269765f73657269616c697a65223a223453384363544476374a4862767867747076516969653961506a784e756c316b46324431496850765574553d222c22707269765f74797065223a32317d\"}","fromAddress":"utxo3","toAddress":"utxo4","toPublicKey":"04e6496ec8db3af69f1efbe12dc6e6c28402d2ff928e69160040cd4e293402d224785cf12912635306a65dc08f2dc840daa71cc30049fb77d3a95480f09d011c7d"}`


func TestCouponsFlow(t *testing.T){
	cc := new(CPSChainCode)
	stub := shim.NewMockStub("CPSCC",cc)
	stub.MockInit("init",nil)
	fmt.Println()
	fmt.Println("========================================invoke certManagement createOrg============================================")
	fmt.Println()
	fmt.Println()
	responseByPutschema := stub.MockInvoke("invoke1",[][]byte{[]byte("certManagement/createOrg"),[]byte(orgUser)})
	fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))


	fmt.Println("========================================invoke certManagement createDitch============================================")
	fmt.Println()
	fmt.Println()
	responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("certManagement/createDitch"),[]byte("1"),[]byte(ditchUser)})
	fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))

	fmt.Println("========================================invoke certManagement createMerchantsApi============================================")
	fmt.Println()
	fmt.Println()
	responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("certManagement/createMerchants"),[]byte("1"),[]byte(merUser)})
	fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
	fmt.Println("========================================invoke createTx createCoupons============================================")
	fmt.Println()
	fmt.Println()
	responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("createTx/createCoupons"), []byte("1"),[]byte(createCouponsDate),[]byte(createCouponsSign)})
	fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
	fmt.Println("========================================invoke createTx disCoupon============================================")
	fmt.Println()
	fmt.Println()
	responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("createTx/disCoupon"),[]byte("1"),[]byte(disCouponsDate),[]byte(disCouponsSign)})
	fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
	fmt.Println("========================================invoke createTx userApplyCoupon============================================")
	fmt.Println()
	fmt.Println()
	responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("createTx/userApplyCoupon"),[]byte("11"),[]byte(ApplyCouponsDate),[]byte(ApplyCouponsSign)})
	fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
	fmt.Println("========================================invoke createTx useCoupon============================================")
	fmt.Println()
	fmt.Println()
	responseByPutschema = stub.MockInvoke("invoke1",[][]byte{[]byte("createTx/useCoupon"),[]byte("111"),[]byte(useCouponsDate),[]byte(useCouponsSign)})
	fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))

}
