添加用户邀请商户记录

This commit is contained in:
luofei 2024-02-20 16:56:20 +08:00
parent db1c05543e
commit 6d6eccb016
2 changed files with 42 additions and 1 deletions

View File

@ -14,7 +14,11 @@
namespace app\controller\api\user;
use app\common\dao\store\order\StoreOrderDao;
use app\common\model\store\order\StoreOrderOther;
use app\common\model\system\merchant\Merchant;
use app\common\repositories\store\IntegralRepository;
use app\common\repositories\store\order\PresellOrderRepository;
use app\common\repositories\store\service\StoreServiceRepository;
use app\common\repositories\system\CacheRepository;
use app\common\repositories\user\MemberinterestsRepository;
@ -31,6 +35,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use app\controller\api\Common;
use app\common\model\user\User as UserModel;
class User extends BaseController
{
@ -545,4 +550,39 @@ class User extends BaseController
$data=$common->Qrcode(['code'=>$siteUrl.'download/index.html?code=shop_'.$this->user->uid,'id'=>$this->user->uid]);
return app('json')->success(['url'=>$data]);
}
/**
* 邀请的商户记录
* @return mixed
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function merchantRecord()
{
[$page, $limit] = $this->getPage();
$userIds = UserModel::where('spread_uid', $this->user->uid)->column('uid');
$query = Merchant::whereIn('uid', $userIds)
->where('status', 1)
->where('is_del', 0)
->where('mer_state', 1);
$count = $query->count();
$result = $query->page($page, $limit)
->field('mer_id,mer_name,uid,real_name')
->select()->toArray();
$dao = new StoreOrderDao();
/** @var PresellOrderRepository $preSellDao */
$preSellRepo = app()->make(PresellOrderRepository::class);
foreach ($result as &$item) {
$saleOrderQuery = $dao->search(['mer_id' => $item['mer_id']])->whereIn('StoreOrder.status', [0, 1, 2, 3, 9, 10])->where('paid', 1);
$saleOrderIds = $saleOrderQuery->column('order_id');
$saleAmount1 = $saleOrderQuery->sum('StoreOrder.pay_price');
$saleAmount2 = $preSellRepo->search(['paid' => 1, 'order_ids' => $saleOrderIds])->sum('pay_price');
$item['sale_amount'] = bcadd($saleAmount1, $saleAmount2, 2);
$item['buy_amount'] = StoreOrderOther::where('uid', $item['uid'])->whereIn('status', [0, 1, 2, 3, 9, 10])->where('paid', 1)->sum('pay_price');
$item['buy_amount'] = bcadd($item['buy_amount'], 0, 2);
}
return app('json')->success(['count' => $count, 'list' => $result]);
}
}

View File

@ -46,8 +46,9 @@ Route::group('api/', function () {
Route::post('articleCatch', 'api.Upload/article');
//强制登录
Route::group(function () {
Route::any('qrcode', 'api.user.User/qrcode');
Route::get('merchantRecord', 'api.user.User/merchantRecord');
Route::post('merchant_license_identify', 'api.Common/merchant_license_identify');//营业执照识别