...
This commit is contained in:
parent
300d4fcc3c
commit
4435fb0631
@ -686,7 +686,7 @@ class MarketController extends BaseAuthedController
|
|||||||
$this->_rspErr(1, 'address not found');
|
$this->_rspErr(1, 'address not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$idx = getReqVal('idx', '');
|
$idx = getReqVal('idx', '');
|
||||||
|
|
||||||
$goods = $this->getGoodsByIdx($idx);
|
$goods = $this->getGoodsByIdx($idx);
|
||||||
@ -719,6 +719,7 @@ class MarketController extends BaseAuthedController
|
|||||||
'ext_data' => json_encode(array(
|
'ext_data' => json_encode(array(
|
||||||
'mode' => MARKET_BUY_MODE_NORMAL,
|
'mode' => MARKET_BUY_MODE_NORMAL,
|
||||||
'idx' => $idx,
|
'idx' => $idx,
|
||||||
|
'order_id' => $goods['order_id'],
|
||||||
)),
|
)),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1379,7 +1380,7 @@ class MarketController extends BaseAuthedController
|
|||||||
$row = SqlHelper::selectOne(
|
$row = SqlHelper::selectOne(
|
||||||
myself()->_getSelfMysql(),
|
myself()->_getSelfMysql(),
|
||||||
't_market_store',
|
't_market_store',
|
||||||
array('item_id', 'amount', 's_price', 'owner_address'),
|
array('order_id', 'item_id', 'amount', 's_price', 'owner_address'),
|
||||||
array(
|
array(
|
||||||
'idx' => $idx,
|
'idx' => $idx,
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
|
@ -59,6 +59,8 @@ class BuyShopGoodsCbService
|
|||||||
)),
|
)),
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
|
case MARKET_BUY_MODE_NORMAL:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -3,81 +3,165 @@
|
|||||||
namespace services;
|
namespace services;
|
||||||
|
|
||||||
require_once('phpcommon/bchelper.php');
|
require_once('phpcommon/bchelper.php');
|
||||||
require_once ('services/callback/BuyPassCbService.php');
|
require_once('services/callback/BuyPassCbService.php');
|
||||||
require_once ('services/callback/BuyShopGoodsCbService.php');
|
require_once('services/callback/BuyShopGoodsCbService.php');
|
||||||
|
require_once('ShopAddItemService.php');
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
use models\ShopBuyRecord;
|
||||||
|
|
||||||
class GameItemMarketBuyOk {
|
class GameItemMarketBuyOk
|
||||||
|
{
|
||||||
|
|
||||||
public function process()
|
public function process()
|
||||||
{
|
{
|
||||||
$address = getReqVal('address', '');
|
$itemService = new ShopAddItemService();
|
||||||
$orderId = getReqVal('order_id', '');
|
$address = getReqVal('address', '');
|
||||||
|
$orderId = getReqVal('order_id', '');
|
||||||
error_log("GameItemMallBuyOk-------------------");
|
|
||||||
$orderDb = SqlHelper::ormSelectOne(
|
error_log("GameItemMallBuyOk-------------------");
|
||||||
myself()->_getMysql($address),
|
$orderDb = SqlHelper::ormSelectOne(
|
||||||
't_bc_order',
|
myself()->_getMysql($address),
|
||||||
array(
|
't_bc_order',
|
||||||
'order_id' => $orderId
|
array(
|
||||||
)
|
'order_id' => $orderId
|
||||||
);
|
)
|
||||||
//1:已发货 2:订单不存在
|
);
|
||||||
if (!$orderDb){
|
//1:已发货 2:订单不存在
|
||||||
echo json_encode(array(
|
if (!$orderDb) {
|
||||||
'errcode' => 2,
|
echo json_encode(array(
|
||||||
'errmsg' => "Order does not exist",
|
'errcode' => 2,
|
||||||
));
|
'errmsg' => "Order does not exist",
|
||||||
die ;
|
));
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
if ($orderDb['status'] == 1) {
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 1,
|
||||||
|
'errmsg' => "Order shipped",
|
||||||
|
));
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
// 修改订单状态
|
||||||
|
$this->_updateOrderState($address, $orderId);
|
||||||
|
|
||||||
|
$ext_data = json_decode($orderDb['ext_data'], true);
|
||||||
|
|
||||||
|
switch ($ext_data['mode']) {
|
||||||
|
case MARKET_BUY_MODE_NORMAL: {
|
||||||
|
$order = $orderDb;
|
||||||
|
$itemService->addGameLog($order['address'], "shopBuyNormal", "begin", array(
|
||||||
|
'param1' => $order['order_id'],
|
||||||
|
'param2' => json_encode(array(
|
||||||
|
'item_id' => $order['item_id'],
|
||||||
|
'item_num' => $order['item_num'],
|
||||||
|
)),
|
||||||
|
));
|
||||||
|
$this->buyFromMarket($order, $ext_data['idx']);
|
||||||
|
$itemService->addGameLog($order['address'], "shopBuyNormal", "end", array(
|
||||||
|
'param1' => $order['order_id'],
|
||||||
|
'param2' => json_encode(array(
|
||||||
|
'item_id' => $order['item_id'],
|
||||||
|
'item_num' => $order['item_num'],
|
||||||
|
)),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($orderDb['status'] == 1){
|
break;
|
||||||
echo json_encode(array(
|
|
||||||
'errcode' => 1,
|
|
||||||
'errmsg' => "Order shipped",
|
|
||||||
));
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
// 修改订单状态
|
|
||||||
$this->_updateOrderState($address,$orderId);
|
|
||||||
|
|
||||||
// 小胡 回调的处理
|
|
||||||
if ($this->_isVirtualItem($orderDb['item_id'])){
|
|
||||||
$passCbService = new BuyPassCbService();
|
|
||||||
$passCbService->process($orderDb);
|
|
||||||
} else {
|
|
||||||
// 老宋 处理...
|
|
||||||
$shopGoodsCbService = new BuyShopGoodsCbService();
|
|
||||||
$shopGoodsCbService->process($orderDb);
|
|
||||||
|
|
||||||
}
|
|
||||||
echo json_encode(array(
|
|
||||||
'errcode' => 0,
|
|
||||||
'errmsg' => "callback success",
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _isVirtualItem($itemId){
|
echo json_encode(array(
|
||||||
return in_array($itemId, array(
|
'errcode' => 0,
|
||||||
V_ITEM_EXP,
|
'errmsg' => "callback success",
|
||||||
V_ITEM_PASS,
|
));
|
||||||
V_ITEM_RESET_CARD,
|
}
|
||||||
)
|
|
||||||
);
|
private function _isVirtualItem($itemId)
|
||||||
|
{
|
||||||
|
return in_array(
|
||||||
|
$itemId,
|
||||||
|
array(
|
||||||
|
V_ITEM_EXP,
|
||||||
|
V_ITEM_PASS,
|
||||||
|
V_ITEM_RESET_CARD,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _updateOrderState($address, $transId)
|
||||||
|
{
|
||||||
|
SqlHelper::update(
|
||||||
|
myself()->_getMysql($address),
|
||||||
|
't_bc_order',
|
||||||
|
array(
|
||||||
|
'order_id' => $transId
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'status' => 1,
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buyFromMarket($order, $idx)
|
||||||
|
{
|
||||||
|
$address = $order['address'];
|
||||||
|
$goods = $this->getMarketGoods($address, $idx);
|
||||||
|
$this->markMarketGoodsSold($address, $idx);
|
||||||
|
|
||||||
|
$this->_addGoods($address, $goods);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getMarketGoods($address, $idx)
|
||||||
|
{
|
||||||
|
$row = SqlHelper::selectOne(
|
||||||
|
myself()->_getMysql($address),
|
||||||
|
't_market_store',
|
||||||
|
array('order_id', 'item_id', 'amount', 's_price', 'owner_address'),
|
||||||
|
array(
|
||||||
|
'idx' => $idx
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (!$row) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!$row['item_id']) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function markMarketGoodsSold($address, $idx)
|
||||||
|
{
|
||||||
|
SqlHelper::update(
|
||||||
|
myself()->_getMysql($address),
|
||||||
|
't_market_store',
|
||||||
|
array(
|
||||||
|
'idx' => $idx
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'status' => 2,
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _addGoods($address, $goods)
|
||||||
|
{
|
||||||
|
$itemService = new ShopAddItemService();
|
||||||
|
$item_id = $goods['item_id'];
|
||||||
|
$goods_num = $goods['amount'];
|
||||||
|
|
||||||
|
$id = null;
|
||||||
|
if ($goods['id']) {
|
||||||
|
$id = $goods['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _updateOrderState($address,$transId){
|
error_log(json_encode($goods));
|
||||||
SqlHelper::update
|
error_log('_addGoods ' . $address . ' item_id ' . $item_id . ' goods_num ' . $amount . ' id ' . $id);
|
||||||
(myself()->_getMysql($address),
|
$itemService->addItem($address, $item_id, $goods_num);
|
||||||
't_bc_order',
|
if ($id) {
|
||||||
array(
|
ShopBuyRecord::addWithAddress($address, $id, $goods_num);
|
||||||
'order_id' => $transId
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'status' => 1,
|
|
||||||
'modifytime' => myself()->_getNowTime(),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user