细节优化,用户添加增加前钩子

This commit is contained in:
gongfuxiang 2023-05-15 10:18:19 +08:00
parent af7e8c141f
commit 3912a4f903
21 changed files with 114 additions and 87 deletions

View File

@ -113,7 +113,8 @@ class Common extends BaseController
$this->admin = AdminService::LoginInfo();
// 权限菜单
$menu = AdminPowerService::PowerMenuInit($this->admin);
$is_refresh = !empty($this->data_request['lang']);
$menu = AdminPowerService::PowerMenuInit($this->admin, $is_refresh);
$this->left_menu = $menu['admin_left_menu'];
// 视图初始化

View File

@ -55,7 +55,7 @@ class Answer extends Common
// 分页
$number = 10;
$page = max(1, isset($this->data_post['page']) ? intval($this->data_post['page']) : 1);
$page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1);
// 条件
$where = AnswerService::AnswerListWhere($params);
@ -95,7 +95,7 @@ class Answer extends Common
// 登录校验
$this->IsLogin();
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(AnswerService::AnswerSave($params));
}
@ -117,7 +117,7 @@ class Answer extends Common
// 分页
$number = 10;
$page = max(1, isset($this->data_post['page']) ? intval($this->data_post['page']) : 1);
$page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1);
// 条件
$where = AnswerService::AnswerListWhere($params);

View File

@ -71,11 +71,11 @@ class Article extends Common
public function DataList()
{
// 参数
$params = $this->data_post;
$params = $this->data_request;
// 分页
$number = 10;
$page = max(1, isset($this->data_post['page']) ? intval($this->data_post['page']) : 1);
$page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1);
// 条件
$where = ArticleService::ArticleWhere($params);

View File

@ -34,7 +34,7 @@ class Base extends Common
public function Common()
{
// 参数
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(SystemBaseService::Common($params));
}

View File

@ -52,7 +52,7 @@ class Buy extends Common
public function Index()
{
// 获取商品列表
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
// 默认支付方式
@ -98,7 +98,7 @@ class Buy extends Common
*/
public function Add()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(BuyService::OrderInsert($params));
}

View File

@ -67,7 +67,7 @@ class Cart extends Common
*/
public function Save()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(GoodsCartService::GoodsCartSave($params));
}
@ -82,7 +82,7 @@ class Cart extends Common
*/
public function Delete()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(GoodsCartService::GoodsCartDelete($params));
}
@ -97,7 +97,7 @@ class Cart extends Common
*/
public function Stock()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(GoodsCartService::GoodsCartStock($params));
}

View File

@ -55,7 +55,7 @@ class Goods extends Common
public function Detail()
{
// 参数
$goods_id = empty($this->data_post['id']) ? (empty($this->data_post['goods_id']) ? 0 : intval($this->data_post['goods_id'])) : intval($this->data_post['id']);
$goods_id = empty($this->data_request['id']) ? (empty($this->data_request['goods_id']) ? 0 : intval($this->data_request['goods_id'])) : intval($this->data_request['id']);
if(empty($goods_id))
{
$ret = DataReturn(MyLang('params_error_tips'), -1);
@ -149,7 +149,7 @@ class Goods extends Common
$this->IsLogin();
// 开始操作
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(GoodsFavorService::GoodsFavorCancel($params));
}
@ -165,7 +165,7 @@ class Goods extends Common
public function SpecType()
{
// 开始处理
$params = $this->data_post;
$params = $this->data_request;
$ret = GoodsService::GoodsSpecType($params);
return ApiService::ApiDataReturn($ret);
}
@ -181,7 +181,7 @@ class Goods extends Common
public function SpecDetail()
{
// 开始处理
$params = $this->data_post;
$params = $this->data_request;
$ret = GoodsService::GoodsSpecDetail($params);
return ApiService::ApiDataReturn($ret);
}
@ -197,7 +197,7 @@ class Goods extends Common
public function Stock()
{
// 开始处理
$params = $this->data_post;
$params = $this->data_request;
$ret = GoodsService::GoodsStock($params);
return ApiService::ApiDataReturn($ret);
}
@ -213,7 +213,7 @@ class Goods extends Common
public function Category()
{
$result = [
'category' => GoodsCategoryService::GoodsCategoryAll($this->data_post),
'category' => GoodsCategoryService::GoodsCategoryAll($this->data_request),
];
return ApiService::ApiDataReturn(SystemBaseService::DataReturn($result));
}
@ -228,12 +228,12 @@ class Goods extends Common
*/
public function GoodsScore()
{
if(empty($this->data_post['goods_id']))
if(empty($this->data_request['goods_id']))
{
$ret = DataReturn(MyLang('params_error_tips'), -1);
} else {
// 获取商品评分
$data = GoodsCommentsService::GoodsCommentsScore($this->data_post['goods_id']);
$data = GoodsCommentsService::GoodsCommentsScore($this->data_request['goods_id']);
$ret = DataReturn('success', 0, $data);
}
return ApiService::ApiDataReturn($ret);
@ -249,7 +249,7 @@ class Goods extends Common
public function Comments()
{
// 参数
$params = $this->data_post;
$params = $this->data_request;
// 分页
$number = 10;

View File

@ -49,7 +49,7 @@ class Message extends Common
public function Index()
{
// 参数
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
// 消息更新未已读
@ -57,7 +57,7 @@ class Message extends Common
// 分页
$number = 10;
$page = max(1, isset($this->data_post['page']) ? intval($this->data_post['page']) : 1);
$page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1);
// 条件
$where = MessageService::MessageListWhere($params);

View File

@ -53,13 +53,13 @@ class Order extends Common
public function Index()
{
// 参数
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
$params['user_type'] = 'user';
// 分页
$number = 10;
$page = max(1, isset($this->data_post['page']) ? intval($this->data_post['page']) : 1);
$page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1);
// 条件
$where = OrderService::OrderListWhere($params);
@ -102,7 +102,7 @@ class Order extends Common
public function Detail()
{
// 参数
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
$params['user_type'] = 'user';
if(!empty($params['id']))
@ -154,7 +154,7 @@ class Order extends Common
public function Comments()
{
// 参数
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
$params['user_type'] = 'user';
if(empty($params['id']))
@ -200,7 +200,7 @@ class Order extends Common
*/
public function CommentsSave()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
$params['business_type'] = 'order';
return ApiService::ApiDataReturn(GoodsCommentsService::Comments($params));
@ -216,7 +216,7 @@ class Order extends Common
*/
public function Pay()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(OrderService::Pay($params));
}
@ -231,7 +231,7 @@ class Order extends Common
*/
public function Cancel()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user_id'] = $this->user['id'];
$params['creator'] = $this->user['id'];
$params['creator_name'] = $this->user['user_name_view'];
@ -247,7 +247,7 @@ class Order extends Common
*/
public function Collect()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user_id'] = $this->user['id'];
$params['creator'] = $this->user['id'];
$params['creator_name'] = $this->user['user_name_view'];
@ -264,7 +264,7 @@ class Order extends Common
*/
public function Delete()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user_id'] = $this->user['id'];
$params['creator'] = $this->user['id'];
$params['creator_name'] = $this->user['user_name_view'];
@ -282,7 +282,7 @@ class Order extends Common
*/
public function PayCheck()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(OrderService::OrderPayCheck($params));
}

View File

@ -51,13 +51,13 @@ class Orderaftersale extends Common
public function Index()
{
// 参数
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
$params['user_type'] = 'user';
// 分页
$number = 10;
$page = max(1, isset($this->data_post['page']) ? intval($this->data_post['page']) : 1);
$page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1);
// 条件
$where = OrderAftersaleService::OrderAftersaleListWhere($params);
@ -95,8 +95,8 @@ class Orderaftersale extends Common
*/
public function Aftersale()
{
$order_id = isset($this->data_post['oid']) ? intval($this->data_post['oid']) : 0;
$order_detail_id = isset($this->data_post['did']) ? intval($this->data_post['did']) : 0;
$order_id = isset($this->data_request['oid']) ? intval($this->data_request['oid']) : 0;
$order_detail_id = isset($this->data_request['did']) ? intval($this->data_request['did']) : 0;
$ret = OrderAftersaleService::OrdferGoodsRow($order_id, $order_detail_id, $this->user['id']);
if($ret['code'] == 0)
{
@ -162,7 +162,7 @@ class Orderaftersale extends Common
*/
public function Create()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(OrderAftersaleService::AftersaleCreate($params));
}
@ -177,7 +177,7 @@ class Orderaftersale extends Common
*/
public function Delivery()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(OrderAftersaleService::AftersaleDelivery($params));
}
@ -192,7 +192,7 @@ class Orderaftersale extends Common
*/
public function Cancel()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(OrderAftersaleService::AftersaleCancel($params));
}

View File

@ -67,7 +67,7 @@ class Personal extends Common
*/
public function Save()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(UserService::PersonalSave($params));
}
@ -82,7 +82,7 @@ class Personal extends Common
*/
public function UserAvatarUpload()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
$params['img_field'] = 'file';
return ApiService::ApiDataReturn(UserService::UserAvatarUpload($params));

View File

@ -80,7 +80,7 @@ class Region extends Common
*/
public function CodeData()
{
return ApiService::ApiDataReturn(RegionService::RegionCodeData($this->data_post));
return ApiService::ApiDataReturn(RegionService::RegionCodeData($this->data_request));
}
}
?>

View File

@ -47,7 +47,7 @@ class Safety extends Common
*/
public function Logout()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(SafetyService::AccountsLogout($params));
}

View File

@ -47,7 +47,7 @@ class Search extends Common
public function Index()
{
// 搜素条件
$map = SearchService::SearchWhereHandle($this->data_post);
$map = SearchService::SearchWhereHandle($this->data_request);
// 返回数据
$result = [
@ -78,15 +78,15 @@ class Search extends Common
public function DataList()
{
// 搜素条件
$map = SearchService::SearchWhereHandle($this->data_post);
$map = SearchService::SearchWhereHandle($this->data_request);
// 获取数据
$ret = SearchService::GoodsList($map, $this->data_post);
$ret = SearchService::GoodsList($map, $this->data_request);
// 搜索记录
$this->data_post['user_id'] = isset($this->user['id']) ? $this->user['id'] : 0;
$this->data_post['search_result_data'] = $ret['data'];
SearchService::SearchAdd($this->data_post);
$this->data_request['user_id'] = isset($this->user['id']) ? $this->user['id'] : 0;
$this->data_request['search_result_data'] = $ret['data'];
SearchService::SearchAdd($this->data_request);
// 返回数据
return ApiService::ApiDataReturn(SystemBaseService::DataReturn($ret['data']));

View File

@ -56,7 +56,7 @@ class User extends Common
*/
public function Login()
{
return ApiService::ApiDataReturn(UserService::Login($this->data_post));
return ApiService::ApiDataReturn(UserService::Login($this->data_request));
}
/**
@ -69,7 +69,7 @@ class User extends Common
*/
public function LoginVerifySend()
{
return ApiService::ApiDataReturn(UserService::LoginVerifySend($this->data_post));
return ApiService::ApiDataReturn(UserService::LoginVerifySend($this->data_request));
}
/**
@ -82,7 +82,7 @@ class User extends Common
*/
public function Reg()
{
return ApiService::ApiDataReturn(UserService::Reg($this->data_post));
return ApiService::ApiDataReturn(UserService::Reg($this->data_request));
}
/**
@ -95,7 +95,7 @@ class User extends Common
*/
public function RegVerifySend()
{
return ApiService::ApiDataReturn(UserService::RegVerifySend($this->data_post));
return ApiService::ApiDataReturn(UserService::RegVerifySend($this->data_request));
}
/**
@ -108,7 +108,7 @@ class User extends Common
*/
public function ForgetPwd()
{
return ApiService::ApiDataReturn(UserService::ForgetPwd($this->data_post));
return ApiService::ApiDataReturn(UserService::ForgetPwd($this->data_request));
}
/**
@ -121,7 +121,7 @@ class User extends Common
*/
public function ForgetPwdVerifySend()
{
return ApiService::ApiDataReturn(UserService::ForgetPwdVerifySend($this->data_post));
return ApiService::ApiDataReturn(UserService::ForgetPwdVerifySend($this->data_request));
}
/**
@ -134,7 +134,7 @@ class User extends Common
*/
public function AppMobileBind()
{
return ApiService::ApiDataReturn(UserService::AppMobileBind($this->data_post));
return ApiService::ApiDataReturn(UserService::AppMobileBind($this->data_request));
}
/**
@ -147,7 +147,7 @@ class User extends Common
*/
public function AppMobileBindVerifySend()
{
return ApiService::ApiDataReturn(UserService::AppMobileBindVerifySend($this->data_post));
return ApiService::ApiDataReturn(UserService::AppMobileBindVerifySend($this->data_request));
}
/**
@ -196,7 +196,7 @@ class User extends Common
$action = ucfirst(APPLICATION_CLIENT_TYPE).'UserAuth';
if(method_exists($module, $action))
{
$ret = AppMiniUserService::$action($this->data_post);
$ret = AppMiniUserService::$action($this->data_request);
} else {
$ret = DataReturn('方法未定义['.$action.']', -1);
}
@ -217,7 +217,7 @@ class User extends Common
$action = ucfirst(APPLICATION_CLIENT_TYPE).'UserInfo';
if(method_exists($module, $action))
{
$ret = AppMiniUserService::$action($this->data_post);
$ret = AppMiniUserService::$action($this->data_request);
} else {
$ret = DataReturn('方法未定义['.$action.']', -1);
}
@ -297,7 +297,7 @@ class User extends Common
*/
public function OnekeyUserMobileBind()
{
return ApiService::ApiDataReturn(AppMiniUserService::AppMiniOnekeyUserMobileBind($this->data_post));
return ApiService::ApiDataReturn(AppMiniUserService::AppMiniOnekeyUserMobileBind($this->data_request));
}
}
?>

View File

@ -68,7 +68,7 @@ class UserAddress extends Common
*/
public function Detail()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
$data = empty($params['id']) ? [] : UserAddressService::UserAddressRow($params);
@ -90,7 +90,7 @@ class UserAddress extends Common
*/
public function Save()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(UserAddressService::UserAddressSave($params));
}
@ -105,7 +105,7 @@ class UserAddress extends Common
*/
public function Delete()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(UserAddressService::UserAddressDelete($params));
}
@ -120,7 +120,7 @@ class UserAddress extends Common
*/
public function SetDefault()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(UserAddressService::UserAddressDefault($params));
}
@ -135,7 +135,7 @@ class UserAddress extends Common
*/
public function Extraction()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(ConfigService::SiteTypeExtractionAddressList(null, $params));
}
@ -150,7 +150,7 @@ class UserAddress extends Common
*/
public function OutSystemAdd()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(UserAddressService::OutSystemUserAddressAdd($params));
}

View File

@ -50,12 +50,12 @@ class UserGoodsBrowse extends Common
public function Index()
{
// 参数
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
// 分页
$number = 10;
$page = max(1, isset($this->data_post['page']) ? intval($this->data_post['page']) : 1);
$page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1);
// 条件
$where = GoodsBrowseService::UserGoodsBrowseListWhere($params);
@ -92,7 +92,7 @@ class UserGoodsBrowse extends Common
*/
public function Delete()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(GoodsBrowseService::GoodsBrowseDelete($params));
}

View File

@ -54,7 +54,7 @@ class UserGoodsFavor extends Common
// 分页
$number = 10;
$page = max(1, isset($this->data_post['page']) ? intval($this->data_post['page']) : 1);
$page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1);
// 条件
$where = GoodsFavorService::UserGoodsFavorListWhere($params);
@ -91,7 +91,7 @@ class UserGoodsFavor extends Common
*/
public function Cancel()
{
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(GoodsFavorService::GoodsFavorCancel($params));
}

View File

@ -50,12 +50,12 @@ class UserIntegral extends Common
public function Index()
{
// 参数
$params = $this->data_post;
$params = $this->data_request;
$params['user'] = $this->user;
// 分页
$number = 10;
$page = max(1, isset($this->data_post['page']) ? intval($this->data_post['page']) : 1);
$page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1);
// 条件
$where = IntegralService::UserIntegralLogListWhere($params);

View File

@ -294,11 +294,13 @@ class OrderService
// 发起支付处理钩子
$hook_name = 'plugins_service_order_pay_launch_handle';
$ret = EventReturnHandle(MyEventTrigger($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'order_ids' => $order_ids,
'params' => &$params,
'pay_data' => &$pay_data,
'hook_name' => $hook_name,
'is_backend' => true,
'pay_log_id' => $pay_log['data']['id'],
'pay_log_no' => $pay_log['data']['log_no'],
'order_ids' => $order_ids,
'params' => &$params,
'pay_data' => &$pay_data,
]));
if(isset($ret['code']) && $ret['code'] != 0)
{

View File

@ -2573,6 +2573,16 @@ class UserService
}
}
// 注册添加之前钩子
$hook_name = 'plugins_service_user_register_begin';
MyEventTrigger($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'params' => &$params,
'user_base' => &$user_base,
'user_platform' => &$user_platform,
]);
// 用户信息以手机或邮箱、不存在则添加
$user_base['add_time'] = time();
$user_id = Db::name('User')->insertGetId($user_base);
@ -2592,7 +2602,11 @@ class UserService
self::UserNumberCodeCreatedHandle($user_id);
// 清除推荐id
MySession('share_referrer_id', null);
if(!empty($user_base['referrer']))
{
MySession('share_referrer_id', null);
MyCookie('share_referrer_id', null);
}
// 返回前端html代码
$body_html = [];
@ -3169,15 +3183,25 @@ class UserService
public static function UserReferrerDecrypt($params = [])
{
// 推荐人
$referrer = empty($params['referrer']) ? MySession('share_referrer_id') : $params['referrer'];
// 查看用户id是否已加密
if(preg_match('/[a-zA-Z]/', $referrer))
if(empty($params['referrer']))
{
$referrer = base64_decode(AsciiToStr($referrer));
$referrer = MySession('share_referrer_id');
if(empty($referrer))
{
$referrer = MyCookie('share_referrer_id');
}
} else {
$referrer = $params['referrer'];
}
return intval($referrer);
if(!empty($referrer))
{
// 查看用户id是否已加密
if(preg_match('/[a-zA-Z]/', $referrer))
{
return intval(base64_decode(AsciiToStr($referrer)));
}
}
return 0;
}
}
?>