123 lines
3.5 KiB
PHP
123 lines
3.5 KiB
PHP
<?php
|
||
|
||
// +----------------------------------------------------------------------
|
||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||
// +----------------------------------------------------------------------
|
||
// | Author: CRMEB Team <admin@crmeb.com>
|
||
// +----------------------------------------------------------------------
|
||
|
||
|
||
namespace app\controller\admin\store\order;
|
||
|
||
|
||
|
||
use crmeb\basic\BaseController;
|
||
|
||
use app\common\repositories\store\order\StoreOrderRepository;
|
||
use think\facade\Db;
|
||
use think\App;
|
||
use app\common\dao\store\order\StoreOrderDao;
|
||
|
||
/**代发订单
|
||
* Class StoreOrder
|
||
* @package app\controller\api\store\order
|
||
* @author xaboy
|
||
* @day 2020/6/10
|
||
*/
|
||
class StoreOrderBehalf extends BaseController
|
||
{
|
||
/**
|
||
* @var StoreOrderRepository
|
||
*/
|
||
protected $repository;
|
||
protected $dao;
|
||
|
||
/**
|
||
* StoreOrder constructor.
|
||
* @param App $app
|
||
* @param StoreOrderRepository $repository
|
||
*/
|
||
public function __construct(App $app, StoreOrderRepository $repository,StoreOrderDao $dao)
|
||
{
|
||
parent::__construct($app);
|
||
$this->repository = $repository;
|
||
$this->dao = $dao;
|
||
}
|
||
/**
|
||
* @return mixed
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author xaboy
|
||
* @day 2020/6/10
|
||
*/
|
||
public function lst()
|
||
{
|
||
[$page, $limit] = $this->getPage();
|
||
$status = $this->request->param('status','all');
|
||
$mer_id = $this->request->merId();
|
||
if ($mer_id) {
|
||
if($status=='all'){
|
||
$where['status']=['>=',0];
|
||
}else{
|
||
$where['status']=['=',$status];
|
||
}
|
||
$column = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where($where)->page($page)->limit($limit)->column('order_id');
|
||
if ($column) {
|
||
$where['order_id'] = $column;
|
||
|
||
}
|
||
if ($status == 0) {
|
||
$where['status'] = 2;
|
||
} elseif ($status == 1) {
|
||
$where['status'] = 3;
|
||
}
|
||
$where['source']=103;
|
||
return app('json')->success($this->repository->getList($where,1, $limit));
|
||
|
||
}
|
||
return app('json')->success([]);
|
||
}
|
||
|
||
/**
|
||
* @param $id
|
||
* @return mixed
|
||
* @author xaboy
|
||
* @day 2020/6/10
|
||
*/
|
||
public function detail($id)
|
||
{
|
||
$order = $this->repository->getDetail((int)$id);
|
||
if (!$order)
|
||
return app('json')->fail('订单不存在');
|
||
if ($order->order_type == 1) {
|
||
$order->append(['take', 'refund_status']);
|
||
}
|
||
return app('json')->success($order->toArray());
|
||
}
|
||
|
||
/**代发订单统计
|
||
* @return mixed
|
||
* @author xaboy
|
||
* @day 2020/6/10
|
||
*/
|
||
public function number()
|
||
{
|
||
$mer_id=$this->request->merId();
|
||
if ($mer_id) {
|
||
$noPostage = Db::name('store_order_behalf')
|
||
->where('mer_id', $mer_id)->where('status',0)
|
||
->count();
|
||
$noDeliver = Db::name('store_order_behalf')
|
||
->where('mer_id', $mer_id)->where('status',1)
|
||
->count();
|
||
|
||
}
|
||
return app('json')->success(compact('noDeliver', 'noPostage',));
|
||
}
|
||
}
|