record daily_purchase
This commit is contained in:
parent
92ce83a436
commit
2105b305b0
@ -343,6 +343,7 @@ CREATE TABLE `recharge` (
|
|||||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`accountid` varchar(60) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '账号id',
|
`accountid` varchar(60) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '账号id',
|
||||||
`first_data` mediumblob COMMENT '首充数据',
|
`first_data` mediumblob COMMENT '首充数据',
|
||||||
|
`daily_purchase` mediumblob COMMENT '每日特惠礼包',
|
||||||
`recharge_diamond` int(11) NOT NULL DEFAULT '0' COMMENT '累计充值钻石',
|
`recharge_diamond` int(11) NOT NULL DEFAULT '0' COMMENT '累计充值钻石',
|
||||||
`present_diamond` int(11) NOT NULL DEFAULT '0' COMMENT '充值赠送钻石总量',
|
`present_diamond` int(11) NOT NULL DEFAULT '0' COMMENT '充值赠送钻石总量',
|
||||||
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
@ -362,7 +363,6 @@ CREATE TABLE `orderinfo` (
|
|||||||
`goodsid` int(11) NOT NULL DEFAULT '0' COMMENT ' 商品id',
|
`goodsid` int(11) NOT NULL DEFAULT '0' COMMENT ' 商品id',
|
||||||
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
`item_list` text DEFAULT '' COMMENT '内容',
|
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
KEY `idx_accountid` (`accountid`),
|
KEY `idx_accountid` (`accountid`),
|
||||||
KEY `idx_orderid` (`orderid`),
|
KEY `idx_orderid` (`orderid`),
|
||||||
|
@ -221,7 +221,7 @@ class RechargeController
|
|||||||
'account_id' => $_REQUEST['account_id'],
|
'account_id' => $_REQUEST['account_id'],
|
||||||
'goodsid' => $_REQUEST['goodsid'],
|
'goodsid' => $_REQUEST['goodsid'],
|
||||||
'orderid' => $_REQUEST['orderid'],
|
'orderid' => $_REQUEST['orderid'],
|
||||||
'amount' => $_REQUEST['amount'],,
|
'amount' => $_REQUEST['amount'],
|
||||||
);
|
);
|
||||||
$sign = phpcommon\md5Sign($params, 'NrN3zkVOzXF1vRzUc9eJM9ZKRO5eLooD', $_REQUEST['timestamp']);
|
$sign = phpcommon\md5Sign($params, 'NrN3zkVOzXF1vRzUc9eJM9ZKRO5eLooD', $_REQUEST['timestamp']);
|
||||||
if ($sign != $_REQUEST['sign']) {
|
if ($sign != $_REQUEST['sign']) {
|
||||||
@ -258,19 +258,73 @@ class RechargeController
|
|||||||
if ($shopgoods['type'] == 3) {
|
if ($shopgoods['type'] == 3) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
$nowtime = time();
|
||||||
|
$conn = $this->getMysql($_REQUEST['account_id']);
|
||||||
|
$this->insertNewOrder($conn, $nowtime);
|
||||||
$addreward = new classes\AddReward();
|
$addreward = new classes\AddReward();
|
||||||
$item_list = $addreward->addReward($shopgoods['item_id'], 1, $_REQUEST['account_id'], 0, 0);
|
$item_list = $addreward->addReward($shopgoods['item_id'], 1, $_REQUEST['account_id'], 0, 0);
|
||||||
foreach ($item_list as &$value) {
|
foreach ($item_list as &$value) {
|
||||||
$value['itemnum'] = (float)$value['itemnum'];
|
$value['itemnum'] = (float)$value['itemnum'];
|
||||||
}
|
}
|
||||||
error_log(json_encode($item_list));
|
error_log(json_encode($item_list));
|
||||||
$nowtime = time();
|
|
||||||
$conn = $this->getMysql($_REQUEST['account_id']);
|
|
||||||
|
|
||||||
$this->insertNewOrder($conn, $nowtime, $item_list);
|
$this->updateUserTable($conn);
|
||||||
|
|
||||||
$this->updateUserTable($conn, $_REQUEST['amount']);
|
|
||||||
$this->addToBuyHis($conn, $nowtime);
|
$this->addToBuyHis($conn, $nowtime);
|
||||||
|
|
||||||
|
//update daily purchase
|
||||||
|
$account_id = $_REQUEST['account_id'];
|
||||||
|
$rechargerow = $conn->execQueryOne(
|
||||||
|
'SELECT * FROM recharge WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!$rechargerow) {
|
||||||
|
$daily_purchase = array();
|
||||||
|
array_push($daily_purchase, array(
|
||||||
|
'id' => $_REQUEST['goodsid'],
|
||||||
|
'time' => $_REQUEST['timestamp'],
|
||||||
|
));
|
||||||
|
|
||||||
|
$ret = $conn->execScript(
|
||||||
|
'INSERT INTO recharge(accountid, daily_purchase, create_time, modify_time) ' .
|
||||||
|
' VALUES(:account_id, :daily_purchase, :create_time, :modify_time) ' .
|
||||||
|
' ON DUPLICATE KEY UPDATE accountid=:account_id, daily_purchase=:daily_purchase, modify_time=:modify_time;',
|
||||||
|
array(
|
||||||
|
':account_id' => $account_id,
|
||||||
|
':daily_purchase' => json_encode($daily_purchase),
|
||||||
|
':create_time' => time(),
|
||||||
|
':modify_time' => time()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$daily_purchase = json_decode($rechargerow['first_data']);
|
||||||
|
$found = false;
|
||||||
|
foreach ($daily_purchase as $key => $dailyitem) {
|
||||||
|
if ($dailyitem['id'] == $_REQUEST['goodsid']) {
|
||||||
|
$firstrecharge = true;
|
||||||
|
$daily_purchase[$key]['time'] = $_REQUEST['timestamp'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$found) {
|
||||||
|
array_push($daily_purchase, array(
|
||||||
|
'id' => $_REQUEST['goodsid'],
|
||||||
|
'time' => $_REQUEST['timestamp'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret = $conn->execScript(
|
||||||
|
'UPDATE recharge SET daily_purchase=:daily_purchase, modify_time=:modify_time' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':daily_purchase' => json_encode($daily_purchase),
|
||||||
|
':modify_time' => time(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
@ -279,57 +333,62 @@ class RechargeController
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function insertNewOrder($conn, $nowtime, $item_list)
|
private function insertNewOrder($conn, $nowtime)
|
||||||
{
|
{
|
||||||
$ret = $conn->execScript('INSERT INTO orderinfo(accountid, orderid, goodsid, price, '.
|
$ret = $conn->execScript(
|
||||||
' create_time, modify_time, item_list)' .
|
'INSERT INTO orderinfo(accountid, orderid, goodsid, price, ' .
|
||||||
'VALUES(:accountid, :orderid, :goodsid, :price, ' .
|
' create_time, modify_time)' .
|
||||||
' :create_time, :modify_time, :item_list);',
|
'VALUES(:accountid, :orderid, :goodsid, :price, ' .
|
||||||
array(
|
' :create_time, :modify_time);',
|
||||||
':accountid' => $_REQUEST['account_id'],
|
array(
|
||||||
':orderid' => $_REQUEST['orderid'],
|
':accountid' => $_REQUEST['account_id'],
|
||||||
':price' => $_REQUEST['amount'],
|
':orderid' => $_REQUEST['orderid'],
|
||||||
':goodsid' => $_REQUEST['goodsid'],
|
':price' => $_REQUEST['amount'],
|
||||||
':create_time' => $nowtime,
|
':goodsid' => $_REQUEST['goodsid'],
|
||||||
':modify_time' => $nowtime,
|
':create_time' => $nowtime,
|
||||||
':item_list' => json_encode($item_list)
|
':modify_time' => $nowtime
|
||||||
));
|
)
|
||||||
|
);
|
||||||
if (!$ret) {
|
if (!$ret) {
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'errcode' => 2,
|
'errcode' => 2,
|
||||||
'errmsg'=> '服务器内部错误'
|
'errmsg' => '服务器内部错误'
|
||||||
));
|
));
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateUserTable($conn, $amount)
|
private function updateUserTable($conn)
|
||||||
{
|
{
|
||||||
$ret = $conn->execScript('UPDATE user SET recharge_times_total=recharge_times_total + 1, ' .
|
$ret = $conn->execScript(
|
||||||
' WHERE accountid=:accountid;',
|
'UPDATE user SET recharge_times_total=recharge_times_total + 1, ' .
|
||||||
array(
|
' WHERE accountid=:accountid;',
|
||||||
':accountid' => $_REQUEST['account_id'],
|
array(
|
||||||
));
|
':accountid' => $_REQUEST['account_id'],
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addToBuyHis($conn, $nowtime)
|
private function addToBuyHis($conn, $nowtime)
|
||||||
{
|
{
|
||||||
$dayseconds = phpcommon\getdayseconds($nowtime);
|
$dayseconds = phpcommon\getdayseconds($nowtime);
|
||||||
$conn->execScript('INSERT INTO buy_his(accountid, goodsid, sum_times, today_times, ' .
|
$conn->execScript(
|
||||||
' last_buy_time, create_time, modify_time)' .
|
'INSERT INTO buy_his(accountid, goodsid, sum_times, today_times, ' .
|
||||||
'VALUES(:accountid, :goodsid, 1, 1, ' .
|
' last_buy_time, create_time, modify_time)' .
|
||||||
' :last_buy_time, :create_time, :modify_time)' .
|
'VALUES(:accountid, :goodsid, 1, 1, ' .
|
||||||
'ON DUPLICATE KEY UPDATE sum_times=sum_times + 1, ' .
|
' :last_buy_time, :create_time, :modify_time)' .
|
||||||
' modify_time=:modify_time, last_buy_time=:last_buy_time,' .
|
'ON DUPLICATE KEY UPDATE sum_times=sum_times + 1, ' .
|
||||||
' today_times=' .
|
' modify_time=:modify_time, last_buy_time=:last_buy_time,' .
|
||||||
" CASE WHEN last_buy_time < $dayseconds THEN 1 ELSE today_times + 1 END;",
|
' today_times=' .
|
||||||
array(
|
" CASE WHEN last_buy_time < $dayseconds THEN 1 ELSE today_times + 1 END;",
|
||||||
':accountid' => $_REQUEST['account_id'],
|
array(
|
||||||
':goodsid' => $_REQUEST['goodsid'],
|
':accountid' => $_REQUEST['account_id'],
|
||||||
':last_buy_time' => $nowtime,
|
':goodsid' => $_REQUEST['goodsid'],
|
||||||
':create_time' => $nowtime,
|
':last_buy_time' => $nowtime,
|
||||||
':modify_time' => $nowtime,
|
':create_time' => $nowtime,
|
||||||
));
|
':modify_time' => $nowtime,
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activityInfo()
|
public function activityInfo()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user