shop-php/app/controller/api/store/StoreActivity.php

133 lines
4.0 KiB
PHP

<?php
namespace app\controller\api\store;
use app\common\dao\store\consumption\StoreConsumptionDao;
use app\common\dao\store\StoreActivityDao;
use app\common\dao\store\StoreActivityUserDao;
use crmeb\basic\BaseController;
class StoreActivity extends BaseController
{
/**
* 消费金列表
* @param StoreConsumptionDao $dao
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function consumption(StoreConsumptionDao $dao)
{
$list = $dao->getValidList();
return app('json')->success($list);
}
/**
* 选择消费金类型
* @param StoreConsumptionDao $dao
* @return mixed
* @throws \Exception
*/
public function choose(StoreActivityUserDao $dao)
{
$userId = $this->request->uid();
$couponId = $this->request->post('coupon_id');
$activityId = $this->request->post('activity_id', 1);
$dao->choose($userId, $couponId, $activityId);
return app('json')->success('提交成功');
}
/**
* 获取用户参与活动的状态
* @param StoreActivityUserDao $dao
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function status(StoreActivityUserDao $dao)
{
$userId = $this->request->uid();
$activityId = $this->request->post('activity_id', 1);
$result = $dao->status($userId, $activityId);
return app('json')->success($result);
}
/**
* 领取消费金
* @param StoreActivityUserDao $dao
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function receive(StoreActivityUserDao $dao)
{
$userId = $this->request->uid();
$result = $dao->receive($userId);
return app('json')->success($result);
}
/**
* 红包获取记录
* @param StoreActivityUserDao $dao
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function record(StoreActivityUserDao $dao)
{
$userId = $this->request->uid();
$type = $this->request->get('type', 1);
$page = $this->request->get('page', 1);
$limit = $this->request->get('limit', 10);
$result = $dao->record($userId, $type, $page, $limit);
return app('json')->success($result);
}
/**
* 红包余额统计
* @param StoreActivityUserDao $dao
* @return mixed
*/
public function total(StoreActivityUserDao $dao)
{
$userId = $this->request->uid();
$result = $dao->total($userId);
return app('json')->success($result);
}
/**
* 活动商品专区
* @param StoreActivityDao $dao
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function product(StoreActivityDao $dao)
{
$userId = $this->request->uid();
$location = $this->request->get('location');
$streetCode = $this->request->get('street_code');
$activityId = $this->request->get('activity_id', 2);
$result = $dao->product($userId, $location, $streetCode, $activityId);
return app('json')->success($result);
}
/**
* 根据活动获取对应的镇街
* @param StoreActivityDao $dao
* @return mixed
*/
public function district(StoreActivityDao $dao)
{
$activityId = $this->request->get('activity_id', 2);
$result = $dao->district($activityId);
return app('json')->success($result);
}
}