gpt4 book ai didi

javascript - 收到错误 : Expected a Resource or Concept have checked older posts too but it's not helping me out with my code

转载 作者:行者123 更新时间:2023-11-30 20:44:26 26 4
gpt4 key购买 nike

我有两个交易 GoodsMovement 和 Payment,Goodsmovement 将跟踪 cargo 的交付,Payment 交易将在 cargo 交付时检查付款。

我正在编写以下代码:

    /**
* New model file
*/

namespace org.acme.paysystem

enum PaymentStatus{
o PARTIALLY_PAID
o TOTAL_AMOUNT_PAID
o NOT_PAID
}

enum DeliveryStatus{
o DELIVERED
o IN_TRANSIT
}

asset Goods identified by billNo{
o String billNo
o Double billAmount
o DateTime billDate
o DeliveryStatus deliveryStatus
o PaymentStatus paymentStatus default = 'NOT_PAID'
}

concept Address{
o String Country optional
o String City optional
o String Street optional
o String Zip optional
}

abstract participant user identified by email{
o String email
o String fname
o String lname
o Address address
}

participant Retailer extends user {
o String shopNo
o Double amountDue
o Double accountBalance
}

participant Distributor extends user{
o String PAN
o Double bankBalance
}

transaction Payment{
--> Goods goods
--> Retailer retailer
--> Distributor distributor
o PaymentStatus paymentStatus
}

transaction GoodsMovement {
--> Goods goods
o DeliveryStatus deliveryStatus

I haven't mentioned GoodsMovement transaction here since it's working as expected.

脚本文件如下:

/**
* @param {org.acme.paysystem.Payment} Payment
* @transaction
*/
function Payment(Payment){
var paymentRecievedFlag = 0;
var amountRecieved = 0;
if(GoodsMovement == 'IN_TRANSIT')
{
console.log("Goods are IN_TRANSIT");
}
else
{
if ((Payment.retailer.accountBalance - Payment.goods.billAmount) > 0 ){
Payment.retailer.accountbalance -= Payment.goods.billAmount;
Payment.distributor.bankBalance += Payment.goods.billAmount;

Payment.paymentStatus = 'TOTAL_AMOUNT_PAID';
//Payment.goods.paymentStatus = 'TOTAL_AMOUNT_PAID';
}

else{
Payment.retailer.amountDue = Payment.goods.billAmount - Payment.retailer.accountBalance;
Payment.distributor.bankBalance += Payment.retailer.accountBalance;
Payment.paymentStatus = PARTIALLY_PAID;
}}


return getParticipantRegistry('org.acme.paysystem.Distributor')
.then(function(distributorRegistry){
return distributorRegistry.update(Payment.distributer);
})
.then(function(){
return getParticipantRegistry('org.acme.paysystem.Retailer');
})
.then(function(retailerRegistry){
return retailerRegistry.update(Payment.retailer);
})
.then(function(){
return getAssetRegistry('org.acme.paysystem.Goods');
})
.then(function(goodsRegistry){
return goodsRegistry.update(Payment.goods);
});
}

我已经正确检查并通过 Internet 进行了搜索,但我无法弄清楚我的代码有什么问题。谢谢,如果有人能帮我解决代码问题

最佳答案

第 x 行应该是:

  if(Payment.goods.deliveryStatus == 'IN_TRANSIT')

第 31 行应该是:

 return distributorRegistry.update(Payment.distributor);

第 18 和 25 行应该是指: Payment.goods.paymentStatus = 'TOTAL_AMOUNT_PAID';

不是 Payment.paymentStatus

第 25 行需要引用: Payment.goods.paymentStatus = 'PARTIALLY_PAID';

然后使用此事务 - 它起作用了:

{
"$class": "org.acme.paysystem.Payment",
"goods": "resource:org.acme.paysystem.Goods#1",
"retailer": "resource:org.acme.paysystem.Retailer#a@b.com",
"distributor": "resource:org.acme.paysystem.Distributor#a@b.com",
"paymentStatus": "PARTIALLY_PAID"
}

关于javascript - 收到错误 : Expected a Resource or Concept have checked older posts too but it's not helping me out with my code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48879731/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com