...
This commit is contained in:
parent
59695d2738
commit
a33db90313
@ -1298,6 +1298,7 @@ CREATE TABLE `t_web2_order` (
|
|||||||
DROP TABLE IF EXISTS `t_market_store`;
|
DROP TABLE IF EXISTS `t_market_store`;
|
||||||
CREATE TABLE `t_market_store` (
|
CREATE TABLE `t_market_store` (
|
||||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`order_id` bigint(20) NOT NULL COMMENT '订单id',
|
||||||
`o_link` varchar(64) DEFAULT NULL COMMENT '关联的链上上架单号',
|
`o_link` varchar(64) DEFAULT NULL COMMENT '关联的链上上架单号',
|
||||||
`status` int(11) NOT NULL COMMENT '订单状态 0:出售中 1:已下架 2:已售出 3:购买中',
|
`status` int(11) NOT NULL COMMENT '订单状态 0:出售中 1:已下架 2:已售出 3:购买中',
|
||||||
`owner_address` varchar(60) NOT NULL COMMENT '当前拥有者',
|
`owner_address` varchar(60) NOT NULL COMMENT '当前拥有者',
|
||||||
@ -1331,7 +1332,8 @@ CREATE TABLE `t_market_store` (
|
|||||||
KEY `c_lv` (`c_lv`),
|
KEY `c_lv` (`c_lv`),
|
||||||
KEY `c_quality` (`c_quality`),
|
KEY `c_quality` (`c_quality`),
|
||||||
KEY `c_durability` (`c_durability`),
|
KEY `c_durability` (`c_durability`),
|
||||||
KEY `c_id` (`c_id`)
|
KEY `c_id` (`c_id`),
|
||||||
|
KEY `order_id` (`order_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10014 DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB AUTO_INCREMENT=10014 DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `t_market_transaction_record`;
|
DROP TABLE IF EXISTS `t_market_transaction_record`;
|
||||||
|
@ -2,6 +2,7 @@ begin;
|
|||||||
|
|
||||||
CREATE TABLE `t_market_store` (
|
CREATE TABLE `t_market_store` (
|
||||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`order_id` bigint(20) NOT NULL COMMENT '订单id',
|
||||||
`o_link` varchar(64) DEFAULT NULL COMMENT '关联的链上上架单号',
|
`o_link` varchar(64) DEFAULT NULL COMMENT '关联的链上上架单号',
|
||||||
`status` int(11) NOT NULL COMMENT '订单状态 0:出售中 1:已下架 2:已售出 3:购买中',
|
`status` int(11) NOT NULL COMMENT '订单状态 0:出售中 1:已下架 2:已售出 3:购买中',
|
||||||
`owner_address` varchar(60) NOT NULL COMMENT '当前拥有者',
|
`owner_address` varchar(60) NOT NULL COMMENT '当前拥有者',
|
||||||
@ -35,7 +36,8 @@ CREATE TABLE `t_market_store` (
|
|||||||
KEY `c_lv` (`c_lv`),
|
KEY `c_lv` (`c_lv`),
|
||||||
KEY `c_quality` (`c_quality`),
|
KEY `c_quality` (`c_quality`),
|
||||||
KEY `c_durability` (`c_durability`),
|
KEY `c_durability` (`c_durability`),
|
||||||
KEY `c_id` (`c_id`)
|
KEY `c_id` (`c_id`),
|
||||||
|
KEY `order_id` (`order_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10014 DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB AUTO_INCREMENT=10014 DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
CREATE TABLE `t_market_transaction_record` (
|
CREATE TABLE `t_market_transaction_record` (
|
||||||
|
@ -45,6 +45,7 @@ use mt\Shop;
|
|||||||
use mt\PayMethod;
|
use mt\PayMethod;
|
||||||
use mt\Dailyselection;
|
use mt\Dailyselection;
|
||||||
use mt\ShopChest;
|
use mt\ShopChest;
|
||||||
|
use mt\ShopGoods;
|
||||||
use models\Transaction;
|
use models\Transaction;
|
||||||
use models\BcOrder;
|
use models\BcOrder;
|
||||||
use services\LogService;
|
use services\LogService;
|
||||||
@ -219,8 +220,8 @@ class ShopController extends BaseAuthedController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$goods_str = json_encode($goods);
|
// $goods_str = json_encode($goods);
|
||||||
error_log("address: {$address}, id: {$id}, token_type: {$token_type}, goods_num: {$goods_num} goods_str: {$goods_str}");
|
// error_log("address: {$address}, id: {$id}, token_type: {$token_type}, goods_num: {$goods_num} goods_str: {$goods_str}");
|
||||||
|
|
||||||
$chk = SqlHelper::insert(
|
$chk = SqlHelper::insert(
|
||||||
$conn,
|
$conn,
|
||||||
@ -277,7 +278,7 @@ class ShopController extends BaseAuthedController
|
|||||||
public function buyGoodsDirect()
|
public function buyGoodsDirect()
|
||||||
{
|
{
|
||||||
error_log("buyGoodsDirect --- " . json_encode($_REQUEST));
|
error_log("buyGoodsDirect --- " . json_encode($_REQUEST));
|
||||||
|
|
||||||
// let repdata = {
|
// let repdata = {
|
||||||
// account_id: string
|
// account_id: string
|
||||||
// order_id: string
|
// order_id: string
|
||||||
@ -324,9 +325,9 @@ class ShopController extends BaseAuthedController
|
|||||||
|
|
||||||
$conn = myself()->_getMysql('');
|
$conn = myself()->_getMysql('');
|
||||||
|
|
||||||
$order = SqlHelper::selectOne($conn, 't_shop_buy_order', array('address', 'item_id', 'goods_num', 'status'), array('idx' => $order_id));
|
$order = SqlHelper::selectOne($conn, 't_shop_buy_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('idx' => $order_id));
|
||||||
|
|
||||||
$id = $order['item_id'];
|
$id = $order['id'];
|
||||||
$goods_num = $order['goods_num'];
|
$goods_num = $order['goods_num'];
|
||||||
$o_status = $order['status'];
|
$o_status = $order['status'];
|
||||||
|
|
||||||
@ -348,29 +349,32 @@ class ShopController extends BaseAuthedController
|
|||||||
|
|
||||||
SqlHelper::update($conn, 't_shop_buy_order', array('idx' => $order_id), array('status' => $buyStatus));
|
SqlHelper::update($conn, 't_shop_buy_order', array('idx' => $order_id), array('status' => $buyStatus));
|
||||||
|
|
||||||
|
// 以下是看商品表中是否配置了充值额外奖励
|
||||||
$goods = mt\ShopGoods::get($id);
|
$goods = mt\ShopGoods::get($id);
|
||||||
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
|
||||||
$goods_num = $order['goods_num'];
|
$goods_num = $order['goods_num'];
|
||||||
$bundle_size = $goods['bonus_num'];
|
$bundle_size = $goods['bonus_num'] ? $goods['bonus_num'] : 0;
|
||||||
$item_num = $goods_num * $bundle_size;
|
$item_num = $goods_num * $bundle_size;
|
||||||
$item_id = $goods['bonus'];
|
$item_id = $goods['bonus'];
|
||||||
$address = $order['address'];
|
$meta = mt\Item::get($item_id);
|
||||||
$account_id = $this->getAccountId($address);
|
if ($meta && $item_num > 0) {
|
||||||
|
$address = $order['address'];
|
||||||
|
$account_id = $this->getAccountId($address);
|
||||||
|
|
||||||
if ($item_id == V_ITEM_DIAMOND) {
|
if ($item_id == V_ITEM_DIAMOND) {
|
||||||
$event = [
|
$event = [
|
||||||
'name' => LogService::RECHARGE_CEBG_BONUS,
|
'name' => LogService::RECHARGE_CEBG_BONUS,
|
||||||
'val' => $item_num
|
'val' => $item_num
|
||||||
];
|
];
|
||||||
LogService::productDiamond(['account_id' => $account_id], $event);
|
LogService::productDiamond(['account_id' => $account_id], $event);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_addGoods($address, array(
|
||||||
|
'goods_id' => $item_id,
|
||||||
|
'goods_num' => $item_num,
|
||||||
|
'id' => $id,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_addGoods($address, array(
|
|
||||||
'goods_id' => $item_id,
|
|
||||||
'goods_num' => $item_num,
|
|
||||||
'id' => $id,
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,6 +401,10 @@ class ShopController extends BaseAuthedController
|
|||||||
|
|
||||||
$account_id = $self->_getAccountId();
|
$account_id = $self->_getAccountId();
|
||||||
$address = $self->_getAddress();
|
$address = $self->_getAddress();
|
||||||
|
if (empty($address)) {
|
||||||
|
$this->_rspErr(4, "start purchase failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$item_id = $goods['goods_id'];
|
$item_id = $goods['goods_id'];
|
||||||
$item_num = $goods['goods_num'] * $goods_num;
|
$item_num = $goods['goods_num'] * $goods_num;
|
||||||
@ -416,15 +424,15 @@ class ShopController extends BaseAuthedController
|
|||||||
));
|
));
|
||||||
|
|
||||||
if (!$chk) {
|
if (!$chk) {
|
||||||
$this->_rspErr(4, "start purchase failed");
|
$this->_rspErr(5, "start purchase failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$lastId = $this->lastInsertId($conn);
|
$lastId = $this->lastInsertId($conn);
|
||||||
$order_id = $this->genOrderId($lastId);
|
$order_id = $this->genOrderId($lastId);
|
||||||
|
|
||||||
$test = SqlHelper::update($conn, 't_web2_order', array('idx' => $lastId), array('order_id' => $order_id));
|
$test = SqlHelper::update($conn, 't_web2_order', array('idx' => $lastId), array('order_id' => $order_id));
|
||||||
if (!$test) {
|
if (!$test) {
|
||||||
$this->_rspErr(5, "start purchase failed");
|
$this->_rspErr(6, "start purchase failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
@ -432,7 +440,8 @@ class ShopController extends BaseAuthedController
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function genOrderId($id) {
|
private function genOrderId($id)
|
||||||
|
{
|
||||||
$order_id_base = date('YmdHis') . "10000000";
|
$order_id_base = date('YmdHis') . "10000000";
|
||||||
$divIdx = gmp_mod($id, 9999999);
|
$divIdx = gmp_mod($id, 9999999);
|
||||||
$order_id = phpcommon\bnAdd_s($order_id_base, $divIdx);
|
$order_id = phpcommon\bnAdd_s($order_id_base, $divIdx);
|
||||||
@ -453,6 +462,7 @@ class ShopController extends BaseAuthedController
|
|||||||
|
|
||||||
public function inappPurchaseDiamonds()
|
public function inappPurchaseDiamonds()
|
||||||
{
|
{
|
||||||
|
error_log('ShopInappPurchaseDiamonds:' . json_encode($_REQUEST, JSON_PRETTY_PRINT));
|
||||||
error_log('----- inappPurchaseDiamonds -----');
|
error_log('----- inappPurchaseDiamonds -----');
|
||||||
$body = json_decode(file_get_contents('php://input'), true);
|
$body = json_decode(file_get_contents('php://input'), true);
|
||||||
error_log('body:' . json_encode($body));
|
error_log('body:' . json_encode($body));
|
||||||
@ -542,14 +552,22 @@ class ShopController extends BaseAuthedController
|
|||||||
SqlHelper::update($conn, 't_web2_order', array('order_id' => $order_id), array('status' => $status, 'channel' => $channel, 'out_order_id' => $out_order_id));
|
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'];
|
$id = $order['id'];
|
||||||
$goods = mt\ShopGoods::get($id);
|
$goods = ShopGoods::get($id);
|
||||||
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
||||||
$goods_num = $order['goods_num'];
|
$goods_num = $order['goods_num'];
|
||||||
$bundle_size = $goods['goods_num'];
|
$bundle_size = $goods['goods_num'];
|
||||||
$item_num = $goods_num * $bundle_size;
|
$item_num = $goods_num * $bundle_size;
|
||||||
$item_id = $goods['goods_id'];
|
$item_id = $goods['goods_id'];
|
||||||
$address = $order['address'];
|
$address = $order['address'];
|
||||||
|
if (empty($address)) {
|
||||||
|
$this->_rspErr(4, "address is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
$account_id = $this->getAccountId($address);
|
$account_id = $this->getAccountId($address);
|
||||||
|
if (empty($account_id)) {
|
||||||
|
$this->_rspErr(5, "account_id is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($item_id == V_ITEM_DIAMOND) {
|
if ($item_id == V_ITEM_DIAMOND) {
|
||||||
$event = [
|
$event = [
|
||||||
@ -586,14 +604,22 @@ class ShopController extends BaseAuthedController
|
|||||||
SqlHelper::update($conn, 't_web2_order', array('order_id' => $order_id), array('status' => $status));
|
SqlHelper::update($conn, 't_web2_order', array('order_id' => $order_id), array('status' => $status));
|
||||||
|
|
||||||
$id = $order['id'];
|
$id = $order['id'];
|
||||||
$goods = mt\ShopGoods::get($id);
|
$goods = ShopGoods::get($id);
|
||||||
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
||||||
$goods_num = $order['goods_num'];
|
$goods_num = $order['goods_num'];
|
||||||
$bundle_size = $goods['goods_num'];
|
$bundle_size = $goods['goods_num'];
|
||||||
$item_num = $goods_num * $bundle_size;
|
$item_num = $goods_num * $bundle_size;
|
||||||
$item_id = $goods['goods_id'];
|
$item_id = $goods['goods_id'];
|
||||||
$address = $order['address'];
|
$address = $order['address'];
|
||||||
|
if (empty($address)) {
|
||||||
|
$this->_rspErr(4, "address is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
$account_id = $this->getAccountId($address);
|
$account_id = $this->getAccountId($address);
|
||||||
|
if (empty($account_id)) {
|
||||||
|
$this->_rspErr(5, "account_id is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($item_id == V_ITEM_DIAMOND) {
|
if ($item_id == V_ITEM_DIAMOND) {
|
||||||
$event = [
|
$event = [
|
||||||
@ -929,7 +955,7 @@ class ShopController extends BaseAuthedController
|
|||||||
$event = [
|
$event = [
|
||||||
'name' => LogService::SHOP_BUY_ITEM,
|
'name' => LogService::SHOP_BUY_ITEM,
|
||||||
'val' => $costItems[0]['item_num']
|
'val' => $costItems[0]['item_num']
|
||||||
];
|
];
|
||||||
LogService::consumeDiamond($event);
|
LogService::consumeDiamond($event);
|
||||||
|
|
||||||
$goodsDto = array(
|
$goodsDto = array(
|
||||||
@ -1819,7 +1845,7 @@ class ShopController extends BaseAuthedController
|
|||||||
if (empty($grade)) {
|
if (empty($grade)) {
|
||||||
$grade = 0;
|
$grade = 0;
|
||||||
}
|
}
|
||||||
switch($grade) {
|
switch ($grade) {
|
||||||
case 1: {
|
case 1: {
|
||||||
Hero::addHero1($itemMeta);
|
Hero::addHero1($itemMeta);
|
||||||
}
|
}
|
||||||
|
@ -2,87 +2,104 @@
|
|||||||
|
|
||||||
namespace services;
|
namespace services;
|
||||||
|
|
||||||
|
require_once("mt/ShopGoods.php");
|
||||||
|
require_once("mt/Item.php");
|
||||||
|
require_once("models/ShopBuyRecord.php");
|
||||||
|
require_once("services/LogService.php");
|
||||||
|
require_once("ShopAddItemService.php");
|
||||||
|
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
|
use mt\ShopGoods;
|
||||||
|
use mt\Item;
|
||||||
|
use models\ShopBuyRecord;
|
||||||
|
|
||||||
|
use services\LogService;
|
||||||
|
|
||||||
class ShopBuyGoodsDirect
|
class ShopBuyGoodsDirect
|
||||||
{
|
{
|
||||||
public function process()
|
public function process()
|
||||||
{
|
{
|
||||||
error_log('ShopBuyGoodsDirect:' . json_encode($_REQUEST, JSON_PRETTY_PRINT));
|
error_log("buyGoodsDirect --- " . json_encode($_REQUEST));
|
||||||
// let repdata = {
|
|
||||||
// account_id: string
|
|
||||||
// order_id: string
|
|
||||||
// status: string
|
|
||||||
// id: string
|
|
||||||
// txhash: string
|
|
||||||
// }
|
|
||||||
// 我返回给你这些数据和一个sign字段,
|
|
||||||
// sign使用上面 repdata 按key 顺序排后, 组成key1=val1&key2=val2后, 使用hmac_sha256 hash, key是 iG4Rpsa)6U31$H#^T85$^^3
|
|
||||||
// PENDING = 0, // 初始状态
|
|
||||||
// TRANSFERING = 1, //只有国库模式才会有该状态
|
|
||||||
// TRANSFERED = 2, //只有国库模式才会有该状态
|
|
||||||
// SUCCESS = 9, // 成功的最终状态
|
|
||||||
// TRANSFER_FAIL = 98, // 转账错误
|
|
||||||
// FAIL = 99, // 也是错误
|
|
||||||
//
|
|
||||||
|
|
||||||
$account_id = getReqVal('account_id', '');
|
// let repdata = {
|
||||||
$order_id = getReqVal('order_id', '');
|
// account_id: string
|
||||||
$status = getReqVal('status', '');
|
// order_id: string
|
||||||
$id = getReqVal('id', '');
|
// status: string
|
||||||
$txhash = getReqVal('txhash', '');
|
// id: string
|
||||||
|
// txhash: string
|
||||||
|
// }
|
||||||
|
// 我返回给你这些数据和一个sign字段,
|
||||||
|
// sign使用上面 repdata 按key 顺序排后, 组成key1=val1&key2=val2后, 使用hmac_sha256 hash, key是 iG4Rpsa)6U31$H#^T85$^^3
|
||||||
|
// PENDING = 0, // 初始状态
|
||||||
|
// TRANSFERING = 1, //只有国库模式才会有该状态
|
||||||
|
// TRANSFERED = 2, //只有国库模式才会有该状态
|
||||||
|
// SUCCESS = 9, // 成功的最终状态
|
||||||
|
// TRANSFER_FAIL = 98, // 转账错误
|
||||||
|
// FAIL = 99, // 也是错误
|
||||||
|
//
|
||||||
|
|
||||||
$sign = getReqVal('sign', '');
|
$account_id = getReqVal('account_id', '');
|
||||||
|
$order_id = getReqVal('order_id', '');
|
||||||
|
$status = getReqVal('status', '');
|
||||||
|
$id = getReqVal('id', '');
|
||||||
|
$txhash = getReqVal('txhash', '');
|
||||||
|
|
||||||
$data = array(
|
$sign = getReqVal('sign', '');
|
||||||
'account_id' => $account_id,
|
|
||||||
'id' => $id,
|
|
||||||
'order_id' => $order_id,
|
|
||||||
'status' => $status,
|
|
||||||
'txhash' => $txhash,
|
|
||||||
);
|
|
||||||
|
|
||||||
$hash_data = http_build_query($data);
|
$data = array(
|
||||||
|
'account_id' => $account_id,
|
||||||
|
'id' => $id,
|
||||||
|
'order_id' => $order_id,
|
||||||
|
'status' => $status,
|
||||||
|
'txhash' => $txhash,
|
||||||
|
);
|
||||||
|
|
||||||
$signature = hash_hmac('sha256', $hash_data, 'iG4Rpsa)6U31$H#^T85$^^3');
|
$hash_data = http_build_query($data);
|
||||||
|
|
||||||
if ($signature != $sign) {
|
$signature = hash_hmac('sha256', $hash_data, 'iG4Rpsa)6U31$H#^T85$^^3');
|
||||||
$this->_rspErr(1, "signature error, signature: {$signature}, sign: {$sign}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
error_log("buyGoodsDirect-------" . $order_id . "---" . $status);
|
if ($signature != $sign) {
|
||||||
|
$this->_rspErr(1, "signature error, signature: {$signature}, sign: {$sign}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$conn = myself()->_getMysql('');
|
error_log("buyGoodsDirect-------" . $order_id . "---" . $status);
|
||||||
|
|
||||||
$order = SqlHelper::selectOne($conn, 't_shop_buy_order', array('address', 'item_id', 'goods_num', 'status'), array('idx' => $order_id));
|
$conn = myself()->_getMysql('');
|
||||||
|
|
||||||
$id = $order['item_id'];
|
$order = SqlHelper::selectOne($conn, 't_shop_buy_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('idx' => $order_id));
|
||||||
$goods_num = $order['goods_num'];
|
|
||||||
$o_status = $order['status'];
|
|
||||||
|
|
||||||
if ($o_status != 0) {
|
$id = $order['id'];
|
||||||
$this->_rspErr(1, "order status error, status: {$o_status}");
|
$goods_num = $order['goods_num'];
|
||||||
return;
|
$o_status = $order['status'];
|
||||||
}
|
|
||||||
|
|
||||||
$buyStatus = 0; // 1: 成功, 2: 失败
|
if ($o_status != 0) {
|
||||||
switch ($status) {
|
$this->_rspErr(1, "order status error, status: {$o_status}");
|
||||||
case "9":
|
return;
|
||||||
$buyStatus = 1;
|
}
|
||||||
break;
|
|
||||||
case "99":
|
|
||||||
case "98":
|
|
||||||
$buyStatus = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SqlHelper::update($conn, 't_shop_buy_order', array('idx' => $order_id), array('status' => $buyStatus));
|
$buyStatus = 0; // 1: 成功, 2: 失败
|
||||||
|
switch ($status) {
|
||||||
|
case "9":
|
||||||
|
$buyStatus = 1;
|
||||||
|
break;
|
||||||
|
case "99":
|
||||||
|
case "98":
|
||||||
|
$buyStatus = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$goods = mt\ShopGoods::get($id);
|
SqlHelper::update($conn, 't_shop_buy_order', array('idx' => $order_id), array('status' => $buyStatus));
|
||||||
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
|
||||||
$goods_num = $order['goods_num'];
|
// 以下是看商品表中是否配置了充值额外奖励
|
||||||
$bundle_size = $goods['bonus_num'];
|
$goods = ShopGoods::get($id);
|
||||||
$item_num = $goods_num * $bundle_size;
|
$goods_num = $order['goods_num'];
|
||||||
$item_id = $goods['bonus'];
|
$bundle_size = $goods['bonus_num'] ? $goods['bonus_num'] : 0;
|
||||||
|
$item_num = $goods_num * $bundle_size;
|
||||||
|
$item_id = $goods['bonus'];
|
||||||
|
$meta = Item::get($item_id);
|
||||||
|
if ($meta && $item_num > 0) {
|
||||||
$address = $order['address'];
|
$address = $order['address'];
|
||||||
$account_id = $this->getAccountId($address);
|
$account_id = $this->getAccountId($address);
|
||||||
|
|
||||||
@ -99,7 +116,58 @@ class ShopBuyGoodsDirect
|
|||||||
'goods_num' => $item_num,
|
'goods_num' => $item_num,
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getAccountId($address)
|
||||||
|
{
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getMysql($address),
|
||||||
|
't_user',
|
||||||
|
array(
|
||||||
|
'address' => $address
|
||||||
|
)
|
||||||
|
);
|
||||||
|
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 _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,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,17 @@
|
|||||||
|
|
||||||
namespace services;
|
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
|
class ShopInappPurchaseDiamonds
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -97,14 +108,22 @@ class ShopInappPurchaseDiamonds
|
|||||||
SqlHelper::update($conn, 't_web2_order', array('order_id' => $order_id), array('status' => $status, 'channel' => $channel, 'out_order_id' => $out_order_id));
|
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'];
|
$id = $order['id'];
|
||||||
$goods = mt\ShopGoods::get($id);
|
$goods = ShopGoods::get($id);
|
||||||
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
||||||
$goods_num = $order['goods_num'];
|
$goods_num = $order['goods_num'];
|
||||||
$bundle_size = $goods['goods_num'];
|
$bundle_size = $goods['goods_num'];
|
||||||
$item_num = $goods_num * $bundle_size;
|
$item_num = $goods_num * $bundle_size;
|
||||||
$item_id = $goods['goods_id'];
|
$item_id = $goods['goods_id'];
|
||||||
$address = $order['address'];
|
$address = $order['address'];
|
||||||
|
if (empty($address)) {
|
||||||
|
$this->_rspErr(4, "address is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
$account_id = $this->getAccountId($address);
|
$account_id = $this->getAccountId($address);
|
||||||
|
if (empty($account_id)) {
|
||||||
|
$this->_rspErr(5, "account_id is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($item_id == V_ITEM_DIAMOND) {
|
if ($item_id == V_ITEM_DIAMOND) {
|
||||||
$event = [
|
$event = [
|
||||||
@ -141,14 +160,22 @@ class ShopInappPurchaseDiamonds
|
|||||||
SqlHelper::update($conn, 't_web2_order', array('order_id' => $order_id), array('status' => $status));
|
SqlHelper::update($conn, 't_web2_order', array('order_id' => $order_id), array('status' => $status));
|
||||||
|
|
||||||
$id = $order['id'];
|
$id = $order['id'];
|
||||||
$goods = mt\ShopGoods::get($id);
|
$goods = ShopGoods::get($id);
|
||||||
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
||||||
$goods_num = $order['goods_num'];
|
$goods_num = $order['goods_num'];
|
||||||
$bundle_size = $goods['goods_num'];
|
$bundle_size = $goods['goods_num'];
|
||||||
$item_num = $goods_num * $bundle_size;
|
$item_num = $goods_num * $bundle_size;
|
||||||
$item_id = $goods['goods_id'];
|
$item_id = $goods['goods_id'];
|
||||||
$address = $order['address'];
|
$address = $order['address'];
|
||||||
|
if (empty($address)) {
|
||||||
|
$this->_rspErr(4, "address is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
$account_id = $this->getAccountId($address);
|
$account_id = $this->getAccountId($address);
|
||||||
|
if (empty($account_id)) {
|
||||||
|
$this->_rspErr(5, "account_id is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($item_id == V_ITEM_DIAMOND) {
|
if ($item_id == V_ITEM_DIAMOND) {
|
||||||
$event = [
|
$event = [
|
||||||
@ -172,4 +199,64 @@ class ShopInappPurchaseDiamonds
|
|||||||
|
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getAccountId($address)
|
||||||
|
{
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getMysql($address),
|
||||||
|
't_user',
|
||||||
|
array(
|
||||||
|
'address' => $address
|
||||||
|
)
|
||||||
|
);
|
||||||
|
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