Commit 9f0382bd authored by shajiaiming's avatar shajiaiming

Merge branch 'master' into feature/ucenter

parents 0c8b28d9 b7af8d09
...@@ -74,6 +74,7 @@ class GameBetController extends BaseController ...@@ -74,6 +74,7 @@ class GameBetController extends BaseController
$query = CoinGameBet::find() $query = CoinGameBet::find()
->select('round, player, amount, height, guess_num, guess_num, rand_num, player_win') ->select('round, player, amount, height, guess_num, guess_num, rand_num, player_win')
->where('player= :player',[':player' => $player]) ->where('player= :player',[':player' => $player])
->andWhere(['valid' => CoinGameBet::VAILD_TRUE])
->orderBy('update_time desc'); ->orderBy('update_time desc');
$count = $query->count(); $count = $query->count();
......
...@@ -56,7 +56,7 @@ class ApplicationController extends BaseController ...@@ -56,7 +56,7 @@ class ApplicationController extends BaseController
if(Yii::$app->request->isPost){ if(Yii::$app->request->isPost){
Yii::$app->response->format = 'json'; Yii::$app->response->format = 'json';
$category_id = Yii::$app->request->get('category_id'); $category_id = Yii::$app->request->get('category_id');
$fields = ['category_id','h5_icon','official_url','introduce_image','show_width','show_height','open_type','name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type', 'platform_id']; $fields = ['category_id','h5_icon','official_url','introduce_image','show_width','show_height','open_type', 'open_type_app', 'name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type', 'platform_id'];
$params = array_merge(Yii::$app->request->post(),['category_id' => $category_id, 'platform_id' => Yii::$app->user->identity->platform_id]); $params = array_merge(Yii::$app->request->post(),['category_id' => $category_id, 'platform_id' => Yii::$app->user->identity->platform_id]);
$params = $this->initParams($params, $fields); $params = $this->initParams($params, $fields);
$coin_applicateion_form = new CoinApplicationForm(); $coin_applicateion_form = new CoinApplicationForm();
...@@ -80,7 +80,7 @@ class ApplicationController extends BaseController ...@@ -80,7 +80,7 @@ class ApplicationController extends BaseController
{ {
if (Yii::$app->request->isPost) { if (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json'; Yii::$app->response->format = 'json';
$fields = ['category_id','id','h5_icon','official_url','introduce_image','show_width','show_height','open_type','name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type', 'platform_id']; $fields = ['category_id','id','h5_icon','official_url','introduce_image','show_width','show_height','open_type', 'open_type_app', 'name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type', 'platform_id'];
$params = array_merge(Yii::$app->request->post(),['platform_id' => Yii::$app->user->identity->platform_id]); $params = array_merge(Yii::$app->request->post(),['platform_id' => Yii::$app->user->identity->platform_id]);
$params = $this->initParams($params, $fields); $params = $this->initParams($params, $fields);
$coin_applicateion_form = new CoinApplicationForm(); $coin_applicateion_form = new CoinApplicationForm();
......
...@@ -39,13 +39,14 @@ class CoinApplicationForm extends BaseForm ...@@ -39,13 +39,14 @@ class CoinApplicationForm extends BaseForm
public $show_width; public $show_width;
public $show_height; public $show_height;
public $open_type; public $open_type;
public $open_type_app;
public $platform_id; public $platform_id;
public function scenarios() public function scenarios()
{ {
return [ return [
self::SCENARIO_ADD => ['category_id','name','h5_icon','official_url','introduce_image','show_width','show_height','open_type','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type', 'platform_id'], self::SCENARIO_ADD => ['category_id','name','h5_icon','official_url','introduce_image','show_width','show_height','open_type', 'open_type_app','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type', 'platform_id'],
self::SCENARIO_EDIT => ['category_id','id','h5_icon','official_url','introduce_image','show_width','show_height','open_type','name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type', 'platform_id'], self::SCENARIO_EDIT => ['category_id','id','h5_icon','official_url','introduce_image','show_width','show_height','open_type', 'open_type_app','name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type', 'platform_id'],
]; ];
} }
...@@ -73,7 +74,8 @@ class CoinApplicationForm extends BaseForm ...@@ -73,7 +74,8 @@ class CoinApplicationForm extends BaseForm
'redirect_type' => '跳转方式', 'redirect_type' => '跳转方式',
'show_width' => '显示宽度', 'show_width' => '显示宽度',
'show_height' => '显示高度', 'show_height' => '显示高度',
'open_type' => 'H5打开方式', 'open_type' => 'H5打开方式 PC版',
'open_type_app' => 'H5打开方式 APP版',
'platform_id' => '平台Id' 'platform_id' => '平台Id'
]; ];
} }
......
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">H5打开方式</label> <label class="layui-form-label">H5打开方式(PC版)</label>
<div class="layui-input-block"> <div class="layui-input-block">
<select name="open_type" > <select name="open_type" >
<option value="0">选择打开方式</option> <option value="0">选择打开方式</option>
...@@ -171,6 +171,17 @@ ...@@ -171,6 +171,17 @@
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">H5打开方式(APP版)</label>
<div class="layui-input-block">
<select name="open_type_app" >
<option value="0" >选择打开方式</option>
<option value="1">钱包内打开</option>
<option value="2">浏览器打开</option>
</select>
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn">提交</button> <button class="layui-btn">提交</button>
</div> </div>
</form> </form>
......
...@@ -162,7 +162,7 @@ ...@@ -162,7 +162,7 @@
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">H5打开方式</label> <label class="layui-form-label">H5打开方式(PC版)</label>
<div class="layui-input-block"> <div class="layui-input-block">
<select name="open_type" > <select name="open_type" >
<option value="0" >选择打开方式</option> <option value="0" >选择打开方式</option>
...@@ -171,6 +171,17 @@ ...@@ -171,6 +171,17 @@
</select> </select>
</div> </div>
</div> </div>
<div class="layui-form-item">
<label class="layui-form-label">H5打开方式(APP版)</label>
<div class="layui-input-block">
<select name="open_type_app" >
<option value="0" >选择打开方式</option>
<option value="1" <?php if($item['open_type_app'] ==1) echo "selected"?>>钱包内打开</option>
<option value="2" <?php if($item['open_type_app'] ==2) echo "selected"?>>浏览器打开</option>
</select>
</div>
</div>
</form> </form>
</div> </div>
</div> </div>
......
...@@ -97,12 +97,12 @@ class ApplicationBusiness ...@@ -97,12 +97,12 @@ class ApplicationBusiness
$app_cate_Model = CoinAppCate::find(); $app_cate_Model = CoinAppCate::find();
if(array_key_exists('platform_id', $condition)){ if(array_key_exists('platform_id', $condition)){
$query = $app_cate_Model->JoinWith(['application'], false) $query = $app_cate_Model->JoinWith(['application'], false)
->select('cate_id,app_id,name,icon,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,advertise,redirect_type,'.CoinAppCate::tableName().'.sort') ->select('cate_id,app_id,name,icon,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,advertise,redirect_type,open_type_app,'.CoinAppCate::tableName().'.sort')
->where($condition) ->where($condition)
->orderBy(CoinAppCate::tableName().'.sort asc'); ->orderBy(CoinAppCate::tableName().'.sort asc');
} else { } else {
$query = $app_cate_Model->JoinWith(['application'], false) $query = $app_cate_Model->JoinWith(['application'], false)
->select('cate_id,app_id,name,icon,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,advertise,redirect_type,'.CoinAppCate::tableName().'.sort') ->select('cate_id,app_id,name,icon,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,advertise,redirect_type,open_type_app,'.CoinAppCate::tableName().'.sort')
->orderBy(CoinAppCate::tableName().'.sort asc'); ->orderBy(CoinAppCate::tableName().'.sort asc');
} }
......
...@@ -120,16 +120,6 @@ class Chain33Business ...@@ -120,16 +120,6 @@ class Chain33Business
} }
/** /**
* 获取最新的区块
*/
public static function getLastHeader()
{
$service = new Chain33Service();
$result = $service->getLastHeader();
return $result;
}
/**
* 获取区块hash * 获取区块hash
* *
* @param integer $height * @param integer $height
...@@ -183,22 +173,45 @@ class Chain33Business ...@@ -183,22 +173,45 @@ class Chain33Business
* @param integer $end * @param integer $end
* @return array * @return array
*/ */
public static function getBetStatus($start, $end) public static function getBetStatus($start, $end, $roundArr = [])
{ {
$node_params = \Yii::$app->params['chain_parallel']['wasm']; $node_params = \Yii::$app->params['chain_parallel']['wasm'];
$service = new Chain33Service($node_params); $service = new Chain33Service($node_params);
$execer = 'wasm'; $execer = 'wasm';
$funcName = 'WasmGetContractTable'; $funcName = 'WasmGetContractTable';
$contractName = 'user.p.tschain.user.wasm.dice'; $contractName = 'user.p.tschain.user.wasm.dice';
for($i = $start + 1; $i <= $end; $i++){ if (empty($roundArr)) {
$items[] = [ for($i = $start + 1; $i <= $end; $i++){
'tableName' => 'roundinfo', $items[] = [
'key' => 'round:' . $i 'tableName' => 'roundinfo',
]; 'key' => 'round:' . $i
];
}
}
if(!empty($roundArr)){
foreach($roundArr as $key => $round){
$items[] = [
'tableName' => 'roundinfo',
'key' => 'round:' . $round
];
}
} }
return $service->chain33Query($execer, $funcName, $contractName, $items); return $service->chain33Query($execer, $funcName, $contractName, $items);
} }
/*
* 获取最新的区块头
* @param null
* @return array
*/
public static function getLastHeader()
{
$node_params = \Yii::$app->params['chain_parallel']['wasm'];
$service = new Chain33Service($node_params);
return $service->getLastHeader();
}
/** /**
* 获取地址下的所有交易记录 * 获取地址下的所有交易记录
* *
......
...@@ -18,6 +18,9 @@ class CoinGameBet extends BaseActiveRecord ...@@ -18,6 +18,9 @@ class CoinGameBet extends BaseActiveRecord
const SCENARIOS_ADD = 'add'; const SCENARIOS_ADD = 'add';
const SCENARIOS_UPDATE = 'update'; const SCENARIOS_UPDATE = 'update';
const VAILD_TRUE = 1;
const VAILD_FALSE = 0;
public static function getDb() public static function getDb()
{ {
return Yii::$app->get('p_sources'); return Yii::$app->get('p_sources');
...@@ -44,7 +47,7 @@ class CoinGameBet extends BaseActiveRecord ...@@ -44,7 +47,7 @@ class CoinGameBet extends BaseActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['round', 'amount', 'height', 'guess_num', 'rand_num', 'player_win'], 'int'], [['round', 'amount', 'height', 'guess_num', 'rand_num', 'player_win', 'vaild'], 'int'],
[['player'], 'string'] [['player'], 'string']
]; ];
} }
...@@ -52,8 +55,8 @@ class CoinGameBet extends BaseActiveRecord ...@@ -52,8 +55,8 @@ class CoinGameBet extends BaseActiveRecord
public function sercians() public function sercians()
{ {
return [ return [
self::SCENARIOS_ADD => ['round', 'amount', 'height', 'guess_num', 'rand_num', 'player_win', 'player'], self::SCENARIOS_ADD => ['round', 'amount', 'height', 'guess_num', 'rand_num', 'player_win', 'player', 'vaild'],
self::SCENARIOS_UPDATE => ['round', 'amount', 'height', 'guess_num', 'rand_num', 'player_win', 'player'], self::SCENARIOS_UPDATE => ['round', 'amount', 'height', 'guess_num', 'rand_num', 'player_win', 'player', 'vaild'],
]; ];
} }
......
...@@ -37,6 +37,8 @@ class ExchangeController extends Controller ...@@ -37,6 +37,8 @@ class ExchangeController extends Controller
public function actionQuotation() public function actionQuotation()
{ {
ExchangeBusiness::setQuotation(); ExchangeBusiness::setQuotation();
echo date('Y-m-d H:i:s') . '数据更新成功'.PHP_EOL;
return 0;
} }
public function actionTest() public function actionTest()
......
...@@ -42,6 +42,7 @@ class GameBetController extends Controller ...@@ -42,6 +42,7 @@ class GameBetController extends Controller
return 0; return 0;
} }
Yii::$app->redis->set('chain33_game_bet_status',$current_round,'EX',300); Yii::$app->redis->set('chain33_game_bet_status',$current_round,'EX',300);
$result = $service->getBetStatus($cache_current_round, $current_round); $result = $service->getBetStatus($cache_current_round, $current_round);
if( 0 !== $result['code']){ if( 0 !== $result['code']){
echo date('Y-m-d H:i:s') . '数据错误'.PHP_EOL; echo date('Y-m-d H:i:s') . '数据错误'.PHP_EOL;
...@@ -64,4 +65,56 @@ class GameBetController extends Controller ...@@ -64,4 +65,56 @@ class GameBetController extends Controller
echo date('Y-m-d H:i:s') . '数据更新成功'.PHP_EOL; echo date('Y-m-d H:i:s') . '数据更新成功'.PHP_EOL;
return 0; return 0;
} }
public function actionBetUpdate()
{
$service = new Chain33Business();
$result = $service->getLastHeader();
$result = $result['result'] ?? [];
if(empty($result)){
echo date('Y-m-d H:i:s') . '数据错误'.PHP_EOL;
return 0;
}
$height = $result['height'];
$models = CoinGameBet::find()->select('round')->where([
'and',
['valid' => CoinGameBet::VAILD_FALSE],
['<', 'height', $height - 12]
])->all();
if(empty($models)){
echo date('Y-m-d H:i:s') . '无需更新的数据'.PHP_EOL;
return 0;
}
$valid_arr = [];
foreach ($models as $model) {
$valid_arr[] = $model->round;
}
$result = $service->getBetStatus('', '', $valid_arr);
if( 0 !== $result['code']){
echo date('Y-m-d H:i:s') . '数据错误'.PHP_EOL;
return 0;
}
$queryResultItems = $result['result'] ?? [];
if(empty($queryResultItems)){
echo date('Y-m-d H:i:s') . '数据错误'.PHP_EOL;
return 0;
}
foreach ($queryResultItems['queryResultItems'] as $key => $val){
if (false == $val['found']) continue;
$resultArr = json_decode($val['resultJSON'],true);
CoinGameBet::updateAll([
'amount' => $resultArr['amount'],
'height' => $resultArr['height'],
'guess_num' => $resultArr['guess_num'],
'rand_num' => $resultArr['rand_num'],
'player_win' => $resultArr['player_win'],
'valid' => CoinGameBet::VAILD_TRUE
],[
'round' => $resultArr['round']
]);
}
echo date('Y-m-d H:i:s') . '数据更新成功'.PHP_EOL;
return 0;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment