商户收支查询明细
This commit is contained in:
parent
27c86f1a8d
commit
aef647d6df
@ -15,6 +15,7 @@ use app\common\dao\store\order\StoreOrderDao;
|
|||||||
use app\common\dao\system\financial\FinancialRecordDao;
|
use app\common\dao\system\financial\FinancialRecordDao;
|
||||||
use app\common\model\store\order\StoreGroupOrder;
|
use app\common\model\store\order\StoreGroupOrder;
|
||||||
use app\common\model\store\order\StoreOrder;
|
use app\common\model\store\order\StoreOrder;
|
||||||
|
use app\common\model\system\merchant\Merchant;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\repositories\BaseRepository;
|
use app\common\repositories\BaseRepository;
|
||||||
use app\common\repositories\delivery\DeliveryOrderRepository;
|
use app\common\repositories\delivery\DeliveryOrderRepository;
|
||||||
@ -2428,4 +2429,46 @@ class StoreOrderRepository extends BaseRepository
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商户收支明细
|
||||||
|
* @param array $where
|
||||||
|
* @param $page
|
||||||
|
* @param $limit
|
||||||
|
* @param $merId
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function revenueExpenditure(array $where, $page, $limit,$merId)
|
||||||
|
{
|
||||||
|
$uid = Merchant::getDB()->where(['mer_id'=>$merId,'is_del'=>0])->value('uid');
|
||||||
|
$data = StoreOrder::getDB()->alias('o')
|
||||||
|
->leftJoin('Merchant m', 'o.mer_id = m.mer_id');
|
||||||
|
if (isset($where['section_startTime']) && $where['section_startTime'] && isset($where['section_endTime']) && $where['section_endTime']) {
|
||||||
|
$data->whereTime('o.create_time', 'between', [$where['section_startTime'], $where['section_endTime']]);
|
||||||
|
}
|
||||||
|
$data->where(function ($query) use ($where,$uid,$merId) {
|
||||||
|
$query->where('o.mer_id', $merId)->whereOr('o.uid', $uid);
|
||||||
|
})->where('o.source', 999);//只要扫码
|
||||||
|
$data->field('o.order_id,o.uid,o.mer_id,o.pay_price,m.mer_name');
|
||||||
|
$list = $data->order('o.create_time DESC')->page($page, $limit)->select();
|
||||||
|
$income = 0;
|
||||||
|
$outcome = 0;
|
||||||
|
foreach ($list as &$value){
|
||||||
|
if($value['mer_id'] == $merId){
|
||||||
|
$value['msg'] = "收入";
|
||||||
|
$income +=$value['pay_price'];
|
||||||
|
}else{
|
||||||
|
$value['msg'] = "支出";
|
||||||
|
$outcome +=$value['pay_price'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return compact('income','outcome','list');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,15 @@ class StoreOrder extends BaseController
|
|||||||
return app('json')->success($list);
|
return app('json')->success($list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function expenditure($merId, StoreOrderRepository $repository)
|
||||||
|
{
|
||||||
|
[$page, $limit] = $this->getPage();
|
||||||
|
$where['section_startTime'] = $this->request->param('section_startTime');
|
||||||
|
$where['section_endTime'] = $this->request->param('section_endTime');
|
||||||
|
return app('json')->success($repository->revenueExpenditure($where, $page, $limit,$merId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function orderList($merId, StoreOrderRepository $repository)
|
public function orderList($merId, StoreOrderRepository $repository)
|
||||||
{
|
{
|
||||||
[$page, $limit] = $this->getPage();
|
[$page, $limit] = $this->getPage();
|
||||||
|
@ -290,6 +290,7 @@ Route::group('api/', function () {
|
|||||||
|
|
||||||
//管理员订单
|
//管理员订单
|
||||||
Route::group('admin/:merId', function () {
|
Route::group('admin/:merId', function () {
|
||||||
|
Route::get('/expenditure', '/expenditure');
|
||||||
Route::get('/statistics', '/orderStatistics');
|
Route::get('/statistics', '/orderStatistics');
|
||||||
Route::get('/order_price', '/orderDetail');
|
Route::get('/order_price', '/orderDetail');
|
||||||
Route::get('/order_list', '/orderList');
|
Route::get('/order_list', '/orderList');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user