Repository navigation
Expand file tree
/
Copy pathFinancingProcessController.sol
More file actions
79 lines (64 loc) · 2.43 KB
/
Copy pathFinancingProcessController.sol
File metadata and controls
79 lines (64 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* 贷款方融资流程控制器
*/
pragma solidity ^0.4.25;
pragma experimental ABIEncoderV2;
import "./role/Role.sol";
import "./utils/Ownable.sol";
import "./utils/LibString.sol";
import "./service/FinancingProcessStorage.sol";
import "./service/FinancingDetailStorage.sol";
import "./service/PledgeGoodsStorage.sol";
import "./service/PledgeReceiptStorage.sol";
contract FinancingProcessController is Ownable, Role {
using LibString for string;
FinancingProcessStorage private financingProcessStorage;
FinancingDetailStorage private financingDetailStorage;
PledgeGoodsStorage private pledgeGoodsStorage;
PledgeReceiptStorage private pledgeReceiptStorage;
event IssueResult(int256);
//日志打印
event LogMessage(string _m);
function _log(bool _b , string memory _m) private {
if(_b){
emit LogMessage(_m);
}
}
constructor() public {
financingProcessStorage = new FinancingProcessStorage();
financingDetailStorage = new FinancingDetailStorage();
pledgeGoodsStorage = new PledgeGoodsStorage();
pledgeReceiptStorage = new PledgeReceiptStorage();
}
/**
* 发布融资流程
* _processStr 流程详情
* _detailStr 融资单信息
* _goodsStr 质押物品信息 "11,ZW2108239960,畜牧-牛,吨,100000,6800,110000,701,200000,奶牛养殖场"
* _user_id 操作用户id
*/
function issue(string _processStr, string _detailStr, string _goodsStr, string _user_id) external onlyOwner returns(int256){
onlyDKRole(_user_id);
int256 count = financingProcessStorage.insert(_processStr, _detailStr, _goodsStr);
_log(!(count > 0), "FinancingProcessController issue: fail!");
emit IssueResult(count);
return count;
}
/**
* 查询融资流程详情
* _processId 流程id
*/
function query(string _processId) external returns(string){
string memory _json = "{";
_json = _json.concat("'financingProcess':");
_json = _json.concat(financingProcessStorage.getDetail(_processId));
_json = _json.concat(",");
_json = _json.concat("'financingDetail':");
_json = _json.concat(financingDetailStorage.getDetail(_processId));
_json = _json.concat(",");
_json = _json.concat("'pledgeGoods':");
_json = _json.concat(pledgeGoodsStorage.getDetail(_processId));
_json = _json.concat("}");
return _json;
}
}