194 行
5.3 KiB
PHP
194 行
5.3 KiB
PHP
<?php
|
|
|
|
namespace addons\shopro\controller;
|
|
|
|
|
|
use app\common\model\ReportModel;
|
|
|
|
class Order extends Base
|
|
{
|
|
protected $noNeedLogin = [];
|
|
protected $noNeedRight = ['*'];
|
|
|
|
public function index()
|
|
{
|
|
$params = $this->request->get();
|
|
|
|
$this->success('订单列表', \addons\shopro\model\Order::getList($params));
|
|
}
|
|
|
|
public function reportList()
|
|
{
|
|
$this->error('报修功能已关闭');
|
|
$page = $this->request->get('page/d', 1);
|
|
$status = $this->request->get('status/d', 0);
|
|
$keyword = $this->request->get('keyword', '');
|
|
$model = new ReportModel();
|
|
$result = $model->getLists([
|
|
'search' => [
|
|
'user_id' => $this->auth->id,
|
|
'status' => $status,
|
|
'content' => $keyword
|
|
],
|
|
], 10, $page);
|
|
|
|
foreach ($result['list'] as &$item) {
|
|
$item['create_time'] = date('Y-m-d H:i', $item['create_time']);
|
|
}
|
|
|
|
$this->success('获取成功', [
|
|
'total' => $result['total'],
|
|
'pageSize' => $result['pageSize'],
|
|
'totalSize' => $result['totalSize'],
|
|
'list' => $result['list'],
|
|
]);
|
|
}
|
|
|
|
public function report()
|
|
{
|
|
$this->error('报修功能已关闭');
|
|
$data = $this->request->post();
|
|
|
|
if (empty($data['name'])) {
|
|
$this->error('请您输入姓名');
|
|
}
|
|
if (empty($data['phone'])) {
|
|
$this->error('请您输入手机号码');
|
|
}
|
|
if (!preg_match('/^1[3-9]\d{9}$/', $data['phone'])) {
|
|
$this->error('请您输入的正确手机号码');
|
|
}
|
|
if (empty($data['address'])) {
|
|
$this->error('请您输入地址');
|
|
}
|
|
if (empty($data['content'])) {
|
|
$this->error('请您输入报修描述');
|
|
}
|
|
|
|
$model = new ReportModel();
|
|
$id = $model->insertGetId([
|
|
'user_id' => $this->auth->id,
|
|
'order_id' => $data['order_id'],
|
|
'item_id' => $data['item_id'],
|
|
'order_sn' => $data['order_sn'],
|
|
'name' => $data['name'],
|
|
'phone' => $data['phone'],
|
|
'address' => $data['address'],
|
|
'content' => $data['content'],
|
|
'images' => !empty($data['images']) ? implode(',', $data['images']) : '',
|
|
'create_time' => time(),
|
|
]);
|
|
|
|
if ($id) {
|
|
$this->success('报修成功');
|
|
} else {
|
|
$this->error('报修失败');
|
|
}
|
|
}
|
|
|
|
public function detail()
|
|
{
|
|
$params = $this->request->get();
|
|
$this->success('订单详情', \addons\shopro\model\Order::detail($params));
|
|
}
|
|
|
|
public function itemDetail()
|
|
{
|
|
$params = $this->request->get();
|
|
$this->success('订单商品', \addons\shopro\model\Order::itemDetail($params));
|
|
}
|
|
|
|
// 即将废弃
|
|
public function statusNum()
|
|
{
|
|
$this->success('订单数量', \addons\shopro\model\Order::statusNum());
|
|
}
|
|
|
|
// 取消订单
|
|
public function cancel()
|
|
{
|
|
$params = $this->request->post();
|
|
|
|
// 表单验证
|
|
$this->shoproValidate($params, get_class(), 'cancel');
|
|
|
|
$this->success('取消成功', \addons\shopro\model\Order::operCancel($params));
|
|
}
|
|
|
|
// 删除订单
|
|
public function delete()
|
|
{
|
|
$params = $this->request->post();
|
|
|
|
// 表单验证
|
|
$this->shoproValidate($params, get_class(), 'delete');
|
|
|
|
$this->success('删除成功', \addons\shopro\model\Order::operDelete($params));
|
|
}
|
|
|
|
// 确认收货
|
|
public function confirm()
|
|
{
|
|
$params = $this->request->post();
|
|
|
|
// 表单验证
|
|
$this->shoproValidate($params, get_class(), 'confirm');
|
|
|
|
$this->success('收货成功', \addons\shopro\model\Order::operConfirm($params));
|
|
}
|
|
|
|
public function comment()
|
|
{
|
|
$params = $this->request->post();
|
|
|
|
// 表单验证
|
|
$this->shoproValidate($params, get_class(), 'comment');
|
|
|
|
$this->success('评价成功', \addons\shopro\model\Order::operComment($params));
|
|
}
|
|
|
|
public function pre()
|
|
{
|
|
$params = $this->request->post();
|
|
|
|
// 表单验证
|
|
$this->shoproValidate($params, get_class(), 'pre');
|
|
|
|
$result = \addons\shopro\model\Order::pre($params);
|
|
|
|
if (isset($result['msg']) && $result['msg']) {
|
|
$this->error($result['msg'], $result);
|
|
} else {
|
|
$this->success('计算成功', $result);
|
|
}
|
|
}
|
|
|
|
public function createOrder()
|
|
{
|
|
$params = $this->request->post();
|
|
// 表单验证
|
|
$this->shoproValidate($params, get_class(), 'createOrder');
|
|
|
|
$order = \addons\shopro\model\Order::createOrder($params);
|
|
|
|
if ($order['create_result'] === 200) {
|
|
$this->success('订单添加成功', $order);
|
|
} else {
|
|
$this->error($order['msg'], []);
|
|
}
|
|
}
|
|
|
|
// 获取可用优惠券列表
|
|
public function coupons()
|
|
{
|
|
$params = $this->request->post();
|
|
|
|
// 表单验证
|
|
$this->shoproValidate($params, get_class(), 'coupons');
|
|
|
|
$coupons = \addons\shopro\model\Order::coupons($params);
|
|
|
|
$this->success('获取成功', $coupons);
|
|
}
|
|
}
|