From dfec5819aacbe98c17ccde6ea76f8c427ae52d43 Mon Sep 17 00:00:00 2001 From: gitfjn <2860488097@qq.com> Date: Wed, 14 Jan 2026 18:05:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=AA=E4=BA=BA=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E5=8A=9F=E8=83=BD=20=E6=B7=BB=E5=8A=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/view/order/lists.html | 70 +++++++++++++--- .../{AfterSale.php => Aftersale.php} | 9 ++- application/api/controller/File.php | 11 +++ application/api/controller/Sale.php | 80 +++++++++++++++++++ application/api/controller/Staffgoods.php | 33 +++++--- application/api/logic/AfterSaleLogic.php | 4 +- application/api/logic/OrderLogic.php | 77 +++++++++++++----- application/api/model/Order.php | 7 ++ 8 files changed, 249 insertions(+), 42 deletions(-) rename application/api/controller/{AfterSale.php => Aftersale.php} (95%) create mode 100644 application/api/controller/Sale.php diff --git a/application/admin/view/order/lists.html b/application/admin/view/order/lists.html index 0bedb310..7fd40c38 100644 --- a/application/admin/view/order/lists.html +++ b/application/admin/view/order/lists.html @@ -73,6 +73,13 @@ height: 62px; margin-bottom: 5px; } + /* 退款状态标红样式 */ + .refund-status-row { + background-color: #ffebee !important; + } + .refund-status-row:hover { + background-color: #ffcdd2 !important; + }
@@ -356,18 +363,46 @@

订单编号:{{d.order_sn}}

下单时间:{{d.create_time}}

-

订单来源:{{d.channel}}

-

收款方式:{{d.gord_name}}

+

订单来源: + {{# if(d.channel){ }} + {{d.channel}} + {{# } else { }} + 小程序 + {{# } }} +

+

支付方式: + {{# if(d.pay_way == 1){ }} + 微信支付 + {{# } }} + {{# if(d.pay_way == 2){ }} + 支付宝支付 + {{# } }} + {{# if(d.pay_way == 3){ }} + 余额支付 + {{# } }} + {{# if(!d.pay_way || (d.pay_way != 1 && d.pay_way != 2 && d.pay_way != 3)){ }} + - + {{# } }} +

- - {{# if(d.pay_zd == 0){ }} -

支付状态: - 已收款 + {{# if(d.pay_status == 0){ }} +

订单状态: + 待支付

{{# } }} - {{# if(d.pay_zd == 1){ }} -

支付状态: - 未收账款 + {{# if(d.pay_status == 1){ }} +

订单状态: + 已支付 +

+ {{# } }} + {{# if(d.pay_status == 2){ }} +

订单状态: + 已退款 +

+ {{# } }} + {{# if(d.pay_status == 3){ }} +

订单状态: + 拒绝退款

{{# } }}
@@ -600,6 +635,23 @@ $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height()); $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height()); }); + + // 如果 refund_status > 0,整行标红显示 + if (res && res.data && res.data.length > 0) { + res.data.forEach(function(item, index) { + if (item.refund_status && parseInt(item.refund_status) > 0) { + // 给主表格行添加红色背景 + var $mainRow = $(".layui-table-main tbody tr").eq(index); + $mainRow.addClass('refund-status-row'); + + // 给固定列的行也添加红色背景 + var $fixedLeftRow = $(".layui-table-fixed-l .layui-table-body tbody tr").eq(index); + var $fixedRightRow = $(".layui-table-fixed-r .layui-table-body tbody tr").eq(index); + $fixedLeftRow.addClass('refund-status-row'); + $fixedRightRow.addClass('refund-status-row'); + } + }); + } } }); } diff --git a/application/api/controller/AfterSale.php b/application/api/controller/Aftersale.php similarity index 95% rename from application/api/controller/AfterSale.php rename to application/api/controller/Aftersale.php index d65431cb..22fade27 100644 --- a/application/api/controller/AfterSale.php +++ b/application/api/controller/Aftersale.php @@ -26,7 +26,7 @@ use app\api\logic\AfterSaleLogic; * Class Order * @package app\api\controller */ -class AfterSale extends ApiBase +class Aftersale extends ApiBase { public function lists() { @@ -107,7 +107,10 @@ class AfterSale extends ApiBase $this->_error('订单已完成,无法申请退款'); } $ref=Db::name('order')->where('id',$post['id'])->update(['refund_status'=>2]); - - $this->_success('申请成功'); + if ($ref){ + $this->_success('申请成功'); + }else{ + $this->_error('申请失败'); + } } } \ No newline at end of file diff --git a/application/api/controller/File.php b/application/api/controller/File.php index 619070b6..44538696 100644 --- a/application/api/controller/File.php +++ b/application/api/controller/File.php @@ -44,4 +44,15 @@ class File extends ApiBase $data = FileServer::userFormImage($this->user_id); $this->_success($data['msg'], $data['data'], $data['code']); } + + /** + * 视频上传 + * @param string $file + * @return \think\response\Json + */ + public function videoUpload($file = '') + { + $result = FileServer::video(); + $this->_success('上传成功', $result); + } } \ No newline at end of file diff --git a/application/api/controller/Sale.php b/application/api/controller/Sale.php new file mode 100644 index 00000000..53a9ff40 --- /dev/null +++ b/application/api/controller/Sale.php @@ -0,0 +1,80 @@ +request->post(); + if ($post['sub_id'] == null){ + $this->_error('请选择售后订单'); + } + if ($post['content'] == null){ + $this->_error('请填写售后问题'); + } + //查询是否存在该订单 + $userid = $this->user_id; + $orderInfo = Db::name('order_exe')->find($post['sub_id']); + if ($orderInfo == null){ + $this->_error('订单不存在'); + } + if ($orderInfo['sale_state'] == 1){ + $this->_error('该订单已投诉'); + } + if ($post['mobile'] != null){ + $phone = $post['mobile']; + }else{ + $phone = $orderInfo['phone']; + } + if ($post['images'] != null){ + $post['images'] = is_array($post['images']) ? implode(',', $post['images']) : $post['images']; + } + if ($post['videos'] != null){ + $post['videos'] = is_array($post['videos']) ? implode(',', $post['videos']) : $post['videos']; + } + $data = [ + 'user_id' => $userid, + 'name' => $orderInfo['name'], + 'phone' => $phone, + 'type' => $post['type'], + 'goods_images' => $post['images'], + 'video' => $post['videos'], + 'problem' => $post['content'], + 'autotime' => time(), + 'staff_id' => $orderInfo['staff_id'], + 'status' => 0, + 'adjust' => "", + 'order_id' => $post['sub_id'], + 'punish' => 0, + 'time' => time() + ]; + Db::startTrans(); + try{ + //创建投诉记录 + Db::name('order_sale')->insert($data); + //修改子订单投诉状态 + Db::name('order_exe')->where('id',$post['sub_id'])->update(['sale_state' => 1]); + Db::commit(); + }catch (\Exception $e){ + Db::rollback(); + $this->_error('提交失败'); + } + $this->_success('提交成功'); + } + + + //投诉列表 + public function complaintList() + { + $userid = $this->user_id; + $list = Db::name('order_sale') + ->where('') + ->where('user_id',$userid) + ->paginate(10); + $this->_success('成功',$list); + } +} \ No newline at end of file diff --git a/application/api/controller/Staffgoods.php b/application/api/controller/Staffgoods.php index c81cd22b..48e98150 100644 --- a/application/api/controller/Staffgoods.php +++ b/application/api/controller/Staffgoods.php @@ -365,6 +365,9 @@ class Staffgoods extends ApiBase $this->_error('订单不存在'); } $user=Db::name('order')->where('order_sn',$order['order_sn'])->find(); //获取主订单信息 + if ($user == null){ + $this->_error('订单不存在'); + } $data=[ 'name'=> $user['consignee'], 'phone'=> $user['mobile'], @@ -372,19 +375,29 @@ class Staffgoods extends ApiBase 'order_id'=>$get['order_id'], 'staff_id'=>$order['staff_id'], 'score'=>$get['score'], - 'eceives'=>$get['infoReceives'], - 'eceivesd'=>$get['infoReceivesd'], - 'content'=>$get['textareaValue'], + 'eceives'=>$get['service_attitude'], + 'eceivesd'=>$get['service_quality'], + 'content'=>$get['comment'], 'create_time'=>time() ]; - $where=Db::name('orderexe_evaluate')->where('order_id',$get['order_id'])->find(); - if($where){ - $this->_success('已经提交评价'); - }else{ - $inser=Db::name('orderexe_evaluate')->data($data)->insert(); - $this->_success('评价内容提交成功'); + $pljl = Db::name('orderexe_evaluate')->where('order_id',$get['order_id'])->find(); + if ($pljl){ + $this->_success('请勿重复评价'); } - + Db::startTrans(); + try { + //添加评论记录 + Db::name('orderexe_evaluate')->data($data)->insert(); + //修改子订单评论状态 + Db::name('order_exe')->where('id',$get['order_id'])->update(['orderpl'=>1]); + // 提交事务 + Db::commit(); + }catch (\Exception $exception){ + // 回滚事务 + Db::rollback(); + $this->_error('评价失败'); + } + $this->_success('评价成功'); } //员工的工资单 diff --git a/application/api/logic/AfterSaleLogic.php b/application/api/logic/AfterSaleLogic.php index 862ba7e5..241e4d51 100644 --- a/application/api/logic/AfterSaleLogic.php +++ b/application/api/logic/AfterSaleLogic.php @@ -374,7 +374,7 @@ class AfterSaleLogic extends LogicBase // Db::startTrans(); // try { /// $id = $post['id']; - // $after_sale = AfterSale::get($id); //获取订单的基本信息 + // $after_sale = Aftersale::get($id); //获取订单的基本信息 /// $refund_status= Db::name('order')->where('id',$id)->update(['refund_status'=>2]); /// dump($refund_status); // if($refund_status){ @@ -386,7 +386,7 @@ class AfterSaleLogic extends LogicBase // $after_sale->refund_reason = trim($post['reason']); // $after_sale->refund_remark = isset($post['remark']) ? trim($post['remark']) : ''; // $after_sale->refund_image = isset($post['img']) ? $post['img'] : ''; - // $after_sale->status = AfterSale::STATUS_APPLY_REFUND; + // $after_sale->status = Aftersale::STATUS_APPLY_REFUND; // $after_sale->save(); // //2,更改订单商品,退款状态为申请退款 diff --git a/application/api/logic/OrderLogic.php b/application/api/logic/OrderLogic.php index 81921abd..00e2fe0f 100644 --- a/application/api/logic/OrderLogic.php +++ b/application/api/logic/OrderLogic.php @@ -957,29 +957,70 @@ class OrderLogic extends LogicBase case 'pay': $where[] = ['pay_status', '=', CommonOrder::STATUS_WAIT_PAY]; break; + case 'stop': + $where[] = ['pay_status', '=', 1]; + $where[] = ['status', '=', 1]; + break; case 'delivery': - $where[] = ['pay_status', '=', 0]; + $where[] = ['pay_status', '=', 1]; break; case 'finish': - $where[] = ['order_status', '=',1]; + $where[] = ['pay_status', '=', 1]; + $where[] = ['order_status', '=', 3]; break; case 'close': $where[] = ['order_status', '=', 4]; break; } - $user=Db::name('user')->where('id',$user_id)->find(); - $count = $order->where(['del' => 0, 'user_id' => $user['mobile']]) - ->where($where) - ->count(); +// $user=Db::name('user')->where('id',$user_id)->find(); + if ($type=='reserving'){ + $where[] = ['pay_status', '=', 1]; + //查询待预约订单 + $count = $order->where(['del' => 0, 'user_id' => $user_id]) + ->with('OrderExe') + ->where($where) + ->count(); - $lists = $order->where(['del' => 0, 'mobile' => $user['mobile']]) - ->where($where) - // ->with(['orderGoods']) - ->field('id,order_sn,order_status,pay_status,order_amount,order_status,order_type,shipping_status,create_time,number,goods_id,code') - ->page($page, $size) - ->order('id desc') - ->select(); + $lists = $order->where(['del' => 0, 'user_id' => $user_id]) + ->where($where) + ->with('OrderExe') + ->field('id,order_sn,order_status,pay_status,order_amount,order_status,order_type,shipping_status,refund_status,create_time,number,goods_id,code') + ->page($page, $size) + ->order('id desc') + ->select(); + }else if($type == 'inservice'){ + //服务中 + $where[] = ['pay_status', '=', 1]; + $count = $order->where(['del' => 0, 'user_id' => $user_id]) + ->with(['OrderExe' => function ($query) { + $query->where('timeout', '<>', 'null'); + }]) + ->where($where) + ->count(); + + $lists = $order->where(['del' => 0, 'user_id' => $user_id]) + ->where($where) + ->with(['OrderExe' => function ($query) { + $query->where('timeout', '<>', 'null'); + }]) + ->field('id,order_sn,order_status,pay_status,order_amount,order_status,order_type,shipping_status,refund_status,create_time,number,goods_id,code') + ->page($page, $size) + ->order('id desc') + ->select(); + }else{ + $count = $order->where(['del' => 0, 'user_id' => $user_id]) + ->where($where) + ->count(); + + $lists = $order->where(['del' => 0, 'user_id' => $user_id]) + ->where($where) + // ->with(['orderGoods']) + ->field('id,order_sn,order_status,pay_status,order_amount,order_status,order_type,shipping_status,refund_status,create_time,number,goods_id,code') + ->page($page, $size) + ->order('id desc') + ->select(); + } foreach ($lists as $list){ $goods=Db::name('goods')->where('id',$list['goods_id'])->find(); $list['image']=UrlServer::getFileUrl($goods['image']); @@ -1329,17 +1370,18 @@ class OrderLogic extends LogicBase $order = new Orderexe(); $where[] = ['order_sn', '=',$order_sn]; switch ($type) { - case 'pay': + case 'wait': + //待服务 $where[] = ['staff_status', '=',0]; break; case 'delivery': $where[] = ['staff_status', '=',1]; break; - case 'finish': + case 'service': $where[] = ['staff_status', '=',2]; break; - case 'close': - $where[] = ['staff_status', '=',4]; + case 'finish': + $where[] = ['staff_status', '=',3]; break; } @@ -1372,7 +1414,6 @@ class OrderLogic extends LogicBase } - $data = [ 'list' => $lists, 'page' => $page, diff --git a/application/api/model/Order.php b/application/api/model/Order.php index 9bf5f272..959719f5 100644 --- a/application/api/model/Order.php +++ b/application/api/model/Order.php @@ -25,6 +25,7 @@ use app\common\server\ConfigServer; use think\Db; use think\Model; use app\common\model\Order as CommonOrder; +use think\model\relation\HasOne; class Order extends Model { @@ -38,6 +39,12 @@ class Order extends Model return date('Y-m-d H:i:s', $value); } + //查询预约订单列表 + public function OrderExe(): HasOne + { + return $this->hasOne(Orderexe::class, 'order_sn', 'order_sn'); + } + /* * 付款时间 */