diff --git a/app/common/dao/user/UserAssetsLogDao.php b/app/common/dao/user/UserAssetsLogDao.php index 297f6dd..9a3aa6e 100644 --- a/app/common/dao/user/UserAssetsLogDao.php +++ b/app/common/dao/user/UserAssetsLogDao.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; + } + + } diff --git a/app/common/repositories/user/UserAssetsLogRepository.php b/app/common/repositories/user/UserAssetsLogRepository.php index 780e5ee..0d21db0 100644 --- a/app/common/repositories/user/UserAssetsLogRepository.php +++ b/app/common/repositories/user/UserAssetsLogRepository.php @@ -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() { diff --git a/app/common/repositories/user/UserAssetsRepository.php b/app/common/repositories/user/UserAssetsRepository.php index 506baac..bb4b58c 100644 --- a/app/common/repositories/user/UserAssetsRepository.php +++ b/app/common/repositories/user/UserAssetsRepository.php @@ -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, + ); } diff --git a/app/common/repositories/user/UserRepository.php b/app/common/repositories/user/UserRepository.php index 745a1e2..6cb655c 100644 --- a/app/common/repositories/user/UserRepository.php +++ b/app/common/repositories/user/UserRepository.php @@ -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); diff --git a/app/controller/admin/system/merchant/Merchant.php b/app/controller/admin/system/merchant/Merchant.php index 2c90167..33e8098 100644 --- a/app/controller/admin/system/merchant/Merchant.php +++ b/app/controller/admin/system/merchant/Merchant.php @@ -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('添加成功'); } diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 7b9ac10..61bf12d 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -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 diff --git a/config/log.php b/config/log.php index a7dc5c5..088e8a3 100644 --- a/config/log.php +++ b/config/log.php @@ -48,7 +48,7 @@ return [ 'format' => '[%s][%s] %s', // 是否实时写入 'realtime_write' => true, - 'file_size' => 1024 * 10, + 'file_size' => 1024 * 1024, ], 'sql' => [ // 日志记录方式 diff --git a/crmeb/listens/AppEnd.php b/crmeb/listens/AppEnd.php index 78c92e3..35b633d 100644 --- a/crmeb/listens/AppEnd.php +++ b/crmeb/listens/AppEnd.php @@ -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, '') === false) { + Log::info(Request::url(). ' params: ' . json_encode($params) ." response: " . json_encode($response)); + }else{ + Log::info(Request::url(). ' params: ' . json_encode($params)); + } } } diff --git a/route/api.php b/route/api.php index d91fe39..3916966 100644 --- a/route/api.php +++ b/route/api.php @@ -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');