diff --git a/app/data/controller/api/Goods.php b/app/data/controller/api/Goods.php index 42f3cc533..c649b743b 100644 --- a/app/data/controller/api/Goods.php +++ b/app/data/controller/api/Goods.php @@ -58,6 +58,6 @@ class Goods extends Controller */ public function getRegion() { - $this->success('获取区域成功', ExpressService::instance()->region(3, 1)); + $this->success('获取区域成功', ExpressService::region(3, 1)); } } \ No newline at end of file diff --git a/app/data/controller/api/Login.php b/app/data/controller/api/Login.php index b7f4c21c2..6ef763885 100644 --- a/app/data/controller/api/Login.php +++ b/app/data/controller/api/Login.php @@ -50,8 +50,8 @@ class Login extends Controller 'password.require' => '登录密码不能为空!', ]); $map = ['deleted' => 0, 'phone' => $data['phone']]; - $user = DataUser::mk()->where($map)->find(); - if (empty($user)) $this->error('该手机号还没有注册哦!'); + $user = DataUser::mk()->where($map)->findOrEmpty(); + if ($user->isEmpty()) $this->error('该手机号还没有注册哦!'); if (empty($user['status'])) $this->error('该用户账号状态异常!'); if (md5($data['password']) === $user['password']) { $this->success('手机登录成功!', UserAdminService::set($map, [], $this->type, true)); diff --git a/app/data/controller/api/News.php b/app/data/controller/api/News.php index e16ffaf46..28b7923d9 100644 --- a/app/data/controller/api/News.php +++ b/app/data/controller/api/News.php @@ -65,5 +65,4 @@ class News extends Controller NewsService::instance()->buildListByUidAndCode($result['list']); $this->success('获取评论成功', $result); } - } \ No newline at end of file diff --git a/app/data/controller/api/Notify.php b/app/data/controller/api/Notify.php index 14510e13d..e8a076dab 100644 --- a/app/data/controller/api/Notify.php +++ b/app/data/controller/api/Notify.php @@ -19,11 +19,7 @@ class Notify extends Controller * @param string $scene 支付场景 * @param string $param 支付参数 * @return string - * @throws \WeChat\Exceptions\InvalidResponseException * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException */ public function wxpay(string $scene = 'order', string $param = ''): string { @@ -39,11 +35,7 @@ class Notify extends Controller * @param string $scene 支付场景 * @param string $param 支付参数 * @return string - * @throws \WeChat\Exceptions\InvalidResponseException * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException */ public function alipay(string $scene = 'order', string $param = ''): string { @@ -59,11 +51,7 @@ class Notify extends Controller * @param string $scene 支付场景 * @param string $param 支付参数 * @return string - * @throws \WeChat\Exceptions\InvalidResponseException * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException */ public function joinpay(string $scene = 'order', string $param = ''): string { diff --git a/app/data/controller/api/auth/Balance.php b/app/data/controller/api/auth/Balance.php index d4892a3a2..f51f9d37a 100644 --- a/app/data/controller/api/auth/Balance.php +++ b/app/data/controller/api/auth/Balance.php @@ -4,6 +4,7 @@ namespace app\data\controller\api\auth; use app\data\controller\api\Auth; use app\data\model\DataUserBalance; +use think\admin\helper\QueryHelper; /** * 用户余额转账 @@ -14,14 +15,13 @@ class Balance extends Auth { /** * 获取用户余额记录 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException */ public function get() { - $query = DataUserBalance::mQuery()->withoutField('deleted,create_by'); - $query->where(['uuid' => $this->uuid, 'deleted' => 0])->like('create_at#date'); - $this->success('获取数据成功', $query->order('id desc')->page(true, false, false, 10)); + DataUserBalance::mQuery(null, function (QueryHelper $query) { + $query->withoutField('deleted,create_by'); + $query->where(['uuid' => $this->uuid, 'deleted' => 0])->like('create_at#date'); + $this->success('获取数据成功', $query->order('id desc')->page(true, false, false, 10)); + }); } } \ No newline at end of file diff --git a/app/data/controller/api/auth/Center.php b/app/data/controller/api/auth/Center.php index fd395d804..7327d932e 100644 --- a/app/data/controller/api/auth/Center.php +++ b/app/data/controller/api/auth/Center.php @@ -118,8 +118,7 @@ class Center extends Auth $map[] = ['deleted', '=', 0]; $map[] = ['path', 'like', "%-{$this->uuid}-%"]; // 查询邀请的朋友 - $query = DataUser::mQuery(); - $query->like('nickname|username#nickname')->equal('vip_code,pids,pid1,id#uuid'); + $query = DataUser::mQuery()->like('nickname|username#nickname')->equal('vip_code,pids,pid1,id#uuid'); $query->field('id,pid0,pid1,pid2,pids,username,nickname,headimg,order_amount_total,teams_amount_total,teams_amount_direct,teams_amount_indirect,teams_users_total,teams_users_direct,teams_users_indirect,rebate_total,rebate_used,rebate_lock,create_at'); $result = $query->where($map)->order('id desc')->page(true, false, false, 15); // 统计当前用户所有下属数 @@ -143,9 +142,9 @@ class Center extends Auth $data = $this->_vali(['from.require' => '邀请人不能为空']); [$state, $message] = UserUpgradeService::instance()->bindAgent($this->uuid, $data['from'], 0); if ($state) { - $this->success($message, UserAdminService::instance()->total($this->uuid)); + $this->success($message, UserAdminService::total($this->uuid)); } else { - $this->error($message, UserAdminService::instance()->total($this->uuid)); + $this->error($message, UserAdminService::total($this->uuid)); } } } \ No newline at end of file diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index e62c265a9..a514079e9 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -403,7 +403,7 @@ class Order extends Auth { [$map, $order] = $this->getOrderData(); if (empty($order)) $this->error('读取订单失败'); - if (in_array($order['status'], [0])) { + if ($order['status'] == 0) { $result = ShopOrder::mk()->where($map)->update([ 'status' => 0, 'deleted_status' => 1, @@ -430,7 +430,7 @@ class Order extends Auth public function confirm() { [$map, $order] = $this->getOrderData(); - if (in_array($order['status'], [5])) { + if ($order['status'] == 5) { if (ShopOrder::mk()->where($map)->update(['status' => 6]) !== false) { // 触发订单确认事件 $this->app->event->trigger('ShopOrderConfirm', $order['order_no']); @@ -481,8 +481,11 @@ class Order extends Auth public function track() { try { - $data = $this->_vali(['code.require' => '快递不能为空', 'number.require' => '单号不能为空']); - $result = ExpressService::instance()->query($data['code'], $data['number']); + $data = $this->_vali([ + 'code.require' => '快递不能为空', + 'number.require' => '单号不能为空' + ]); + $result = ExpressService::query($data['code'], $data['number']); empty($result['code']) ? $this->error($result['info']) : $this->success('快递追踪信息', $result); } catch (HttpResponseException $exception) { throw $exception; diff --git a/app/data/controller/api/auth/Transfer.php b/app/data/controller/api/auth/Transfer.php index f3d727f3e..d9f930235 100644 --- a/app/data/controller/api/auth/Transfer.php +++ b/app/data/controller/api/auth/Transfer.php @@ -57,7 +57,7 @@ class Transfer extends Auth [$total, $count] = UserRebateService::instance()->amount($this->uuid); if ($total - $count < $data['amount']) $this->error('可提现余额不足!'); // 提现方式处理 - if (in_array($data['type'], ['alipay_account'])) { + if ($data['type'] == 'alipay_account') { $data = array_merge($data, $this->_vali([ 'alipay_user.require' => '开户姓名不能为空!', 'alipay_code.require' => '支付账号不能为空!', @@ -74,7 +74,7 @@ class Transfer extends Auth 'bank_bran.require' => '银行分行不能为空!', 'bank_code.require' => '银行卡号不能为空!', ])); - } elseif (!in_array($data['type'], ['wechat_wallet'])) { + } elseif ($data['type'] != 'wechat_wallet') { $this->error('转账方式不存在!'); } // 当日提现次数限制 @@ -130,7 +130,7 @@ class Transfer extends Auth DataUserTransfer::mk()->where($data)->whereIn('status', [1, 2, 3])->update([ 'status' => 0, 'change_time' => date("Y-m-d H:i:s"), 'change_desc' => '用户主动取消提现', ]); - UserRebateService::instance()->amount($this->uuid); + UserRebateService::amount($this->uuid); $this->success('取消提现成功'); } @@ -143,7 +143,7 @@ class Transfer extends Auth DataUserTransfer::mk()->where($data)->whereIn('status', [4])->update([ 'status' => 5, 'change_time' => date("Y-m-d H:i:s"), 'change_desc' => '用户主动确认收款', ]); - UserRebateService::instance()->amount($this->uuid); + UserRebateService::amount($this->uuid); $this->success('确认收款成功'); } @@ -155,7 +155,7 @@ class Transfer extends Auth */ public function config() { - $data = UserTransferService::instance()->config(); + $data = UserTransferService::config(); $data['banks'] = UserTransferService::instance()->banks(); $this->success('获取用户提现配置', $data); } diff --git a/app/data/service/UserTransferService.php b/app/data/service/UserTransferService.php index b287a3b8f..93756c6e7 100644 --- a/app/data/service/UserTransferService.php +++ b/app/data/service/UserTransferService.php @@ -132,7 +132,7 @@ class UserTransferService extends Service * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function config(?string $name = null) + public static function config(?string $name = null) { static $data = []; if (empty($data)) $data = sysdata('TransferRule');