2024-02-05 10:08:57 +08:00

67 lines
2.0 KiB
PHP

<?php
namespace app\controller\api\server;
use app\common\model\system\merchant\FinancialRecord;
use app\controller\api\Common;
use crmeb\basic\BaseController;
use think\App;
use think\db\Query;
class Store extends BaseController
{
protected $merId;
public function __construct(App $app)
{
parent::__construct($app);
$this->merId = $this->request->route('merId');
}
/**
* 生成二维码
*/
public function qrcode()
{
$common = app()->make(Common::class);
$siteUrl = systemConfig('site_url');
$data = $common->Qrcode(['code' => $siteUrl . 'download/index.html?code=mer_' . $this->merId, 'id' => $this->merId]);
return app('json')->success(['url' => $data]);
}
/**
* 邀请记录
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function record()
{
[$page, $limit] = $this->getPage();
$query = FinancialRecord::field('order_sn,number')
->where('mer_id', $this->merId)
->where('financial_type', 'commission_to_promoter')
->with(['orderInfo' => function (Query $query) {
$query->field('pay_price,real_name,uid,order_sn')->with(['user' => function (Query $query) {
$query->field('nickname,uid');
}]);
}]);
$count = $query->count();
$result = $query->page($page, $limit)->select()->toArray();
$list = [];
foreach ($result as $item) {
$list[] = [
'nickname' => $item['orderInfo']['user']['nickname'],
'uid' => $item['orderInfo']['uid'],
'order_amount' => $item['orderInfo']['pay_price'],
'commission' => $item['number'],
];
}
return app('json')->success(['count' => $count, 'list' => $list]);
}
}