mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-29 14:01:07 +00:00
【程序目录】优化配置
This commit is contained in:
parent
2821b2833d
commit
2c3f3d5d77
@ -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'];
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -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' => '对外接口列表']);
|
||||
|
||||
/** 多语言 */
|
||||
//语言国家列表
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 = '')
|
||||
{
|
||||
|
||||
14
crmeb/app/dao/out/OutInterfaceDao.php
Normal file
14
crmeb/app/dao/out/OutInterfaceDao.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace app\dao\out;
|
||||
|
||||
use app\dao\BaseDao;
|
||||
use app\model\out\OutInterface;
|
||||
|
||||
class OutInterfaceDao extends BaseDao
|
||||
{
|
||||
protected function setModel(): string
|
||||
{
|
||||
return OutInterface::class;
|
||||
}
|
||||
}
|
||||
@ -34,6 +34,7 @@ return [
|
||||
'order.orderTake' => [\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], //通知->消息事件
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
124
crmeb/app/jobs/OutPushJob.php
Normal file
124
crmeb/app/jobs/OutPushJob.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace app\jobs;
|
||||
|
||||
use app\services\order\OutStoreOrderRefundServices;
|
||||
use app\services\order\OutStoreOrderServices;
|
||||
use crmeb\basic\BaseJobs;
|
||||
use crmeb\traits\QueueTrait;
|
||||
use think\facade\Log;
|
||||
|
||||
class OutPushJob extends BaseJobs
|
||||
{
|
||||
use QueueTrait;
|
||||
|
||||
/**
|
||||
* 订单推送
|
||||
* @param int $oid
|
||||
* @param string $pushUrl
|
||||
* @param int $step
|
||||
* @return bool
|
||||
*/
|
||||
public function orderCreate(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->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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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']]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
31
crmeb/app/listener/out/OutPush.php
Normal file
31
crmeb/app/listener/out/OutPush.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\listener\out;
|
||||
|
||||
use app\jobs\OutPushJob;
|
||||
use app\services\out\OutAccountServices;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
|
||||
class OutPush implements ListenerInterface
|
||||
{
|
||||
public function handle($event): void
|
||||
{
|
||||
[$type, $orderId] = $event;
|
||||
/** @var OutAccountServices $outAccountServices */
|
||||
$outAccountServices = app()->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']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
crmeb/app/model/out/OutInterface.php
Normal file
30
crmeb/app/model/out/OutInterface.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace app\model\out;
|
||||
|
||||
use crmeb\basic\BaseModel;
|
||||
use crmeb\traits\ModelTrait;
|
||||
|
||||
class OutInterface extends BaseModel
|
||||
{
|
||||
use ModelTrait;
|
||||
|
||||
/**
|
||||
* 数据表主键
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'out_interface';
|
||||
|
||||
public function searchTypeAttr($query, $value)
|
||||
{
|
||||
if ($value !== '') {
|
||||
$query->where('type', $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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, '取消售后单');
|
||||
}
|
||||
|
||||
|
||||
@ -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, '订单支付');
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
64
crmeb/app/services/out/OutInterfaceServices.php
Normal file
64
crmeb/app/services/out/OutInterfaceServices.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace app\services\out;
|
||||
|
||||
use app\dao\out\OutInterfaceDao;
|
||||
use app\Request;
|
||||
use app\services\BaseServices;
|
||||
use crmeb\exceptions\AuthException;
|
||||
|
||||
class OutInterfaceServices extends BaseServices
|
||||
{
|
||||
public function __construct(OutInterfaceDao $dao)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -154,7 +154,6 @@ class SystemConfigServices extends BaseServices
|
||||
],
|
||||
'pay_weixin_client_cert' => '',
|
||||
'pay_weixin_client_key' => '',
|
||||
'paydir' => '',
|
||||
],
|
||||
'show_value' => 1
|
||||
],
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 */
|
||||
|
||||
@ -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 = '')
|
||||
{
|
||||
|
||||
@ -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
|
||||
*/
|
||||
|
||||
@ -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`
|
||||
--
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user