3 changed files with 165 additions and 56 deletions
@ -0,0 +1,79 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\controller; |
||||
|
|
||||
|
use app\BaseController; |
||||
|
use app\model\Zone as ZoneModel; |
||||
|
use app\model\ZoneGoods; |
||||
|
use app\logic\Zone as ZoneLogic; |
||||
|
use app\model\ZoneOrder; |
||||
|
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($zone_id) |
||||
|
{ |
||||
|
return $this->renderSuccess('数据返回成功',ZoneGoods::getList($zone_id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 立即刮奖 |
||||
|
* @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); |
||||
|
|
||||
|
return $this->renderSuccess('开始刮奖',['list' => $data['data'], 'c_r_id' => $data['c_r_id']]); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 结束刮奖 |
||||
|
* @param $zoneOrderId |
||||
|
* @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['msg']); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue