233 lines
7.9 KiB
PHP
233 lines
7.9 KiB
PHP
<?php
|
|
|
|
namespace app\controller\admin\user;
|
|
|
|
use app\common\model\user\ExchangePickupPoint;
|
|
use app\common\repositories\marketing\AgentRepository;
|
|
use app\common\repositories\system\config\ConfigClassifyRepository;
|
|
use app\common\repositories\system\config\ConfigValueRepository;
|
|
use app\common\repositories\user\ExchangeIntegralRecordRepository;
|
|
use app\common\repositories\user\ExchangePickupPointRepository;
|
|
use app\common\repositories\user\ExchangePickupRecordRepository;
|
|
use app\common\repositories\user\ExchangeQuotaRecordRepository;
|
|
use app\common\repositories\user\ExchangeQuotaRepository;
|
|
use crmeb\basic\BaseController;
|
|
use app\common\model\user\User;
|
|
|
|
|
|
class ExchangeQuota extends BaseController{
|
|
|
|
protected $repository;
|
|
|
|
/**
|
|
* Common: 额度信息 - 统计
|
|
* Author: wu-hui
|
|
* Time: 2024/01/11 9:54
|
|
* @return mixed
|
|
*/
|
|
public function quotaTitle(){
|
|
$params = $this->request->params(['quota_type']);
|
|
$statInfo = app()->make(ExchangeQuotaRepository::class)->getStat($params);
|
|
|
|
$quotaType = $params['quota_type'] ?? 1;
|
|
$quotaTitle = $quotaType == 5 ? '积分' : '额度';
|
|
|
|
$data = [
|
|
['className' => 'el-icon-coin','count' => $statInfo['sum_total_quota'],'field' => '分','name' => '平台总'.$quotaTitle],
|
|
['className' => 'el-icon-coin','count' => $statInfo['sum_use_quota'],'field' => '分','name' => '平台已使用'.$quotaTitle],
|
|
['className' => 'el-icon-coin','count' => $statInfo['sum_surplus_quota'],'field' => '分','name' => '平台剩余'.$quotaTitle],
|
|
['className' => 'el-icon-coin','count' => $statInfo['sum_freeze_quota'],'field' => '分','name' => '平台冻结'.$quotaTitle],
|
|
// ['className' => 'el-icon-coin','count' => $statInfo['sum_people_num'],'field' => '分','name' => '参与人数'],
|
|
];
|
|
|
|
return app('json')->success($data);
|
|
}
|
|
/**
|
|
* Common: 额度信息 - 额度持有信息
|
|
* Author: wu-hui
|
|
* Time: 2024/01/11 9:59
|
|
* @return mixed
|
|
*/
|
|
public function quotaList(){
|
|
[$page, $limit] = $this->getPage();
|
|
$params = $this->request->params(['uid','quota_type']);
|
|
|
|
$data = app()->make(ExchangeQuotaRepository::class)->getList((array)$params,(int)$page,(int)$limit);
|
|
|
|
return app('json')->success($data);
|
|
}
|
|
/**
|
|
* Common: 额度信息 - 变更记录
|
|
* Author: wu-hui
|
|
* Time: 2024/01/11 10:02
|
|
* @return mixed
|
|
*/
|
|
public function quotaRecordList(){
|
|
[$page, $limit] = $this->getPage();
|
|
$params = $this->request->params(['uid','quota_type']);
|
|
|
|
$data = app()->make(ExchangeQuotaRecordRepository::class)->getList((array)$params,(int)$page,(int)$limit);
|
|
|
|
return app('json')->success($data);
|
|
}
|
|
|
|
|
|
/**
|
|
* Common: 酒水卡积分 - 统计
|
|
* Author: wu-hui
|
|
* Time: 2024/01/12 17:38
|
|
* @return mixed
|
|
*/
|
|
public function integralTitle(){
|
|
$model = new User();
|
|
|
|
$data = [
|
|
['className' => 'el-icon-coin','count' => $model->sum('exchange_integral'),'field' => '分','name' => '总酒水卡积分'],
|
|
];
|
|
|
|
return app('json')->success($data);
|
|
}
|
|
/**
|
|
* Common: 酒水卡积分 - 额度持有信息
|
|
* Author: wu-hui
|
|
* Time: 2024/01/12 17:39
|
|
* @return mixed
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function integralList(){
|
|
[$page, $limit] = $this->getPage();
|
|
$params = $this->request->params(['uid']);
|
|
|
|
$query = (new User())
|
|
->when((int)$params['uid'] > 0,function($query) use ($params){
|
|
$query->where('uid', (int)$params['uid']);
|
|
})
|
|
->where('exchange_integral','>',0)
|
|
->order('create_time DESC,uid DESC');
|
|
$count = $query->count();
|
|
$list = $query->page($page,$limit)->select();
|
|
|
|
return app('json')->success(compact('count','list'));
|
|
}
|
|
/**
|
|
* Common: 酒水卡积分 - 变更记录
|
|
* Author: wu-hui
|
|
* Time: 2024/01/12 17:40
|
|
* @return mixed
|
|
*/
|
|
public function integralRecordList(){
|
|
[$page, $limit] = $this->getPage();
|
|
$params = $this->request->params(['uid','source']);
|
|
|
|
$data = app()->make(ExchangeIntegralRecordRepository::class)->getList((array)$params,(int)$page,(int)$limit);
|
|
|
|
return app('json')->success($data);
|
|
}
|
|
|
|
|
|
/**
|
|
* Common: 提货点编辑
|
|
* Author: wu-hui
|
|
* Time: 2024/01/14 10:53
|
|
* @return mixed
|
|
*/
|
|
public function pickupPointEdit(){
|
|
// 参数获取
|
|
$params = $this->request->params(['id','title','address','is_show','uid_list','lat','lng']);
|
|
if(empty($params['title'])) return app('json')->fail('请输入提货点名称!');
|
|
if(empty($params['address'])) return app('json')->fail('请输入提货点地址!');
|
|
if(!is_array($params['uid_list']) || count($params['uid_list']) <= 0) return app('json')->fail('请至少选择一个负责人!');
|
|
if(empty($params['lat']) || empty($params['lng'])) return app('json')->fail('请选择经纬度!');
|
|
// 判断:地址是否已经存在
|
|
$isHave = ExchangePickupPoint::where('address',$params['address'])
|
|
->when((int)$params['id'] > 0,function($query) use ($params){
|
|
$query->where('id','<>',$params['id']);
|
|
})
|
|
->count();
|
|
if($isHave > 0) return app('json')->fail('地址已经存在,请勿重复添加!');
|
|
// 信息添加 || 编辑
|
|
app()->make(ExchangePickupPointRepository::class)->editInfo($params);
|
|
|
|
|
|
return app('json')->success('success');
|
|
}
|
|
/**
|
|
* Common: 提货点列表
|
|
* Author: wu-hui
|
|
* Time: 2024/01/14 10:53
|
|
* @return mixed
|
|
*/
|
|
public function pickupPointList(){
|
|
[$page, $limit] = $this->getPage();
|
|
$params = $this->request->params(['uid','address']);
|
|
|
|
$data = app()->make(ExchangePickupPointRepository::class)->getList((array)$params,(int)$page,(int)$limit);
|
|
|
|
return app('json')->success($data);
|
|
}
|
|
/**
|
|
* Common: 提货点信息
|
|
* Author: wu-hui
|
|
* Time: 2024/01/14 11:30
|
|
* @return mixed
|
|
*/
|
|
public function pickupPointInfo($id){
|
|
$data = app()->make(ExchangePickupPointRepository::class)->getInfo($id);
|
|
|
|
return app('json')->success($data);
|
|
}
|
|
/**
|
|
* Common: 提货记录
|
|
* Author: wu-hui
|
|
* Time: 2024/01/14 18:21
|
|
* @return mixed
|
|
*/
|
|
public function pickupPointRecord(){
|
|
[$page, $limit] = $this->getPage();
|
|
$params = $this->request->params(['uid','address', 'staff_uid']);
|
|
|
|
$data = app()->make(ExchangePickupRecordRepository::class)->getList((array)$params,(int)$page,(int)$limit);
|
|
|
|
return app('json')->success($data);
|
|
}
|
|
|
|
|
|
/**
|
|
* Common: 配置信息 - 修改
|
|
* Author: wu-hui
|
|
* Time: 2024/07/01 10:15
|
|
* @return mixed
|
|
*/
|
|
public function setConfig(){
|
|
$config = $this->request->params([
|
|
['quota_integral_switch',0],
|
|
['quota_integral_rate',0],
|
|
['quota_integral_diff_rate',0],
|
|
['quota_integral_upgrade_switch',0],
|
|
['quota_integral_upgrade_money',0],
|
|
['quota_integral_upgrade_level',0],
|
|
]);
|
|
// 保存信息
|
|
$cid = app()->make(ConfigClassifyRepository::class)->getConfigClassifyKeyById('quota_config', '额度与积分配置');
|
|
if (!$cid) return app('json')->fail('保存失败');
|
|
app()->make(ConfigValueRepository::class)->setFormData($config,$this->request->merId());
|
|
return app('json')->success('保存成功');
|
|
}
|
|
/**
|
|
* Common: 配置信息 - 获取
|
|
* Author: wu-hui
|
|
* Time: 2024/07/01 10:15
|
|
* @return mixed
|
|
*/
|
|
public function getConfig(){
|
|
$config = app()->make(ExchangeQuotaRepository::class)->getConfig();
|
|
|
|
return app('json')->success($config);
|
|
}
|
|
|
|
|
|
|
|
}
|