diff --git a/application/admin/form/Message.php b/application/admin/form/Message.php index f58921f47..c085a83b2 100644 --- a/application/admin/form/Message.php +++ b/application/admin/form/Message.php @@ -91,13 +91,11 @@ class Message 'label' => '业务类型', 'view_type' => 'field', 'view_key' => 'business_type', - 'view_data_key' => 'name', - 'view_data' => lang('common_business_type_list'), 'search_config' => [ 'form_type' => 'select', 'where_type' => 'in', - 'data' => lang('common_business_type_list'), - 'data_key' => 'id', + 'data' => $this->MessageBusinessTypeList(), + 'data_key' => 'name', 'data_name' => 'name', 'is_multiple' => 1, ], @@ -183,5 +181,18 @@ class Message } return $value; } + + /** + * 业务类型 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-06-26 + * @desc description + */ + public function MessageBusinessTypeList() + { + return Db::name('Message')->field('business_type as name')->group('business_type')->select(); + } } ?> \ No newline at end of file diff --git a/application/api/controller/Devtest.php b/application/api/controller/Devtest.php index c80856947..4aeba30ee 100644 --- a/application/api/controller/Devtest.php +++ b/application/api/controller/Devtest.php @@ -396,5 +396,54 @@ class Devtest extends Common } echo 'count:'.count($data).', success:'.$success.', fail:'.$fail; } + + /** + * 消息数据处理 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-07-26 + * @desc description + */ + public function MessageHandle() + { + if(input('pwd') != 'shopxo520') + { + die('非法访问'); + } + + // 状态 + $success = 0; + $fail = 0; + + + // 获取日志 + $data = Db::name('Message')->where(['is_handle'=>0])->limit(0, 500)->select(); + if(!empty($data)) + { + $business_type_list = [ + 0 => '默认', + 1 => '订单', + 2 => '充值', + 3 => '提现', + ]; + foreach($data as $v) + { + $upd_data = [ + 'is_handle' => 1, + 'business_type' => isset($business_type_list[$v['business_type']]) ? $business_type_list[$v['business_type']] : $v['business_type'], + ]; + + // 更新操作 + if(Db::name('Message')->where(['is_handle'=>0, 'id'=>$v['id']])->update($upd_data)) + { + $success++; + } else { + $fail++; + } + } + } + echo 'count:'.count($data).', success:'.$success.', fail:'.$fail; + } } ?> \ No newline at end of file diff --git a/application/index/controller/Message.php b/application/index/controller/Message.php index 837b866c1..f00bde531 100755 --- a/application/index/controller/Message.php +++ b/application/index/controller/Message.php @@ -69,6 +69,9 @@ class Message extends Common ]; $ret = MessageService::MessageList($data_params); + // 消息更新未已读 + MessageService::MessageRead(['user'=>$this->user]); + // 浏览器名称 $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('我的消息', 1)); diff --git a/application/index/form/Message.php b/application/index/form/Message.php index cc8b3bfc8..3249a67a7 100644 --- a/application/index/form/Message.php +++ b/application/index/form/Message.php @@ -83,13 +83,11 @@ class Message 'label' => '业务类型', 'view_type' => 'field', 'view_key' => 'business_type', - 'view_data_key' => 'name', - 'view_data' => lang('common_business_type_list'), 'search_config' => [ 'form_type' => 'select', 'where_type' => 'in', - 'data' => lang('common_business_type_list'), - 'data_key' => 'id', + 'data' => $this->MessageBusinessTypeList(), + 'data_key' => 'name', 'data_name' => 'name', 'is_multiple' => 1, ], @@ -147,5 +145,18 @@ class Message ], ]; } + + /** + * 业务类型 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-06-26 + * @desc description + */ + public function MessageBusinessTypeList() + { + return Db::name('Message')->field('business_type as name')->group('business_type')->select(); + } } ?> \ No newline at end of file diff --git a/application/install/controller/Index.php b/application/install/controller/Index.php index b1f7b8b92..c538476f7 100755 --- a/application/install/controller/Index.php +++ b/application/install/controller/Index.php @@ -226,7 +226,7 @@ class Index extends Common */ private function CreateConfig($params = []) { - // 配置文件信息处理 + // 配置文件信息处理 $db_str=<< array('id' => 1, 'name' => '微信'), ), - // 业务类型 - 'common_business_type_list' => array( - 0 => array('id' => 0, 'name' => '默认', 'checked' => true), - 1 => array('id' => 1, 'name' => '订单'), - 2 => array('id' => 2, 'name' => '充值'), - 3 => array('id' => 3, 'name' => '提现'), - ), - // 用户积分 - 操作类型 'common_integral_log_type_list' => array( 0 => array('id' => 0, 'name' => '减少', 'checked' => true), diff --git a/application/service/CrontabService.php b/application/service/CrontabService.php index 1e321d71c..f883f6712 100644 --- a/application/service/CrontabService.php +++ b/application/service/CrontabService.php @@ -66,7 +66,7 @@ class CrontabService if($ret['code'] == 0) { // 用户消息 - MessageService::MessageAdd($v['user_id'], '订单关闭', '订单超时关闭', 1, $v['id']); + MessageService::MessageAdd($v['user_id'], '订单关闭', '订单超时关闭', '订单', $v['id']); // 订单状态日志 OrderService::OrderHistoryAdd($v['id'], $upd_data['status'], $v['status'], '超时关闭', 0, '系统'); @@ -130,7 +130,7 @@ class CrontabService if($ret['code'] == 0) { // 用户消息 - MessageService::MessageAdd($v['user_id'], '订单收货', '订单自动收货成功', 1, $v['id']); + MessageService::MessageAdd($v['user_id'], '订单收货', '订单自动收货成功', '订单', $v['id']); // 订单状态日志 OrderService::OrderHistoryAdd($v['id'], $upd_data['status'], $v['status'], '自动收货', 0, '系统'); diff --git a/application/service/IntegralService.php b/application/service/IntegralService.php index 6bf013009..eb75c3351 100755 --- a/application/service/IntegralService.php +++ b/application/service/IntegralService.php @@ -49,11 +49,12 @@ class IntegralService 'add_time' => time(), ); $data['new_integral'] = ($data['type'] == 1) ? $data['original_integral']+$data['operation_integral'] : $data['original_integral']-$data['operation_integral']; - if(Db::name('UserIntegralLog')->insertGetId($data) > 0) + $log_id = Db::name('UserIntegralLog')->insertGetId($data); + if($log_id > 0) { $type_msg = lang('common_integral_log_type_list')[$type]['name']; $detail = $msg.'积分'.$type_msg.$operation_integral; - MessageService::MessageAdd($user_id, '积分变动', $detail); + MessageService::MessageAdd($user_id, '积分变动', $detail, '积分', $log_id); return true; } return false; diff --git a/application/service/MessageService.php b/application/service/MessageService.php index bf083fde2..78fdccf21 100755 --- a/application/service/MessageService.php +++ b/application/service/MessageService.php @@ -32,18 +32,18 @@ class MessageService * @param [int] $user_id [用户id] * @param [string] $title [标题] * @param [string] $detail [内容] - * @param [int] $business_type [业务类型(0默认, 1订单, 2充值, 3提现, ...)] + * @param [string] $business_type [业务类型(默认, 如:订单, 充值, 提现, ...)] * @param [int] $business_id [业务id] * @param [int] $type [类型(默认0 普通消息)] * @return [boolean] [成功true, 失败false] */ - public static function MessageAdd($user_id, $title, $detail, $business_type = 0, $business_id = 0, $type = 0) + public static function MessageAdd($user_id, $title, $detail, $business_type = '默认', $business_id = 0, $type = 0) { $data = array( 'title' => $title, 'detail' => $detail, 'user_id' => intval($user_id), - 'business_type' => intval($business_type), + 'business_type' => trim($business_type), 'business_id' => intval($business_id), 'type' => intval($type), 'is_read' => 0, @@ -90,9 +90,9 @@ class MessageService if(isset($params['is_more']) && $params['is_more'] == 1) { // 等值 - if(isset($params['business_type']) && $params['business_type'] > -1) + if(!empty($params['business_type'])) { - $where[] = ['business_type', '=', intval($params['business_type'])]; + $where[] = ['business_type', '=', $params['business_type']]; } if(isset($params['type']) && $params['type'] > -1) { @@ -180,7 +180,6 @@ class MessageService $data = Db::name('Message')->where($where)->field($field)->limit($m, $n)->order($order_by)->select(); if(!empty($data)) { - $common_business_type_list = lang('common_business_type_list'); $common_is_read_list = lang('common_is_read_list'); $common_message_type_list = lang('common_message_type_list'); foreach($data as &$v) @@ -200,9 +199,6 @@ class MessageService // 是否已读 $v['is_read_text'] = $common_is_read_list[$v['is_read']]['name']; - // 业务类型 - $v['business_type_text'] = $common_business_type_list[$v['business_type']]['name']; - // 用户是否已删除 $v['user_is_delete_time_text'] = ($v['user_is_delete_time'] == 0) ? '否' : '是'; diff --git a/application/service/OrderAftersaleService.php b/application/service/OrderAftersaleService.php index 3b6d5baa0..76d8013c3 100644 --- a/application/service/OrderAftersaleService.php +++ b/application/service/OrderAftersaleService.php @@ -987,7 +987,7 @@ class OrderAftersaleService // 消息通知 $detail = '订单退款成功,金额'.PriceBeautify($aftersale['price']).'元'; - MessageService::MessageAdd($order['data']['user_id'], '订单退款', $detail, 1, $order['data']['id']); + MessageService::MessageAdd($order['data']['user_id'], '订单退款', $detail, '订单售后', $order['data']['id']); // 订单状态日志 if(isset($order_upd_data['status'])) @@ -1187,7 +1187,7 @@ class OrderAftersaleService RefundLogService::RefundLogInsert($refund_log); // 消息通知 - MessageService::MessageAdd($order['user_id'], '账户余额变动', $msg, 1, $order['id']); + MessageService::MessageAdd($order['user_id'], '账户余额变动', $msg, '订单售后', $order['id']); return DataReturn('退款成功', 0); } diff --git a/application/service/OrderService.php b/application/service/OrderService.php index 6479395cc..638339888 100755 --- a/application/service/OrderService.php +++ b/application/service/OrderService.php @@ -32,7 +32,7 @@ use app\service\OrderAftersaleService; class OrderService { // 业务类型名称 - public static $business_type_name = '订单'; + public static $message_business_type = '订单'; /** * 订单支付 @@ -309,7 +309,7 @@ class OrderService 'subject' => '订单支付', 'payment' => isset($params['payment']) ? $params['payment'] : '', 'payment_name' => isset($params['payment_name']) ? $params['payment_name'] : '', - 'business_type' => self::$business_type_name, + 'business_type' => self::$message_business_type, ]); } @@ -691,7 +691,7 @@ class OrderService // 消息通知 $detail = '订单支付成功,金额'.PriceBeautify($order['total_price']).'元'; - MessageService::MessageAdd($order['user_id'], '订单支付', $detail, 1, $order['id']); + MessageService::MessageAdd($order['user_id'], '订单支付', $detail, self::$message_business_type, $order['id']); // 订单更新数据 $upd_data = [ @@ -1468,7 +1468,7 @@ class OrderService } // 用户消息 - MessageService::MessageAdd($order['user_id'], '订单取消', '订单取消成功', 1, $order['id']); + MessageService::MessageAdd($order['user_id'], '订单取消', '订单取消成功', self::$message_business_type, $order['id']); // 订单状态日志 $creator = isset($params['creator']) ? intval($params['creator']) : 0; @@ -1601,7 +1601,7 @@ class OrderService } // 用户消息 - MessageService::MessageAdd($order['user_id'], '订单发货', '订单已发货', 1, $order['id']); + MessageService::MessageAdd($order['user_id'], '订单发货', '订单已发货', self::$message_business_type, $order['id']); // 订单状态日志 $creator = isset($params['creator']) ? intval($params['creator']) : 0; @@ -1691,7 +1691,7 @@ class OrderService } // 用户消息 - MessageService::MessageAdd($order['user_id'], '订单收货', '订单收货成功', 1, $order['id']); + MessageService::MessageAdd($order['user_id'], '订单收货', '订单收货成功', self::$message_business_type, $order['id']); // 订单状态日志 $creator = isset($params['creator']) ? intval($params['creator']) : 0; @@ -1772,7 +1772,7 @@ class OrderService } // 用户消息 - MessageService::MessageAdd($order['user_id'], '订单确认', '订单确认成功', 1, $order['id']); + MessageService::MessageAdd($order['user_id'], '订单确认', '订单确认成功', self::$message_business_type, $order['id']); // 订单状态日志 $creator = isset($params['creator']) ? intval($params['creator']) : 0; @@ -1860,7 +1860,7 @@ class OrderService if(Db::name('Order')->where($where)->update($data)) { // 用户消息 - MessageService::MessageAdd($order['user_id'], '订单删除', '订单删除成功', 1, $order['id']); + MessageService::MessageAdd($order['user_id'], '订单删除', '订单删除成功', self::$message_business_type, $order['id']); return DataReturn('删除成功', 0); } diff --git a/application/tags.php b/application/tags.php index 7fb4b4ce8..918c436ba 100755 --- a/application/tags.php +++ b/application/tags.php @@ -32,5 +32,17 @@ return array ( 'log_write' => array ( ), + 'plugins_css' => + array ( + 0 => 'app\\plugins\\freightfee\\Hook', + ), + 'plugins_service_buy_group_goods_handle' => + array ( + 0 => 'app\\plugins\\freightfee\\Hook', + ), + 'plugins_view_goods_detail_title' => + array ( + 0 => 'app\\plugins\\freightfee\\Hook', + ), ); ?> \ No newline at end of file