adjust
This commit is contained in:
parent
527571146c
commit
8d795e1b6a
@ -511,53 +511,73 @@ class RechargeController
|
|||||||
|
|
||||||
$activityconf = metatable\getRechargeActivityConf();
|
$activityconf = metatable\getRechargeActivityConf();
|
||||||
$recharge_activity = array();
|
$recharge_activity = array();
|
||||||
|
$activity = array();
|
||||||
if ($rechargerow['activity'] != null && $rechargerow['activity'] != '') {
|
if ($rechargerow['activity'] != null && $rechargerow['activity'] != '') {
|
||||||
$activity = json_decode($rechargerow['activity']);
|
$activity = json_decode($rechargerow['activity']);
|
||||||
$needupdate = false;
|
}
|
||||||
foreach ($activity as $key => $item) {
|
$needupdate = false;
|
||||||
$itemconf = $activityconf[$item['id']];
|
foreach ($activityconf as $key => $itemconf) {
|
||||||
if (time() < strtotime($itemconf['time1']) || time() > strtotime($itemconf['time2'])) {
|
if (time() < strtotime($itemconf['time1']) || time() > strtotime($itemconf['time2'])) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$found = false;
|
||||||
|
$itemarray = array();
|
||||||
|
foreach ($activity as $itemkey => $item) {
|
||||||
|
if ($itemconf['shop_id'] == $item['id']) {
|
||||||
|
$found = true;
|
||||||
|
|
||||||
|
switch ($itemconf['type']) {
|
||||||
|
case 1: //累积充值
|
||||||
|
case 2: //累计消耗
|
||||||
|
$itemarray = array(
|
||||||
|
'id' => $item['id'],
|
||||||
|
'cur' => $item['cur'],
|
||||||
|
'target' => $item['target'],
|
||||||
|
'award' => $item['time'] > 0 ? 1 : 0,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 3: //每日累积充值
|
||||||
|
$daysecs = phpcommon\getdayseconds(time());
|
||||||
|
$itemarray['id'] = $item['id'];
|
||||||
|
$itemarray['target'] = $item['target'];
|
||||||
|
if ($item['time'] < $daysecs) {
|
||||||
|
$itemarray['cur'] = 0;
|
||||||
|
$itemarray['award'] = 0;
|
||||||
|
$needupdate = true;
|
||||||
|
$activity[$itemkey]['cur'] = 0;
|
||||||
|
$activity[$itemkey]['award'] = 0;
|
||||||
|
} else {
|
||||||
|
$itemarray['cur'] = $item['cur'];
|
||||||
|
$itemarray['award'] = $item['award'];
|
||||||
|
}
|
||||||
|
array_push($recharge_activity, $itemarray);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$found) {
|
||||||
$itemarray = array(
|
$itemarray = array(
|
||||||
'id' => $item['id'],
|
'id' => $itemconf['shop_id'],
|
||||||
'cur' => $item['cur'],
|
'cur' => 0,
|
||||||
'target' => $item['target'],
|
'target' => $itemconf['target'],
|
||||||
'award' => ($item['time'] > 0 ? 1 : 0),
|
'award' => 0,
|
||||||
);
|
|
||||||
|
|
||||||
switch ($itemconf['type']) {
|
|
||||||
case 1: //累积充值
|
|
||||||
case 2: //累计消耗
|
|
||||||
array_push($recharge_activity, $itemarray);
|
|
||||||
break;
|
|
||||||
case 3: //每日累积充值
|
|
||||||
$daysecs = phpcommon\getdayseconds(time());
|
|
||||||
if ($item['time'] < $daysecs) {
|
|
||||||
$itemarray['cur'] = 0;
|
|
||||||
$itemarray['award'] = 0;
|
|
||||||
$needupdate = true;
|
|
||||||
$activity[$key]['cur'] = 0;
|
|
||||||
$activity[$key]['award'] = 0;
|
|
||||||
} else {
|
|
||||||
$itemarray['award'] = $item['award'];
|
|
||||||
}
|
|
||||||
array_push($recharge_activity, $itemarray);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($needupdate) {
|
|
||||||
$conn->execScript(
|
|
||||||
'UPDATE recharge SET activity=:activity, modify_time=:modify_time' .
|
|
||||||
' WHERE accountid=:accountid;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':activity' => json_encode($activity),
|
|
||||||
':modify_time' => time(),
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
array_push($recharge_activity, $itemarray);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($needupdate) {
|
||||||
|
$conn->execScript(
|
||||||
|
'UPDATE recharge SET activity=:activity, modify_time=:modify_time' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':activity' => json_encode($activity),
|
||||||
|
':modify_time' => time(),
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
@ -757,7 +777,7 @@ class RechargeController
|
|||||||
|
|
||||||
$ret = $conn->execScript(
|
$ret = $conn->execScript(
|
||||||
'UPDATE recharge SET activity=:activity, modify_time=:modify_time' .
|
'UPDATE recharge SET activity=:activity, modify_time=:modify_time' .
|
||||||
' WHERE accountid=:accountid;',
|
' WHERE accountid=:accountid;',
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id,
|
':accountid' => $account_id,
|
||||||
':activity' => json_encode($activity),
|
':activity' => json_encode($activity),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user