127 lines
4.0 KiB
PHP
Raw Normal View History

2024-09-29 15:43:18 +08:00
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\merchant\controller;
use think\admin\Controller;
use app\merchant\service\MerchantLogService;
use app\merchant\service\MerchantService;
use app\merchant\service\OrderService;
use app\channel\service\ChannelService;
use app\channel\service\ProductService;
/**
* 商户订单管理
* Class Merchant
* @package app\merchant\controller
*/
class Order extends Controller
{
/**
* 绑定数据表
* @var string
*/
public $table = 'MerchantOrder';
/**
* 订单列表
* @auth true
* @menu true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$id = input('id');
$info = MerchantService::instance()->getInfo($id);
$this->title = '【' . $info['name'] . '】订单列表';
$query = $this->_query($this->table);
$query->equal('cid,pid,mid,order_id,merchant_order_id,status')->dateBetween('create_at');
// 加载对应数据列表
$this->type = input('type', 'all');
$query->where(['mid' => $id]);
// 列表排序并显示
$query->order('create_at desc')->page();
}
/**
* 查看详细数据
* @login true
* @auth true
* @param integer $id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function info()
{
$this->_applyFormToken();
$this->verify = false;
$this->_form($this->table, 'info');
}
/**
* 表单数据处理
* @param array $data
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
protected function _form_filter(&$data)
{
}
/**
* 列表数据处理
* @param array $data
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
protected function _index_page_filter(array &$data)
{
$order = OrderService::instance();
$channel = ChannelService::instance();
$product = ProductService::instance();
$channel_list = $product_list = array();
foreach ($data as $k => $v) {
if (!isset($channel_list[$v['cid']])) {
$channel_list[$v['cid']] = $channel->getInfo($v['cid']);
}
$data[$k]['channel'] = $channel_list[$v['cid']];
if (!isset($product_list[$v['pid']])) {
$product_list[$v['pid']] = $product->getInfo($v['pid']);
}
$data[$k]['product'] = $product_list[$v['pid']];
if ($v['status'] == 1) {
$data[$k]['status_name'] = '进行中';
} elseif ($v['status'] == 2) {
$data[$k]['status_name'] = '已完成';
} elseif ($v['status'] == 3) {
$data[$k]['status_name'] = '失败';
} elseif ($v['status'] == 4) {
$data[$k]['status_name'] = '处理中';
} elseif ($v['status'] == 5) {
$data[$k]['status_name'] = '存疑';
}
}
}
}