1
This commit is contained in:
parent
918fdaaf9c
commit
8933b31dcc
@ -26,6 +26,7 @@ class Bigwheel(object):
|
|||||||
'url': 'webapp/index.php?c=Bigwheel&a=drawS',
|
'url': 'webapp/index.php?c=Bigwheel&a=drawS',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
|
['type', 0, '0:双勾选 1:第1档 2:第2档']
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
|
@ -19,7 +19,8 @@ use services\LogService;
|
|||||||
"grid_state": 0,
|
"grid_state": 0,
|
||||||
"item_id": 123,
|
"item_id": 123,
|
||||||
"item_num": 314,
|
"item_num": 314,
|
||||||
"buy_price": 314
|
"buy_price": 314,
|
||||||
|
"draw_times": 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@ -32,8 +33,13 @@ class BigwheelController extends BaseAuthedController {
|
|||||||
{
|
{
|
||||||
$key = $this->getMidDataKey();
|
$key = $this->getMidDataKey();
|
||||||
$data = $this->getAndCreateData($key);
|
$data = $this->getAndCreateData($key);
|
||||||
|
$priceInfo = $this->getPriceInfo($data['drawed_times']);
|
||||||
|
if (empty($priceInfo)) {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$info = array();
|
$info = array();
|
||||||
$this->fillInfo($info, $data);
|
$this->fillInfo($info, $data, $priceInfo);
|
||||||
myself()->_rspData(array(
|
myself()->_rspData(array(
|
||||||
'info' => $info
|
'info' => $info
|
||||||
));
|
));
|
||||||
@ -41,8 +47,43 @@ class BigwheelController extends BaseAuthedController {
|
|||||||
|
|
||||||
public function drawS()
|
public function drawS()
|
||||||
{
|
{
|
||||||
|
$drawType = getReqVal('type', 0);
|
||||||
|
if (!($drawType == 0 || $drawType == 1 || $drawType == 2)) {
|
||||||
|
myself()->_rspErr(2, 'type param error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$key = $this->getMidDataKey();
|
$key = $this->getMidDataKey();
|
||||||
$data = $this->getAndCreateData($key);
|
$data = $this->getAndCreateData($key);
|
||||||
|
if ($data['drawed_times'] >= self::MAX_DRAW_TIMES) {
|
||||||
|
myself()->_rspErr(1, 'The maximum number of lucky draws has been reached');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$priceInfo = $this->getPriceInfo($data['drawed_times']);
|
||||||
|
if (empty($priceInfo)) {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($priceInfo['cost_item_id'] != V_ITEM_DIAMOND) {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$costItemNum = 0;
|
||||||
|
if ($drawType == 0) {
|
||||||
|
$costItemNum = $priceInfo['price_double'] * $priceInfo['discount_double'];
|
||||||
|
if (empty($costItemNum)) {
|
||||||
|
myself()->_rspErr(3, 'config error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if ($drawType == 1 || $drawType == 2) {
|
||||||
|
$costItemNum = $priceInfo['price_single'] * $priceInfo['discount_single'];
|
||||||
|
if (empty($costItemNum)) {
|
||||||
|
myself()->_rspErr(3, 'config error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
myself()->_rspErr(2, 'type param error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buyS()
|
public function buyS()
|
||||||
@ -71,13 +112,13 @@ class BigwheelController extends BaseAuthedController {
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fillInfo(&$info, &$data)
|
private function fillInfo(&$info, &$data, $priceInfo)
|
||||||
{
|
{
|
||||||
$info = array(
|
$info = array(
|
||||||
'drawed_times' => $data['drawed_times'],
|
'drawed_times' => $data['drawed_times'],
|
||||||
'total_times' => self::MAX_DRAW_TIMES,
|
'total_times' => self::MAX_DRAW_TIMES,
|
||||||
'single_cost' => 0,
|
'single_cost' => $priceInfo['price_single'] * $priceInfo['discount_single'],
|
||||||
'double_cost' => 0,
|
'double_cost' => $priceInfo['price_double'] * $priceInfo['discount_double'],
|
||||||
'items1' => array(),
|
'items1' => array(),
|
||||||
'items2' => array(),
|
'items2' => array(),
|
||||||
);
|
);
|
||||||
@ -119,4 +160,37 @@ class BigwheelController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getPriceInfo($drawedTimes)
|
||||||
|
{
|
||||||
|
$costItem = mt\Parameter::getVal('gacha_cost_item', 0);
|
||||||
|
$gachaPriceSingles = mt\Parameter::getListValue('gacha_price_single');
|
||||||
|
$gachaDiscountSingles = mt\Parameter::getListValue('gacha_discount_single');
|
||||||
|
$gachaPriceDoubles = mt\Parameter::getListValue('gacha_price_double');
|
||||||
|
$gachaDiscountDoubles = mt\Parameter::getListValue('gacha_discount_double');
|
||||||
|
$gachaPriceBuys = mt\Parameter::getListValue('gacha_price_buy');
|
||||||
|
$gachaDiscountBuys = mt\Parameter::getListValue('gacha_discount_buy');
|
||||||
|
if (count($gachaPriceSingles) != count($gachaDiscountSingles) &&
|
||||||
|
count($gachaPriceDoubles) != count($gachaDiscountDoubles) &&
|
||||||
|
count($gachaPriceBuys) != count($gachaDiscountBuys) &&
|
||||||
|
count($gachaDiscountBuys) != self::MAX_DRAW_TIMES) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ($drawedTimes < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ($drawedTimes > self::MAX_DRAW_TIMES) {
|
||||||
|
$drawedTimes = self::MAX_DRAW_TIMES - 1;
|
||||||
|
}
|
||||||
|
$priceInfo = array(
|
||||||
|
'cost_item_id' => $costItem,
|
||||||
|
'price_single' => $gachaPriceSingles[$drawedTimes],
|
||||||
|
'discount_single' => $gachaDiscountSingles[$drawedTimes],
|
||||||
|
'price_double' => $gachaPriceDoubles[$drawedTimes],
|
||||||
|
'discount_double' => $gachaDiscountSingles[$drawedTimes],
|
||||||
|
'price_buy' => $gachaPriceBuys[$drawedTimes],
|
||||||
|
'discount_buy' => $gachaDiscountBuys[$drawedTimes],
|
||||||
|
);
|
||||||
|
return $priceInfo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user