1
This commit is contained in:
parent
40a9933e42
commit
be50073599
@ -1,245 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace services;
|
||||
|
||||
require_once('mt/BattlePass.php');
|
||||
require_once('mt/HeroLevel.php');
|
||||
require_once('mt/Item.php');
|
||||
require_once ('services/callback/ShopAddItemService.php');
|
||||
|
||||
use mt\BattlePass;
|
||||
use mt\HeroLevel;
|
||||
use mt\Item;
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class BuyPassCbService
|
||||
{
|
||||
public function process($order){
|
||||
error_log("BuyPassCbService----------------");
|
||||
$itemService = new ShopAddItemService();
|
||||
switch ($order['item_id']){
|
||||
//购买通行证回调
|
||||
case V_ITEM_PASS : {
|
||||
$itemService->addGameLog($order['address'],"buyItem","begin",array(
|
||||
'param1' => $order['order_id'],
|
||||
'param2' => json_encode(array(
|
||||
'item_id' => $order['item_id'],
|
||||
'item_num' => $order['item_num'],
|
||||
)),
|
||||
));
|
||||
$this->_activateUser($order['address']);
|
||||
error_log("callback buyBattlePass address: {$order['address']}, order_id: {$order['order_id']}, item_id: {$order['item_id']}, item_num: {$order['item_num']}");
|
||||
$itemService->addGameLog($order['address'],"buyItem","end",array(
|
||||
'param1' => $order['order_id'],
|
||||
'param2' => json_encode(array(
|
||||
'item_id' => $order['item_id'],
|
||||
'item_num' => $order['item_num'],
|
||||
)),
|
||||
));
|
||||
}
|
||||
break;
|
||||
//购买等级回调
|
||||
case V_ITEM_EXP : {
|
||||
$itemService->addGameLog($order['address'],"buyItem","begin",array(
|
||||
'param1' => $order['order_id'],
|
||||
'param2' => json_encode(array(
|
||||
'item_id' => $order['item_id'],
|
||||
'item_num' => $order['item_num'],
|
||||
)),
|
||||
));
|
||||
$this->_updateUserLevel($order['address'],$order['item_num']);
|
||||
error_log("callback buyPassExp address: {$order['address']}, order_id: {$order['order_id']}, item_id: {$order['item_id']}, item_num: {$order['item_num']}");
|
||||
$itemService->addGameLog($order['address'],"buyItem","end",array(
|
||||
'param1' => $order['order_id'],
|
||||
'param2' => json_encode(array(
|
||||
'item_id' => $order['item_id'],
|
||||
'item_num' => $order['item_num'],
|
||||
)),
|
||||
));
|
||||
}
|
||||
break;
|
||||
//重置英雄等级回调
|
||||
case V_ITEM_RESET_CARD : {
|
||||
$itemService->addGameLog($order['address'],"resetHero","begin",array(
|
||||
'param1' => $order['order_id'],
|
||||
'param2' => json_encode(array(
|
||||
'item_id' => $order['item_id'],
|
||||
'item_num' => $order['item_num'],
|
||||
'hero_unnid' => json_decode($order['ext_data']),
|
||||
)),
|
||||
));
|
||||
$this->_resetHeroLevel($order,$itemService);
|
||||
error_log("callback resetHeroLevel address: {$order['address']}, order_id: {$order['order_id']}, item_id: {$order['item_id']}, item_num: {$order['item_num']}");
|
||||
$itemService->addGameLog($order['address'],"resetHero","end",array(
|
||||
'param1' => $order['order_id'],
|
||||
'param2' => json_encode(array(
|
||||
'item_id' => $order['item_id'],
|
||||
'item_num' => $order['item_num'],
|
||||
'hero_unnid' => json_decode($order['ext_data']),
|
||||
)),
|
||||
));
|
||||
}
|
||||
default : {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _resetHeroLevel($order,$addItemService){
|
||||
$heroDb = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($order['address']),
|
||||
't_hero',
|
||||
array(
|
||||
'idx' => json_decode($order['ext_data'])
|
||||
)
|
||||
);
|
||||
$piece_item_id = 0;
|
||||
$metaList = Item::getMetaListByType(Item::FRAGMENT_TYPE);
|
||||
foreach ($metaList as $meta){
|
||||
if ($meta['relationship'] == $heroDb['hero_id']) {
|
||||
$piece_item_id = $meta['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$piece = 0;
|
||||
$serum = 0;
|
||||
$gold = 0;
|
||||
for ($i=1;$i<=$heroDb['hero_lv'];$i++){
|
||||
$heroLevelMeta = HeroLevel::getByLevel($i);
|
||||
$piece += $heroLevelMeta['piece'];
|
||||
$serum += $heroLevelMeta['serum'];
|
||||
$gold += $heroLevelMeta['gold'];
|
||||
}
|
||||
SqlHelper::update
|
||||
(myself()->_getMysql($order['address']),
|
||||
't_hero',
|
||||
array(
|
||||
'idx' => json_decode($order['ext_data'])
|
||||
),
|
||||
array(
|
||||
'hero_lv' => 1,
|
||||
'rand_attr' => $heroDb['base_attr'],
|
||||
)
|
||||
);
|
||||
$addItemService->addItem($order['address'],$piece_item_id,$piece);
|
||||
$addItemService->addItem($order['address'],V_ITEM_GOLD,$gold);
|
||||
$this->_updateDynData($order,TN_DAILY_RESET_HERO_LEVEL_STATE,json_decode($order['ext_data']));
|
||||
}
|
||||
|
||||
private function _activateUser($address){
|
||||
SqlHelper::update
|
||||
(myself()->_getMysql($address),
|
||||
't_user',
|
||||
array(
|
||||
'address' => $address
|
||||
),
|
||||
array(
|
||||
'activated' => 1,
|
||||
'activatetime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
|
||||
$userDb = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($address),
|
||||
't_user',
|
||||
array(
|
||||
'address' => $address
|
||||
)
|
||||
);
|
||||
$this->_updatePassData($userDb);
|
||||
}
|
||||
|
||||
private function _updateUserLevel($address,$exp){
|
||||
$userDb = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($address),
|
||||
't_user',
|
||||
array(
|
||||
'address' => $address
|
||||
)
|
||||
);
|
||||
|
||||
$expNew = $userDb['exp'] + $exp;
|
||||
$levelNew = $userDb['level'];
|
||||
BattlePass::getExpByLv($levelNew,$expNew);
|
||||
SqlHelper::update
|
||||
(myself()->_getMysql($address),
|
||||
't_user',
|
||||
array(
|
||||
'address' => $address
|
||||
),
|
||||
array(
|
||||
'exp' => $expNew,
|
||||
'level' => $levelNew,
|
||||
)
|
||||
);
|
||||
$userDbNew = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($address),
|
||||
't_user',
|
||||
array(
|
||||
'address' => $address
|
||||
)
|
||||
);
|
||||
$this->_updatePassData($userDbNew);
|
||||
$this->_updateDynData($userDbNew,TN_DAILY_BUY_LEVEL_STATE,0);
|
||||
}
|
||||
|
||||
private function _updateDynData($user,$x,$y){
|
||||
$x = intval($x) ;
|
||||
$y = intval($y) ;
|
||||
SqlHelper::update
|
||||
( myself()->_getMysql($user['address']),
|
||||
't_dyndata',
|
||||
array(
|
||||
'account_id' => $user['account_id'],
|
||||
'x' => $x,
|
||||
'y' => $y
|
||||
),
|
||||
array(
|
||||
'val' => 0,
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _updatePassData($user){
|
||||
$currSeasonMeta = BattlePass::getCurrentSeason();
|
||||
$passDb = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($user['address']),
|
||||
't_user_pass',
|
||||
array(
|
||||
'account_id' => $user['account_id'],
|
||||
'season_id' => $currSeasonMeta['id'],
|
||||
)
|
||||
);
|
||||
$rewards = emptyReplace(json_decode($passDb['data'], true), array());
|
||||
foreach ($rewards['basic'] as &$reward){
|
||||
if ($user['level'] >= $reward['level'] && $reward['state']==-1){
|
||||
$reward['state'] = 0;
|
||||
}
|
||||
}
|
||||
if ($user['activated']){
|
||||
foreach ($rewards['platinum'] as &$reward){
|
||||
if ($user['level'] >= $reward['level'] && $reward['state']==-1){
|
||||
$reward['state'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
SqlHelper::update(
|
||||
myself()->_getMysql($user['address']),
|
||||
't_user_pass',
|
||||
array(
|
||||
'account_id' => $user['account_id'],
|
||||
'season_id' => $currSeasonMeta['id'],
|
||||
|
||||
),
|
||||
array(
|
||||
'data' => json_encode($rewards),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace services;
|
||||
|
||||
require_once('mt/Dailyselection.php');
|
||||
require_once('ShopAddItemService.php');
|
||||
require_once('models/ShopBuyRecord.php');
|
||||
require_once('services/LogService.php');
|
||||
|
||||
define('V_ORDER_TYPE_BUY_SHOP_GOODS', 1);
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use mt\Dailyselection;
|
||||
use mt\Shop;
|
||||
use models\ShopBuyRecord;
|
||||
use services\LogService;
|
||||
|
||||
class BuyShopGoodsCbService
|
||||
{
|
||||
public function process($order)
|
||||
{
|
||||
$itemService = new ShopAddItemService();
|
||||
switch ($order['order_type']) {
|
||||
case V_ORDER_TYPE_BUY_SHOP_GOODS: {
|
||||
$ext_data = json_decode($order['ext_data'], true);
|
||||
switch ($ext_data['mode']) {
|
||||
case SHOP_BUY_MODE_NORMAL:
|
||||
$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->_buyNormal($order, $ext_data);
|
||||
$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'],
|
||||
)),
|
||||
));
|
||||
break;
|
||||
case SHOP_BUY_MODE_DAILY_SELECTION:
|
||||
$itemService->addGameLog($order['address'], "shopBuyDailySelection", "begin", array(
|
||||
'param1' => $order['order_id'],
|
||||
'param2' => json_encode(array(
|
||||
'item_id' => $order['item_id'],
|
||||
'item_num' => $order['item_num'],
|
||||
)),
|
||||
));
|
||||
$this->_buyDailySelection($order, $ext_data);
|
||||
$itemService->addGameLog($order['address'], "shopBuyDailySelection", "end", array(
|
||||
'param1' => $order['order_id'],
|
||||
'param2' => json_encode(array(
|
||||
'item_id' => $order['item_id'],
|
||||
'item_num' => $order['item_num'],
|
||||
)),
|
||||
));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _buyNormal($order, $ext_data)
|
||||
{
|
||||
$self = myself();
|
||||
if (!$self) {
|
||||
return;
|
||||
}
|
||||
|
||||
$order_id = $order['order_id'];
|
||||
$address = $order['address'];
|
||||
$account_id = $this->getAccountId($address);
|
||||
$item_id = $order['item_id'];
|
||||
$item_num = $order['item_num'];
|
||||
$id = null;
|
||||
if (isset($ext_data['id'])) {
|
||||
$id = $ext_data['id'];
|
||||
}
|
||||
|
||||
error_log("callback buynormal address: $address, order_id: $order_id, goods_id: $item_id, goods_num: $item_num");
|
||||
|
||||
$this->_addGoods($address, array(
|
||||
'goods_id' => $item_id,
|
||||
'goods_num' => $item_num,
|
||||
'id' => $id,
|
||||
));
|
||||
}
|
||||
|
||||
private function _buyDailySelection($order, $ext_data)
|
||||
{
|
||||
$self = myself();
|
||||
if (!$self) {
|
||||
return;
|
||||
}
|
||||
|
||||
$order_id = $order['order_id'];
|
||||
$item_id = $order['item_id'];
|
||||
$item_num = $order['item_num'];
|
||||
$address = $order['address'];
|
||||
$account_id = $this->getAccountId($address);
|
||||
$idx = $ext_data['idx'];
|
||||
$grid = $ext_data['grid'];
|
||||
$count = $ext_data['count'];
|
||||
|
||||
error_log("callback buyDailySelection address: $address, order_id: $order_id, item_id: $item_id, item_num: $item_num, idx: $idx, grid: $grid, count: $count");
|
||||
|
||||
$conn = $self->_getMysql($address);
|
||||
$sql = "SELECT count_$grid FROM t_shop_dailyselection WHERE idx = $idx";
|
||||
$chk = $conn->execQuery($sql);
|
||||
if (!$chk) {
|
||||
return;
|
||||
}
|
||||
if ($chk[0]['count_' . $grid] < $count) {
|
||||
error_log("BuyShopGoodsCbService::_buyDailySelection() count not enough, address: $address, order_id: $order_id, item_id: $item_id, item_num: $item_num, idx: $idx, grid: $grid, count: $count");
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = "UPDATE t_shop_dailyselection SET count_$grid = count_$grid - $count WHERE idx = $idx";
|
||||
$chk = $conn->execScript($sql);
|
||||
|
||||
if ($chk) {
|
||||
$this->_addGoods($address, array(
|
||||
'goods_id' => $item_id,
|
||||
'goods_num' => $item_num,
|
||||
));
|
||||
} else {
|
||||
error_log("BuyShopGoodsCbService::_buyDailySelection() decDailySelectionItem failed, address: $address, order_id: $order_id, item_id: $item_id, item_num: $item_num, idx: $idx, grid: $grid, count: $count");
|
||||
}
|
||||
}
|
||||
|
||||
private function _addGoods($address, $goods)
|
||||
{
|
||||
$itemService = new ShopAddItemService();
|
||||
$item_id = $goods['goods_id'];
|
||||
$goods_num = $goods['goods_num'];
|
||||
|
||||
$id = null;
|
||||
if ($goods['id']) {
|
||||
$id = $goods['id'];
|
||||
}
|
||||
|
||||
error_log(json_encode($goods));
|
||||
error_log('_addGoods ' . $address . ' item_id ' . $item_id . ' goods_num ' . $goods_num . ' id ' . $id);
|
||||
$itemService->addItem($address, $item_id, $goods_num);
|
||||
if ($id) {
|
||||
ShopBuyRecord::addWithAddress($address, $id, $goods_num);
|
||||
}
|
||||
}
|
||||
|
||||
private function getAccountId($address)
|
||||
{
|
||||
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($address),
|
||||
't_user',
|
||||
array(
|
||||
'address' => $address
|
||||
)
|
||||
);
|
||||
|
||||
return $row['account_id'];
|
||||
}
|
||||
}
|
@ -1,251 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace services;
|
||||
|
||||
require_once("models/ShopBuyRecord.php");
|
||||
require_once("mt/ShopGoods.php");
|
||||
require_once("services/LogService.php");
|
||||
require_once("ShopAddItemService.php");
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
use mt\ShopGoods;
|
||||
use models\ShopBuyRecord;
|
||||
use services\LogService;
|
||||
|
||||
class ShopInappPurchaseDiamonds
|
||||
{
|
||||
|
||||
public function process()
|
||||
{
|
||||
error_log('ShopInappPurchaseDiamonds:' . json_encode($_REQUEST, JSON_PRETTY_PRINT));
|
||||
error_log('----- inappPurchaseDiamonds -----');
|
||||
$body = json_decode(file_get_contents('php://input'), true);
|
||||
error_log('body:' . json_encode($body));
|
||||
$channel = $body['channel'];
|
||||
$records = $body['records'];
|
||||
$sign = $body['sign'];
|
||||
|
||||
// {
|
||||
// channel: 'google',
|
||||
// sign: '123456677' // 签名字段
|
||||
// records: [{
|
||||
// productId: '2999', // 从google play console获取的product id
|
||||
// gameOrderId: '1231321312', // 开始支付时, 从游戏相关服务那获得的订单id
|
||||
// orderId: 'GPA.3355-1172-9416-16839', // 从google develope API 获取的订单id
|
||||
// status: 9, // 订单状态, 上报的订单状态一般只有2种情况, 9: 支付成功, 96: 用户退款
|
||||
// }]
|
||||
// }
|
||||
// let reportData: any = {
|
||||
// channel: 'google',
|
||||
// records,
|
||||
// }
|
||||
// const hashSort = ''
|
||||
// const signStr = 'channel=google&' + records.map(record =>Object.keys(record).sort().map(key => `${key}=${record[key]}`).join('&')).join('&')
|
||||
|
||||
// const sign = hmacsha256(signStr, hashSort)
|
||||
|
||||
// 定义一个空数组,用来存放每个记录的键值对字符串
|
||||
$record_strings = array();
|
||||
|
||||
// 遍历 records 数组,对每个记录进行排序和拼接
|
||||
foreach ($records as $record) {
|
||||
// 对记录的键进行升序排序
|
||||
ksort($record);
|
||||
// 把记录的键值对用等号连接,然后用 & 连接成一个字符串
|
||||
$record_string = http_build_query($record);
|
||||
// 把字符串加入到 record_strings 数组中
|
||||
$record_strings[] = $record_string;
|
||||
}
|
||||
|
||||
// 把 record_strings 数组用 & 连接成一个字符串
|
||||
$records_string = implode("&", $record_strings);
|
||||
|
||||
$hash_data = 'channel=' . $channel . '&' . $records_string;
|
||||
|
||||
$signature = hash_hmac('sha256', $hash_data, BUY_SERVER_PKEY);
|
||||
|
||||
if ($signature != $sign) {
|
||||
$this->_rspErr(1, "signature error, signature: {$signature}, sign: {$sign}");
|
||||
return;
|
||||
}
|
||||
|
||||
$conn = myself()->_getMysql('');
|
||||
// 有三种情况:
|
||||
// 1. 从商城购买钻石,有订单号
|
||||
// 2. 站外充值钻石,没有订单号
|
||||
// 3. appstore 退款,没有订单号
|
||||
|
||||
for ($i = 0; $i < count($records); $i++) {
|
||||
$record = $records[$i];
|
||||
|
||||
$product_id = $record['productId'];
|
||||
$order_id = $record['gameOrderId'];
|
||||
$out_order_id = $record['orderId'];
|
||||
$status = $record['status'];
|
||||
|
||||
switch ($status) {
|
||||
case 9: {
|
||||
$status = 1;
|
||||
if (empty($order_id)) {
|
||||
if (empty($product_id)) {
|
||||
$this->_rspErr(2, "product_id is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
// $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' => 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;
|
||||
}
|
||||
|
||||
$this->_addGoods($address, array(
|
||||
'goods_id' => $item_id,
|
||||
'goods_num' => $item_num,
|
||||
'id' => $id,
|
||||
));
|
||||
}
|
||||
break;
|
||||
case 96:
|
||||
$status = 3;
|
||||
if (empty($order_id)) {
|
||||
if (empty($product_id)) {
|
||||
$this->_rspErr(2, "product_id is empty");
|
||||
return;
|
||||
}
|
||||
// $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;
|
||||
}
|
||||
|
||||
$this->_decGoods($address, array(
|
||||
'goods_id' => $item_id,
|
||||
'goods_num' => $item_num,
|
||||
'id' => $id,
|
||||
));
|
||||
break;
|
||||
default:
|
||||
$status = 0;
|
||||
$this->_rspErr(1, "status is not 9 or 96");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
private function getAccountId($address)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($address),
|
||||
't_user',
|
||||
array(
|
||||
'address' => $address
|
||||
)
|
||||
);
|
||||
if (!$row) {
|
||||
return null;
|
||||
}
|
||||
return $row['account_id'];
|
||||
}
|
||||
|
||||
private function _addGoods($address, $goods)
|
||||
{
|
||||
$itemService = new ShopAddItemService();
|
||||
$item_id = $goods['goods_id'];
|
||||
$goods_num = $goods['goods_num'];
|
||||
|
||||
$id = null;
|
||||
if ($goods['id']) {
|
||||
$id = $goods['id'];
|
||||
}
|
||||
|
||||
error_log('_addGoods ' . $address . ' item_id ' . $item_id . ' goods_num ' . $goods_num . ' id ' . $id);
|
||||
$itemService->addItem($address, $item_id, $goods_num);
|
||||
if ($id) {
|
||||
ShopBuyRecord::addWithAddress($address, $id, $goods_num);
|
||||
}
|
||||
}
|
||||
|
||||
private function _decGoods($address, $goods)
|
||||
{
|
||||
$itemService = new ShopAddItemService();
|
||||
$item_id = $goods['goods_id'];
|
||||
$goods_num = $goods['goods_num'];
|
||||
|
||||
error_log('_decGoods ' . $address . ' item_id ' . $item_id . ' goods_num ' . $goods_num);
|
||||
$itemService->decItem($address, $item_id, $goods_num);
|
||||
}
|
||||
|
||||
private function _rspOk() {
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => "callback success",
|
||||
));
|
||||
}
|
||||
|
||||
private function _rspErr($errcode, $errmsg) {
|
||||
if (SERVER_ENV != _ONLINE) {
|
||||
error_log(json_encode(array(
|
||||
'errcode' => $errcode,
|
||||
'errmsg' => $errmsg,
|
||||
)));
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => $errcode,
|
||||
'errmsg' => $errmsg,
|
||||
));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user