1
This commit is contained in:
parent
dedfaacc2d
commit
62fa1b6352
@ -9,6 +9,7 @@ require_once('mt/LootConfig.php');
|
|||||||
require_once('models/Bag.php');
|
require_once('models/Bag.php');
|
||||||
require_once('models/Hero.php');
|
require_once('models/Hero.php');
|
||||||
require_once('models/User.php');
|
require_once('models/User.php');
|
||||||
|
require_once('models/DiamondConsumeProduct.php');
|
||||||
|
|
||||||
|
|
||||||
require_once('services/AwardService.php');
|
require_once('services/AwardService.php');
|
||||||
@ -21,6 +22,7 @@ use phpcommon\SqlHelper;
|
|||||||
use models\Bag;
|
use models\Bag;
|
||||||
use models\Hero;
|
use models\Hero;
|
||||||
use models\User;
|
use models\User;
|
||||||
|
use models\DiamondConsumeProduct;
|
||||||
use services\LogService;
|
use services\LogService;
|
||||||
|
|
||||||
class BagController extends BaseAuthedController {
|
class BagController extends BaseAuthedController {
|
||||||
@ -483,24 +485,44 @@ class BagController extends BaseAuthedController {
|
|||||||
$this->_rspErr(1, "only supported property");
|
$this->_rspErr(1, "only supported property");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$costItems= array(
|
$costItems= array();
|
||||||
array(
|
if ($itemMeta['gold'] > 0){
|
||||||
|
array_push($costItems,array(
|
||||||
'item_id' => V_ITEM_GOLD,
|
'item_id' => V_ITEM_GOLD,
|
||||||
'item_num' => $itemMeta['gold'] * $itemNum
|
'item_num' => $itemMeta['gold'] * $itemNum
|
||||||
)
|
));
|
||||||
);
|
}
|
||||||
|
$diamondTrue = 0;
|
||||||
|
if ($itemMeta['diamond'] > 0){
|
||||||
|
$diamondTrue = 1;
|
||||||
|
array_push($costItems,array(
|
||||||
|
'item_id' => V_ITEM_DIAMOND,
|
||||||
|
'item_num' => $itemMeta['diamond'] * $itemNum
|
||||||
|
));
|
||||||
|
}
|
||||||
$lackItem = null;
|
$lackItem = null;
|
||||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_decItems($costItems);
|
||||||
|
if ($diamondTrue > 0){
|
||||||
|
$params = array(
|
||||||
|
'type' => DiamondConsumeProduct::CONSUME_TYPE,
|
||||||
|
'amount' => $itemMeta['diamond'] * $itemNum,
|
||||||
|
'source' => DiamondConsumeProduct::GAME_STATE,
|
||||||
|
);
|
||||||
|
myself()->_fireEvent('Diamond','onConsume',$params);
|
||||||
|
}
|
||||||
|
|
||||||
$items = array(
|
$items = array(
|
||||||
array(
|
array(
|
||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'item_num' => $itemNum
|
'item_num' => $itemNum
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->_decItems($costItems);
|
|
||||||
$this->_addItems($items, $this->awardService, $this->propertyChgService);
|
$this->_addItems($items, $this->awardService, $this->propertyChgService);
|
||||||
$this->propertyChgService->addUserChg();
|
$this->propertyChgService->addUserChg();
|
||||||
$this->propertyChgService->addBagChg();
|
$this->propertyChgService->addBagChg();
|
||||||
|
14
webapp/events/Diamond.php
Normal file
14
webapp/events/Diamond.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace events;
|
||||||
|
|
||||||
|
|
||||||
|
class Diamond
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function onConsume($params){
|
||||||
|
myself()->_callModelStatic('DiamondConsumeProduct', 'addRecord', $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
webapp/models/DiamondConsumeProduct.php
Normal file
33
webapp/models/DiamondConsumeProduct.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
use mt;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
class DiamondConsumeProduct extends BaseModel
|
||||||
|
{
|
||||||
|
const CONSUME_TYPE = 0; //消耗
|
||||||
|
const PRODUCT_TYPE = 1; //产出
|
||||||
|
|
||||||
|
const GAME_STATE = 0; //游戏内
|
||||||
|
const MARKET_STATE = 1; //market
|
||||||
|
|
||||||
|
public static function addRecord($params){
|
||||||
|
SqlHelper::insert
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_user_currency',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'passport_address' => myself()->_getAddress(),
|
||||||
|
'type' => $params['type'],
|
||||||
|
'amount' => $params['amount'],
|
||||||
|
'source' => $params['source'],
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -234,7 +234,7 @@ class HashRateService extends BaseService
|
|||||||
'SELECT SUM(amount) FROM t_diamond_consume_product WHERE (account_id=:account_id OR passport_address=:address) AND type=:type AND createtime > :star_time',
|
'SELECT SUM(amount) FROM t_diamond_consume_product WHERE (account_id=:account_id OR passport_address=:address) AND type=:type AND createtime > :star_time',
|
||||||
array(
|
array(
|
||||||
':account' => myself()->_getAccountId(),
|
':account' => myself()->_getAccountId(),
|
||||||
':address' => 1,
|
':address' => myself()->_getAddress(),
|
||||||
':type' => 0,
|
':type' => 0,
|
||||||
':star_time' => $task['createtime'],
|
':star_time' => $task['createtime'],
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user