diff --git a/app/common/dao/user/ExchangePickupPointDao.php b/app/common/dao/user/ExchangePickupPointDao.php new file mode 100644 index 0000000..fdd32f3 --- /dev/null +++ b/app/common/dao/user/ExchangePickupPointDao.php @@ -0,0 +1,23 @@ +uid_list) + ->column(['uid','real_name','nickname','avatar','phone'],'uid'); + } + + + +} diff --git a/app/common/repositories/user/ExchangePickupPointRepository.php b/app/common/repositories/user/ExchangePickupPointRepository.php new file mode 100644 index 0000000..a9f40a3 --- /dev/null +++ b/app/common/repositories/user/ExchangePickupPointRepository.php @@ -0,0 +1,78 @@ +dao = $dao; + } + + + + + + /** + * Common: 编辑信息 + * Author: wu-hui + * Time: 2024/01/14 10:52 + * @param $params + */ + public function editInfo($params){ + $info = $this->dao->getSearch([])->where('id',(int)$params['id'])->findOrEmpty(); + $info->address = $params['address']; + $info->is_show = $params['is_show']; + $info->uid_list = implode(',',$params['uid_list']); + + $info->save(); + } + /** + * Common: 获取信息列表 + * Author: wu-hui + * Time: 2024/01/14 10:47 + * @param array $params + * @param int $page + * @param int $limit + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function getList(array $params,int $page,int $limit):array{ + $query = $this->dao->getSearch([]) + ->when((int)$params['uid'] > 0,function($query) use ($params){ + $query->where('find_in_set(' . $params['uid'] . ',`uid_list`)'); + }) + ->when(!empty($params['address']),function($query) use ($params){ + $query->where('address', "like", "%{$params['address']}%"); + }) + ->order('create_time DESC,id DESC'); + $count = $query->count(); + $list = $query->page($page,$limit)->append(['user_list'])->select(); + + return compact('count','list'); + } + /** + * Common: 获取单条信息 + * Author: wu-hui + * Time: 2024/01/14 11:31 + * @param $id + * @return array + */ + public function getInfo($id){ + return $this->dao->getSearch([]) + ->append(['user_list']) + ->where('id',$id) + ->findOrEmpty() + ->toArray(); + } + + + + +} diff --git a/app/controller/admin/user/ExchangeQuota.php b/app/controller/admin/user/ExchangeQuota.php index 2d8cf8e..2dac117 100644 --- a/app/controller/admin/user/ExchangeQuota.php +++ b/app/controller/admin/user/ExchangeQuota.php @@ -2,7 +2,9 @@ namespace app\controller\admin\user; +use app\common\model\user\ExchangePickupPoint; use app\common\repositories\user\ExchangeIntegralRecordRepository; +use app\common\repositories\user\ExchangePickupPointRepository; use app\common\repositories\user\ExchangeQuotaRecordRepository; use app\common\repositories\user\ExchangeQuotaRepository; use crmeb\basic\BaseController; @@ -116,6 +118,62 @@ class ExchangeQuota extends BaseController } + /** + * Common: 提货点编辑 + * Author: wu-hui + * Time: 2024/01/14 10:53 + * @return mixed + */ + public function pickupPointEdit(){ + // 参数获取 + $params = $this->request->params(['id','address','is_show','uid_list']); + if(empty($params['address'])) return app('json')->fail('请输入提货点地址!'); + if(!is_array($params['uid_list']) || count($params['uid_list']) <= 0) 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); + } + // 提货记录 + public function pickupPointRecord(){ + + + debug('开发中...'); + } + diff --git a/route/admin/marketing.php b/route/admin/marketing.php index b6e2940..0d348bd 100644 --- a/route/admin/marketing.php +++ b/route/admin/marketing.php @@ -447,7 +447,19 @@ Route::group(function () { Route::get('integral_record_list', '.ExchangeQuota/integralRecordList')->name('systemUserExchangeIntegralRecordList')->option([ '_alias' => '额度变更记录', ]); - + // 提货点管理 + Route::get('pickup_point_edit', '.ExchangeQuota/pickupPointEdit')->name('systemUserExchangePickupPointEdit')->option([ + '_alias' => '提货点编辑', + ]); + Route::get('pickup_point_list', '.ExchangeQuota/pickupPointList')->name('systemUserExchangePickupPointList')->option([ + '_alias' => '提货点列表', + ]); + Route::get('pickup_point_info/:id', '.ExchangeQuota/pickupPointInfo')->name('systemUserExchangePickupPointInfo')->option([ + '_alias' => '提货点信息', + ]); + Route::get('pickup_point_record', '.ExchangeQuota/pickupPointRecord')->name('systemUserExchangePickupPointRecord')->option([ + '_alias' => '提货记录', + ]);