Merge branch 'feature/push' into feature/purchase_record
This commit is contained in:
commit
5ac9ce5b1d
@ -34,7 +34,7 @@ class SystemNoticeConfigDao extends BaseDao
|
|||||||
|
|
||||||
public function getNoticeStatusByConstKey(string $key)
|
public function getNoticeStatusByConstKey(string $key)
|
||||||
{
|
{
|
||||||
$value = $this->getModel()::getDb()->where('const_key',$key)->field('notice_sys,notice_wechat,notice_routine,notice_sms')->find();
|
$value = $this->getModel()::getDb()->where('const_key',$key)->field('notice_sys,notice_wechat,notice_routine,notice_sms,notice_app')->find();
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
201
app/common/service/JgPush.php
Normal file
201
app/common/service/JgPush.php
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\service;
|
||||||
|
|
||||||
|
use app\common\model\system\merchant\Merchant;
|
||||||
|
use app\common\model\user\User;
|
||||||
|
use app\common\repositories\store\order\StoreGroupOrderRepository;
|
||||||
|
use app\common\repositories\store\order\StoreOrderRepository;
|
||||||
|
use JPush\Client;
|
||||||
|
|
||||||
|
class JgPush
|
||||||
|
{
|
||||||
|
|
||||||
|
public $client;
|
||||||
|
public $push;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->client = new Client('b5f679f4357018605ea6fd2e', 'c4fb573758f8d7058d697c54');
|
||||||
|
$this->push = $this->client->push();
|
||||||
|
$this->setPlatform();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function send($type, $data)
|
||||||
|
{
|
||||||
|
switch ($type) {
|
||||||
|
case 'ADMIN_PAY_SUCCESS_CODE':
|
||||||
|
$groupOrder = app()->make(StoreGroupOrderRepository::class)->get($data['id']);
|
||||||
|
if ($groupOrder) {
|
||||||
|
foreach ($groupOrder->orderList as $order) {
|
||||||
|
$route = "/pages/admin/orderDetail/index?id={$order['order_id']}&mer_id={$order['mer_id']}";
|
||||||
|
$merUserId = Merchant::where('mer_id', $order->mer_id)->value('uid');
|
||||||
|
$jgRegisterId = User::where('uid', $merUserId)->value('jg_register_id');
|
||||||
|
if (empty($jgRegisterId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$this->addRegistrationId($jgRegisterId);
|
||||||
|
$this->androidNotification('您有新的订单,请注意查看。', ['extras' => ['route' => $route]]);
|
||||||
|
$this->iosNotification('您有新的订单,请注意查看。', ['extras' => ['route' => $route]]);
|
||||||
|
$this->push->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'DELIVER_GOODS_CODE':
|
||||||
|
case 'ORDER_DELIVER_SUCCESS':
|
||||||
|
$order = app()->make(StoreOrderRepository::class)->get($data['id']);
|
||||||
|
if ($order) {
|
||||||
|
$route = "/pages/order_details/index?order_id={$order['order_id']}";
|
||||||
|
$jgRegisterId = User::where('uid', $order['uid'])->value('jg_register_id');
|
||||||
|
if (!empty($jgRegisterId)) {
|
||||||
|
$this->addRegistrationId($jgRegisterId);
|
||||||
|
$this->androidNotification('您的订单已发货,请注意查看。', ['extras' => ['route' => $route]]);
|
||||||
|
$this->iosNotification('您的订单已发货,请注意查看。', ['extras' => ['route' => $route]]);
|
||||||
|
$this->push->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置推送平台
|
||||||
|
* @param array $platform
|
||||||
|
*/
|
||||||
|
public function setPlatform(array $platform = ['android', 'ios'])
|
||||||
|
{
|
||||||
|
$this->push->setPlatform($platform);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置推送设备
|
||||||
|
* @param $registrationId
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addRegistrationId($registrationId)
|
||||||
|
{
|
||||||
|
$this->push->addRegistrationId($registrationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 给所有平台推送相同的 alert 消息
|
||||||
|
* @param $alert
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setNotificationAlert($alert)
|
||||||
|
{
|
||||||
|
$this->push->setNotificationAlert($alert);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ios平台通知
|
||||||
|
* @param $alert
|
||||||
|
* @param $extras
|
||||||
|
* @return void
|
||||||
|
* @example $extras = ['sound' => 'sound', 'badge' => '+1', 'extras' => ['key' => 'value']
|
||||||
|
*/
|
||||||
|
public function iosNotification($alert, $extras = [])
|
||||||
|
{
|
||||||
|
$this->push->iosNotification($alert, $extras);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* android平台通知
|
||||||
|
* @param $alert
|
||||||
|
* @param $extras
|
||||||
|
* @return void
|
||||||
|
* @example $extras = ['alert' => 'alert', 'title' => 'title', 'extras' => ['key' => 'value']
|
||||||
|
*/
|
||||||
|
public function androidNotification($alert, $extras = [])
|
||||||
|
{
|
||||||
|
$this->push->androidNotification($alert, $extras);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* iOS VOIP 功能
|
||||||
|
* @param $extras
|
||||||
|
* @return void
|
||||||
|
* @example $extras = ['key' => 'value'] //任意自定义 key/value 对,会透传给 APP
|
||||||
|
*/
|
||||||
|
public function voip($extras = [])
|
||||||
|
{
|
||||||
|
$this->push->voip($extras);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $msg_content
|
||||||
|
* @param array $extras
|
||||||
|
* @return void
|
||||||
|
* @example $extras = ['title' => 'title', 'content_type' => 'text', 'extras' => ['key' => 'value']
|
||||||
|
*/
|
||||||
|
public function message($msg_content, array $extras = [])
|
||||||
|
{
|
||||||
|
$this->push->message($msg_content, $extras);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送可选项
|
||||||
|
* @param array $options
|
||||||
|
* @return void
|
||||||
|
* @example $options = ['sendno' => 100, 'time_to_live' => 1, 'apns_production' => false, 'big_push_duration' => 1]
|
||||||
|
* sendno: 表示推送序号,纯粹用来作为 API 调用标识,
|
||||||
|
* time_to_live: 表示离线消息保留时长(秒),
|
||||||
|
* apns_production: 表示APNs是否生产环境,
|
||||||
|
* big_push_duration: 表示定速推送时长(分钟),又名缓慢推送
|
||||||
|
*/
|
||||||
|
public function options(array $options = [])
|
||||||
|
{
|
||||||
|
$this->push->options($options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信通知
|
||||||
|
* @param int $delay 延迟时间,单位秒
|
||||||
|
* @param string $templateId 模板id
|
||||||
|
* @param array $param 模板参数
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setSms(int $delay, string $templateId, array $param = [])
|
||||||
|
{
|
||||||
|
$this->push->setSms($delay, $templateId, $param);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备标签
|
||||||
|
* @param $tag
|
||||||
|
*/
|
||||||
|
public function addTag($tag)
|
||||||
|
{
|
||||||
|
$this->push->addTag($tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备标签AND
|
||||||
|
* @param $tag
|
||||||
|
*/
|
||||||
|
public function addTagAnd($tag)
|
||||||
|
{
|
||||||
|
$this->push->addTagAnd($tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备别名
|
||||||
|
* @param $alias
|
||||||
|
*/
|
||||||
|
public function addAlias($alias)
|
||||||
|
{
|
||||||
|
$this->push->addAlias($alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有用户
|
||||||
|
*/
|
||||||
|
public function addAllAudience()
|
||||||
|
{
|
||||||
|
$this->push->addAllAudience();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -393,6 +393,25 @@ class Auth extends BaseController
|
|||||||
return app('json')->success();
|
return app('json')->success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定极光register_id
|
||||||
|
* @param UserRepository $repository
|
||||||
|
* @return mixed
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function bindJg(UserRepository $repository)
|
||||||
|
{
|
||||||
|
$phone = $this->request->param('phone');
|
||||||
|
$jgRegisterId = $this->request->param('jg_register_id');
|
||||||
|
$user = $repository->accountByUser($phone);
|
||||||
|
if ($user->save(['jg_register_id' => $jgRegisterId]) === false) {
|
||||||
|
return app('json')->fail('绑定失败');
|
||||||
|
}
|
||||||
|
return app('json')->success();
|
||||||
|
}
|
||||||
|
|
||||||
public function getCaptcha()
|
public function getCaptcha()
|
||||||
{
|
{
|
||||||
$codeBuilder = new CaptchaBuilder(null, new PhraseBuilder(4));
|
$codeBuilder = new CaptchaBuilder(null, new PhraseBuilder(4));
|
||||||
|
@ -123,7 +123,7 @@ class paySuccessOrder
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$financialRecordRepository->insertAll($this->finance)) {
|
if ($financialRecordRepository->insertAll($this->finance) === false) {
|
||||||
throw new \Exception('财务流水保存出错');
|
throw new \Exception('财务流水保存出错');
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
@ -15,9 +15,11 @@ namespace crmeb\jobs;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\repositories\system\notice\SystemNoticeConfigRepository;
|
use app\common\repositories\system\notice\SystemNoticeConfigRepository;
|
||||||
|
use app\common\service\JgPush;
|
||||||
use crmeb\interfaces\JobInterface;
|
use crmeb\interfaces\JobInterface;
|
||||||
use crmeb\services\SmsService;
|
use crmeb\services\SmsService;
|
||||||
use crmeb\services\WechatTemplateMessageService;
|
use crmeb\services\WechatTemplateMessageService;
|
||||||
|
use crmeb\utils\DingTalk;
|
||||||
use think\facade\Log;
|
use think\facade\Log;
|
||||||
|
|
||||||
class SendSmsJob implements JobInterface
|
class SendSmsJob implements JobInterface
|
||||||
@ -26,6 +28,17 @@ class SendSmsJob implements JobInterface
|
|||||||
public function fire($job, $data)
|
public function fire($job, $data)
|
||||||
{
|
{
|
||||||
$status = app()->make(SystemNoticeConfigRepository::class)->getNoticeStatusByConstKey($data['tempId']);
|
$status = app()->make(SystemNoticeConfigRepository::class)->getNoticeStatusByConstKey($data['tempId']);
|
||||||
|
if ($status['notice_app'] == 1) {
|
||||||
|
try {
|
||||||
|
/** @var JgPush $client */
|
||||||
|
$client = app()->make(JgPush::class);
|
||||||
|
Log::info('app推送发送数据:' . var_export($data, 1));
|
||||||
|
$client->send($data['tempId'], $data);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::info('app推送消息发送失败' . var_export($data, 1) . $e->getMessage());
|
||||||
|
DingTalk::exception($e, 'app推送消息发送失败' . var_export($data, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($status['notice_sms'] == 1) {
|
if ($status['notice_sms'] == 1) {
|
||||||
try {
|
try {
|
||||||
SmsService::sendMessage($data);
|
SmsService::sendMessage($data);
|
||||||
|
@ -605,6 +605,8 @@ Route::group('api/', function () {
|
|||||||
Route::post('auth/mp', 'api.Auth/mpAuth');
|
Route::post('auth/mp', 'api.Auth/mpAuth');
|
||||||
//绑定小程序账号
|
//绑定小程序账号
|
||||||
Route::post('auth/bindMp', 'api.Auth/bindMp');
|
Route::post('auth/bindMp', 'api.Auth/bindMp');
|
||||||
|
//绑定极光register_id
|
||||||
|
Route::post('auth/bindJg', 'api.Auth/bindJg');
|
||||||
//app授权
|
//app授权
|
||||||
Route::post('auth/app', 'api.Auth/appAuth');
|
Route::post('auth/app', 'api.Auth/appAuth');
|
||||||
//apple授权
|
//apple授权
|
||||||
|
12
vendor/composer/ClassLoader.php
vendored
12
vendor/composer/ClassLoader.php
vendored
@ -429,7 +429,8 @@ class ClassLoader
|
|||||||
public function loadClass($class)
|
public function loadClass($class)
|
||||||
{
|
{
|
||||||
if ($file = $this->findFile($class)) {
|
if ($file = $this->findFile($class)) {
|
||||||
(self::$includeFile)($file);
|
$includeFile = self::$includeFile;
|
||||||
|
$includeFile($file);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -560,7 +561,10 @@ class ClassLoader
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function initializeIncludeClosure(): void
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private static function initializeIncludeClosure()
|
||||||
{
|
{
|
||||||
if (self::$includeFile !== null) {
|
if (self::$includeFile !== null) {
|
||||||
return;
|
return;
|
||||||
@ -574,8 +578,8 @@ class ClassLoader
|
|||||||
* @param string $file
|
* @param string $file
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
self::$includeFile = static function($file) {
|
self::$includeFile = \Closure::bind(static function($file) {
|
||||||
include $file;
|
include $file;
|
||||||
};
|
}, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
vendor/composer/InstalledVersions.php
vendored
17
vendor/composer/InstalledVersions.php
vendored
@ -98,7 +98,7 @@ class InstalledVersions
|
|||||||
{
|
{
|
||||||
foreach (self::getInstalled() as $installed) {
|
foreach (self::getInstalled() as $installed) {
|
||||||
if (isset($installed['versions'][$packageName])) {
|
if (isset($installed['versions'][$packageName])) {
|
||||||
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ class InstalledVersions
|
|||||||
*/
|
*/
|
||||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||||
{
|
{
|
||||||
$constraint = $parser->parseConstraints($constraint);
|
$constraint = $parser->parseConstraints((string) $constraint);
|
||||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||||
|
|
||||||
return $provided->matches($constraint);
|
return $provided->matches($constraint);
|
||||||
@ -328,7 +328,9 @@ class InstalledVersions
|
|||||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||||
$installed[] = self::$installedByVendor[$vendorDir];
|
$installed[] = self::$installedByVendor[$vendorDir];
|
||||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||||
|
$required = require $vendorDir.'/composer/installed.php';
|
||||||
|
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
||||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||||
self::$installed = $installed[count($installed) - 1];
|
self::$installed = $installed[count($installed) - 1];
|
||||||
}
|
}
|
||||||
@ -340,12 +342,17 @@ class InstalledVersions
|
|||||||
// only require the installed.php file if this file is loaded from its dumped location,
|
// only require the installed.php file if this file is loaded from its dumped location,
|
||||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||||
self::$installed = require __DIR__ . '/installed.php';
|
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||||
|
$required = require __DIR__ . '/installed.php';
|
||||||
|
self::$installed = $required;
|
||||||
} else {
|
} else {
|
||||||
self::$installed = array();
|
self::$installed = array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$installed[] = self::$installed;
|
|
||||||
|
if (self::$installed !== array()) {
|
||||||
|
$installed[] = self::$installed;
|
||||||
|
}
|
||||||
|
|
||||||
return $installed;
|
return $installed;
|
||||||
}
|
}
|
||||||
|
6
vendor/composer/autoload_real.php
vendored
6
vendor/composer/autoload_real.php
vendored
@ -34,15 +34,15 @@ class ComposerAutoloaderInitb1229d2685c190533aa1234015613f09
|
|||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitb1229d2685c190533aa1234015613f09::$files;
|
$filesToLoad = \Composer\Autoload\ComposerStaticInitb1229d2685c190533aa1234015613f09::$files;
|
||||||
$requireFile = static function ($fileIdentifier, $file) {
|
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
|
|
||||||
require $file;
|
require $file;
|
||||||
}
|
}
|
||||||
};
|
}, null, null);
|
||||||
foreach ($filesToLoad as $fileIdentifier => $file) {
|
foreach ($filesToLoad as $fileIdentifier => $file) {
|
||||||
($requireFile)($fileIdentifier, $file);
|
$requireFile($fileIdentifier, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $loader;
|
return $loader;
|
||||||
|
4
vendor/composer/installed.php
vendored
4
vendor/composer/installed.php
vendored
@ -3,7 +3,7 @@
|
|||||||
'name' => 'topthink/think',
|
'name' => 'topthink/think',
|
||||||
'pretty_version' => 'dev-master',
|
'pretty_version' => 'dev-master',
|
||||||
'version' => 'dev-master',
|
'version' => 'dev-master',
|
||||||
'reference' => '9ff9e05d922b426d2829e28386114e1d19ba5adb',
|
'reference' => 'fa730cf99f81c843e926f633ad856764fdcf6f49',
|
||||||
'type' => 'project',
|
'type' => 'project',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
@ -892,7 +892,7 @@
|
|||||||
'topthink/think' => array(
|
'topthink/think' => array(
|
||||||
'pretty_version' => 'dev-master',
|
'pretty_version' => 'dev-master',
|
||||||
'version' => 'dev-master',
|
'version' => 'dev-master',
|
||||||
'reference' => '9ff9e05d922b426d2829e28386114e1d19ba5adb',
|
'reference' => 'fa730cf99f81c843e926f633ad856764fdcf6f49',
|
||||||
'type' => 'project',
|
'type' => 'project',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user