用户资产补全,添加用户接口

main
fengxinyhyl 8 months ago
parent b3d1f7f4af
commit cd0365c472
  1. 14
      app/common/dao/user/UserAssetsLogDao.php
  2. 62
      app/common/repositories/user/UserAssetsLogRepository.php
  3. 34
      app/common/repositories/user/UserAssetsRepository.php
  4. 6
      app/common/repositories/user/UserRepository.php
  5. 8
      app/controller/admin/system/merchant/Merchant.php
  6. 22
      app/controller/api/Auth.php
  7. 2
      config/log.php
  8. 7
      crmeb/listens/AppEnd.php
  9. 2
      route/api.php

@ -18,6 +18,14 @@ use app\common\model\user\UserAssetsLog;
class UserAssetsLogDao extends BaseDao
{
/**
* notes
* @return UserAssetsLog
* @create 2024/3/18 15:16
* @update 2024/3/18 15:16
* @author zhangkxiang
* @editor
*/
protected function getModel(): string
{
return UserAssetsLog::class;
@ -29,4 +37,10 @@ class UserAssetsLogDao extends BaseDao
}
public function search(int $uid, array $where){
$query = UserAssetsLog::getDB()->where('uid', $uid)->where($where);
return $query;
}
}

@ -153,6 +153,39 @@ class UserAssetsLogRepository extends BaseRepository
$this->recommendAssets($orderItem['mer_id'], $orderItem['order_id'], $config, $base);
}
// 6. 商户和平台资产
// $this->merchantAndPlatformAssets($orderItem);
}
}
public function merchantAndPlatformAssets($orderItem){
/**
* @var MerchantRepository $merchantRepository
*/
$merchantRepository = app(MerchantRepository::class);
$merchant = $merchantRepository->get($orderItem['mer_id']);
if(empty($merchant)){
return;
}
/**
* @var UserRepository $userRepository
*/
$userRepository = app(UserRepository::class);
$user = $userRepository->searchOne(['phone' => $merchant['mer_phone']]);
$logList = array();
$welfare = $huitong = $contribution = 0;
if($user){
$logList[] = array(
'uid' => $user['uid'],
'asset_type' => self::ASSET_TYPE_WELFARE,
'type' => self::CHANGE_TYPE_ORDER_GET,
'status' => self::STATUS_FROZEN,
'order_id' => $orderItem['order_id'],
'count' => $welfare,
'mer_id' => $merchant['id'],
);
}
}
@ -516,6 +549,35 @@ class UserAssetsLogRepository extends BaseRepository
}
/**
* notes 获取资产变动日志
* @param $uid
* @param $where
* @param $page
* @param $limit
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @create 2024/3/18 17:37
* @update 2024/3/18 17:37
* @author zhangkxiang
* @editor
*/
public function list($uid, $where, $page, $limit){
$query = $this->dao->search($uid, $where);
$count = $query->count();
$data = $query->page($page, $limit)->select();
$list = array();
$changeType = $this->getChangeType();
foreach ($data as $item){
$item['type'] = $changeType[$item['type']];
$list[] = $item;
}
return compact('count', 'list');
}
public function userRefund()
{

@ -32,15 +32,33 @@ class UserAssetsRepository extends BaseRepository
}
public function getList(array $where, $page, $limit)
/**
* notes 获取用户资产
* @param $uid
* @return array
* @create 2024/3/18 14:48
* @update 2024/3/18 14:48
* @author zhangkxiang
* @editor
*/
public function assets($uid)
{
$query = $this->dao->search($where);
$count = $query->count();
$list = $query->page($page, $limit)->with(['spread' => function ($query) {
$query->field('uid,nickname,avatar');
}])->select();
return compact('count', 'list');
$item = $this->dao->get($uid);
if($item){
return $item->toArray();
}
return array(
'uid' => 0,
'consume' => 0.00,
'consume_frozen' => 0.00,
'share_point' => 0.00,
'welfare' => 0.00,
'welfare_frozen' => 0.00,
'huitong' => 0.00,
'huitong_frozen' => 0.00,
'contribution' => 0.00,
'contribution_frozen' => 0.00,
);
}

@ -190,6 +190,12 @@ class UserRepository extends BaseRepository
return compact('count', 'list');
}
public function searchOne($where){
$query = $this->dao->search($where);
return $query->find();
}
public function getPulbicLst(array $where, $page, $limit)
{
$query = $this->dao->search($where);

@ -17,6 +17,7 @@ namespace app\controller\admin\system\merchant;
use app\common\repositories\store\product\ProductCopyRepository;
use app\common\repositories\system\merchant\MerchantTypeRepository;
use app\common\repositories\user\UserBillRepository;
use app\common\repositories\user\UserRepository;
use crmeb\basic\BaseController;
use app\common\repositories\system\merchant\MerchantAdminRepository;
use app\common\repositories\system\merchant\MerchantCategoryRepository;
@ -99,6 +100,13 @@ class Merchant extends BaseController
{
$data = $this->checkParam($validate);
$this->repository->createMerchant($data);
$userRepository = \app()->make(UserRepository::class);
$user = $userRepository->create("pc", [
'account' => $data['mer_phone'],
'real_name' => $data['real_name'],
'phone' => $data['mer_phone'],
'pwd' => $userRepository->encodePassword(substr(md5(time() . random_int(10, 99)), 0, 8)),
]);
return app('json')->success('添加成功');
}

@ -17,6 +17,8 @@ namespace app\controller\api;
use app\common\repositories\store\order\StoreOrderRepository;
use app\common\repositories\store\order\StoreRefundOrderRepository;
use app\common\repositories\system\notice\SystemNoticeConfigRepository;
use app\common\repositories\user\UserAssetsLogRepository;
use app\common\repositories\user\UserAssetsRepository;
use app\common\repositories\user\UserRepository;
use app\common\repositories\user\UserSignRepository;
use app\common\repositories\wechat\RoutineQrcodeRepository;
@ -168,9 +170,29 @@ class Auth extends BaseController
Cache::set($key,true, new \DateTime($day.' 23:59:59'));
}
}
// 用户资产
$assets = app(UserAssetsRepository::class)->assets($data['uid']);
$data['assets'] = $assets;
return app('json')->success($data);
}
public function assetsLog(){
$user = $this->request->userInfo();
$uid = $user->uid;
$page = $this->request->param('page', 1);
$limit = $this->request->param('limit', 10);
$asset_type = $this->request->param('asset_type', 1);
$where = array();
$where[] = array('asset_type','=',$asset_type);
$where[] = array('status','in',[UserAssetsLogRepository::STATUS_FROZEN, UserAssetsLogRepository::STATUS_SUCCESS]);
return app('json')->success(app(UserAssetsLogRepository::class)->list($uid, $where, $page, $limit));
}
/**
* @param UserRepository $repository
* @return mixed

@ -48,7 +48,7 @@ return [
'format' => '[%s][%s] %s',
// 是否实时写入
'realtime_write' => true,
'file_size' => 1024 * 10,
'file_size' => 1024 * 1024,
],
'sql' => [
// 日志记录方式

@ -17,6 +17,11 @@ class AppEnd
public function handle($response)
{
$params = Request::param();
Log::info(Request::url(). ' params: ' . json_encode($params));
$response = $response->getData();
if(is_array($response) or strpos($response, '<!DOCTYPE html>') === false) {
Log::info(Request::url(). ' params: ' . json_encode($params) ." response: " . json_encode($response));
}else{
Log::info(Request::url(). ' params: ' . json_encode($params));
}
}
}

@ -35,6 +35,8 @@ Route::group('api/', function () {
Route::post('logout', 'api.Auth/logout');
//用户信息
Route::get('user', 'api.Auth/userInfo');
//用户资产明细
Route::get('user/assetsLog', 'api.Auth/assetsLog');
//绑定推荐人
Route::post('user/spread', 'api.Auth/spread');

Loading…
Cancel
Save