123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?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\allwin\controller;
- use think\facade\Request;
- use think\helper\Time;
- use app\allwin\model\AllwinShopOrder;
- class ShopOrder extends Common{
- public function initialize() {
- parent::initialize();
- $this->assign('pathMaps',[['name'=>'订单管理','url'=>url("allwin/shopOrder/index")]]);
- }
- /**
- * 列表
- */
- public function index(int $types = 1){
- $condition = [];
- $condition[] = ['AllwinShopOrder.member_miniapp_id','=',$this->member_miniapp_id];
- $condition[] = ['AllwinShopOrder.is_del', '=',0];
- $time = Request::param('time/d',0);
- $starttime = Request::param('starttime/s');
- $endtime = Request::param('endtime/s');
- if ($time) {
- switch ($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 ($starttime) {
- $condition[] = ['create_time', '>=', strtotime($starttime)];
- }
- if ($endtime) {
- $condition[] = ['create_time', '<=', strtotime($endtime)];
- }
- }
- 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;
- }
- $keyword = Request::param('keyword/s');
- $lists = AllwinShopOrder::hasWhere('shop', function($query) use($keyword) {
- if($keyword){
- $query->where('phone|name', 'like', '%'.$keyword.'%', 'or');
- }
- })->where($condition)->order('id desc')->paginate(20, false, ['query' => ['keyword' => $keyword, 'starttime' => $starttime, 'endtime' => $endtime, 'time' => $time]]);
- $view['pay'] = AllwinShopOrder::where($this->mini_program)->where(['paid_at' => 1])->sum('amount');
- $view['invalid'] = AllwinShopOrder::where($this->mini_program)->where(['status' => 1])->sum('amount');
- $view['lists'] = $lists;
- $view['types'] = $types;
- $view['keyword'] = $keyword;
- $view['time'] = $time;
- $view['starttime'] = $starttime;
- $view['endtime'] = $endtime;
- return view()->assign($view);
- }
-
- /**
- * 订单详情
- */
- public function detail(int $id){
- $view['info'] = AllwinShopOrder::where(['id' => $id])->find();
- return view()->assign($view);
- }
- /**
- * 删除
- */
- public function delete($id){
- $result = AllwinShopOrder::update(['is_del'=>1],['id' => $id]);
- if($result){
- return enjson(200,'操作成功',['url' => url('allwin/shopOrder/index',['status' => $this->request->param('status/d')])]);
- }
- return enjson(0,'操作失败');
- }
- /**
- * 订单完成
- */
- public function force_completion($id){
- $result = AllwinShopOrder::update(['status'=>1],['id' => $id]);
- if($result){
- return enjson(200,'操作成功',['url' => url('allwin/shopOrder/index',['status' => $this->request->param('status/d')])]);
- }else{
- return enjson(0,'操作失败');
- }
- }
- }
|