添加个人中心功能
添加订单记录
This commit is contained in:
80
application/api/controller/Sale.php
Normal file
80
application/api/controller/Sale.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user