This commit is contained in:
mkm 2024-05-13 17:56:33 +08:00
commit 04372b88b2
13 changed files with 581 additions and 10 deletions

View File

@ -0,0 +1,95 @@
<?php
namespace app\admin\controller\user;
use app\admin\controller\BaseAdminController;
use app\admin\lists\user\UserFeedbackLists;
use app\admin\logic\user\UserFeedbackLogic;
use app\admin\validate\user\UserFeedbackValidate;
/**
* 用户反馈表控制器
* Class UserFeedbackController
* @package app\admin\controller\user
*/
class UserFeedbackController extends BaseAdminController
{
/**
* @notes 获取用户反馈表列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function lists()
{
return $this->dataLists(new UserFeedbackLists());
}
/**
* @notes 添加用户反馈表
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function add()
{
$params = (new UserFeedbackValidate())->post()->goCheck('add');
$result = UserFeedbackLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(UserFeedbackLogic::getError());
}
/**
* @notes 编辑用户反馈表
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function edit()
{
$params = (new UserFeedbackValidate())->post()->goCheck('edit');
$result = UserFeedbackLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(UserFeedbackLogic::getError());
}
/**
* @notes 删除用户反馈表
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function delete()
{
$params = (new UserFeedbackValidate())->post()->goCheck('delete');
UserFeedbackLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取用户反馈表详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function detail()
{
$params = (new UserFeedbackValidate())->goCheck('detail');
$result = UserFeedbackLogic::detail($params);
return $this->data($result);
}
}

View File

@ -7,7 +7,9 @@ use app\admin\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
use app\common\model\bank\Bank;
use app\common\model\merchant\Merchant;
use app\common\model\merchant\MerchantBank;
use app\common\model\supplier\Supplier;
/**
@ -46,7 +48,6 @@ class MerchantBankLists extends BaseAdminDataLists implements ListsSearchInterfa
public function lists(): array
{
return MerchantBank::where($this->searchWhere)
->field(['id', 'mer_id', 'bank_id', 'bank_code', 'bank_branch', 'name', 'id_card', 'phone', 'financial_img', 'is_own', 'is_check', 'fail_msg', 'admin_id'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
@ -56,6 +57,13 @@ class MerchantBankLists extends BaseAdminDataLists implements ListsSearchInterfa
$data['bank_info'] = $bank;
$data['is_own_text'] = $data['is_own'] == 0 ? '个人账户' : '对公账户';
$data['is_check_text'] = $data->is_check_text;
if($data['user_type'] == 1){
$merchant = Merchant::field('mer_name')->where('mer_id',$data['mer_id'])->findOrEmpty();
$data['mer_name'] = $merchant['mer_name'];
}else{
$supplier = Supplier::field('mer_name')->where('id',$data['supplier_id'])->findOrEmpty();
$data['mer_name'] = $supplier['mer_name'];
}
})
->toArray();
}

View File

@ -0,0 +1,66 @@
<?php
namespace app\admin\lists\user;
use app\admin\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\user\UserFeedback;
/**
* 用户反馈表列表
* Class UserFeedbackLists
* @package app\admin\listsuser
*/
class UserFeedbackLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function setSearch(): array
{
return [
'=' => ['uid'],
'%like%' => ['name', 'contact'],
];
}
/**
* @notes 获取用户反馈表列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function lists(): array
{
return UserFeedback::where($this->searchWhere)
->field(['id', 'uid', 'content', 'images', 'name', 'contact'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取用户反馈表数量
* @return int
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function count(): int
{
return UserFeedback::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,102 @@
<?php
namespace app\admin\logic\user;
use app\common\logic\BaseLogic;
use app\common\model\user\UserFeedback;
use think\facade\Db;
/**
* 用户反馈表逻辑
* Class UserFeedbackLogic
* @package app\admin\logic\user
*/
class UserFeedbackLogic extends BaseLogic
{
/**
* @notes 添加用户反馈表
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/13 16:56
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
UserFeedback::create([
'uid' => $params['uid'],
'content' => $params['content'],
'images' => $params['images'],
'name' => $params['name'],
'contact' => $params['contact']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑用户反馈表
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/13 16:56
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
UserFeedback::where('id', $params['id'])->update([
'uid' => $params['uid'],
'content' => $params['content'],
'images' => $params['images'],
'name' => $params['name'],
'contact' => $params['contact']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除用户反馈表
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/13 16:56
*/
public static function delete(array $params): bool
{
return UserFeedback::destroy($params['id']);
}
/**
* @notes 获取用户反馈表详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/05/13 16:56
*/
public static function detail($params): array
{
return UserFeedback::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace app\admin\validate\user;
use app\common\validate\BaseValidate;
/**
* 用户反馈表验证器
* Class UserFeedbackValidate
* @package app\admin\validate\user
*/
class UserFeedbackValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'uid' => 'require',
'content' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'uid' => '用户id',
'content' => '反馈内容',
];
/**
* @notes 添加场景
* @return UserFeedbackValidate
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function sceneAdd()
{
return $this->only(['uid','content','images','name','contact']);
}
/**
* @notes 编辑场景
* @return UserFeedbackValidate
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function sceneEdit()
{
return $this->only(['id','uid','content','images','name','contact']);
}
/**
* @notes 删除场景
* @return UserFeedbackValidate
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return UserFeedbackValidate
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace app\api\controller;
use app\common\service\UploadService;
use Exception;
class UploadController extends BaseApiController
{
/**
* @notes 上传图片
* @author 乔峰
* @date 2021/12/29 16:27
*/
public function image()
{
try {
$cid = $this->request->post('cid', 0);
$result = UploadService::image($cid);
return $this->success('上传成功', $result);
} catch (Exception $e) {
return $this->fail($e->getMessage());
}
}
/**
* @notes 上传视频
* @author 乔峰
* @date 2021/12/29 16:27
*/
public function video()
{
try {
$cid = $this->request->post('cid', 0);
$result = UploadService::video($cid);
return $this->success('上传成功', $result);
} catch (Exception $e) {
return $this->fail($e->getMessage());
}
}
}

View File

@ -17,15 +17,20 @@ class MerchantController extends BaseApiController
return $this->dataLists(new MerchantLists());
}
public function add_bank(){
public function add_bank()
{
$params = (new MerchantBankValidate())->post()->goCheck('add');
$has = Db::name('merchant_bank')->where('is_own',$params['is_own'])->where('is_check','<>',2)->findOrEmpty();
if($params['user_type'] == 1){
$has = Db::name('merchant_bank')->where('mer_id',$params['mer_id'])->where('is_own',$params['is_own'])->where('is_check','<>',2)->findOrEmpty();
}else{
$has = Db::name('merchant_bank')->where('supplier_id',$params['supplier_id'])->where('is_own',$params['is_own'])->where('is_check','<>',2)->findOrEmpty();
}
if(!empty($has)){
return $this->fail('已提交审核请勿重复提交');
}
$expireAt = strtotime(date('Y-m-d 23:59:59')); // 当天结束时间戳
$totalKey = $params['mer_id'].$params['bank_code'];
$checkKey = $params['mer_id'].'check';
$totalKey = $params['user_type'] == 1 ? $params['mer_id'].$params['bank_code'] : $params['supplier_id'].$params['bank_code'];
$checkKey = $params['user_type'] == 1 ? $params['mer_id'].'check' : $params['supplier_id'].'check';
$check = Cache::get($totalKey) ?? 0;
if ($check && $check > 9) {
return $this->fail('超出绑定限制请明日再绑定');
@ -58,7 +63,9 @@ class MerchantController extends BaseApiController
}
}
$save_data = [
'mer_id' => $params['mer_id'],
'user_type' => $params['user_type'],
'mer_id' => $params['mer_id'] ?? 0,
'supplier_id' => $params['supplier_id'] ?? 0,
'name' => $params['name'],
'bank_id' => $params['bank_id'],
'bank_code' => $params['bank_code'],

View File

@ -0,0 +1,34 @@
<?php
namespace app\api\controller\user;
use app\api\lists\user\UserFeedbackLists;
use app\api\logic\user\UserFeedbackLogic;
use app\admin\validate\user\UserFeedbackValidate;
use app\api\controller\BaseApiController;
class UserFeedbackController extends BaseApiController
{
/**
* @notes 获取用户反馈表列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function lists()
{
return $this->dataLists(new UserFeedbackLists());
}
public function add()
{
$params = (new UserFeedbackValidate())->post()->goCheck('add');
$result = UserFeedbackLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(UserFeedbackLogic::getError());
}
}

View File

@ -69,7 +69,7 @@ class OpurchaseGoodsOfferList extends BaseAdminDataLists implements ListsSearchI
*/
public function count(): int
{
$supplier_id=$this->request->userInfo['supplier']['id'] ?? 1;
$supplier_id=$this->request->userInfo['supplier']['id'] ?? 0;
$params = $this->request->get();
if(isset($params['type']) && $params['type'] == 2){
$where[] = ['price','<>',''];

View File

@ -0,0 +1,60 @@
<?php
namespace app\api\lists\user;
use app\admin\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\user\UserFeedback;
class UserFeedbackLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function setSearch(): array
{
return [
'=' => ['uid'],
'%like%' => ['name', 'contact'],
];
}
/**
* @notes 获取用户反馈表列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function lists(): array
{
$uid = $this->request->userInfo['user_id'];
return UserFeedback::where($this->searchWhere)->where('uid',$uid)
->field(['id', 'uid', 'content', 'images', 'name', 'contact'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取用户反馈表数量
* @return int
* @author likeadmin
* @date 2024/05/13 16:56
*/
public function count(): int
{
return UserFeedback::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace app\api\logic\user;
use app\common\logic\BaseLogic;
use app\common\model\user\UserFeedback;
use think\facade\Db;
class UserFeedbackLogic extends BaseLogic
{
/**
* @notes 添加用户反馈表
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/13 16:56
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
UserFeedback::create([
'uid' => $params['uid'],
'content' => $params['content'],
'images' => $params['images'] ? json_encode($params['images']) : null,
'name' => $params['name'],
'contact' => $params['contact'],
'create_time' => time(),
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
}

View File

@ -8,11 +8,13 @@
class MerchantBankValidate extends BaseValidate
{
protected $rule = [
'user_type|用户类型' => 'require|in:1,2',
'mer_id|商户id' => 'requireIf:user_type,1|checkMerchant',
'supplier_id|供应商id' => 'requireIf:user_type,2|checkSupplier',
'is_own|账号类型' => 'require|in:0,1',
'mer_id|商户id' => 'require|checkMerchant',
'name|姓名' => 'require',
'bank_id|开户银行' => 'require|checkBank',
'bank_code|银行账号' => 'require|integer',
'bank_code|银行账号' => 'require',
'bank_branch|开户网点' => 'require|max:32',
'id_card|身份证' => 'requireIf:is_own,0|idCard',
'phone|手机号' => 'requireIf:is_own,0|mobile',
@ -22,7 +24,7 @@
public function sceneAdd()
{
return $this->only(['mer_id','is_own','bank_id','name','bank_code','bank_branch','id_card','phone','financial_img']);
return $this->only(['user_type','mer_id','supplier_id','is_own','bank_id','name','bank_code','bank_branch','id_card','phone','financial_img']);
}
public function checkBank($value){
@ -40,4 +42,12 @@
}
return true;
}
public function checkSupplier($value){
$data = Db::name('supplier')->where('id',$value)->findOrEmpty();
if(empty($data)){
return '供应商不存在';
}
return true;
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace app\common\model\user;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 用户反馈表模型
* Class UserFeedback
* @package app\common\model\user
*/
class UserFeedback extends BaseModel
{
use SoftDelete;
protected $name = 'user_feedback';
protected $deleteTime = 'delete_time';
public function getImagesAttr($value){
return !empty($value) ? json_decode($value,true) : '';
}
}