...
This commit is contained in:
parent
23730ec532
commit
ad8adc2838
15
doc/Shop.py
15
doc/Shop.py
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import _common
|
import _common
|
||||||
|
|
||||||
|
|
||||||
class Shop(object):
|
class Shop(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -95,7 +96,7 @@ class Shop(object):
|
|||||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||||
['goods_chg', _common.NewGoods(), '购买后更新商品的最新信息(可能为null客户端需要做容错处理)'],
|
['goods_chg', _common.NewGoods(), '购买后更新商品的最新信息(可能为null客户端需要做容错处理)'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'buyGoodsNormal',
|
'name': 'buyGoodsNormal',
|
||||||
'desc': '购买商品(正式)',
|
'desc': '购买商品(正式)',
|
||||||
@ -114,7 +115,7 @@ class Shop(object):
|
|||||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||||
['goods_chg', _common.NewGoods(), '购买后更新商品的最新信息(可能为null客户端需要做容错处理)'],
|
['goods_chg', _common.NewGoods(), '购买后更新商品的最新信息(可能为null客户端需要做容错处理)'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'buyGoodsDirect',
|
'name': 'buyGoodsDirect',
|
||||||
'desc': '直接购买(充值,gold)',
|
'desc': '直接购买(充值,gold)',
|
||||||
@ -130,7 +131,7 @@ class Shop(object):
|
|||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'startGoodsDirect',
|
'name': 'startGoodsDirect',
|
||||||
'desc': '发起一个 直接购买(充值,gold)',
|
'desc': '发起一个 直接购买(充值,gold)',
|
||||||
@ -146,7 +147,7 @@ class Shop(object):
|
|||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['order_id', '', '订单id'],
|
['order_id', '', '订单id'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'statusGoodsDirect',
|
'name': 'statusGoodsDirect',
|
||||||
'desc': '查询 直接购买(充值,gold) 状态',
|
'desc': '查询 直接购买(充值,gold) 状态',
|
||||||
@ -160,7 +161,7 @@ class Shop(object):
|
|||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['status', 0, '订单状态 0:未支付 1:已支付 2:支付失败'],
|
['status', 0, '订单状态 0:未支付 1:已支付 2:支付失败'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'getPayMethods',
|
'name': 'getPayMethods',
|
||||||
'desc': '获取支付方式',
|
'desc': '获取支付方式',
|
||||||
@ -240,7 +241,7 @@ class Shop(object):
|
|||||||
'url': 'webapp/index.php?c=Shop&a=getChestItems',
|
'url': 'webapp/index.php?c=Shop&a=getChestItems',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['goods_id', 0, '宝箱物品id item_id'],
|
['id', 0, '商品唯一id,参见shopGoods表'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
@ -274,5 +275,5 @@ class Shop(object):
|
|||||||
['!items', [0], '盲盒列表'],
|
['!items', [0], '盲盒列表'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -143,7 +143,7 @@ class ShopController extends BaseAuthedController
|
|||||||
$goods['goods_num'] = 1;
|
$goods['goods_num'] = 1;
|
||||||
}
|
}
|
||||||
if (!empty($goods['free_type'])) {
|
if (!empty($goods['free_type'])) {
|
||||||
$count = $this->countFreeBuyTimes($goods);
|
$count = $this->countFreeBuyTimes($goods['free_type'], $goods['id'], $goods['goods_id']);
|
||||||
$goods['free_num'] = $goods['free_num'] - $count;
|
$goods['free_num'] = $goods['free_num'] - $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,7 +857,7 @@ class ShopController extends BaseAuthedController
|
|||||||
$token_pos = array_search($token_type, $check_token_type, true);
|
$token_pos = array_search($token_type, $check_token_type, true);
|
||||||
$isFreeBuy = false;
|
$isFreeBuy = false;
|
||||||
if (!empty($row['free_type'])) {
|
if (!empty($row['free_type'])) {
|
||||||
$count = $this->countFreeBuyTimes($row);
|
$count = $this->countFreeBuyTimes($row['free_type'], $row['id'], $row['goods_id']);
|
||||||
if ($count < $row['free_num']) {
|
if ($count < $row['free_num']) {
|
||||||
$isFreeBuy = true;
|
$isFreeBuy = true;
|
||||||
}
|
}
|
||||||
@ -1172,7 +1172,7 @@ class ShopController extends BaseAuthedController
|
|||||||
$cost = $shop['price'] * $num;
|
$cost = $shop['price'] * $num;
|
||||||
$isFreeBuy = false;
|
$isFreeBuy = false;
|
||||||
if (!empty($shop['free_type'])) {
|
if (!empty($shop['free_type'])) {
|
||||||
$count = $this->countFreeBuyTimes($shop);
|
$count = $this->countFreeBuyTimes($shop['free_type'], $shop['id'], $shop['goods_id']);
|
||||||
if ($count < $shop['free_num']) {
|
if ($count < $shop['free_num']) {
|
||||||
$isFreeBuy = true;
|
$isFreeBuy = true;
|
||||||
}
|
}
|
||||||
@ -1290,8 +1290,17 @@ class ShopController extends BaseAuthedController
|
|||||||
|
|
||||||
public function getChestItems()
|
public function getChestItems()
|
||||||
{
|
{
|
||||||
$goods_id = getReqVal('goods_id', 0);
|
$address = $this->_getAddress();
|
||||||
|
// if (!$address) {
|
||||||
|
// $this->_rspErr(2, 'address is invalid');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
$id = getReqVal('id', 0);
|
||||||
|
$goods = mt\ShopGoods::get($id);
|
||||||
|
$goods_id = $goods['goods_id'];
|
||||||
|
$shop_id = $goods['shop_id'];
|
||||||
|
|
||||||
$meta = mt\Item::get($goods_id);
|
$meta = mt\Item::get($goods_id);
|
||||||
if ($meta['type'] != mt\Item::CHEST_BOX_TYPE) {
|
if ($meta['type'] != mt\Item::CHEST_BOX_TYPE) {
|
||||||
$this->_rspErr(2, 'goods_id is invalid');
|
$this->_rspErr(2, 'goods_id is invalid');
|
||||||
@ -1302,20 +1311,29 @@ class ShopController extends BaseAuthedController
|
|||||||
$record = array();
|
$record = array();
|
||||||
foreach ($itemStore as $key => $value) {
|
foreach ($itemStore as $key => $value) {
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
|
if (empty($record[$v['item_id']])) {
|
||||||
|
$record[$v['item_id']] = 0;
|
||||||
|
}
|
||||||
$record[$v['item_id']] += 1;
|
$record[$v['item_id']] += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$free_num = $goods['free_num'] - $this->countFreeBuyTimes($address, $id, $goods_id);
|
||||||
|
$pending = $this->checkPendingBuyGoodsNormal($address, $goods_id, $shop_id, $id);
|
||||||
error_log("getChestItems start " . json_encode(
|
error_log("getChestItems start " . json_encode(
|
||||||
array(
|
array(
|
||||||
'goods_id' => $goods_id,
|
'goods_id' => $goods_id,
|
||||||
'items' => array_keys($record),
|
'items' => array_keys($record),
|
||||||
|
'free_num' => $free_num,
|
||||||
|
'pending' => $pending,
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->_rspData(
|
$this->_rspData(
|
||||||
array(
|
array(
|
||||||
'items' => array_keys($record),
|
'items' => array_keys($record),
|
||||||
|
'free_num' => $free_num,
|
||||||
|
'pending' => $pending,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1811,16 +1829,16 @@ class ShopController extends BaseAuthedController
|
|||||||
return phpcommon\bnToStr($ret_price);
|
return phpcommon\bnToStr($ret_price);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function countFreeBuyTimes($goods)
|
private function countFreeBuyTimes($free_type, $id, $goods_id)
|
||||||
{
|
{
|
||||||
$conn = myself()->_getMysql('');
|
$conn = myself()->_getMysql('');
|
||||||
$account = myself()->_getAccountId();
|
$account = myself()->_getAccountId();
|
||||||
|
|
||||||
switch ($goods['free_type']) {
|
switch ($free_type) {
|
||||||
case 1: {
|
case 1: {
|
||||||
$dayTime = myself()->_getNowDaySeconds();
|
$dayTime = myself()->_getNowDaySeconds();
|
||||||
$sql = 'SELECT COUNT(*) as cnt FROM t_shop_free_record WHERE account_id = ? AND `id` = ? AND goods_id = ? AND createtime >= ?';
|
$sql = 'SELECT COUNT(*) as cnt FROM t_shop_free_record WHERE account_id = ? AND `id` = ? AND goods_id = ? AND createtime >= ?';
|
||||||
$row = $conn->execQueryOne($sql, array($account, $goods['id'], $goods['goods_id'], $dayTime));
|
$row = $conn->execQueryOne($sql, array($account, $id, $goods_id, $dayTime));
|
||||||
return $row['cnt'];
|
return $row['cnt'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user