mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-11-06 01:40:37 +00:00
Merge branch 'v5.0.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.0.0dev
This commit is contained in:
commit
4f218087e1
@ -11,9 +11,11 @@
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\utils\Rsa;
|
||||
use think\facade\App;
|
||||
use crmeb\utils\Captcha;
|
||||
use app\services\system\admin\SystemAdminServices;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 后台登陆
|
||||
@ -83,7 +85,7 @@ class Login extends AuthController
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function login()
|
||||
public function login(Rsa $rsa)
|
||||
{
|
||||
[$account, $password, $key, $captchaVerification, $captchaType] = $this->request->postMore([
|
||||
'account',
|
||||
@ -93,6 +95,7 @@ class Login extends AuthController
|
||||
['captchaType', '']
|
||||
], true);
|
||||
|
||||
|
||||
if ($captchaVerification != '') {
|
||||
try {
|
||||
aj_captcha_check_two($captchaType, $captchaVerification);
|
||||
@ -101,10 +104,25 @@ class Login extends AuthController
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (strlen(trim($password)) > 500) {
|
||||
return app('json')->fail(400762);
|
||||
}
|
||||
$password = $rsa->privateDecrypt($password);
|
||||
} catch (\Throwable $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
|
||||
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 32) {
|
||||
return app('json')->fail(400762);
|
||||
}
|
||||
|
||||
$this->validate(['account' => $account, 'pwd' => $password], \app\adminapi\validate\setting\SystemAdminValidata::class, 'get');
|
||||
|
||||
|
||||
$result = $this->services->login($account, $password, 'admin', $key);
|
||||
if (!$result) {
|
||||
$num = CacheService::get('login_captcha',1);
|
||||
$num = CacheService::get('login_captcha', 1);
|
||||
if ($num > 1) {
|
||||
return app('json')->fail(400140, ['login_captcha' => 1]);
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -53,10 +53,12 @@ class LoginController
|
||||
[$account, $password, $spread] = $request->postMore([
|
||||
'account', 'password', 'spread'
|
||||
], true);
|
||||
TaskJob::dispatch('emptyYesterdayAttachment');
|
||||
if (!$account || !$password) {
|
||||
return app('json')->fail(410000);
|
||||
}
|
||||
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 32) {
|
||||
return app('json')->fail(400762);
|
||||
}
|
||||
return app('json')->success(410001, $this->services->login($account, $password, $spread));
|
||||
}
|
||||
|
||||
@ -193,14 +195,15 @@ class LoginController
|
||||
} catch (ValidateException $e) {
|
||||
return app('json')->fail($e->getError());
|
||||
}
|
||||
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 32) {
|
||||
return app('json')->fail(400762);
|
||||
}
|
||||
$verifyCode = CacheService::get('code_' . $account);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail(410009);
|
||||
$verifyCode = substr($verifyCode, 0, 6);
|
||||
if ($verifyCode != $captcha)
|
||||
return app('json')->fail(410010);
|
||||
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 16)
|
||||
return app('json')->fail(410011);
|
||||
if (md5($password) == md5('123456')) return app('json')->fail(410012);
|
||||
|
||||
$registerStatus = $this->services->register($account, $password, $spread, 'h5');
|
||||
@ -226,6 +229,9 @@ class LoginController
|
||||
} catch (ValidateException $e) {
|
||||
return app('json')->fail($e->getError());
|
||||
}
|
||||
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 32) {
|
||||
return app('json')->fail(400762);
|
||||
}
|
||||
$verifyCode = CacheService::get('code_' . $account);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail(410009);
|
||||
@ -233,8 +239,6 @@ class LoginController
|
||||
if ($verifyCode != $captcha) {
|
||||
return app('json')->fail(410010);
|
||||
}
|
||||
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 16)
|
||||
return app('json')->fail(410011);
|
||||
if ($password == '123456') return app('json')->fail(410012);
|
||||
$resetStatus = $this->services->reset($account, $password);
|
||||
if ($resetStatus) return app('json')->success(100001);
|
||||
|
||||
@ -42,6 +42,14 @@ class WechatController
|
||||
{
|
||||
return $this->services->serve();
|
||||
}
|
||||
/**
|
||||
* 微信小程序公众号服务
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function miniServe()
|
||||
{
|
||||
return $this->services->miniServe();
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付异步回调
|
||||
|
||||
@ -16,6 +16,7 @@ use think\Response;
|
||||
|
||||
Route::group(function () {
|
||||
Route::any('wechat/serve', 'v1.wechat.WechatController/serve')->option(['real_name' => '公众号服务']);//公众号服务
|
||||
Route::any('wechat/miniServe', 'v1.wechat.WechatController/miniServe')->option(['real_name' => '小程序服务']);//公众号服务
|
||||
Route::any('pay/notify/:type', 'v1.PayController/notify')->option(['real_name' => '支付回调']);//支付回调
|
||||
Route::get('get_script', 'v1.PublicController/getScript')->option(['real_name' => '获取统计代码']);//获取统计代码
|
||||
Route::get('version', 'v1.PublicController/getVersion')->option(['real_name' => '获取代码版本号']);
|
||||
|
||||
@ -14,6 +14,7 @@ namespace app\services\message\notice;
|
||||
use app\jobs\TemplateJob;
|
||||
use app\services\message\NoticeService;
|
||||
use app\services\kefu\service\StoreServiceServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\wechat\WechatUserServices;
|
||||
use think\facade\Log;
|
||||
|
||||
@ -52,9 +53,13 @@ class WechatTemplateListService extends NoticeService
|
||||
*/
|
||||
public function getOpenidByUid(int $uid)
|
||||
{
|
||||
/** @var WechatUserServices $wechatServices */
|
||||
$wechatServices = app()->make(WechatUserServices::class);
|
||||
return $wechatServices->uidToOpenid($uid, 'wechat');
|
||||
$isDel = app()->make(UserServices::class)->value(['uid' => $uid], 'is_del');
|
||||
if ($isDel) {
|
||||
$openid = '';
|
||||
} else {
|
||||
$openid = app()->make(WechatUserServices::class)->uidToOpenid($uid, 'wechat');
|
||||
}
|
||||
return $openid;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,8 +76,10 @@ class WechatTemplateListService extends NoticeService
|
||||
$this->isOpen = $this->noticeInfo['is_wechat'] === 1;
|
||||
if ($this->isOpen) {
|
||||
$openid = $this->getOpenidByUid($uid);
|
||||
//放入队列执行
|
||||
TemplateJob::dispatch('doJob', ['wechat', $openid, $this->noticeInfo['mark'], $data, $link, $color]);
|
||||
if ($openid != '') {
|
||||
//放入队列执行
|
||||
TemplateJob::dispatch('doJob', ['wechat', $openid, $this->noticeInfo['mark'], $data, $link, $color]);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
|
||||
@ -440,6 +440,8 @@ class StoreOrderDeliveryServices extends BaseServices
|
||||
/** @var StoreOrderCartInfoServices $orderInfoServices */
|
||||
$orderInfoServices = app()->make(StoreOrderCartInfoServices::class);
|
||||
$storeName = $orderInfoServices->getCarIdByProductTitle((int)$orderInfo->id);
|
||||
// 发货信息录入
|
||||
event('OrderShipping', [$orderInfo, $type, $data['delivery_id'], $data['delivery_name']]);
|
||||
$res = [];
|
||||
switch ($type) {
|
||||
case 1://快递发货
|
||||
|
||||
@ -35,6 +35,7 @@ use crmeb\exceptions\AdminException;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\exceptions\PayException;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\easywechat\orderShipping\MiniOrderService;
|
||||
use crmeb\services\FormBuilder as Form;
|
||||
use crmeb\services\printer\Printer;
|
||||
use crmeb\services\SystemConfigService;
|
||||
@ -2495,6 +2496,11 @@ HTML;
|
||||
'help_status' => 1
|
||||
];
|
||||
}
|
||||
// 判断是否开启小程序订单管理
|
||||
$orderData['order_shipping_open'] = false;
|
||||
if (sys_config('order_shipping_open', 0) && MiniOrderService::isManaged()) {
|
||||
$orderData['order_shipping_open'] = true;
|
||||
}
|
||||
return $orderData;
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ use app\services\system\SystemMenusServices;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\FormBuilder;
|
||||
use crmeb\services\workerman\ChannelService;
|
||||
use crmeb\utils\Rsa;
|
||||
use think\facade\Config;
|
||||
use think\facade\Event;
|
||||
use think\Model;
|
||||
@ -167,7 +168,8 @@ class SystemAdminServices extends BaseServices
|
||||
'copyright' => sys_config('nncnL_crmeb_copyright', ''),
|
||||
'version' => get_crmeb_version(),
|
||||
'key' => $key,
|
||||
'login_captcha' => 0
|
||||
'login_captcha' => 0,
|
||||
'publicKey' => app()->make(Rsa::class)->getPublicKey()
|
||||
];
|
||||
if (CacheService::get('login_captcha', 1) > 1) {
|
||||
$data['login_captcha'] = 1;
|
||||
|
||||
@ -314,12 +314,7 @@ class SystemStorageServices extends BaseServices
|
||||
break;
|
||||
case 4:// cos 腾讯云
|
||||
$upload = UploadService::init($type);
|
||||
$cosList = $upload->listbuckets();
|
||||
if (isset($cosList['Name'])) {
|
||||
$list[] = $cosList;
|
||||
} else {
|
||||
$list = $cosList;
|
||||
}
|
||||
$list = $upload->listbuckets();
|
||||
$config = $this->getStorageConfig($type);
|
||||
foreach ($list as $item) {
|
||||
if (!$this->dao->count(['name' => $item['Name'], 'access_key' => $config['accessKey']])) {
|
||||
|
||||
@ -4,6 +4,7 @@ namespace app\services\user;
|
||||
|
||||
use app\dao\user\UserCancelDao;
|
||||
use app\services\BaseServices;
|
||||
use app\services\kefu\service\StoreServiceServices;
|
||||
use app\services\wechat\WechatUserServices;
|
||||
use crmeb\services\CacheService;
|
||||
|
||||
@ -31,9 +32,13 @@ class UserCancelServices extends BaseServices
|
||||
$userServices = app()->make(UserServices::class);
|
||||
/** @var WechatUserServices $wechatUserServices */
|
||||
$wechatUserServices = app()->make(WechatUserServices::class);
|
||||
/** @var StoreServiceServices $ServiceServices */
|
||||
$ServiceServices = app()->make(StoreServiceServices::class);
|
||||
$userServices->update($uid, ['is_del' => 1]);
|
||||
$userServices->update(['spread_uid' => $uid], ['spread_uid' => 0, 'spread_time' => 0]);
|
||||
$wechatUserServices->update(['uid' => $uid], ['is_del' => 1]);
|
||||
$ServiceServices->delete(['uid' => $uid]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -479,7 +479,7 @@ class RoutineServices extends BaseServices
|
||||
if (!$userInfo || !isset($userInfo['purePhoneNumber'])) {
|
||||
throw new ApiException(410079);
|
||||
}
|
||||
$uid = app()->make(WechatUserServices::class)->openidTouid($userInfoCong['openid']);
|
||||
$uid = app()->make(WechatUserServices::class)->openidToUid($userInfoCong['openid']);
|
||||
$userServices = app()->make(UserServices::class);
|
||||
if ($userServices->count(['phone' => $userInfo['purePhoneNumber']])) {
|
||||
throw new ApiException(410028);
|
||||
|
||||
@ -17,6 +17,7 @@ use app\dao\wechat\WechatUserDao;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\user\UserVisitServices;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\services\app\MiniProgramService;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\CacheService as Cache;
|
||||
use crmeb\services\app\WechatService as WechatAuthService;
|
||||
@ -53,6 +54,17 @@ class WechatServices extends BaseServices
|
||||
return WechatAuthService::serve();
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信公众号服务
|
||||
* @return \think\Response
|
||||
* @throws \EasyWeChat\Server\BadRequestException
|
||||
*/
|
||||
public function miniServe()
|
||||
{
|
||||
ob_clean();
|
||||
return MiniProgramService::serve();
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付异步回调
|
||||
* @return string
|
||||
|
||||
@ -83,7 +83,7 @@ class WechatUserServices extends BaseServices
|
||||
* @param string $openidType
|
||||
* @return mixed
|
||||
*/
|
||||
public function openidTouid($openid, $openidType = 'openid')
|
||||
public function openidToUid($openid, string $openidType = 'openid')
|
||||
{
|
||||
$uid = $this->dao->value([[$openidType, '=', $openid], ['user_type', '<>', 'h5']], 'uid');
|
||||
if (!$uid)
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
|
||||
namespace crmeb\services\app;
|
||||
|
||||
use app\services\order\StoreOrderTakeServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\services\SystemConfigService;
|
||||
use app\services\pay\PayNotifyServices;
|
||||
@ -19,6 +20,7 @@ use EasyWeChat\Payment\Order;
|
||||
use think\facade\Log;
|
||||
use crmeb\utils\Hook;
|
||||
use think\facade\Cache;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 微信小程序接口
|
||||
@ -100,6 +102,16 @@ class MiniProgramService
|
||||
$appId = isset($wechat['routine_appId']) ? trim($wechat['routine_appId']) : '';
|
||||
$appsecret = isset($wechat['routine_appsecret']) ? trim($wechat['routine_appsecret']) : '';
|
||||
}
|
||||
$config = [
|
||||
'token' => isset($wechat['wechat_token']) ? trim($wechat['wechat_token']) : '',
|
||||
'aes_key' => isset($wechat['wechat_encodingaeskey']) ? trim($wechat['wechat_encodingaeskey']) : '',
|
||||
'debug' => true,
|
||||
'log' => [
|
||||
'level' => 'debug',
|
||||
'permission' => 0777,
|
||||
'file' => '/www/wwwroot/bz.wuht.net/crmeb/crmeb/runtime/log/easywechat.log',
|
||||
],
|
||||
];
|
||||
$config['mini_program'] = [
|
||||
'app_id' => $appId,
|
||||
'secret' => $appsecret,
|
||||
@ -848,4 +860,44 @@ class MiniProgramService
|
||||
}
|
||||
return $message ?: self::MSG_CODE[$e->getCode()] ?? $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
* @throws \EasyWeChat\Server\BadRequestException
|
||||
*/
|
||||
public static function serve(): Response
|
||||
{
|
||||
$wechat = self::application(true);
|
||||
$server = $wechat->server;
|
||||
self::hook($server);
|
||||
$response = $server->serve();
|
||||
return response($response->getContent());
|
||||
}
|
||||
|
||||
private static function hook($server)
|
||||
{
|
||||
$server->setMessageHandler(function ($message) {
|
||||
switch ($message->MsgType) {
|
||||
case 'event':
|
||||
switch (strtolower($message->Event)) {
|
||||
case 'trade_manage_remind_access_api': // 小程序完成账期授权时 小程序产生第一笔交易时 已产生交易但从未发货的小程序,每天一次
|
||||
break;
|
||||
case 'trade_manage_remind_shipping': // 曾经发过货的小程序,订单超过48小时未发货时
|
||||
break;
|
||||
case 'trade_manage_order_settlement': // 订单完成发货时 订单结算时
|
||||
if (isset($message['estimated_settlement_time'])) { //订单完成发货时
|
||||
|
||||
}
|
||||
if (isset($message['confirm_receive_method'])) { // 订单结算时
|
||||
/** @var StoreOrderTakeServices $StoreOrderTakeServices */
|
||||
$storeOrderTakeServices = app()->make(StoreOrderTakeServices::class);
|
||||
$storeOrderTakeServices->takeOrder($message['merchant_trade_no'], 0);
|
||||
}
|
||||
break;
|
||||
};
|
||||
break;
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,17 +12,21 @@ class BaseOrder extends AbstractAPI
|
||||
{
|
||||
|
||||
public $config;
|
||||
public $accessToken;
|
||||
|
||||
const BASE_API = 'https://api.weixin.qq.com/';
|
||||
|
||||
const ORDER = 'wxa/sec/order/';
|
||||
const EXPRESS = 'cgi-bin/express/delivery/open_msg/';
|
||||
|
||||
const PATH = '/pages/goods/order_details/index';
|
||||
|
||||
|
||||
public function __construct(AccessToken $accessToken, $config)
|
||||
{
|
||||
parent::__construct($accessToken);
|
||||
$this->config = $config;
|
||||
$this->accessToken = $accessToken;
|
||||
}
|
||||
|
||||
private function resultHandle(Collection $result)
|
||||
@ -38,6 +42,73 @@ class BaseOrder extends AbstractAPI
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* request.
|
||||
*
|
||||
* @param string $endpoint
|
||||
* @param string $method
|
||||
* @param array $options
|
||||
* @param bool $returnResponse
|
||||
*/
|
||||
public function request(string $method, string $endpoint, array $options = [])
|
||||
{
|
||||
|
||||
if (isset($options['json'])) {
|
||||
$body = json_encode($options['json']);
|
||||
$options['body'] = $body;
|
||||
unset($options['json']);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Content-Type' => 'text/plain',
|
||||
'User-Agent' => 'curl',
|
||||
'Accept' => 'text/plain',
|
||||
];
|
||||
|
||||
$options['headers'] = array_merge($headers, ($options['headers'] ?? []));
|
||||
|
||||
|
||||
return $this->_doRequestCurl($method, self::BASE_API . $endpoint, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $method
|
||||
* @param $location
|
||||
* @param array $options
|
||||
* @return mixed
|
||||
*/
|
||||
private function _doRequestCurl($method, $location, $options = [])
|
||||
{
|
||||
//拼接$accessToken
|
||||
$location .= $this->accessToken->getToken();
|
||||
var_dump($location);
|
||||
$curl = curl_init();
|
||||
// POST数据设置
|
||||
if (strtolower($method) === 'post') {
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $options['data'] ?? $options['body'] ?? '');
|
||||
}
|
||||
// CURL头信息设置
|
||||
if (!empty($options['headers'])) {
|
||||
$headers = [];
|
||||
foreach ($options['headers'] as $k => $v) {
|
||||
$headers[] = "$k: $v";
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_URL, $location);
|
||||
curl_setopt($curl, CURLOPT_HEADER, true);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
$content = curl_exec($curl);
|
||||
$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
||||
curl_close($curl);
|
||||
return json_decode(substr($content, $headerSize), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发货
|
||||
* @param $params
|
||||
@ -49,8 +120,7 @@ class BaseOrder extends AbstractAPI
|
||||
*/
|
||||
public function shipping($params)
|
||||
{
|
||||
return $this->resultHandle($this->parseJSON('POST', [self::BASE_API . self::ORDER . 'upload_shipping_info', json_encode($params)]));
|
||||
|
||||
return $this->resultHandle($this->parseJSON('POST', [self::BASE_API . self::ORDER . 'upload_shipping_info', json_encode($params, JSON_UNESCAPED_UNICODE)]));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,7 +166,7 @@ class BaseOrder extends AbstractAPI
|
||||
$params = [
|
||||
'appid' => $this->config['config']['mini_program']['app_id']
|
||||
];
|
||||
return $this->resultHandle($this->parseJSON('POST', [self::BASE_API . self::ORDER . 'notify_confirm_receive', json_encode($params)]));
|
||||
return $this->resultHandle($this->parseJSON('POST', [self::BASE_API . self::ORDER . 'is_trade_managed', json_encode($params)]));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,6 +196,6 @@ class BaseOrder extends AbstractAPI
|
||||
*/
|
||||
public function getDeliveryList()
|
||||
{
|
||||
return $this->resultHandle($this->parseJSON('POST', [self::BASE_API . self::EXPRESS . 'get_delivery_list']));
|
||||
return $this->resultHandle($this->parseJSON('POST', [self::BASE_API . self::EXPRESS . 'get_delivery_list', "{}"]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ use EasyWeChat\Core\Exceptions\HttpException;
|
||||
|
||||
class MiniOrderService
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Application
|
||||
*/
|
||||
@ -25,6 +24,12 @@ class MiniOrderService
|
||||
{
|
||||
$payment = SystemConfigService::more(['routine_appId', 'routine_appsecret', 'pay_weixin_mchid', 'pay_new_weixin_open', 'pay_new_weixin_mchid']);
|
||||
return [
|
||||
'debug' => true,
|
||||
'log' => [
|
||||
'level' => 'debug',
|
||||
'permission' => 0777,
|
||||
'file' => '/www/wwwroot/bz.wuht.net/crmeb/crmeb/runtime/log/easywechat.log',
|
||||
],
|
||||
'mini_program' => [
|
||||
'app_id' => $payment['routine_appId'] ?? '',
|
||||
'secret' => $payment['routine_appsecret'] ?? '',
|
||||
|
||||
@ -70,9 +70,11 @@ class OrderClient extends BaseOrder
|
||||
*/
|
||||
public function shippingByTradeNo(string $out_trade_no, int $logistics_type, array $shipping_list, string $payer_openid, int $delivery_mode = 1, bool $is_all_delivered = true)
|
||||
{
|
||||
if (!$this->checkManaged()) {
|
||||
throw new AdminException('开通小程序订单管理服务后重试');
|
||||
}
|
||||
// $this->setMesJumpPath('demo');
|
||||
|
||||
// if (!$this->checkManaged()) {
|
||||
// throw new AdminException('开通小程序订单管理服务后重试');
|
||||
// }
|
||||
|
||||
|
||||
$params = [
|
||||
@ -101,6 +103,9 @@ class OrderClient extends BaseOrder
|
||||
'contact' => $contact
|
||||
];
|
||||
}
|
||||
|
||||
// 跳转路径
|
||||
$this->setMesJumpPath(self::PATH . '?order_id=' . $out_trade_no);
|
||||
return $this->shipping($params);
|
||||
}
|
||||
|
||||
@ -234,7 +239,7 @@ class OrderClient extends BaseOrder
|
||||
$list = $this->getDeliveryList();
|
||||
if ($list) {
|
||||
$key = self::redis_prefix . '_delivery_list';
|
||||
$date = array_column($list, 'delivery_id', 'delivery_name');
|
||||
$date = array_column($list['delivery_list'], 'delivery_id', 'delivery_name');
|
||||
// 创建缓存
|
||||
$this->getRedis()->hMSet($key, $date);
|
||||
|
||||
@ -263,7 +268,7 @@ class OrderClient extends BaseOrder
|
||||
}
|
||||
$express_company = $date[$company_name];
|
||||
} else {
|
||||
$express_company = $this->getRedis()->hMGet($key, $company_name);
|
||||
$express_company = $this->getRedis()->hMGet($key, [$company_name])[$company_name] ?? '';
|
||||
}
|
||||
if (empty($express_company)) {
|
||||
throw new AdminException('物流公司异常2');
|
||||
|
||||
@ -380,7 +380,7 @@ class Cos extends BaseUpload
|
||||
{
|
||||
try {
|
||||
$res = $this->app()->listBuckets();
|
||||
return $res->toArray()['Buckets'] ?? [];
|
||||
return $res['Buckets']['Bucket'] ?? [];
|
||||
} catch (\Throwable $e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
200
crmeb/crmeb/utils/Rsa.php
Normal file
200
crmeb/crmeb/utils/Rsa.php
Normal file
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace crmeb\utils;
|
||||
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* Class Rsa
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/5/16
|
||||
* @package crmeb\utils
|
||||
*/
|
||||
class Rsa
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $publicKey;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $privateKey;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $basePath;
|
||||
|
||||
/**
|
||||
* 获取证书文件
|
||||
* @param $publicKey
|
||||
* @param $privateKey
|
||||
*/
|
||||
public function __construct(string $publicKey = 'cert_public_password.key', string $privateKey = 'cert_private_password.key')
|
||||
{
|
||||
$this->basePath = app()->getRootPath();
|
||||
if ($publicKey) {
|
||||
$this->publicKey = $this->basePath . $publicKey;
|
||||
}
|
||||
if ($privateKey) {
|
||||
$this->privateKey = $this->basePath . $publicKey;
|
||||
}
|
||||
if (!is_file($this->publicKey) || !is_file($this->privateKey)) {
|
||||
$this->exportOpenSSLFile();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false|string
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/5/16
|
||||
*/
|
||||
public function getPublicKey()
|
||||
{
|
||||
if (!is_file($this->publicKey)) {
|
||||
$this->exportOpenSSLFile();
|
||||
}
|
||||
|
||||
return file_get_contents($this->publicKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成证书
|
||||
* @return bool
|
||||
*/
|
||||
public function exportOpenSSLFile($passwork = null)
|
||||
{
|
||||
|
||||
$publicKey = $privateKey = '';
|
||||
$dir = app()->getRootPath() . 'runtime/conf';
|
||||
$conf = 'openssl.cnf';
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0700);
|
||||
}
|
||||
if (!file_exists($conf)) {
|
||||
touch($dir . '/' . $conf);
|
||||
}
|
||||
|
||||
//参数设置
|
||||
$config = [
|
||||
"digest_alg" => "sha256",
|
||||
//字节数 512 1024 2048 4096 等
|
||||
"private_key_bits" => 1024,
|
||||
"config" => $dir . '/' . $conf,
|
||||
//加密类型
|
||||
"private_key_type" => OPENSSL_KEYTYPE_RSA,
|
||||
];
|
||||
|
||||
//创建私钥和公钥
|
||||
$res = openssl_pkey_new($config);
|
||||
if ($res == false) {
|
||||
//创建失败,请检查openssl.cnf文件是否存在
|
||||
return false;
|
||||
}
|
||||
|
||||
//将密钥导出为PEM编码的字符串,并输出(通过引用传递)。
|
||||
openssl_pkey_export($res, $privateKey, $passwork, $config);
|
||||
$publicKey = openssl_pkey_get_details($res);
|
||||
$publicKey = $publicKey["key"];
|
||||
|
||||
//生成证书
|
||||
$createPublicFileRet = file_put_contents($this->publicKey, $publicKey);
|
||||
$createPrivateFileRet = file_put_contents($this->privateKey, $privateKey);
|
||||
if (!($createPublicFileRet || $createPrivateFileRet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
openssl_free_key($res);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据加密
|
||||
* @param string $data
|
||||
* @param string|null $passwork
|
||||
* @return false|string
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/5/16
|
||||
*/
|
||||
function privateEncrypt(string $data, string $passwork = null)
|
||||
{
|
||||
$encrypted = '';
|
||||
$pi_key = openssl_pkey_get_private(file_get_contents($this->privateKey), $passwork);//这个函数可用来判断私钥是否是可用的,可用返回资源id Resource id
|
||||
//最大允许加密长度为117,得分段加密
|
||||
$plainData = str_split($data, 100);//生成密钥位数 1024 bit key
|
||||
foreach ($plainData as $chunk) {
|
||||
$partialEncrypted = '';
|
||||
$encryptionOk = openssl_private_encrypt($chunk, $partialEncrypted, $pi_key);//私钥加密
|
||||
if ($encryptionOk === false) {
|
||||
return false;
|
||||
}
|
||||
$encrypted .= $partialEncrypted;
|
||||
}
|
||||
|
||||
$encrypted = base64_encode($encrypted);//加密后的内容通常含有特殊字符,需要编码转换下,在网络间通过url传输时要注意base64编码是否是url安全的
|
||||
return $encrypted;
|
||||
}
|
||||
|
||||
/**
|
||||
* RSA公钥解密(私钥加密的内容通过公钥可以解密出来)
|
||||
* @param string $public_key 公钥
|
||||
* @param string $data 私钥加密后的字符串
|
||||
* @return string $decrypted 返回解密后的字符串
|
||||
* @author mosishu
|
||||
*/
|
||||
function publicDecrypt(string $data)
|
||||
{
|
||||
$decrypted = '';
|
||||
$pu_key = openssl_pkey_get_public(file_get_contents($this->publicKey));//这个函数可用来判断公钥是否是可用的
|
||||
$plainData = str_split(base64_decode($data), 128);//生成密钥位数 1024 bit key
|
||||
foreach ($plainData as $chunk) {
|
||||
$str = '';
|
||||
$decryptionOk = openssl_public_decrypt($chunk, $str, $pu_key);//公钥解密
|
||||
if ($decryptionOk === false) {
|
||||
return false;
|
||||
}
|
||||
$decrypted .= $str;
|
||||
}
|
||||
return $decrypted;
|
||||
}
|
||||
|
||||
/**
|
||||
* 私钥解密
|
||||
* @param string $data
|
||||
* @return mixed
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/5/16
|
||||
*/
|
||||
public function privateDecrypt(string $data)
|
||||
{
|
||||
if (!is_file($this->privateKey)) {
|
||||
$this->exportOpenSSLFile();
|
||||
}
|
||||
|
||||
$res = openssl_private_decrypt(base64_decode($data), $decryptedData, file_get_contents($this->privateKey));
|
||||
|
||||
if (false === $res) {
|
||||
throw new ValidateException('RSA:解密失败');
|
||||
}
|
||||
|
||||
return $decryptedData;
|
||||
}
|
||||
|
||||
}
|
||||
@ -33763,7 +33763,8 @@ INSERT INTO `eb_system_config` (`id`, `menu_name`, `type`, `input_type`, `config
|
||||
(433, 'network_security', 'text', 'input', 26, '', 1, '', 0, 0, '\"\\u4eac\\u516c\\u7f51\\u5b89\\u5907xxxxxx\\u53f7\"', '网安备案', '公安部门登记的备案信息,显示在pc底部', 8, 1),
|
||||
(435, 'icp_url', 'text', 'input', 26, '', 1, '', 0, 0, '\"https:\\/\\/beian.miit.gov.cn\"', 'ICP备案链接', 'H5和PC底部显示的ICP备案号点击跳转的链接', 9, 1),
|
||||
(436, 'network_security_url', 'text', 'input', 26, '', 1, '', 0, 0, '\"https:\\/\\/www.beian.gov.cn\"', '网安备案链接', 'H5和PC底部显示的网安备案号点击跳转的链接', 7, 1),
|
||||
(437, 'agent_apply_open', 'radio', 'input', 72, '1=>开启\n0=>关闭', 1, '', 0, 0, '1', '代理商申请开关', '控制移动端我的推广页面的代理商申请按钮是否显示', 0, 1);
|
||||
(437, 'agent_apply_open', 'radio', 'input', 72, '1=>开启\n0=>关闭', 1, '', 0, 0, '1', '代理商申请开关', '控制移动端我的推广页面的代理商申请按钮是否显示', 0, 1),
|
||||
(438, 'order_shipping_open', 'radio', 'input', 7, '1=>开启\n0=>关闭', 1, '', 0, 0, '1', '小程序发货信息管理服务', '小程序有订单发货管理时,请打开此开关,否则会导致订单资金冻结', 0, 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
@click.stop="evaluateTap(item.unique,orderId)">
|
||||
{{$t(`评价`)}}</view>
|
||||
<view class='logistics'
|
||||
v-if="paid === 1 && refund_status === 0 && item.refund_num !=item.cart_num && !is_confirm && isShow && virtualType == 0"
|
||||
v-if="paid === 1 && refund_status === 0 && item.refund_num !=item.cart_num && !is_confirm && isShow && (virtualType == 0 || (virtualType > 0 && statusType == 1))"
|
||||
@click.stop="openSubcribe(item)">
|
||||
{{$t(`申请退款`)}}</view>
|
||||
<view class="rig-btn" v-if="status_type === 2 && index === cartInfo.length - 1 || !split">
|
||||
|
||||
@ -26,7 +26,9 @@
|
||||
"Payment" : {},
|
||||
"Share" : {},
|
||||
"VideoPlayer" : {},
|
||||
"OAuth" : {}
|
||||
"OAuth" : {},
|
||||
"Barcode" : {},
|
||||
"Camera" : {}
|
||||
},
|
||||
"safearea" : {
|
||||
"bottom" : {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user