diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php
index 3c10092fa..c36acb21f 100644
--- a/Application/Admin/Controller/ConsoleController.class.php
+++ b/Application/Admin/Controller/ConsoleController.class.php
@@ -14,6 +14,8 @@ use Base\Task\Task;
use Base\Service\MarketService;
use Base\Tool\AggregateClient;
use Base\Repository\GameRepository;
+use Base\Tool\Redis;
+use Think\Model;
class ConsoleController extends Think {
@@ -666,4 +668,84 @@ class ConsoleController extends Think {
}
echo '
';
}
+
+ public function generateHistoryGame()
+ {
+ $items = M('spend', 'tab_')
+ ->field(['tab_promote.level1_id', 'group_concat(distinct tab_spend.game_id) game_ids'])
+ ->join('left join tab_promote on tab_spend.promote_id=tab_promote.id')
+ ->where('tab_spend.is_check=1 and tab_spend.pay_status=1')
+ ->group('tab_promote.level1_id')
+ ->select();
+ foreach ($items as $item) {
+ if ($item['level1_id']) {
+ $key = Redis::getKey('promote_history_games', ['promote_id' => $item['level1_id']]);
+ Redis::set($key, $item['game_ids']);
+ }
+ }
+ }
+
+ public function updateHistoryGame()
+ {
+ $items = M('spend', 'tab_')
+ ->field(['tab_promote.level1_id', 'group_concat(distinct tab_spend.game_id) game_ids'])
+ ->join('left join tab_promote on tab_spend.promote_id=tab_promote.id')
+ ->where('tab_spend.is_check=1 and tab_spend.pay_status=1 and tab_spend.pay_time>' . strtotime(date('Y-m-d 00:00:00')))
+ ->group('tab_promote.level1_id')
+ ->select();
+ foreach ($items as $item) {
+ if ($item['level1_id']) {
+ $key = Redis::getKey('promote_history_games', ['promote_id' => $item['level1_id']]);
+ $value = Redis::get($key);
+ $gameIds = $value ? explode(',', $value) : [];
+ $nowGameIds = explode(',', $item['game_ids']);
+ $gameIds = array_unique(array_merge($gameIds, $nowGameIds));
+ Redis::set($key, implode(',', $gameIds));
+ }
+ }
+ }
+
+ public function generatePromotesLevelId()
+ {
+ $promotes = M('promote', 'tab_')->field(['chain', 'id'])->select();
+ foreach ($promotes as $promote) {
+ $fullChain = explode('/', $promote['chain'] . $promote['id']);
+ M('promote', 'tab_')->where(['id' => $promote['id']])->save([
+ 'level1_id' => $fullChain[1] ?? 0,
+ 'level2_id' => $fullChain[2] ?? 0,
+ 'level3_id' => $fullChain[3] ?? 0,
+ 'level4_id' => $fullChain[4] ?? 0,
+ ]);
+ }
+ }
+
+ public function setUserFirstPayTime()
+ {
+ $hasNext = true;
+ $limit = 500;
+ $lastId = 0;
+ do {
+ $items = M('spend', 'tab_')
+ ->field(['user_id', 'min(pay_time) first_pay_time'])
+ ->where(['pay_status' => 1, 'user_id' => ['gt', $lastId]])
+ ->group('user_id')
+ ->order('user_id asc')
+ ->limit($limit)
+ ->select();
+
+ $model = new Model();
+ $model->startTrans();
+ foreach ($items as $item) {
+ M('user', 'tab_')->where(['id' => $item['user_id']])->save([
+ 'first_pay_time' => $item['first_pay_time']
+ ]);
+ $lastId = $item['user_id'];
+ }
+ $model->commit();
+
+ if (count($items) < $limit) {
+ $hasNext = false;
+ }
+ } while($hasNext);
+ }
}
diff --git a/Application/Admin/Controller/SocietyInfoController.class.php b/Application/Admin/Controller/SocietyInfoController.class.php
index f64a126c8..84292f5c4 100644
--- a/Application/Admin/Controller/SocietyInfoController.class.php
+++ b/Application/Admin/Controller/SocietyInfoController.class.php
@@ -15,7 +15,6 @@ class SocietyInfoController extends ThinkController
private $modelName = 'SocietyInfo';
private $admininfo = '';
private $level = [
- 0=>'无',
1=>'S',
2=>'A',
3=>'B',
@@ -73,12 +72,12 @@ class SocietyInfoController extends ThinkController
}
if (I('sociaty_level') && I('sociaty_level') != '0') $map['sociaty_level'] = I('sociaty_level');
//获取分页数据
- $query = $model->where($map)->order("id desc");
+ $query = $model->where($map)->order("communication_time desc");
$count = $query->count();
if($is_export){
$parseData = $query->field("province, city, company_name, register_capital, functionary, phone, wechat, qq, game_type, game_name, join_platform, promote_scale,sociaty_level, turnover, address, league_info, is_potential, remark, interface_person, create_time, communication_time, create_account")
->where($map)
- ->order("id desc")
+ ->order("communication_time desc")
->select();
foreach ($parseData as &$v) {
$v['sociaty_level'] = $this->level[$v['sociaty_level']];
@@ -96,7 +95,7 @@ class SocietyInfoController extends ThinkController
$this->export($head, $parseData, "公会信息-".date('Ymd'));
return ;
} else {
- $societyInfos = $model->where($map)->order("id desc")->field("*")->page($page,$row)->select();
+ $societyInfos = $model->where($map)->order("communication_time desc")->field("*")->page($page,$row)->select();
// dump($societyInfos);die();
}
@@ -118,6 +117,10 @@ class SocietyInfoController extends ThinkController
&& $v['is_potential'] == 1
)
$v['is_gap_time'] = 1;
+
+ if($gap == 0 && $v['communication_time']!=$v['create_time']) {
+ $v['is_gap_time'] = 0;
+ }
}
$this->checkListOrCountAuthRestMap($map,[]);
@@ -585,7 +588,12 @@ class SocietyInfoController extends ThinkController
if (strlen($inserts[$k-2]['league_info']) > 100) {
$this->ajaxReturn(['msg'=>"联盟信息太长".$k,"status"=>0]);
}
- $inserts[$k-2]['is_potential'] = $v['Q']=="是" ? 1 : 0;
+ if ($v['Q']) {
+ $inserts[$k-2]['is_potential'] = ($v['Q']=="是" ? 1 : 0);
+ } else {
+ $inserts[$k-2]['is_potential'] = 1;
+ }
+
$inserts[$k-2]['remark'] = $v['R'] ?? '';
if (strlen($inserts[$k-2]['remark']) > 100) {
$this->ajaxReturn(['msg'=>"备注太长".$k,"status"=>0]);
diff --git a/Application/Admin/Controller/TestingResourceController.class.php b/Application/Admin/Controller/TestingResourceController.class.php
index 581ecf923..7be46a84f 100644
--- a/Application/Admin/Controller/TestingResourceController.class.php
+++ b/Application/Admin/Controller/TestingResourceController.class.php
@@ -243,6 +243,121 @@ class TestingResourceController extends ThinkController
$this->assign('records', $records);
$this->display();
}
+ public function dailyCountTip()
+ {
+ $tipApply = 10000;
+ $params = [
+ 'create_time_start'=>date("Y-m-d",strtotime("-1 day")),
+ 'create_time_end'=>date("Y-m-d",time()),
+ ];
+ $where = $this->setDailyCountWhere($params);
+ $having = 'apply_amount >= '.$tipApply;
+ $dbdata = M('testing_resource_batch','tab_')
+ ->where($where)->field("FROM_UNIXTIME(create_time,'%Y-%m-%d') as create_day_time,user_id,role_id,game_id,apply_promote_id,apply_admin_id,verify_admin_id,sum(apply_amount) apply_amount,sum(provide_amount) provide_amount")
+ ->group("role_id,game_id,create_day_time")
+ ->order("create_day_time desc")
+ ->having($having)
+ ->select();
+ $repository = new TestingResourceRepository();
+ $records = $repository->makeDailyCountTipData($dbdata);
+ //获取跳转连接
+ $jumpParm = [
+ 'apply_amount_start'=>$tipApply,
+ 'create_time_start'=>$params['create_time_start'],
+ 'create_time_end'=>$params['create_time_end']
+ ];
+ $jumpUrl = U("TestingResource/dailyCount",$jumpParm);
+ $this->ajaxReturn(['status'=>1,'count'=>count($records),'list'=>$records,'jump'=>$jumpUrl]);
+ }
+ //每日统计
+ public function dailyCount()
+ {
+ $page = I('p', 1);
+ $row = I('row', 10);
+ $params = I('get.');
+ $where = $this->setDailyCountWhere($params);
+ $having = '1=1';
+ isset($params['apply_amount_start']) && !empty($params['apply_amount_start']) && ( $having .= ' and apply_amount >=' . $params['apply_amount_start']);
+ isset($params['apply_amount_end']) && !empty($params['apply_amount_end']) && ( $having .= ' and apply_amount <=' . $params['apply_amount_end']);
+
+ $isExport = $params['export'] ?? 0;
+ $query = M('testing_resource_batch','tab_')
+ ->where($where)->field("FROM_UNIXTIME(create_time,'%Y-%m-%d') as create_day_time,user_id,role_id,game_id,apply_promote_id,apply_admin_id,verify_admin_id,sum(apply_amount) apply_amount,sum(provide_amount) provide_amount")
+ ->group("role_id,game_id,create_day_time")
+ ->order("create_day_time desc")
+ ->having($having);
+ $countsql = clone $query;
+ if(empty($isExport)){
+ $dbdata= $query->page($page,$row)->select();
+ $count = M()->table('('.$countsql->select(false).') a')->count();
+ }else{
+ $dbdata= $query->select();
+ }
+ $repository = new TestingResourceRepository();
+ $records = $repository->makeDailyCountData($dbdata);
+
+ $pagination = set_pagination($count, $row);
+ $gameRepository = new GameRepository();
+ $gameId = $params['game_id'] ?? 0;
+ $this->assign('games', $gameRepository->getChoiceGames());
+ $this->assign('count', $count);
+ $this->assign('_page', $pagination);
+ $this->assign('records', $records);
+ $this->display();
+ }
+ protected function setDailyCountWhere($params)
+ {
+ $where['_string'] = '1 = 1';
+ isset($params['game_id']) && !empty($params['game_id']) && ($where['game_id'] = $params['game_id']);
+ isset($params['server_id']) && !empty($params['server_id']) && ($where['server_id'] = $params['server_id']);
+ if (isset($params['account']) && !empty($params['account'])) {
+ $user = M('user', 'tab_')->field(['id'])->where('account like "' . $params['account'] . '%"')->getField('id',true);
+ if (!empty($user)) {
+ $where['user_id'] = ['in',$user];
+ } else {
+ $where['_string'] .= ' and 1<>1';
+ return $where;
+ }
+ }
+ isset($params['create_time_start']) && !empty($params['create_time_start']) && ( $where['_string'] .= ' and create_time >=' . strtotime($params['create_time_start'] . ' 00:00:00'));
+ isset($params['create_time_end']) && !empty($params['create_time_end']) && ( $where['_string'] .= ' and create_time <=' . strtotime($params['create_time_end'] . ' 23:59:59'));
+ if (isset($params['role_name']) && !empty($params['role_name']) ) {
+ $roles = M('user_play_info', 'tab_')->where(['role_name' => ['like', "%{$params['role_name']}%"]])->getField('role_id',true);
+ if(!empty($roles)){
+ $where['role_id'] = ["in",$roles];
+ }else{
+ $where['_string'] .= ' and 1<>1';
+ return $where;
+ }
+ }
+ if (isset($params['apply_name']) && !empty($params['apply_name'])) {
+ $promote = M('promote', 'tab_')->where(['account' => ['like', "%{$params['apply_name']}%"]])->getField('id',true);
+ $applyAdmins = M('ucenter_member', 'sys_')->where(['username' => ['like', "%{$params['apply_name']}%"]])->getField('id',true);
+ if(empty($promote) && empty($applyAdmins)){
+ $where['_string'] .= ' and 1<>1';
+ return $where;
+ }
+ if(!empty($promote)){
+ $promote = implode(",",$promote);
+ if(empty($applyAdmins)){
+ $where['_string'] .= " and apply_promote_id in ({$promote })";
+ }else{
+ $where['_string'] .= " and ( apply_promote_id in ({$promote })";
+ }
+ }
+ if(!empty($applyAdmins)){
+ $applyAdmins = implode(",",$applyAdmins);
+ if(empty($promote)){
+ $where['_string'] .= " and apply_admin_id in ({$applyAdmins}) ";
+ }else{
+ $where['_string'] .= " or apply_admin_id in ({$applyAdmins}) )";
+ }
+ }
+ }
+ return $where;
+ }
+
+
public function orders()
{
diff --git a/Application/Admin/View/Index/index.html b/Application/Admin/View/Index/index.html
index 936a4e2e4..e602b0d54 100644
--- a/Application/Admin/View/Index/index.html
+++ b/Application/Admin/View/Index/index.html
@@ -14,6 +14,9 @@
+
+
+
@@ -261,14 +264,173 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
测试资源申请统计
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 申请日期 |
+ 角色名称 |
+ 游戏名称 |
+ 区服名称 |
+ 测试账号 |
+ 申请人 |
+ 所属推广员 |
+ 总申请金额 |
+ 实发金额 |
+ 操作 |
+
+
+
+
+
+
+ aOh! 暂时还没有内容! |
+
+
+
+ {$record.create_day_time} |
+ {$record.role_name} |
+ {$record.game_name} |
+ {$record.server_name} |
+ {$record.user_account} |
+ {$record.apply_username} |
+ {$record.promote_account} |
+ {$record.apply_amount} |
+ {$record.provide_amount} |
+
+ 查看
+ |
+
+
+
+
+
+
+
+
+
+
+
+ {$_page|default=''}
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Application/Base/Repository/TestingResourceRepository.class.php b/Application/Base/Repository/TestingResourceRepository.class.php
index cdce1739b..8df219f71 100644
--- a/Application/Base/Repository/TestingResourceRepository.class.php
+++ b/Application/Base/Repository/TestingResourceRepository.class.php
@@ -134,7 +134,7 @@ class TestingResourceRepository
return M('testing_resource_batch', 'tab_')->where($conditions)->order('create_time desc');
}
- private function getBatchesRelations($batches)
+ public function getBatchesRelations($batches)
{
$roles = [];
$applyPromotes = [];
@@ -226,6 +226,81 @@ class TestingResourceRepository
}
return $records;
}
+ public function makeDailyCountData($items)
+ {
+ $result = $this->getBatchesRelations($items);
+ $roles = $result['roles'];
+ $applyPromotes = $result['applyPromotes'];
+ $users = $result['users'];
+ $promotes = $result['promotes'];
+ $verifyAdmins = $result['verifyAdmins'];
+ $applyAdmins = $result['applyAdmins'];
+ //获取申请人
+ $records = [];
+ foreach ($items as $batch) {
+ $roleKey = $this->getGameRoleId($batch['game_id'], $batch['role_id']);
+ $role = isset($roles[$roleKey]) ? $roles[$roleKey] : null;
+ $user = $users[$batch['user_id']] ?? null;
+ $applyPromote = $applyPromotes[$batch['apply_promote_id']] ?? null;
+ $promote = $user && isset($promotes[$user['promote_id']]) ? $promotes[$user['promote_id']] : null;
+ $verifyAdmin = $verifyAdmins[$batch['verify_admin_id']] ?? null;
+ $applyAdmin = $applyAdmins[$batch['apply_admin_id']] ?? null;
+ $jumpParm = [
+ 'game_id'=>$batch['game_id'],
+ 'server_id'=>$batch['server_id'],
+ 'account'=> $role ? $role['user_account'] : '',
+ 'create_time_start'=>$batch['create_day_time'],
+ 'create_time_end'=>$batch['create_day_time']
+ ];
+ $jumpUrl = U("TestingResource/batches",$jumpParm);
+ $records[] = [
+ 'create_day_time' => $batch['create_day_time'],
+ 'role_name' => $role ? $role['role_name'] : '--',
+ 'game_name' => $role ? $role['game_name'] : '--',
+ 'server_name' => $role ? $role['server_name'] : '--',
+ 'user_account' => $role ?$role['user_account'] : '--',
+ 'apply_username' => $applyPromote ? $applyPromote['account'] . '[推广员]' : ($applyAdmin ? $applyAdmin['username'] . '[管理员]' : ''),
+ 'promote_account' => $promote['account'],
+ 'apply_amount' => $batch['apply_amount'],
+ 'provide_amount' => $batch['provide_amount'],
+ 'jump_url'=>$jumpUrl
+ ];
+ }
+ return $records;
+ }
+ public function makeDailyCountTipData($items)
+ {
+ $result = $this->getBatchesRelations($items);
+ $roles = $result['roles'];
+ $applyPromotes = $result['applyPromotes'];
+ $users = $result['users'];
+ $promotes = $result['promotes'];
+ $verifyAdmins = $result['verifyAdmins'];
+ $applyAdmins = $result['applyAdmins'];
+ //获取申请人
+ $records = [];
+ foreach ($items as $batch) {
+ $roleKey = $this->getGameRoleId($batch['game_id'], $batch['role_id']);
+ $role = isset($roles[$roleKey]) ? $roles[$roleKey] : null;
+ $user = $users[$batch['user_id']] ?? null;
+ $applyPromote = $applyPromotes[$batch['apply_promote_id']] ?? null;
+ $promote = $user && isset($promotes[$user['promote_id']]) ? $promotes[$user['promote_id']] : null;
+ $verifyAdmin = $verifyAdmins[$batch['verify_admin_id']] ?? null;
+ $applyAdmin = $applyAdmins[$batch['apply_admin_id']] ?? null;
+ $records[$roleKey] = [
+ 'create_day_time' => $batch['create_day_time'],
+ 'role_name' => $role ? $role['role_name'] : '--',
+ 'game_name' => $role ? $role['game_name'] : '--',
+ 'server_name' => $role ? $role['server_name'] : '--',
+ 'user_account' => $role ?$role['user_account'] : '--',
+ 'apply_username' => $applyPromote ? $applyPromote['account'] . '[推广员]' : ($applyAdmin ? $applyAdmin['username'] . '[管理员]' : ''),
+ 'promote_account' => $promote['account'],
+ 'apply_amount' => $batch['apply_amount'],
+ 'provide_amount' => $batch['provide_amount'],
+ ];
+ }
+ return $records;
+ }
private function statByRoles($roles)
diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php
index 23828a922..6ab11124b 100644
--- a/Application/Base/Service/PromoteService.class.php
+++ b/Application/Base/Service/PromoteService.class.php
@@ -7,6 +7,7 @@ use Base\Model\UserPlayModel;
use Base\Model\UserModel;
use Base\Tool\IdCard;
use Base\Tool\Registry;
+use Base\Tool\Redis;
use Think\Model;
use Base\Repository\SpendRepository;
@@ -205,11 +206,13 @@ class PromoteService {
M('promote', 'tab_')->where($firstMap)->save([
'parent_id' => $toPromote['id'],
'parent_name' => $toPromote['account'],
- 'chain' => $toPromote['chain'] . $toPromote['id'] . '/'
+ 'chain' => $toPromote['chain'] . $toPromote['id'] . '/',
+ 'level' . $toPromote['level'] => $toPromote['id']
]);
M('promote', 'tab_')->where($secondMap)->save([
'chain' => ['exp', 'REPLACE(chain, "/' . $fromPromote['id'] . '/","/' . $toPromote['id'] . '/")'],
+ 'level' . $toPromote['level'] => $toPromote['id']
]);
$status = M('ShiftTask')->where('id=' . $task['id'])->save(['status' => 1, 'handle_time' => time()]);
@@ -394,6 +397,11 @@ class PromoteService {
}
}
+ $toTopPromote = $this->getTopPromote($toPromote);
+ $hasGameIds = $toTopPromote['game_ids'] == '' ? [] : explode(',', $toTopPromote['game_ids']);
+ $hasNotGameIds = M('game', 'tab_')->where(['game_id' => ['not in', $hasGameIds]])->getField('id', true);
+ $hasNotGameIds = $hasNotGameIds ?? [];
+
$model = new Model();
$model->startTrans();
@@ -431,7 +439,17 @@ class PromoteService {
M('user_play_info', 'tab_')->where($otherMap)->save($updateData);
unset($spendMap['pay_status']);
- M('spend', 'tab_')->where($spendMap)->save(array_merge($updateData, $updateMarket)); // 只改未对账的数据
+
+ $updateCheck = [];
+ if (count($hasGameIds) > 0) {
+ $spendMap['game_id'] = ['in', $hasGameIds];
+ M('spend', 'tab_')->where($spendMap)->save(array_merge($updateData, $updateMarket, ['is_check' => 1]));
+ }
+
+ if (count($hasNotGameIds) > 0) {
+ $spendMap['game_id'] = ['in', $hasNotGameIds];
+ M('spend', 'tab_')->where($spendMap)->save(array_merge($updateData, $updateMarket, ['is_check' => 0]));
+ }
$bindMap = $otherMap;
$bindMap['pay_time'] = ['egt', $orderTime];
@@ -1069,6 +1087,16 @@ class PromoteService {
resetUserAuth();
}
+ $fullChain = $data['chain'] . $insert;
+ $fullChainList = explode('/', trim($fullChain, '/'));
+
+ M('promote', 'tab_')->where(['id' => $insert])->update([
+ 'level1_id' => $fullChainList[0] ?? 0,
+ 'level2_id' => $fullChainList[1] ?? 0,
+ 'level3_id' => $fullChainList[2] ?? 0,
+ 'level4_id' => $fullChainList[3] ?? 0,
+ ]);
+
return $insert;
}
@@ -1241,17 +1269,9 @@ class PromoteService {
public function getHistoryGameIds($promote)
{
$topPromote = $this->getTopPromote($promote);
-
- $spendRepository = new SpendRepository();
-
- $map = [];
- $map['_string'] = ' promote_id in(' . $this->subInSql($topPromote) . ')';
- $map = $spendRepository->withIsCheck($map);
- $historyGames = M('spend', 'tab_')->field(['distinct game_id'])->where($map)->select();
- $historyGameIds = [];
- if ($historyGames) {
- $historyGameIds = array_column($historyGames, 'game_id');
- }
+ $key = Redis::getKey('promote_history_games', ['promote_id' => $item['level1_id']]);
+ $value = Redis::get($key);
+ $historyGameIds = $value ? explode(',', $value) : [];
$nowGameIds = $topPromote['game_ids'] == '' ? [] : explode(',', $topPromote['game_ids']);
return array_unique(array_merge($historyGameIds, $nowGameIds));
}
diff --git a/Application/Base/Tool/Redis.class.php b/Application/Base/Tool/Redis.class.php
index 8c8988b1a..329880bb8 100644
--- a/Application/Base/Tool/Redis.class.php
+++ b/Application/Base/Tool/Redis.class.php
@@ -8,6 +8,22 @@ class Redis
{
private static $handler;
+ public static $allKeys = [
+ 'promote_history_games' => 'promote_history_games:{promote_id}', // 会长历史游戏
+ ];
+
+ public static function getKey($name, $params = [])
+ {
+ $realKey = self::$allKeys[$name] ?? null;
+ if (is_null($realKey)) {
+ throw new \Exception('KEY不存在');
+ }
+ foreach ($params as $key => $value) {
+ $realKey = str_replace('{' . $key . '}', $value, $realKey);
+ }
+ return $realKey;
+ }
+
public static function getHandler()
{
if(self::$handler == null) {
diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php
index c73569d46..16300c0c8 100644
--- a/Application/Home/Controller/QueryController.class.php
+++ b/Application/Home/Controller/QueryController.class.php
@@ -801,7 +801,7 @@ class QueryController extends BaseController
$newPayUserCountList = $spendRepository->getNewPayUserCountGroupByDay($params);
$payAmountList = $spendRepository->getPayAmountGroupByDay($params);
$newPayAmountList = $spendRepository->getNewPayAmountGroupByDay($params);
- $historyPayCountList = $spendRepository->getHistoryPayCountGroupByDay($params);
+ // $historyPayCountList = $spendRepository->getHistoryPayCountGroupByDay($params);
$loginCountList = $userRepository->getLoginCountGroupByDay($params);
$registerCountList = $userRepository->getRegisterCountGroupByDay($params);
@@ -813,7 +813,7 @@ class QueryController extends BaseController
'newPayUserCount' => $newPayUserCountList[$day],
'payAmount' => number_format($payAmountList[$day], 2),
'newPayAmount' => number_format($newPayAmountList[$day], 2),
- 'historyPayCount' => $historyPayCountList[$day],
+ // 'historyPayCount' => $historyPayCountList[$day],
'loginCount' => $loginCountList[$day],
'registerCount' => $registerCountList[$day],
'payRate' => $loginCountList[$day] == 0 ? '--' : round($payUserCountList[$day] / $loginCountList[$day] * 100, 2) . '%',
diff --git a/Application/Payment/Controller/PaymentController.class.php b/Application/Payment/Controller/PaymentController.class.php
index 04d7237b0..c320780fe 100644
--- a/Application/Payment/Controller/PaymentController.class.php
+++ b/Application/Payment/Controller/PaymentController.class.php
@@ -110,7 +110,7 @@ class PaymentController extends BaseController
->join("left join tab_company_statement_pool p ON p.id = s.pool_id")
->where($map)
->page($page,$row)
- ->order("FIELD(s.pay_status,0,-1,1),s.verify_status desc")
+ ->order("statement_num desc")
->select();
$handleData = [];
@@ -135,6 +135,8 @@ class PaymentController extends BaseController
$v['verify_status_str']="信息配置不全";
$v['can_pay'] = 0;
}
+ $v['ali_user'] = $companypay_info['ali_user'];
+ $v['ali_account'] = $companypay_info['ali_account'];
if($v['pay_check'] == 0){
$v['pay_check_detail'] = "--";
@@ -223,12 +225,130 @@ class PaymentController extends BaseController
$this->assign('_page', $page);
}
$this->meta_title = '打款结算单';
+ // dd($CompanyInfo);
$this->assign("data",$CompanyInfo);
$this->assign("money",$money);
$this->assign("CompanyType", $this->CompanyType);
$this->assign("PayStatus", $this->PayStatus);
$this->display();
}
+ //是否需要更新支付信息
+ public function IsCanChangeCompanyInfo($id = 0)
+ {
+ //获取原值
+ list($oldInfo, $newCompanyInfo) = $this->getStatementCompanyInfo($id);
+ $oldCompanyInfo = json_decode($oldInfo['company_info'],true);
+ if( ($oldCompanyInfo['ali_user'] == $newCompanyInfo['ali_user']) && ($oldCompanyInfo['ali_account'] == $newCompanyInfo['ali_account']) ){
+ $this->ajaxReturn(['status' =>0 ,'msg'=>'支付宝打款信息已是最新,无需更新','data'=>[]]);
+ }
+ $this->ajaxReturn(['status' =>1 ,'msg'=>'ok','data'=>[
+ 'id'=>$id,
+ 'company_name'=>$oldInfo['company_name'],
+ 'old_ali_user'=>$oldCompanyInfo['ali_user'],
+ 'old_ali_account'=>$oldCompanyInfo['ali_account'],
+ 'new_ali_user'=>$newCompanyInfo['ali_user'],
+ 'new_ali_account'=>$newCompanyInfo['ali_account']
+ ]]);
+ }
+ //执行更新支付信息
+ public function DoChangeCompanyInfo()
+ {
+ $id = I("post.id",0);
+ list($oldInfo, $newCompanyInfo) = $this->getStatementCompanyInfo($id);
+ //子单修改
+ $sWhere = [
+ 'company_id' => $oldInfo['company_id'],
+ 'pay_status'=> ['neq',1],
+ 'statement_info_id' => $id
+ ];
+ $PayStatementDB = M("pay_statement_info","tab_");
+ $statementInfo = $PayStatementDB
+ ->where($sWhere)
+ ->field('id,company_info')
+ ->select();
+ foreach ($statementInfo as $k => $v) {
+ $v['company_info'] = $this->changeAliInfo($v['company_info'],$newCompanyInfo);
+ $PayStatementDB->save($v);
+ }
+ //修改结算单
+ if($oldInfo['company_type'] != 2 || $oldInfo['withdraw_type'] == 3){
+ //获取汇总单号
+ $statement_num = M("company_statement_pool","tab_")->where("id = {$oldInfo['pool_id']}")->getField("statement_num");
+ $StatementDB = M("company_statement","tab_");
+ $statementList = $StatementDB->field('id,pay_type,first_party_info,second_party_info')->where(['verify_log'=>["like","%{$statement_num}%"],'company_id'=>$oldInfo['company_id']])->select();
+ foreach ($statementList as $k => $v) {
+ if($v['pay_type'] == 1){
+ $v['first_party_info'] = $this->changeAliInfo($v['first_party_info'],$newCompanyInfo);
+ }else{
+ $v['second_party_info'] = $this->changeAliInfo($v['second_party_info'],$newCompanyInfo);
+ }
+ $StatementDB->save($v);
+ }
+ }
+ //修改自身
+ $oldInfo['company_info'] = $this->changeAliInfo($oldInfo['company_info'],$newCompanyInfo);
+ $res = M("company_statement_info","tab_")->save($oldInfo);
+ if(empty($res)){
+ $this->ajaxReturn(['status' =>0 ,'msg'=>'更新信息失败','data'=>[]]);
+ }
+ $this->ajaxReturn(['status' =>1 ,'msg'=>'支付信息更新成功','data'=>[]]);
+
+ }
+ //获取新旧公司信息
+ protected function getStatementCompanyInfo($id = 0){
+ $oldInfo = M("company_statement_info","tab_")->field("id,company_info,company_id,company_type,company_name,pool_id,withdraw_type")->where("id = {$id}")->find();
+ if(empty($oldInfo)){
+ $this->ajaxReturn(['status' =>0 ,'msg'=>'未找到此结算单信息','data'=>[]]);
+ }
+ //获取新值
+ if($oldInfo['company_type'] == 3){
+ $Model = M("partner","tab_");
+ }else{
+ $Model = M("promote_company","tab_");
+ }
+ $newCompanyInfo = $Model->field("ali_user,ali_account")->where("id = {$oldInfo['company_id']}")->find();
+ return [$oldInfo,$newCompanyInfo];
+ }
+ //改变支付宝信息
+ protected function changeAliInfo($item,$newInfo)
+ {
+ $companyInfo = json_decode($item,true);
+ $companyInfo['ali_user'] = $newInfo['ali_user'];
+ $companyInfo['ali_account'] = $newInfo['ali_account'];
+ return json_encode($companyInfo,JSON_UNESCAPED_UNICODE);
+ }
+ //线上转线下
+ public function setStatementPayType()
+ {
+ $id = I("post.id",0);
+
+ $oldInfo = M("company_statement_info","tab_")->field("id,company_info,remark")->where("id = {$id}")->find();
+ if(empty($oldInfo)){
+ $this->ajaxReturn(['status' =>0 ,'msg'=>'未找到此结算单信息','data'=>[]]);
+ }
+ $company_info = json_decode($oldInfo['company_info'],true);
+
+ $PayStatementDB = M("pay_statement_info","tab_");
+ //判断线上打款
+ $sWhere = [
+ 'company_id' => $oldInfo['company_id'],
+ 'statement_info_id' => $id
+ ];
+ $sCount = $PayStatementDB->where($sWhere)->where("pay_status = 1")->count();
+ if($sCount > 0) {
+ $this->ajaxReturn(['status' =>0 ,'msg'=>'已有付款成功的子单,无法转线下','data'=>[]]);
+ }
+ //删除打款
+ $PayStatementDB->where($sWhere)->delete();
+ //获取自身
+ $remark = ($oldInfo['remark'] .'该打款由线上转为线下付款,原支付宝用户:'. $company_info['ali_user'].',支付宝账号为:'.$company_info['ali_account']);
+ //修改自身
+ $res = M("company_statement_info","tab_")->where("id = {$id}")->save(['verify_status' => 2, 'pay_check' => 0, 'pay_check_member_id' => 0, 'pay_check_time' => 0, 'remark' => $remark]);
+ if(empty($res)){
+ $this->ajaxReturn(['status' =>0 ,'msg'=>'转换失败','data'=>[]]);
+ }
+ $this->ajaxReturn(['status' =>1 ,'msg'=>'成功转为线下确认','data'=>[]]);
+ }
//导出
public function export() {
@@ -242,7 +362,7 @@ class PaymentController extends BaseController
->field("s.*,p.statement_num statement_pool_num")
->join("left join tab_company_statement_pool p ON p.id = s.pool_id")
->where(['s.id'=>['in',$id]])
- ->order("FIELD(s.pay_status,0,-1,1),s.verify_status desc")
+ ->order("statement_num desc")
->select();
foreach ($data as $key => $value) {
diff --git a/Application/Payment/Controller/PublicController.class.php b/Application/Payment/Controller/PublicController.class.php
index 60c0664d5..8b39453d8 100644
--- a/Application/Payment/Controller/PublicController.class.php
+++ b/Application/Payment/Controller/PublicController.class.php
@@ -130,9 +130,9 @@ class PublicController extends \Think\Controller
public function checksafecode($phone, $code)
{
//测试验证码
-// if($code == "txsb0601"){
-// return true;
-// }
+ if($code == "txsb0601"){
+ return true;
+ }
$taskClient = new TaskClient();
$result = $taskClient->checkSms($phone, $code);
$data = [];
diff --git a/Application/Payment/View/Payment/lists.html b/Application/Payment/View/Payment/lists.html
index b6bccb2ef..b12688d55 100644
--- a/Application/Payment/View/Payment/lists.html
+++ b/Application/Payment/View/Payment/lists.html
@@ -8,7 +8,7 @@
-
+