优化代码

main
home.fengxinyhyl 8 months ago
parent a997517ff2
commit 9dcfb303b4
  1. 2
      app/common/dao/user/UserDao.php
  2. 4
      app/common/repositories/user/UserAssetsLogRepository.php
  3. 3
      app/controller/admin/system/merchant/Merchant.php
  4. 2
      app/controller/admin/user/User.php
  5. 2
      app/controller/api/user/User.php
  6. 3
      app/validate/admin/MerchantValidate.php

@ -85,6 +85,8 @@ class UserDao extends BaseDao
}); });
})->when(isset($where['status']) && $where['status'] !== '', function (BaseQuery $query) use ($where) { })->when(isset($where['status']) && $where['status'] !== '', function (BaseQuery $query) use ($where) {
return $query->where('User.status', intval($where['status'])); return $query->where('User.status', intval($where['status']));
})->when(isset($where['mer_id']) && $where['mer_id'] !== '', function (BaseQuery $query) use ($where) {
return $query->where('User.mer_id', intval($where['mer_id']));
})->when(isset($where['group_id']) && $where['group_id'], function (BaseQuery $query) use ($where) { })->when(isset($where['group_id']) && $where['group_id'], function (BaseQuery $query) use ($where) {
return $query->where('User.group_id', intval($where['group_id'])); return $query->where('User.group_id', intval($where['group_id']));
})->when(isset($where['brokerage_level']) && $where['brokerage_level'], function (BaseQuery $query) use ($where) { })->when(isset($where['brokerage_level']) && $where['brokerage_level'], function (BaseQuery $query) use ($where) {

@ -197,6 +197,7 @@ class UserAssetsLogRepository extends BaseRepository
$welfare = $consume = $huitong = $contribution = 0; $welfare = $consume = $huitong = $contribution = 0;
$consume = round($orderItem['total_price'] * $orderItem['commission_rate'] / 100, 2); $consume = round($orderItem['total_price'] * $orderItem['commission_rate'] / 100, 2);
$consume = $this->_getValue($consume); $consume = $this->_getValue($consume);
Log::info("+++++++++++++merchantAndPlatformAssets uid is ".$user['uid']);
$logList[] = array( $logList[] = array(
'uid' => $user['uid'], 'uid' => $user['uid'],
'asset_type' => self::ASSET_TYPE_CONSUME, 'asset_type' => self::ASSET_TYPE_CONSUME,
@ -749,6 +750,9 @@ class UserAssetsLogRepository extends BaseRepository
foreach ($data as $item) { foreach ($data as $item) {
$item['type'] = $changeType[$item['type']] ?? '未知'; $item['type'] = $changeType[$item['type']] ?? '未知';
$item['asset_type'] = $assetsType[$item['asset_type']] ?? '未知'; $item['asset_type'] = $assetsType[$item['asset_type']] ?? '未知';
if($item['status'] == self::STATUS_REFUND){
$item['type'] .= '(已退款)';
}
if($item['count'] > 0){ if($item['count'] > 0){
$item['count'] = "+".$item['count']; $item['count'] = "+".$item['count'];
} }

@ -31,6 +31,7 @@ use think\App;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\DbException; use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException; use think\db\exception\ModelNotFoundException;
use think\facade\Log;
use think\facade\Queue; use think\facade\Queue;
/** /**
@ -153,7 +154,7 @@ class Merchant extends BaseController
return app('json')->fail('请输入正确的手机号'); return app('json')->fail('请输入正确的手机号');
if (!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id'])) if (!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id']))
return app('json')->fail('商户分类不存在'); return app('json')->fail('商户分类不存在');
Log::info("+++++++++++merchant-update ". json_encode($data));
unset($data['mer_account'], $data['mer_password']); unset($data['mer_account'], $data['mer_password']);
$margin = $this->repository->checkMargin($id, $data['type_id']); $margin = $this->repository->checkMargin($id, $data['type_id']);
$data['margin'] = $margin['margin']; $data['margin'] = $margin['margin'];

@ -269,7 +269,7 @@ class User extends BaseController
$where[] = array('create_time','between',[date('Y-m-d', strtotime($date[0])),date('Y-m-d', strtotime($date[1]) +86400)]); $where[] = array('create_time','between',[date('Y-m-d', strtotime($date[0])),date('Y-m-d', strtotime($date[1]) +86400)]);
} }
if($user) $where[] = array('uid','=',$user['uid']); if($user) $where[] = array('uid','=',$user['uid']);
$where[] = array('status','in',[UserAssetsLogRepository::STATUS_FROZEN, UserAssetsLogRepository::STATUS_SUCCESS, UserAssetsLogRepository::STATUS_USED]); $where[] = array('status','in',[UserAssetsLogRepository::STATUS_FROZEN, UserAssetsLogRepository::STATUS_SUCCESS, UserAssetsLogRepository::STATUS_USED, UserAssetsLogRepository::STATUS_REFUND]);
return app('json')->success(app(UserAssetsLogRepository::class)->list(0, $where, $page, $limit)); return app('json')->success(app(UserAssetsLogRepository::class)->list(0, $where, $page, $limit));
} }

@ -59,7 +59,7 @@ class User extends BaseController
$where = array(); $where = array();
$where[] = array('asset_type','=',$asset_type); $where[] = array('asset_type','=',$asset_type);
if($change_type) $where[] = array('type','=',$change_type); if($change_type) $where[] = array('type','=',$change_type);
$where[] = array('status','in',[UserAssetsLogRepository::STATUS_FROZEN, UserAssetsLogRepository::STATUS_SUCCESS, UserAssetsLogRepository::STATUS_USED]); $where[] = array('status','in',[UserAssetsLogRepository::STATUS_FROZEN, UserAssetsLogRepository::STATUS_SUCCESS, UserAssetsLogRepository::STATUS_USED, UserAssetsLogRepository::STATUS_REFUND]);
return app('json')->success(app(UserAssetsLogRepository::class)->list($uid, $where, $page, $limit)); return app('json')->success(app(UserAssetsLogRepository::class)->list($uid, $where, $page, $limit));
} }

@ -50,7 +50,8 @@ class MerchantValidate extends Validate
'is_bro_goods|直播商品状态' => 'require|in:0,1', 'is_bro_goods|直播商品状态' => 'require|in:0,1',
'is_bro_room|直播间状态' => 'require|in:0,1', 'is_bro_room|直播间状态' => 'require|in:0,1',
'is_trader|自营状态' => 'require|in:0,1', 'is_trader|自营状态' => 'require|in:0,1',
'commission_rate|提成比例' => '>=:0' 'commission_rate|提成比例' => '>=:0',
'district_id|所属区域' =>'>=:0'
]; ];
/** /**

Loading…
Cancel
Save