diff --git a/app/api/controller/Recovery.php b/app/api/controller/Recovery.php index fec56b97..1ecb9b57 100644 --- a/app/api/controller/Recovery.php +++ b/app/api/controller/Recovery.php @@ -4,15 +4,70 @@ declare (strict_types=1); namespace app\api\controller; use app\api\model\RecoveryOrder; +use app\api\model\Server\RecoveryCategory; +use app\api\model\Server\ServerRecovery; use app\common\enum\RecoveryStatusEnum; use app\common\enum\RecoveryTypeEnum; use app\common\library\helper; use cores\exception\BaseException; +use think\db\exception\DataNotFoundException; use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; use think\response\Json; class Recovery extends Controller { + + /** + * @notes:分类列表 + * @return Json + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + * @author: wanghousheng + */ + public function categoryList(): Json + { + $model = new RecoveryCategory(); + $list = $model->list(); + if (!empty($list)) { + foreach ($list as $key => $value) { + unset($list[$key]['image']); + } + } + return $this->renderSuccess(compact('list')); + } + + /** + * @notes:服务列表页 + * @throws DbException + * @author: wanghousheng + */ + public function recoveryList(): Json + { + $recovery_name = $this->request->post('recovery_name'); + $category_id = intval($this->request->post('category_id')); + $where = []; + if ($recovery_name) { + $where[] = ['server_recovery.recovery_name', 'like', "%$recovery_name%"]; + } + if ($category_id) { + $where[] = ['server_recovery.category_id', '=', $category_id]; + } + $where[] = ['server_recovery.status', '=', 1]; + $model = new ServerRecovery(); + $list = $model->getList($where); + $data['list'] = $list->items(); + $data['total'] = $list->total(); + if (!$list->isEmpty()) { + foreach ($data['list'] as $key => $value) { + unset($data['list'][$key]['image']); + unset($data['list'][$key]['category']); + } + } + return $this->renderSuccess($data); + } + /** * @notes:用户回收订单列表 * @return Json @@ -20,7 +75,7 @@ class Recovery extends Controller * @throws DbException * @author: wanghousheng */ - public function list(): Json + public function orderList(): Json { $where = []; $order_status = intval($this->request->post('order_status')); @@ -59,7 +114,7 @@ class Recovery extends Controller * @throws BaseException * @author: wanghousheng */ - public function detail(): Json + public function orderDetail(): Json { $orderId = intval($this->request->post('order_id')); if (!$orderId) { @@ -89,7 +144,7 @@ class Recovery extends Controller * @throws BaseException * @author: wanghousheng */ - public function cancel(): Json + public function cancelOrder(): Json { $orderId = intval($this->request->post('order_id')); if (!$orderId) { @@ -109,7 +164,7 @@ class Recovery extends Controller * @throws BaseException * @author: wanghousheng */ - public function add(): Json + public function addOrder(): Json { $imageIds = $this->request->post('image_ids'); if ($imageIds) { @@ -123,6 +178,10 @@ class Recovery extends Controller if (!$shop_id) { return $this->renderError('门店不能为空'); } + $recovery_id = intval($this->request->post('recovery_id')); + if (!$recovery_id) { + return $this->renderError('缺少必要参数'); + } $recovery_type_arr = array_values(RecoveryStatusEnum::data()); $recovery_type_arr = array_column($recovery_type_arr, 'value'); $recovery_type = intval($this->request->post('recovery_type')); @@ -171,6 +230,7 @@ class Recovery extends Controller $express_id = intval($this->request->post('express_id')); $express_no = $this->request->post('express_no'); $data = [ + 'recovery_id' => $recovery_id, 'express_id' => $express_id, 'express_no' => $express_no, 'shipping_address' => $shipping_address, @@ -198,7 +258,7 @@ class Recovery extends Controller * @return Json * @author: wanghousheng */ - public function update(): Json + public function updateOrder(): Json { $order_id = intval($this->request->post('order_id')); if (!$order_id) { diff --git a/app/api/controller/Server.php b/app/api/controller/Server.php index 2e8df859..2239f25e 100644 --- a/app/api/controller/Server.php +++ b/app/api/controller/Server.php @@ -47,6 +47,8 @@ class Server extends Controller { $server_name = $this->request->post('server_name'); $category_id = intval($this->request->post('category_id')); + $order_field = $this->request->post('order_field'); + $order_sort = $this->request->post('order_sort', 'desc'); $where = []; if ($server_name) { $where[] = ['server.server_name', 'like', "%$server_name%"]; @@ -56,7 +58,7 @@ class Server extends Controller } $where[] = ['server.status', '=', 1]; $model = new \app\api\model\Server(); - $list = $model->getList($where); + $list = $model->getList($where, $order_field, $order_sort); $data['list'] = $list->items(); $data['total'] = $list->total(); if (!$list->isEmpty()) { @@ -147,12 +149,20 @@ class Server extends Controller { $serverId = intval($this->request->post('server_id')); $couponId = intval($this->request->post('coupon_id')); + $server_time = $this->request->post('server_time'); + if (!$server_time) { + return $this->renderError('服务时间不能为空'); + } + $server_address = $this->request->post('server_address'); + if (!$server_address) { + return $this->renderError('服务地址不能为空'); + } $remake = (string)$this->request->post('remake'); if (!$serverId) { return $this->renderError('非法请求'); } $orderService = new ServerServiceOrder(); - $result = $orderService->createOrder($serverId, $couponId, $remake); + $result = $orderService->createOrder($serverId, $couponId, $server_address, $server_time, $remake); if ($result) { return $this->renderSuccess($result); } diff --git a/app/api/model/Server/RecoveryCategory.php b/app/api/model/Server/RecoveryCategory.php new file mode 100644 index 00000000..f0d87cb6 --- /dev/null +++ b/app/api/model/Server/RecoveryCategory.php @@ -0,0 +1,53 @@ +hasOne(UploadFile::class, 'file_id', 'image_id') + ->bind(['image_url' => 'preview_url']); + } + + /** + * @notes:获取全部记录 + * @return array + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + * @author: wanghousheng + */ + public function list(): array + { + return $this->with(['image']) + ->where(['status' => 1]) + ->order(['sort', 'create_time']) + ->select() + ->toArray(); + } +} \ No newline at end of file diff --git a/app/api/model/Server/ServerRecovery.php b/app/api/model/Server/ServerRecovery.php new file mode 100644 index 00000000..602202da --- /dev/null +++ b/app/api/model/Server/ServerRecovery.php @@ -0,0 +1,21 @@ +orderInfo; $userInfo = $this->userInfo; //判断当前用户角色 - $orderType = $orderInfo['type']; + $orderType = $orderInfo['order_type']; $userType = $userInfo['user_type']; if ($userType == UserTypeEnum::STORE) { return; @@ -364,15 +364,25 @@ class PaySuccess extends BaseService $userModel = new UserModel(); $up = []; $time = date('Y-m-d'); - if (!empty($userInfo['effective_time']) && strtotime($userInfo['effective_time']) > strtotime(date('Y-m-d'))) { - $time = $userInfo['effective_time']; - } //已经是会员或者未开通会员 if ($orderType == IdentityEnum::MEMBER && $userType != UserTypeEnum::DEALER) { $up['user_type'] = UserTypeEnum::MEMBER; + //已经是会员 + if ($userType == UserTypeEnum::MEMBER) { + //是否到期 + if (!empty($userInfo['effective_time']) && strtotime($userInfo['effective_time']) > strtotime(date('Y-m-d'))) { + $time = $userInfo['effective_time']; + } + } } else { - //分销商 $up['user_type'] = UserTypeEnum::DEALER; + //已经是分销商 + if ($userType == UserTypeEnum::DEALER) { + //是否到期 + if (!empty($userInfo['effective_time']) && strtotime($userInfo['effective_time']) > strtotime(date('Y-m-d'))) { + $time = $userInfo['effective_time']; + } + } if (!User::isDealerUser($userInfo['user_id'])) { // 新增分销商用户 User::add($userInfo['user_id'], [ @@ -383,5 +393,6 @@ class PaySuccess extends BaseService } $up['effective_time'] = date("Y-m-d", strtotime("+{$orderInfo['month']} months", strtotime($time))); $userModel->where(['user_id' => $userInfo['user_id']])->save($up); + } } \ No newline at end of file diff --git a/app/common/model/article/Category.php b/app/common/model/article/Category.php index 98af9c8b..9c435bb4 100644 --- a/app/common/model/article/Category.php +++ b/app/common/model/article/Category.php @@ -59,7 +59,7 @@ class Category extends BaseModel */ public function getList(array $where = []): \think\Collection { - return $this->where($where) + return $this->where($where)->with(['catImg']) ->order(['sort', $this->getPk()]) ->select(); } diff --git a/app/common/service/server/Order.php b/app/common/service/server/Order.php index 9d5354af..09d3d19f 100644 --- a/app/common/service/server/Order.php +++ b/app/common/service/server/Order.php @@ -163,13 +163,15 @@ class Order extends BaseService * @notes:生成订单 * @param int $serverId * @param int $couponId + * @param string $server_address + * @param string $server_time * @param string $buyer_remark * @return array * @throws BaseException * @throws DbException * @author: wanghousheng */ - public function createOrder(int $serverId, int $couponId, string $buyer_remark = ''): array + public function createOrder(int $serverId, int $couponId, string $server_address, string $server_time, string $buyer_remark = ''): array { $userId = UserService::getCurrentLoginUserId(); $data = $this->onCheck($serverId, $couponId); @@ -190,6 +192,8 @@ class Order extends BaseService 'buyer_remark' => $buyer_remark, 'create_time' => time(), 'update_time' => time(), + 'server_time' => $server_time, + 'server_address' => $server_address, ]; $model = new ServerOrder(); $order_id = $model->insertGetId($order_data); diff --git a/app/store/controller/Recovery.php b/app/store/controller/Recovery.php index 893eadc7..f554edfa 100644 --- a/app/store/controller/Recovery.php +++ b/app/store/controller/Recovery.php @@ -94,13 +94,13 @@ class Recovery extends Controller $status = intval($this->request->post('status')); $where = []; if ($recovery_name) { - $where[] = ['recovery.server_name', 'like', "%$recovery_name%"]; + $where[] = ['server_recovery.server_name', 'like', "%$recovery_name%"]; } if ($category_id) { - $where[] = ['recovery.category_id', '=', $category_id]; + $where[] = ['server_recovery.category_id', '=', $category_id]; } if ($status) { - $where[] = ['recovery.status', '=', $status]; + $where[] = ['server_recovery.status', '=', $status]; } try { $list = $model->getList($where); diff --git a/app/store/controller/user/Feedback.php b/app/store/controller/user/Feedback.php new file mode 100644 index 00000000..5d948ae8 --- /dev/null +++ b/app/store/controller/user/Feedback.php @@ -0,0 +1,44 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\store\controller\user; + +use think\response\Json; +use app\store\controller\Controller; +use app\store\model\user\Feedback as FeedbackModel; + +/** + * 反馈 + * + * @package app\store\controller\user + */ +class Feedback extends Controller +{ + //获取反馈列表 + public function getFeedBack(): Json + { + $params = $this->request->param(); + $service = new FeedbackModel(); + $list = $service->getFeedback($params); + return $this->renderSuccess(compact('list')); + } + + public function replay(): Json + { + $params = $this->request->param(); + $service = new FeedbackModel(); + if ($service->replyFeedback($params)) { + return $this->renderSuccess("回复成功"); + } + return $this->renderError($service->getError() ?? "回复失败"); + } +} diff --git a/app/store/controller/user/GoodsSource.php b/app/store/controller/user/GoodsSource.php new file mode 100644 index 00000000..98fcbfd7 --- /dev/null +++ b/app/store/controller/user/GoodsSource.php @@ -0,0 +1,34 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\store\controller\user; + +use think\response\Json; +use app\store\controller\Controller; +use app\store\model\user\GoodsSource as GoodsSourceModel; + +/** + * 反馈 + * + * @package app\store\controller\user + */ +class GoodsSource extends Controller +{ + //获取列表 + public function getList(): Json + { + $params = $this->request->param(); + $service = new GoodsSourceModel(); + $list = $service->getList($params); + return $this->renderSuccess(compact('list')); + } +} diff --git a/app/store/model/user/Feedback.php b/app/store/model/user/Feedback.php new file mode 100644 index 00000000..5855d8a3 --- /dev/null +++ b/app/store/model/user/Feedback.php @@ -0,0 +1,56 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\store\model\user; + +use app\common\model\UserFeedback as UserFeedbackModel; +use cores\exception\BaseException; + +/** + * 用户余额充值服务 + * Class Recharge + * @package app\api\controller + */ +class Feedback extends UserFeedbackModel +{ + + //反馈列表 + public function getFeedback($params, $listRows = 10) + { + $query = new UserFeedbackModel(); + if (!empty($params['user_id'])) { + $query = $query->where(['user_id' => $params['user_id']]); + } + $list = $query->with(['shop']) + ->paginate($listRows)->toArray(); + foreach ($list['data'] as $k => $v) { + $list['data'][$k]['shop_name'] = !empty($v['shop']['shop_name']) ? $v['shop']['shop_name'] : ''; + unset($list['data'][$k]['shop']); + } + return $list; + } + + + public function replyFeedback(array $data) + { + $model = self::get(['id' => $data['id']]); + if($model->status == 1){ + $this->error = '请勿重复回复'; + return false; + } + return $model->save([ + 'replay' => $data['content'], + 'status' => 1, + 'replay_at' => time(), + ]); + } +} \ No newline at end of file diff --git a/app/store/model/user/GoodsSource.php b/app/store/model/user/GoodsSource.php new file mode 100644 index 00000000..460d60e2 --- /dev/null +++ b/app/store/model/user/GoodsSource.php @@ -0,0 +1,49 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\store\model\user; + +use app\common\model\user\GoodSource as GoodSourceModel; +use app\store\model\UploadFile; +use cores\exception\BaseException; + +/** + * 用户余额充值服务 + * Class Recharge + * @package app\api\controller + */ +class GoodsSource extends GoodSourceModel +{ + + //反馈列表 + public function getList($params, $listRows = 10) + { + $query = new GoodSourceModel(); + if (!empty($params['user_id'])) { + $query = $query->where(['user_id' => $params['user_id']]); + } + $list = $query->paginate($listRows)->toArray(); + foreach ($list['data'] as $k => $v) { + $img_data = []; + if(!empty($v['imgage_ids'])){ + $img_ids = json_decode($v['imgage_ids']); + $img = UploadFile::whereIn('file_id',$img_ids)->select()->toArray(); + foreach($img as $ik => $iv){ + $img_data[] = $iv['preview_url']; + } + } + $list['data'][$k]['imgs'] = $img_data; + } + return $list; + } + +} \ No newline at end of file