You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.1 KiB
82 lines
2.1 KiB
<?php
|
|
|
|
namespace app\controller;
|
|
|
|
use app\BaseController;
|
|
use app\model\Zone as ZoneModel;
|
|
use app\model\ZoneGoods;
|
|
use app\logic\Zone as ZoneLogic;
|
|
use think\facade\Session;
|
|
|
|
/**
|
|
* 专区
|
|
*/
|
|
class Zone extends BaseController
|
|
{
|
|
/**
|
|
* 首页专区列表
|
|
* @return array
|
|
*/
|
|
public function zoneList()
|
|
{
|
|
return $this->renderSuccess('数据返回成功',ZoneModel::getList());
|
|
}
|
|
|
|
/**
|
|
* 刮奖专区列表
|
|
* @param $zone_id
|
|
* @return array
|
|
*/
|
|
public function zoneGoodsList($zoneId)
|
|
{
|
|
return $this->renderSuccess('数据返回成功',ZoneGoods::getList($zoneId));
|
|
}
|
|
|
|
/**
|
|
* 立即刮奖
|
|
* @param $zoneGoodsId
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function beginLottery($zoneGoodsId)
|
|
{
|
|
$userData = Session::get('login_user_data');
|
|
|
|
# 判断余额够不够
|
|
$judgeRes = ZoneLogic::judgeBalance($userData['id'],$zoneGoodsId);
|
|
if (!$judgeRes) return $this->renderError('余额不足');
|
|
|
|
# 获取刮奖图片
|
|
$data = ZoneLogic::createOrder($userData['id'],$zoneGoodsId);
|
|
if (!$data['status']) $this->renderError($data['msg']);
|
|
|
|
return $this->renderSuccess('开始刮奖',['list' => $data['data'], 'c_r_id' => $data['c_r_id']]);
|
|
}
|
|
|
|
/**
|
|
* 结束刮奖
|
|
* @param $c_r_id
|
|
* @return array|void
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function endLottery($c_r_id)
|
|
{
|
|
$userData = Session::get('login_user_data');
|
|
|
|
$res = ZoneLogic::endOrder($userData['id'],$c_r_id);
|
|
|
|
if (!$res['status']) return $this->renderError($res['msg']);
|
|
|
|
return $this->renderSuccess(
|
|
$res['awards_amount'] > 0 ? '恭喜你中奖了' : '未中奖',
|
|
['awards_amount' => $res['awards_amount']]
|
|
);
|
|
}
|
|
|
|
|
|
|
|
}
|