game2006api/webapp/services/callback/GameItemMallBuyOk.php
hujiabin 876f69fd7a 1
2023-06-27 16:12:08 +08:00

79 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace services;
require_once('phpcommon/bchelper.php');
require_once ('services/callback/BuyPassCbService.php');
require_once ('services/callback/BuyShopGoodsCbService.php');
use phpcommon\SqlHelper;
class GameItemMallBuyOk {
public function process()
{
$address = getReqVal('address', '');
$orderId = getReqVal('order_id', '');
error_log("GameItemMallBuyOk-------------------");
$orderDb = SqlHelper::ormSelectOne(
myself()->_getMysql($address),
't_bc_order',
array(
'order_id' => $orderId
)
);
//1已发货 2订单不存在
if (!$orderDb){
echo json_encode(array(
'errcode' => 2,
'errmsg' => "Order does not exist",
));
die ;
}
if ($orderDb['status'] == 1){
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){
return in_array($itemId, array(V_ITEM_EXP, V_ITEM_PASS));
}
private function _updateOrderState($address,$transId){
SqlHelper::update
(myself()->_getMysql($address),
't_bc_order',
array(
'order_id' => $transId
),
array(
'status' => 1,
'modifytime' => myself()->_getNowTime(),
)
);
}
}