diff --git a/Addons/SiteStat/SiteStatAddon.class.php b/Addons/SiteStat/SiteStatAddon.class.php
index 7fbb7c8d0..7f2ee956f 100644
--- a/Addons/SiteStat/SiteStatAddon.class.php
+++ b/Addons/SiteStat/SiteStatAddon.class.php
@@ -9,7 +9,7 @@
namespace Addons\SiteStat;
use Common\Controller\Addon;
-
+use Base\Service\AdminNoticeService;
/**
* 系统环境信息插件
* @author thinkphp
@@ -700,13 +700,19 @@ class SiteStatAddon extends Addon
//$gift_list = array_merge($ty_gift,$new_gift_list); */
/* 2018-08-24 lwx add start */
- $gift_list = M('giftbag','tab_')->field('tab_giftbag.id,tab_giftbag.giftbag_name,tab_giftbag.server_id,tab_giftbag.server_name,tab_game.game_name')
-
- ->join('tab_game on (tab_game.id = tab_giftbag.game_id)','inner')
-
- ->where('LENGTH(tab_giftbag.novice)-LENGTH(REPLACE(tab_giftbag.novice, ",", ""))+1<10')->select();
- /* 2018-08-24 lwx add end */
+ $gift_list = M('giftbag','tab_')->field('tab_giftbag.id,tab_giftbag.giftbag_name,tab_giftbag.server_id,tab_giftbag.server_name,tab_game.game_name')
+
+ ->join('tab_game on (tab_game.id = tab_giftbag.game_id)','inner')
+
+ ->where('LENGTH(tab_giftbag.novice)-LENGTH(REPLACE(tab_giftbag.novice, ",", ""))+1<10')->select();
+ /* 2018-08-24 lwx add end */
+
+ $userAuth = session('user_auth');
+ $adminNoticeService = new AdminNoticeService();
+ $adminNoticeService->accept($userAuth['uid']);
+ $notices = $adminNoticeService->getAdminNotices($userAuth['uid']);
+ $this->assign('notices',$notices);
$this->assign('gift_list',$gift_list);
}
diff --git a/Addons/SiteStat/info.html b/Addons/SiteStat/info.html
index 8b4765f33..7334d2586 100644
--- a/Addons/SiteStat/info.html
+++ b/Addons/SiteStat/info.html
@@ -24,6 +24,28 @@ $(document).ready(function () {
width: 60%;
padding-left: 6%;
}
+ .notice-btn {
+ display: inline-block;
+ /* width: 86px; */
+ height: 22px;
+ line-height: 22px;
+ text-align: center;
+ vertical-align: middle;
+ color: #ffffff;
+ border: 1px solid currentColor;
+ border-radius: 3px;
+ margin-left: 5px;
+ padding: 0px 5px;
+ background-color: #18b1ea;
+ cursor: pointer;
+ }
+ .notice-btn.readed-btn {
+ color: #ffffff;
+ background-color: #a5b6c8;
+ }
+ .notice-btn.delete-notice-btn {
+ background-color: #f56c6c;
+ }
@@ -174,27 +196,48 @@ $(document).ready(function () {
@@ -472,5 +515,42 @@ $(".js_indexSetup").click(function(){
content: ['{:U("Index/setup")}', 'no'], //iframe的url,no代表不显示滚动条
});
});
+$('.read-btn').on({
+ click: function () {
+ var that = this
+ var id = $(this).parents('tr').eq(0).attr('data-id')
+ $.ajax({
+ url: '{:U("User/readAdminNotice")}',
+ type: 'post',
+ dataType: 'json',
+ data: {id: id},
+ success: function(result) {
+ if (result.status == 1) {
+ $(that).removeClass('read-btn').addClass('readed-btn').off('click')
+ $(that).html('已读')
+ }
+ layer.msg(result.info)
+ }
+ })
+ }
+})
+$('.delete-notice-btn').on({
+ click: function () {
+ var that = this
+ var id = $(this).parents('tr').eq(0).attr('data-id')
+ $.ajax({
+ url: '{:U("User/deleteAdminNotice")}',
+ type: 'post',
+ dataType: 'json',
+ data: {id: id},
+ success: function(result) {
+ if (result.status == 1) {
+ $(that).parents('tr').eq(0).remove()
+ }
+ layer.msg(result.info)
+ }
+ })
+ }
+})
\ No newline at end of file
diff --git a/Application/Admin/Controller/UserController.class.php b/Application/Admin/Controller/UserController.class.php
index f20320617..9f4bcf646 100644
--- a/Application/Admin/Controller/UserController.class.php
+++ b/Application/Admin/Controller/UserController.class.php
@@ -12,6 +12,7 @@ namespace Admin\Controller;
use User\Api\UserApi;
use Com\Wechat;
use Com\WechatAuth;
+use Base\Service\AdminNoticeService;
/**
* 后台用户控制器
@@ -839,4 +840,20 @@ class UserController extends AdminController
}
return $this->ajaxReturn(array('status' => 1, 'data' => $lists));
}
+
+ public function readAdminNotice()
+ {
+ $id = I('id', 0);
+ $service = new AdminNoticeService();
+ $service->read($id);
+ $this->success('标记成功');
+ }
+
+ public function deleteAdminNotice()
+ {
+ $id = I('id', 0);
+ $service = new AdminNoticeService();
+ $service->delete($id);
+ $this->success('删除成功');
+ }
}
\ No newline at end of file
diff --git a/Application/Admin/View/Mend/edit.html b/Application/Admin/View/Mend/edit.html
index 022c92554..16f777fc6 100644
--- a/Application/Admin/View/Mend/edit.html
+++ b/Application/Admin/View/Mend/edit.html
@@ -76,7 +76,7 @@
-
+
diff --git a/Application/Base/Service/AdminNoticeService.class.php b/Application/Base/Service/AdminNoticeService.class.php
new file mode 100644
index 000000000..666beb695
--- /dev/null
+++ b/Application/Base/Service/AdminNoticeService.class.php
@@ -0,0 +1,82 @@
+where([
+ 'start_time' => ['elt', time()],
+ 'end_time' => ['egt', time()],
+ '_string' => 'concat(",", admin_ids, ",") like "%,' . $uid . ',%"'
+ ])
+ ->getField('id', true);
+ if (empty($notices) || count($notices) == 0) {
+ return;
+ }
+
+ $readNotices = M('admin_notice_read', 'tab_')->where(['admin_id' => $uid, 'notice_id' => ['in', $notices]])->getField('notice_id', true);
+ $unreadNotices = $readNotices ? array_diff($notices, $readNotices) : $notices;
+
+ $records = [];
+ foreach ($unreadNotices as $noticeId) {
+ $records[] = [
+ 'notice_id' => $noticeId,
+ 'admin_id' => $uid,
+ 'create_time' => time(),
+ 'update_time' => time()
+ ];
+ }
+ M('admin_notice_read', 'tab_')->addAll($records);
+ }
+
+ public function read($id)
+ {
+ M('admin_notice_read', 'tab_')->where(['id' => $id])->save(['status' => 1, 'update_time' => time()]);
+ }
+
+ public function delete($id)
+ {
+ M('admin_notice_read', 'tab_')->where(['id' => $id])->save(['status' => 2, 'update_time' => time()]);
+ }
+
+ public function getAdminNotices($uid)
+ {
+ $items = M('admin_notice_read', 'tab_')->field(['notice_id', 'status'])->where(['admin_id' => $uid, 'status' => ['in', [0, 1]]])->order('create_time desc')->select();
+ if (empty($items) || count($items) == 0) {
+ return [];
+ }
+ $ids = array_column($items, 'notice_id');
+ $notices = M('admin_notice','tab_')
+ ->where([
+ 'id' => ['in', $ids],
+ 'start_time' => ['elt', time()],
+ 'end_time' => ['egt', time()],
+ ])
+ ->select();
+
+ if ($notices) {
+ $notices = index_by_column('id', $notices);
+ }
+
+ $records = [];
+ foreach ($items as $item) {
+ $notice = $notices[$item['notice_id']] ?? null;
+ if (is_null($notice)) {
+ continue;
+ }
+ $records[] = [
+ 'id' => $item['notice_id'],
+ 'status' => $item['status'],
+ 'type' => $notice['type'],
+ 'content' => $notice['content'],
+ 'title' => $notice['title'],
+ 'target' => $notice['target'],
+ ];
+ }
+ return $records;
+ }
+}
\ No newline at end of file
diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php
index 5c640d99c..0972f13f9 100644
--- a/Application/Base/Service/PromoteService.class.php
+++ b/Application/Base/Service/PromoteService.class.php
@@ -321,9 +321,8 @@ class PromoteService {
$toPromote = M('promote', 'tab_')->where(['id' => $toPromoteId])->find();
$fromPromote = M('promote', 'tab_')->where(['id' => $fromPromoteId])->find();
- $toPromote = $toPromote ?? ['id' => 0, 'account' => C('OFFICIEL_CHANNEL')];
- $fromPromote = $fromPromote ?? ['id' => 0, 'account' => C('OFFICIEL_CHANNEL')];
-
+ $toPromote = $toPromote ?? ['id' => 0, 'account' => C('OFFICIEL_CHANNEL'), 'company_id' => 0];
+ $fromPromote = $fromPromote ?? ['id' => 0, 'account' => C('OFFICIEL_CHANNEL'), 'company_id' => 0];
if ($fromPromote['id'] == 0 && count($shiftIds) == 0) {
return ['status' => false, 'msg' => '官方渠道玩家不能全部迁移'];
@@ -339,14 +338,26 @@ class PromoteService {
$users = M('user', 'tab_')->field(['id', 'account', 'nickname'])->where($map)->select();
$spendMap['pay_time'] = ['egt', $orderTime];
+ $spendMap['is_check'] = ['in','1,2'];
+ $spendMap['settle_check'] = 0;
+ $spendMap['selle_status'] = 0;
+ $spendMap['pay_status'] = 1;
+
$payAmountRows = M('spend', 'tab_')
- ->field(['user_id', 'sum(pay_amount) payAmount'])
+ ->field(['user_id', 'sum(pay_amount) pay_amount'])
->where($spendMap)
+ ->group('user_id')
->select();
$payAmountRows = index_by_column('user_id', $payAmountRows);
+ $users = index_by_column('id', $users);
+ $notices = [];
+ $formConpany = M('promote_company', 'tab_')->field(['company_name', 'company_belong'])->where(['id' => $fromPromote['company_id']])->find();
+ $toConpany = M('promote_company', 'tab_')->field(['company_name', 'company_belong'])->where(['id' => $toPromote['company_id']])->find();
+ $belongs = PromoteCompanyService::$belongs;
$mends = [];
foreach ($users as $item) {
+ $amount = isset($payAmountRows[$item['id']]) ? round(floatval($payAmountRows[$item['id']]['pay_amount']), 2) : 0;
$mends[] = [
'user_id' => $item['id'],
'user_account' => $item['account'],
@@ -358,12 +369,28 @@ class PromoteService {
'remark' => $remark == '' ? ($task['creator_type'] == 0 ? '后台补链' : '玩家迁移') : $remark,
'order_time' => $orderTime,
'create_time' => time(),
- 'pay_amount' => isset($payAmountRows[$item['id']]) ? intval($payAmountRows[$item['id']]['payAmount']) : 0,
+ 'pay_amount' => $amount,
'op_id' => $creator ? $creator['id'] : 0,
'op_account' => $opAccount,
'op_type' => $task['creator_type'],
'bind_type' => 1,
];
+ if ($amount > 500) {
+ $userWord = '玩家账号' . $item['account'];
+ $fromWord = $fromPromote['account'] . ($formConpany ? '(' . $belongs[$formConpany['company_belong']] . '-' . $formConpany['company_name'] : '');
+ $toWord = $toPromote['account'] . ($toConpany ? '(' . $belongs[$toConpany['company_belong']] . '-' . $toConpany['company_name'] : '');
+ $content = $userWord . ', 从' . $fromWord . '换绑到' . $toWord . ',换绑金额超过500,达到' . $amount . '元';
+ $notices[] = [
+ 'type' => 'shift-player',
+ 'title' => '换绑额度超500',
+ 'content' => $content,
+ 'admin_ids' => '1',
+ 'create_time' => time(),
+ 'target' => $item['account'],
+ 'start_time' => time(),
+ 'end_time' => time() + 7*24*3600,
+ ];
+ }
}
$model = new Model();
@@ -375,6 +402,10 @@ class PromoteService {
return ['status' => false, 'msg' => '系统异常,添加变更记录失败'];
}
+ if (count($notices) > 0) {
+ M('admin_notice', 'tab_')->addAll($notices);
+ }
+
$updateData = [
'promote_id' => $toPromote['id'],
'promote_account' => $toPromote['account']
@@ -398,15 +429,17 @@ class PromoteService {
M('user_play', 'tab_')->where($otherMap)->save($updateData);
M('user_play_info', 'tab_')->where($otherMap)->save($updateData);
- $orderMap1 = $otherMap;
- $orderMap1['pay_time'] = ['egt', $orderTime];
- M('spend', 'tab_')->where($orderMap1)->where(['is_check' => ['in','1,2'], 'settle_check' => 0, 'selle_status' => 0])->save(array_merge($updateData, $updateMarket)); // 只改未对账的数据
- M('bind_spend', 'tab_')->where($orderMap1)->save($updateData);
-
- $orderMap2 = $otherMap;
- $orderMap2['create_time'] = ['egt', $orderTime];
- M('deposit', 'tab_')->where($orderMap2)->save(array_merge($updateData, $updateMarket));
- M('user_play_data_count', 'tab_')->where($orderMap2)->save(['promote_id' => $toPromote['id']]);
+ unset($spendMap['pay_status']);
+ M('spend', 'tab_')->where($spendMap)->save(array_merge($updateData, $updateMarket)); // 只改未对账的数据
+
+ $bindMap = $otherMap;
+ $bindMap['pay_time'] = ['egt', $orderTime];
+ M('bind_spend', 'tab_')->where($bindMap)->save($updateData);
+
+ $orderMap = $otherMap;
+ $orderMap['create_time'] = ['egt', $orderTime];
+ M('deposit', 'tab_')->where($orderMap)->save(array_merge($updateData, $updateMarket));
+ M('user_play_data_count', 'tab_')->where($orderMap)->save(['promote_id' => $toPromote['id']]);
$status = M('shift_task', 'sys_')->where('id=' . $task['id'])->save(['status' => 1, 'handle_time' => time()]);
if (!$status) {
diff --git a/Data/update.sql b/Data/update.sql
index e98d14d62..70d21dfeb 100644
--- a/Data/update.sql
+++ b/Data/update.sql
@@ -2512,4 +2512,27 @@ CREATE TABLE `tab_payment_orders` (
`created_at` datetime NOT NULL COMMENT '订单创建时间',
`finished_at` datetime NOT NULL COMMENT '订单完成时间',
PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `tab_admin_notice` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `type` varchar(20) NOT NULL COMMENT '提示类型',
+ `title` varchar(32) NOT NULL COMMENT '标题',
+ `content` varchar(255) NOT NULL COMMENT '内容',
+ `admin_ids` varchar(255) NOT NULL DEFAULT '' COMMENT '接收管理员ID',
+ `target` varchar(255) NOT NULL DEFAULT '' COMMENT '对应标识',
+ `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
+ `start_time` int(11) NOT NULL DEFAULT '0' COMMENT '展示开始时间',
+ `end_time` int(11) NOT NULL DEFAULT '0' COMMENT '展示结束时间',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `tab_admin_notice_read` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `notice_id` int(11) NOT NULL COMMENT '通知ID',
+ `admin_id` int(11) NOT NULL COMMENT '管理员ID',
+ `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
+ `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
+ `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态 0 未读 1 已读',
+ PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
|