This commit is contained in:
luofei 2024-03-13 14:06:27 +08:00
commit e75e8f32b3
4 changed files with 55 additions and 1 deletions

View File

@ -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');
}
} }

View File

@ -192,7 +192,8 @@ class MerchantIntentionRepository extends BaseRepository
} }
$data['mer_id'] = $merchant->mer_id; $data['mer_id'] = $merchant->mer_id;
$data['uid'] = $intention['uid']; $data['uid'] = $intention['uid'];
$data['reg_admin_id'] = $autoCreate ? 0: $merchant['merchant_admin']['merchant_admin_id']; // $data['reg_admin_id'] = $autoCreate ? 0: $merchant['merchant_admin']['merchant_admin_id'];
$data['reg_admin_id'] = $autoCreate ? 0: $merchant->reg_admin_id;
//写入商户客服表 //写入商户客服表
$store_service_data['mer_id'] = $merchant->mer_id; $store_service_data['mer_id'] = $merchant->mer_id;
$store_service_data['uid'] = $intention['uid']; $store_service_data['uid'] = $intention['uid'];

View File

@ -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();

View File

@ -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');