From 2c3f3d5d77edbe4059006fad2d8c82e52ad4bdf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=98=8A=E5=A4=A9?= <442384644@qq.com> Date: Tue, 11 Oct 2022 10:56:22 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=A8=8B=E5=BA=8F=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E3=80=91=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/v1/setting/SystemConfig.php | 14 +- .../v1/setting/SystemOutAccount.php | 63 ++++++++- crmeb/app/adminapi/route/setting.php | 6 + .../app/api/controller/v1/LoginController.php | 23 +++- .../controller/v2/wechat/WechatController.php | 18 ++- crmeb/app/dao/out/OutInterfaceDao.php | 14 ++ crmeb/app/event.php | 1 + crmeb/app/jobs/OrderJob.php | 52 -------- crmeb/app/jobs/OutPushJob.php | 124 ++++++++++++++++++ crmeb/app/jobs/RefundOrderJob.php | 52 -------- crmeb/app/listener/order/OrderCreateAfter.php | 5 - crmeb/app/listener/order/OrderPaySuccess.php | 5 - .../listener/order/OrderRefundCancelAfter.php | 5 - .../listener/order/OrderRefundCreateAfter.php | 10 -- crmeb/app/listener/out/OutPush.php | 31 +++++ crmeb/app/model/out/OutInterface.php | 30 +++++ crmeb/app/outapi/controller/Login.php | 6 +- .../outapi/middleware/AuthTokenMiddleware.php | 10 +- .../order/OutStoreOrderRefundServices.php | 29 ++-- .../services/order/OutStoreOrderServices.php | 22 +--- .../order/StoreOrderCreateServices.php | 6 +- .../order/StoreOrderRefundServices.php | 5 +- .../order/StoreOrderSuccessServices.php | 2 + ...ginServices.php => OutAccountServices.php} | 35 ++++- .../app/services/out/OutInterfaceServices.php | 64 +++++++++ crmeb/app/services/pay/OrderPayServices.php | 4 + .../app/services/shipping/ExpressServices.php | 6 +- .../system/config/SystemConfigServices.php | 1 - .../app/services/user/UserExtractServices.php | 1 + crmeb/app/services/wechat/RoutineServices.php | 51 +++++-- .../services/wechat/WechatReplyServices.php | 31 +++-- crmeb/app/services/wechat/WechatServices.php | 52 +++++--- crmeb/public/install/crmeb.sql | 79 +++++++++++ 33 files changed, 617 insertions(+), 240 deletions(-) create mode 100644 crmeb/app/dao/out/OutInterfaceDao.php create mode 100644 crmeb/app/jobs/OutPushJob.php create mode 100644 crmeb/app/listener/out/OutPush.php create mode 100644 crmeb/app/model/out/OutInterface.php rename crmeb/app/services/out/{LoginServices.php => OutAccountServices.php} (83%) create mode 100644 crmeb/app/services/out/OutInterfaceServices.php diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php b/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php index 703a6239f..f713aa9e4 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php @@ -309,13 +309,13 @@ class SystemConfig extends AuthController } //支付接口类型选择,如果有订单就不能再进行切换 - if (isset($post['pay_wechat_type'])) { - /** @var StoreOrderServices $orderServices */ - $orderServices = app()->make(StoreOrderServices::class); - if ($post['pay_wechat_type'] != -1 && $orderServices->count()) { - return app('json')->fail('支付接口类型已经选择,不能再次进行切换,切换后会导致无法退款等问题。'); - } - } +// if (isset($post['pay_wechat_type'])) { +// /** @var StoreOrderServices $orderServices */ +// $orderServices = app()->make(StoreOrderServices::class); +// if ($post['pay_wechat_type'] != -1 && $orderServices->count()) { +// return app('json')->fail('支付接口类型已经选择,不能再次进行切换,切换后会导致无法退款等问题。'); +// } +// } if (isset($post['weixin_ckeck_file'])) { $from = public_path() . $post['weixin_ckeck_file']; diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemOutAccount.php b/crmeb/app/adminapi/controller/v1/setting/SystemOutAccount.php index 42ec2daf9..99a6e87e4 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemOutAccount.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemOutAccount.php @@ -12,7 +12,8 @@ namespace app\adminapi\controller\v1\setting; use app\adminapi\controller\AuthController; use app\outapi\validate\StoreOutAccountValidate; -use app\services\out\LoginServices; +use app\services\out\OutAccountServices; +use app\services\out\OutInterfaceServices; use think\facade\App; /** @@ -26,9 +27,9 @@ class SystemOutAccount extends AuthController * 构造方法 * SystemOut constructor. * @param App $app - * @param LoginServices $services + * @param OutAccountServices $services */ - public function __construct(App $app, LoginServices $services) + public function __construct(App $app, OutAccountServices $services) { parent::__construct($app); $this->services = $services; @@ -76,6 +77,9 @@ class SystemOutAccount extends AuthController /** * 保存 * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function save() { @@ -83,6 +87,7 @@ class SystemOutAccount extends AuthController [['appid', 's'], ''], [['appsecret', 's'], ''], [['title', 's'], ''], + ['rules', []], ]); $this->validate($data, StoreOutAccountValidate::class, 'save'); if ($this->services->getOne(['appid' => $data['appid']])) return app('json')->fail('账号重复'); @@ -92,6 +97,7 @@ class SystemOutAccount extends AuthController $data['appsecret'] = password_hash($data['appsecret'], PASSWORD_DEFAULT); } $data['add_time'] = time(); + $data['rules'] = implode(',', $data['rules']); if (!$this->services->save($data)) { return app('json')->fail('添加失败'); } else { @@ -103,12 +109,16 @@ class SystemOutAccount extends AuthController * 修改 * @param string $id * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function update($id = '') { $data = $this->request->postMore([ [['appsecret', 's'], ''], [['title', 's'], ''], + ['rules', []], ]); $this->validate($data, StoreOutAccountValidate::class, 'update'); @@ -118,7 +128,7 @@ class SystemOutAccount extends AuthController $data['appsecret'] = password_hash($data['appsecret'], PASSWORD_DEFAULT); } if (!$this->services->getOne(['id' => $id])) return app('json')->fail('没有此账号'); - + $data['rules'] = implode(',', $data['rules']); $res = $this->services->update($id, $data); if (!$res) { return app('json')->fail('修改失败'); @@ -126,4 +136,49 @@ class SystemOutAccount extends AuthController return app('json')->success('修改成功!'); } } + + /** + * 设置账号推送接口表单 + * @param $id + * @return mixed + * @throws \FormBuilder\Exception\FormBuilderException + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function outSetUpForm($id) + { + return app('json')->success($this->services->outSetUpForm($id)); + } + + /** + * 设置账号推送接口 + * @param $id + * @return mixed + */ + public function outSetUpSave($id) + { + $data = $this->request->postMore([ + ['push_open', 0], + ['order_create_push', ''], + ['order_pay_push', ''], + ['refund_create_push', ''], + ['refund_cancel_push', ''], + ]); + $this->services->outSetUpSave($id, $data); + return app('json')->success('修改成功'); + } + + /** + * 对外接口列表 + * @param OutInterfaceServices $service + * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function outInterfaceList(OutInterfaceServices $service) + { + return app('json')->success($service->outInterfaceList()); + } } diff --git a/crmeb/app/adminapi/route/setting.php b/crmeb/app/adminapi/route/setting.php index c02c87b9d..d6300f4c1 100644 --- a/crmeb/app/adminapi/route/setting.php +++ b/crmeb/app/adminapi/route/setting.php @@ -165,8 +165,14 @@ Route::group('setting', function () { Route::post('system_out_account/update/:id', 'v1.setting.SystemOutAccount/update')->option(['real_name' => '对外接口账号修改']); //设置账号是否禁用 Route::put('system_out_account/set_status/:id/:status', 'v1.setting.SystemOutAccount/set_status')->option(['real_name' => '设置账号是否禁用']); + //设置账号推送接口表单 + Route::get('system_out_account/set_up/:id', 'v1.setting.SystemOutAccount/outSetUpForm')->option(['real_name' => '设置账号推送接口表单']); + //设置账号推送接口 + Route::put('system_out_account/set_up/:id', 'v1.setting.SystemOutAccount/outSetUpSave')->option(['real_name' => '设置账号推送接口']); //删除账号 Route::delete('system_out_account/:id', 'v1.setting.SystemOutAccount/delete')->option(['real_name' => '删除账号']); + //对外接口列表 + Route::get('system_out_interface/list', 'v1.setting.SystemOutAccount/outInterfaceList')->option(['real_name' => '对外接口列表']); /** 多语言 */ //语言国家列表 diff --git a/crmeb/app/api/controller/v1/LoginController.php b/crmeb/app/api/controller/v1/LoginController.php index 44d570b5a..dd8716487 100644 --- a/crmeb/app/api/controller/v1/LoginController.php +++ b/crmeb/app/api/controller/v1/LoginController.php @@ -11,7 +11,6 @@ namespace app\api\controller\v1; - use app\Request; use app\services\message\notice\SmsService; use app\services\wechat\WechatServices; @@ -23,7 +22,8 @@ use app\services\user\LoginServices; use think\exception\ValidateException; use app\api\validate\user\RegisterValidates; -/**微信小程序授权类 +/** + * 微信小程序授权类 * Class AuthController * @package app\api\controller */ @@ -63,6 +63,7 @@ class LoginController /** * 退出登录 * @param Request $request + * @return mixed */ public function logout(Request $request) { @@ -71,6 +72,10 @@ class LoginController return app('json')->success(410002); } + /** + * 获取发送验证码key + * @return mixed + */ public function verifyCode() { $unique = password_hash(uniqid(true), PASSWORD_BCRYPT); @@ -79,6 +84,11 @@ class LoginController return app('json')->success(['key' => $unique, 'expire_time' => $time]); } + /** + * 获取图片验证码 + * @param Request $request + * @return \think\Response + */ public function captcha(Request $request) { ob_clean(); @@ -93,7 +103,6 @@ class LoginController /** * 验证验证码是否正确 - * * @param $uni * @param string $code * @return bool @@ -117,6 +126,7 @@ class LoginController /** * 验证码发送 * @param Request $request + * @param SmsService $services * @return mixed */ public function verify(Request $request, SmsService $services) @@ -171,6 +181,9 @@ class LoginController * H5注册新用户 * @param Request $request * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function register(Request $request) { @@ -201,6 +214,9 @@ class LoginController * 密码修改 * @param Request $request * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function reset(Request $request) { @@ -462,6 +478,7 @@ class LoginController } /** + * 滑块验证 * @return mixed */ public function ajcaptcha(Request $request) diff --git a/crmeb/app/api/controller/v2/wechat/WechatController.php b/crmeb/app/api/controller/v2/wechat/WechatController.php index 4ae0366e0..92d5a1fb2 100644 --- a/crmeb/app/api/controller/v2/wechat/WechatController.php +++ b/crmeb/app/api/controller/v2/wechat/WechatController.php @@ -56,9 +56,10 @@ class WechatController /** * 微信公众号静默授权 - * @param $code - * @param $spread + * @param string $spread * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException */ public function silenceAuth($spread = '') { @@ -73,9 +74,10 @@ class WechatController /** * 微信公众号静默授权 - * @param $code - * @param $spread + * @param string $spread * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException */ public function silenceAuthNoLogin($spread = '') { @@ -90,9 +92,13 @@ class WechatController /** * 静默授权 手机号直接注册登录 - * @param $code - * @param $spread + * @param string $key + * @param string $phone + * @param string $captcha * @return mixed + * @throws \Psr\SimpleCache\InvalidArgumentException + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException */ public function silenceAuthBindingPhone($key = '', $phone = '', $captcha = '') { diff --git a/crmeb/app/dao/out/OutInterfaceDao.php b/crmeb/app/dao/out/OutInterfaceDao.php new file mode 100644 index 000000000..2875e9188 --- /dev/null +++ b/crmeb/app/dao/out/OutInterfaceDao.php @@ -0,0 +1,14 @@ + [\app\listener\order\OrderTake::class], //订单收货后置事件 'order.orderRefundCreateAfter' => [\app\listener\order\OrderRefundCreateAfter::class], //售后单生成后置事件 'order.orderRefundCancelAfter' => [\app\listener\order\OrderRefundCancelAfter::class], //售后单取消后置事件 + 'out.outPush' => [\app\listener\out\OutPush::class], //对外推送事件 'user.userLevel' => [\app\listener\user\UserLevel::class], //用户升级事件 'user.userVisit' => [\app\listener\user\UserVisit::class], //用户访问事件 'notice.notice' => [\app\listener\notice\Notice::class], //通知->消息事件 diff --git a/crmeb/app/jobs/OrderJob.php b/crmeb/app/jobs/OrderJob.php index e47861921..086e11d51 100644 --- a/crmeb/app/jobs/OrderJob.php +++ b/crmeb/app/jobs/OrderJob.php @@ -308,56 +308,4 @@ class OrderJob extends BaseJobs return false; } - - /** - * 订单推送 - * @param int $oid - * @param int $step - * @return bool - */ - public function orderCreate(int $oid, int $step = 0): bool - { - if ($step > 2) { - Log::error('订单' . $oid . '推送失败'); - return true; - } - - try { - /** @var OutStoreOrderServices $services */ - $services = app()->make(OutStoreOrderServices::class); - if (!$services->orderCreatePush($oid)) { - OrderJob::dispatchSece(($step + 1) * 5, 'push', [$oid, $step + 1]); - } - } catch (\Exception $e) { - Log::error('订单' . $oid . '推送失败,失败原因:' . $e->getMessage()); - OrderJob::dispatchSece(($step + 1) * 5, 'push', [$oid, $step + 1]); - } - return true; - } - - /** - * 订单支付推送 - * @param int $oid - * @param int $step - * @return bool - */ - public function paySuccess(int $oid, int $step = 0): bool - { - if ($step > 2) { - Log::error('订单支付' . $oid . '推送失败'); - return true; - } - - try { - /** @var OutStoreOrderServices $services */ - $services = app()->make(OutStoreOrderServices::class); - if (!$services->paySuccessPush($oid)) { - OrderJob::dispatchSece(($step + 1) * 5, 'paySuccess', [$oid, $step + 1]); - } - } catch (\Exception $e) { - Log::error('订单支付' . $oid . '推送失败,失败原因:' . $e->getMessage()); - OrderJob::dispatchSece(($step + 1) * 5, 'paySuccess', [$oid, $step + 1]); - } - return true; - } } diff --git a/crmeb/app/jobs/OutPushJob.php b/crmeb/app/jobs/OutPushJob.php new file mode 100644 index 000000000..cfee183ec --- /dev/null +++ b/crmeb/app/jobs/OutPushJob.php @@ -0,0 +1,124 @@ + 2) { + Log::error('订单' . $oid . '推送失败'); + return true; + } + + try { + /** @var OutStoreOrderServices $services */ + $services = app()->make(OutStoreOrderServices::class); + if (!$services->orderCreatePush($oid, $pushUrl)) { + OutPushJob::dispatchSece(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]); + } + } catch (\Exception $e) { + Log::error('订单' . $oid . '推送失败,失败原因:' . $e->getMessage()); + OutPushJob::dispatchSece(($step + 1) * 5, 'orderCreate', [$oid, $pushUrl, $step + 1]); + } + + return true; + } + + /** + * 订单支付推送 + * @param int $oid + * @param string $pushUrl + * @param int $step + * @return bool + */ + public function paySuccess(int $oid, string $pushUrl, int $step = 0): bool + { + if ($step > 2) { + Log::error('订单支付' . $oid . '推送失败'); + return true; + } + + try { + /** @var OutStoreOrderServices $services */ + $services = app()->make(OutStoreOrderServices::class); + if (!$services->paySuccessPush($oid, $pushUrl)) { + OutPushJob::dispatchSece(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]); + } + } catch (\Exception $e) { + Log::error('订单支付' . $oid . '推送失败,失败原因:' . $e->getMessage()); + OutPushJob::dispatchSece(($step + 1) * 5, 'paySuccess', [$oid, $pushUrl, $step + 1]); + } + + return true; + } + + /** + * 售后单生成 + * @param int $oid + * @param string $pushUrl + * @param int $step + * @return bool + */ + public function refundCreate(int $oid, string $pushUrl, int $step = 0): bool + { + if ($step > 2) { + Log::error('售后单' . $oid . '推送失败'); + return true; + } + + try { + /** @var OutStoreOrderRefundServices $services */ + $services = app()->make(OutStoreOrderRefundServices::class); + if (!$services->refundCreatePush($oid, $pushUrl)) { + OutPushJob::dispatchSece(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]); + } + } catch (\Exception $e) { + Log::error('售后单' . $oid . '推送失败,失败原因:' . $e->getMessage()); + OutPushJob::dispatchSece(($step + 1) * 5, 'refundCreate', [$oid, $pushUrl, $step + 1]); + } + return true; + } + + /** + * 取消申请 + * @param int $oid + * @param string $pushUrl + * @param int $step + * @return bool + */ + public function refundCancel(int $oid, string $pushUrl, int $step = 0): bool + { + if ($step > 2) { + Log::error('取消售后单' . $oid . '推送失败'); + return true; + } + + try { + /** @var OutStoreOrderRefundServices $services */ + $services = app()->make(OutStoreOrderRefundServices::class); + if (!$services->cancelApplyPush($oid, $pushUrl)) { + OutPushJob::dispatchSece(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]); + } + } catch (\Exception $e) { + Log::error('取消售后单' . $oid . '推送失败,失败原因:' . $e->getMessage()); + OutPushJob::dispatchSece(($step + 1) * 5, 'refundCancel', [$oid, $pushUrl, $step + 1]); + } + return true; + } +} \ No newline at end of file diff --git a/crmeb/app/jobs/RefundOrderJob.php b/crmeb/app/jobs/RefundOrderJob.php index 15d6f5a5a..2bcb8fbb7 100644 --- a/crmeb/app/jobs/RefundOrderJob.php +++ b/crmeb/app/jobs/RefundOrderJob.php @@ -24,56 +24,4 @@ use think\facade\Log; class RefundOrderJob extends BaseJobs { use QueueTrait; - - /** - * 售后单生成 - * @param int $oid - * @param int $step - * @return bool - */ - public function refundCreate(int $oid, int $step = 0): bool - { - if ($step > 2) { - Log::error('售后单' . $oid . '推送失败'); - return true; - } - - try { - /** @var OutStoreOrderRefundServices $services */ - $services = app()->make(OutStoreOrderRefundServices::class); - if (!$services->refundCreatePush($oid)) { - RefundOrderJob::dispatchSece(($step + 1) * 5, 'refundCreate', [$oid, $step + 1]); - } - } catch (\Exception $e) { - Log::error('售后单' . $oid . '推送失败,失败原因:' . $e->getMessage()); - RefundOrderJob::dispatchSece(($step + 1) * 5, 'refundCreate', [$oid, $step + 1]); - } - return true; - } - - /** - * 取消申请 - * @param int $oid - * @param int $step - * @return bool - */ - public function cancelApply(int $oid, int $step = 0): bool - { - if ($step > 2) { - Log::error('取消售后单' . $oid . '推送失败'); - return true; - } - - try { - /** @var OutStoreOrderRefundServices $services */ - $services = app()->make(OutStoreOrderRefundServices::class); - if (!$services->cancelApplyPush($oid)) { - RefundOrderJob::dispatchSece(($step + 1) * 5, 'cancelApply', [$oid, $step + 1]); - } - } catch (\Exception $e) { - Log::error('取消售后单' . $oid . '推送失败,失败原因:' . $e->getMessage()); - RefundOrderJob::dispatchSece(($step + 1) * 5, 'cancelApply', [$oid, $step + 1]); - } - return true; - } } \ No newline at end of file diff --git a/crmeb/app/listener/order/OrderCreateAfter.php b/crmeb/app/listener/order/OrderCreateAfter.php index 6fda67fb5..b8111ae95 100644 --- a/crmeb/app/listener/order/OrderCreateAfter.php +++ b/crmeb/app/listener/order/OrderCreateAfter.php @@ -53,11 +53,6 @@ class OrderCreateAfter implements ListenerInterface //下单记录 ProductLogJob::dispatch(['order', ['uid' => $uid, 'order_id' => $order['id']]]); - - // 推送订单 - if (sys_config('out_push_switch') && sys_config('out_push_order_url')) { - OrderJob::dispatchDo('orderCreate', [(int)$order['id']]); - } } /** diff --git a/crmeb/app/listener/order/OrderPaySuccess.php b/crmeb/app/listener/order/OrderPaySuccess.php index 1963f1214..e5eca9183 100644 --- a/crmeb/app/listener/order/OrderPaySuccess.php +++ b/crmeb/app/listener/order/OrderPaySuccess.php @@ -89,10 +89,5 @@ class OrderPaySuccess implements ListenerInterface //商品日志记录支付记录 ProductLogJob::dispatch(['pay', ['uid' => $orderInfo['uid'], 'order_id' => $orderInfo['id']]]); - - // 推送订单支付 - if (sys_config('out_push_switch') && sys_config('out_push_order_pay_url')) { - OrderJob::dispatchDo('paySuccess', [(int)$orderInfo['id']]); - } } } diff --git a/crmeb/app/listener/order/OrderRefundCancelAfter.php b/crmeb/app/listener/order/OrderRefundCancelAfter.php index 526193234..a63bb006a 100644 --- a/crmeb/app/listener/order/OrderRefundCancelAfter.php +++ b/crmeb/app/listener/order/OrderRefundCancelAfter.php @@ -15,10 +15,5 @@ class OrderRefundCancelAfter implements ListenerInterface public function handle($event): void { [$orderRefundInfo] = $event; - - // 售后单取消 - if (sys_config('out_push_switch') && sys_config('out_push_refund_cancel_url')) { - RefundOrderJob::dispatchDo('cancelApply', [(int)$orderRefundInfo['id']]); - } } } diff --git a/crmeb/app/listener/order/OrderRefundCreateAfter.php b/crmeb/app/listener/order/OrderRefundCreateAfter.php index 6f5fc8c6f..96064a104 100644 --- a/crmeb/app/listener/order/OrderRefundCreateAfter.php +++ b/crmeb/app/listener/order/OrderRefundCreateAfter.php @@ -16,15 +16,5 @@ class OrderRefundCreateAfter implements ListenerInterface public function handle($event): void { [$order] = $event; - - // 推送售后单 - if (sys_config('out_push_switch') && sys_config('out_push_order_url')) { - /** @var OutStoreOrderRefundServices $refundServices */ - $refundServices = app()->make(OutStoreOrderRefundServices::class); - $orderRefundId = $refundServices->value(['store_order_id' => (int)$order['id']], 'id'); - if ($orderRefundId) { - RefundOrderJob::dispatchDo('refundCreate', [(int)$orderRefundId]); - } - } } } diff --git a/crmeb/app/listener/out/OutPush.php b/crmeb/app/listener/out/OutPush.php new file mode 100644 index 000000000..202351228 --- /dev/null +++ b/crmeb/app/listener/out/OutPush.php @@ -0,0 +1,31 @@ +make(OutAccountServices::class); + $outAccountList = $outAccountServices->selectList(['is_del' => 0, 'status' => 1])->toArray(); + foreach ($outAccountList as $item) { + if ($item['push_open'] == 1) { + if ($type == 'order_create_push') { + OutPushJob::dispatchDo('orderCreate', [$orderId, $item['order_create_push']]); + } elseif ($type == 'order_pay_push') { + OutPushJob::dispatchDo('paySuccess', [$orderId, $item['order_pay_push']]); + }elseif($type == 'refund_create_push'){ + OutPushJob::dispatchDo('refundCreate', [$orderId, $item['refund_create_push']]); + }elseif($type == 'refund_cancel_push'){ + OutPushJob::dispatchDo('refundCancel', [$orderId, $item['refund_cancel_push']]); + } + } + } + } +} \ No newline at end of file diff --git a/crmeb/app/model/out/OutInterface.php b/crmeb/app/model/out/OutInterface.php new file mode 100644 index 000000000..6d8e1f8a8 --- /dev/null +++ b/crmeb/app/model/out/OutInterface.php @@ -0,0 +1,30 @@ +where('type', $value); + } + } +} \ No newline at end of file diff --git a/crmeb/app/outapi/controller/Login.php b/crmeb/app/outapi/controller/Login.php index 216d74274..922190eb4 100644 --- a/crmeb/app/outapi/controller/Login.php +++ b/crmeb/app/outapi/controller/Login.php @@ -13,7 +13,7 @@ namespace app\outapi\controller; use app\outapi\validate\LoginValidate; use app\Request; use think\facade\App; -use app\services\out\LoginServices; +use app\services\out\OutAccountServices; /** * Class Login @@ -24,9 +24,9 @@ class Login extends AuthController /** * OutAccount constructor. * @param App $app - * @param LoginServices $services + * @param OutAccountServices $services */ - public function __construct(App $app, LoginServices $services) + public function __construct(App $app, OutAccountServices $services) { parent::__construct($app); $this->services = $services; diff --git a/crmeb/app/outapi/middleware/AuthTokenMiddleware.php b/crmeb/app/outapi/middleware/AuthTokenMiddleware.php index 7efb4c3b4..4100d46da 100644 --- a/crmeb/app/outapi/middleware/AuthTokenMiddleware.php +++ b/crmeb/app/outapi/middleware/AuthTokenMiddleware.php @@ -13,7 +13,8 @@ namespace app\outapi\middleware; use app\Request; -use app\services\out\LoginServices; +use app\services\out\OutAccountServices; +use app\services\out\OutInterfaceServices; use crmeb\interfaces\MiddlewareInterface; use think\facade\Config; @@ -35,8 +36,8 @@ class AuthTokenMiddleware implements MiddlewareInterface public function handle(Request $request, \Closure $next) { $token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer')); - /** @var LoginServices $services */ - $services = app()->make(LoginServices::class); + /** @var OutAccountServices $services */ + $services = app()->make(OutAccountServices::class); $outInfo = $services->parseToken($token); Request::macro('outId', function () use (&$outInfo) { return (int)$outInfo['id']; @@ -45,6 +46,9 @@ class AuthTokenMiddleware implements MiddlewareInterface Request::macro('outInfo', function () use (&$outInfo) { return $outInfo; }); + /** @var OutInterfaceServices $outInterfaceServices */ + $outInterfaceServices = app()->make(OutInterfaceServices::class); + $outInterfaceServices->verifyAuth($request); return $next($request); } diff --git a/crmeb/app/services/order/OutStoreOrderRefundServices.php b/crmeb/app/services/order/OutStoreOrderRefundServices.php index 92a261b55..f8a735a19 100644 --- a/crmeb/app/services/order/OutStoreOrderRefundServices.php +++ b/crmeb/app/services/order/OutStoreOrderRefundServices.php @@ -275,16 +275,11 @@ class OutStoreOrderRefundServices extends BaseServices /** * 售后单生成 * @param int $id + * @param string $pushUrl * @return bool */ - public function refundCreatePush(int $id): bool + public function refundCreatePush(int $id, string $pushUrl): bool { - $pushUrl = sys_config('out_push_refund_url'); - if (!$pushUrl) { - Log::error('请检查售后单推送接口配置'); - return true; - } - $refundInfo = $this->getInfo('', $id); /** @var OutStoreOrderServices $orderServices */ $orderServices = app()->make(OutStoreOrderServices::class); @@ -299,21 +294,19 @@ class OutStoreOrderRefundServices extends BaseServices /** * 售后单取消 * @param int $id + * @param string $pushUrl * @return bool */ - public function cancelApplyPush(int $id): bool + public function cancelApplyPush(int $id, string $pushUrl): bool { - $pushUrl = sys_config('out_push_refund_cancel_url'); - if (!$pushUrl) { - Log::error('请检查售后单取消推送接口配置'); - return true; + $refundInfo = $this->getInfo('', $id); + /** @var OutStoreOrderServices $orderServices */ + $orderServices = app()->make(OutStoreOrderServices::class); + $orderInfo = $orderServices->get($refundInfo['store_order_id'], ['id', 'order_id']); + if (!$orderInfo) { + throw new AdminException(400118); } - - $refundInfo = $this->dao->get($id, ['order_id']); - if (!$refundInfo) { - throw new AdminException(410173); - } - $refundInfo = $refundInfo->toArray(); + $refundInfo['order'] = $orderInfo->toArray(); return $this->push($pushUrl, $refundInfo, $id, '取消售后单'); } diff --git a/crmeb/app/services/order/OutStoreOrderServices.php b/crmeb/app/services/order/OutStoreOrderServices.php index 1036dfc53..d869f3342 100644 --- a/crmeb/app/services/order/OutStoreOrderServices.php +++ b/crmeb/app/services/order/OutStoreOrderServices.php @@ -393,15 +393,11 @@ class OutStoreOrderServices extends BaseServices /** * 订单推送 * @param int $id + * @param string $pushUrl * @return bool */ - public function orderCreatePush(int $id): bool + public function orderCreatePush(int $id, string $pushUrl): bool { - $pushUrl = sys_config('out_push_order_url'); - if (!$pushUrl) { - Log::error('请检查订单推送接口配置'); - return true; - } $orderInfo = $this->getInfo('', $id); return $this->push($pushUrl, $orderInfo, $id, '订单'); } @@ -409,20 +405,12 @@ class OutStoreOrderServices extends BaseServices /** * 支付推送 * @param int $id + * @param string $pushUrl * @return bool */ - public function paySuccessPush(int $id): bool + public function paySuccessPush(int $id, string $pushUrl): bool { - $pushUrl = sys_config('out_push_order_pay_url'); - if (!$pushUrl) { - Log::error('请检查订单支付推送接口配置'); - return true; - } - $orderInfo = $this->dao->get($id, ['order_id']); - if (!$orderInfo) { - throw new AdminException(410173); - } - $orderInfo = $orderInfo->toArray(); + $orderInfo = $this->getInfo('', $id); return $this->push($pushUrl, $orderInfo, $id, '订单支付'); } diff --git a/crmeb/app/services/order/StoreOrderCreateServices.php b/crmeb/app/services/order/StoreOrderCreateServices.php index 642d4b0f9..7d8f17ed9 100644 --- a/crmeb/app/services/order/StoreOrderCreateServices.php +++ b/crmeb/app/services/order/StoreOrderCreateServices.php @@ -212,7 +212,7 @@ class StoreOrderCreateServices extends BaseServices 'unique' => $key, 'shipping_type' => $shippingType, 'channel_type' => $userInfo['user_type'], - 'province' => $userInfo['user_type'] == 'wechat' || $userInfo['user_type'] == 'routine' ? $wechatServices->value(['uid' => $uid, 'user_type' => $userInfo['user_type']], 'province') : '', + 'province' => strval($userInfo['user_type'] == 'wechat' || $userInfo['user_type'] == 'routine' ? $wechatServices->value(['uid' => $uid, 'user_type' => $userInfo['user_type']], 'province') : ''), 'spread_uid' => 0, 'spread_two_uid' => 0, 'virtual_type' => $virtual_type, @@ -260,8 +260,10 @@ class StoreOrderCreateServices extends BaseServices return $order; }); - //订单创建成功后置事件 + // 订单创建成功后置事件 event('order.orderCreateAfter', [$order, compact('cartInfo', 'priceData', 'addressId', 'cartIds', 'news'), $uid, $key, $combinationId, $seckillId, $bargainId]); + // 推送订单 + event('out.outPush', ['order_create_push', (int)$order['id']]); return $order; } diff --git a/crmeb/app/services/order/StoreOrderRefundServices.php b/crmeb/app/services/order/StoreOrderRefundServices.php index 4c583e2ef..16880262c 100644 --- a/crmeb/app/services/order/StoreOrderRefundServices.php +++ b/crmeb/app/services/order/StoreOrderRefundServices.php @@ -995,6 +995,8 @@ class StoreOrderRefundServices extends BaseServices event('order.orderRefundCreateAfter', [$order]); //提醒推送 event('notice.notice', [['order' => $order], 'send_order_apply_refund']); + //推送订单 + event('out.outPush', ['refund_create_push', (int)$order['id']]); try { ChannelService::instance()->send('NEW_REFUND_ORDER', ['order_id' => $order['order_id']]); } catch (\Exception $e) { @@ -1250,7 +1252,8 @@ class StoreOrderRefundServices extends BaseServices $storeOrderCartInfoServices->clearOrderCartInfo($oid); //售后订单取消后置事件 event('order.orderRefundCancelAfter', [$orderRefundInfo]); - + // 推送订单 + event('out.outPush', ['order_pay_push', (int)$orderRefundInfo['id']]); return true; } diff --git a/crmeb/app/services/order/StoreOrderSuccessServices.php b/crmeb/app/services/order/StoreOrderSuccessServices.php index c0dd732b8..274d7e299 100644 --- a/crmeb/app/services/order/StoreOrderSuccessServices.php +++ b/crmeb/app/services/order/StoreOrderSuccessServices.php @@ -97,6 +97,8 @@ class StoreOrderSuccessServices extends BaseServices event('notice.notice', [$orderInfo, 'order_pay_success']); //支付成功给客服发送消息 event('notice.notice', [$orderInfo, 'admin_pay_success_code']); + // 推送订单 + event('out.outPush', ['order_pay_push', (int)$orderInfo['id']]); $res = $res1 && $resPink; return false !== $res; } diff --git a/crmeb/app/services/out/LoginServices.php b/crmeb/app/services/out/OutAccountServices.php similarity index 83% rename from crmeb/app/services/out/LoginServices.php rename to crmeb/app/services/out/OutAccountServices.php index 0adcf4ce3..ac83a7439 100644 --- a/crmeb/app/services/out/LoginServices.php +++ b/crmeb/app/services/out/OutAccountServices.php @@ -15,6 +15,7 @@ use app\dao\out\OutAccountDao; use app\services\BaseServices; use crmeb\exceptions\AuthException; use crmeb\services\CacheService; +use crmeb\services\FormBuilder as Form; use crmeb\utils\JwtAuth; use Firebase\JWT\ExpiredException; @@ -26,7 +27,7 @@ use Firebase\JWT\ExpiredException; * @method update($id, array $data, ?string $key = null) * @method save(array $data)保存 */ -class LoginServices extends BaseServices +class OutAccountServices extends BaseServices { /** * LoginServices constructor. @@ -123,6 +124,7 @@ class LoginServices extends BaseServices foreach ($list as &$item) { $item['add_time'] = $item['add_time'] ? date('Y-m-d H:i:s', $item['add_time']) : '暂无'; $item['last_time'] = $item['last_time'] ? date('Y-m-d H:i:s', $item['last_time']) : '暂无'; + $item['rules'] = is_null($item['rules']) ? [] : explode(',', $item['rules']); } } return compact('count', 'list'); @@ -234,4 +236,35 @@ class LoginServices extends BaseServices return [$md5Token, $id, $type]; } + + /** + * 设置账号推送接口表单 + * @param $id + * @return array + * @throws \FormBuilder\Exception\FormBuilderException + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function outSetUpForm($id) + { + $info = $this->dao->get($id); + $f[] = Form::radio('push_open', '推送开关', $info['push_open'] ?? 0)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]); + $f[] = Form::input('order_create_push', '订单创建推送', $info['order_create_push'] ?? ''); + $f[] = Form::input('order_pay_push', '订单支付推送', $info['order_pay_push'] ?? ''); + $f[] = Form::input('refund_create_push', '退款单创建推送', $info['refund_create_push'] ?? ''); + $f[] = Form::input('refund_cancel_push', '退款单取消推送', $info['refund_cancel_push'] ?? ''); + return create_form('设置推送', $f, $this->url('/setting/system_out_account/set_up/' . $id), 'PUT'); + } + + /** + * 设置账号推送接口 + * @param $id + * @param $data + * @return \crmeb\basic\BaseModel + */ + public function outSetUpSave($id, $data) + { + return $this->dao->update($id, $data); + } } diff --git a/crmeb/app/services/out/OutInterfaceServices.php b/crmeb/app/services/out/OutInterfaceServices.php new file mode 100644 index 000000000..cc506af39 --- /dev/null +++ b/crmeb/app/services/out/OutInterfaceServices.php @@ -0,0 +1,64 @@ +dao = $dao; + } + + /** + * 验证对外接口权限 + * @param Request $request + * @return bool + */ + public function verifyAuth(Request $request) + { + $rule = trim(strtolower($request->rule()->getRule())); + $method = trim(strtolower($request->method())); + $authList = $this->dao->getColumn([['id', 'in', $request->outInfo()['rules']]], 'method,url'); + $rolesAuth = []; + foreach ($authList as $item) { + $rolesAuth[trim(strtolower($item['method']))][] = trim(strtolower(str_replace(' ', '', $item['url']))); + } + if (in_array('/' . $rule, $rolesAuth[$method])) { + return true; + } else { + throw new AuthException(110000); + } + } + + /** + * 对外接口列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function outInterfaceList(): array + { + $list = $this->dao->selectList([], '*,name as title')->toArray(); + $data = []; + foreach ($list as $key => $item) { + if ($item['pid'] == 0) { + $data[] = $item; + unset($list[$key]); + } + } + foreach ($data as &$item_p) { + foreach ($list as $item_c) { + if ($item_p['id'] == $item_c['pid']) { + $item_p['children'][] = $item_c; + } + } + } + return $data; + } +} \ No newline at end of file diff --git a/crmeb/app/services/pay/OrderPayServices.php b/crmeb/app/services/pay/OrderPayServices.php index c3e98375e..da9605ff9 100644 --- a/crmeb/app/services/pay/OrderPayServices.php +++ b/crmeb/app/services/pay/OrderPayServices.php @@ -40,7 +40,11 @@ class OrderPayServices /** * 订单发起支付 * @param array $orderInfo + * @param string $payType * @return array|string + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function orderPay(array $orderInfo, string $payType) { diff --git a/crmeb/app/services/shipping/ExpressServices.php b/crmeb/app/services/shipping/ExpressServices.php index d72d4c98c..8af4e06ad 100644 --- a/crmeb/app/services/shipping/ExpressServices.php +++ b/crmeb/app/services/shipping/ExpressServices.php @@ -89,9 +89,9 @@ class ExpressServices extends BaseServices if (isset($formData['partner_id']) && $formData['partner_id'] == 1) $field[] = Form::input('account', '月结账号', $formData['account'] ?? '')->required(); if (isset($formData['partner_key']) && $formData['partner_key'] == 1) $field[] = Form::input('key', '月结密码', $formData['key'] ?? '')->required(); if (isset($formData['net']) && $formData['net'] == 1) $field[] = Form::input('net_name', '取件网点', $formData['net_name'] ?? '')->required(); - if (isset($formData['check_man']) && $formData['check_man'] == 1) $field[] = Form::input('courier_name', '承载快递员名', $formData['net_name'] ?? '')->required(); - if (isset($formData['partner_name']) && $formData['partner_name'] == 1) $field[] = Form::input('customer_name', '客户账户名称', $formData['net_name'] ?? '')->required(); - if (isset($formData['is_code']) && $formData['is_code'] == 1) $field[] = Form::input('code_name', '电子面单承载编号', $formData['net_name'] ?? '')->required(); + if (isset($formData['check_man']) && $formData['check_man'] == 1) $field[] = Form::input('courier_name', '承载快递员名', $formData['courier_name'] ?? '')->required(); + if (isset($formData['partner_name']) && $formData['partner_name'] == 1) $field[] = Form::input('customer_name', '客户账户名称', $formData['customer_name'] ?? '')->required(); + if (isset($formData['is_code']) && $formData['is_code'] == 1) $field[] = Form::input('code_name', '电子面单承载编号', $formData['code_name'] ?? '')->required(); $field[] = Form::number('sort', '排序', (int)($formData['sort'] ?? 0))->precision(0); $field[] = Form::radio('is_show', '是否启用', $formData['is_show'] ?? 1)->options([['value' => 0, 'label' => '隐藏'], ['value' => 1, 'label' => '启用']]); return $field; diff --git a/crmeb/app/services/system/config/SystemConfigServices.php b/crmeb/app/services/system/config/SystemConfigServices.php index 9780db058..d9f5f9180 100644 --- a/crmeb/app/services/system/config/SystemConfigServices.php +++ b/crmeb/app/services/system/config/SystemConfigServices.php @@ -154,7 +154,6 @@ class SystemConfigServices extends BaseServices ], 'pay_weixin_client_cert' => '', 'pay_weixin_client_key' => '', - 'paydir' => '', ], 'show_value' => 1 ], diff --git a/crmeb/app/services/user/UserExtractServices.php b/crmeb/app/services/user/UserExtractServices.php index 92236f8a3..26b1b15a2 100644 --- a/crmeb/app/services/user/UserExtractServices.php +++ b/crmeb/app/services/user/UserExtractServices.php @@ -253,6 +253,7 @@ class UserExtractServices extends BaseServices $extract_statistics['priced'] = $this->getExtractSum($where); /** @var UserBrokerageServices $userBrokerageServices */ $userBrokerageServices = app()->make(UserBrokerageServices::class); + $where['pm'] = 1; $extract_statistics['brokerage_count'] = $userBrokerageServices->getUsersBokerageSum($where); //未提现金额 $extract_statistics['brokerage_not'] = $extract_statistics['brokerage_count'] > $extract_statistics['priced'] ? bcsub((string)$extract_statistics['brokerage_count'], (string)$extract_statistics['priced'], 2) : 0.00; diff --git a/crmeb/app/services/wechat/RoutineServices.php b/crmeb/app/services/wechat/RoutineServices.php index c3d8dd423..6fb87dd8d 100644 --- a/crmeb/app/services/wechat/RoutineServices.php +++ b/crmeb/app/services/wechat/RoutineServices.php @@ -51,7 +51,9 @@ class RoutineServices extends BaseServices * @param $spread_code * @param $iv * @param $encryptedData - * @return mixed + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException */ public function mp_auth($code, $post_cache_key, $login_type, $spread_spid, $spread_code, $iv, $encryptedData) { @@ -150,8 +152,8 @@ class RoutineServices extends BaseServices /** * 小程序创建用户后返回uid - * @param $routineInfo - * @return mixed + * @param $routine + * @return array */ public function routineOauth($routine) { @@ -179,6 +181,8 @@ class RoutineServices extends BaseServices /** * 小程序支付回调 + * @return \Symfony\Component\HttpFoundation\Response + * @throws \EasyWeChat\Core\Exceptions\FaultException */ public function notify() { @@ -187,7 +191,7 @@ class RoutineServices extends BaseServices /** * 获取小程序订阅消息id - * @return mixed + * @return bool|mixed|null */ public function tempIds() { @@ -210,9 +214,9 @@ class RoutineServices extends BaseServices /** * 获取小程序直播列表 - * @param $pgae + * @param $page * @param $limit - * @return mixed + * @return array|bool|mixed */ public function live($page, $limit) { @@ -230,7 +234,11 @@ class RoutineServices extends BaseServices * 静默授权 * @param $code * @param $spread - * @return mixed + * @param $spid + * @return array + * @throws \Psr\SimpleCache\InvalidArgumentException + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException */ public function silenceAuth($code, $spread, $spid) { @@ -290,7 +298,9 @@ class RoutineServices extends BaseServices * 静默授权 * @param $code * @param $spread - * @return mixed + * @param $spid + * @return array + * @throws \Psr\SimpleCache\InvalidArgumentException */ public function silenceAuthNoLogin($code, $spread, $spid) { @@ -341,7 +351,11 @@ class RoutineServices extends BaseServices * 手机号登录 静默授权绑定关系 * @param $code * @param $spread - * @return mixed + * @param $spid + * @param $phone + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException */ public function silenceAuthBindingPhone($code, $spread, $spid, $phone) { @@ -382,8 +396,15 @@ class RoutineServices extends BaseServices /** * 自动获取手机号绑定 * @param $code + * @param $iv + * @param $encryptedData * @param $spread - * @return mixed + * @param $spid + * @param string $key + * @return array + * @throws \Psr\SimpleCache\InvalidArgumentException + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\ModelNotFoundException */ public function authBindingPhone($code, $iv, $encryptedData, $spread, $spid, $key = '') { @@ -394,7 +415,6 @@ class RoutineServices extends BaseServices [$openid, $wechatInfo, $spreadId, $login_type, $userType] = $createData = CacheService::getTokenBucket($key); } - /** @var OAuth $oauth */ $oauth = app()->make(OAuth::class, ['mini_program']); [$userInfoCong, $userInfo] = $oauth->oauth($code, [ @@ -438,6 +458,15 @@ class RoutineServices extends BaseServices } + /** + * 更新用户信息 + * @param $uid + * @param array $data + * @return bool + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ public function updateUserInfo($uid, array $data) { /** @var UserServices $userServices */ diff --git a/crmeb/app/services/wechat/WechatReplyServices.php b/crmeb/app/services/wechat/WechatReplyServices.php index 48f76443c..1887e8b2c 100644 --- a/crmeb/app/services/wechat/WechatReplyServices.php +++ b/crmeb/app/services/wechat/WechatReplyServices.php @@ -19,7 +19,6 @@ use crmeb\exceptions\AdminException; use crmeb\services\app\WechatService; /** - * * Class UserWechatuserServices * @package app\services\user * @method delete($id, ?string $key = null) 删除 @@ -39,7 +38,7 @@ class WechatReplyServices extends BaseServices /** * 消息类型 - * @var string[] + * @return string[] */ public function replyType() { @@ -71,7 +70,8 @@ class WechatReplyServices extends BaseServices } /** - * @param $key + * 关注回复 + * @param string $key * @return array|\think\Model|null * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException @@ -89,7 +89,9 @@ class WechatReplyServices extends BaseServices } /** + * 保存关键字 * @param $data + * @param $id * @param $key * @param $type * @param int $status @@ -213,8 +215,11 @@ class WechatReplyServices extends BaseServices /** * 整理图片资源 * @param $data - * @param $key - * @return array|bool|mixed + * @param $id + * @return array|mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function tidyImage($data, $id) { @@ -246,8 +251,11 @@ class WechatReplyServices extends BaseServices /** * 整理声音资源 * @param $data - * @param $key - * @return array|bool|mixed + * @param $id + * @return array|mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function tidyVoice($data, $id) { @@ -279,17 +287,16 @@ class WechatReplyServices extends BaseServices /** * 整理图文资源 * @param $data - * @param $key + * @param $id * @return bool */ public function tidyNews($data, $id = 0) { -// $data = $data['list'][0]; if (!count($data)) { throw new AdminException(400709); } $siteUrl = sys_config('site_url'); - if (empty($data['url'])) $data['url'] = $siteUrl . '/pages/news_details/index?id=' . $data['id']; + if (empty($data['url'])) $data['url'] = $siteUrl . '/pages/extension/news_details/index?id=' . $data['id']; if (count($data['image_input'])) $data['image'] = $data['image_input'][0]; return $data; } @@ -297,7 +304,11 @@ class WechatReplyServices extends BaseServices /** * 获取关键字 * @param $key + * @param string $openId * @return array|\EasyWeChat\Message\Image|\EasyWeChat\Message\News|\EasyWeChat\Message\Text|\EasyWeChat\Message\Transfer|\EasyWeChat\Message\Voice + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function reply($key, string $openId = '') { diff --git a/crmeb/app/services/wechat/WechatServices.php b/crmeb/app/services/wechat/WechatServices.php index cdca6767c..22566ae45 100644 --- a/crmeb/app/services/wechat/WechatServices.php +++ b/crmeb/app/services/wechat/WechatServices.php @@ -45,6 +45,7 @@ class WechatServices extends BaseServices /** * 微信公众号服务 * @return \think\Response + * @throws \EasyWeChat\Server\BadRequestException */ public function serve() { @@ -54,6 +55,8 @@ class WechatServices extends BaseServices /** * 支付异步回调 + * @return string + * @throws \EasyWeChat\Core\Exceptions\FaultException */ public function notify() { @@ -285,31 +288,36 @@ class WechatServices extends BaseServices /** @var WechatUserServices $wechatUserServices */ $wechatUserServices = app()->make(WechatUserServices::class); $user = $wechatUserServices->getAuthUserInfo($openid, 'wechat'); - if (!$user) {//没有注册用户也没有强制手机号绑定 返回让微信授权登录 - $createData = [$openid, $wechatInfo, $spread, '', 'wechat']; - $userInfoKey = md5($openid . '_' . time() . '_wechat'); - Cache::setTokenBucket($userInfoKey, $createData, 7200); - return ['auth_login' => 1, 'key' => $userInfoKey]; - } else { - //更新用户信息 - $wechatUserServices->wechatUpdata([$user['uid'], ['code' => $spread]]); - $token = $this->createToken((int)$user['uid'], 'wechat'); - if ($token) { - /** @var UserVisitServices $visitServices */ - $visitServices = app()->make(UserVisitServices::class); - $visitServices->loginSaveVisit($user); - $token['userInfo'] = $user; - return $token; - } else - throw new ApiException(410019); - } + $createData = [$openid, $wechatInfo, $spread, '', 'wechat']; + $userInfoKey = md5($openid . '_' . time() . '_wechat'); + Cache::setTokenBucket($userInfoKey, $createData, 7200); + return ['auth_login' => 1, 'key' => $userInfoKey]; +// if (!$user) {//没有注册用户也没有强制手机号绑定 返回让微信授权登录 +// $createData = [$openid, $wechatInfo, $spread, '', 'wechat']; +// $userInfoKey = md5($openid . '_' . time() . '_wechat'); +// Cache::setTokenBucket($userInfoKey, $createData, 7200); +// return ['auth_login' => 1, 'key' => $userInfoKey]; +// } else { +// //更新用户信息 +// $wechatUserServices->wechatUpdata([$user['uid'], ['code' => $spread]]); +// $token = $this->createToken((int)$user['uid'], 'wechat'); +// if ($token) { +// /** @var UserVisitServices $visitServices */ +// $visitServices = app()->make(UserVisitServices::class); +// $visitServices->loginSaveVisit($user); +// $token['userInfo'] = $user; +// return $token; +// } else +// throw new ApiException(410019); +// } } /** * 微信公众号静默授权 - * @param $spread + * @param $key * @param $phone * @return array + * @throws \Psr\SimpleCache\InvalidArgumentException * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException */ @@ -357,9 +365,11 @@ class WechatServices extends BaseServices } /** - * @param array $userInfo + * app登录 + * @param array $userData * @param string $phone - * @return array + * @param string $userType + * @return array|false * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException */ diff --git a/crmeb/public/install/crmeb.sql b/crmeb/public/install/crmeb.sql index bda9d4d88..f197e9a97 100644 --- a/crmeb/public/install/crmeb.sql +++ b/crmeb/public/install/crmeb.sql @@ -26586,11 +26586,90 @@ CREATE TABLE IF NOT EXISTS `eb_out_account` ( `last_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次登录时间', `ip` varchar(30) NOT NULL DEFAULT '' COMMENT 'IP', `is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除', + `push_open` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否推送', + `order_create_push` varchar(255) NOT NULL DEFAULT '' COMMENT '订单创建推送接口', + `order_pay_push` varchar(255) NOT NULL DEFAULT '' COMMENT '订单支付推送接口', + `refund_create_push` varchar(255) NOT NULL DEFAULT '' COMMENT '售后订单创建推送接口', + `refund_cancel_push` varchar(255) NOT NULL DEFAULT '' COMMENT '售后订单取消推送接口', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='对外接口账号' ROW_FORMAT=DYNAMIC; -- -------------------------------------------------------- +-- +-- 表的结构 `eb_out_interface` +-- + +CREATE TABLE IF NOT EXISTS `eb_out_interface` ( + `id` int(11) NOT NULL COMMENT '自增id', + `pid` int(11) NOT NULL DEFAULT '0' COMMENT '父级pid', + `type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0菜单,1接口', + `name` varchar(255) NOT NULL DEFAULT '' COMMENT '接口名称', + `describe` text DEFAULT NULL COMMENT '功能描述', + `method` varchar(255) NOT NULL DEFAULT '' COMMENT '接口类型', + `url` varchar(255) NOT NULL DEFAULT '' COMMENT '接口地址', + `request_params` text DEFAULT NULL COMMENT '请求参数', + `return_params` text DEFAULT NULL COMMENT '返回参数', + `request_example` text DEFAULT NULL COMMENT '请求示例', + `return_example` text DEFAULT NULL COMMENT '返回示例', + `error_code` text DEFAULT NULL COMMENT '错误返回', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='对外接口'; + +-- +-- 转存表中的数据 `eb_out_interface` +-- + +INSERT INTO `eb_out_interface` (`id`, `pid`, `type`, `name`, `describe`, `method`, `url`, `request_params`, `return_params`, `request_example`, `return_example`, `error_code`) VALUES +(1, 0, 0, '第三方授权', NULL, '', '', NULL, NULL, NULL, NULL, NULL), +(2, 1, 1, '获取access_token', NULL, 'post', '/access_token', NULL, NULL, NULL, NULL, NULL), +(3, 1, 1, '刷新access_token', NULL, 'post', '/refresh_token', NULL, NULL, NULL, NULL, NULL), +(4, 0, 0, '用户相关', NULL, '', '', NULL, NULL, NULL, NULL, NULL), +(5, 4, 1, '新增用户', NULL, 'post', '/user', NULL, NULL, NULL, NULL, NULL), +(6, 4, 1, '用户列表', NULL, 'get', '/user/list', NULL, NULL, NULL, NULL, NULL), +(7, 4, 1, '等级列表', NULL, 'get', '/user_level/list', NULL, NULL, NULL, NULL, NULL), +(8, 4, 1, '更新用户', NULL, 'put', '/user/{uid}', NULL, NULL, NULL, NULL, NULL), +(9, 4, 1, '赠送积分余额优惠券会员', NULL, 'put', '/user/give/{uid}', NULL, NULL, NULL, NULL, NULL), +(10, 0, 0, '优惠券相关', NULL, '', '', NULL, NULL, NULL, NULL, NULL), +(11, 10, 1, '新增优惠券', NULL, 'post', '/coupon', NULL, NULL, NULL, NULL, NULL), +(12, 10, 1, '修改优惠券状态', NULL, 'put', '/coupon/status/{id}/{status}', NULL, NULL, NULL, NULL, NULL), +(13, 10, 1, '删除优惠券', NULL, 'delete', '/coupon/{id}', NULL, NULL, NULL, NULL, NULL), +(14, 10, 1, '优惠券列表', NULL, 'get', '/coupon/list', NULL, NULL, NULL, NULL, NULL), +(15, 0, 0, '商品相关', NULL, '', '', NULL, NULL, NULL, NULL, NULL), +(16, 15, 1, '新增分类', NULL, 'post', '/category', NULL, NULL, NULL, NULL, NULL), +(17, 15, 1, '更新分类', NULL, 'put', '/category/{id}', NULL, NULL, NULL, NULL, NULL), +(18, 15, 1, '更新分类状态', NULL, 'put', '/category/set_show/{id}/{is_show}', NULL, NULL, NULL, NULL, NULL), +(19, 15, 1, '删除分类', NULL, 'delete', '/category/{id}', NULL, NULL, NULL, NULL, NULL), +(20, 15, 1, '分类列表', NULL, 'get', '/category/list', NULL, NULL, NULL, NULL, NULL), +(21, 15, 1, '分类详情', NULL, 'get', '/category/{id}', NULL, NULL, NULL, NULL, NULL), +(22, 15, 1, '新增商品', NULL, 'post', '/product', NULL, NULL, NULL, NULL, NULL), +(23, 15, 1, '更新商品', NULL, 'put', '/product/{id}', NULL, NULL, NULL, NULL, NULL), +(24, 15, 1, '更新商品状态', NULL, 'put', '/product/set_show/{id}/{is_show}', NULL, NULL, NULL, NULL, NULL), +(25, 15, 1, '商品列表', NULL, 'get', '/product/list', NULL, NULL, NULL, NULL, NULL), +(26, 15, 1, '商品详情', NULL, 'get', '/product/{id}', NULL, NULL, NULL, NULL, NULL), +(27, 15, 1, '同步商品库存', NULL, 'put', '/product/stock/upload', NULL, NULL, NULL, NULL, NULL), +(28, 0, 0, '订单相关', NULL, '', '', NULL, NULL, NULL, NULL, NULL), +(29, 28, 1, '订单列表', NULL, 'get', '/order/list', NULL, NULL, NULL, NULL, NULL), +(30, 28, 1, '订单详情', NULL, 'get', '/order/{order_id}', NULL, NULL, NULL, NULL, NULL), +(31, 28, 1, '订单未发货商品列表', NULL, 'get', '/order/split_cart_info/{order_id}', NULL, NULL, NULL, NULL, NULL), +(32, 28, 1, '快递公司', NULL, 'get', '/order/express_list', NULL, NULL, NULL, NULL, NULL), +(33, 28, 1, '订单收货', NULL, 'put', '/order/receive/{order_id}', NULL, NULL, NULL, NULL, NULL), +(34, 28, 1, '订单发货', NULL, 'put', '/order/delivery/{order_id}', NULL, NULL, NULL, NULL, NULL), +(35, 28, 1, '订单拆单发货', NULL, 'put', '/order/split_delivery/{order_id}', NULL, NULL, NULL, NULL, NULL), +(36, 28, 1, '修改订单备注', NULL, 'put', '/order/remark/{order_id}', NULL, NULL, NULL, NULL, NULL), +(37, 28, 1, '修改订单配送信息', NULL, 'put', '/order/distribution/{order_id}', NULL, NULL, NULL, NULL, NULL), +(38, 28, 1, '修改订单发票', NULL, 'put', '/order/invoice/{order_id}', NULL, NULL, NULL, NULL, NULL), +(39, 28, 1, '修改订单发票状态', NULL, 'put', '/order/invoice_status/{order_id}', NULL, NULL, NULL, NULL, NULL), +(40, 28, 1, '推送订单', NULL, 'post', '/order/upload', NULL, NULL, NULL, NULL, NULL), +(41, 0, 0, '售后服务', NULL, '', '', NULL, NULL, NULL, NULL, NULL), +(42, 41, 1, '售后订单列表', NULL, 'get', '/refund/list', NULL, NULL, NULL, NULL, NULL), +(43, 41, 1, '售后订单详情', NULL, 'get', '/refund/{order_id}', NULL, NULL, NULL, NULL, NULL), +(44, 41, 1, '修改售后订单备注', NULL, 'put', '/refund/remark/{order_id}', NULL, NULL, NULL, NULL, NULL), +(45, 41, 1, '同意退款', NULL, 'put', '/refund/{order_id}', NULL, NULL, NULL, NULL, NULL), +(46, 41, 1, '拒绝退款', NULL, 'put', '/refund/refuse/{order_id}', NULL, NULL, NULL, NULL, NULL); + +-- -------------------------------------------------------- + -- -- 表的结构 `eb_page_categroy` --