Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e3eba92e2 | |||
| 81a95f47a0 | |||
| 4b47fe7250 | |||
| 01e93acdd8 | |||
| 6ce37d789f | |||
| 489090382f | |||
| 4b8f205e86 | |||
| 1161f06aeb | |||
| 6d242ae973 | |||
| 025dab4c2c | |||
| aa40614965 | |||
| b14c000bc3 | |||
| bebbee4184 | |||
| f4f61a5f4c | |||
| 1c555934d1 | |||
| 66d88ea2b3 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,3 +17,4 @@ yarn-error.log
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscode
|
||||
test.php
|
||||
|
||||
201
app/Bean/Model/Api/Order/CustomerUserPostOrderBean.php
Normal file
201
app/Bean/Model/Api/Order/CustomerUserPostOrderBean.php
Normal file
@ -0,0 +1,201 @@
|
||||
<?php
|
||||
namespace App\Bean\Model\Api\Order;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
use App\Models\Api\Wallet\CustomerWalletCurrencyModel;
|
||||
|
||||
class CustomerUserPostOrderBean extends BaseBean
|
||||
{
|
||||
protected $id;
|
||||
protected $sn;
|
||||
protected $pay_status;
|
||||
protected $buyer_uid;
|
||||
protected $buyer_currency_code = CustomerWalletCurrencyModel::CODE_USDT_TRC20;
|
||||
protected $seller_uid;
|
||||
protected $seller_currency_code = CustomerWalletCurrencyModel::CODE_USDT_TRC20;
|
||||
protected $pid;
|
||||
protected $post_history_id;
|
||||
protected $amount;
|
||||
protected $buyer_wallet_transaction_id;
|
||||
protected $seller_wallet_transaction_id;
|
||||
protected $wallet_checkbook_id;
|
||||
protected $dispute_status;
|
||||
protected $dispute_result_status;
|
||||
protected $created_at;
|
||||
protected $updated_at;
|
||||
|
||||
public function getBuyerCurrencyCode()
|
||||
{
|
||||
return $this->buyer_currency_code;
|
||||
}
|
||||
|
||||
public function setBuyerCurrencyCode($buyer_currency_code): void
|
||||
{
|
||||
$this->buyer_currency_code = $buyer_currency_code;
|
||||
}
|
||||
|
||||
public function getSellerCurrencyCode()
|
||||
{
|
||||
return $this->seller_currency_code;
|
||||
}
|
||||
|
||||
public function setSellerCurrencyCode($seller_currency_code): void
|
||||
{
|
||||
$this->seller_currency_code = $seller_currency_code;
|
||||
}
|
||||
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getSn()
|
||||
{
|
||||
return $this->sn;
|
||||
}
|
||||
|
||||
public function setSn($sn): void
|
||||
{
|
||||
$this->sn = $sn;
|
||||
}
|
||||
|
||||
public function getPayStatus()
|
||||
{
|
||||
return $this->pay_status;
|
||||
}
|
||||
|
||||
public function setPayStatus($pay_status): void
|
||||
{
|
||||
$this->pay_status = $pay_status;
|
||||
}
|
||||
|
||||
public function getBuyerUid()
|
||||
{
|
||||
return $this->buyer_uid;
|
||||
}
|
||||
|
||||
public function setBuyerUid($buyer_uid): void
|
||||
{
|
||||
$this->buyer_uid = $buyer_uid;
|
||||
}
|
||||
|
||||
public function getSellerUid()
|
||||
{
|
||||
return $this->seller_uid;
|
||||
}
|
||||
|
||||
public function setSellerUid($seller_uid): void
|
||||
{
|
||||
$this->seller_uid = $seller_uid;
|
||||
}
|
||||
|
||||
public function getPid()
|
||||
{
|
||||
return $this->pid;
|
||||
}
|
||||
|
||||
public function setPid($pid): void
|
||||
{
|
||||
$this->pid = $pid;
|
||||
}
|
||||
|
||||
public function getPostHistoryId()
|
||||
{
|
||||
return $this->post_history_id;
|
||||
}
|
||||
|
||||
public function setPostHistoryId($post_history_id): void
|
||||
{
|
||||
$this->post_history_id = $post_history_id;
|
||||
}
|
||||
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function setAmount($amount): void
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
public function getBuyerWalletTransactionId()
|
||||
{
|
||||
return $this->buyer_wallet_transaction_id;
|
||||
}
|
||||
|
||||
public function setBuyerWalletTransactionId($buyer_wallet_transaction_id): void
|
||||
{
|
||||
$this->buyer_wallet_transaction_id = $buyer_wallet_transaction_id;
|
||||
}
|
||||
|
||||
public function getSellerWalletTransactionId()
|
||||
{
|
||||
return $this->seller_wallet_transaction_id;
|
||||
}
|
||||
|
||||
public function setSellerWalletTransactionId($seller_wallet_transaction_id): void
|
||||
{
|
||||
$this->seller_wallet_transaction_id = $seller_wallet_transaction_id;
|
||||
}
|
||||
|
||||
public function getWalletCheckbookId()
|
||||
{
|
||||
return $this->wallet_checkbook_id;
|
||||
}
|
||||
|
||||
public function setWalletCheckbookId($wallet_checkbook_id): void
|
||||
{
|
||||
$this->wallet_checkbook_id = $wallet_checkbook_id;
|
||||
}
|
||||
|
||||
public function getDisputeStatus()
|
||||
{
|
||||
return $this->dispute_status;
|
||||
}
|
||||
|
||||
public function setDisputeStatus($dispute_status): void
|
||||
{
|
||||
$this->dispute_status = $dispute_status;
|
||||
}
|
||||
|
||||
public function getDisputeResultStatus()
|
||||
{
|
||||
return $this->dispute_result_status;
|
||||
}
|
||||
|
||||
public function setDisputeResultStatus($dispute_result_status): void
|
||||
{
|
||||
$this->dispute_result_status = $dispute_result_status;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt($created_at): void
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
}
|
||||
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updated_at;
|
||||
}
|
||||
|
||||
public function setUpdatedAt($updated_at): void
|
||||
{
|
||||
$this->updated_at = $updated_at;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
277
app/Bean/Model/Api/Order/CustomerUserPostOrderDisputeBean.php
Normal file
277
app/Bean/Model/Api/Order/CustomerUserPostOrderDisputeBean.php
Normal file
@ -0,0 +1,277 @@
|
||||
<?php
|
||||
namespace App\Bean\Model\Api\Order;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class CustomerUserPostOrderDisputeBean extends BaseBean
|
||||
{
|
||||
public $id;
|
||||
public $post_order_id;
|
||||
public $status;
|
||||
public $chat_group_id;
|
||||
public $seller_submit_datetime;
|
||||
public $buyer_submit_datetime;
|
||||
public $result_status;
|
||||
public $buyer_uid;
|
||||
public $buyer_pay_dispute_status;
|
||||
public $buyer_pay_amount;
|
||||
public $buyer_pay_transaction_id;
|
||||
public $buyer_dispute_fee_pay_status;
|
||||
public $buyer_dispute_fee_amount;
|
||||
public $buyer_dispute_fee_pay_transaction_id;
|
||||
public $seller_pay_dispute_status;
|
||||
public $seller_uid;
|
||||
public $seller_pay_amount;
|
||||
public $seller_pay_transaction_id;
|
||||
public $seller_desc_key;
|
||||
public $seller_desc;
|
||||
public $admin_remark;
|
||||
public $admin_uid;
|
||||
public $created_at;
|
||||
public $updated_at;
|
||||
|
||||
public function getBuyerUid()
|
||||
{
|
||||
return $this->buyer_uid;
|
||||
}
|
||||
|
||||
public function setBuyerUid($buyer_uid): void
|
||||
{
|
||||
$this->buyer_uid = $buyer_uid;
|
||||
}
|
||||
|
||||
public function getSellerUid()
|
||||
{
|
||||
return $this->seller_uid;
|
||||
}
|
||||
|
||||
public function setSellerUid($seller_uid): void
|
||||
{
|
||||
$this->seller_uid = $seller_uid;
|
||||
}
|
||||
|
||||
public function getBuyerDisputeFeePayStatus()
|
||||
{
|
||||
return $this->buyer_dispute_fee_pay_status;
|
||||
}
|
||||
|
||||
public function setBuyerDisputeFeePayStatus($buyer_dispute_fee_pay_status): void
|
||||
{
|
||||
$this->buyer_dispute_fee_pay_status = $buyer_dispute_fee_pay_status;
|
||||
}
|
||||
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getPostOrderId()
|
||||
{
|
||||
return $this->post_order_id;
|
||||
}
|
||||
|
||||
public function setPostOrderId($post_order_id): void
|
||||
{
|
||||
$this->post_order_id = $post_order_id;
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus($status): void
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function getChatGroupId()
|
||||
{
|
||||
return $this->chat_group_id;
|
||||
}
|
||||
|
||||
public function setChatGroupId($chat_group_id): void
|
||||
{
|
||||
$this->chat_group_id = $chat_group_id;
|
||||
}
|
||||
|
||||
public function getSellerSubmitDatetime()
|
||||
{
|
||||
return $this->seller_submit_datetime;
|
||||
}
|
||||
|
||||
public function setSellerSubmitDatetime($seller_submit_datetime): void
|
||||
{
|
||||
$this->seller_submit_datetime = $seller_submit_datetime;
|
||||
}
|
||||
|
||||
public function getBuyerSubmitDatetime()
|
||||
{
|
||||
return $this->buyer_submit_datetime;
|
||||
}
|
||||
|
||||
public function setBuyerSubmitDatetime($buyer_submit_datetime): void
|
||||
{
|
||||
$this->buyer_submit_datetime = $buyer_submit_datetime;
|
||||
}
|
||||
|
||||
public function getResultStatus()
|
||||
{
|
||||
return $this->result_status;
|
||||
}
|
||||
|
||||
public function setResultStatus($result_status): void
|
||||
{
|
||||
$this->result_status = $result_status;
|
||||
}
|
||||
|
||||
public function getBuyerPayDisputeStatus()
|
||||
{
|
||||
return $this->buyer_pay_dispute_status;
|
||||
}
|
||||
|
||||
public function setBuyerPayDisputeStatus($buyer_pay_dispute_status): void
|
||||
{
|
||||
$this->buyer_pay_dispute_status = $buyer_pay_dispute_status;
|
||||
}
|
||||
|
||||
public function getBuyerPayAmount()
|
||||
{
|
||||
return $this->buyer_pay_amount;
|
||||
}
|
||||
|
||||
public function setBuyerPayAmount($buyer_pay_amount): void
|
||||
{
|
||||
$this->buyer_pay_amount = $buyer_pay_amount;
|
||||
}
|
||||
|
||||
public function getBuyerPayTransactionId()
|
||||
{
|
||||
return $this->buyer_pay_transaction_id;
|
||||
}
|
||||
|
||||
public function setBuyerPayTransactionId($buyer_pay_transaction_id): void
|
||||
{
|
||||
$this->buyer_pay_transaction_id = $buyer_pay_transaction_id;
|
||||
}
|
||||
|
||||
public function getBuyerDisputeFeeAmount()
|
||||
{
|
||||
return $this->buyer_dispute_fee_amount;
|
||||
}
|
||||
|
||||
public function setBuyerDisputeFeeAmount($buyer_dispute_fee_amount): void
|
||||
{
|
||||
$this->buyer_dispute_fee_amount = $buyer_dispute_fee_amount;
|
||||
}
|
||||
|
||||
public function getBuyerDisputeFeePayTransactionId()
|
||||
{
|
||||
return $this->buyer_dispute_fee_pay_transaction_id;
|
||||
}
|
||||
|
||||
public function setBuyerDisputeFeePayTransactionId($buyer_dispute_fee_pay_transaction_id): void
|
||||
{
|
||||
$this->buyer_dispute_fee_pay_transaction_id = $buyer_dispute_fee_pay_transaction_id;
|
||||
}
|
||||
|
||||
public function getSellerPayDisputeStatus()
|
||||
{
|
||||
return $this->seller_pay_dispute_status;
|
||||
}
|
||||
|
||||
public function setSellerPayDisputeStatus($seller_pay_dispute_status): void
|
||||
{
|
||||
$this->seller_pay_dispute_status = $seller_pay_dispute_status;
|
||||
}
|
||||
|
||||
public function getSellerPayAmount()
|
||||
{
|
||||
return $this->seller_pay_amount;
|
||||
}
|
||||
|
||||
public function setSellerPayAmount($seller_pay_amount): void
|
||||
{
|
||||
$this->seller_pay_amount = $seller_pay_amount;
|
||||
}
|
||||
|
||||
public function getSellerPayTransactionId()
|
||||
{
|
||||
return $this->seller_pay_transaction_id;
|
||||
}
|
||||
|
||||
public function setSellerPayTransactionId($seller_pay_transaction_id): void
|
||||
{
|
||||
$this->seller_pay_transaction_id = $seller_pay_transaction_id;
|
||||
}
|
||||
|
||||
public function getSellerDescKey()
|
||||
{
|
||||
return $this->seller_desc_key;
|
||||
}
|
||||
|
||||
public function setSellerDescKey($seller_desc_key): void
|
||||
{
|
||||
$this->seller_desc_key = $seller_desc_key;
|
||||
}
|
||||
|
||||
public function getSellerDesc()
|
||||
{
|
||||
return $this->seller_desc;
|
||||
}
|
||||
|
||||
public function setSellerDesc($seller_desc): void
|
||||
{
|
||||
$this->seller_desc = $seller_desc;
|
||||
}
|
||||
|
||||
public function getAdminRemark()
|
||||
{
|
||||
return $this->admin_remark;
|
||||
}
|
||||
|
||||
public function setAdminRemark($admin_remark): void
|
||||
{
|
||||
$this->admin_remark = $admin_remark;
|
||||
}
|
||||
|
||||
public function getAdminUid()
|
||||
{
|
||||
return $this->admin_uid;
|
||||
}
|
||||
|
||||
public function setAdminUid($admin_uid): void
|
||||
{
|
||||
$this->admin_uid = $admin_uid;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt($created_at): void
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
}
|
||||
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updated_at;
|
||||
}
|
||||
|
||||
public function setUpdatedAt($updated_at): void
|
||||
{
|
||||
$this->updated_at = $updated_at;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
121
app/Bean/Model/Api/Wallet/CustomerWalletBalanceBean.php
Normal file
121
app/Bean/Model/Api/Wallet/CustomerWalletBalanceBean.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bean\Model\Api\Wallet;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class CustomerWalletBalanceBean extends BaseBean
|
||||
{
|
||||
protected $id;
|
||||
protected $uid;
|
||||
protected $currency_code;
|
||||
protected $total_amount;
|
||||
protected $frozen_amount;
|
||||
protected $available_amount;
|
||||
protected $security_amount;
|
||||
protected $recharge_wallet_addr;
|
||||
protected $created_at;
|
||||
protected $updated_at;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getUid()
|
||||
{
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
public function setUid($uid): void
|
||||
{
|
||||
$this->uid = $uid;
|
||||
}
|
||||
|
||||
public function getCurrencyCode()
|
||||
{
|
||||
return $this->currency_code;
|
||||
}
|
||||
|
||||
public function setCurrencyCode($currency_code): void
|
||||
{
|
||||
$this->currency_code = $currency_code;
|
||||
}
|
||||
|
||||
public function getTotalAmount()
|
||||
{
|
||||
return $this->total_amount;
|
||||
}
|
||||
|
||||
public function setTotalAmount($total_amount): void
|
||||
{
|
||||
$this->total_amount = $total_amount;
|
||||
}
|
||||
|
||||
public function getFrozenAmount()
|
||||
{
|
||||
return $this->frozen_amount;
|
||||
}
|
||||
|
||||
public function setFrozenAmount($frozen_amount): void
|
||||
{
|
||||
$this->frozen_amount = $frozen_amount;
|
||||
}
|
||||
|
||||
public function getAvailableAmount()
|
||||
{
|
||||
return $this->available_amount;
|
||||
}
|
||||
|
||||
public function setAvailableAmount($available_amount): void
|
||||
{
|
||||
$this->available_amount = $available_amount;
|
||||
}
|
||||
|
||||
public function getSecurityAmount()
|
||||
{
|
||||
return $this->security_amount;
|
||||
}
|
||||
|
||||
public function setSecurityAmount($security_amount): void
|
||||
{
|
||||
$this->security_amount = $security_amount;
|
||||
}
|
||||
|
||||
public function getRechargeWalletAddr()
|
||||
{
|
||||
return $this->recharge_wallet_addr;
|
||||
}
|
||||
|
||||
public function setRechargeWalletAddr($recharge_wallet_addr): void
|
||||
{
|
||||
$this->recharge_wallet_addr = $recharge_wallet_addr;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt($created_at): void
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
}
|
||||
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updated_at;
|
||||
}
|
||||
|
||||
public function setUpdatedAt($updated_at): void
|
||||
{
|
||||
$this->updated_at = $updated_at;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,235 @@
|
||||
<?php
|
||||
namespace App\Bean\Model\Api\Wallet;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
use App\Models\Api\Wallet\CustomerWalletCurrencyModel;
|
||||
use App\Models\Api\Wallet\CustomerWalletBalanceTransactionModel;
|
||||
|
||||
class CustomerWalletBalanceTransactionBean extends BaseBean
|
||||
{
|
||||
protected $id;
|
||||
protected $type;
|
||||
protected $status = CustomerWalletBalanceTransactionModel::STATUS_WAIT;
|
||||
protected $wallet_id;
|
||||
protected $uid;
|
||||
protected $currency_code = CustomerWalletCurrencyModel::CODE_USDT_TRC20;
|
||||
protected $amount = 0;
|
||||
protected $fee_amount = 0;
|
||||
protected $before_total_amount;
|
||||
protected $after_total_amount;
|
||||
protected $source_params;
|
||||
protected $remark;
|
||||
protected $target_uid;
|
||||
protected $target_post_order_id;
|
||||
protected $target_post_order_dispute_id;
|
||||
protected $sign;
|
||||
protected $callback_time;
|
||||
protected $delay_payment_time;
|
||||
protected $created_at;
|
||||
protected $updated_at;
|
||||
|
||||
public function getFeeAmount(): int
|
||||
{
|
||||
return $this->fee_amount;
|
||||
}
|
||||
|
||||
public function setFeeAmount(int $fee_amount): void
|
||||
{
|
||||
$this->fee_amount = $fee_amount;
|
||||
}
|
||||
|
||||
|
||||
public function getTargetPostOrderDisputeId()
|
||||
{
|
||||
return $this->target_post_order_dispute_id;
|
||||
}
|
||||
|
||||
public function setTargetPostOrderDisputeId($target_post_order_dispute_id): void
|
||||
{
|
||||
$this->target_post_order_dispute_id = $target_post_order_dispute_id;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus(int $status): void
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function getWalletId()
|
||||
{
|
||||
return $this->wallet_id;
|
||||
}
|
||||
|
||||
public function setWalletId($wallet_id): void
|
||||
{
|
||||
$this->wallet_id = $wallet_id;
|
||||
}
|
||||
|
||||
public function getUid()
|
||||
{
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
public function setUid($uid): void
|
||||
{
|
||||
$this->uid = $uid;
|
||||
}
|
||||
|
||||
public function getCurrencyCode(): string
|
||||
{
|
||||
return $this->currency_code;
|
||||
}
|
||||
|
||||
public function setCurrencyCode(string $currency_code): void
|
||||
{
|
||||
$this->currency_code = $currency_code;
|
||||
}
|
||||
|
||||
public function getAmount(): int
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function setAmount(int $amount): void
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
public function getBeforeTotalAmount()
|
||||
{
|
||||
return $this->before_total_amount;
|
||||
}
|
||||
|
||||
public function setBeforeTotalAmount($before_total_amount): void
|
||||
{
|
||||
$this->before_total_amount = $before_total_amount;
|
||||
}
|
||||
|
||||
public function getAfterTotalAmount()
|
||||
{
|
||||
return $this->after_total_amount;
|
||||
}
|
||||
|
||||
public function setAfterTotalAmount($after_total_amount): void
|
||||
{
|
||||
$this->after_total_amount = $after_total_amount;
|
||||
}
|
||||
|
||||
public function getSourceParams()
|
||||
{
|
||||
return $this->source_params;
|
||||
}
|
||||
|
||||
public function setSourceParams($source_params): void
|
||||
{
|
||||
$this->source_params = $source_params;
|
||||
}
|
||||
|
||||
public function getRemark()
|
||||
{
|
||||
return $this->remark;
|
||||
}
|
||||
|
||||
public function setRemark($remark): void
|
||||
{
|
||||
$this->remark = $remark;
|
||||
}
|
||||
|
||||
public function getTargetUid()
|
||||
{
|
||||
return $this->target_uid;
|
||||
}
|
||||
|
||||
public function setTargetUid($target_uid): void
|
||||
{
|
||||
$this->target_uid = $target_uid;
|
||||
}
|
||||
|
||||
public function getTargetPostOrderId()
|
||||
{
|
||||
return $this->target_post_order_id;
|
||||
}
|
||||
|
||||
public function setTargetPostOrderId($target_post_order_id): void
|
||||
{
|
||||
$this->target_post_order_id = $target_post_order_id;
|
||||
}
|
||||
|
||||
public function getSign()
|
||||
{
|
||||
return $this->sign;
|
||||
}
|
||||
|
||||
public function setSign($sign): void
|
||||
{
|
||||
$this->sign = $sign;
|
||||
}
|
||||
|
||||
public function getCallbackTime()
|
||||
{
|
||||
return $this->callback_time;
|
||||
}
|
||||
|
||||
public function setCallbackTime($callback_time): void
|
||||
{
|
||||
$this->callback_time = $callback_time;
|
||||
}
|
||||
|
||||
public function getDelayPaymentTime()
|
||||
{
|
||||
return $this->delay_payment_time;
|
||||
}
|
||||
|
||||
public function setDelayPaymentTime($delay_payment_time): void
|
||||
{
|
||||
$this->delay_payment_time = $delay_payment_time;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt($created_at): void
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
}
|
||||
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updated_at;
|
||||
}
|
||||
|
||||
public function setUpdatedAt($updated_at): void
|
||||
{
|
||||
$this->updated_at = $updated_at;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
13
app/Bean/Model/Base/BaseBean.php
Normal file
13
app/Bean/Model/Base/BaseBean.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace App\Bean\Model\Base;
|
||||
|
||||
use EasySwoole\Spl\SplBean;
|
||||
|
||||
abstract class BaseBean extends SplBean
|
||||
{
|
||||
function toArrayNotNull(): array
|
||||
{
|
||||
return $this->toArray(self::FILTER_NOT_NULL);
|
||||
}
|
||||
|
||||
}
|
||||
9
app/Bean/Model/Base/TmplBean.php
Normal file
9
app/Bean/Model/Base/TmplBean.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace App\Bean\Model\Base;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class TmplBean extends BaseBean
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,305 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bean\Model\Wallet\Platform;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class WalletPlatformBalanceTransactionBean extends BaseBean
|
||||
{
|
||||
|
||||
protected $id;
|
||||
protected $sn;
|
||||
protected $type;
|
||||
protected $status;
|
||||
protected $platform_id;
|
||||
protected $balance_id;
|
||||
protected $currency_code;
|
||||
protected $block_transaction_id;
|
||||
protected $bind_wallet_address_id;
|
||||
protected $bind_wallet_address;
|
||||
protected $from_wallet_address_id;
|
||||
protected $from_wallet_address;
|
||||
protected $to_wallet_address_id;
|
||||
protected $to_wallet_address;
|
||||
|
||||
protected $uid;
|
||||
protected $amount = 0;
|
||||
protected $fee_amount = 0;
|
||||
protected $before_total_amount;
|
||||
protected $after_total_amount;
|
||||
protected $remark;
|
||||
protected $source_wallet_id;
|
||||
protected $callback_time;
|
||||
protected $callback_wallet_address_transaction_id;
|
||||
protected $is_notify;
|
||||
protected $created_at;
|
||||
protected $updated_at;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getSn()
|
||||
{
|
||||
return $this->sn;
|
||||
}
|
||||
|
||||
public function setSn($sn): void
|
||||
{
|
||||
$this->sn = $sn;
|
||||
}
|
||||
|
||||
public function getBindWalletAddressId()
|
||||
{
|
||||
return $this->bind_wallet_address_id;
|
||||
}
|
||||
|
||||
public function setBindWalletAddressId($bind_wallet_address_id): void
|
||||
{
|
||||
$this->bind_wallet_address_id = $bind_wallet_address_id;
|
||||
}
|
||||
|
||||
public function getBindWalletAddress()
|
||||
{
|
||||
return $this->bind_wallet_address;
|
||||
}
|
||||
|
||||
public function setBindWalletAddress($bind_wallet_address): void
|
||||
{
|
||||
$this->bind_wallet_address = $bind_wallet_address;
|
||||
}
|
||||
|
||||
public function getFromWalletAddressId()
|
||||
{
|
||||
return $this->from_wallet_address_id;
|
||||
}
|
||||
|
||||
public function setFromWalletAddressId($from_wallet_address_id): void
|
||||
{
|
||||
$this->from_wallet_address_id = $from_wallet_address_id;
|
||||
}
|
||||
|
||||
public function getFromWalletAddress()
|
||||
{
|
||||
return $this->from_wallet_address;
|
||||
}
|
||||
|
||||
public function setFromWalletAddress($from_wallet_address): void
|
||||
{
|
||||
$this->from_wallet_address = $from_wallet_address;
|
||||
}
|
||||
|
||||
public function getToWalletAddressId()
|
||||
{
|
||||
return $this->to_wallet_address_id;
|
||||
}
|
||||
|
||||
public function setToWalletAddressId($to_wallet_address_id): void
|
||||
{
|
||||
$this->to_wallet_address_id = $to_wallet_address_id;
|
||||
}
|
||||
|
||||
public function getToWalletAddress()
|
||||
{
|
||||
return $this->to_wallet_address;
|
||||
}
|
||||
|
||||
public function setToWalletAddress($to_wallet_address): void
|
||||
{
|
||||
$this->to_wallet_address = $to_wallet_address;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getCallbackWalletAddressTransactionId()
|
||||
{
|
||||
return $this->callback_wallet_address_transaction_id;
|
||||
}
|
||||
|
||||
public function setCallbackWalletAddressTransactionId($callback_wallet_address_transaction_id): void
|
||||
{
|
||||
$this->callback_wallet_address_transaction_id = $callback_wallet_address_transaction_id;
|
||||
}
|
||||
|
||||
public function getUid()
|
||||
{
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
public function setUid($uid): void
|
||||
{
|
||||
$this->uid = $uid;
|
||||
}
|
||||
|
||||
|
||||
public function getSourceWalletId()
|
||||
{
|
||||
return $this->source_wallet_id;
|
||||
}
|
||||
|
||||
public function setSourceWalletId($source_wallet_id): void
|
||||
{
|
||||
$this->source_wallet_id = $source_wallet_id;
|
||||
}
|
||||
|
||||
public function getBalanceId()
|
||||
{
|
||||
return $this->balance_id;
|
||||
}
|
||||
|
||||
public function setBalanceId($balance_id): void
|
||||
{
|
||||
$this->balance_id = $balance_id;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus($status): void
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function getPlatformId()
|
||||
{
|
||||
return $this->platform_id;
|
||||
}
|
||||
|
||||
public function setPlatformId($platform_id): void
|
||||
{
|
||||
$this->platform_id = $platform_id;
|
||||
}
|
||||
|
||||
public function getCurrencyCode()
|
||||
{
|
||||
return $this->currency_code;
|
||||
}
|
||||
|
||||
public function setCurrencyCode($currency_code): void
|
||||
{
|
||||
$this->currency_code = $currency_code;
|
||||
}
|
||||
|
||||
public function getBlockTransactionId()
|
||||
{
|
||||
return $this->block_transaction_id;
|
||||
}
|
||||
|
||||
public function setBlockTransactionId($block_transaction_id): void
|
||||
{
|
||||
$this->block_transaction_id = $block_transaction_id;
|
||||
}
|
||||
|
||||
|
||||
public function getFeeAmount()
|
||||
{
|
||||
return $this->fee_amount;
|
||||
}
|
||||
|
||||
public function setFeeAmount($fee_amount): void
|
||||
{
|
||||
$this->fee_amount = $fee_amount;
|
||||
}
|
||||
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function setAmount($amount): void
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
|
||||
public function getBeforeTotalAmount()
|
||||
{
|
||||
return $this->before_total_amount;
|
||||
}
|
||||
|
||||
public function setBeforeTotalAmount($before_total_amount): void
|
||||
{
|
||||
$this->before_total_amount = $before_total_amount;
|
||||
}
|
||||
|
||||
public function getAfterTotalAmount()
|
||||
{
|
||||
return $this->after_total_amount;
|
||||
}
|
||||
|
||||
public function setAfterTotalAmount($after_total_amount): void
|
||||
{
|
||||
$this->after_total_amount = $after_total_amount;
|
||||
}
|
||||
|
||||
public function getRemark()
|
||||
{
|
||||
return $this->remark;
|
||||
}
|
||||
|
||||
public function setRemark($remark): void
|
||||
{
|
||||
$this->remark = $remark;
|
||||
}
|
||||
|
||||
public function getCallbackTime()
|
||||
{
|
||||
return $this->callback_time;
|
||||
}
|
||||
|
||||
public function setCallbackTime($callback_time): void
|
||||
{
|
||||
$this->callback_time = $callback_time;
|
||||
}
|
||||
|
||||
|
||||
public function getIsNotify()
|
||||
{
|
||||
return $this->is_notify;
|
||||
}
|
||||
|
||||
public function setIsNotify($is_notify): void
|
||||
{
|
||||
$this->is_notify = $is_notify;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt($created_at): void
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
}
|
||||
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updated_at;
|
||||
}
|
||||
|
||||
public function setUpdatedAt($updated_at): void
|
||||
{
|
||||
$this->updated_at = $updated_at;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
90
app/Bean/Model/Wallet/Platform/WalletPlatformBean.php
Normal file
90
app/Bean/Model/Wallet/Platform/WalletPlatformBean.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bean\Model\Wallet\Platform;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class WalletPlatformBean extends BaseBean
|
||||
{
|
||||
|
||||
protected $id;
|
||||
protected $name;
|
||||
protected $code;
|
||||
protected $appid;
|
||||
protected $secret;
|
||||
protected $notify_ip;
|
||||
protected $created_at;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode($code): void
|
||||
{
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
public function getAppid()
|
||||
{
|
||||
return $this->appid;
|
||||
}
|
||||
|
||||
public function setAppid($appid): void
|
||||
{
|
||||
$this->appid = $appid;
|
||||
}
|
||||
|
||||
public function getSecret()
|
||||
{
|
||||
return $this->secret;
|
||||
}
|
||||
|
||||
public function setSecret($secret): void
|
||||
{
|
||||
$this->secret = $secret;
|
||||
}
|
||||
|
||||
public function getNotifyIp()
|
||||
{
|
||||
return $this->notify_ip;
|
||||
}
|
||||
|
||||
public function setNotifyIp($notify_ip): void
|
||||
{
|
||||
$this->notify_ip = $notify_ip;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt($created_at): void
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
79
app/Bean/Model/Wallet/Tron/WalletTronBlockBean.php
Normal file
79
app/Bean/Model/Wallet/Tron/WalletTronBlockBean.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bean\Model\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class WalletTronBlockBean extends BaseBean
|
||||
{
|
||||
|
||||
protected $id;
|
||||
protected $status;
|
||||
protected $block_id;
|
||||
protected $block_num;
|
||||
protected $block_timestamp;
|
||||
protected $created_at;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus($status): void
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function getBlockId()
|
||||
{
|
||||
return $this->block_id;
|
||||
}
|
||||
|
||||
public function setBlockId($block_id): void
|
||||
{
|
||||
$this->block_id = $block_id;
|
||||
}
|
||||
|
||||
public function getBlockNum()
|
||||
{
|
||||
return $this->block_num;
|
||||
}
|
||||
|
||||
public function setBlockNum($block_num): void
|
||||
{
|
||||
$this->block_num = $block_num;
|
||||
}
|
||||
|
||||
public function getBlockTimestamp()
|
||||
{
|
||||
return $this->block_timestamp;
|
||||
}
|
||||
|
||||
public function setBlockTimestamp($block_timestamp): void
|
||||
{
|
||||
$this->block_timestamp = $block_timestamp;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt($created_at): void
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
124
app/Bean/Model/Wallet/Wallet/WalletAddressBean.php
Normal file
124
app/Bean/Model/Wallet/Wallet/WalletAddressBean.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bean\Model\Wallet\Wallet;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class WalletAddressBean extends BaseBean
|
||||
{
|
||||
|
||||
protected $id;
|
||||
protected $use_status;
|
||||
protected $currency_code;
|
||||
|
||||
protected $balance;
|
||||
protected $address_hex;
|
||||
protected $address_base58;
|
||||
protected $private_key;
|
||||
protected $remark;
|
||||
protected $created_at;
|
||||
protected $updated_at;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getUseStatus()
|
||||
{
|
||||
return $this->use_status;
|
||||
}
|
||||
|
||||
public function setUseStatus($use_status): void
|
||||
{
|
||||
$this->use_status = $use_status;
|
||||
}
|
||||
|
||||
public function getCurrencyCode()
|
||||
{
|
||||
return $this->currency_code;
|
||||
}
|
||||
|
||||
public function setCurrencyCode($currency_code): void
|
||||
{
|
||||
$this->currency_code = $currency_code;
|
||||
}
|
||||
|
||||
public function getBalance()
|
||||
{
|
||||
return $this->balance;
|
||||
}
|
||||
|
||||
public function setBalance($balance): void
|
||||
{
|
||||
$this->balance = $balance;
|
||||
}
|
||||
|
||||
public function getAddressHex()
|
||||
{
|
||||
return $this->address_hex;
|
||||
}
|
||||
|
||||
public function setAddressHex($address_hex): void
|
||||
{
|
||||
$this->address_hex = $address_hex;
|
||||
}
|
||||
|
||||
public function getAddressBase58()
|
||||
{
|
||||
return $this->address_base58;
|
||||
}
|
||||
|
||||
public function setAddressBase58($address_base58): void
|
||||
{
|
||||
$this->address_base58 = $address_base58;
|
||||
}
|
||||
|
||||
public function getPrivateKey()
|
||||
{
|
||||
return $this->private_key;
|
||||
}
|
||||
|
||||
public function setPrivateKey($private_key): void
|
||||
{
|
||||
$this->private_key = $private_key;
|
||||
}
|
||||
|
||||
public function getRemark()
|
||||
{
|
||||
return $this->remark;
|
||||
}
|
||||
|
||||
public function setRemark($remark): void
|
||||
{
|
||||
$this->remark = $remark;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt($created_at): void
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
}
|
||||
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updated_at;
|
||||
}
|
||||
|
||||
public function setUpdatedAt($updated_at): void
|
||||
{
|
||||
$this->updated_at = $updated_at;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
169
app/Bean/Model/Wallet/Wallet/WalletAddressTransactionBean.php
Normal file
169
app/Bean/Model/Wallet/Wallet/WalletAddressTransactionBean.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bean\Model\Wallet\Wallet;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class WalletAddressTransactionBean extends BaseBean
|
||||
{
|
||||
|
||||
protected $id;
|
||||
protected $currency_code;
|
||||
protected $type;
|
||||
protected $wallet_address_id;
|
||||
protected $amount;
|
||||
protected $block_transaction_id;
|
||||
protected $block_number;
|
||||
protected $block_event_name;
|
||||
protected $block_from_address;
|
||||
protected $block_to_address;
|
||||
protected $block_value;
|
||||
protected $block_timestamp;
|
||||
protected $created_at;
|
||||
protected $is_notify;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getCurrencyCode()
|
||||
{
|
||||
return $this->currency_code;
|
||||
}
|
||||
|
||||
public function setCurrencyCode($currency_code): void
|
||||
{
|
||||
$this->currency_code = $currency_code;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function getWalletAddressId()
|
||||
{
|
||||
return $this->wallet_address_id;
|
||||
}
|
||||
|
||||
public function setWalletAddressId($wallet_address_id): void
|
||||
{
|
||||
$this->wallet_address_id = $wallet_address_id;
|
||||
}
|
||||
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function setAmount($amount): void
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
public function getBlockTransactionId()
|
||||
{
|
||||
return $this->block_transaction_id;
|
||||
}
|
||||
|
||||
public function setBlockTransactionId($block_transaction_id): void
|
||||
{
|
||||
$this->block_transaction_id = $block_transaction_id;
|
||||
}
|
||||
|
||||
public function getBlockNumber()
|
||||
{
|
||||
return $this->block_number;
|
||||
}
|
||||
|
||||
public function setBlockNumber($block_number): void
|
||||
{
|
||||
$this->block_number = $block_number;
|
||||
}
|
||||
|
||||
public function getBlockEventName()
|
||||
{
|
||||
return $this->block_event_name;
|
||||
}
|
||||
|
||||
public function setBlockEventName($block_event_name): void
|
||||
{
|
||||
$this->block_event_name = $block_event_name;
|
||||
}
|
||||
|
||||
public function getBlockFromAddress()
|
||||
{
|
||||
return $this->block_from_address;
|
||||
}
|
||||
|
||||
public function setBlockFromAddress($block_from_address): void
|
||||
{
|
||||
$this->block_from_address = $block_from_address;
|
||||
}
|
||||
|
||||
public function getBlockToAddress()
|
||||
{
|
||||
return $this->block_to_address;
|
||||
}
|
||||
|
||||
public function setBlockToAddress($block_to_address): void
|
||||
{
|
||||
$this->block_to_address = $block_to_address;
|
||||
}
|
||||
|
||||
public function getBlockValue()
|
||||
{
|
||||
return $this->block_value;
|
||||
}
|
||||
|
||||
public function setBlockValue($block_value): void
|
||||
{
|
||||
$this->block_value = $block_value;
|
||||
}
|
||||
|
||||
public function getBlockTimestamp()
|
||||
{
|
||||
return $this->block_timestamp;
|
||||
}
|
||||
|
||||
public function setBlockTimestamp($block_timestamp): void
|
||||
{
|
||||
$this->block_timestamp = $block_timestamp;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt($created_at): void
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
}
|
||||
|
||||
public function getIsNotify()
|
||||
{
|
||||
return $this->is_notify;
|
||||
}
|
||||
|
||||
public function setIsNotify($is_notify): void
|
||||
{
|
||||
$this->is_notify = $is_notify;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
79
app/Bean/Model/Wallet/Wallet/WalletPlatformBindBean.php
Normal file
79
app/Bean/Model/Wallet/Wallet/WalletPlatformBindBean.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bean\Model\Wallet\Wallet;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class WalletPlatformBindBean extends BaseBean
|
||||
{
|
||||
|
||||
protected $id;
|
||||
protected $platform_id;
|
||||
protected $wallet_address_id;
|
||||
protected $currency_code;
|
||||
protected $uid;
|
||||
protected $created_at;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getPlatformId()
|
||||
{
|
||||
return $this->platform_id;
|
||||
}
|
||||
|
||||
public function setPlatformId($platform_id): void
|
||||
{
|
||||
$this->platform_id = $platform_id;
|
||||
}
|
||||
|
||||
public function getWalletAddressId()
|
||||
{
|
||||
return $this->wallet_address_id;
|
||||
}
|
||||
|
||||
public function setWalletAddressId($wallet_address_id): void
|
||||
{
|
||||
$this->wallet_address_id = $wallet_address_id;
|
||||
}
|
||||
|
||||
public function getCurrencyCode()
|
||||
{
|
||||
return $this->currency_code;
|
||||
}
|
||||
|
||||
public function setCurrencyCode($currency_code): void
|
||||
{
|
||||
$this->currency_code = $currency_code;
|
||||
}
|
||||
|
||||
public function getUid()
|
||||
{
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
public function setUid($uid): void
|
||||
{
|
||||
$this->uid = $uid;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt($created_at): void
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
37
app/Bean/Queue/Api/QueueAddPostBean.php
Normal file
37
app/Bean/Queue/Api/QueueAddPostBean.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace App\Bean\Queue\Api;
|
||||
|
||||
use App\Bean\Queue\QueueBaseBean;
|
||||
|
||||
class QueueAddPostBean extends QueueBaseBean
|
||||
{
|
||||
const QUEUE_NAME = 'queue_add_post';
|
||||
|
||||
protected $id;
|
||||
protected $type;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
41
app/Bean/Queue/Api/QueueUserActiveStatusBean.php
Normal file
41
app/Bean/Queue/Api/QueueUserActiveStatusBean.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace App\Bean\Queue\Api;
|
||||
|
||||
use App\Bean\Queue\QueueBaseBean;
|
||||
|
||||
class QueueUserActiveStatusBean extends QueueBaseBean
|
||||
{
|
||||
const QUEUE_NAME = 'queue_user_active_status';
|
||||
|
||||
protected $uid;
|
||||
protected $queue_created_at;
|
||||
|
||||
public function getUid()
|
||||
{
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
public function setUid($uid): void
|
||||
{
|
||||
$this->uid = $uid;
|
||||
}
|
||||
|
||||
public function getQueueCreatedAt()
|
||||
{
|
||||
return $this->queue_created_at;
|
||||
}
|
||||
|
||||
public function setQueueCreatedAt($queue_created_at): void
|
||||
{
|
||||
$this->queue_created_at = $queue_created_at;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
35
app/Bean/Queue/QueueBaseBean.php
Normal file
35
app/Bean/Queue/QueueBaseBean.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace App\Bean\Queue;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class QueueBaseBean extends BaseBean
|
||||
{
|
||||
protected $try_limt = 3;
|
||||
protected $try_times = 0;
|
||||
|
||||
public function IncrTryTimes($num = 1): void
|
||||
{
|
||||
$this->try_times += $num;
|
||||
}
|
||||
|
||||
public function checkTryTimes(): bool
|
||||
{
|
||||
if($this->try_times >= $this->try_limt) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getTryTimes(): int
|
||||
{
|
||||
return $this->try_times;
|
||||
}
|
||||
|
||||
function getDelaySeconds($seconds = 30): int
|
||||
{
|
||||
return $seconds * $this->try_times;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
123
app/Bean/Queue/Wallet/QueueEventBean.php
Normal file
123
app/Bean/Queue/Wallet/QueueEventBean.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
namespace App\Bean\Queue\Wallet;
|
||||
|
||||
use App\Bean\Queue\QueueBaseBean;
|
||||
use App\Bean\Sdk\Wallet\Tron\EventResultBean;
|
||||
use App\Bean\Sdk\Wallet\Tron\EventResultTypeBean;
|
||||
|
||||
class QueueEventBean extends QueueBaseBean
|
||||
{
|
||||
const QUEUE_NAME = 'queue_wallet_address_transaction';
|
||||
protected $block_number;
|
||||
protected $block_timestamp;
|
||||
protected $caller_contract_address;
|
||||
protected $contract_address;
|
||||
protected $event;
|
||||
protected $event_index;
|
||||
protected $event_name;
|
||||
protected EventResultBean $result;
|
||||
protected EventResultTypeBean $result_type;
|
||||
protected $transaction_id;
|
||||
|
||||
public function getBlockNumber()
|
||||
{
|
||||
return $this->block_number;
|
||||
}
|
||||
|
||||
public function setBlockNumber($block_number): void
|
||||
{
|
||||
$this->block_number = $block_number;
|
||||
}
|
||||
|
||||
public function getBlockTimestamp()
|
||||
{
|
||||
return $this->block_timestamp;
|
||||
}
|
||||
|
||||
public function setBlockTimestamp($block_timestamp): void
|
||||
{
|
||||
$this->block_timestamp = $block_timestamp;
|
||||
}
|
||||
|
||||
public function getCallerContractAddress()
|
||||
{
|
||||
return $this->caller_contract_address;
|
||||
}
|
||||
|
||||
public function setCallerContractAddress($caller_contract_address): void
|
||||
{
|
||||
$this->caller_contract_address = $caller_contract_address;
|
||||
}
|
||||
|
||||
public function getContractAddress()
|
||||
{
|
||||
return $this->contract_address;
|
||||
}
|
||||
|
||||
public function setContractAddress($contract_address): void
|
||||
{
|
||||
$this->contract_address = $contract_address;
|
||||
}
|
||||
|
||||
public function getEvent()
|
||||
{
|
||||
return $this->event;
|
||||
}
|
||||
|
||||
public function setEvent($event): void
|
||||
{
|
||||
$this->event = $event;
|
||||
}
|
||||
|
||||
public function getEventIndex()
|
||||
{
|
||||
return $this->event_index;
|
||||
}
|
||||
|
||||
public function setEventIndex($event_index): void
|
||||
{
|
||||
$this->event_index = $event_index;
|
||||
}
|
||||
|
||||
public function getEventName()
|
||||
{
|
||||
return $this->event_name;
|
||||
}
|
||||
|
||||
public function setEventName($event_name): void
|
||||
{
|
||||
$this->event_name = $event_name;
|
||||
}
|
||||
|
||||
public function getResult(): EventResultBean
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
public function setResult(EventResultBean $result): void
|
||||
{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
public function getResultType(): EventResultTypeBean
|
||||
{
|
||||
return $this->result_type;
|
||||
}
|
||||
|
||||
public function setResultType(EventResultTypeBean $result_type): void
|
||||
{
|
||||
$this->result_type = $result_type;
|
||||
}
|
||||
|
||||
public function getTransactionId()
|
||||
{
|
||||
return $this->transaction_id;
|
||||
}
|
||||
|
||||
public function setTransactionId($transaction_id): void
|
||||
{
|
||||
$this->transaction_id = $transaction_id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
84
app/Bean/Queue/Wallet/QueueNotifyToPlatformBean.php
Normal file
84
app/Bean/Queue/Wallet/QueueNotifyToPlatformBean.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bean\Queue\Wallet;
|
||||
|
||||
use App\Bean\Queue\QueueBaseBean;
|
||||
|
||||
class QueueNotifyToPlatformBean extends QueueBaseBean
|
||||
{
|
||||
const QUEUE_NAME = 'queue_notify_to_platform';
|
||||
|
||||
const TYPE_WITHDRAW = 1;
|
||||
|
||||
protected $type;
|
||||
protected $sn;
|
||||
protected $amount;
|
||||
protected $currency_code;
|
||||
protected $status;
|
||||
protected $platform_id;
|
||||
|
||||
public function getPlatformId()
|
||||
{
|
||||
return $this->platform_id;
|
||||
}
|
||||
|
||||
public function setPlatformId($platform_id): void
|
||||
{
|
||||
$this->platform_id = $platform_id;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function getSn()
|
||||
{
|
||||
return $this->sn;
|
||||
}
|
||||
|
||||
public function setSn($sn): void
|
||||
{
|
||||
$this->sn = $sn;
|
||||
}
|
||||
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function setAmount($amount): void
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
public function getCurrencyCode()
|
||||
{
|
||||
return $this->currency_code;
|
||||
}
|
||||
|
||||
public function setCurrencyCode($currency_code): void
|
||||
{
|
||||
$this->currency_code = $currency_code;
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus($status): void
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
35
app/Bean/Queue/Wallet/QueueWalletBlockBean.php
Normal file
35
app/Bean/Queue/Wallet/QueueWalletBlockBean.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace App\Bean\Queue\Wallet;
|
||||
|
||||
use App\Bean\Queue\QueueBaseBean;
|
||||
|
||||
class QueueWalletBlockBean extends QueueBaseBean
|
||||
{
|
||||
const QUEUE_NAME = 'queue_wallet_block';
|
||||
|
||||
protected $id;
|
||||
protected $block_number;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getBlockNumber()
|
||||
{
|
||||
return $this->block_number;
|
||||
}
|
||||
|
||||
public function setBlockNumber($block_number): void
|
||||
{
|
||||
$this->block_number = $block_number;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
25
app/Bean/Queue/Wallet/QueueWalletBlockTransactionBean.php
Normal file
25
app/Bean/Queue/Wallet/QueueWalletBlockTransactionBean.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bean\Queue\Wallet;
|
||||
|
||||
use App\Bean\Queue\QueueBaseBean;
|
||||
|
||||
class QueueWalletBlockTransactionBean extends QueueBaseBean
|
||||
{
|
||||
const QUEUE_NAME = 'queue_wallet_block_transaction';
|
||||
|
||||
protected array $data = [];
|
||||
|
||||
public function getData(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function setData(array $data): void
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
69
app/Bean/Queue/Wallet/QueueWalletPlatformTransactionBean.php
Normal file
69
app/Bean/Queue/Wallet/QueueWalletPlatformTransactionBean.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bean\Queue\Wallet;
|
||||
|
||||
use App\Bean\Queue\QueueBaseBean;
|
||||
|
||||
class QueueWalletPlatformTransactionBean extends QueueBaseBean
|
||||
{
|
||||
const QUEUE_NAME = 'queue_wallet_platform_transaction';
|
||||
|
||||
protected $wallet_id;
|
||||
protected $wallet_transaction_id;
|
||||
protected $block_transaction_id;
|
||||
protected $amount;
|
||||
protected $type;
|
||||
|
||||
public function getWalletId()
|
||||
{
|
||||
return $this->wallet_id;
|
||||
}
|
||||
|
||||
public function setWalletId($wallet_id): void
|
||||
{
|
||||
$this->wallet_id = $wallet_id;
|
||||
}
|
||||
|
||||
public function getWalletTransactionId()
|
||||
{
|
||||
return $this->wallet_transaction_id;
|
||||
}
|
||||
|
||||
public function setWalletTransactionId($wallet_transaction_id): void
|
||||
{
|
||||
$this->wallet_transaction_id = $wallet_transaction_id;
|
||||
}
|
||||
|
||||
public function getBlockTransactionId()
|
||||
{
|
||||
return $this->block_transaction_id;
|
||||
}
|
||||
|
||||
public function setBlockTransactionId($block_transaction_id): void
|
||||
{
|
||||
$this->block_transaction_id = $block_transaction_id;
|
||||
}
|
||||
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function setAmount($amount): void
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace App\Bean\Queue\Wallet;
|
||||
|
||||
use App\Bean\Queue\QueueBaseBean;
|
||||
|
||||
class QueueWalletPlatformWithdrawTransferBean extends QueueBaseBean
|
||||
{
|
||||
const QUEUE_NAME = 'queue_wallet_platform_withdraw_transfer';
|
||||
|
||||
protected $transaction_id;
|
||||
|
||||
public function getTransactionId()
|
||||
{
|
||||
return $this->transaction_id;
|
||||
}
|
||||
|
||||
public function setTransactionId($transaction_id): void
|
||||
{
|
||||
$this->transaction_id = $transaction_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
88
app/Bean/Sdk/Wallet/Tron/AccountTransactionBean.php
Normal file
88
app/Bean/Sdk/Wallet/Tron/AccountTransactionBean.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class AccountTransactionBean extends BaseBean
|
||||
{
|
||||
protected $transaction_id;
|
||||
protected AccountTransactionTokenInfoBean $token_info;
|
||||
protected $block_timestamp;
|
||||
protected $from;
|
||||
protected $to;
|
||||
protected $type;
|
||||
protected $value;
|
||||
|
||||
public function getTransactionId()
|
||||
{
|
||||
return $this->transaction_id;
|
||||
}
|
||||
|
||||
public function setTransactionId($transaction_id): void
|
||||
{
|
||||
$this->transaction_id = $transaction_id;
|
||||
}
|
||||
|
||||
public function getTokenInfo(): AccountTransactionTokenInfoBean
|
||||
{
|
||||
return $this->token_info;
|
||||
}
|
||||
|
||||
public function setTokenInfo(AccountTransactionTokenInfoBean $token_info): void
|
||||
{
|
||||
$this->token_info = $token_info;
|
||||
}
|
||||
|
||||
public function getBlockTimestamp()
|
||||
{
|
||||
return $this->block_timestamp;
|
||||
}
|
||||
|
||||
public function setBlockTimestamp($block_timestamp): void
|
||||
{
|
||||
$this->block_timestamp = $block_timestamp;
|
||||
}
|
||||
|
||||
public function getFrom()
|
||||
{
|
||||
return $this->from;
|
||||
}
|
||||
|
||||
public function setFrom($from): void
|
||||
{
|
||||
$this->from = $from;
|
||||
}
|
||||
|
||||
public function getTo()
|
||||
{
|
||||
return $this->to;
|
||||
}
|
||||
|
||||
public function setTo($to): void
|
||||
{
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value): void
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
55
app/Bean/Sdk/Wallet/Tron/AccountTransactionTokenInfoBean.php
Normal file
55
app/Bean/Sdk/Wallet/Tron/AccountTransactionTokenInfoBean.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class AccountTransactionTokenInfoBean extends BaseBean
|
||||
{
|
||||
protected $symbol;
|
||||
protected $address;
|
||||
protected $decimals;
|
||||
protected $name;
|
||||
|
||||
public function getSymbol()
|
||||
{
|
||||
return $this->symbol;
|
||||
}
|
||||
|
||||
public function setSymbol($symbol): void
|
||||
{
|
||||
$this->symbol = $symbol;
|
||||
}
|
||||
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function setAddress($address): void
|
||||
{
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
public function getDecimals()
|
||||
{
|
||||
return $this->decimals;
|
||||
}
|
||||
|
||||
public function setDecimals($decimals): void
|
||||
{
|
||||
$this->decimals = $decimals;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
119
app/Bean/Sdk/Wallet/Tron/BlockEventBean.php
Normal file
119
app/Bean/Sdk/Wallet/Tron/BlockEventBean.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class BlockEventBean extends BaseBean
|
||||
{
|
||||
protected $block_number;
|
||||
protected $block_timestamp;
|
||||
protected $caller_contract_address;
|
||||
protected $contract_address;
|
||||
protected $event;
|
||||
protected $event_index;
|
||||
protected $event_name;
|
||||
protected BlockEventResultBean $result;
|
||||
protected $result_type;
|
||||
protected $transaction_id;
|
||||
|
||||
public function getBlockNumber()
|
||||
{
|
||||
return $this->block_number;
|
||||
}
|
||||
|
||||
public function setBlockNumber($block_number): void
|
||||
{
|
||||
$this->block_number = $block_number;
|
||||
}
|
||||
|
||||
public function getBlockTimestamp()
|
||||
{
|
||||
return $this->block_timestamp;
|
||||
}
|
||||
|
||||
public function setBlockTimestamp($block_timestamp): void
|
||||
{
|
||||
$this->block_timestamp = $block_timestamp;
|
||||
}
|
||||
|
||||
public function getCallerContractAddress()
|
||||
{
|
||||
return $this->caller_contract_address;
|
||||
}
|
||||
|
||||
public function setCallerContractAddress($caller_contract_address): void
|
||||
{
|
||||
$this->caller_contract_address = $caller_contract_address;
|
||||
}
|
||||
|
||||
public function getContractAddress()
|
||||
{
|
||||
return $this->contract_address;
|
||||
}
|
||||
|
||||
public function setContractAddress($contract_address): void
|
||||
{
|
||||
$this->contract_address = $contract_address;
|
||||
}
|
||||
|
||||
public function getEvent()
|
||||
{
|
||||
return $this->event;
|
||||
}
|
||||
|
||||
public function setEvent($event): void
|
||||
{
|
||||
$this->event = $event;
|
||||
}
|
||||
|
||||
public function getEventIndex()
|
||||
{
|
||||
return $this->event_index;
|
||||
}
|
||||
|
||||
public function setEventIndex($event_index): void
|
||||
{
|
||||
$this->event_index = $event_index;
|
||||
}
|
||||
|
||||
public function getEventName()
|
||||
{
|
||||
return $this->event_name;
|
||||
}
|
||||
|
||||
public function setEventName($event_name): void
|
||||
{
|
||||
$this->event_name = $event_name;
|
||||
}
|
||||
|
||||
public function getResult()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
public function setResult($result): void
|
||||
{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
public function getResultType()
|
||||
{
|
||||
return $this->result_type;
|
||||
}
|
||||
|
||||
public function setResultType($result_type): void
|
||||
{
|
||||
$this->result_type = $result_type;
|
||||
}
|
||||
|
||||
public function getTransactionId()
|
||||
{
|
||||
return $this->transaction_id;
|
||||
}
|
||||
|
||||
public function setTransactionId($transaction_id): void
|
||||
{
|
||||
$this->transaction_id = $transaction_id;
|
||||
}
|
||||
}
|
||||
|
||||
44
app/Bean/Sdk/Wallet/Tron/BlockEventResultBean.php
Normal file
44
app/Bean/Sdk/Wallet/Tron/BlockEventResultBean.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class BlockEventResultBean extends BaseBean
|
||||
{
|
||||
protected $from;
|
||||
protected $to;
|
||||
protected $value;
|
||||
|
||||
public function getFrom()
|
||||
{
|
||||
return $this->from;
|
||||
}
|
||||
|
||||
public function setFrom($from): void
|
||||
{
|
||||
$this->from = $from;
|
||||
}
|
||||
|
||||
public function getTo()
|
||||
{
|
||||
return $this->to;
|
||||
}
|
||||
|
||||
public function setTo($to): void
|
||||
{
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value): void
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
120
app/Bean/Sdk/Wallet/Tron/EventBean.php
Normal file
120
app/Bean/Sdk/Wallet/Tron/EventBean.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class EventBean extends BaseBean
|
||||
{
|
||||
protected $block_number;
|
||||
protected $block_timestamp;
|
||||
protected $caller_contract_address;
|
||||
protected $contract_address;
|
||||
protected $event;
|
||||
protected $event_index;
|
||||
protected $event_name;
|
||||
protected EventResultBean $result;
|
||||
protected EventResultTypeBean $result_type;
|
||||
protected $transaction_id;
|
||||
|
||||
public function getBlockNumber()
|
||||
{
|
||||
return $this->block_number;
|
||||
}
|
||||
|
||||
public function setBlockNumber($block_number): void
|
||||
{
|
||||
$this->block_number = $block_number;
|
||||
}
|
||||
|
||||
public function getBlockTimestamp()
|
||||
{
|
||||
return $this->block_timestamp;
|
||||
}
|
||||
|
||||
public function setBlockTimestamp($block_timestamp): void
|
||||
{
|
||||
$this->block_timestamp = $block_timestamp;
|
||||
}
|
||||
|
||||
public function getCallerContractAddress()
|
||||
{
|
||||
return $this->caller_contract_address;
|
||||
}
|
||||
|
||||
public function setCallerContractAddress($caller_contract_address): void
|
||||
{
|
||||
$this->caller_contract_address = $caller_contract_address;
|
||||
}
|
||||
|
||||
public function getContractAddress()
|
||||
{
|
||||
return $this->contract_address;
|
||||
}
|
||||
|
||||
public function setContractAddress($contract_address): void
|
||||
{
|
||||
$this->contract_address = $contract_address;
|
||||
}
|
||||
|
||||
public function getEvent()
|
||||
{
|
||||
return $this->event;
|
||||
}
|
||||
|
||||
public function setEvent($event): void
|
||||
{
|
||||
$this->event = $event;
|
||||
}
|
||||
|
||||
public function getEventIndex()
|
||||
{
|
||||
return $this->event_index;
|
||||
}
|
||||
|
||||
public function setEventIndex($event_index): void
|
||||
{
|
||||
$this->event_index = $event_index;
|
||||
}
|
||||
|
||||
public function getEventName()
|
||||
{
|
||||
return $this->event_name;
|
||||
}
|
||||
|
||||
public function setEventName($event_name): void
|
||||
{
|
||||
$this->event_name = $event_name;
|
||||
}
|
||||
|
||||
public function getResult(): EventResultBean
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
public function setResult(EventResultBean $result): void
|
||||
{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
public function getResultType(): EventResultTypeBean
|
||||
{
|
||||
return $this->result_type;
|
||||
}
|
||||
|
||||
public function setResultType(EventResultTypeBean $result_type): void
|
||||
{
|
||||
$this->result_type = $result_type;
|
||||
}
|
||||
|
||||
public function getTransactionId()
|
||||
{
|
||||
return $this->transaction_id;
|
||||
}
|
||||
|
||||
public function setTransactionId($transaction_id): void
|
||||
{
|
||||
$this->transaction_id = $transaction_id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
43
app/Bean/Sdk/Wallet/Tron/EventResultBean.php
Normal file
43
app/Bean/Sdk/Wallet/Tron/EventResultBean.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class EventResultBean extends BaseBean
|
||||
{
|
||||
protected $from;
|
||||
protected $to;
|
||||
protected $value;
|
||||
|
||||
public function getFrom()
|
||||
{
|
||||
return $this->from;
|
||||
}
|
||||
|
||||
public function setFrom($from): void
|
||||
{
|
||||
$this->from = $from;
|
||||
}
|
||||
|
||||
public function getTo()
|
||||
{
|
||||
return $this->to;
|
||||
}
|
||||
|
||||
public function setTo($to): void
|
||||
{
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value): void
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
43
app/Bean/Sdk/Wallet/Tron/EventResultTypeBean.php
Normal file
43
app/Bean/Sdk/Wallet/Tron/EventResultTypeBean.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class EventResultTypeBean extends BaseBean
|
||||
{
|
||||
protected $from;
|
||||
protected $to;
|
||||
protected $value;
|
||||
|
||||
public function getFrom()
|
||||
{
|
||||
return $this->from;
|
||||
}
|
||||
|
||||
public function setFrom($from): void
|
||||
{
|
||||
$this->from = $from;
|
||||
}
|
||||
|
||||
public function getTo()
|
||||
{
|
||||
return $this->to;
|
||||
}
|
||||
|
||||
public function setTo($to): void
|
||||
{
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value): void
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
55
app/Bean/Sdk/Wallet/Tron/MetaBean.php
Normal file
55
app/Bean/Sdk/Wallet/Tron/MetaBean.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class MetaBean extends BaseBean
|
||||
{
|
||||
protected $at;
|
||||
protected $fingerprint;
|
||||
protected MetaLinksBean $links;
|
||||
protected $page_size;
|
||||
|
||||
public function getAt()
|
||||
{
|
||||
return $this->at;
|
||||
}
|
||||
|
||||
public function setAt($at): void
|
||||
{
|
||||
$this->at = $at;
|
||||
}
|
||||
|
||||
public function getFingerprint()
|
||||
{
|
||||
return $this->fingerprint;
|
||||
}
|
||||
|
||||
public function setFingerprint($fingerprint): void
|
||||
{
|
||||
$this->fingerprint = $fingerprint;
|
||||
}
|
||||
|
||||
public function getLinks(): MetaLinksBean
|
||||
{
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
public function setLinks(MetaLinksBean $links): void
|
||||
{
|
||||
$this->links = $links;
|
||||
}
|
||||
|
||||
public function getPageSize()
|
||||
{
|
||||
return $this->page_size;
|
||||
}
|
||||
|
||||
public function setPageSize($page_size): void
|
||||
{
|
||||
$this->page_size = $page_size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
10
app/Bean/Sdk/Wallet/Tron/MetaLinksBean.php
Normal file
10
app/Bean/Sdk/Wallet/Tron/MetaLinksBean.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class MetaLinksBean extends BaseBean
|
||||
{
|
||||
protected $next;
|
||||
|
||||
}
|
||||
34
app/Bean/Sdk/Wallet/Tron/NowBlockBean.php
Normal file
34
app/Bean/Sdk/Wallet/Tron/NowBlockBean.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class NowBlockBean extends BaseBean
|
||||
{
|
||||
protected $block_number;
|
||||
protected $block_timestamp;
|
||||
|
||||
public function getBlockNumber()
|
||||
{
|
||||
return $this->block_number;
|
||||
}
|
||||
|
||||
public function setBlockNumber($block_number): void
|
||||
{
|
||||
$this->block_number = $block_number;
|
||||
}
|
||||
|
||||
public function getBlockTimestamp()
|
||||
{
|
||||
return $this->block_timestamp;
|
||||
}
|
||||
|
||||
public function setBlockTimestamp($block_timestamp): void
|
||||
{
|
||||
$this->block_timestamp = $block_timestamp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
43
app/Bean/Sdk/Wallet/Tron/ResponseBean.php
Normal file
43
app/Bean/Sdk/Wallet/Tron/ResponseBean.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class ResponseBean extends BaseBean
|
||||
{
|
||||
protected $data;
|
||||
protected bool $success;
|
||||
protected MetaBean $meta;
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function setData($data): void
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function getSuccess(): bool
|
||||
{
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function setSuccess($success): void
|
||||
{
|
||||
$this->success = $success;
|
||||
}
|
||||
|
||||
public function getMeta(): MetaBean
|
||||
{
|
||||
return $this->meta;
|
||||
}
|
||||
|
||||
public function setMeta($meta): void
|
||||
{
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
55
app/Bean/Sdk/Wallet/Tron/TokenAddressBean.php
Normal file
55
app/Bean/Sdk/Wallet/Tron/TokenAddressBean.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class TokenAddressBean extends BaseBean
|
||||
{
|
||||
public $private_key;
|
||||
public $public_key;
|
||||
public $address_hex;
|
||||
public $address_base58;
|
||||
|
||||
public function getPrivateKey()
|
||||
{
|
||||
return $this->private_key;
|
||||
}
|
||||
|
||||
public function setPrivateKey($private_key): void
|
||||
{
|
||||
$this->private_key = $private_key;
|
||||
}
|
||||
|
||||
public function getPublicKey()
|
||||
{
|
||||
return $this->public_key;
|
||||
}
|
||||
|
||||
public function setPublicKey($public_key): void
|
||||
{
|
||||
$this->public_key = $public_key;
|
||||
}
|
||||
|
||||
public function getAddressHex()
|
||||
{
|
||||
return $this->address_hex;
|
||||
}
|
||||
|
||||
public function setAddressHex($address_hex): void
|
||||
{
|
||||
$this->address_hex = $address_hex;
|
||||
}
|
||||
|
||||
public function getAddressBase58()
|
||||
{
|
||||
return $this->address_base58;
|
||||
}
|
||||
|
||||
public function setAddressBase58($address_base58): void
|
||||
{
|
||||
$this->address_base58 = $address_base58;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
33
app/Bean/Sdk/Wallet/Tron/TransferTransactionBean.php
Normal file
33
app/Bean/Sdk/Wallet/Tron/TransferTransactionBean.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace App\Bean\Sdk\Wallet\Tron;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class TransferTransactionBean extends BaseBean
|
||||
{
|
||||
protected $txID;
|
||||
protected $raw_data;
|
||||
|
||||
public function getTxID()
|
||||
{
|
||||
return $this->txID;
|
||||
}
|
||||
|
||||
public function setTxID($txID): void
|
||||
{
|
||||
$this->txID = $txID;
|
||||
}
|
||||
|
||||
public function getRawData()
|
||||
{
|
||||
return $this->raw_data;
|
||||
}
|
||||
|
||||
public function setRawData($raw_data): void
|
||||
{
|
||||
$this->raw_data = $raw_data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
23
app/Bean/Service/HttpServiceConfigBean.php
Normal file
23
app/Bean/Service/HttpServiceConfigBean.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace App\Bean\Service;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class HttpServiceConfigBean extends BaseBean
|
||||
{
|
||||
protected bool $is_return_json = true;
|
||||
|
||||
public function isIsReturnJson(): bool
|
||||
{
|
||||
return $this->is_return_json;
|
||||
}
|
||||
|
||||
public function setIsReturnJson(bool $is_return_json): void
|
||||
{
|
||||
$this->is_return_json = $is_return_json;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
66
app/Bean/Service/HttpServiceReturnLogBean.php
Normal file
66
app/Bean/Service/HttpServiceReturnLogBean.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace App\Bean\Service;
|
||||
|
||||
use App\Bean\Model\Base\BaseBean;
|
||||
|
||||
class HttpServiceReturnLogBean extends BaseBean
|
||||
{
|
||||
protected $request_url;
|
||||
protected $request_data;
|
||||
protected $request_header;
|
||||
protected $response_body;
|
||||
protected $response_status_code;
|
||||
|
||||
public function getResponseStatusCode()
|
||||
{
|
||||
return $this->response_status_code;
|
||||
}
|
||||
|
||||
public function setResponseStatusCode($response_status_code): void
|
||||
{
|
||||
$this->response_status_code = $response_status_code;
|
||||
}
|
||||
|
||||
public function getRequestUrl()
|
||||
{
|
||||
return $this->request_url;
|
||||
}
|
||||
|
||||
public function setRequestUrl($request_url): void
|
||||
{
|
||||
$this->request_url = $request_url;
|
||||
}
|
||||
|
||||
public function getRequestData()
|
||||
{
|
||||
return $this->request_data;
|
||||
}
|
||||
|
||||
public function setRequestData($request_data): void
|
||||
{
|
||||
$this->request_data = $request_data;
|
||||
}
|
||||
|
||||
public function getRequestHeader()
|
||||
{
|
||||
return $this->request_header;
|
||||
}
|
||||
|
||||
public function setRequestHeader($request_header): void
|
||||
{
|
||||
$this->request_header = $request_header;
|
||||
}
|
||||
|
||||
public function getResponseBody()
|
||||
{
|
||||
return $this->response_body;
|
||||
}
|
||||
|
||||
public function setResponseBody($response_body): void
|
||||
{
|
||||
$this->response_body = $response_body;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -29,24 +29,36 @@ abstract class BaseCache
|
||||
{
|
||||
$sCacheKey = $this->getPrimaryKey();
|
||||
$aData = $this->loadData();
|
||||
|
||||
if (empty($aData)) return false;
|
||||
return Cache::put($sCacheKey, serialize($aData), self::CACHE_TTL);
|
||||
return Cache::put($sCacheKey, $aData, self::CACHE_TTL);
|
||||
}
|
||||
|
||||
abstract function loadData(): array|null;
|
||||
abstract function loadData(): array|string|null;
|
||||
|
||||
function getCacheData($primary_key = null): array|null
|
||||
function get($key): array|string|null
|
||||
{
|
||||
return $this->getCacheData($key);
|
||||
}
|
||||
function del($key): bool
|
||||
{
|
||||
return $this->delCacheData($key);
|
||||
}
|
||||
|
||||
function getCacheData($primary_key = null): array|string|null
|
||||
{
|
||||
|
||||
if ($primary_key === null) $primary_key = $this->primary_key;
|
||||
if (empty($primary_key)) return [];
|
||||
$sCacheKey = $this->getPrimaryKey($primary_key);
|
||||
$sData = Cache::get($sCacheKey);
|
||||
if (empty($sData)) {
|
||||
$this->primary_key = $primary_key;
|
||||
if($this->loadToCache()) $sData = Cache::get($sCacheKey);
|
||||
|
||||
if ($this->loadToCache()) $sData = Cache::get($sCacheKey);
|
||||
}
|
||||
if (empty($sData)) return null;
|
||||
return unserialize($sData);
|
||||
return $sData;
|
||||
}
|
||||
|
||||
//根据primary_key获取缓存数据单个值,不指定key就默认获取所有
|
||||
@ -55,7 +67,7 @@ abstract class BaseCache
|
||||
if ($primary_key === null) $primary_key = $this->primary_key;
|
||||
if (empty($primary_key)) return false;
|
||||
$aData = $this->getCacheData($primary_key);
|
||||
if(empty($aData)) return null;
|
||||
if (empty($aData)) return null;
|
||||
if (empty($key)) return $aData;
|
||||
return $aData[$key] ?? '';
|
||||
}
|
||||
@ -68,4 +80,10 @@ abstract class BaseCache
|
||||
return Cache::forget($sCacheKey);
|
||||
}
|
||||
|
||||
function clearAll(): bool
|
||||
{
|
||||
if (empty($this->primary_prefix)) return false;
|
||||
return Cache::forget($this->primary_prefix);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
42
app/Cache/Base/KeyBaseCache.php
Normal file
42
app/Cache/Base/KeyBaseCache.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cache\Base;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
abstract class KeyBaseCache
|
||||
{
|
||||
protected string $prefix = 'Key:'; //缓存前缀
|
||||
const CACHE_TTL = 60 * 60 * 24 * 3; //缓存时间 3天
|
||||
|
||||
function getByKey($key): string|array|bool|null
|
||||
{
|
||||
return Cache::get($key);
|
||||
}
|
||||
|
||||
function setKey($key, $value): bool
|
||||
{
|
||||
return Cache::put($this->getKey($key), $value);
|
||||
}
|
||||
|
||||
function setKeyWithExp($key, $value, $exp = self::CACHE_TTL): bool
|
||||
{
|
||||
return Cache::put($this->getKey($key), $value, $exp);
|
||||
}
|
||||
|
||||
function getPrefix(): string
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
function getKey($key): string
|
||||
{
|
||||
return $this->getPrefix().$key;
|
||||
}
|
||||
|
||||
function removeKey($key): bool
|
||||
{
|
||||
return Cache::forget($this->getKey($key));
|
||||
}
|
||||
|
||||
}
|
||||
59
app/Cache/Base/SetBaseCache.php
Normal file
59
app/Cache/Base/SetBaseCache.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cache\Base;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
//无序集合缓存基类
|
||||
abstract class SetBaseCache
|
||||
{
|
||||
|
||||
protected $client;
|
||||
protected string $prefix = 'Set:'; //缓存前缀
|
||||
protected string $set_name = ''; //集合名
|
||||
const CACHE_TTL = 60 * 60 * 24 * 3; //缓存时间 3天
|
||||
|
||||
function getRedis()
|
||||
{
|
||||
if(!$this->client) $this->client = Redis::client();
|
||||
return $this->client ;
|
||||
}
|
||||
|
||||
function getAll(): bool
|
||||
{
|
||||
return $this->getRedis()->sMembers($this->getSetName());
|
||||
}
|
||||
|
||||
function checkKey($value): bool
|
||||
{
|
||||
return $this->getRedis()->sIsMember($this->getSetName(),$value);
|
||||
}
|
||||
|
||||
function setKey($value): bool
|
||||
{
|
||||
return $this->getRedis()->sAdd($this->getSetName(),$value);
|
||||
}
|
||||
|
||||
function removeKey($value): bool
|
||||
{
|
||||
return $this->getRedis()->sRem($this->getSetName(),$value);
|
||||
}
|
||||
|
||||
function getCount()
|
||||
{
|
||||
return $this->getRedis()->sCard($this->getSetName());
|
||||
}
|
||||
|
||||
function getPrefix(): string
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
function getSetName(): string
|
||||
{
|
||||
return $this->getPrefix().$this->set_name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Cache\Base;
|
||||
|
||||
use App\Models\Follow\FollowModel;
|
||||
|
||||
//用户缓存用户基础信息(等于数据表)primary_key为主键
|
||||
abstract class TableBaseCache extends BaseCache
|
||||
{
|
||||
@ -12,20 +10,23 @@ abstract class TableBaseCache extends BaseCache
|
||||
public array $get_columns = ['*'];
|
||||
public array $get_exclude_columns = [];
|
||||
|
||||
function loadTable(): array|null
|
||||
function loadTable(): array|string|null
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function loadData(): array|null
|
||||
function loadData(): array|string|null
|
||||
{
|
||||
|
||||
//默认获取表数据方式
|
||||
if (!empty($table_class)) {
|
||||
|
||||
$oTable = new $this->table_class();
|
||||
//排除不需要的字段
|
||||
if (!empty($this->get_exclude_columns) && $this->get_columns != ['*']) $this->get_columns = array_diff($this->get_columns, $this->get_exclude_columns);
|
||||
$oData = $oTable->findItemByWhere([$this->primary_key_column => $this->primary_key], $this->get_columns);
|
||||
if($oData->isEmpty()) return null;
|
||||
if ($oData->isEmpty()) return null;
|
||||
$aData = $oData->toArray();
|
||||
//排除不需要的字段
|
||||
if (!empty($this->get_exclude_columns) && $this->get_columns == ['*'] && !empty($aData)) {
|
||||
|
||||
23
app/Cache/Key/TronKeyCache.php
Normal file
23
app/Cache/Key/TronKeyCache.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cache\Key;
|
||||
|
||||
use App\Cache\Base\KeyBaseCache;
|
||||
|
||||
class TronKeyCache extends KeyBaseCache
|
||||
{
|
||||
protected string $prefix = 'WalletTronKeyCache:'; //缓存前缀
|
||||
|
||||
const NOW_BLOCK = 'nowBlock'; //当前区块
|
||||
|
||||
function setNowBlock(string $block): bool
|
||||
{
|
||||
return $this->setKey(self::NOW_BLOCK, $block);
|
||||
}
|
||||
|
||||
function getNowBlock(): bool|array|string|null
|
||||
{
|
||||
return $this->getByKey(self::NOW_BLOCK);
|
||||
}
|
||||
|
||||
}
|
||||
30
app/Cache/Lock/BaseLock.php
Normal file
30
app/Cache/Lock/BaseLock.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace App\Cache\Lock;
|
||||
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
class BaseLock
|
||||
{
|
||||
const TTL = 120;
|
||||
|
||||
function setLockNxEx($key, $value)
|
||||
{
|
||||
return Redis::client()->set($key, $value, 'EX', self::TTL, 'NX');
|
||||
}
|
||||
|
||||
function setLock($key, $value = '1')
|
||||
{
|
||||
return Redis::client()->setex($key, self::TTL , $value);
|
||||
}
|
||||
|
||||
function unLock($key)
|
||||
{
|
||||
return Redis::client()->del($key);
|
||||
}
|
||||
|
||||
function checkLock($key)
|
||||
{
|
||||
return Redis::client()->get($key);
|
||||
}
|
||||
|
||||
}
|
||||
13
app/Cache/Lock/WalletPlatformUserTransactionLock.php
Normal file
13
app/Cache/Lock/WalletPlatformUserTransactionLock.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace App\Cache\Lock;
|
||||
|
||||
class WalletPlatformUserTransactionLock extends BaseLock
|
||||
{
|
||||
const WITHDRAW_LOCK_KEY = 'wallet_platform_user_transaction_withdraw_lock:';
|
||||
|
||||
public static function getWithdrawKey($id): string
|
||||
{
|
||||
return self::WITHDRAW_LOCK_KEY . $id;
|
||||
}
|
||||
|
||||
}
|
||||
11
app/Cache/Set/TronWalletAddressSetCache.php
Normal file
11
app/Cache/Set/TronWalletAddressSetCache.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cache\Set;
|
||||
|
||||
use App\Cache\Base\SetBaseCache;
|
||||
|
||||
class TronWalletAddressSetCache extends SetBaseCache
|
||||
{
|
||||
protected string $set_name = 'TronWalletAddressSetCache:'; //缓存前缀
|
||||
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
namespace App\Cache\Struct;
|
||||
|
||||
use App\Cache\Base\StructBaseCache;
|
||||
use App\Models\Customer\CustomerUserExtendModel;
|
||||
use App\Models\Api\Customer\CustomerUserExtendModel;
|
||||
|
||||
//用户缓存用户基础信息(结构自己组装不完全等于数据表)primary_key为主键
|
||||
class StructUserCommonCacheUid extends StructBaseCache
|
||||
|
||||
42
app/Cache/Table/Api/TableCustomerSettingCache.php
Normal file
42
app/Cache/Table/Api/TableCustomerSettingCache.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cache\Table\Api;
|
||||
|
||||
use App\Cache\Base\TableBaseCache;
|
||||
use App\Models\Api\Other\CustomerSettingModel;
|
||||
|
||||
//用户缓存用户基础信息(结构自己组装不完全等于数据表)uid为主键
|
||||
class TableCustomerSettingCache extends TableBaseCache
|
||||
{
|
||||
|
||||
public string $table_class = CustomerSettingModel::class;
|
||||
public string $primary_prefix = 'TableCustomerSettingCache:'; //后面跟name
|
||||
|
||||
public string $primary_key_column = 'name';
|
||||
public array $get_columns = [
|
||||
'value',
|
||||
];
|
||||
|
||||
const NAME_WITHDRAW_FEE_AMOUNT = 'withdraw_fee_amount';
|
||||
|
||||
//只存值 key为name value为value
|
||||
function loadData(): array|string|null
|
||||
{
|
||||
$oTable = new $this->table_class();
|
||||
$oData = $oTable->findItemByWhere([$this->primary_key_column => $this->primary_key], $this->get_columns);
|
||||
if ($oData->isEmpty()) return null;
|
||||
$aData = $oData->toArray();
|
||||
|
||||
if (empty($aData)) return null;
|
||||
return $aData['value'];
|
||||
}
|
||||
|
||||
function getWithdrawFeeAmount(): string|null
|
||||
{
|
||||
$res = $this->get(self::NAME_WITHDRAW_FEE_AMOUNT);
|
||||
if (empty($res)) $res = 0;
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
namespace App\Cache\Table;
|
||||
|
||||
namespace App\Cache\Table\Api;
|
||||
|
||||
use App\Cache\Base\TableBaseCache;
|
||||
use App\Models\Customer\CustomerUserModel;
|
||||
use App\Models\Api\Customer\CustomerUserModel;
|
||||
|
||||
//用户缓存用户基础信息(结构自己组装不完全等于数据表)uid为主键
|
||||
class TableCustomerUserCache extends TableBaseCache
|
||||
@ -17,6 +18,18 @@ class TableCustomerUserCache extends TableBaseCache
|
||||
'google_auth_secret',
|
||||
];
|
||||
|
||||
function loadData(): array|string|null
|
||||
{
|
||||
|
||||
|
||||
$oTable = new $this->table_class();
|
||||
$oData = $oTable->findItemByWhere([$this->primary_key_column => $this->primary_key], $this->get_columns);
|
||||
|
||||
if (!$oData) return null;
|
||||
|
||||
$aData = $oData->toArray();
|
||||
if (empty($aData)) return null;
|
||||
|
||||
return $aData;
|
||||
}
|
||||
}
|
||||
26
app/Cache/Table/Wallet/TableWalletPlatformCache.php
Normal file
26
app/Cache/Table/Wallet/TableWalletPlatformCache.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace App\Cache\Table\Wallet;
|
||||
|
||||
use App\Cache\Base\TableBaseCache;
|
||||
use App\Models\Wallet\Other\WalletSettingModel;
|
||||
use App\Models\Wallet\Platform\WalletPlatformModel;
|
||||
|
||||
//用户缓存用户基础信息(结构自己组装不完全等于数据表)uid为主键
|
||||
class TableWalletPlatformCache extends TableBaseCache
|
||||
{
|
||||
|
||||
public string $table_class = WalletPlatformModel::class;
|
||||
public string $primary_prefix = 'TableWalletPlatformCache:'; //后面跟name
|
||||
|
||||
public string $primary_key_column = 'id';
|
||||
public array $get_columns = [
|
||||
'id',
|
||||
'name',
|
||||
'code',
|
||||
'appid',
|
||||
'secret',
|
||||
'notify_ip',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
}
|
||||
41
app/Cache/Table/Wallet/TableWalletSettingCache.php
Normal file
41
app/Cache/Table/Wallet/TableWalletSettingCache.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace App\Cache\Table\Wallet;
|
||||
|
||||
use App\Cache\Base\TableBaseCache;
|
||||
use App\Models\Wallet\Other\WalletSettingModel;
|
||||
|
||||
//用户缓存用户基础信息(结构自己组装不完全等于数据表)uid为主键
|
||||
class TableWalletSettingCache extends TableBaseCache
|
||||
{
|
||||
|
||||
public string $table_class = WalletSettingModel::class;
|
||||
public string $primary_prefix = 'TableWalletSettingCache:'; //后面跟name
|
||||
|
||||
public string $primary_key_column = 'name';
|
||||
public array $get_columns = [
|
||||
'value',
|
||||
];
|
||||
|
||||
const NAME_WITHDRAW_FEE_AMOUNT = 'withdraw_fee_amount';
|
||||
|
||||
//只存值 key为name value为value
|
||||
function loadData(): array|string|null
|
||||
{
|
||||
$oTable = new $this->table_class();
|
||||
$oData = $oTable->findItemByWhere([$this->primary_key_column => $this->primary_key], $this->get_columns);
|
||||
if ($oData->isEmpty()) return null;
|
||||
$aData = $oData->toArray();
|
||||
|
||||
if (empty($aData)) return null;
|
||||
return $aData['value'];
|
||||
}
|
||||
|
||||
function getWithdrawFeeAmount(): string|null
|
||||
{
|
||||
$res = $this->get(self::NAME_WITHDRAW_FEE_AMOUNT);
|
||||
if (empty($res)) $res = 0;
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,18 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Api;
|
||||
|
||||
use App\Models\Customer\CustomerUserExtendModel;
|
||||
use App\Models\Api\Customer\CustomerUserExtendModel;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class DailyCheckUserActiveStatus extends Command
|
||||
class DailyCheckUserActiveStatusCmd extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:daily-check-user-active-status';
|
||||
protected $signature = 'app:daily-check-user-active-status-cmd';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@ -29,7 +29,7 @@ class DailyCheckUserActiveStatus extends Command
|
||||
$this->info('每日更新用户活跃状态');
|
||||
$this->info('开始...');
|
||||
$oCustomerUserExtendModelExtend = new CustomerUserExtendModel();
|
||||
$oCustomerUserExtendModelExtend->updateUserActiveStatus();
|
||||
$oCustomerUserExtendModelExtend->updateAllUserActiveStatus();
|
||||
$this->info('结束...');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Api;
|
||||
|
||||
use App\Models\Api\Wallet\CustomerWalletBalanceTransactionModel;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class HourCustomerWalletTrsDelayPayCmd extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:hour-customer-wallet-trs-delay-pay-cmd';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '每小时检查用户钱包交易延迟支付';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('每小时检查用户钱包交易延迟支付');
|
||||
$this->info('开始...');
|
||||
$oCustomerWalletBalanceTransactionModel = new CustomerWalletBalanceTransactionModel();
|
||||
$oCustomerWalletBalanceTransactionModel->dealDelayPaymentTransactionCmd();
|
||||
$this->info('结束...');
|
||||
}
|
||||
}
|
||||
35
app/Console/Commands/Api/SecondsWalletBlockCheckCmd.php
Normal file
35
app/Console/Commands/Api/SecondsWalletBlockCheckCmd.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Api;
|
||||
|
||||
use App\Service\Wallet\Coin\Tron\UsdtTrx20Service;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SecondsWalletBlockCheckCmd extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:seconds-wallet-block-check-cmd';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '每2秒检查最新链上区块';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('每2秒检查最新链上区块');
|
||||
$this->info('开始...');
|
||||
$oUsdtTrx20Service = new UsdtTrx20Service();
|
||||
$oUsdtTrx20Service->checkNowBlock();
|
||||
$this->info('结束...');
|
||||
}
|
||||
}
|
||||
@ -13,7 +13,9 @@ class Kernel extends ConsoleKernel
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
$schedule->command('app:daily-check-user-active-status')->dailyAt('00:30')->onOneServer();
|
||||
$schedule->command('app:daily-check-user-active-status-cmd')->dailyAt('00:30')->onOneServer();
|
||||
$schedule->command('app:hour-customer-wallet-trs-delay-pay-cmd')->hourly()->onOneServer();
|
||||
$schedule->command('app:seconds-wallet-block-check-cmd')->everyTwoSeconds()->onOneServer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
8
app/Const/Prefix.php
Normal file
8
app/Const/Prefix.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace App\Const;
|
||||
|
||||
class Prefix{
|
||||
|
||||
const ORDER_SN_PREFIX = 'SN_';
|
||||
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use App\Service\ReplyService;
|
||||
use App\Service\Api\ReplyService;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@ -27,6 +27,7 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
|
||||
$this->renderable(function (NotFoundHttpException $e, Request $request) {
|
||||
return ReplyService::error( 'record not find');
|
||||
});
|
||||
|
||||
@ -5,4 +5,11 @@ namespace App\Exceptions;
|
||||
class ModelException extends \Exception
|
||||
{
|
||||
|
||||
const CODE_WALLET_AMOUNT_ADDR_NOT_FOUND = 10101;
|
||||
const CODE_WALLET_ADDR_BALANCE_LOW = 10102;
|
||||
|
||||
const CODE = [
|
||||
self::CODE_WALLET_AMOUNT_ADDR_NOT_FOUND => '钱包金额地址不存在',
|
||||
self::CODE_WALLET_ADDR_BALANCE_LOW => '钱包余额不足',
|
||||
];
|
||||
}
|
||||
|
||||
8
app/Exceptions/PlatformNotifyException.php
Normal file
8
app/Exceptions/PlatformNotifyException.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class PlatformNotifyException extends \Exception
|
||||
{
|
||||
|
||||
}
|
||||
7
app/Exceptions/QueueException.php
Normal file
7
app/Exceptions/QueueException.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class QueueException extends \Exception
|
||||
{
|
||||
}
|
||||
7
app/Exceptions/WalletException.php
Normal file
7
app/Exceptions/WalletException.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class WalletException extends \Exception
|
||||
{
|
||||
}
|
||||
9
app/Exceptions/WalletSdkException.php
Normal file
9
app/Exceptions/WalletSdkException.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class WalletSdkException extends \Exception
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Base;
|
||||
|
||||
use App\Service\ReplyService;
|
||||
use App\Service\Api\ReplyService;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
abstract class BaseController extends Controller
|
||||
@ -29,7 +29,7 @@ abstract class BaseController extends Controller
|
||||
|
||||
function error($msg = 'error', $data = []): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
ReplyService::error($msg, $data);
|
||||
return ReplyService::error($msg, $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,10 +6,10 @@ use App\Const\Im;
|
||||
use App\Const\VrCode;
|
||||
use App\Exceptions\AppException;
|
||||
use App\Http\Controllers\Base\CustomerBaseController;
|
||||
use App\Models\Customer\CustomerUserModel;
|
||||
use App\Service\AuthService;
|
||||
use App\Service\ImService;
|
||||
use App\Service\VrCodeService;
|
||||
use App\Models\Api\Customer\CustomerUserModel;
|
||||
use App\Service\Api\AuthService;
|
||||
use App\Service\Api\ImService;
|
||||
use App\Service\Api\VrCodeService;
|
||||
use App\Tools\Tools;
|
||||
|
||||
class CustomerUserController extends CustomerBaseController
|
||||
@ -49,6 +49,7 @@ class CustomerUserController extends CustomerBaseController
|
||||
{
|
||||
$oAuthService = new AuthService();
|
||||
$token = $oAuthService->getTokenFromReq();
|
||||
var_dump($token);
|
||||
$aUser = $oAuthService->getCurrentUser();
|
||||
$data = [
|
||||
'token' => $token,
|
||||
@ -102,8 +103,8 @@ class CustomerUserController extends CustomerBaseController
|
||||
$oAuthService = new AuthService();
|
||||
$oImService = new ImService();
|
||||
$token = $oAuthService->createTokenToUser($oUser->id, $device);
|
||||
$imToken = $oImService->authUserToken($oUser->id, $device);
|
||||
|
||||
$imToken = "test";
|
||||
//$imToken = $oImService->authUserToken($oUser->id, $device);
|
||||
$data = [
|
||||
'token' => $token,
|
||||
'im_token' => $imToken,
|
||||
@ -157,7 +158,7 @@ class CustomerUserController extends CustomerBaseController
|
||||
$password = $request->input('password');
|
||||
$device = $request->input('device');
|
||||
$sVrCode = $request->input('vr_code');
|
||||
|
||||
var_dump($sVrCode);
|
||||
|
||||
//check vrcode
|
||||
$oVrCodeService = new VrCodeService();
|
||||
@ -186,7 +187,8 @@ class CustomerUserController extends CustomerBaseController
|
||||
|
||||
//向im注册
|
||||
$oImService = new ImService();
|
||||
if (!$oImService->userUserRegister($oUser->id)) throw new AppException('im register error');
|
||||
//暂时不注册
|
||||
// if (!$oImService->userUserRegister($oUser->id)) throw new AppException('im register error');
|
||||
|
||||
$oAuthService = new AuthService();
|
||||
$token = $oAuthService->createTokenToUser($oUser->id, $device);
|
||||
|
||||
@ -5,9 +5,8 @@ namespace App\Http\Controllers\Follow;
|
||||
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Http\Controllers\Base\BaseController;
|
||||
use App\Models\Follow\FollowHistoryModel;
|
||||
use App\Models\Follow\FollowModel;
|
||||
use App\Service\AuthService;
|
||||
use App\Models\Api\Follow\FollowModel;
|
||||
use App\Service\Api\AuthService;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
|
||||
@ -4,8 +4,54 @@
|
||||
namespace App\Http\Controllers\Post;
|
||||
|
||||
use App\Http\Controllers\Base\BaseController;
|
||||
use App\Service\Api\AuthService;
|
||||
|
||||
class PostController extends BaseController
|
||||
{
|
||||
//$uid, $content = null, $media = null,$mid = null,$sBachSn = null
|
||||
public array $validateMethodParams = [
|
||||
'addPost' => [
|
||||
'type' => 'required|numeric|max:2',
|
||||
'content' => 'required|numeric|max:255',
|
||||
'media' => 'json',
|
||||
],
|
||||
'pullPostList' => [
|
||||
'lastId' => 'numeric|max:10',
|
||||
'limit' => 'numeric|max:5',
|
||||
],
|
||||
];
|
||||
public function addPost(): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
$aParams = request()->only([
|
||||
'type',
|
||||
'content',
|
||||
'media',
|
||||
]);
|
||||
if (!in_array($aParams['type'], [\App\Models\Api\Post\PostModel::TYPE_POST, \App\Models\Api\Post\PostModel::TYPE_REPOST])) return $this->error('type params error');
|
||||
|
||||
$oAuthService = new AuthService();
|
||||
$aUser = $oAuthService->getCurrentUser();
|
||||
$oFollowModel = new \App\Models\Api\Post\PostModel();
|
||||
$aParams['uid'] = $aUser['id'];
|
||||
|
||||
$oFollowModel->addBatchPost([$aParams]);
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
function pullPostList()
|
||||
{
|
||||
$aParams = request()->only([
|
||||
'lastId',
|
||||
'limit',
|
||||
]);
|
||||
$oAuthService = new AuthService();
|
||||
$aUser = $oAuthService->getCurrentUser();
|
||||
$oPostModel = new \App\Models\Api\Post\PostPushBoxModel();
|
||||
$aPostList = $oPostModel->getPushBoxList($aUser['id'],$aParams['lastId']??0,$aParams['limit']??15);
|
||||
return $this->success($aPostList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -4,9 +4,9 @@ namespace App\Http\Controllers\Sms;
|
||||
use App\Const\VrCode;
|
||||
use App\Exceptions\AppException;
|
||||
use App\Http\Controllers\Base\CustomerBaseController;
|
||||
use App\Models\Customer\CustomerUserModel;
|
||||
use App\Service\AuthService;
|
||||
use App\Service\VrCodeService;
|
||||
use App\Models\Api\Customer\CustomerUserModel;
|
||||
use App\Service\Api\AuthService;
|
||||
use App\Service\Api\VrCodeService;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
@ -40,7 +40,7 @@ class SmsController extends CustomerBaseController
|
||||
|
||||
$validator = Validator::make($aReqData, [
|
||||
'phone_area' => 'required|alpha_dash:ascii|max:5',
|
||||
'phone' => 'required|numeric|max:15',
|
||||
'phone' => 'required|digits_between:6,15',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return $this->error($validator->errors()->first());
|
||||
|
||||
@ -3,11 +3,10 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Const\Responses;
|
||||
use App\Models\Customer\CustomerUserModel;
|
||||
use App\Service\AuthService;
|
||||
use App\Models\Api\Customer\CustomerUserModel;
|
||||
use App\Service\Api\AuthService;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class AuthMiddleware
|
||||
|
||||
45
app/Jobs/Api/AddPostQueue.php
Normal file
45
app/Jobs/Api/AddPostQueue.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Api;
|
||||
|
||||
use App\Bean\Queue\Api\QueueAddPostBean;
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Api\Post\PostPushBoxModel;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class AddPostQueue implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//处理用户的推文推送
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* @throws ModelException
|
||||
*/
|
||||
public function handle(array $params): void
|
||||
{
|
||||
$bean = new QueueAddPostBean($params);
|
||||
$oPostPushBoxModel = new PostPushBoxModel();
|
||||
$oPostPushBoxModel->addPostQueueConsumer($bean);
|
||||
}
|
||||
|
||||
public static function putToQueue(QueueAddPostBean $bean,$delaySec = null): \Illuminate\Foundation\Bus\PendingDispatch
|
||||
{
|
||||
$queue = self::dispatch($bean->toArrayNotNull())->onQueue(QueueAddPostBean::QUEUE_NAME);
|
||||
if(!empty($delaySec)){
|
||||
$queue->delay(now()->addSeconds($delaySec));
|
||||
}
|
||||
return $queue;
|
||||
}
|
||||
}
|
||||
43
app/Jobs/Api/UserActiveStatusQueue.php
Normal file
43
app/Jobs/Api/UserActiveStatusQueue.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Api;
|
||||
|
||||
use App\Bean\Queue\Api\QueueUserActiveStatusBean;
|
||||
use App\Models\Api\Customer\CustomerUserExtendModel;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class UserActiveStatusQueue implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//处理用户活跃状态改变后任务
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(array $params): void
|
||||
{
|
||||
$bean = new QueueUserActiveStatusBean($params);
|
||||
$oCustomerUserExtendModel = new CustomerUserExtendModel();
|
||||
$oCustomerUserExtendModel->activeUserStatusQueueConsumer($bean);
|
||||
}
|
||||
|
||||
public static function putToQueue(QueueUserActiveStatusBean $bean,$delaySec = null): \Illuminate\Foundation\Bus\PendingDispatch
|
||||
{
|
||||
$queue = self::dispatch($bean->toArrayNotNull())->onQueue(QueueUserActiveStatusBean::QUEUE_NAME);
|
||||
if(!empty($delaySec)){
|
||||
$queue->delay(now()->addSeconds($delaySec));
|
||||
}
|
||||
return $queue;
|
||||
}
|
||||
}
|
||||
46
app/Jobs/Wallet/WalletAddressTransactionQueue.php
Normal file
46
app/Jobs/Wallet/WalletAddressTransactionQueue.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Wallet;
|
||||
|
||||
use App\Bean\Queue\Wallet\QueueEventBean;
|
||||
use App\Service\Wallet\Coin\Tron\UsdtTrx20Service;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class WalletAddressTransactionQueue implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//钱包地址交易账变处理队列
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(array $params): void
|
||||
{
|
||||
$oQueueEventBean = new QueueEventBean($params);
|
||||
$oUsdtTrx20Service = new UsdtTrx20Service();
|
||||
try {
|
||||
$oUsdtTrx20Service->walletAddressTransactionConsumer($oQueueEventBean);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static function putToQueue(QueueEventBean $bean,$delaySec = null): \Illuminate\Foundation\Bus\PendingDispatch
|
||||
{
|
||||
$queue = self::dispatch($bean->toArrayNotNull())->onQueue(QueueEventBean::QUEUE_NAME);
|
||||
if(!empty($delaySec)){
|
||||
$queue->delay(now()->addSeconds($delaySec));
|
||||
}
|
||||
return $queue;
|
||||
}
|
||||
}
|
||||
46
app/Jobs/Wallet/WalletBlockQueue.php
Normal file
46
app/Jobs/Wallet/WalletBlockQueue.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Wallet;
|
||||
|
||||
use App\Bean\Queue\Wallet\QueueWalletBlockBean;
|
||||
use App\Service\Wallet\Coin\Tron\UsdtTrx20Service;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class WalletBlockQueue implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//处理tron区块任务
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(array $params): void
|
||||
{
|
||||
$oQueueWalletBlockBean = new QueueWalletBlockBean($params);
|
||||
$oUsdtTrx20Service = new UsdtTrx20Service();
|
||||
try {
|
||||
$oUsdtTrx20Service->tronBlockConsumer($oQueueWalletBlockBean);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static function putToQueue(QueueWalletBlockBean $bean,$delaySec = null): \Illuminate\Foundation\Bus\PendingDispatch
|
||||
{
|
||||
$queue = self::dispatch($bean->toArrayNotNull())->onQueue(QueueWalletBlockBean::QUEUE_NAME);
|
||||
if(!empty($delaySec)){
|
||||
$queue->delay(now()->addSeconds($delaySec));
|
||||
}
|
||||
return $queue;
|
||||
}
|
||||
}
|
||||
46
app/Jobs/Wallet/WalletBlockTransactionQueue.php
Normal file
46
app/Jobs/Wallet/WalletBlockTransactionQueue.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Wallet;
|
||||
|
||||
use App\Bean\Queue\Wallet\QueueWalletBlockTransactionBean;
|
||||
use App\Service\Wallet\Coin\Tron\UsdtTrx20Service;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class WalletBlockTransactionQueue implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(array $params): void
|
||||
{
|
||||
$oQueueWalletBlockTransactionBean = new QueueWalletBlockTransactionBean($params);
|
||||
$oUsdtTrx20Service = new UsdtTrx20Service();
|
||||
try {
|
||||
$oUsdtTrx20Service->tronBlockTransactionConsumer($oQueueWalletBlockTransactionBean);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static function putToQueue(QueueWalletBlockTransactionBean $bean, $delaySec = null): \Illuminate\Foundation\Bus\PendingDispatch
|
||||
{
|
||||
$queue = self::dispatch($bean->toArrayNotNull())->onQueue(QueueWalletBlockTransactionBean::QUEUE_NAME);
|
||||
if(!empty($delaySec)){
|
||||
$queue->delay(now()->addSeconds($delaySec));
|
||||
}
|
||||
return $queue;
|
||||
}
|
||||
}
|
||||
42
app/Jobs/Wallet/WalletNotifyToPlatformQueue.php
Normal file
42
app/Jobs/Wallet/WalletNotifyToPlatformQueue.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Wallet;
|
||||
|
||||
use App\Bean\Queue\Wallet\QueueNotifyToPlatformBean;
|
||||
use App\Service\Wallet\PlatformNotifyService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class WalletNotifyToPlatformQueue implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//通知到平台
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(array $params): void
|
||||
{
|
||||
$oPlatformNotifyService = new PlatformNotifyService();
|
||||
$oPlatformNotifyService->notifyToPlatform(new QueueNotifyToPlatformBean($params));
|
||||
}
|
||||
|
||||
public static function putToQueue(QueueNotifyToPlatformBean $bean, $delaySec = null): \Illuminate\Foundation\Bus\PendingDispatch
|
||||
{
|
||||
$queue = self::dispatch($bean->toArrayNotNull())->onQueue(QueueNotifyToPlatformBean::QUEUE_NAME);
|
||||
if(!empty($delaySec)){
|
||||
$queue->delay(now()->addSeconds($delaySec));
|
||||
}
|
||||
return $queue;
|
||||
}
|
||||
}
|
||||
58
app/Jobs/Wallet/WalletPlatformTransactionQueue.php
Normal file
58
app/Jobs/Wallet/WalletPlatformTransactionQueue.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Wallet;
|
||||
|
||||
use App\Bean\Queue\Wallet\QueueWalletPlatformTransactionBean;
|
||||
use App\Models\Wallet\Wallet\WalletAddressTransactionModel;
|
||||
use App\Service\Wallet\PlatformRechargeService;
|
||||
use App\Service\Wallet\PlatformWithdrawService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class WalletPlatformTransactionQueue implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//处理平台到账账变
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(array $params): void
|
||||
{
|
||||
$bean = new QueueWalletPlatformTransactionBean($params);
|
||||
$oWithdrawService = new PlatformWithdrawService();
|
||||
$oRechargeSService = new PlatformRechargeService();
|
||||
try {
|
||||
$type = $bean->getType();
|
||||
//提现
|
||||
if ($type == WalletAddressTransactionModel::TYPE_WITHDRAW) {
|
||||
$oWithdrawService->walletPlatformTransactionConsumer($bean);
|
||||
}
|
||||
//充值
|
||||
if ($type == WalletAddressTransactionModel::TYPE_RECHARGE) {
|
||||
$oRechargeSService->walletPlatformTransactionConsumer($bean);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function putToQueue(QueueWalletPlatformTransactionBean $bean, $delaySec = null): \Illuminate\Foundation\Bus\PendingDispatch
|
||||
{
|
||||
$queue = self::dispatch($bean->toArrayNotNull())->onQueue(QueueWalletPlatformTransactionBean::QUEUE_NAME);
|
||||
if(!empty($delaySec)){
|
||||
$queue->delay(now()->addSeconds($delaySec));
|
||||
}
|
||||
return $queue;
|
||||
}
|
||||
}
|
||||
46
app/Jobs/Wallet/WalletPlatformWithdrawTransferQueue.php
Normal file
46
app/Jobs/Wallet/WalletPlatformWithdrawTransferQueue.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Wallet;
|
||||
|
||||
use App\Bean\Queue\Wallet\QueueWalletPlatformWithdrawTransferBean;
|
||||
use App\Service\Wallet\PlatformWithdrawService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class WalletPlatformWithdrawTransferQueue implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//处理提现任务
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(array $params): void
|
||||
{
|
||||
$bean = new QueueWalletPlatformWithdrawTransferBean($params);
|
||||
$oService = new PlatformWithdrawService();
|
||||
try {
|
||||
$oService->withdrawTransferConsumer($bean);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static function putToQueue(QueueWalletPlatformWithdrawTransferBean $bean, $delaySec = null): \Illuminate\Foundation\Bus\PendingDispatch
|
||||
{
|
||||
$queue = self::dispatch($bean->toArrayNotNull())->onQueue(QueueWalletPlatformWithdrawTransferBean::QUEUE_NAME);
|
||||
if(!empty($delaySec)){
|
||||
$queue->delay(now()->addSeconds($delaySec));
|
||||
}
|
||||
return $queue;
|
||||
}
|
||||
}
|
||||
9
app/Models/Api/Base/ApiBaseModel.php
Normal file
9
app/Models/Api/Base/ApiBaseModel.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Api\Base;
|
||||
|
||||
use App\Models\Base\BaseModel;
|
||||
|
||||
class ApiBaseModel extends BaseModel {
|
||||
|
||||
}
|
||||
22
app/Models/Api/Comment/PostCommentModel.php
Normal file
22
app/Models/Api/Comment/PostCommentModel.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace App\Models\Api\Comment;
|
||||
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PostCommentModel extends ApiBaseModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $table = 'customer_post_comment';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'pid',
|
||||
'uid',
|
||||
'content',
|
||||
'created_at',
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
@ -1,14 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Customer;
|
||||
namespace App\Models\Api\Customer;
|
||||
|
||||
use App\Cache\Table\TableCustomerUserCache;
|
||||
use App\Models\Base\CustomerBaseModel;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class CustomerChangeInfoLogModel extends CustomerBaseModel
|
||||
class CustomerChangeInfoLogModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_change_info_log';
|
||||
protected $primaryKey = 'id';
|
||||
@ -47,4 +44,20 @@ class CustomerChangeInfoLogModel extends CustomerBaseModel
|
||||
return $this->addItem($aItem);
|
||||
}
|
||||
|
||||
function addUserActiveStatusLog($uid,$beforeValue,$value,$remark_key): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
$aLogInsert = [
|
||||
'type' => CustomerChangeInfoLogModel::TYPE_CHANG_USER_ACTIVE_STATUS,
|
||||
'uid' => $uid,
|
||||
'column' => CustomerUserExtendModel::COL_IS_ACTIVE,
|
||||
'before_value' => $beforeValue,
|
||||
'pid' => CustomerChangeInfoLogModel::PID_SYSTEM,
|
||||
'value' => $value,
|
||||
'after_value' => $value,
|
||||
'remark_key' => $remark_key,
|
||||
'remark_desc' => CustomerChangeInfoLogModel::REMARK[$remark_key],
|
||||
];
|
||||
return $this->addLog($aLogInsert);
|
||||
}
|
||||
|
||||
}
|
||||
19
app/Models/Api/Customer/CustomerLoginHistoryModel.php
Normal file
19
app/Models/Api/Customer/CustomerLoginHistoryModel.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Api\Customer;
|
||||
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
|
||||
class CustomerLoginHistoryModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_login_history';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'status',
|
||||
'uid',
|
||||
'device',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
}
|
||||
196
app/Models/Api/Customer/CustomerUserExtendModel.php
Normal file
196
app/Models/Api/Customer/CustomerUserExtendModel.php
Normal file
@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Api\Customer;
|
||||
|
||||
use App\Bean\Queue\Api\QueueUserActiveStatusBean;
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Jobs\Api\UserActiveStatusQueue;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use App\Models\Api\Post\PostPushBoxModel;
|
||||
use App\Models\Api\WebSocket\CustomerWsHistoryModel;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CustomerUserExtendModel extends ApiBaseModel
|
||||
{
|
||||
|
||||
protected $table = 'customer_user_extend';
|
||||
protected $primaryKey = 'uid';
|
||||
|
||||
protected $fillable = [
|
||||
'uid',
|
||||
'is_active',
|
||||
'fans_num',
|
||||
'follow_num',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
const COL_IS_ACTIVE = 'is_active';
|
||||
|
||||
//是否活跃用户
|
||||
const IS_ACTIVE_YES = 1;
|
||||
const IS_ACTIVE_NO = 2;
|
||||
const IS_ACTIVE = [
|
||||
self::IS_ACTIVE_YES => '活跃',
|
||||
self::IS_ACTIVE_NO => '不活跃',
|
||||
];
|
||||
|
||||
//增加用户扩展信息
|
||||
function addExtend($aItem): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
if (empty($aItem['uid'])) throw new ModelException('uid error');
|
||||
if ($this->findItem($aItem['uid'], ['uid'])) return null; //已存在
|
||||
$sDateTime = date('Y-m-d H:i:s');
|
||||
$aItem['updated_at'] = $sDateTime;
|
||||
return $this->addItem($aItem);
|
||||
}
|
||||
|
||||
function initExtend($uid): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
if (!$uid) throw new ModelException('uid error');
|
||||
if ($this->findItem($uid, ['uid'])) return null; //已存在
|
||||
|
||||
$sDateTime = date('Y-m-d H:i:s');
|
||||
$aItem = [
|
||||
'uid' => $uid,
|
||||
'is_active' => 1,
|
||||
'fans_num' => 0,
|
||||
'follow_num' => 0,
|
||||
'updated_at' => $sDateTime,
|
||||
];
|
||||
return $this->addItem($aItem);
|
||||
}
|
||||
|
||||
//增加当前粉丝总数
|
||||
function incrFansNum($uid): int
|
||||
{
|
||||
$oExtend = $this->findItem($uid, 'uid');
|
||||
if (!$oExtend) $this->initExtend($uid);
|
||||
return $this->newQuery()->where('uid', $uid)->increment('fans_num');
|
||||
}
|
||||
|
||||
//减去当前追随者总数
|
||||
function decrFansNum($uid): int
|
||||
{
|
||||
$oExtend = $this->findItem($uid, 'uid');
|
||||
if (!$oExtend)$this->addExtend();
|
||||
return $this->newQuery()->where('uid', $uid)->decrement('fans_num');
|
||||
}
|
||||
|
||||
//增加当前订阅总数
|
||||
function incrFollowNum($uid): int
|
||||
{
|
||||
$oExtend = $this->findItem($uid, 'uid');
|
||||
if (!$oExtend) $this->initExtend($uid);
|
||||
return $this->newQuery()->where('uid', $uid)->increment('follow_num');
|
||||
}
|
||||
|
||||
//减去当前订阅总数
|
||||
function decrFollowNum($uid): int
|
||||
{
|
||||
$oExtend = $this->findItem($uid, 'uid');
|
||||
if (!$oExtend) $this->initExtend($uid);
|
||||
return $this->newQuery()->where('uid', $uid)->decrement('follow_num');
|
||||
}
|
||||
|
||||
//获取用户活跃信息
|
||||
function getUserActiveListLimit($nowUid, $limit = 500): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
return $this->newQuery()
|
||||
->where('id', '>=', $nowUid)
|
||||
->limit($limit)
|
||||
->orderBy('id')
|
||||
->get(['uid', 'is_active']);
|
||||
}
|
||||
|
||||
//检测所有用户活跃状态
|
||||
function updateAllUserActiveStatus($date = null): void
|
||||
{
|
||||
if (empty($date)) $date = Carbon::yesterday()->toDateString();
|
||||
|
||||
$oCustomerWsHistoryModel = new CustomerWsHistoryModel();
|
||||
$aActiveUserIdList = $oCustomerWsHistoryModel->getActiveUserIdList($date); //三日内活跃用户
|
||||
if (empty($aActiveUserIdList)) return;
|
||||
$oCustomerChangeInfoLogModel = new CustomerChangeInfoLogModel();
|
||||
|
||||
$nowUid = 0;
|
||||
while (true) {
|
||||
try {
|
||||
Db::beginTransaction();
|
||||
$aUserExtendList = $this->getUserActiveListLimit($nowUid, 500);
|
||||
if (empty($aUserExtendList)) break;
|
||||
$nowUid = max($aUserExtendList->pluck('uid')->toArray());
|
||||
|
||||
foreach ($aUserExtendList as $oUserExtend) {
|
||||
if (in_array($oUserExtend->uid, $aActiveUserIdList)) { //在活跃列表中
|
||||
if ($oUserExtend->is_active == self::IS_ACTIVE_YES) continue; //已经是活跃用户
|
||||
//变更用户状态
|
||||
$res = $this->newQuery()->where('uid', $oUserExtend->uid)->update(['is_active' => self::IS_ACTIVE_YES]);
|
||||
if ($res) {
|
||||
//记录日志
|
||||
$oCustomerChangeInfoLogModel->addUserActiveStatusLog($oUserExtend->uid, $oUserExtend->is_active, self::IS_ACTIVE_YES, CustomerChangeInfoLogModel::REMARK_DAILY_CHECK_USER_ACTIVE_STATUS_YES);
|
||||
//投递到消息队列
|
||||
$oQueueUserActiveStatusBean = new QueueUserActiveStatusBean();
|
||||
$oQueueUserActiveStatusBean->setUid($oUserExtend->uid);
|
||||
$oQueueUserActiveStatusBean->setQueueCreatedAt(date('Y-m-d H:i:s'));
|
||||
UserActiveStatusQueue::putToQueue($oQueueUserActiveStatusBean);
|
||||
}
|
||||
} else { //三日内不活跃
|
||||
if ($oUserExtend->is_active == self::IS_ACTIVE_NO) continue; //已经是不活跃用户
|
||||
//变更用户状态
|
||||
$res = $this->newQuery()->where('uid', $oUserExtend->uid)->update(['is_active' => self::IS_ACTIVE_NO]);
|
||||
if ($res) {
|
||||
//记录日志
|
||||
$oCustomerChangeInfoLogModel->addUserActiveStatusLog($oUserExtend->uid, $oUserExtend->is_active, self::IS_ACTIVE_YES, CustomerChangeInfoLogModel::REMARK_DAILY_CHECK_USER_ACTIVE_STATUS_NO);
|
||||
}
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Log::error('updateUserActiveStatus error:' . $e->getMessage());
|
||||
Db::rollBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//登录检测用户活跃状态
|
||||
function updateUserActiveStatus($uid): void
|
||||
{
|
||||
try{
|
||||
Db::beginTransaction();
|
||||
$oCustomerWsHistoryModel = new CustomerWsHistoryModel();
|
||||
$aActiveUserId = $oCustomerWsHistoryModel->findActiveUserId($uid, Carbon::yesterday()->toDateString()); //三日内活跃用户
|
||||
if(empty($aActiveUserId)) return;
|
||||
$oCustomerUserExtendModel = $this->newQuery()->where('uid', $uid)->first(['uid','is_active']);
|
||||
if(!$oCustomerUserExtendModel) return;
|
||||
$oCustomerChangeInfoLogModel = new CustomerChangeInfoLogModel();
|
||||
|
||||
$res = $this->newQuery()->where('uid', $uid)->update(['is_active' => self::IS_ACTIVE_YES]);
|
||||
if ($res) {
|
||||
//记录日志
|
||||
$oCustomerChangeInfoLogModel->addUserActiveStatusLog($uid, $oCustomerUserExtendModel->is_active, self::IS_ACTIVE_YES, CustomerChangeInfoLogModel::REMARK_DAILY_CHECK_USER_ACTIVE_STATUS_YES);
|
||||
//投递到消息队列
|
||||
$oQueueUserActiveStatusBean = new QueueUserActiveStatusBean();
|
||||
$oQueueUserActiveStatusBean->setUid($uid);
|
||||
$oQueueUserActiveStatusBean->setQueueCreatedAt(date('Y-m-d H:i:s'));
|
||||
UserActiveStatusQueue::putToQueue($oQueueUserActiveStatusBean);
|
||||
}
|
||||
Db::commit();
|
||||
}catch (\Exception $e){
|
||||
Log::error('updateUserActiveStatus error:' . $e->getMessage());
|
||||
Db::rollBack();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function activeUserStatusQueueConsumer(QueueUserActiveStatusBean $bean): void
|
||||
{
|
||||
$uid = $bean->getUid();
|
||||
$oPostPushBoxModel = new PostPushBoxModel();
|
||||
$oPostPushBoxModel->pullBigFanMasterPostConsumer($uid);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Customer;
|
||||
namespace App\Models\Api\Customer;
|
||||
|
||||
use App\Cache\Table\TableCustomerUserCache;
|
||||
use App\Models\Base\CustomerBaseModel;
|
||||
use App\Cache\Table\Api\TableCustomerUserCache;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class CustomerUserModel extends CustomerBaseModel
|
||||
class CustomerUserModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_users';
|
||||
protected $primaryKey = 'id';
|
||||
@ -109,12 +109,15 @@ class CustomerUserModel extends CustomerBaseModel
|
||||
{
|
||||
$oTableCustomerUserCache = new TableCustomerUserCache();
|
||||
$oTableCustomerUserCache->setPrimaryKey($iUid);
|
||||
|
||||
return $oTableCustomerUserCache->getCacheData();
|
||||
// return Cache::remember($this->getCacheKey($iUid), RedisConst::ORM_FIND_CACHE_SECOND, function () use ($iUid) {
|
||||
// return $this->findItem($iUid);
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
|
||||
// function delItemFromCache($iUid): bool
|
||||
// {
|
||||
// return Cache::delete($this->getCacheKey($iUid));
|
||||
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace App\Models\Follow;
|
||||
namespace App\Models\Api\Follow;
|
||||
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Base\BaseModel;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
|
||||
class FollowHistoryModel extends BaseModel
|
||||
class FollowHistoryModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_follow_history';
|
||||
protected $primaryKey = 'id';
|
||||
@ -28,7 +28,7 @@ class FollowHistoryModel extends BaseModel
|
||||
*/
|
||||
function addFollowHistory($method, $uid, $follow_uid): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
if(!in_array($method,self::METHOD)) throw new ModelException('method error');
|
||||
if(!array_key_exists($method,self::METHOD)) throw new ModelException('method error');
|
||||
$aItem['method'] = $method;
|
||||
$aItem['uid'] = $uid;
|
||||
$aItem['follow_uid'] = $follow_uid;
|
||||
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Follow;
|
||||
namespace App\Models\Api\Follow;
|
||||
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Base\BaseModel;
|
||||
use App\Models\Customer\CustomerUserExtendModel;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use App\Models\Api\Customer\CustomerUserExtendModel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class FollowModel extends BaseModel
|
||||
class FollowModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_follow';
|
||||
protected $primaryKey = 'id';
|
||||
280
app/Models/Api/Order/CustomerUserPostOrderDisputeModel.php
Normal file
280
app/Models/Api/Order/CustomerUserPostOrderDisputeModel.php
Normal file
@ -0,0 +1,280 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Api\Order;
|
||||
|
||||
use App\Bean\Model\Api\Order\CustomerUserPostOrderDisputeBean;
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use App\Models\Api\Wallet\CustomerWalletBalanceTransactionModel;
|
||||
use App\Tools\Logs;
|
||||
use App\Tools\Times;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Spatie\FlareClient\Api;
|
||||
|
||||
class CustomerUserPostOrderDisputeModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_user_post_order_dispute';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'post_order_id',
|
||||
'status',
|
||||
'chat_group_id',
|
||||
'seller_submit_datetime',
|
||||
'buyer_submit_datetime',
|
||||
'result_status',
|
||||
'buyer_uid',
|
||||
'buyer_pay_dispute_status',
|
||||
'buyer_pay_amount',
|
||||
'buyer_pay_transaction_id',
|
||||
'buyer_dispute_fee_pay_status',
|
||||
'buyer_dispute_fee_amount',
|
||||
'buyer_dispute_fee_pay_transaction_id',
|
||||
'seller_uid',
|
||||
'seller_pay_dispute_status',
|
||||
'seller_pay_amount',
|
||||
'seller_pay_transaction_id',
|
||||
'seller_desc_key',
|
||||
'seller_desc',
|
||||
'admin_remark',
|
||||
'admin_uid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
const STATUS_NO_DISPUTE = 1;
|
||||
const STATUS_WAITING = 2;
|
||||
const STATUS_PROCESSING = 3;
|
||||
const STATUS_FINISH = 4;
|
||||
const STATUS_CANCEL = 5;
|
||||
const STATUS = [
|
||||
self::STATUS_NO_DISPUTE => '无纠纷',
|
||||
self::STATUS_WAITING => '待处理',
|
||||
self::STATUS_PROCESSING => '处理中',
|
||||
self::STATUS_FINISH => '处理完成',
|
||||
self::STATUS_CANCEL => '取消',
|
||||
];
|
||||
|
||||
const RESULT_STATUS_SELLER_RESPLITY = 1;
|
||||
const RESULT_STATUS_BUYER_RESPLITY = 2;
|
||||
const RESULT_STATUS_EACH_RESPLITY = 3;
|
||||
const RESULT_STATUS_OVERRULE = 4;
|
||||
const RESULT_STATUS = [
|
||||
self::RESULT_STATUS_SELLER_RESPLITY => '卖家责任',
|
||||
self::RESULT_STATUS_BUYER_RESPLITY => '买家责任',
|
||||
self::RESULT_STATUS_EACH_RESPLITY => '双方责任',
|
||||
self::RESULT_STATUS_OVERRULE => '驳回',
|
||||
];
|
||||
|
||||
|
||||
const PAY_DISPUTE_STATUS_WAITING = 1;
|
||||
const PAY_DISPUTE_STATUS_SUCCESS = 2;
|
||||
const PAY_DISPUTE_STATUS_FAIL = 3;
|
||||
const PAY_DISPUTE_STATUS = [
|
||||
self::PAY_DISPUTE_STATUS_WAITING => '待处理',
|
||||
self::PAY_DISPUTE_STATUS_SUCCESS => '成功',
|
||||
self::PAY_DISPUTE_STATUS_FAIL => '失败',
|
||||
];
|
||||
|
||||
const BUYER_DISPUTE_FEE_PAY_STATUS_NO = 1;
|
||||
const BUYER_DISPUTE_FEE_PAY_STATUS_YES = 2;
|
||||
const BUYER_DISPUTE_FEE_PAY_STATUS = [
|
||||
self::BUYER_DISPUTE_FEE_PAY_STATUS_NO => '未支付',
|
||||
self::BUYER_DISPUTE_FEE_PAY_STATUS_YES => '已支付',
|
||||
];
|
||||
|
||||
//纠纷管理员接单
|
||||
public function disputeAdminAccept($dispute_id, $admin_uid, $is_change_admin = false): bool|int
|
||||
{
|
||||
try {
|
||||
$datetimeNow = Times::getNowDateTime();
|
||||
DB::beginTransaction();
|
||||
$resModel = $this->findItem($dispute_id);
|
||||
if (!$resModel) throw new ModelException('dispute not found');
|
||||
if ($resModel->status != self::STATUS_WAITING) throw new ModelException('dispute status error');
|
||||
if (!empty($resModel->admin_uid) && !$is_change_admin) throw new ModelException('already have admin');
|
||||
|
||||
$updateItem = [
|
||||
'id' => $resModel->id,
|
||||
'status' => self::STATUS_PROCESSING,
|
||||
'admin_uid' => $admin_uid,
|
||||
'updated_at' => $datetimeNow,
|
||||
];
|
||||
$res = $this->updateItem($updateItem);
|
||||
if (!$res) throw new ModelException('update dispute status fail');
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//创建纠纷
|
||||
public function createDispute($post_order_id)
|
||||
{
|
||||
try {
|
||||
$datetimeNow = Times::getNowDateTime();
|
||||
DB::beginTransaction();
|
||||
$oCustomerUserPostOrderModel = new CustomerUserPostOrderModel();
|
||||
$resCustomerUserPostOrderModel = $oCustomerUserPostOrderModel->findItem($post_order_id);
|
||||
if (!$resCustomerUserPostOrderModel) throw new \Exception('order not found');
|
||||
if ($resCustomerUserPostOrderModel->pay_status != CustomerUserPostOrderModel::PAY_STATUS_PAID) throw new ModelException('order already in dispute');
|
||||
if ($resCustomerUserPostOrderModel->dispute_status != CustomerUserPostOrderModel::DISPUTE_STATUS_UN_DISPUTE) throw new ModelException('order already in dispute');
|
||||
//更新订单纠纷状态
|
||||
$updateItem = [
|
||||
'id' => $resCustomerUserPostOrderModel->id,
|
||||
'dispute_status' => CustomerUserPostOrderModel::DISPUTE_STATUS_WAITING,
|
||||
'updated_at' => $datetimeNow,
|
||||
];
|
||||
$res = $oCustomerUserPostOrderModel->updateItem($updateItem);
|
||||
if (!$res) throw new ModelException('update order dispute status fail');
|
||||
//创建纠纷
|
||||
$bean = new CustomerUserPostOrderDisputeBean();
|
||||
$bean->setBuyerUid($resCustomerUserPostOrderModel->buyer_uid);
|
||||
$bean->setSellerUid($resCustomerUserPostOrderModel->seller_uid);
|
||||
$bean->setPostOrderId($post_order_id);
|
||||
$bean->setStatus(self::STATUS_WAITING);
|
||||
$bean->setBuyerDisputeFeePayStatus(self::BUYER_DISPUTE_FEE_PAY_STATUS_NO);
|
||||
//@@计算纠纷申诉费用
|
||||
$bean->setBuyerDisputeFeeAmount(5); //默认5u
|
||||
$bean->setCreatedAt($datetimeNow);
|
||||
$bean->setUpdatedAt($datetimeNow);
|
||||
$resModel = $this->addItem($bean->toArrayNotNull());
|
||||
if (!$resModel) throw new ModelException('create dispute fail');
|
||||
|
||||
//创建聊天群组
|
||||
$chat_id = $this->createChatGroupForDispute($resModel->id);
|
||||
if (!$chat_id) throw new ModelException('create chat group fail');
|
||||
$updateItem = [
|
||||
'id' => $resModel->id,
|
||||
'chat_group_id' => $chat_id,
|
||||
];
|
||||
$res = $this->updateItem($updateItem);
|
||||
if (!$res) throw new ModelException('update chat group id fail');
|
||||
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return $resModel->id;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//@@创建聊天群组用于纠纷
|
||||
function createChatGroupForDispute($dispute_id)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//纠纷判罚
|
||||
public function disputePenalty($dispute_id, $result_status, $buyer_amount, $seller_amount, $admin_uid, $admin_remark): bool|int
|
||||
{
|
||||
try {
|
||||
if (
|
||||
!in_array(
|
||||
$result_status,
|
||||
[self::RESULT_STATUS_SELLER_RESPLITY, self::RESULT_STATUS_BUYER_RESPLITY, self::RESULT_STATUS_EACH_RESPLITY, self::RESULT_STATUS_OVERRULE]
|
||||
)
|
||||
) throw new ModelException('result_status error');
|
||||
$datetimeNow = Times::getNowDateTime();
|
||||
DB::beginTransaction();
|
||||
$resModel = $this->findItem($dispute_id);
|
||||
if (!$resModel) throw new ModelException('dispute not found');
|
||||
if ($resModel->status != self::STATUS_PROCESSING) throw new ModelException('dispute status error');
|
||||
if ($resModel->admin_uid != $admin_uid) throw new ModelException('admin_uid error');
|
||||
$oCustomerUserPostOrderModel = new CustomerUserPostOrderModel();
|
||||
$resCustomerUserPostOrderModel = $oCustomerUserPostOrderModel->findItem($resModel->post_order_id);
|
||||
if (!$resCustomerUserPostOrderModel) throw new ModelException('order not found');
|
||||
if ($resCustomerUserPostOrderModel->dispute_status != CustomerUserPostOrderModel::DISPUTE_STATUS_PROCESSING) throw new ModelException('order dispute status error');
|
||||
//更新订单状态
|
||||
$updateItem = [
|
||||
'id' => $resCustomerUserPostOrderModel->id,
|
||||
'dispute_status' => CustomerUserPostOrderModel::DISPUTE_STATUS_FINISH,
|
||||
'dispute_result_status' => $result_status,
|
||||
'updated_at' => $datetimeNow,
|
||||
];
|
||||
$res = $oCustomerUserPostOrderModel->updateItem($updateItem);
|
||||
if (!$res) throw new ModelException('update order dispute status fail');
|
||||
|
||||
//执行金额处理
|
||||
$oCustomerWalletBalanceTransactionModel = new CustomerWalletBalanceTransactionModel();
|
||||
$buyer_pay_status = self::PAY_DISPUTE_STATUS_SUCCESS;
|
||||
$seller_pay_status = self::PAY_DISPUTE_STATUS_SUCCESS;
|
||||
//执行买家
|
||||
$resBuyerTrsId = $this->changeUserAmountDispute(
|
||||
$resCustomerUserPostOrderModel->buyer_uid,
|
||||
$resCustomerUserPostOrderModel->buyer_currency_code,
|
||||
$buyer_amount,
|
||||
$resModel->id,
|
||||
);
|
||||
if (!$resBuyerTrsId) {
|
||||
$buyer_pay_status = self::PAY_DISPUTE_STATUS_FAIL;
|
||||
$this->changeUserAmountNotEnough($resCustomerUserPostOrderModel->buyer_uid, $resCustomerUserPostOrderModel->buyer_currency_code, $buyer_amount);
|
||||
}
|
||||
//执行卖家
|
||||
$resSellerTrsId = $this->changeUserAmountDispute(
|
||||
$resCustomerUserPostOrderModel->seller_uid,
|
||||
$resCustomerUserPostOrderModel->seller_currency_code,
|
||||
$seller_amount,
|
||||
$resModel->id,
|
||||
);
|
||||
if (!$resSellerTrsId) {
|
||||
$seller_pay_status = self::PAY_DISPUTE_STATUS_FAIL;
|
||||
$this->changeUserAmountNotEnough($resCustomerUserPostOrderModel->seller_uid, $resCustomerUserPostOrderModel->seller_currency_code, $seller_amount);
|
||||
}
|
||||
|
||||
//更新纠纷
|
||||
$updateItem = [
|
||||
'status' => self::STATUS_FINISH,
|
||||
'result_status' => $result_status,
|
||||
'admin_remark' => $admin_remark,
|
||||
'updated_at' => $datetimeNow,
|
||||
'buyer_pay_amount' => $buyer_amount,
|
||||
'buyer_pay_dispute_status' => $buyer_pay_status,
|
||||
'seller_pay_amount' => $seller_amount,
|
||||
'seller_pay_dispute_status' => $seller_pay_status,
|
||||
];
|
||||
if ($buyer_pay_status == self::PAY_DISPUTE_STATUS_SUCCESS) $updateItem['buyer_pay_transaction_id'] = $resBuyerTrsId;
|
||||
if ($seller_pay_status == self::PAY_DISPUTE_STATUS_SUCCESS) $updateItem['seller_pay_transaction_id'] = $resSellerTrsId;
|
||||
$res = $this->updateItem($updateItem);
|
||||
if (!$res) throw new ModelException('update dispute status fail');
|
||||
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//@@金额不足处理
|
||||
function changeUserAmountNotEnough($uid, $currency_code, $amount, $remark = '')
|
||||
{
|
||||
//@@冻结用户提款功能
|
||||
//@@提交到定期扣款任务
|
||||
}
|
||||
|
||||
|
||||
//纠纷金额处理
|
||||
function changeUserAmountDispute($uid, $currency_code, $amount, $dispute_id, $remark = ''): bool|int
|
||||
{
|
||||
if ($amount == 0) return true;
|
||||
$oCustomerWalletBalanceTransactionModel = new CustomerWalletBalanceTransactionModel();
|
||||
if ($amount > 0) {
|
||||
$res = $oCustomerWalletBalanceTransactionModel->typeDisputeAdd($uid, $currency_code, $amount, $dispute_id, $remark);
|
||||
} else {
|
||||
$res = $oCustomerWalletBalanceTransactionModel->typeDisputeSub($uid, $currency_code, $amount, $dispute_id, $remark);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
102
app/Models/Api/Order/CustomerUserPostOrderModel.php
Normal file
102
app/Models/Api/Order/CustomerUserPostOrderModel.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
namespace App\Models\Api\Order;
|
||||
|
||||
use App\Bean\Model\Api\Order\CustomerUserPostOrderBean;
|
||||
use App\Const\Prefix;
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use App\Models\Api\Post\PostHistoryModel;
|
||||
use App\Models\Api\Wallet\CustomerWalletBalanceTransactionModel;
|
||||
use App\Tools\Logs;
|
||||
use App\Tools\Times;
|
||||
use App\Tools\Tools;
|
||||
|
||||
class CustomerUserPostOrderModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_user_post_order';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'sn',
|
||||
'pay_status',
|
||||
'buyer_uid',
|
||||
'seller_uid',
|
||||
'pid',
|
||||
'post_history_id',
|
||||
'amount',
|
||||
'buyer_wallet_transaction_id',
|
||||
'seller_wallet_transaction_id',
|
||||
'dispute_status',
|
||||
'dispute_result_status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
const PAY_STATUS_UNPAID = 1;
|
||||
const PAY_STATUS_PAID = 2;
|
||||
const PAY_STATUS_PAID_FAIL = 3;
|
||||
const PAY_STATUS_CANCEL = 4;
|
||||
const PAY_STATUS = [
|
||||
self::PAY_STATUS_UNPAID => '未支付',
|
||||
self::PAY_STATUS_PAID => '已支付',
|
||||
self::PAY_STATUS_PAID_FAIL => '支付失败',
|
||||
self::PAY_STATUS_CANCEL => '取消',
|
||||
];
|
||||
|
||||
const DISPUTE_STATUS_UN_DISPUTE = 1;
|
||||
const DISPUTE_STATUS_WAITING = 2;
|
||||
const DISPUTE_STATUS_PROCESSING = 3;
|
||||
const DISPUTE_STATUS_FINISH = 4;
|
||||
|
||||
const DISPUTE_STATUS = [
|
||||
self::DISPUTE_STATUS_UN_DISPUTE => '未申诉',
|
||||
self::DISPUTE_STATUS_WAITING => '申诉待处理',
|
||||
self::DISPUTE_STATUS_PROCESSING => '申诉处理中',
|
||||
self::DISPUTE_STATUS_FINISH => '申诉完成',
|
||||
];
|
||||
|
||||
//订单购买
|
||||
public function buy($buyer_uid, $seller_id,$currency_code, $amount, $post_id): bool|int
|
||||
{
|
||||
try {
|
||||
$sn = Tools::genSnowflakeId(Prefix::ORDER_SN_PREFIX);
|
||||
$datetimeNow = Times::getNowDateTime();
|
||||
$bean = new CustomerUserPostOrderBean();
|
||||
|
||||
$bean->setAmount(abs($amount));
|
||||
$bean->setSn($sn);
|
||||
$bean->setPayStatus(self::PAY_STATUS_UNPAID);
|
||||
$bean->setBuyerUid($buyer_uid); //买家
|
||||
$bean->setSellerUid($seller_id); //卖家
|
||||
$bean->setPid($post_id);
|
||||
$bean->setBuyerCurrencyCode($currency_code); //买家
|
||||
$bean->setSellerCurrencyCode($currency_code); //卖家
|
||||
$bean->setDisputeStatus(self::DISPUTE_STATUS_UN_DISPUTE); //纠纷状态
|
||||
$bean->setCreatedAt($datetimeNow);
|
||||
$bean->setUpdatedAt($datetimeNow);
|
||||
|
||||
//查找post_history_id做快照
|
||||
$oPostHistoryModel = new PostHistoryModel();
|
||||
$resPostHistoryModel = $oPostHistoryModel->findLastPostId($post_id,['id']);
|
||||
if(!$resPostHistoryModel) throw new ModelException('post_history_id not found');
|
||||
$bean->setPostHistoryId($resPostHistoryModel->id);
|
||||
|
||||
$res = $this->addItem($bean->toArrayNotNull());
|
||||
if(!$res) throw new ModelException('order add fail');
|
||||
$bean->setId($res->id);
|
||||
|
||||
//进行支付
|
||||
$oCustomerWalletBalanceTransactionModel = new CustomerWalletBalanceTransactionModel();
|
||||
$res = $oCustomerWalletBalanceTransactionModel->typeOrderPay($bean); //订单支付,内部会进行order状态的更新
|
||||
if(!$res) throw new ModelException('order pay fail');
|
||||
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return $bean->getId();
|
||||
}catch (\Exception $e){
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'catchErr', $e, func_get_args());
|
||||
// throw new ModelException($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
20
app/Models/Api/Other/CustomerSettingModel.php
Normal file
20
app/Models/Api/Other/CustomerSettingModel.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Api\Other;
|
||||
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
|
||||
class CustomerSettingModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_setting';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'name',
|
||||
'value',
|
||||
'customer_setting',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace App\Models\Post;
|
||||
namespace App\Models\Api\Post;
|
||||
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Base\BaseModel;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
|
||||
class PostHistoryModel extends BaseModel
|
||||
class PostHistoryModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_post_history';
|
||||
protected $primaryKey = 'id';
|
||||
@ -44,5 +44,15 @@ class PostHistoryModel extends BaseModel
|
||||
return $this->addItem($aItem);
|
||||
}
|
||||
|
||||
//获取最新的历史记录(=当前)
|
||||
function findLastPostId($post_id,$col = ['*']): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|null
|
||||
{
|
||||
return $this->newQuery()
|
||||
->where('oid',$post_id)
|
||||
->where('method','!=',self::METHOD_DEL)
|
||||
->orderBy('created_at','desc')
|
||||
->first($col);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
209
app/Models/Api/Post/PostModel.php
Normal file
209
app/Models/Api/Post/PostModel.php
Normal file
@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Api\Post;
|
||||
|
||||
use App\Bean\Queue\Api\QueueAddPostBean;
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Jobs\Api\AddPostQueue;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use App\Models\Api\Post\Structs\PostParamsStruct;
|
||||
use App\Tools\Tools;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PostModel extends ApiBaseModel
|
||||
{
|
||||
//软删除
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'customer_post';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'type',
|
||||
'uuid',
|
||||
'post_batch_sn',
|
||||
'mid',
|
||||
'uid',
|
||||
'media',
|
||||
'content',
|
||||
'post_params',
|
||||
'created_at',
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
const TYPE_POST = PostPushBoxModel::TYPE_POST;
|
||||
const TYPE_REPOST = PostPushBoxModel::TYPE_REPOST;
|
||||
|
||||
const TYPE = [
|
||||
self::TYPE_POST => '推文',
|
||||
self::TYPE_REPOST => '转发',
|
||||
];
|
||||
|
||||
protected function media(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn(string $value = '') => Tools::JonsDecode($value),
|
||||
set: fn(array $value = []) => Tools::JonsEncode($value),
|
||||
);
|
||||
}
|
||||
|
||||
protected function postParams(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn(string $value = '') => Tools::JonsDecode($value),
|
||||
set: fn(array $value = []) => Tools::JonsEncode($value),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ModelException
|
||||
*/
|
||||
function addPost($uid, $type = self::TYPE_POST, $content = null, $media = null, $mid = null, $sBachSn = null): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
if (!in_array($type, [self::TYPE_POST, self::TYPE_REPOST])) throw new ModelException('type params error');
|
||||
$aPostParams = [];
|
||||
if($type == self::TYPE_REPOST){
|
||||
$oRePostModel = $this->findItem($mid);
|
||||
$aPostParams[PostParamsStruct::REPOST_ORG_USER_ID] = $oRePostModel->uid;
|
||||
$aPostParams[PostParamsStruct::REPOST_ORG_POST_ID] = $oRePostModel->mid;
|
||||
}
|
||||
|
||||
$uuid = Tools::genUuid();
|
||||
$bsn = 'BSN_' . ($sBachSn ?? Tools::genUuid());
|
||||
if (!$content && !$media) throw new ModelException('addPost params error');
|
||||
$aItem['type'] = $type;
|
||||
$aItem['uid'] = $uid;
|
||||
$aItem['uuid'] = $uuid;
|
||||
$aItem['post_batch_sn'] = $bsn;
|
||||
$aItem['mid'] = $mid;
|
||||
$aItem['media'] = $media;
|
||||
$aItem['content'] = $content;
|
||||
$aItem['post_params'] = $aPostParams;
|
||||
$sDateTime = date('Y-m-d H:i:s');
|
||||
$aItem['created_at'] = $sDateTime;
|
||||
$res = $this->addItem($aItem);
|
||||
if ($res) {
|
||||
//发送到消息队列处理新增post
|
||||
$oQueueAddPostBean = new QueueAddPostBean();
|
||||
$oQueueAddPostBean->setId($res->id);
|
||||
$oQueueAddPostBean->setType(self::TYPE_POST);
|
||||
AddPostQueue::putToQueue(new QueueAddPostBean(['id' => $res->id, 'type' => $type]));
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function addBatchPost(array $aPostList): void
|
||||
{
|
||||
$mid = null;
|
||||
$bsn = 'BSN_' . ($sBachSn ?? Tools::genUuid());
|
||||
foreach ($aPostList as $aPostItem) {
|
||||
$oPost = $this->addPost($aPostItem['uid'], $aPostItem['type'], $aPostItem['content'], $aPostItem['media'], $mid, $bsn);
|
||||
if ($oPost) {
|
||||
$mid = $oPost->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ModelException
|
||||
*/
|
||||
function delPostById($id)
|
||||
{
|
||||
$oPost = $this->findItem($id);
|
||||
$res = $this->delItem($id);
|
||||
if ($res) {
|
||||
$oPostHistoryModel = new PostHistoryModel();
|
||||
$oPostHistoryModel->addPostHistory(PostHistoryModel::METHOD_DEL, $oPost->toArray());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ModelException
|
||||
*/
|
||||
function delPostByUuid($uuid)
|
||||
{
|
||||
$oPost = $this->findItemByWhere(['uuid' => $uuid]);
|
||||
$res = $this->newQuery()->where('uuid', $uuid)->delete();
|
||||
if ($res) {
|
||||
$oPostHistoryModel = new PostHistoryModel();
|
||||
$oPostHistoryModel->addPostHistory(PostHistoryModel::METHOD_DEL, $oPost->toArray());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getPostListByUid($uid): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
return $this->getItemsByWhere(['uid' => $uid]);
|
||||
}
|
||||
|
||||
function getPostById($id): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
return $this->findItem($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ModelException
|
||||
*/
|
||||
function updatePostById($aItem): bool|int
|
||||
{
|
||||
if (!isset($aItem['id'])) throw new ModelException('updatePostById params error');
|
||||
if (empty($aItem['id'])) throw new ModelException('updatePostById params error');
|
||||
$oPost = $this->findItem($aItem['id']);
|
||||
$res = $this->updateItem($aItem);
|
||||
if ($res) {
|
||||
$oPostHistoryModel = new PostHistoryModel();
|
||||
$oPostHistoryModel->addPostHistory(PostHistoryModel::METHOD_EDIT, $oPost->toArray());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ModelException
|
||||
*/
|
||||
function updatePostByUuid($aItem): bool|int
|
||||
{
|
||||
if (!isset($aItem['uuid'])) throw new ModelException('updatePostByUuid params error');
|
||||
if (empty($aItem['uuid'])) throw new ModelException('updatePostByUuid params error');
|
||||
$oPost = $this->findItemByWhere(['uuid' => $aItem['uuid']]);
|
||||
$res = $this->updateItem($aItem, 'uuid');
|
||||
if ($res) {
|
||||
$oPostHistoryModel = new PostHistoryModel();
|
||||
$oPostHistoryModel->addPostHistory(PostHistoryModel::METHOD_EDIT, $oPost->toArray());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getPostListByMid($mid): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
return $this->getItemsByWhere(['mid' => $mid]);
|
||||
}
|
||||
|
||||
|
||||
function getPostListByUidMid($uid, $mid): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
return $this->getItemsByWhere(['uid' => $uid, 'mid' => $mid]);
|
||||
}
|
||||
|
||||
function getPostListByUids($uids, $sDateLimit = null,$cols = ['*'],$offset = null, $limit = null): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
$oModel = $this->newQuery();
|
||||
if ($offset) $oModel->offset($offset);
|
||||
if ($limit) $oModel->limit($offset);
|
||||
if ($sDateLimit == null) $sDateLimit = date('Y-m-d H:i:s', strtotime('-3 day'));
|
||||
return $oModel
|
||||
->where('created_at', $sDateLimit)
|
||||
->whereIn('uid', $uids)
|
||||
->orderBy('created_at')
|
||||
->get($cols);
|
||||
}
|
||||
|
||||
function CountPostListByUids($uids, $sDateLimit = null): int
|
||||
{
|
||||
if ($sDateLimit == null) $sDateLimit = date('Y-m-d H:i:s', strtotime('-3 day'));
|
||||
return $this->newQuery()->where('created_at', $sDateLimit)->whereIn('uid', $uids)->orderBy('created_at')->count();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
250
app/Models/Api/Post/PostPushBoxModel.php
Normal file
250
app/Models/Api/Post/PostPushBoxModel.php
Normal file
@ -0,0 +1,250 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Api\Post;
|
||||
|
||||
use App\Bean\Queue\Api\QueueAddPostBean;
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Jobs\Api\AddPostQueue;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use App\Models\Api\Comment\PostCommentModel;
|
||||
use App\Models\Api\Customer\CustomerUserExtendModel;
|
||||
use App\Models\Api\Follow\FollowModel;
|
||||
use App\Models\Api\Post\Structs\PostParamsStruct;
|
||||
use App\Tools\CollectOffsetLimit;
|
||||
use App\Tools\Tools;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
||||
class PostPushBoxModel extends ApiBaseModel
|
||||
{
|
||||
|
||||
protected $table = 'customer_post_push_box';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'type',
|
||||
'uid',
|
||||
'pid',
|
||||
'puuid',
|
||||
'post_params',
|
||||
'is_like',
|
||||
'is_repost',
|
||||
'is_bookmark',
|
||||
'is_read',
|
||||
'post_created_at',
|
||||
'created_at',
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
const TYPE_POST = 1;
|
||||
const TYPE_REPOST = 2;
|
||||
const TYPE_COMMENT = 3;
|
||||
const TYPE = [
|
||||
self::TYPE_POST => '推文',
|
||||
self::TYPE_REPOST => '转发',
|
||||
self::TYPE_COMMENT => '评论',
|
||||
];
|
||||
|
||||
const IS_LIKE_DEFAULT = 1;
|
||||
const IS_LIKE_YES = 2;
|
||||
const IS_LIKE_NO = 3;
|
||||
const IS_LIKE = [
|
||||
self::IS_LIKE_DEFAULT => '默认',
|
||||
self::IS_LIKE_YES => '喜欢',
|
||||
self::IS_LIKE_NO => '不喜欢',
|
||||
];
|
||||
|
||||
const IS_REPOST_DEFAULT = 1;
|
||||
const IS_REPOST_YES = 2;
|
||||
const IS_REPOST = [
|
||||
self::IS_REPOST_DEFAULT => '默认',
|
||||
self::IS_REPOST_YES => '已转发',
|
||||
];
|
||||
|
||||
const IS_BOOKMARK_DEFAULT = 1;
|
||||
const IS_BOOKMARK_YES = 2;
|
||||
const IS_BOOKMARK = [
|
||||
self::IS_BOOKMARK_DEFAULT => '默认',
|
||||
self::IS_BOOKMARK_YES => '已收藏',
|
||||
];
|
||||
|
||||
const IS_READ_NO = 1;
|
||||
const IS_READ_YES = 2;
|
||||
const IS_READ = [
|
||||
self::IS_READ_NO => '默认',
|
||||
self::IS_READ_YES => '已收藏',
|
||||
];
|
||||
|
||||
protected function postParams(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn(string $value = '') => Tools::JonsDecode($value),
|
||||
set: fn(array $value = []) => Tools::JonsEncode($value),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交后调用事件,在消费队列跑推送
|
||||
* @throws ModelException
|
||||
*/
|
||||
function addPostQueueConsumer(QueueAddPostBean $bean)
|
||||
{
|
||||
$id = $bean->getId();
|
||||
$type = $bean->getType();
|
||||
if (empty($id)) return false;
|
||||
if (empty($type)) return false;
|
||||
|
||||
if (!in_array($type, [self::TYPE_POST, self::TYPE_REPOST, self::TYPE_COMMENT])) return false;
|
||||
if (empty($id)) return false;
|
||||
|
||||
$oPostModel = new PostModel();
|
||||
$oPost = null;
|
||||
$aPostParams = [];
|
||||
|
||||
//判断推送类型
|
||||
if ($type == self::TYPE_POST) {
|
||||
$postId = $id;
|
||||
} elseif ($type == self::TYPE_REPOST) {
|
||||
$postId = $id;
|
||||
$oRePostModel = $oPostModel->findItem($id);
|
||||
if (!$oRePostModel) return false;
|
||||
$aPostParams[PostParamsStruct::REPOST_ORG_USER_ID] = $oRePostModel->uid;
|
||||
$aPostParams[PostParamsStruct::REPOST_ORG_POST_ID] = $oRePostModel->mid;
|
||||
} elseif ($type == self::TYPE_COMMENT) {
|
||||
$oPostCommentModel = new PostCommentModel();
|
||||
$oPostCommentModel = $oPostCommentModel->findItem($id);
|
||||
if (!$oPostCommentModel) return false;
|
||||
$postId = $oPostCommentModel->pid;
|
||||
$aPostParams[PostParamsStruct::COMMENT_ID] = $oPostCommentModel->id;
|
||||
$aPostParams[PostParamsStruct::COMMENT_USER_ID] = $oPostCommentModel->uid;
|
||||
$aPostParams[PostParamsStruct::COMMENT_POST_ID] = $oPostCommentModel->pid;
|
||||
$aPostParams[PostParamsStruct::COMMENT_CONTEXT] = $oPostCommentModel->content;
|
||||
$aPostParams[PostParamsStruct::COMMENT_CONTEXT_CREATE_TIME] = $oPostCommentModel->created_at;
|
||||
} else {
|
||||
throw new ModelException('type error');
|
||||
}
|
||||
|
||||
if ($postId) $oPost = $oPostModel->findItem($postId);
|
||||
if (!$oPost) throw new ModelException('post not found');
|
||||
$iConfigFansPushLimit = intval(env('CONFIG_FANS_PUSH_LIMIT', 2000));
|
||||
|
||||
//查询粉丝数
|
||||
$CustomerUserExtendModel = new CustomerUserExtendModel();
|
||||
$CustomerUserExtend = $CustomerUserExtendModel->findItem($oPost->uid);
|
||||
if (!$CustomerUserExtend) throw new ModelException('user extend not found');
|
||||
|
||||
//粉丝数少于$iConfigFansPushLimit的用户走写扩散流程(所有粉丝信箱插入一条)
|
||||
$bSendMode = $CustomerUserExtend->fans_num < $iConfigFansPushLimit;
|
||||
|
||||
$iTotalCount = $this->countSendFans($bSendMode, $oPost->uid); //计算发送总数
|
||||
$aPost = $oPost->toArray();
|
||||
if (empty($aPost)) return false;
|
||||
$aPost['post_params'] = $aPostParams;
|
||||
//分批发送
|
||||
$oCollectOffsetLimit = new CollectOffsetLimit();
|
||||
$oCollectOffsetLimit->setITotalCount($iTotalCount)->runWhile(function ($offset, $limit) use ($aPost, $bSendMode) {
|
||||
$oFollowList = $this->getFansListWithPage($bSendMode, $aPost['uid'], $offset, $limit);
|
||||
if(empty($oFollowList)) return;
|
||||
$this->sendPostToBox($aPost, $oFollowList);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function getFansListWithPage($bAllFans, $uid, $offset = 0, $limit = 2000): \Illuminate\Database\Eloquent\Collection|array|\Illuminate\Support\Collection
|
||||
{
|
||||
$oFollowModel = new FollowModel();
|
||||
//粉丝数少于$iConfigFansPushLimit的用户走写扩散流程(所有粉丝信箱插入一条)
|
||||
if ($bAllFans) {
|
||||
$oFollowList = $oFollowModel->getFansList($uid, ['uid'], $offset, $limit); //获取所有粉丝列表
|
||||
} else { //读扩散流程(只针对活跃粉丝信箱插入一条)
|
||||
//获取活跃粉丝列表
|
||||
//@活跃粉丝数量过大需要分批处理
|
||||
$oFollowList = $oFollowModel->getActiveFansUidList($uid, ['a.uid'], $offset, $limit);
|
||||
}
|
||||
return $oFollowList;
|
||||
}
|
||||
|
||||
function countSendFans($bAllFans, $uid): int
|
||||
{
|
||||
$oFollowModel = new FollowModel();
|
||||
if ($bAllFans) {
|
||||
$iCount = $oFollowModel->getFansCount($uid); //获取所有粉丝列表
|
||||
} else { //读扩散流程(只针对活跃粉丝信箱插入一条)
|
||||
//获取活跃粉丝列表
|
||||
$iCount = $oFollowModel->getActiveFansUidListCount($uid);
|
||||
}
|
||||
return $iCount;
|
||||
}
|
||||
|
||||
//发送到推送信箱
|
||||
function sendPostToBox($aPost, $oFollowList): void
|
||||
{
|
||||
if (!$oFollowList) return;
|
||||
foreach ($oFollowList as $oFollow) {
|
||||
$aItem['uid'] = $oFollow->uid;
|
||||
$aItem['pid'] = $aPost['id'];
|
||||
$aItem['puuid'] = $aPost['uuid'];
|
||||
$aItem['post_created_at'] = $aPost['created_at'];
|
||||
$this->addItemWithCreateTime($aItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拉取推送信箱列表
|
||||
* @param $uid
|
||||
* @param $last_id //上次最后一条id
|
||||
* @param $limit
|
||||
* @return \Illuminate\Database\Eloquent\Collection|array
|
||||
*/
|
||||
function getPushBoxList($uid, $last_id = 0, $limit = 20, $cols = ['*']): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
//活跃用户直接拉取未读消息
|
||||
return $this->newQuery()
|
||||
->where('uid', $uid)
|
||||
// ->where('id', '>', $last_id)
|
||||
->where('is_read', self::IS_READ_NO)
|
||||
->orderBy('created_at', 'desc')
|
||||
->limit($limit)
|
||||
->get($cols);
|
||||
//非活跃用户拉取大v消息,在用户状态更新时已经调用过,此处不用在做处理
|
||||
}
|
||||
|
||||
//非活跃拉取已跟随大v最新文章。
|
||||
//放在用户状态更新时调用
|
||||
function pullBigFanMasterPostConsumer($uid)
|
||||
{
|
||||
//获取文章和转发文章
|
||||
//获取大v定义粉丝数,获取大于该粉丝数的大v文章
|
||||
$iConfigFansPushLimit = intval(env('CONFIG_FANS_PUSH_LIMIT', 2000));
|
||||
$oFollowModel = new FollowModel();
|
||||
$oFollowList = $oFollowModel->getFollowListWithFansLimit($uid, $iConfigFansPushLimit, ['a.follow_uid']);
|
||||
if ($oFollowList->isEmpty()) return null;
|
||||
$aFollowList = $oFollowList->toArray();
|
||||
$aFollowUid = array_column($aFollowList, 'follow_uid');
|
||||
$oPostModel = new PostModel();
|
||||
|
||||
//分批发送到信箱
|
||||
//@@大v评论拉取到自己信箱
|
||||
$iTotalCount = $oPostModel->CountPostListByUids($aFollowUid);
|
||||
$oCollectOffsetLimit = new CollectOffsetLimit();
|
||||
$oCollectOffsetLimit->setITotalCount($iTotalCount)->runWhile(function ($offset, $limit) use ($oPostModel,$aFollowUid,$uid) {
|
||||
$oPostList = $oPostModel->getPostListByUids($aFollowUid,null,['*'],$offset, $limit);
|
||||
if(empty($oPostList)) return;
|
||||
$this->sendPostToBoxByUid($oPostList->toArray(), $uid);
|
||||
});
|
||||
}
|
||||
|
||||
function sendPostToBoxByUid(array $oPostList, $uid): void
|
||||
{
|
||||
foreach ($oPostList as $oPost) {
|
||||
$aItem['type'] = $oPost->type;
|
||||
$aItem['uid'] = $uid;
|
||||
$aItem['pid'] = $oPost->id;
|
||||
$aItem['puuid'] = $oPost->uuid;
|
||||
$aItem['post_params'] = $oPost->post_params;
|
||||
$aItem['post_created_at'] = $oPost->created_at;
|
||||
$this->addItemWithCreateTime($aItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
16
app/Models/Api/Post/Structs/PostParamsStruct.php
Normal file
16
app/Models/Api/Post/Structs/PostParamsStruct.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace App\Models\Api\Post\Structs;
|
||||
class PostParamsStruct{
|
||||
const REPOST_ORG_USER_ID = 'repostOrgUserId';
|
||||
const REPOST_ORG_USERNAME = 'repostOrgUsername';
|
||||
const REPOST_ORG_USER_NICKNAME = 'repostOrgUserNickname';
|
||||
const REPOST_ORG_POST_ID = 'repostOrgPostId'; //原推文id
|
||||
|
||||
const COMMENT_ID = 'CommentId';
|
||||
const COMMENT_USER_ID = 'CommentUserId';
|
||||
const COMMENT_USERNAME = 'CommentUsername';
|
||||
const COMMENT_POST_ID = 'CommentPostId';
|
||||
const COMMENT_CONTEXT= 'CommentContext';
|
||||
const COMMENT_CONTEXT_CREATE_TIME= 'CommentContextCreateTime';
|
||||
|
||||
}
|
||||
130
app/Models/Api/Wallet/CustomerWalletBalanceModel.php
Normal file
130
app/Models/Api/Wallet/CustomerWalletBalanceModel.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Api\Wallet;
|
||||
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CustomerWalletBalanceModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_wallet_balance';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'uid',
|
||||
'currency_code',
|
||||
'total_amount',
|
||||
'frozen_amount',
|
||||
'available_amount',
|
||||
'security_amount',
|
||||
'recharge_wallet_addr',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
function frozenAmount($id,$amount): bool|int
|
||||
{
|
||||
$amount = abs($amount);
|
||||
$updateItem = [
|
||||
'id' => $id,
|
||||
'frozen_amount' => DB::raw('frozen_amount + '. $amount),
|
||||
'available_amount' => DB::raw('available_amount - '. $amount),
|
||||
];
|
||||
return $this->updateItem($updateItem);
|
||||
}
|
||||
|
||||
function unFrozenAmount($id,$amount): bool|int
|
||||
{
|
||||
$amount = abs($amount);
|
||||
$updateItem = [
|
||||
'id' => $id,
|
||||
'frozen_amount' => DB::raw('frozen_amount - '. $amount),
|
||||
'available_amount' => DB::raw('available_amount + '. $amount),
|
||||
];
|
||||
return $this->updateItem($updateItem);
|
||||
}
|
||||
|
||||
function subFrozenAmount($id, $amount): bool|int
|
||||
{
|
||||
$amount = abs($amount);
|
||||
$updateItem = [
|
||||
'id' => $id,
|
||||
'total_amount' => DB::raw('total_amount - '. $amount),
|
||||
'frozen_amount' => DB::raw('frozen_amount - '. $amount),
|
||||
];
|
||||
return $this->updateItem($updateItem);
|
||||
}
|
||||
|
||||
function addFrozenAmount($id, $amount): bool|int
|
||||
{
|
||||
$amount = abs($amount);
|
||||
$updateItem = [
|
||||
'id' => $id,
|
||||
'total_amount' => DB::raw('total_amount + '. $amount),
|
||||
'frozen_amount' => DB::raw('frozen_amount + '. $amount),
|
||||
];
|
||||
return $this->updateItem($updateItem);
|
||||
}
|
||||
|
||||
function subAvailableAmount($id, $amount): bool|int
|
||||
{
|
||||
$amount = abs($amount);
|
||||
$updateItem = [
|
||||
'id' => $id,
|
||||
'total_amount' => DB::raw('total_amount - '. $amount),
|
||||
'available_amount' => DB::raw('available_amount - '. $amount),
|
||||
];
|
||||
return $this->updateItem($updateItem);
|
||||
}
|
||||
|
||||
function addAvailableAmount($id, $amount): bool|int
|
||||
{
|
||||
$amount = abs($amount);
|
||||
$updateItem = [
|
||||
'id' => $id,
|
||||
'total_amount' => DB::raw('total_amount + '. $amount),
|
||||
'available_amount' => DB::raw('available_amount + '. $amount),
|
||||
];
|
||||
return $this->updateItem($updateItem);
|
||||
}
|
||||
|
||||
function balanceToSecurity($id, $amount): bool|int
|
||||
{
|
||||
$amount = abs($amount);
|
||||
$updateItem = [
|
||||
'id' => $id,
|
||||
'total_amount' => DB::raw('total_amount - '. $amount),
|
||||
'available_amount' => DB::raw('available_amount - '. $amount),
|
||||
'security_amount' => DB::raw('security_amount + '. $amount),
|
||||
];
|
||||
return $this->updateItem($updateItem);
|
||||
}
|
||||
|
||||
function securityToBalance($id, $amount): bool|int
|
||||
{
|
||||
$amount = abs($amount);
|
||||
$updateItem = [
|
||||
'id' => $id,
|
||||
'total_amount' => DB::raw('total_amount + '. $amount),
|
||||
'available_amount' => DB::raw('available_amount + '. $amount),
|
||||
'security_amount' => DB::raw('security_amount - '. $amount),
|
||||
];
|
||||
return $this->updateItem($updateItem);
|
||||
}
|
||||
|
||||
function subSecurityAmount($id, $amount): bool|int
|
||||
{
|
||||
$amount = abs($amount);
|
||||
$updateItem = [
|
||||
'id' => $id,
|
||||
'security_amount' => DB::raw('security_amount - '. $amount),
|
||||
];
|
||||
return $this->updateItem($updateItem);
|
||||
}
|
||||
|
||||
function findByUidCurrencyCode($uid, $currency_code): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
return $this->findItemByWhere(['uid' => $uid, 'currency_code' => $currency_code]);
|
||||
}
|
||||
|
||||
}
|
||||
883
app/Models/Api/Wallet/CustomerWalletBalanceTransactionModel.php
Normal file
883
app/Models/Api/Wallet/CustomerWalletBalanceTransactionModel.php
Normal file
@ -0,0 +1,883 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Api\Wallet;
|
||||
|
||||
use App\Bean\Model\Api\Order\CustomerUserPostOrderBean;
|
||||
use App\Bean\Model\Api\Wallet\CustomerWalletBalanceTransactionBean;
|
||||
use App\Cache\Table\Api\TableCustomerSettingCache;
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use App\Models\Api\Order\CustomerUserPostOrderModel;
|
||||
use App\Tools\Logs;
|
||||
use App\Tools\Math;
|
||||
use App\Tools\Times;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CustomerWalletBalanceTransactionModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_wallet_balance_transaction';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'type',
|
||||
'status',
|
||||
'wallet_id',
|
||||
'uid',
|
||||
'currency_code',
|
||||
'amount',
|
||||
'fee_amount',
|
||||
'before_total_amount',
|
||||
'after_total_amount',
|
||||
'source_params',
|
||||
'remark',
|
||||
'target_uid',
|
||||
'target_post_order_id',
|
||||
'target_post_order_dispute_id',
|
||||
'sign',
|
||||
'callback_time',
|
||||
'delay_payment_time',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
const TYPE_RECHARGE_ADD = 1;
|
||||
const TYPE_WITHDRAW_DEC = 2;
|
||||
const TYPE_ORDER_PAY_DEC = 3;
|
||||
const TYPE_ORDER_RECEIVE_ADD = 4;
|
||||
const TYPE_ORDER_REFUND_SUB = 5;
|
||||
const TYPE_BALANCE_TO_SECURITY = 6;
|
||||
const TYPE_SECURITY_TO_BALANCE = 7;
|
||||
const TYPE_DISPUTE_ADD = 8;
|
||||
const TYPE_DISPUTE_SUB = 9;
|
||||
const TYPE_TRANSACTION_FEE_SUB = 10;
|
||||
const TYPE_TRANSACTION_FEE_ADD = 11;
|
||||
const TYPE_ADMIN_ADD = 12;
|
||||
const TYPE_ADMIN_SUB = 13;
|
||||
const TYPE_TRANSFER_TO_USER_DEC = 14;
|
||||
const TYPE_TRANSFER_RECEIVE_ADD = 15;
|
||||
const TYPE_ORDER_DISPUTE_FEE_DEC = 16;
|
||||
const TYPE_ORDER_DISPUTE_FEE_ADD = 17;
|
||||
const TYPE = [
|
||||
self::TYPE_RECHARGE_ADD => '充值',
|
||||
self::TYPE_WITHDRAW_DEC => '提现',
|
||||
self::TYPE_ORDER_PAY_DEC => '订单支付',
|
||||
self::TYPE_ORDER_RECEIVE_ADD => '订单收款',
|
||||
self::TYPE_ORDER_REFUND_SUB => '订单退款',
|
||||
self::TYPE_BALANCE_TO_SECURITY => '余额转保证金',
|
||||
self::TYPE_SECURITY_TO_BALANCE => '保证金转余额',
|
||||
self::TYPE_DISPUTE_ADD => '纠纷加款',
|
||||
self::TYPE_DISPUTE_SUB => '纠纷扣款',
|
||||
self::TYPE_TRANSACTION_FEE_SUB => '交易手续费扣除',
|
||||
self::TYPE_TRANSACTION_FEE_ADD => '交易手续费增加',
|
||||
self::TYPE_ADMIN_ADD => '管理员加款',
|
||||
self::TYPE_ADMIN_SUB => '管理员扣款',
|
||||
self::TYPE_TRANSFER_TO_USER_DEC => '转账给用户',
|
||||
self::TYPE_TRANSFER_RECEIVE_ADD => '转账收款',
|
||||
self::TYPE_ORDER_DISPUTE_FEE_DEC => '纠纷仲裁费用扣除',
|
||||
self::TYPE_ORDER_DISPUTE_FEE_ADD => '纠纷仲裁费用退还',
|
||||
];
|
||||
|
||||
const STATUS_WAIT = 1;
|
||||
const STATUS_PROCESSING = 2;
|
||||
const STATUS_SUCCESS = 3;
|
||||
const STATUS_FAIL = 4;
|
||||
const STATUS_DELAY_PAYMENT = 5;
|
||||
const STATUS = [
|
||||
self::STATUS_WAIT => '等待处理',
|
||||
self::STATUS_PROCESSING => '处理中',
|
||||
self::STATUS_SUCCESS => '成功',
|
||||
self::STATUS_FAIL => '失败',
|
||||
self::STATUS_DELAY_PAYMENT => '延期到账',
|
||||
];
|
||||
|
||||
const SOURCE_PARAMS_BALANCE = 1;
|
||||
const SOURCE_PARAMS_SECURITY = 2;
|
||||
const SOURCE_PARAMS = [
|
||||
self::SOURCE_PARAMS_BALANCE => '余额',
|
||||
self::SOURCE_PARAMS_SECURITY => '保证金',
|
||||
];
|
||||
|
||||
function getDelayPayList($datetime, $col = ['*']): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
return $this->newQuery()->where('status', self::STATUS_DELAY_PAYMENT)->where('delay_payment_time', '<=', $datetime)->limit(100)->get($col);
|
||||
}
|
||||
|
||||
//纠纷仲裁费用退还
|
||||
function typeOrderDisputeFeeAdd($uid, $currency_code, $amount, $remark = null): bool
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(abs($amount)); //正数
|
||||
$bean->setType(self::TYPE_ORDER_DISPUTE_FEE_ADD);
|
||||
$bean->setStatus(self::STATUS_SUCCESS);
|
||||
$bean->setRemark($remark);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount(Math::bcAdd($resWalletBalanceModel->total_amount, $bean->getAmount()));
|
||||
//新增账变
|
||||
$res = $this->addTransaction($bean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
//变更余额
|
||||
$res = $oCustomerWalletBalanceModel->addAvailableAmount($bean->getWalletId(), $bean->getAmount());
|
||||
if (!$res) throw new ModelException('order dispute fee add fail');
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//纠纷仲裁费用扣除
|
||||
function typeOrderDisputeFeeDec($uid, $currency_code, $amount, $remark = null): bool
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(-abs($amount)); //账变负数
|
||||
$bean->setType(self::TYPE_ORDER_DISPUTE_FEE_DEC);
|
||||
$bean->setStatus(self::STATUS_SUCCESS);
|
||||
$bean->setRemark($remark);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
if (Math::bcComp($resWalletBalanceModel->available_amount, abs($bean->getAmount())) != -1) throw new ModelException('balance not enough');
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount(Math::bcAdd($resWalletBalanceModel->total_amount, $bean->getAmount()));
|
||||
//新增账变
|
||||
$res = $this->addTransaction($bean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
//变更余额
|
||||
$res = $oCustomerWalletBalanceModel->subAvailableAmount($bean->getWalletId(), $bean->getAmount());
|
||||
if (!$res) throw new ModelException('order dispute fee dec fail');
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//处理延期账变
|
||||
function dealDelayPaymentTransactionCmd(): void
|
||||
{
|
||||
$datetimeNow = Times::getNowDateTime();
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
while (true) {
|
||||
$resList = $this->getDelayPayList($datetimeNow, ['id']);
|
||||
if ($resList->isEmpty()) {
|
||||
break;
|
||||
}
|
||||
foreach ($resList as $itemId) {
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$item = $this->findItem($itemId->id);
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findItem($item->wallet_id);
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
$updateItem = [
|
||||
'id' => $item->id,
|
||||
'status' => self::STATUS_SUCCESS,
|
||||
'updated_at' => Times::getNowDateTime(),
|
||||
];
|
||||
$res = $this->updateItem($updateItem);
|
||||
if (!$res) throw new ModelException('updateItem fail');
|
||||
$res = $oCustomerWalletBalanceModel->unFrozenAmount($item->wallet_id, $item->amount);
|
||||
if (!$res) throw new ModelException('unFrozenAmount fail');
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//转账给用户
|
||||
function typeTransferToUser($uid, $target_uid, $currency_code, $amount, $remark = null): bool
|
||||
{
|
||||
$senderWalletTransactionBean = new CustomerWalletBalanceTransactionBean();
|
||||
$receiverWalletTransactionBean = new CustomerWalletBalanceTransactionBean();
|
||||
|
||||
$senderWalletTransactionBean->setUid($uid);
|
||||
$senderWalletTransactionBean->setTargetUid($target_uid);
|
||||
$senderWalletTransactionBean->setCurrencyCode($currency_code);
|
||||
$senderWalletTransactionBean->setAmount(-abs($amount)); //账变负数
|
||||
$senderWalletTransactionBean->setType(self::TYPE_TRANSFER_TO_USER_DEC);
|
||||
$senderWalletTransactionBean->setStatus(self::STATUS_SUCCESS);
|
||||
$senderWalletTransactionBean->setRemark($remark);
|
||||
|
||||
$receiverWalletTransactionBean->setUid($target_uid);
|
||||
$receiverWalletTransactionBean->setTargetUid($uid);
|
||||
$receiverWalletTransactionBean->setCurrencyCode($currency_code);
|
||||
$receiverWalletTransactionBean->setAmount(abs($amount)); //账变正数
|
||||
$receiverWalletTransactionBean->setType(self::TYPE_TRANSFER_RECEIVE_ADD);
|
||||
$receiverWalletTransactionBean->setStatus(self::STATUS_SUCCESS);
|
||||
$receiverWalletTransactionBean->setRemark($remark);
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询发送人余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resSenderWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($senderWalletTransactionBean->getUid(), $senderWalletTransactionBean->getCurrencyCode());
|
||||
if (!$resSenderWalletBalanceModel) throw new ModelException('sender wallet not found');
|
||||
//加悲观锁
|
||||
$resSenderWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resSenderWalletBalanceModel->id);
|
||||
//查询接收人余额
|
||||
$resReceiverWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($receiverWalletTransactionBean->getUid(), $receiverWalletTransactionBean->getCurrencyCode());
|
||||
if (!$resReceiverWalletBalanceModel) throw new ModelException('receiver wallet not found');
|
||||
//加悲观锁
|
||||
$resReceiverWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resReceiverWalletBalanceModel->id);
|
||||
|
||||
//检查发送人余额是否足够
|
||||
if (Math::bcComp($resSenderWalletBalanceModel->available_amount, abs($senderWalletTransactionBean->getAmount())) != -1) throw new ModelException('balance not enough');
|
||||
$senderWalletTransactionBean->setWalletId($resSenderWalletBalanceModel->id);
|
||||
$senderWalletTransactionBean->setBeforeTotalAmount($resSenderWalletBalanceModel->total_amount);
|
||||
$senderWalletTransactionBean->setAfterTotalAmount(Math::bcAdd($resSenderWalletBalanceModel->total_amount, $senderWalletTransactionBean->getAmount()));
|
||||
|
||||
//发送人新增账变
|
||||
$res = $this->addTransaction($senderWalletTransactionBean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
//发送人变更余额
|
||||
$res = $oCustomerWalletBalanceModel->subAvailableAmount($senderWalletTransactionBean->getWalletId(), $senderWalletTransactionBean->getAmount());
|
||||
if (!$res) throw new ModelException('transfer to user dec fail');
|
||||
|
||||
//接收人账变
|
||||
$receiverWalletTransactionBean->setWalletId($resReceiverWalletBalanceModel->id);
|
||||
$receiverWalletTransactionBean->setBeforeTotalAmount($resReceiverWalletBalanceModel->total_amount);
|
||||
$receiverWalletTransactionBean->setAfterTotalAmount(Math::bcAdd($resReceiverWalletBalanceModel->total_amount, $receiverWalletTransactionBean->getAmount()));
|
||||
//接收人新增账变
|
||||
$res = $this->addTransaction($receiverWalletTransactionBean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
//接收人变更余额
|
||||
$res = $oCustomerWalletBalanceModel->addAvailableAmount($receiverWalletTransactionBean->getWalletId(), $receiverWalletTransactionBean->getAmount());
|
||||
if (!$res) throw new ModelException('transfer receive add fail');
|
||||
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//管理员扣除
|
||||
function typeAdminSub($uid, $currency_code, $amount, $remark = null): bool
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(-abs($amount)); //账变负数
|
||||
$bean->setType(self::TYPE_ADMIN_SUB);
|
||||
$bean->setStatus(self::STATUS_SUCCESS);
|
||||
$bean->setRemark($remark);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
if (Math::bcComp($resWalletBalanceModel->available_amount, abs($bean->getAmount())) != -1) throw new ModelException('balance not enough');
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount(Math::bcAdd($resWalletBalanceModel->total_amount, $bean->getAmount()));
|
||||
|
||||
//新增账变
|
||||
$res = $this->addTransaction($bean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
//变更余额
|
||||
$res = $oCustomerWalletBalanceModel->subAvailableAmount($bean->getWalletId(), $bean->getAmount());
|
||||
if (!$res) throw new ModelException('admin sub fail');
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//管理员增加
|
||||
function typeAdminAdd($uid, $currency_code, $amount, $remark = null): bool
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(abs($amount)); //正数
|
||||
$bean->setType(self::TYPE_ADMIN_ADD);
|
||||
$bean->setStatus(self::STATUS_SUCCESS);
|
||||
$bean->setRemark($remark);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount(Math::bcAdd($resWalletBalanceModel->total_amount, $bean->getAmount()));
|
||||
//新增账变
|
||||
$res = $this->addTransaction($bean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
//变更余额
|
||||
$res = $oCustomerWalletBalanceModel->addAvailableAmount($bean->getWalletId(), $bean->getAmount());
|
||||
if (!$res) throw new ModelException('admin add fail');
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//手续费增加
|
||||
function typeTransactionFeeAdd($uid, $currency_code, $amount, $remark = null): bool
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(abs($amount)); //正数
|
||||
$bean->setType(self::TYPE_TRANSACTION_FEE_ADD);
|
||||
$bean->setStatus(self::STATUS_SUCCESS);
|
||||
$bean->setRemark($remark);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount(Math::bcAdd($resWalletBalanceModel->total_amount, $bean->getAmount()));
|
||||
//新增账变
|
||||
$res = $this->addTransaction($bean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
//变更余额
|
||||
$res = $oCustomerWalletBalanceModel->addAvailableAmount($bean->getWalletId(), $bean->getAmount());
|
||||
if (!$res) throw new ModelException('transaction fee add fail');
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//手续费扣除
|
||||
function typeTransactionFeeSub($uid, $currency_code, $amount, $remark = null): bool
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(-abs($amount)); //账变负数
|
||||
$bean->setType(self::TYPE_TRANSACTION_FEE_SUB);
|
||||
$bean->setStatus(self::STATUS_SUCCESS);
|
||||
$bean->setRemark($remark);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount(Math::bcAdd($resWalletBalanceModel->total_amount, $bean->getAmount()));
|
||||
|
||||
//新增账变
|
||||
$res = $this->addTransaction($bean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
//变更余额
|
||||
//检查余额是否足够
|
||||
if (Math::bcComp($resWalletBalanceModel->available_amount, abs($bean->getAmount())) != -1) { //从余额中扣除
|
||||
$bean->setSourceParams(self::SOURCE_PARAMS_BALANCE);
|
||||
$res = $oCustomerWalletBalanceModel->subAvailableAmount($bean->getWalletId(), $bean->getAmount());
|
||||
} else if (Math::bcComp($resWalletBalanceModel->security_amount, abs($bean->getAmount())) != -1) { //从保证金中扣除
|
||||
$bean->setSourceParams(self::SOURCE_PARAMS_SECURITY);
|
||||
$res = $oCustomerWalletBalanceModel->subSecurityAmount($bean->getWalletId(), $bean->getAmount());
|
||||
} else {
|
||||
throw new ModelException('balance and security not enough');
|
||||
}
|
||||
if (!$res) throw new ModelException('transaction fee sub fail');
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//仲裁判罚扣除
|
||||
function typeDisputeSub($uid, $currency_code, $amount, $target_post_order_dispute_id, $remark = null): bool|int
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(-abs($amount)); //账变负数
|
||||
$bean->setType(self::TYPE_DISPUTE_SUB);
|
||||
$bean->setStatus(self::STATUS_SUCCESS);
|
||||
$bean->setRemark($remark);
|
||||
$bean->setTargetPostOrderDisputeId($target_post_order_dispute_id);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount(Math::bcAdd($resWalletBalanceModel->total_amount, $bean->getAmount()));
|
||||
|
||||
//新增账变
|
||||
$resModel = $this->addTransaction($bean);
|
||||
if (!$resModel) throw new ModelException('addTransaction fail');
|
||||
//变更余额
|
||||
//检查余额是否足够
|
||||
if (Math::bcComp($resWalletBalanceModel->available_amount, abs($bean->getAmount())) != -1) { //从余额中扣除
|
||||
$bean->setSourceParams(self::SOURCE_PARAMS_BALANCE);
|
||||
$res = $oCustomerWalletBalanceModel->subAvailableAmount($bean->getWalletId(), $bean->getAmount());
|
||||
} else if (Math::bcComp($resWalletBalanceModel->security_amount, abs($bean->getAmount())) != -1) { //从保证金中扣除
|
||||
$bean->setSourceParams(self::SOURCE_PARAMS_SECURITY);
|
||||
$res = $oCustomerWalletBalanceModel->subSecurityAmount($bean->getWalletId(), $bean->getAmount());
|
||||
} else {
|
||||
throw new ModelException('balance and security not enough');
|
||||
}
|
||||
if (!$res) throw new ModelException('dispute sub fail');
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return $resModel->id;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//仲裁判罚增加
|
||||
function typeDisputeAdd($uid, $currency_code, $amount, $target_post_order_dispute_id, $remark = null): bool|int
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(abs($amount)); //正数
|
||||
$bean->setType(self::TYPE_DISPUTE_ADD);
|
||||
$bean->setStatus(self::STATUS_SUCCESS);
|
||||
$bean->setRemark($remark);
|
||||
$bean->setTargetPostOrderDisputeId($target_post_order_dispute_id);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount(Math::bcAdd($resWalletBalanceModel->total_amount, $bean->getAmount()));
|
||||
//新增账变
|
||||
$resModel = $this->addTransaction($bean);
|
||||
if (!$resModel) throw new ModelException('addTransaction fail');
|
||||
//变更余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$res = $oCustomerWalletBalanceModel->addAvailableAmount($bean->getWalletId(), $bean->getAmount());
|
||||
if (!$res) throw new ModelException('dispute add fail');
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return $resModel->id;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//押金转余额
|
||||
function typeSecurityToBalance($uid, $currency_code, $amount): bool
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(abs($amount)); //正数
|
||||
$bean->setType(self::TYPE_SECURITY_TO_BALANCE);
|
||||
$bean->setStatus(self::STATUS_SUCCESS);
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount(Math::bcAdd($resWalletBalanceModel->total_amount, $bean->getAmount()));
|
||||
|
||||
//检查保证金是否足够
|
||||
if (Math::bcComp($resWalletBalanceModel->security_amount, abs($bean->getAmount())) == -1) throw new ModelException('security not enough');
|
||||
|
||||
//新增账变
|
||||
$res = $this->addTransaction($bean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
|
||||
//变更余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$res = $oCustomerWalletBalanceModel->securityToBalance($bean->getWalletId(), $bean->getAmount());
|
||||
if (!$res) throw new ModelException('securityToBalance fail');
|
||||
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//余额转押金
|
||||
function typeBalanceToSecurity($uid, $currency_code, $amount): bool
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(-abs($amount)); //账变负数
|
||||
$bean->setType(self::TYPE_BALANCE_TO_SECURITY);
|
||||
$bean->setStatus(self::STATUS_SUCCESS);
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount(Math::bcAdd($resWalletBalanceModel->total_amount, $bean->getAmount()));
|
||||
|
||||
//检查余额是否足够
|
||||
if (Math::bcComp($resWalletBalanceModel->available_amount, abs($bean->getAmount())) == -1) throw new ModelException('balance not enough');
|
||||
|
||||
//新增账变
|
||||
$res = $this->addTransaction($bean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
|
||||
//变更余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$res = $oCustomerWalletBalanceModel->balanceToSecurity($bean->getWalletId(), $bean->getAmount());
|
||||
if (!$res) throw new ModelException('balanceToSecurity fail');
|
||||
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//订单支付
|
||||
function typeOrderPay(CustomerUserPostOrderBean $orderBean): bool
|
||||
{
|
||||
//初始检测
|
||||
if ($orderBean->getBuyerCurrencyCode() != $orderBean->getSellerCurrencyCode()) throw new ModelException('currency_code not match');
|
||||
if ($orderBean->getBuyerUid() == $orderBean->getSellerUid()) throw new ModelException('buyer_uid can not match seller_uid');
|
||||
if ($orderBean->getAmount() <= 0) throw new ModelException('amount error');
|
||||
$orderBean->setAmount(abs($orderBean->getAmount())); //限制正数
|
||||
|
||||
$buyerWalletTransactionBean = new CustomerWalletBalanceTransactionBean();
|
||||
$sellerWalletTransactionBean = new CustomerWalletBalanceTransactionBean();
|
||||
//买家初始化
|
||||
$buyerWalletTransactionBean->setType(self::TYPE_ORDER_PAY_DEC);
|
||||
$buyerWalletTransactionBean->setStatus(self::STATUS_SUCCESS);
|
||||
$buyerWalletTransactionBean->setAmount(-$orderBean->getAmount()); //负数
|
||||
$buyerWalletTransactionBean->setUid($orderBean->getBuyerUid());
|
||||
$buyerWalletTransactionBean->setCurrencyCode($orderBean->getBuyerCurrencyCode());
|
||||
$buyerWalletTransactionBean->setTargetPostOrderId($orderBean->getId());
|
||||
//卖家初始化
|
||||
$sellerWalletTransactionBean->setType(self::TYPE_ORDER_RECEIVE_ADD);
|
||||
$sellerWalletTransactionBean->setStatus(self::STATUS_DELAY_PAYMENT);
|
||||
$sellerWalletTransactionBean->setAmount($orderBean->getAmount()); //正数
|
||||
$sellerWalletTransactionBean->setUid($orderBean->getSellerUid());
|
||||
$sellerWalletTransactionBean->setCurrencyCode($orderBean->getSellerCurrencyCode());
|
||||
$sellerWalletTransactionBean->setTargetPostOrderId($orderBean->getId());
|
||||
//@@计算订单延期到账时间
|
||||
$delay_payment_time = Times::getNowDateTimeAddDays(1);
|
||||
$sellerWalletTransactionBean->setDelayPaymentTime($delay_payment_time);
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询买家余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resBuyerWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($buyerWalletTransactionBean->getUid(), $buyerWalletTransactionBean->getCurrencyCode());
|
||||
if (!$resBuyerWalletBalanceModel) throw new ModelException('buyer wallet not found');
|
||||
//加悲观锁
|
||||
$resBuyerWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resBuyerWalletBalanceModel->id);
|
||||
//检查买家余额是否足够
|
||||
if (Math::bcComp($resBuyerWalletBalanceModel->available_amount, abs($orderBean->getAmount())) == -1) throw new ModelException('buyer balance not enough');
|
||||
|
||||
//设置买家卖家钱包id
|
||||
$buyerWalletTransactionBean->setWalletId($resBuyerWalletBalanceModel->id);
|
||||
$buyerWalletTransactionBean->setBeforeTotalAmount($resBuyerWalletBalanceModel->total_amount);
|
||||
$buyerWalletTransactionBean->setAfterTotalAmount(Math::bcAdd($resBuyerWalletBalanceModel->total_amount, $buyerWalletTransactionBean->getAmount()));
|
||||
//设置卖家卖家钱包id
|
||||
$resSellerWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($sellerWalletTransactionBean->getUid(), $sellerWalletTransactionBean->getCurrencyCode());
|
||||
if (!$resSellerWalletBalanceModel) throw new ModelException('seller wallet not found');
|
||||
//加悲观锁
|
||||
$resSellerWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resSellerWalletBalanceModel->id);
|
||||
$sellerWalletTransactionBean->setWalletId($resSellerWalletBalanceModel->id);
|
||||
$sellerWalletTransactionBean->setBeforeTotalAmount($resSellerWalletBalanceModel->total_amount);
|
||||
$sellerWalletTransactionBean->setAfterTotalAmount(Math::bcAdd($resSellerWalletBalanceModel->total_amount, $sellerWalletTransactionBean->getAmount()));
|
||||
|
||||
//买家新增账变
|
||||
$resBuyerTransaction = $this->addTransaction($buyerWalletTransactionBean);
|
||||
if (!$resBuyerTransaction) throw new ModelException('buyer addTransaction fail');
|
||||
$buyerWalletTransactionBean->setId($resBuyerTransaction->id);
|
||||
//买家变更余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$res = $oCustomerWalletBalanceModel->subAvailableAmount($buyerWalletTransactionBean->getWalletId(), $buyerWalletTransactionBean->getAmount());
|
||||
if (!$res) throw new ModelException('buyer order pay fail');
|
||||
|
||||
//卖家新增账变
|
||||
$resSellerTransaction = $this->addTransaction($sellerWalletTransactionBean);
|
||||
if (!$resSellerTransaction) throw new ModelException('seller addTransaction fail');
|
||||
$sellerWalletTransactionBean->setId($resSellerTransaction->id);
|
||||
//卖家变更余额
|
||||
$res = $oCustomerWalletBalanceModel->addFrozenAmount($sellerWalletTransactionBean->getWalletId(), $sellerWalletTransactionBean->getAmount());
|
||||
if (!$res) throw new ModelException('seller order receive fail');
|
||||
|
||||
//更新订单状态
|
||||
$oCustomerUserPostOrderModel = new CustomerUserPostOrderModel();
|
||||
$updateItem = [
|
||||
'id' => $orderBean->getId(),
|
||||
'pay_status' => CustomerUserPostOrderModel::PAY_STATUS_PAID,
|
||||
'buyer_wallet_transaction_id' => $buyerWalletTransactionBean->getId(),
|
||||
'seller_wallet_transaction_id' => $sellerWalletTransactionBean->getId(),
|
||||
'updated_at' => Times::getNowDateTime(),
|
||||
];
|
||||
$res = $oCustomerUserPostOrderModel->updateItem($updateItem);
|
||||
if (!$res) throw new ModelException('updateItem fail');
|
||||
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//发起提现
|
||||
function typeWithdrawFirst($uid, $currency_code, $amount): bool
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(-abs($amount)); //负数
|
||||
$bean->setUid($uid);
|
||||
$bean->setType(self::TYPE_WITHDRAW_DEC);
|
||||
$bean->setStatus(self::STATUS_PROCESSING);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//获取提现手续费
|
||||
$oTableCustomerSettingCache = new TableCustomerSettingCache();
|
||||
$withdraw_fee = $oTableCustomerSettingCache->getWithdrawFeeAmount();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
//检查余额是否足够
|
||||
if (Math::bcComp(Math::bcSub($resWalletBalanceModel->available_amount, $withdraw_fee), abs($bean->getAmount())) == -1) throw new ModelException('balance not enough');
|
||||
|
||||
$bean->setFeeAmount($withdraw_fee);
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount($resWalletBalanceModel->total_amount);
|
||||
//新增账变
|
||||
$res = $this->addTransaction($bean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
//先扣除手续费
|
||||
$res = $this->typeTransactionFeeSub($uid, $currency_code, $withdraw_fee, $res->id . ' withdraw fee');
|
||||
if (!$res) throw new ModelException('withdraw fee fail');
|
||||
//变更余额
|
||||
//先冻结,等回调成功再扣减
|
||||
$res = $oCustomerWalletBalanceModel->frozenAmount($bean->getWalletId(), $bean->getAmount());
|
||||
if (!$res) throw new ModelException('withdraw fail');
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
//@@发送到提现通知钱包队列
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//提现回调
|
||||
function typeWithdrawSecondCallback($id, $status, $remark = null): bool
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$resModel = $this->findItem($id);
|
||||
if (!$resModel) throw new ModelException('transaction not found');
|
||||
if ($resModel->status != self::STATUS_PROCESSING) throw new ModelException('transaction status error');
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findItem($resModel->wallet_id);
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
|
||||
if ($status == self::STATUS_SUCCESS) {
|
||||
//扣减冻结金额
|
||||
$res = $oCustomerWalletBalanceModel->subFrozenAmount($resModel->wallet_id, $resModel->amount);
|
||||
if (!$res) throw new ModelException('withdraw fail');
|
||||
//更新账变状态
|
||||
$updateItem = [
|
||||
'id' => $id,
|
||||
'status' => self::STATUS_SUCCESS,
|
||||
'updated_at' => Times::getNowDateTime(),
|
||||
'before_total_amount' => $resWalletBalanceModel->total_amount,
|
||||
'after_total_amount' => Math::bcAdd($resWalletBalanceModel->total_amount, $resModel->amount)
|
||||
];
|
||||
if (!empty($remark)) $updateItem['remark'] = $remark;
|
||||
$res = $this->updateItem($updateItem);
|
||||
if (!$res) throw new ModelException('updateItem fail');
|
||||
} else { //失败
|
||||
//解冻
|
||||
$res = $oCustomerWalletBalanceModel->unFrozenAmount($resModel->wallet_id, $resModel->amount);
|
||||
if (!$res) throw new ModelException('withdraw fail');
|
||||
//更新账变状态
|
||||
$updateItem = [
|
||||
'id' => $id,
|
||||
'status' => self::STATUS_FAIL,
|
||||
'updated_at' => Times::getNowDateTime(),
|
||||
];
|
||||
if (!empty($remark)) $updateItem['remark'] = $remark;
|
||||
$res = $this->updateItem($updateItem);
|
||||
if (!$res) throw new ModelException('updateItem fail');
|
||||
//返还手续费
|
||||
$res = $this->typeTransactionFeeAdd($resModel->uid, $resModel->currency_code, $resModel->fee_amount, $resModel->id . ' withdraw fail return fee');
|
||||
if (!$res) throw new ModelException('withdraw fail return fee fail');
|
||||
}
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__ . ' ' . 'rollBack', $e, func_get_args());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//充值
|
||||
function typeRecharge($uid, $currency_code, $amount): bool
|
||||
{
|
||||
$bean = new CustomerWalletBalanceTransactionBean();
|
||||
$bean->setUid($uid);
|
||||
$bean->setCurrencyCode($currency_code);
|
||||
$bean->setAmount(abs($amount)); //正数
|
||||
$bean->setUid($uid);
|
||||
$bean->setType(self::TYPE_RECHARGE_ADD);
|
||||
$bean->setStatus(self::STATUS_SUCCESS);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//查询用户余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByUidCurrencyCode($bean->getUid(), $bean->getCurrencyCode());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
//加悲观锁
|
||||
$resWalletBalanceModel = $oCustomerWalletBalanceModel->findByWhereWithLock($resWalletBalanceModel->id);
|
||||
$bean->setWalletId($resWalletBalanceModel->id);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
$bean->setAfterTotalAmount(Math::bcAdd($resWalletBalanceModel->total_amount, $bean->getAmount()));
|
||||
//新增账变
|
||||
$res = $this->addTransaction($bean);
|
||||
if (!$res) throw new ModelException('addTransaction fail');
|
||||
//变更余额
|
||||
$oCustomerWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$res = $oCustomerWalletBalanceModel->addAvailableAmount($bean->getWalletId(), $bean->getAmount());
|
||||
if (!$res) throw new ModelException('recharge fail');
|
||||
|
||||
DB::commit();
|
||||
Logs::SuccLog(__FUNCTION__, func_get_args());
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Logs::ErrLog(__FUNCTION__.'typeRecharge error rollBack', $e);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function addTransaction(CustomerWalletBalanceTransactionBean &$bean): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|bool
|
||||
{
|
||||
if (!$bean->getWalletId()) throw new ModelException('wallet_id is required');
|
||||
if (!$bean->getType()) throw new ModelException('type is required');
|
||||
if (!$bean->getStatus()) $bean->setStatus(self::STATUS_WAIT);
|
||||
if (empty($bean->getUid()) || empty($bean->getBeforeTotalAmount())) {
|
||||
$oWalletBalanceModel = new CustomerWalletBalanceModel();
|
||||
$resWalletBalanceModel = $oWalletBalanceModel->findItem($bean->getWalletId());
|
||||
if (!$resWalletBalanceModel) throw new ModelException('wallet not found');
|
||||
$bean->setUid($resWalletBalanceModel->uid);
|
||||
$bean->setBeforeTotalAmount($resWalletBalanceModel->total_amount);
|
||||
}
|
||||
$bean->setCreatedAt(Times::getNowDateTime());
|
||||
$bean->setUpdatedAt(Times::getNowDateTime());
|
||||
return $this->addItem($bean->toArrayNotNull());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
29
app/Models/Api/Wallet/CustomerWalletCurrencyModel.php
Normal file
29
app/Models/Api/Wallet/CustomerWalletCurrencyModel.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace App\Models\Api\Wallet;
|
||||
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use Spatie\FlareClient\Api;
|
||||
|
||||
class CustomerWalletCurrencyModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_wallet_currency';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'type',
|
||||
'name',
|
||||
'code',
|
||||
'token',
|
||||
'transfer_rate',
|
||||
'desc',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
const TYPE_CASH = 1;
|
||||
const TYPE_CRYPTO_COIN = 2;
|
||||
const TYPE = [
|
||||
self::TYPE_CASH => '现金',
|
||||
self::TYPE_CRYPTO_COIN => '加密货币',
|
||||
];
|
||||
const CODE_USDT_TRC20 = 'USDT_TRC20';
|
||||
}
|
||||
@ -1,15 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\WebSocket;
|
||||
namespace App\Models\Api\WebSocket;
|
||||
|
||||
use App\Cache\Table\TableCustomerUserCache;
|
||||
use App\Models\Base\CustomerBaseModel;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use App\Models\Api\Base\ApiBaseModel;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class CustomerWsHistoryModel extends CustomerBaseModel
|
||||
class CustomerWsHistoryModel extends ApiBaseModel
|
||||
{
|
||||
protected $table = 'customer_ws_history';
|
||||
protected $primaryKey = 'id';
|
||||
@ -46,4 +43,17 @@ class CustomerWsHistoryModel extends CustomerBaseModel
|
||||
->toArray();
|
||||
}
|
||||
|
||||
//获取判断用户是否活跃
|
||||
//@需要加入缓存-缓存时间为3天
|
||||
function findActiveUserId($uid, $date, $days = 3): array
|
||||
{
|
||||
return $this->newQuery()
|
||||
->where('uid', $uid)
|
||||
->where('event', self::EVENT_ON_CONNECT)
|
||||
->where('status', self::STATUS_SUCCESS)
|
||||
->whereBetween(DB::raw("DATE_FORMAT(created_at,'%Y-%m-%d')"), [Carbon::parse($date)->subDays($days - 1)->toDateString(), Carbon::parse($date)->toDateString()])
|
||||
->first(['uid'])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,14 +2,19 @@
|
||||
|
||||
namespace App\Models\Base;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class BaseModel extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
const LOCK_TYPE_FOR_UPDATE = 1;
|
||||
const LOCK_TYPE_FOR_SHARE = 2;
|
||||
const LOCK_TYPE = [
|
||||
self::LOCK_TYPE_FOR_UPDATE => '悲观锁',
|
||||
self::LOCK_TYPE_FOR_SHARE => '乐观锁',
|
||||
];
|
||||
|
||||
function checkColInFill($aItem)
|
||||
{
|
||||
foreach ($aItem as $key => $value) {
|
||||
@ -27,6 +32,14 @@ class BaseModel extends Model
|
||||
return $this->newQuery()->create($aItem);
|
||||
}
|
||||
|
||||
function addItemWithCreateTime($aItem,$col = 'created_at'): Model|\Illuminate\Database\Eloquent\Builder|bool
|
||||
{
|
||||
$aItem = $this->checkColInFill($aItem);
|
||||
if (empty($aItem)) return false;
|
||||
$aItem[$col] = date('Y-m-d H:i:s');
|
||||
return $this->newQuery()->create($aItem);
|
||||
}
|
||||
|
||||
function delItem($id)
|
||||
{
|
||||
return $this->newQuery()->where($this->primaryKey, $id)->delete();
|
||||
@ -37,7 +50,8 @@ class BaseModel extends Model
|
||||
if(!$col) $col = $this->primaryKey;
|
||||
$aItem = $this->checkColInFill($aItem);
|
||||
if (empty($aItem)) return false;
|
||||
if (isset($aItem[$col])) return false;
|
||||
if (!isset($aItem[$col])) return false;
|
||||
if (empty($aItem[$col])) return false;
|
||||
return $this->newQuery()->where($col,$aItem[$col])->update($aItem);
|
||||
}
|
||||
|
||||
@ -57,6 +71,28 @@ class BaseModel extends Model
|
||||
return $this->newQuery()->where($aWhere)->get($col);
|
||||
}
|
||||
|
||||
function findByPrimaryKeyWithLock($id,$lock_type = self::LOCK_TYPE_FOR_UPDATE): Model|\Illuminate\Database\Eloquent\Builder|null
|
||||
{
|
||||
$model = $this->newQuery()->where($this->primaryKey, $id);
|
||||
if($lock_type == self::LOCK_TYPE_FOR_SHARE){
|
||||
$model = $model->sharedLock();
|
||||
}elseif ($lock_type == self::LOCK_TYPE_FOR_UPDATE){
|
||||
$model = $model->lockForUpdate();
|
||||
}
|
||||
return $model->first();
|
||||
}
|
||||
|
||||
function findByWhereWithLock($id,$col=['*'],$lock_type = self::LOCK_TYPE_FOR_UPDATE): Model|\Illuminate\Database\Eloquent\Builder|null
|
||||
{
|
||||
$model = $this->newQuery()->where($this->primaryKey, $id);
|
||||
if($lock_type == self::LOCK_TYPE_FOR_SHARE){
|
||||
$model = $model->sharedLock();
|
||||
}elseif ($lock_type == self::LOCK_TYPE_FOR_UPDATE){
|
||||
$model = $model->lockForUpdate();
|
||||
}
|
||||
return $model->first($col);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Base;
|
||||
|
||||
class CustomerBaseModel extends BaseModel {
|
||||
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Customer;
|
||||
|
||||
use App\Cache\Table\TableCustomerUserCache;
|
||||
use App\Models\Base\CustomerBaseModel;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class CustomerLoginHistoryModel extends CustomerBaseModel
|
||||
{
|
||||
protected $table = 'customer_login_history';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'status',
|
||||
'uid',
|
||||
'device',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
}
|
||||
@ -1,154 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Customer;
|
||||
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Base\CustomerBaseModel;
|
||||
use App\Models\WebSocket\CustomerWsHistoryModel;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CustomerUserExtendModel extends CustomerBaseModel
|
||||
{
|
||||
|
||||
protected $table = 'customer_user_extend';
|
||||
protected $primaryKey = 'uid';
|
||||
|
||||
protected $fillable = [
|
||||
'uid',
|
||||
'is_active',
|
||||
'fans_num',
|
||||
'follow_num',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
const COL_IS_ACTIVE = 'is_active';
|
||||
|
||||
//是否活跃用户
|
||||
const IS_ACTIVE_YES = 1;
|
||||
const IS_ACTIVE_NO = 2;
|
||||
const IS_ACTIVE = [
|
||||
self::IS_ACTIVE_YES => '活跃',
|
||||
self::IS_ACTIVE_NO => '不活跃',
|
||||
];
|
||||
|
||||
//增加用户扩展信息
|
||||
function addExtend($aItem): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
if(empty($aItem['uid'])) throw new ModelException('uid error');
|
||||
if($this->findItem($aItem['uid'],['uid'])) return null; //已存在
|
||||
$sDateTime = date('Y-m-d H:i:s');
|
||||
$aItem['updated_at'] = $sDateTime;
|
||||
return $this->addItem($aItem);
|
||||
}
|
||||
|
||||
//增加当前粉丝总数
|
||||
function incrFansNum($uid): int
|
||||
{
|
||||
$oExtend = $this->findItem($uid,'uid');
|
||||
if(!$oExtend) throw new ModelException('user extend not found');
|
||||
return $this->newQuery()->where('uid',$uid)->increment('fans_num');
|
||||
}
|
||||
|
||||
//减去当前追随者总数
|
||||
function decrFansNum($uid): int
|
||||
{
|
||||
$oExtend = $this->findItem($uid,'uid');
|
||||
if(!$oExtend) throw new ModelException('user extend not found');
|
||||
return $this->newQuery()->where('uid',$uid)->decrement('fans_num');
|
||||
}
|
||||
|
||||
//增加当前订阅总数
|
||||
function incrFollowNum($uid): int
|
||||
{
|
||||
$oExtend = $this->findItem($uid,'uid');
|
||||
if(!$oExtend) throw new ModelException('user extend not found');
|
||||
return $this->newQuery()->where('uid',$uid)->increment('follow_num');
|
||||
}
|
||||
|
||||
//减去当前订阅总数
|
||||
function decrFollowNum($uid): int
|
||||
{
|
||||
$oExtend = $this->findItem($uid,'uid');
|
||||
if(!$oExtend) throw new ModelException('user extend not found');
|
||||
return $this->newQuery()->where('uid',$uid)->decrement('follow_num');
|
||||
}
|
||||
|
||||
//获取用户活跃信息
|
||||
function getUserActiveListLimit($nowUid, $limit = 500): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
return $this->newQuery()
|
||||
->where('id', '>=', $nowUid)
|
||||
->limit($limit)
|
||||
->orderBy('id')
|
||||
->get(['uid', 'is_active']);
|
||||
}
|
||||
|
||||
//检测所有用户活跃状态
|
||||
function updateUserActiveStatus($date = null): void
|
||||
{
|
||||
if(empty($date)) $date = Carbon::yesterday()->toDateString();
|
||||
|
||||
$oCustomerWsHistoryModel = new CustomerWsHistoryModel();
|
||||
$aActiveUserIdList = $oCustomerWsHistoryModel->getActiveUserIdList($date); //三日内活跃用户
|
||||
if(empty($aActiveUserIdList)) return;
|
||||
$oCustomerChangeInfoLogModel = new CustomerChangeInfoLogModel();
|
||||
|
||||
$nowUid = 0;
|
||||
while (true){
|
||||
try{
|
||||
Db::beginTransaction();
|
||||
$aUserList = $this->getUserActiveListLimit($nowUid, 500);
|
||||
if(empty($aUserList)) break;
|
||||
$nowUid = max($aUserList->pluck('uid')->toArray());
|
||||
|
||||
foreach ($aUserList as $oUser){
|
||||
$isChanged = false;
|
||||
$aLogInsert = [
|
||||
'type' => CustomerChangeInfoLogModel::TYPE_CHANG_USER_ACTIVE_STATUS,
|
||||
'uid' => $oUser->uid,
|
||||
'column' => self::COL_IS_ACTIVE,
|
||||
'before_value' => $oUser->is_active,
|
||||
'pid' => CustomerChangeInfoLogModel::PID_SYSTEM,
|
||||
];
|
||||
|
||||
if(in_array($oUser->uid, $aActiveUserIdList)){ //在活跃列表中
|
||||
if($oUser->is_active == self::IS_ACTIVE_YES) continue; //已经是活跃用户
|
||||
//变更用户状态
|
||||
$res = $this->newQuery()->where('uid',$oUser->uid)->update(['is_active'=>self::IS_ACTIVE_YES]);
|
||||
if($res) {
|
||||
$isChanged = true;
|
||||
$aLogInsert['value'] = self::IS_ACTIVE_YES;
|
||||
$aLogInsert['after_value'] = self::IS_ACTIVE_YES;
|
||||
$aLogInsert['remark_key'] = CustomerChangeInfoLogModel::REMARK_DAILY_CHECK_USER_ACTIVE_STATUS_YES;
|
||||
$aLogInsert['remark_desc'] = CustomerChangeInfoLogModel::REMARK[CustomerChangeInfoLogModel::REMARK_DAILY_CHECK_USER_ACTIVE_STATUS_YES];
|
||||
}
|
||||
}else{ //三日内不活跃
|
||||
if($oUser->is_active == self::IS_ACTIVE_NO) continue; //已经是不活跃用户
|
||||
//变更用户状态
|
||||
$res = $this->newQuery()->where('uid',$oUser->uid)->update(['is_active'=>self::IS_ACTIVE_NO]);
|
||||
if($res) {
|
||||
$isChanged = true;
|
||||
$aLogInsert['value'] = self::IS_ACTIVE_NO;
|
||||
$aLogInsert['after_value'] = self::IS_ACTIVE_NO;
|
||||
$aLogInsert['remark_key'] = CustomerChangeInfoLogModel::REMARK_DAILY_CHECK_USER_ACTIVE_STATUS_NO;
|
||||
$aLogInsert['remark_desc'] = CustomerChangeInfoLogModel::REMARK[CustomerChangeInfoLogModel::REMARK_DAILY_CHECK_USER_ACTIVE_STATUS_NO];
|
||||
}
|
||||
}
|
||||
|
||||
if($isChanged){ //有变化插入日志
|
||||
$oCustomerChangeInfoLogModel->addLog($aLogInsert);
|
||||
}
|
||||
|
||||
}
|
||||
Db::commit();
|
||||
}catch (\Exception $e){
|
||||
Log::error('updateUserActiveStatus error:'.$e->getMessage());
|
||||
Db::rollBack();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,133 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models\Post;
|
||||
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Base\BaseModel;
|
||||
use App\Tools\Tools;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PostModel extends BaseModel
|
||||
{
|
||||
//软删除
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'customer_post';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'uuid',
|
||||
'mid',
|
||||
'uid',
|
||||
'media',
|
||||
'content',
|
||||
'created_at',
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* @throws ModelException
|
||||
*/
|
||||
function addPost($uid, $content = null, $media = null): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
if(!$content && !$media) throw new ModelException('addPost params error');
|
||||
$aItem['uid'] = $uid;
|
||||
$aItem['uuid'] = Tools::genUuid();
|
||||
$aItem['media'] = $media;
|
||||
$aItem['content'] = $content;
|
||||
$sDateTime = date('Y-m-d H:i:s');
|
||||
$aItem['created_at'] = $sDateTime;
|
||||
$res = $this->addItem($aItem);
|
||||
if($res){
|
||||
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ModelException
|
||||
*/
|
||||
function delPostById($id)
|
||||
{
|
||||
$oPost = $this->findItem($id);
|
||||
$res = $this->delItem($id);
|
||||
if($res){
|
||||
$oPostHistoryModel = new PostHistoryModel();
|
||||
$oPostHistoryModel->addPostHistory(PostHistoryModel::METHOD_DEL,$oPost->toArray());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ModelException
|
||||
*/
|
||||
function delPostByUuid($uuid)
|
||||
{
|
||||
$oPost = $this->findItemByWhere(['uuid'=>$uuid]);
|
||||
$res = $this->newQuery()->where('uuid', $uuid)->delete();
|
||||
if($res){
|
||||
$oPostHistoryModel = new PostHistoryModel();
|
||||
$oPostHistoryModel->addPostHistory(PostHistoryModel::METHOD_DEL,$oPost->toArray());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getPostListByUid($uid): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
return $this->getItemsByWhere(['uid'=>$uid]);
|
||||
}
|
||||
|
||||
function getPostById($id): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
return $this->findItem($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ModelException
|
||||
*/
|
||||
function updatePostById($aItem): bool|int
|
||||
{
|
||||
if(!isset($aItem['id'])) throw new ModelException('updatePostById params error');
|
||||
if(empty($aItem['id'])) throw new ModelException('updatePostById params error');
|
||||
$oPost = $this->findItem($aItem['id']);
|
||||
$res = $this->updateItem($aItem);
|
||||
if($res){
|
||||
$oPostHistoryModel = new PostHistoryModel();
|
||||
$oPostHistoryModel->addPostHistory(PostHistoryModel::METHOD_EDIT,$oPost->toArray());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ModelException
|
||||
*/
|
||||
function updatePostByUuid($aItem): bool|int
|
||||
{
|
||||
if(!isset($aItem['uuid'])) throw new ModelException('updatePostByUuid params error');
|
||||
if(empty($aItem['uuid'])) throw new ModelException('updatePostByUuid params error');
|
||||
$oPost = $this->findItemByWhere(['uuid'=>$aItem['uuid']]);
|
||||
$res = $this->updateItem($aItem,'uuid');
|
||||
if($res){
|
||||
$oPostHistoryModel = new PostHistoryModel();
|
||||
$oPostHistoryModel->addPostHistory(PostHistoryModel::METHOD_EDIT,$oPost->toArray());
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getPostListByMid($mid): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
return $this->getItemsByWhere(['mid'=>$mid]);
|
||||
}
|
||||
|
||||
|
||||
function getPostListByUidMid($uid,$mid): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
return $this->getItemsByWhere(['uid'=>$uid,'mid'=>$mid]);
|
||||
}
|
||||
function getPostListByUids($uids,$sDateLimit = null): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
if($sDateLimit == null) $sDateLimit = date('Y-m-d H:i:s',strtotime('-3 day'));
|
||||
return $this->newQuery()->where('created_at',$sDateLimit)->whereIn('uid',$uids)->get();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,181 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Post;
|
||||
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Base\BaseModel;
|
||||
use App\Models\Customer\CustomerUserExtendModel;
|
||||
use App\Models\Follow\FollowModel;
|
||||
use App\Tools\CollectOffsetLimit;
|
||||
|
||||
class PostPushBoxModel extends BaseModel
|
||||
{
|
||||
|
||||
protected $table = 'customer_post_push_box';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'uid',
|
||||
'pid',
|
||||
'puuid',
|
||||
'is_like',
|
||||
'is_repost',
|
||||
'is_bookmark',
|
||||
'is_read',
|
||||
'created_at',
|
||||
'created_box_at',
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
const IS_LIKE_DEFAULT = 1;
|
||||
const IS_LIKE_YES = 2;
|
||||
const IS_LIKE_NO = 3;
|
||||
const IS_LIKE = [
|
||||
self::IS_LIKE_DEFAULT => '默认',
|
||||
self::IS_LIKE_YES => '喜欢',
|
||||
self::IS_LIKE_NO => '不喜欢',
|
||||
];
|
||||
|
||||
const IS_REPOST_DEFAULT = 1;
|
||||
const IS_REPOST_YES = 2;
|
||||
const IS_REPOST = [
|
||||
self::IS_REPOST_DEFAULT => '默认',
|
||||
self::IS_REPOST_YES => '已转发',
|
||||
];
|
||||
|
||||
const IS_BOOKMARK_DEFAULT = 1;
|
||||
const IS_BOOKMARK_YES = 2;
|
||||
const IS_BOOKMARK = [
|
||||
self::IS_BOOKMARK_DEFAULT => '默认',
|
||||
self::IS_BOOKMARK_YES => '已收藏',
|
||||
];
|
||||
|
||||
const IS_READ_DEFAULT = 1;
|
||||
const IS_READ_YES = 2;
|
||||
const IS_READ = [
|
||||
self::IS_READ_DEFAULT => '默认',
|
||||
self::IS_READ_YES => '已收藏',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 提交后调用事件
|
||||
* @throws ModelException
|
||||
*/
|
||||
function newPostPushTask($id = null, $uuid = null)
|
||||
{
|
||||
$oPostModel = new PostModel();
|
||||
$oPost = null;
|
||||
if ($id) $oPost = $oPostModel->findItem($id);
|
||||
if ($uuid) $oPost = $oPostModel->findItemByWhere(['uuid' => $uuid]);
|
||||
if (!$oPost) throw new ModelException('post not found');
|
||||
$iConfigFansPushLimit = intval(env('CONFIG_FANS_PUSH_LIMIT', 2000));
|
||||
|
||||
//查询粉丝数
|
||||
$CustomerUserExtendModel = new CustomerUserExtendModel();
|
||||
$CustomerUserExtend = $CustomerUserExtendModel->findItem($oPost->uid);
|
||||
if (!$CustomerUserExtend) throw new ModelException('user extend not found');
|
||||
|
||||
//粉丝数少于$iConfigFansPushLimit的用户走写扩散流程(所有粉丝信箱插入一条)
|
||||
$bSendMode = $CustomerUserExtend->fans_num < $iConfigFansPushLimit;
|
||||
|
||||
$iTotalCount = $this->countSendFans($bSendMode, $oPost->uid); //计算发送总数
|
||||
//分批发送
|
||||
$oCollectOffsetLimit = new CollectOffsetLimit();
|
||||
$oCollectOffsetLimit->setITotalCount($iTotalCount)->runWhile(function ($offset, $limit) use ($oPost, $bSendMode) {
|
||||
$oFollowList = $this->getFansListWithPage($bSendMode, $oPost->uid, $offset, $limit);
|
||||
$this->sendPostToBox($oPost, $oFollowList);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function getFansListWithPage($bAllFans, $uid, $offset = 0, $limit = 2000): \Illuminate\Database\Eloquent\Collection|array|\Illuminate\Support\Collection
|
||||
{
|
||||
$oFollowModel = new FollowModel();
|
||||
//粉丝数少于$iConfigFansPushLimit的用户走写扩散流程(所有粉丝信箱插入一条)
|
||||
if ($bAllFans) {
|
||||
$oFollowList = $oFollowModel->getFansList($uid, ['uid'], $offset, $limit); //获取所有粉丝列表
|
||||
} else { //读扩散流程(只针对活跃粉丝信箱插入一条)
|
||||
//获取活跃粉丝列表
|
||||
//@活跃粉丝数量过大需要分批处理
|
||||
$oFollowList = $oFollowModel->getActiveFansUidList($uid, ['a.uid'], $offset, $limit);
|
||||
}
|
||||
return $oFollowList;
|
||||
}
|
||||
|
||||
function countSendFans($bAllFans, $uid): int
|
||||
{
|
||||
$oFollowModel = new FollowModel();
|
||||
if ($bAllFans) {
|
||||
$iCount = $oFollowModel->getFansCount($uid); //获取所有粉丝列表
|
||||
} else { //读扩散流程(只针对活跃粉丝信箱插入一条)
|
||||
//获取活跃粉丝列表
|
||||
$iCount = $oFollowModel->getActiveFansUidListCount($uid);
|
||||
}
|
||||
return $iCount;
|
||||
}
|
||||
|
||||
//发送到推送信箱
|
||||
function sendPostToBox($oPost, $oFollowList): void
|
||||
{
|
||||
if (!$oFollowList) return;
|
||||
$date = date('Y-m-d H:i:s');
|
||||
foreach ($oFollowList as $oFollow) {
|
||||
$aItem['uid'] = $oFollow->uid;
|
||||
$aItem['pid'] = $oPost->id;
|
||||
$aItem['puuid'] = $oPost->uuid;
|
||||
$aItem['created_at'] = $oPost->created_at;
|
||||
$aItem['created_box_at'] = $date;
|
||||
$this->addItem($aItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拉取推送信箱列表
|
||||
* @param $uid
|
||||
* @param $last_id //上次最后一条id
|
||||
* @param $limit
|
||||
* @return \Illuminate\Database\Eloquent\Collection|array
|
||||
*/
|
||||
function getPushBoxList($uid, $last_id = 0, $limit = 20): \Illuminate\Database\Eloquent\Collection|array
|
||||
{
|
||||
//活跃用户直接拉取未读消息
|
||||
return $this->newQuery()->where('uid', $uid)->where('id', '>', $last_id)->where('is_read', self::IS_READ_DEFAULT)->orderBy('created_at', 'desc')->limit($limit)->get();
|
||||
//非活跃用户拉取大v消息,在用户状态更新时已经调用过,此处不用在做处理
|
||||
}
|
||||
|
||||
//非活跃拉取已跟随大v最新文章。
|
||||
//放在用户状态更新时调用
|
||||
function pullBigFanMasterPost($uid)
|
||||
{
|
||||
//获取大v定义粉丝数,获取大于该粉丝数的大v文章
|
||||
$iConfigFansPushLimit = intval(env('CONFIG_FANS_PUSH_LIMIT', 2000));
|
||||
//@此处需针对大量数据进行分批获取
|
||||
$oFollowModel = new FollowModel();
|
||||
$oFollowList = $oFollowModel->getFollowListWithFansLimit($uid,$iConfigFansPushLimit,['a.follow_uid']);
|
||||
if ($oFollowList->isEmpty()) return null;
|
||||
$aFollowList = $oFollowList->toArray();
|
||||
$aFollowUid = array_column($aFollowList,'follow_uid');
|
||||
$oPostModel = new PostModel();
|
||||
$oPostList = $oPostModel->getPostListByUids($aFollowUid);
|
||||
|
||||
//将推文发送到信箱
|
||||
$this->sendPostToBoxByUid($oPostList,$uid);
|
||||
|
||||
}
|
||||
|
||||
function sendPostToBoxByUid($oPostList, $uid): void
|
||||
{
|
||||
$date = date('Y-m-d H:i:s');
|
||||
foreach ($oPostList as $oPost) {
|
||||
$aItem['uid'] = $uid;
|
||||
$aItem['pid'] = $oPost->id;
|
||||
$aItem['puuid'] = $oPost->uuid;
|
||||
$aItem['created_at'] = $oPost->created_at;
|
||||
$aItem['created_box_at'] = $date;
|
||||
$this->addItem($aItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user