game2006api/webapp/services/callback/GameItemMallBuyOk.php
hujiabin d00f69ea3e 1
2023-06-25 19:55:41 +08:00

78 lines
2.0 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('orderId', '');
error_log("GameItemMallBuyOk");
$orderDb = SqlHelper::ormSelectOne(
myself()->_getMysql($address),
't_bc_order',
array(
'order_id' => $orderId
)
);
//1已发货 2订单不存在
if (!$orderDb){
return json_encode(array(
'errcode' => 2,
'errmsg' => "Order does not exist",
));
}
if ($orderDb['status'] == 1){
return json_encode(array(
'errcode' => 1,
'errmsg' => "Order shipped",
));
}
// 修改订单状态
$this->_updateOrderState($address,$orderId);
// 小胡 回调的处理
if ($this->_isVirtualItem($orderDb['item_id'])){
$passCbService = new BuyPassCbService();
$passCbService->process($orderDb);
} else {
// 老宋 处理...
$shopGoodsCbService = new BuyShopGoodsCbService();
$shopGoodsCbService->process($orderDb);
}
return 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(),
)
);
}
}