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.
79 lines
2.3 KiB
79 lines
2.3 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
// +----------------------------------------------------------------------
|
|
// | Author: CRMEB Team <admin@crmeb.com>
|
|
// +----------------------------------------------------------------------
|
|
namespace app\controller\admin\system;
|
|
|
|
use app\common\repositories\store\LotteryRepository;
|
|
use app\validate\admin\DepositValidate;
|
|
use crmeb\basic\BaseController;
|
|
use think\App;
|
|
use think\db\exception\DataNotFoundException;
|
|
use think\db\exception\DbException;
|
|
use think\db\exception\ModelNotFoundException;
|
|
use think\facade\Request;
|
|
|
|
class Lottery extends BaseController
|
|
{
|
|
/**
|
|
* @var LotteryRepository
|
|
*/
|
|
protected $repository;
|
|
|
|
/**
|
|
* CacheRepository constructor.
|
|
* @param App $app
|
|
*/
|
|
public function __construct(App $app, LotteryRepository $repository)
|
|
{
|
|
parent::__construct($app);
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return mixed
|
|
* @throws DataNotFoundException
|
|
* @throws DbException
|
|
* @throws ModelNotFoundException
|
|
* @author xaboy
|
|
* @day 2020-05-07
|
|
*/
|
|
public function lst()
|
|
{
|
|
return app('json')->success($this->repository->getList([]));
|
|
}
|
|
|
|
/**
|
|
* @param $id
|
|
* @param DepositValidate $validate
|
|
* @return mixed
|
|
* @throws DbException
|
|
* @author xaboy
|
|
* @day 2020-05-07
|
|
*/
|
|
public function save()
|
|
{
|
|
$data = Request::post();
|
|
|
|
if(count($data) != 6){
|
|
return app('json')->fail('参数错误');
|
|
}
|
|
|
|
$total = array_sum(array_column($data, 'rate'));
|
|
if($total != 100)
|
|
return app('json')->fail('总概率不等于100');
|
|
|
|
foreach ($data as $item){
|
|
$this->repository->update($item['id'], array('type' => $item['type'], 'value' => $item['value'], 'rate' => $item['rate']));
|
|
}
|
|
|
|
return app('json')->success('保存成功');
|
|
}
|
|
}
|
|
|