|
|
@@ -2,10 +2,8 @@
|
|
|
|
|
|
namespace app\api\logic;
|
|
|
|
|
|
-use app\api\controller\Teac;
|
|
|
-use app\common\model\ParametersModel;
|
|
|
-use app\common\model\ServersModel;
|
|
|
-use app\common\model\TeacTrade;
|
|
|
+
|
|
|
+use app\common\model\ProductTeac;
|
|
|
use fast\Http;
|
|
|
use think\Loader;
|
|
|
use Exception;
|
|
|
@@ -21,76 +19,68 @@ class TeacLogin
|
|
|
{
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
- * 发布求购信息
|
|
|
- */
|
|
|
- public static function setCreateOrder(int $uid, float $price, int $stock, int $typeId = TeacTrade::Buying):float
|
|
|
+ * 发布求购出售信息
|
|
|
+ */
|
|
|
+ public static function setCreateTrade(int $uid, float $price, int $stock, int $typeId = ProductTeac::Buying):float
|
|
|
{
|
|
|
|
|
|
- $rows = TeacTrade::where('status', TeacTrade::Normal)->find();
|
|
|
+ $rows = ProductTeac::where('status', ProductTeac::Normal)->find();
|
|
|
if($rows) throw new Exception(__("你有未完成的求购订单、不能重复发布"));
|
|
|
|
|
|
//添加订单信息
|
|
|
- return TeacTrade::setUserCreateOrder($uid, $typeId, $price, $stock, bcmul($price, $stock, 2));
|
|
|
-
|
|
|
-
|
|
|
+ return ProductTeac::setUserCreateOrder($uid, $typeId, $price, $stock, bcmul($price, $stock, 2));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 发布出售
|
|
|
- * @$address 查询地址
|
|
|
- * @$from_to 是查询付款交易(from),还剩收款交易(to),默认from
|
|
|
- */
|
|
|
- public function setCreateSellOrder(string $from, string $to, int $start_block, int $end_block = 99999999)
|
|
|
- {
|
|
|
+ /**
|
|
|
+ * 发布出售
|
|
|
+ * @$address 查询地址
|
|
|
+ * @$from_to 是查询付款交易(from),还剩收款交易(to),默认from
|
|
|
+ */
|
|
|
+ public function setCreateSellOrder(string $from, string $to, int $start_block, int $end_block = 99999999)
|
|
|
+ {
|
|
|
if(empty($from) && empty($to)){
|
|
|
return _error('钱包地址不能都为空');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 获取哈希地址成功状态
|
|
|
- * @param $orderInfo
|
|
|
- * @return array|string
|
|
|
- */
|
|
|
- public function getHashStatus($tx_hash):array
|
|
|
- {
|
|
|
- if (empty($tx_hash)) {
|
|
|
- return _error('hash值不能为空');
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 获取哈希地址成功状态
|
|
|
+ * @param $orderInfo
|
|
|
+ * @return array|string
|
|
|
+ */
|
|
|
+ public function getHashStatus($tx_hash):array
|
|
|
+ {
|
|
|
+ if (empty($tx_hash)) {
|
|
|
+ return _error('hash值不能为空');
|
|
|
+ }
|
|
|
|
|
|
- $url = "https://api.bscscan.com/api?module=transaction&action=gettxreceiptstatus";
|
|
|
- $url .= "&apikey=" . $this->bsc_api_key;
|
|
|
- $url .= "&txhash=" . $tx_hash;
|
|
|
+ $url = "https://api.bscscan.com/api?module=transaction&action=gettxreceiptstatus";
|
|
|
+ $url .= "&apikey=" . $this->bsc_api_key;
|
|
|
+ $url .= "&txhash=" . $tx_hash;
|
|
|
|
|
|
- $body = Http::get($url);
|
|
|
- if (empty($body)) {
|
|
|
- return _error('状态api返回内容为空');
|
|
|
- }
|
|
|
- // 转成数组
|
|
|
- $rsArr = json_decode($body, true);
|
|
|
- if (empty($rsArr) || !is_array($rsArr)) {
|
|
|
- return _error('状态api返回数据异常,json转换失败');
|
|
|
- }
|
|
|
+ $body = Http::get($url);
|
|
|
+ if (empty($body)) {
|
|
|
+ return _error('状态api返回内容为空');
|
|
|
+ }
|
|
|
+ // 转成数组
|
|
|
+ $rsArr = json_decode($body, true);
|
|
|
+ if (empty($rsArr) || !is_array($rsArr)) {
|
|
|
+ return _error('状态api返回数据异常,json转换失败');
|
|
|
+ }
|
|
|
|
|
|
- if ($rsArr['status'] != '1') {
|
|
|
- return _error('状态api返回status不为1,当前值为:' . $rsArr['status']);
|
|
|
- }
|
|
|
+ if ($rsArr['status'] != '1') {
|
|
|
+ return _error('状态api返回status不为1,当前值为:' . $rsArr['status']);
|
|
|
+ }
|
|
|
|
|
|
- if ($rsArr['result']['status'] != 1) {
|
|
|
- return _error('状态api返回result中的status不为1,当前值为:' . $rsArr['result']['status']);
|
|
|
- }
|
|
|
+ if ($rsArr['result']['status'] != 1) {
|
|
|
+ return _error('状态api返回result中的status不为1,当前值为:' . $rsArr['result']['status']);
|
|
|
+ }
|
|
|
|
|
|
- return _success();
|
|
|
- }
|
|
|
+ return _success();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 根据时间戳获取最近的区块高度
|