删除未用到的文件

This commit is contained in:
aozhiwei 2024-08-09 11:53:49 +08:00
parent a8c969027b
commit c94fe3f396
24 changed files with 29 additions and 1263 deletions

23
changed.md Normal file
View File

@ -0,0 +1,23 @@
# 2024/08/09
# modified: controller/BlockChainController.class.php
# deleted: models/BoxOpenedEvent.php
# deleted: models/BoxOrder.php
# modified: models/Chip.php
# deleted: models/Currency.php
# modified: models/Gun.php
# deleted: models/GunTalent.php
# modified: models/Hero.php
# deleted: models/LuckyBox.php
# deleted: models/Market.php
# deleted: models/NftUpEvent.php
# deleted: models/NftUpReceive.php
# deleted: models/Recharge.php
# deleted: models/TransactionPrefee.php
# deleted: models/Transfer.php
# deleted: models/UserWalletRecord.php
# deleted: models/Web2Order.php
# deleted: models/Withdrawal.php
# deleted: mt/Recharge.php
# deleted: services/ContractConfig.php
# deleted: services/LoginService.php
# deleted: services/ShopService.php

View File

@ -50,6 +50,12 @@
* 删除 c=PayMethod
* 删除 c=OutAppPlanet
* 删除 c=Shop
* 删除 c=BlockChain&a=getTransactionList
* 删除 c=BlockChain&a=getTransactionInfo
* 删除 c=BlockChain&a=reportResult
* 删除 c=BlockChain&a=getJumpInfo
* 删除 c=BlockChain&a=buyDiamond
* 删除 c=BlockChain&a=buyMallProduct
*
*
*/

View File

@ -4,7 +4,6 @@ require_once('mt/Parameter.php');
require_once('mt/Item.php');
require_once('mt/Drop.php');
require_once('mt/Hero.php');
require_once('mt/Recharge.php');
require_once('models/Hero.php');
require_once('models/Gun.php');
@ -14,7 +13,6 @@ require_once('models/Transaction.php');
require_once('models/BuyRecord.php');
require_once('models/Chip.php');
require_once('models/BcOrder.php');
require_once('models/Recharge.php');
require_once('services/AwardService.php');
require_once('services/PropertyChgService.php');
@ -28,7 +26,6 @@ use models\Transaction;
use models\BuyRecord;
use models\Chip;
use models\BcOrder;
use models\Recharge;
use services\BlockChainService;
@ -47,72 +44,6 @@ class BlockChainController extends BaseAuthedController {
error_log(json_encode($_REQUEST));
}
public function getTransactionList()
{
$trans = array();
foreach (Transaction::all() as $tran) {
if (myself()->_getNowTime() - $tran['createtime'] < 24*3600){
array_push(
$trans,
array(
'trans_id' => $tran['trans_id'],
'item_id' => $tran['item_id'],
'action' => Transaction::getActionDesc($tran),
'status' => Transaction::getStatusDesc($tran),
'time' => $tran['createtime'],
)
);
}
}
$this->_rspData(array(
'transactions' => $trans
));
}
public function reportResult()
{
$transId = getReqVal('trans_id', '');
$result = getReqVal('result', '');
error_log($result);
Transaction::reportResult($transId, $result);
myself()->_rspOk();
}
public function getJumpInfo()
{
$transId = getReqVal('trans_id', '');
if (!$transId){
myself()->_rspErr(101, 'trans_id paramater error');
return;
}
$tranDb= Transaction::find($transId);
if (!$tranDb){
myself()->_rspErr(101, 'trans_id paramater error');
return;
}
$data = Transaction::getJumpInfo($tranDb);
myself()->_rspData($data);
}
public function getTransactionInfo()
{
$transId = getReqVal('trans_id', '');
if (!$transId){
myself()->_rspErr(101, 'trans_id paramater error');
return;
}
$tranDb= Transaction::find($transId);
myself()->_rspData(array(
'data' => array(
'trans_id' => $tranDb['trans_id'],
'item_id' => $tranDb['item_id'],
'action' => Transaction::getActionDesc($tranDb),
'status' => Transaction::getStatusDesc($tranDb),
'time' => $tranDb['createtime'],
)
));
}
public function active721Nft()
{
$type = getReqVal('type', 0);
@ -323,128 +254,6 @@ class BlockChainController extends BaseAuthedController {
}
}
public function _buyDiamond()
{
return;
error_log(json_encode($_REQUEST));
$num = getReqVal('num', 0);
$tokenType = getReqVal('token_type', '');
if (!is_numeric($num)) {
myself()->_rspErr(1, "num is invalid, {$num}");
return;
}
if ($num <= 0) {
myself()->_rspErr(1, "num is invalid, {$num}");
return;
}
if (!in_array(
$tokenType,
array(
BlockChainService::CURRENCY_CEG,
BlockChainService::CURRENCY_USDC,
BlockChainService::CURRENCY_USDT,
)
)) {
myself()->_rspErr(1, "token_type error");
return;
}
$rate = 1;
if (in_array(
$tokenType,
array(
BlockChainService::CURRENCY_USDC,
BlockChainService::CURRENCY_USDT,
)
)) {
$rate = 10;
}
$jinDu = BlockChainService::getCurrencyDecimals($tokenType);
if ($jinDu === false) {
myself()->_rspErr(1, "token_type error");
return;
}
$currency = $tokenType;
$price = BlockChainService::formatCurrencyEx($num, $jinDu);
$itemId = V_ITEM_DIAMOND;
$itemCount = $num * $rate;
$rspObj = BlockChainService::gameItemMallBuy(
Transaction::BUY_GOODS_ACTION_TYPE,
$currency,
$price,
$itemId,
$itemCount
);
BcOrder::upsert($rspObj['trans_id'], array(
'item_id' => $itemId,
'item_num' => $itemCount,
'order_type' => BcOrder::SPEC_ORDER_TYPE,
'price' => $num,
'currency_name' => $currency,
'ext_data' => json_encode(array(
'mode' => BcOrder::SHOP_BUY_MODE_NORMAL,
)),
));
error_log(json_encode(
array(
'trans_id' => $rspObj['trans_id'],
'params' => $rspObj['params'],
'item_id' => $itemId,
'item_num' => $itemCount
)
));
myself()->_rspData(
array(
'trans_id' => $rspObj['trans_id'],
'params' => $rspObj['params'],
'item_id' => $itemId,
'item_num' => $itemCount
)
);
}
private function rechargeBuyS()
{
$goodsMeta = mt\Recharge::get(getReqVal('goods_id', ''));
if (!$goodsMeta) {
myself()->_rspErr(1, 'goods_id paramater error');
return;
}
$orderId = Recharge::addOrder($goodsMeta['id']);
{
$params = array(
'c' => 'BcService',
'a' => 'recharge',
'account_address' => myself()->_getAddress(),
'passport_address' => myself()->_getAddress(),
'net_id' => NET_ID,
'amount' => 1,
'currency_name' => 'TestToken',
'order_id' => $orderId,
);
//$params['account_address'] = '0xAd2DeA1977055Db01C66e6E53309C4604AB869b8';
//$params['passport_address'] = '0xAd2DeA1977055Db01C66e6E53309C4604AB869b8';
error_log(json_encode($params));
{
$url = self::getWeb3ServiceUrl();
$response = '';
if (!phpcommon\HttpClient::get
($url,
$params,
$response)) {
myself()->_rspErr(500, 'server internal error');
die();
return;
}
error_log($response);
echo $response;
}
}
}
private static function getWeb3ServiceUrl()
{
$web3ServiceCluster = require_once('../config/web3service.cluster.php');

View File

@ -1,22 +0,0 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class BoxOpenedEvent extends BaseModel {
public static function find($boxId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMarketMysql(),
't_boxopened_event',
array(
'box_token_id' => $boxId,
)
);
return $row;
}
}

View File

@ -1,47 +0,0 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class BoxOrder extends BaseModel {
const MAX_NFT_NUM = 3;
public function getSoldNum($batchIdx)
{
$row = myself()->_getMarketMysql()->execQueryOne
('SELECT COUNT(*) AS sold_num FROM t_box_order WHERE batch_idx=:batch_idx AND ' .
' (bc_paid = 1 OR done <> 1);',
array(
':batch_idx' => $batchIdx
));
return $row && $row['sold_num'] ? (int)$row['sold_num'] : 0;
}
public function isBuyed($buyerAddress, $batchIdx)
{
$row = myself()->_getMarketMysql()->execQueryOne
('SELECT COUNT(*) AS buy_count FROM t_box_order WHERE batch_idx=:batch_idx AND ' .
' buyer_address=:buyer_address AND (bc_paid = 1 OR done <> 1);',
array(
':buyer_address' => $buyerAddress,
':batch_idx' => $batchIdx
));
return $row && $row['buy_count'] ? $row['buy_count'] > 0 : false;
}
public function findByOrderId($orderId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMarketMysql(),
't_box_order',
array(
'order_id' => $orderId,
)
);
return $row;
}
}

View File

@ -5,7 +5,6 @@ namespace models;
require_once('services/NftService.php');
require_once('services/FormulaService.php');
require_once('services/ContractConfig.php');
require_once('mt/Item.php');
require_once('mt/EconomyAttribute.php');
@ -14,7 +13,6 @@ require_once('mt/ChipAttribute.php');
use mt;
use phpcommon\SqlHelper;
use services\ContractConfig;
use services\NftService;
use services\FormulaService;

View File

@ -1,166 +0,0 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class Currency extends BaseModel
{
public static function getCurrencyList(){
$baseList = self::baseCurrency();
$rows = SqlHelper::ormSelect(
myself()->_getSelfMysql(),
't_user_currency',
array(
'account_id'=>myself()->_getAccountId()
)
);
if ($rows){
$list = array_merge($baseList,$rows);
}else{
$list = $baseList;
}
return $list;
}
public static function addCurrency($data){
if (!$data){
return;
}
SqlHelper::upsert
(myself()->_getSelfMysql(),
't_user_currency',
array(
'account_id' => myself()->_getAccountId(),
'net_id' => $data['net_id'],
'address' => $data['address'],
),
array(
),
array(
'account_id' => myself()->_getAccountId(),
'net_id' => $data['net_id'],
'address' => $data['address'],
'symbol' => $data['symbol'],
'precision' => $data['precision'],
'type' => $data['type'],
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
}
private static function baseCurrency(){
if (SERVER_ENV == _ONLINE) {
return array(
array(
'account_id'=> myself()->_getAccountId(),
'net_id'=>80001,
'address'=>'0xfa513999031dC1DCf86e99d91101e17d07839235',
'symbol'=>'CEC',
'precision'=>18,
'type'=>3,
'symbol_id' =>2
),
array(
'account_id'=> myself()->_getAccountId(),
'net_id'=>80001,
'address'=>'0x9f87eCA8F0479383fF11a5AB2336b5A6c383d6F3',
'symbol'=>'CEG',
'precision'=>18,
'type'=>3,
'symbol_id' =>1
),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>80001,
// 'address'=>'0x3EBF5196dADC8F3F09C808333f98FE8A4b7d1e62',
// 'symbol'=>'hero',
// 'precision'=>18,
// 'type'=>1,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>80001,
// 'address'=>'0x2F2Ed1c403cB7156617449795dE1CB47A0302a25',
// 'symbol'=>'weapon',
// 'precision'=>18,
// 'type'=>1,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>80001,
// 'address'=>'0x73482411443E87CAC124C12A10B34e9Aaa2De168',
// 'symbol'=>'chip',
// 'precision'=>18,
// 'type'=>2,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>80001,
// 'address'=>'0xFc21A863bFb4E4534B246078772e2074e076f0a7',
// 'symbol'=>'shard',
// 'precision'=>18,
// 'type'=>2,
// ),
);
}else{
return array(
array(
'account_id'=> myself()->_getAccountId(),
'net_id'=>1338,
'address'=>'0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7',
'symbol'=>'CEC',
'precision'=>18,
'type'=>3,
'symbol_id' =>2
),
array(
'account_id'=> myself()->_getAccountId(),
'net_id'=>1338,
'address'=>'0x59d3631c86BbE35EF041872d502F218A39FBa150',
'symbol'=>'CEG',
'precision'=>18,
'type'=>3,
'symbol_id' =>1
),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>1338,
// 'address'=>'0x9b1f7F645351AF3631a656421eD2e40f2802E6c0',
// 'symbol'=>'hero',
// 'precision'=>18,
// 'type'=>1,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>1338,
// 'address'=>'0x2612Af3A521c2df9EAF28422Ca335b04AdF3ac66',
// 'symbol'=>'weapon',
// 'precision'=>18,
// 'type'=>1,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>1338,
// 'address'=>'0x26b4AFb60d6C903165150C6F0AA14F8016bE4aec',
// 'symbol'=>'chip',
// 'precision'=>18,
// 'type'=>2,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>1338,
// 'address'=>'0x0E696947A06550DEf604e82C26fd9E493e576337',
// 'symbol'=>'shard',
// 'precision'=>18,
// 'type'=>2,
// ),
);
}
}
}

View File

@ -10,14 +10,12 @@ require_once('models/ChipPlugin.php');
require_once('models/User.php');
require_once('services/NftService.php');
require_once('services/FormulaService.php');
require_once('services/ContractConfig.php');
use mt;
use phpcommon;
use phpcommon\SqlHelper;
use services\NftService;
use services\FormulaService;
use services\ContractConfig;
use models\ChipPlugin;
class Gun extends BaseModel {

View File

@ -1,54 +0,0 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class GunTalent extends BaseModel {
public static function find($talentId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_gun_talent',
array(
'account_id' => myself()->_getAccountId(),
'talent_id' => $talentId
)
);
return $row;
}
public static function toDto($row)
{
return array(
'talent_id' => $row['talent_id'],
'talent_lv' => $row['talent_lv'],
);
}
public static function upgradeLv($talentId, $talentLv)
{
SqlHelper::upsert(
myself()->_getSelfMysql(),
't_gun_talent',
array(
'account_id' => myself()->_getAccountId(),
'talent_id' => $talentId
),
array(
'talent_lv' => $talentLv,
'modifytime' => myself()->_getNowTime()
),
array(
'account_id' => myself()->_getAccountId(),
'talent_id' => $talentId,
'talent_lv' => $talentLv,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
}

View File

@ -19,7 +19,6 @@ require_once('models/ChipPage.php');
require_once('models/Nft.php');
require_once('services/NftService.php');
require_once('services/FormulaService.php');
require_once('services/ContractConfig.php');
use mt;
@ -27,7 +26,6 @@ use phpcommon;
use phpcommon\SqlHelper;
use services\NftService;
use services\FormulaService;
use services\ContractConfig;
class Hero extends BaseModel {

View File

@ -1,38 +0,0 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class LuckyBox extends BaseModel {
public static function find($boxTokenId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMarketMysql(),
't_lucky_box',
array(
'box_token_id' => $boxTokenId,
)
);
return $row;
}
public static function add($boxTokenId, $account, $tokenIds)
{
SqlHelper::insert(
myself()->_getMarketMysql(),
't_lucky_box',
array(
'box_token_id' => $boxTokenId,
'account' => $account,
'token_id1' => $tokenIds[0],
'token_id2' => $tokenIds[1],
'token_id3' => $tokenIds[2],
)
);
}
}

View File

@ -1,106 +0,0 @@
<?php
namespace models;
use phpcommon\SqlHelper;
class Market extends BaseModel {
const PENDING_STATE = 0;
const BUY_OK_STATE = 1;
const CANCEL_STATE = 2;
public static function find($orderId, $netId){
$row = SqlHelper::ormSelectOne(
myself()->_getMysql(''),
't_market',
array(
'order_id' => $orderId,
'net_id' => $netId,
)
);
return $row;
}
public static function add($orderId, $netId, $tokenId, $seller, $nftToken,
$amount, $currency, $price, $fieldsKv) {
if (empty($fieldsKv)) {
$fieldsKv = array();
}
$fieldsKv = array_merge(
$fieldsKv,
array(
'token_id' => $tokenId,
'seller' => $seller,
'nft_token' => $nftToken,
'amount' => $amount,
'currency' => strtolower($currency),
'price' => $price,
'activated' => 1,
'selltime' => myself()->_getNowTime(),
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
));
self::internalUpdate(
$orderId,
$netId,
$fieldsKv);
}
public static function updatePrice($orderId, $netId, $price) {
self::internalUpdate(
$orderId,
$netId,
array(
'update_price' => $price,
'update_time' => myself()->_getNowTime(),
));
}
public static function buyOk($orderId, $netId) {
self::internalUpdate(
$orderId,
$netId,
array(
'status' => self::BUY_OK_STATE,
));
}
public static function cancel($orderId, $netId) {
self::internalUpdate(
$orderId,
$netId,
array(
'status' => self::CANCEL_STATE,
));
}
private static function internalUpdate($orderId, $netId, $fieldsKv){
SqlHelper::upsert
(myself()->_getMysql(''),
't_market',
array(
'order_id' => $orderId,
'net_id' => $netId,
),
array(
),
array(
'order_id' => $orderId,
'net_id' => $netId,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
SqlHelper::update
(myself()->_getMysql(''),
't_market',
array(
'order_id' => $orderId,
'net_id' => $netId,
),
$fieldsKv
);
}
}

View File

@ -1,30 +0,0 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class NftUpEvent extends BaseModel
{
public static function find($transId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMysql($transId),
't_nft_up_event',
array(
'trans_id' => $transId,
)
);
return $row;
}
public static function add($fieldKv){
return SqlHelper::insert(
myself()->_getMysql(''),
't_nft_up_event',
$fieldKv
);
}
}

View File

@ -1,81 +0,0 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class NftUpReceive extends BaseModel
{
public static function find($accountId,$transId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMysql($accountId),
't_nft_up_receive',
array(
'trans_id' => $transId,
)
);
return $row;
}
public static function add($accountId,$fieldKv){
return SqlHelper::insert(
myself()->_getMysql($accountId),
't_nft_up_receive',
$fieldKv
);
}
public static function all($accountId,$tokenType)
{
$row = SqlHelper::ormSelect(
myself()->_getMysql($accountId),
't_nft_up_receive',
array(
'account_id' => $accountId,
'token_type' => $tokenType,
)
);
return $row;
}
public static function upsert($accountId,$data){
SqlHelper::upsert(
myself()->_getMysql($accountId),
't_nft_up_receive',
array(
'trans_id' => $data['trans_id']
),
array(
'state' => 1,
'modifytime' => myself()->_getNowTime()
),
array(
'account_id' => $accountId,
'trans_id' => $data['trans_id'],
'token_id1' => $data['token_id1'],
'token_id2' => $data['token_id2'],
'state' => 1,
'token_type' => $data['token_type'],
'from_data' => 1,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
public static function setAccountIdNull($accountId,$transId){
SqlHelper::update(
myself()->_getMysql($accountId),
't_nft_up_receive',
array(
'trans_id' => $transId,
),
array(
'account_id' => '',
)
);
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace models;
require_once('models/BuyRecord.php');
use phpcommon\SqlHelper;
class Recharge
{
public static function addOrder($goodsId){
$orderId = BuyRecord::genOrderId
(
GAME_ID,
1,
myself()->_getNowTime(),
myself()->_getAddress()
);
SqlHelper::insert
(myself()->_getSelfMysql(),
't_recharge_order',
array(
'order_id' => $orderId,
'account_id' => myself()->_getAccountId(),
'account_address' => myself()->_getAddress(),
'currency_address' => '0xfd42bfb03212da7e1a4608a44d7658641d99cf34',
'currency_name' => 'TestToken',
'status' => 0,
'item_id' => $goodsId,
'item_num' => 1,
'price' => 1,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
return $orderId;
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class TransactionPrefee extends BaseModel
{
public static function add($transId,$param)
{
SqlHelper::insert(
myself()->_getSelfMysql(),
't_transaction_prefee',
array(
'account_id' => myself()->_getAccountId(),
'trans_id' => $transId,
'target_token_id' => isset($param['token_id']) ? $param['token_id']:0,
'target_token_type' => isset($param['token_type']) ? $param['token_type']:0,
'item_uniid' => isset($param['item_uniid']) ? $param['item_uniid'] : 0,
'item_id' => $param['item_id'],
'item_num' => $param['item_num'],
'done' => 0,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
}
}

View File

@ -1,25 +0,0 @@
<?php
namespace models;
require_once('phpcommon/bchelper.php');
use mt;
use phpcommon;
use phpcommon\SqlHelper;
class Transfer extends BaseModel {
public static function find($txHash)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMarketMysql(),
't_transfer',
array(
'txhash' => $txHash,
)
);
return $row;
}
}

View File

@ -1,49 +0,0 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class UserWalletRecord extends BaseModel {
public static function find($conn, $txHash)
{
$row = SqlHelper::ormSelectOne(
$conn,
't_user_wallet_record',
array(
'txhash' => $txHash,
)
);
return $row;
}
public static function add($conn, $txHash, $dir, $accountId, $type, $value)
{
SqlHelper::insert(
$conn,
't_user_wallet_record',
array(
'txhash' => $txHash,
'dir' => $dir,
'account_id' => $accountId,
'type' => $type,
'value' => $value,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
));
}
public static function update($conn, $txHash, $fieldKv)
{
SqlHelper::update(
$conn,
't_user_wallet_record',
array(
'txhash' => $txHash,
),
$fieldKv);
}
}

View File

@ -1,37 +0,0 @@
<?php
namespace models;
use phpcommon\SqlHelper;
class Web2Order
{
public static function upsert($transId,$fieldsKv){
SqlHelper::upsert
(myself()->_getSelfMysql(),
't_bc_order',
array(
'order_id' => $transId
),
array(
'status' => 1,
'modifytime' => myself()->_getNowTime(),
),
array(
'order_id' => $transId,
'order_type' => getXVal($fieldsKv,'order_type',0),
'account_id' => myself()->_getAccountId(),
'address' => myself()->_getAddress(),
'status' => 0,
'item_id' => $fieldsKv['item_id'],
'item_num' => $fieldsKv['item_num'],
'ext_data' => getXVal($fieldsKv,'ext_data',''),
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
'price' => $fieldsKv['price'],
)
);
}
}

View File

@ -1,86 +0,0 @@
<?php
namespace models;
require_once('phpcommon/bchelper.php');
use mt;
use phpcommon;
use phpcommon\SqlHelper;
class Withdrawal extends BaseModel {
public static function getTodayWithdrawalTimes($account)
{
$row = myself()->_getMarketMysql()->execQueryOne(
'SELECT COUNT(1) AS times FROM t_withdrawal WHERE account=:account AND createtime>=:now_dayseconds AND createtime<=:now_dayseconds + 3600 * 24;',
array(
':account' => $account,
':now_dayseconds' => myself()->_getNowDaySeconds()
)
);
return $row ? $row['times'] : 0;
}
public static function add($account, $type, $netId, $amount)
{
SqlHelper::insert
(myself()->_getMarketMysql(),
't_withdrawal',
array(
'account' => $account,
'type' => $type,
'net_id' => $netId,
'amount' => $amount,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
$seqId = SqlHelper::getLastInsertId(myself()->_getMarketMysql());
return $seqId;
}
public static function find($seqId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMarketMysql(),
't_withdrawal',
array(
'idx' => $seqId,
)
);
return $row;
}
public static function testOk($idx, $account, $type, $netId, $amount)
{
SqlHelper::update(
myself()->_getMarketMysql(),
't_withdrawal',
array(
'idx' => $idx,
),
array(
'state' => 2,
'bc_block_number' => 1,
'bc_txhash' => $idx,
'bc_time' => myself()->_getNowTime(),
)
);
SqlHelper::insert
(myself()->_getMarketMysql(),
't_transfer',
array(
'txhash' => $idx,
'type' => $type,
'_from' => $account,
'_to' => $account,
'value' => $amount,
'state' => 1,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
}

View File

@ -1,31 +0,0 @@
<?php
namespace mt;
use phpcommon;
class Recharge {
public static function get($id)
{
return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null;
}
public static function traverseMeta($cb)
{
foreach (self::getMetaList() as $meta) {
$cb($meta);
}
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('Recharge@Recharge.php');
}
return self::$metaList;
}
protected static $metaList;
}

View File

@ -1,52 +0,0 @@
<?php
namespace services;
use mt\Item;
class ContractConfig extends BaseService {
const ERC721 = "erc721";
public static function find($type){
return self::_setConfig($type)?:null;
}
private static function _setConfig($type){
if (!$type){
return;
}
if (SERVER_ENV != _ONLINE){
switch ($type){
case "erc721" : {
return array(
"hero" => "0xE6A69474E04B93De50dd07F239d62879dB9bF716",
"gun" => "0x8Ce844402bE22fA1276a375Ff2354DD27aDEF285",
"chip" => "0x4678fE0177B15538F441264cB851364d9F3872AA",
);
}
case "erc20" : {
return array(
"CEC" => "0x8dd1439E0C3254b4543d6D68b3C0C891E5Bd2eCE",
"CEG" => "0x2C7221588D4FBac2585D71618CD540e74c7413B8",
);
}
}
} else {
switch ($type){
case "erc721" : {
return array(
"hero" => "0x79fc2a4216A1e595DBD09D13c4B4bD3B095d5bb2",
"gun" => "",
"chip" => "0x551838d7754157D13e7D945b8a37bBD6Ad50dDC7",
);
}
case "erc20" : {
return array(
"CEC" => "",
"CEG" => "0x741482aE1480E552735E44Ff3A733448AcBbeD8d",
);
}
}
}
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace services;
class LoginService extends BaseService {
public function onLogon()
{
}
}

View File

@ -1,162 +0,0 @@
<?php
namespace services;
require_once('mt/ShopGoods.php');
require_once('mt/Item.php');
require_once('mt/Shop.php');
require_once('models/ShopBuyRecord.php');
require_once('models/Hero.php');
require_once('models/HeroSkin.php');
require_once('models/GunSkin.php');
use mt;
use phpcommon;
use models\ShopBuyRecord;
use models\Hero;
use models\HeroSkin;
use models\GunSkin;
class ShopService {
public static function getGoodsList($shopId)
{
if ($shopId == 0) {
$goodsMetaList = mt\ShopGoods::all();
} else {
$goodsMetaList = mt\ShopGoods::getGoodsList($shopId);
}
$goodsMetaList = $goodsMetaList ? $goodsMetaList : array();
$buyRecordHash = ShopBuyRecord::allToHash();
$goodsList = array();
foreach ($goodsMetaList as $goodsMeta) {
if ($goodsMeta['is_close']) {
continue;
}
$goodsDto = array(
'goods_id' => $goodsMeta['goods_id'],
'goods_meta' => self::goodsMetaToInfo($goodsMeta),
'bought_times' => 0,
'free_num' => 0,
);
array_push($goodsList, $goodsDto);
switch ($goodsMeta['limit_type']) {
case mt\Shop::DAILY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsMeta['goods_id']);
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_day_buy_times'] : 0;
}
break;
case mt\Shop::WEEKLY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsMeta['goods_id']);
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_week_buy_times'] : 0;
}
break;
case mt\Shop::TOTAL_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsMeta['goods_id']);
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['total_buy_times'] : 0;
}
break;
default: {
}
break;
}
$itemMeta = mt\Item::get($goodsMeta['item_id']);
if ($itemMeta) {
// 如果是皮肤,判断是否已经拥有,如果已经拥有,不能购买
if ($itemMeta['type'] == mt\Item::HERO_SKIN_TYPE) {
$errCode = 0;
$errMsg = '';
if (!self::canBuy($itemMeta, $errCode, $errMsg)) {
$goods['bought_times'] = 1;
} else {
$goods['bought_times'] = 0;
}
}
} else if ($goodsMeta['goods_id'] != 9999){
error_log('item not found:' . json_encode($goodsMeta));
}
}
return $goodsList;
}
public static function buyLimitCheck($goodsMeta, &$errCode, &$errMsg)
{
$errCode = 0;
$errMsg = '';
$buyRecordHash = ShopBuyRecord::allToHash();
$boughtTimes = 1;
$goodsId = $goodsMeta['goods_id'];
{
switch ($goodsMeta['limit_type']) {
case mt\Shop::DAILY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsId);
$boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1 : 1;
if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $goodsMeta['limit_num']) {
$errCode = 2;
$errMsg = 'Daily purchase limit';
return false;
}
}
break;
case mt\Shop::WEEKLY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsId);
$boughtTimes = $buyRecord ? $buyRecord['this_week_buy_times'] + 1 : 1;
if ($buyRecord && getXVal($buyRecord, 'this_week_buy_times', 0) >= $goodsMeta['limit_num']) {
$errCode = 2;
$errMsg = 'Weekly purchase limit reached';
return false;
}
}
break;
case mt\Shop::TOTAL_BUY_LIMIT: {
// error_log("total buy limit " . $address . " " . $goodsId . " " . $goodsMeta['limit_num']);
$buyRecord = getXVal($buyRecordHash, $goodsId);
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1 : 1;
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $goodsMeta['limit_num']) {
$errCode = 2;
$errMsg = 'Purchase limit reached';
return false;
}
}
break;
default: {
}
break;
}
}
return true;
}
public static function goodsMetaToInfo($goodsMeta)
{
return array(
'item_id' => $goodsMeta['item_id'],
'item_num' => $goodsMeta['item_num'],
'max_amount' => $goodsMeta['max_amount'],
'shop_id' => $goodsMeta['shop_id'],
'shopstage' => $goodsMeta['shopstage'],
'tag' => $goodsMeta['tag'],
'recommend' => $goodsMeta['recommend'],
'token_type' => $goodsMeta['token_type'],
'price' => $goodsMeta['price'],
'free_type' => $goodsMeta['free_type'],
'shop_icon' => $goodsMeta['shop_icon'],
'gg_product_id' => $goodsMeta['gg_product_id'],
'ios_product_id' => $goodsMeta['ios_product_id'],
'bonus' => $goodsMeta['bonus'],
'bonus_num' => $goodsMeta['bonus_num'],
);
}
public static function canBuy($itemMeta, &$errCode, &$errMsg)
{
$errCode = 0;
$errMsg = '';
return true;
}
}