|
|
<?php
|
|
|
/**
|
|
|
* Created by PhpStorm.
|
|
|
* User: wz
|
|
|
* Date: 2018/9/25
|
|
|
* Time: 11:29
|
|
|
*/
|
|
|
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
|
|
|
use cmf\controller\AdminBaseController;
|
|
|
use think\Db;
|
|
|
|
|
|
class ZjOrderController extends AdminBaseController
|
|
|
{
|
|
|
/**
|
|
|
* 订单列表
|
|
|
*/
|
|
|
public function index(){
|
|
|
$where['o.delete_time']=0;
|
|
|
$arr=[];
|
|
|
$where1=[];
|
|
|
if ($this->request->param()){
|
|
|
$arr=input('param.');
|
|
|
if (!empty($arr['uid'])){
|
|
|
$where['o.uid']=$arr['uid'];
|
|
|
}
|
|
|
if (!empty($arr['step'])){
|
|
|
$where['o.step']=$arr['step'];
|
|
|
}
|
|
|
if (!empty($arr['num'])){
|
|
|
$where['o.order_num']=$arr['num'];
|
|
|
}
|
|
|
if (!empty($arr['name'])){
|
|
|
$where['o.name']=$arr['name'];
|
|
|
}
|
|
|
if (!empty($arr['mobile'])){
|
|
|
$where['o.mobile']=$arr['mobile'];
|
|
|
}
|
|
|
if (!empty($arr['start_time'])){
|
|
|
$where['o.create_time']=['egt',strtotime($arr['start_time'])];
|
|
|
}
|
|
|
if (!empty($arr['end_time'])){
|
|
|
$where1['o.create_time']=['elt',strtotime($arr['end_time'])];
|
|
|
}
|
|
|
}
|
|
|
$all=Db::name('zj_order')->alias('o')->join('user u','o.uid=u.id','left')->where($where)->where($where1)
|
|
|
->order('create_time','desc')->field('o.*,u.user_nickname')->paginate(15);
|
|
|
$all->appends($arr);
|
|
|
$this->assign('start_time', !empty($arr['start_time']) ? $arr['start_time'] : '');
|
|
|
$this->assign('end_time', !empty($arr['end_time']) ? $arr['end_time'] : '');
|
|
|
$this->assign('uid',!empty($arr['uid'])?$arr['uid']:'');
|
|
|
$this->assign('step',!empty($arr['step'])?$arr['step']:'');
|
|
|
$this->assign('num',!empty($arr['num'])?$arr['num']:'');
|
|
|
$this->assign('name',!empty($arr['name'])?$arr['name']:'');
|
|
|
$this->assign('mobile',!empty($arr['mobile'])?$arr['mobile']:'');
|
|
|
$this->assign('page',$all->render());
|
|
|
$this->assign('all',$all->items());
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 订单详情
|
|
|
*/
|
|
|
public function detail(){
|
|
|
if ($this->request->param()){
|
|
|
$id=input('param.id');
|
|
|
$url=input('param.sta');
|
|
|
if ($url==1){
|
|
|
$url=url('index');
|
|
|
}elseif ($url==2){
|
|
|
$url=url('backlog');
|
|
|
}
|
|
|
$one=Db::name('zj_order')->alias('o')->join('user u','o.uid=u.id','left')->join('zj_kd k','o.kid=k.id','left')
|
|
|
->where('o.id',$id)->field('o.*,u.user_nickname,k.name as kname')->find();
|
|
|
$kd=Db::name('zj_kd')->select();
|
|
|
$all=Db::name('zj_order_goods')->alias('og')->join('zj_goods g','og.gid=g.id')->where('oid',$id)
|
|
|
->field('g.name,og.num')->select();
|
|
|
$this->assign('kd',$kd);
|
|
|
$this->assign('url',$url);
|
|
|
$this->assign('one',$one);
|
|
|
$this->assign('all',$all);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 订单详情修改提交
|
|
|
*/
|
|
|
public function detailPost(){
|
|
|
if ($this->request->param()){
|
|
|
$param=input('param.');
|
|
|
$edit=Db::name('zj_order')->update($param);
|
|
|
if (empty($edit)){
|
|
|
$this->error('修改失败');
|
|
|
}else{
|
|
|
$this->success('修改成功');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 待处理订单列表
|
|
|
*/
|
|
|
public function backlog(){
|
|
|
$where['o.delete_time']=0;
|
|
|
$arr=[];
|
|
|
$where1['o.step']=['in',['2','6','8']];
|
|
|
if ($this->request->param()){
|
|
|
$arr=input('param.');
|
|
|
if (!empty($arr['uid'])){
|
|
|
$where['o.uid']=$arr['uid'];
|
|
|
}
|
|
|
if (!empty($arr['step'])){
|
|
|
$where['o.step']=$arr['step'];
|
|
|
}
|
|
|
if (!empty($arr['num'])){
|
|
|
$where['o.order_num']=$arr['num'];
|
|
|
}
|
|
|
if (!empty($arr['name'])){
|
|
|
$where['o.name']=$arr['name'];
|
|
|
}
|
|
|
if (!empty($arr['mobile'])){
|
|
|
$where['o.mobile']=$arr['mobile'];
|
|
|
}
|
|
|
if (!empty($arr['start_time'])){
|
|
|
$where['o.create_time']=['egt',strtotime($arr['start_time'])];
|
|
|
}
|
|
|
if (!empty($arr['end_time'])){
|
|
|
$where1['o.create_time']=['elt',strtotime($arr['end_time'])];
|
|
|
}
|
|
|
}
|
|
|
$all=Db::name('zj_order')->alias('o')->join('user u','o.uid=u.id','left')->where($where)->where($where1)
|
|
|
->order('create_time','desc')->field('o.*,u.user_nickname')->paginate(15);
|
|
|
$all->appends($arr);
|
|
|
$this->assign('start_time', !empty($arr['start_time']) ? $arr['start_time'] : '');
|
|
|
$this->assign('end_time', !empty($arr['end_time']) ? $arr['end_time'] : '');
|
|
|
$this->assign('uid',!empty($arr['uid'])?$arr['uid']:'');
|
|
|
$this->assign('step',!empty($arr['step'])?$arr['step']:'');
|
|
|
$this->assign('num',!empty($arr['num'])?$arr['num']:'');
|
|
|
$this->assign('name',!empty($arr['name'])?$arr['name']:'');
|
|
|
$this->assign('mobile',!empty($arr['mobile'])?$arr['mobile']:'');
|
|
|
$this->assign('page',$all->render());
|
|
|
$this->assign('all',$all->items());
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
/**
|
|
|
* 订单发货
|
|
|
*/
|
|
|
public function fahuo(){
|
|
|
if ($this->request->param()){
|
|
|
$param=input('param.id');
|
|
|
//获取订单数据
|
|
|
$one=Db::name('zj_order')->alias('o')->join('user u','o.uid=u.id','left')
|
|
|
->where('o.id',$param)->field('o.*,u.user_nickname')->find();
|
|
|
//获取快递公司数据
|
|
|
$kd=Db::name('zj_kd')->select();
|
|
|
//获取订单商品
|
|
|
$all=Db::name('zj_order_goods')->alias('og')->join('zj_goods g','og.gid=g.id')->where('oid',$param)
|
|
|
->field('g.name,og.num')->select();
|
|
|
if ($one['step']>2){
|
|
|
echo "<div style='width: 100%;text-align: center;padding-top: 50px'><p style='font-size: 25px'>订单已发货</p></div>";
|
|
|
}elseif ($one['step']==1){
|
|
|
echo "<div style='width: 100%;text-align: center;padding-top: 50px'><p style='font-size: 25px'>订单未支付</p></div>";
|
|
|
}else{
|
|
|
$this->assign('kd',$kd);
|
|
|
$this->assign('one',$one);
|
|
|
$this->assign('all',$all);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 订单发货提交
|
|
|
*/
|
|
|
public function fhPost(){
|
|
|
if ($this->request->param()){
|
|
|
$param=input('param.');
|
|
|
if (empty($param['kd_num'])){
|
|
|
$this->error('快递单号不能为空');
|
|
|
}
|
|
|
$param['step']=3;
|
|
|
$edit=Db::name('zj_order')->update($param);
|
|
|
if (empty($edit)){
|
|
|
$this->error('订单状态更新失败');
|
|
|
}else{
|
|
|
$this->success('订单状态更新成功');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 订单退款审核
|
|
|
*/
|
|
|
public function check(){
|
|
|
if ($this->request->param()){
|
|
|
$param=input('param.id');
|
|
|
//获取订单数据
|
|
|
$one=Db::name('zj_order')->alias('o')->join('user u','o.uid=u.id','left')->where('o.id',$param)
|
|
|
->field('o.*,u.user_nickname')->find();
|
|
|
//获取订单商品
|
|
|
$all=Db::name('zj_order_goods')->alias('og')->join('zj_goods g','og.gid=g.id')->where('oid',$param)
|
|
|
->field('g.name,g.price,og.num')->select();
|
|
|
if ($one['step']<6){
|
|
|
echo "<div style='width: 100%;text-align: center;padding-top: 50px'><p style='font-size: 25px'>订单未退货</p></div>";
|
|
|
}elseif ($one['step']>6){
|
|
|
echo "<div style='width: 100%;text-align: center;padding-top: 50px'><p style='font-size: 25px'>退款审核通过</p></div>";
|
|
|
}else{
|
|
|
$this->assign('one',$one);
|
|
|
$this->assign('all',$all);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 订单退款审核提交
|
|
|
*/
|
|
|
public function checkPost(){
|
|
|
if ($this->request->param()){
|
|
|
$param=input('param.');
|
|
|
//判断审核是否通过
|
|
|
if (!empty($param['sta'])){
|
|
|
$param['step']=5;
|
|
|
unset($param['sta']);
|
|
|
$edit=Db::name('zj_order')->update($param);
|
|
|
}else{
|
|
|
$param['step']=7;
|
|
|
$edit=Db::name('zj_order')->update($param);
|
|
|
}
|
|
|
if (empty($edit)){
|
|
|
$this->error('订单状态更新失败');
|
|
|
}else{
|
|
|
$this->success('订单状态更新成功');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 订单退款
|
|
|
*/
|
|
|
public function refund(){
|
|
|
if ($this->request->param()){
|
|
|
$param=input('param.id');
|
|
|
//获取订单数据
|
|
|
$one=Db::name('zj_order')->alias('o')->join('user u','o.uid=u.id','left')->where('o.id',$param)
|
|
|
->field('o.*,u.user_nickname')->find();
|
|
|
//获取订单商品
|
|
|
$all=Db::name('zj_order_goods')->alias('og')->join('zj_goods g','og.gid=g.id')->where('oid',$param)
|
|
|
->field('g.name,g.price,og.num')->select();
|
|
|
if ($one['step']>8){
|
|
|
echo "<div style='width: 100%;text-align: center;padding-top: 50px'><p style='font-size: 25px'>订单已退款</p></div>";
|
|
|
}elseif ($one['step']<8){
|
|
|
echo "<div style='width: 100%;text-align: center;padding-top: 50px'><p style='font-size: 25px'>订单状态错误</p></div>";
|
|
|
}else{
|
|
|
$this->assign('one',$one);
|
|
|
$this->assign('all',$all);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 订单退款提交
|
|
|
*/
|
|
|
public function refundPost(){
|
|
|
if ($this->request->param()){
|
|
|
$param=input('param.');
|
|
|
if ($param['tui']<=0){
|
|
|
$this->error('退款金额需大于0');
|
|
|
}
|
|
|
|
|
|
$param['step']=9;
|
|
|
unset($param['tui']);//删除无用数据
|
|
|
$edit=Db::name('zj_order')->update($param);
|
|
|
if (empty($edit)){
|
|
|
$this->error('订单退款失败');
|
|
|
}else{
|
|
|
$this->success('订单退款成功');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|