1
This commit is contained in:
parent
f8bf1cd1a2
commit
de95223e13
21
doc/Contribution.py
Normal file
21
doc/Contribution.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
import _common
|
||||||
|
|
||||||
|
class Contribution(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.apis = [
|
||||||
|
{
|
||||||
|
'name': 'getMyContributionPoint',
|
||||||
|
'desc': '我的贡献点',
|
||||||
|
'group': 'Contribution',
|
||||||
|
'url': 'webapp/index.php?c=Contribution&a=getMyContributionPoint',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
['point', 0, '贡献点']
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
@ -14,6 +14,7 @@ class RspHead(object):
|
|||||||
self.fields = [
|
self.fields = [
|
||||||
['errcode', 0, '错误码/0 成功;1 失败;2余额不足'],
|
['errcode', 0, '错误码/0 成功;1 失败;2余额不足'],
|
||||||
['errmsg', '', '错误描述'],
|
['errmsg', '', '错误描述'],
|
||||||
|
['contributionPoint', '', '贡献点'],
|
||||||
]
|
]
|
||||||
for (key, value) in kwargs.items():
|
for (key, value) in kwargs.items():
|
||||||
for i in range(0, len(self.fields)):
|
for i in range(0, len(self.fields)):
|
||||||
@ -471,6 +472,7 @@ class GoodsInfo(object):
|
|||||||
['gg_product_id', 0, 'ios商品id'],
|
['gg_product_id', 0, 'ios商品id'],
|
||||||
['bonus', 0, 'bonus'],
|
['bonus', 0, 'bonus'],
|
||||||
['bonus_num', 0, 'bonus_num'],
|
['bonus_num', 0, 'bonus_num'],
|
||||||
|
['function', 0, '购买方式'],
|
||||||
]
|
]
|
||||||
|
|
||||||
class Goods(object):
|
class Goods(object):
|
||||||
|
@ -13,6 +13,7 @@ class BaseController {
|
|||||||
private $confDbConn = null;
|
private $confDbConn = null;
|
||||||
private $timeOffset = 0;
|
private $timeOffset = 0;
|
||||||
private $moduleHash = array();
|
private $moduleHash = array();
|
||||||
|
private $contributionPoint = 0;
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
@ -31,6 +32,11 @@ class BaseController {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function _giveContributionPoint($point)
|
||||||
|
{
|
||||||
|
$this->contributionPoint += $point;
|
||||||
|
}
|
||||||
|
|
||||||
public function _getNowTime()
|
public function _getNowTime()
|
||||||
{
|
{
|
||||||
return $this->nowtime + $this->timeOffset;
|
return $this->nowtime + $this->timeOffset;
|
||||||
@ -104,6 +110,7 @@ class BaseController {
|
|||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'errcode' => $errcode,
|
'errcode' => $errcode,
|
||||||
'errmsg' => $errmsg,
|
'errmsg' => $errmsg,
|
||||||
|
'contributionPoint' => $this->contributionPoint
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +119,7 @@ class BaseController {
|
|||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'errcode' => 0,
|
'errcode' => 0,
|
||||||
'errmsg' => '',
|
'errmsg' => '',
|
||||||
|
'contributionPoint' => $this->contributionPoint
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +128,7 @@ class BaseController {
|
|||||||
$rawData = array(
|
$rawData = array(
|
||||||
'errcode' => 0,
|
'errcode' => 0,
|
||||||
'errmsg' => '',
|
'errmsg' => '',
|
||||||
|
'contributionPoint' => $this->contributionPoint
|
||||||
);
|
);
|
||||||
foreach ($data as $key => $val) {
|
foreach ($data as $key => $val) {
|
||||||
$rawData[$key] = $val;
|
$rawData[$key] = $val;
|
||||||
|
12
webapp/controller/ContributionController.class.php
Normal file
12
webapp/controller/ContributionController.class.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once('models/Contribution.php');
|
||||||
|
|
||||||
|
use models\Contribution;
|
||||||
|
class ContributionController extends BaseAuthedController
|
||||||
|
{
|
||||||
|
public function getMyContributionPoint(){
|
||||||
|
$point = Contribution::find();
|
||||||
|
$this->_rspData(array('point'=>$point));
|
||||||
|
}
|
||||||
|
}
|
65
webapp/models/Contribution.php
Normal file
65
webapp/models/Contribution.php
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
use mt;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
class Contribution extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function find(){
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_contribution',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (!$row){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return $row['ingame_contribution'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function add($point){
|
||||||
|
SqlHelper::upsert(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_contribution',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'contribution' => function () use ($point){
|
||||||
|
return "contribution + ${point}";
|
||||||
|
},
|
||||||
|
'ingame_contribution' => function () use ($point){
|
||||||
|
return "ingame_contribution + ${point}";
|
||||||
|
},
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'contribution' => $point,
|
||||||
|
'ingame_contribution' => $point,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function addHistory($gold,$point){
|
||||||
|
SqlHelper::insert(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_contribution_history',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'consume_gold' => $gold,
|
||||||
|
'contribution' => $point,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -6,13 +6,18 @@ class ContributionService extends BaseService {
|
|||||||
|
|
||||||
private static $ignoreCa = array(
|
private static $ignoreCa = array(
|
||||||
'BlockChain@mintGoldBullion',
|
'BlockChain@mintGoldBullion',
|
||||||
|
'InGameMall@buyS',
|
||||||
|
'InGameMall@shoppingCartBuyS',
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function onGoldConsume($params) {
|
public static function onGoldConsume($params) {
|
||||||
$ca = getReqVal('c', '') . '@' . getReqVal('a');
|
$ca = getReqVal('c', '') . '@' . getReqVal('a','');
|
||||||
if (array_key_exists($ca, self::$ignoreCa)) {
|
if (array_key_exists($ca, self::$ignoreCa)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
myself()->_giveContributionPoint(round($params/10,2));
|
||||||
|
myself()->_callModelStatic('Contribution', 'add', round($params/10,2));
|
||||||
|
myself()->_callModelStatic('Contribution', 'addHistory', $params, round($params/10,2));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -150,6 +150,7 @@ class ShopService {
|
|||||||
'ios_product_id' => $goodsMeta['ios_product_id'],
|
'ios_product_id' => $goodsMeta['ios_product_id'],
|
||||||
'bonus' => $goodsMeta['bonus'],
|
'bonus' => $goodsMeta['bonus'],
|
||||||
'bonus_num' => $goodsMeta['bonus_num'],
|
'bonus_num' => $goodsMeta['bonus_num'],
|
||||||
|
'function' => $goodsMeta['function'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user