1
This commit is contained in:
parent
610d1f368f
commit
c5a34111fb
@ -54,7 +54,8 @@ class InGameMall(object):
|
||||
['order_id', '', '订单id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead()
|
||||
_common.RspHead(),
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -67,7 +68,8 @@ class InGameMall(object):
|
||||
['order_id', '', '订单id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead()
|
||||
_common.RspHead(),
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -132,4 +134,18 @@ class InGameMall(object):
|
||||
['!list', [_common.InGameMallGoods()], '商品列表']
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'shoppingCartBuy',
|
||||
'desc': '购物车下单',
|
||||
'group': 'InGameMall',
|
||||
'url': 'webapp/index.php?c=InGameMall&a=shoppingCartBuy',
|
||||
'params':[
|
||||
_common.ReqHead(),
|
||||
['order_ids', '', '订单id(多个订单用 | 隔开)'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
]
|
||||
|
@ -620,6 +620,108 @@ class InGameMallController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
|
||||
public function shoppingCartBuy(){
|
||||
$orderIds = getReqVal('order_ids', '');
|
||||
if (!$orderIds){
|
||||
$this->_rspErr(1, 'param is not null');
|
||||
return;
|
||||
}
|
||||
$orderIdArr = explode("|",$orderIds);
|
||||
$price = 0;
|
||||
foreach ($orderIdArr as $orderId) {
|
||||
$goodsDb = InGameMall::findByOrderId($orderId);
|
||||
if (!$goodsDb) {
|
||||
myself()->_rspErr(1, 'goods not found');
|
||||
return;
|
||||
}
|
||||
if ($goodsDb['status'] != InGameMall::PENDING_STATE){
|
||||
myself()->_rspErr(1, 'cannot cancel the goods');
|
||||
return;
|
||||
}
|
||||
$price += $goodsDb['price'];
|
||||
}
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $price
|
||||
)
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$this->_decItems($costItems);
|
||||
$propertyChgService = new PropertyChgService();
|
||||
foreach ($orderIdArr as $orderId) {
|
||||
$goodsDb = InGameMall::findByOrderId($orderId);
|
||||
SqlHelper::update
|
||||
($this->_getSelfMysql(),
|
||||
't_user',
|
||||
array(
|
||||
'account_id' => $goodsDb['seller']
|
||||
),
|
||||
array(
|
||||
'gold' => function () use($price) {
|
||||
return "gold + ${price}";
|
||||
}
|
||||
)
|
||||
);
|
||||
switch ($goodsDb['order_type']){
|
||||
case InGameMall::HERO_TYPE :{
|
||||
SqlHelper::update
|
||||
(myself()->_getSelfMysql(),
|
||||
't_hero',
|
||||
array(
|
||||
'idx' => $goodsDb['goods_uniid'],
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId()
|
||||
)
|
||||
);
|
||||
$propertyChgService->addHeroChg();
|
||||
}
|
||||
break;
|
||||
case InGameMall::CHIP_TYPE:{
|
||||
SqlHelper::update
|
||||
(myself()->_getSelfMysql(),
|
||||
't_chip',
|
||||
array(
|
||||
'idx' => $goodsDb['goods_uniid'],
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId()
|
||||
)
|
||||
);
|
||||
$propertyChgService->addChip();
|
||||
}
|
||||
break;
|
||||
case InGameMall::GOLD_TYPE :{
|
||||
SqlHelper::update
|
||||
(myself()->_getSelfMysql(),
|
||||
't_bag',
|
||||
array(
|
||||
'idx' => $goodsDb['goods_uniid'],
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId()
|
||||
)
|
||||
);
|
||||
$propertyChgService->addBagChg();
|
||||
}
|
||||
break;
|
||||
default : {
|
||||
Bag::addItem($goodsDb['item_id'],$goodsDb['item_num']);
|
||||
$propertyChgService->addBagChg();
|
||||
}
|
||||
}
|
||||
InGameMall::buyOk($orderId,myself()->_getAccountId());
|
||||
}
|
||||
myself()->_rspData(array(
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
private function _isNumber($number){
|
||||
if (is_int($number) && $number > 0){
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user