1
This commit is contained in:
parent
c8aaa5d878
commit
d3e16fd6b6
@ -33,6 +33,7 @@ class InAppOrder extends BaseModel {
|
|||||||
't_inapp_order',
|
't_inapp_order',
|
||||||
array(
|
array(
|
||||||
'order_id' => $orderId,
|
'order_id' => $orderId,
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
'platform' => $platform,
|
'platform' => $platform,
|
||||||
'goods_id' => $goodsId,
|
'goods_id' => $goodsId,
|
||||||
'price' => $price,
|
'price' => $price,
|
||||||
@ -42,6 +43,18 @@ class InAppOrder extends BaseModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function update($order, $fieldsKv)
|
||||||
|
{
|
||||||
|
SqlHelper::update(
|
||||||
|
myself()->_getMysql(''),
|
||||||
|
't_inapp_order',
|
||||||
|
array(
|
||||||
|
'order_id' => $orderId
|
||||||
|
),
|
||||||
|
$fieldsKv
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static function isValidPlatform($platform)
|
public static function isValidPlatform($platform)
|
||||||
{
|
{
|
||||||
return in_array($platform, array(self::ANDROID_PLATFORM, self::IOS_PLATFORM));
|
return in_array($platform, array(self::ANDROID_PLATFORM, self::IOS_PLATFORM));
|
||||||
|
@ -96,112 +96,57 @@ class InAppPurchase {
|
|||||||
error_log('InAppPurchase: not found order ' . json_encode($_REQUEST));
|
error_log('InAppPurchase: not found order ' . json_encode($_REQUEST));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ($orderDb['status'] == InAppOrder::FINISHED_STATE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($orderDb['status'] == InAppOrder::FAILED_STATE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case 9: {
|
case 9:
|
||||||
$status = 1;
|
{
|
||||||
if (empty($order_id)) {
|
InAppOrder::update(
|
||||||
if (empty($product_id)) {
|
$orderId,
|
||||||
$this->_rspErr(2, "product_id is empty");
|
array(
|
||||||
|
'status' => InAppOrder::FINISHED_STATE,
|
||||||
|
'sp_order_id' => $spOrderId
|
||||||
|
));
|
||||||
|
$goodsMeta = mt\ShopGoods::get($orderDb['goods_id']);
|
||||||
|
if (!$goodsMeta) {
|
||||||
|
myself()->_addLogEx($orderDb['account_id'], 'InAppPurchase', 'error_not_found_goods',
|
||||||
|
array(
|
||||||
|
$ordreDb['order_id'],
|
||||||
|
json_encode($orderDb)
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$itemId = $goodsMeta['item_id'];
|
||||||
// $goods = mt\ShopGoods::getByProductId($product_id);
|
$itemNum = $goodsMeta['item_num'];
|
||||||
|
if ($itemId == V_ITEM_DIAMOND) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$order = SqlHelper::selectOne($conn, 't_web2_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('order_id' => $order_id, 'status' => 0));
|
|
||||||
error_log('process order ' . json_encode($order));
|
|
||||||
if (!$order) {
|
|
||||||
$this->_rspErr(3, "order not found, order_id: {$order_id}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SqlHelper::update($conn, 't_web2_order', array('order_id' => $order_id), array('status' => $status, 'channel' => $channel, 'out_order_id' => $out_order_id));
|
|
||||||
|
|
||||||
$id = $order['id'];
|
|
||||||
$goods = ShopGoods::get($id);
|
|
||||||
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
|
||||||
$goods_num = $order['goods_num'];
|
|
||||||
$bundle_size = $goods['goods_num'];
|
|
||||||
$item_num = $goods_num * $bundle_size;
|
|
||||||
$item_id = $goods['goods_id'];
|
|
||||||
$address = $order['address'];
|
|
||||||
if (empty($address)) {
|
|
||||||
$this->_rspErr(4, "address is empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$account_id = $this->getAccountId($address);
|
|
||||||
if (empty($account_id)) {
|
|
||||||
$this->_rspErr(5, "account_id is empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item_id == V_ITEM_DIAMOND) {
|
|
||||||
$event = [
|
$event = [
|
||||||
'name' => LogService::RECHARGE_DIAMOND,
|
'name' => LogService::RECHARGE_DIAMOND,
|
||||||
'val' => $item_num
|
'val' => $itemNum
|
||||||
];
|
];
|
||||||
LogService::productDiamond(['account_id' => $account_id], $event);
|
LogService::productDiamondCallback(['account_id' => $orderDb['account_id']], $event);
|
||||||
}
|
} else {
|
||||||
|
myself()->_addLogEx($orderDb['account_id'], 'InAppPurchase', 'error_goods_item_id',
|
||||||
$this->_addGoods($address, array(
|
array(
|
||||||
'goods_id' => $item_id,
|
$ordreDb['order_id'],
|
||||||
'goods_num' => $item_num,
|
json_encode($orderDb)
|
||||||
'id' => $id,
|
|
||||||
));
|
));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 96:
|
case 96:
|
||||||
$status = 3;
|
{
|
||||||
if (empty($order_id)) {
|
myself()->_addLogEx($orderDb['account_id'], 'InAppPurchase', 'refund',
|
||||||
if (empty($product_id)) {
|
array(
|
||||||
$this->_rspErr(2, "product_id is empty");
|
$ordreDb['order_id'],
|
||||||
return;
|
json_encode($orderDb)
|
||||||
}
|
|
||||||
// $goods = mt\ShopGoods::getByProductId($product_id);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 退款
|
|
||||||
$order = SqlHelper::selectOne($conn, 't_web2_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('order_id' => $order_id, 'status' => 1));
|
|
||||||
if (!$order) {
|
|
||||||
$this->_rspErr(3, "order not found, order_id: {$order_id}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SqlHelper::update($conn, 't_web2_order', array('order_id' => $order_id), array('status' => $status));
|
|
||||||
|
|
||||||
$id = $order['id'];
|
|
||||||
$goods = ShopGoods::get($id);
|
|
||||||
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
|
||||||
$goods_num = $order['goods_num'];
|
|
||||||
$bundle_size = $goods['goods_num'];
|
|
||||||
$item_num = $goods_num * $bundle_size;
|
|
||||||
$item_id = $goods['goods_id'];
|
|
||||||
$address = $order['address'];
|
|
||||||
if (empty($address)) {
|
|
||||||
$this->_rspErr(4, "address is empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$account_id = $this->getAccountId($address);
|
|
||||||
if (empty($account_id)) {
|
|
||||||
$this->_rspErr(5, "account_id is empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item_id == V_ITEM_DIAMOND) {
|
|
||||||
$event = [
|
|
||||||
'name' => LogService::RECHARGE_DIAMOND,
|
|
||||||
'val' => -$item_num
|
|
||||||
];
|
|
||||||
LogService::productDiamond(['account_id' => $account_id], $event);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_decGoods($address, array(
|
|
||||||
'goods_id' => $item_id,
|
|
||||||
'goods_num' => $item_num,
|
|
||||||
'id' => $id,
|
|
||||||
));
|
));
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user