添加个人中心功能

添加订单记录
This commit is contained in:
2026-01-14 18:05:59 +08:00
parent e658c2a0fd
commit dfec5819aa
8 changed files with 249 additions and 42 deletions

View File

@@ -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('申请失败');
}
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace app\api\controller;
use think\Db;
class Sale extends ApiBase
{
//添加投诉内容
public function addComplaint()
{
$post = $this->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);
}
}

View File

@@ -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('评价成功');
}
//员工的工资单