123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- /**
- * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
- * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
- * @author pillar<ltmn@qq.com>
- * 同城号
- */
- namespace app\citys\controller;
- use app\citys\controller\Common;
- use app\citys\model\CitysOrder;
- use think\facade\Request;
- use think\helper\Time;
- class Order extends Common{
- public function initialize() {
- parent::initialize();
- $this->assign('pathMaps',[['name'=>'订单管理','url'=>url("citys/order/index")]]);
- }
- /**
- * 列表
- */
- public function index(int $infoid = 0,int $types = 1){
- $condition = [];
- $condition[] = ['member_miniapp_id','=',$this->member_miniapp_id];
- $condition[] = ['is_del', '=',0];
- $view['keyword'] = Request::param('keyword/s');
- if($view['keyword'] ){
- $condition[] = ['phone','<=', $view['keyword']];
- }
- $view['starttime'] = Request::param('starttime/s');
- $view['endtime'] = Request::param('endtime/s');
- $view['time'] = Request::param('time/d',0);
- if ($view['time']) {
- switch ($view['time']) {
- case 2:
- list($start, $end) = Time::yesterday();
- break;
- case 30:
- list($start, $end) = Time::month();
- break;
- case 60:
- list($start, $end) = Time::lastMonth();
- break;
- default:
- list($start, $end) = Time::today();
- break;
- }
- $condition[] = ['create_time', '>=', $start];
- $condition[] = ['create_time', '<=', $end];
- } else {
- if ($view['starttime']) {
- $condition[] = ['create_time', '>=', strtotime($view['starttime'])];
- }
- if ($view['endtime']) {
- $condition[] = ['create_time', '<=', strtotime($view['endtime'])];
- }
- }
- $view['types'] = $types;
- switch ($types) {
- case 1:
- $condition[] = ['paid_at', '=',1];
- $condition[] = ['status', '=', 0];
- break;
- case 2:
- $condition[] = ['paid_at', '=',1];
- $condition[] = ['status', '=', 1];
- break;
- default:
- $condition[] = ['paid_at', '=',0];
- break;
- }
- $view['lists'] = CitysOrder::where($condition)->order('id desc')->paginate(20, false, ['query' => ['keyword' => $view['keyword'], 'starttime' => $view['starttime'], 'endtime' => $view['endtime'], 'time' => $view['time']]]);
- $view['pay'] = CitysOrder::where($this->mini_program)->where(['paid_at' => 1])->sum('amount');
- $view['invalid'] = CitysOrder::where($this->mini_program)->where(['status' => 1])->sum('amount');
- $view['infoid'] = $infoid;
- if($infoid){
- $view['tabs'] = [
- ['name' =>'信息内容','url' =>url('citys/index/reply',['id' => $infoid])],
- ['name' =>'订单列表','url' =>url('citys/order/index',['infoid' => $infoid]),'action' => 1],
- ];
- }
- return view()->assign($view);
- }
- /**
- * 订单详情
- */
- public function detail(int $id){
- $info = CitysOrder::where(['id' => $id])->find();
- $info->field = json_decode($info->fields, true);
- $view['info'] = $info;
-
- return view()->assign($view);
- }
- /**
- * 删除
- */
- public function delete($id){
- $result = CitysOrder::update(['is_del'=>1],['id' => $id]);
- if($result){
- return enjson(200,'操作成功',['url' => url('index',['status' => $this->request->param('status/d')])]);
- }
- return enjson(0,'操作失败');
- }
- /**
- * 订单完成
- */
- public function completion($id){
- $result = CitysOrder::update(['status'=>1],['id' => $id]);
- if($result){
- return enjson(200,'操作成功',['url' => url('index',['status' => $this->request->param('status/d')])]);
- }else{
- return enjson(0,'操作失败');
- }
- }
- }
|