diff --git a/doc/Contribution.py b/doc/Contribution.py new file mode 100644 index 00000000..a4e0137b --- /dev/null +++ b/doc/Contribution.py @@ -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, '贡献点'] + ] + }, + ] \ No newline at end of file diff --git a/doc/_common.py b/doc/_common.py index 5036a285..771cff93 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -14,6 +14,7 @@ class RspHead(object): self.fields = [ ['errcode', 0, '错误码/0 成功;1 失败;2余额不足'], ['errmsg', '', '错误描述'], + ['contributionPoint', '', '贡献点'], ] for (key, value) in kwargs.items(): for i in range(0, len(self.fields)): @@ -471,6 +472,7 @@ class GoodsInfo(object): ['gg_product_id', 0, 'ios商品id'], ['bonus', 0, 'bonus'], ['bonus_num', 0, 'bonus_num'], + ['function', 0, '购买方式'], ] class Goods(object): diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index cb8e8325..82d77e8c 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -13,6 +13,7 @@ class BaseController { private $confDbConn = null; private $timeOffset = 0; private $moduleHash = array(); + private $contributionPoint = 0; function __construct() { @@ -31,6 +32,11 @@ class BaseController { { } + public function _giveContributionPoint($point) + { + $this->contributionPoint += $point; + } + public function _getNowTime() { return $this->nowtime + $this->timeOffset; @@ -104,6 +110,7 @@ class BaseController { echo json_encode(array( 'errcode' => $errcode, 'errmsg' => $errmsg, + 'contributionPoint' => $this->contributionPoint )); } @@ -112,6 +119,7 @@ class BaseController { echo json_encode(array( 'errcode' => 0, 'errmsg' => '', + 'contributionPoint' => $this->contributionPoint )); } @@ -120,6 +128,7 @@ class BaseController { $rawData = array( 'errcode' => 0, 'errmsg' => '', + 'contributionPoint' => $this->contributionPoint ); foreach ($data as $key => $val) { $rawData[$key] = $val; diff --git a/webapp/controller/ContributionController.class.php b/webapp/controller/ContributionController.class.php new file mode 100644 index 00000000..166fb077 --- /dev/null +++ b/webapp/controller/ContributionController.class.php @@ -0,0 +1,12 @@ +_rspData(array('point'=>$point)); + } +} \ No newline at end of file diff --git a/webapp/models/Contribution.php b/webapp/models/Contribution.php new file mode 100644 index 00000000..7094d053 --- /dev/null +++ b/webapp/models/Contribution.php @@ -0,0 +1,65 @@ +_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(), + ) + ); + } + + +} \ No newline at end of file diff --git a/webapp/services/ContributionService.php b/webapp/services/ContributionService.php index c289982d..b722be03 100644 --- a/webapp/services/ContributionService.php +++ b/webapp/services/ContributionService.php @@ -6,13 +6,18 @@ class ContributionService extends BaseService { private static $ignoreCa = array( 'BlockChain@mintGoldBullion', + 'InGameMall@buyS', + 'InGameMall@shoppingCartBuyS', ); public static function onGoldConsume($params) { - $ca = getReqVal('c', '') . '@' . getReqVal('a'); + $ca = getReqVal('c', '') . '@' . getReqVal('a',''); if (array_key_exists($ca, self::$ignoreCa)) { return; } + myself()->_giveContributionPoint(round($params/10,2)); + myself()->_callModelStatic('Contribution', 'add', round($params/10,2)); + myself()->_callModelStatic('Contribution', 'addHistory', $params, round($params/10,2)); } } diff --git a/webapp/services/ShopService.php b/webapp/services/ShopService.php index 84b15e94..f726ffda 100644 --- a/webapp/services/ShopService.php +++ b/webapp/services/ShopService.php @@ -150,6 +150,7 @@ class ShopService { 'ios_product_id' => $goodsMeta['ios_product_id'], 'bonus' => $goodsMeta['bonus'], 'bonus_num' => $goodsMeta['bonus_num'], + 'function' => $goodsMeta['function'], ); }