fix: 全项目清理 PHP 7.4 升级遗留(open_basedir 临时目录、implode 反序、null 取下标、嵌套三元)

一、open_basedir 不能再写 /tmp(7.4 池子把白名单收紧,Monolog/EasyWeChat 会抛异常)
- addons/shopro/library/Wechat.php:easywechat 日志改到 runtime/easywechat/
- addons/epay/library/Yansongda/Supports/Logger.php:epay 日志默认路径改到 runtime/epay/
- application/admin/library/traits/Backend.php:CSV 导入临时文件改到 runtime/temp/

二、implode 参数反序(7.4 起 E_DEPRECATED,TP5 会抛异常)
- application/api/controller/Datas.php
- application/index/controller/wms/Pda.php
- 另修正 Wms.php 中 1 处(拆分面单提示)

三、null 取下标(7.4 起 "Trying to access array offset on value of type null")
- 覆盖 71 个文件 135 行:find()/value()/json_decode()/redis get 等结果未判空即取下标处,
  统一 (\['k'] ?? null) 兜底;foreach 目标用 ?? [];in_array/count 等数组参数用 ?? []
- 涉及 api/*、admin/shopro/*、addons/shopro/*、addons/epay/*、index/wms/* 等

四、嵌套三元未加括号(7.4 弃用)
- application/index/controller/wms/Wms.php getPackingprice 2 处,补括号后与旧版本解析顺序一致

验证:74 个文件、148 行改动,逐行括号/引号配平与 HEAD 一致,未改动 vendor/ 与 thinkphp/;
剩余扫描命中均为写目标、unset、或已被 if(!\){error()} 拦截的假阳性。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
liufumingren 2026-10-25 09:47:48 +08:00
parent f5bff78d88
commit 7b18287328
74 changed files with 148 additions and 140 deletions

View File

@ -447,7 +447,7 @@ class Index extends Controller
$this->error("签名不正确");
}
$json = json_decode(base64_decode($data), true);
if ($json['deadline'] < time()) {
if (($json['deadline'] ?? null)< time()) {
$this->error("请求已经超时");
}
}

View File

@ -88,7 +88,7 @@ class Api extends Controller
$orderid = $this->request->post("orderid");
try {
$result = $pay->find($orderid, 'scan');
if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') {
if (($result['return_code'] ?? null)== 'SUCCESS' && ($result['result_code'] ?? null)== 'SUCCESS') {
$this->success("", "", ['status' => $result['trade_state']]);
} else {
$this->error("查询失败");
@ -150,7 +150,7 @@ class Api extends Controller
$pay = Pay::alipay($config);
try {
$result = $pay->find($orderid, 'scan');
if ($result['code'] == '10000' && $result['trade_status'] == 'TRADE_SUCCESS') {
if (($result['code'] ?? null)== '10000' && ($result['trade_status'] ?? null)== 'TRADE_SUCCESS') {
$this->success("", "", ['status' => $result['trade_status']]);
} else {
$this->error("查询失败");

View File

@ -26,7 +26,7 @@ class AppGateway extends Gateway
$biz_array = json_decode($payload['biz_content'], true);
if ((Alipay::MODE_SERVICE === $this->mode) && (!empty(Support::getInstance()->pid))) {
$biz_array['extend_params'] = is_array($biz_array['extend_params']) ? array_merge(['sys_service_provider_id' => Support::getInstance()->pid], $biz_array['extend_params']) : ['sys_service_provider_id' => Support::getInstance()->pid];
$biz_array['extend_params'] = is_array(($biz_array['extend_params'] ?? null)) ? array_merge(['sys_service_provider_id' => Support::getInstance()->pid], ($biz_array['extend_params'] ?? [])) : ['sys_service_provider_id' => Support::getInstance()->pid];
}
$payload['biz_content'] = json_encode(array_merge($biz_array, ['product_code' => 'QUICK_MSECURITY_PAY']));
$payload['sign'] = Support::generateSign($payload);

View File

@ -29,7 +29,7 @@ class MiniGateway extends Gateway
public function pay($endpoint, array $payload): Collection
{
$biz_array = json_decode($payload['biz_content'], true);
if (empty($biz_array['buyer_id'])) {
if (empty(($biz_array['buyer_id'] ?? null))) {
throw new InvalidArgumentException('buyer_id required');
}
if ((Alipay::MODE_SERVICE === $this->mode) && (!empty(Support::getInstance()->pid))) {

View File

@ -29,7 +29,7 @@ class PosGateway extends Gateway
$payload['method'] = 'alipay.trade.pay';
$biz_array = json_decode($payload['biz_content'], true);
if ((Alipay::MODE_SERVICE === $this->mode) && (!empty(Support::getInstance()->pid))) {
$biz_array['extend_params'] = is_array($biz_array['extend_params']) ? array_merge(['sys_service_provider_id' => Support::getInstance()->pid], $biz_array['extend_params']) : ['sys_service_provider_id' => Support::getInstance()->pid];
$biz_array['extend_params'] = is_array(($biz_array['extend_params'] ?? null)) ? array_merge(['sys_service_provider_id' => Support::getInstance()->pid], ($biz_array['extend_params'] ?? [])) : ['sys_service_provider_id' => Support::getInstance()->pid];
}
$payload['biz_content'] = json_encode(array_merge(
$biz_array,

View File

@ -29,7 +29,7 @@ class ScanGateway extends Gateway
$payload['method'] = 'alipay.trade.precreate';
$biz_array = json_decode($payload['biz_content'], true);
if ((Alipay::MODE_SERVICE === $this->mode) && (!empty(Support::getInstance()->pid))) {
$biz_array['extend_params'] = is_array($biz_array['extend_params']) ? array_merge(['sys_service_provider_id' => Support::getInstance()->pid], $biz_array['extend_params']) : ['sys_service_provider_id' => Support::getInstance()->pid];
$biz_array['extend_params'] = is_array(($biz_array['extend_params'] ?? null)) ? array_merge(['sys_service_provider_id' => Support::getInstance()->pid], ($biz_array['extend_params'] ?? [])) : ['sys_service_provider_id' => Support::getInstance()->pid];
}
$payload['biz_content'] = json_encode(array_merge($biz_array, ['product_code' => '']));
$payload['sign'] = Support::generateSign($payload);

View File

@ -205,7 +205,11 @@ class Logger
*/
public function createHandler(): AbstractHandler
{
$file = $this->config['file'] ?? sys_get_temp_dir().'/logs/'.$this->config['identify'].'.log';
$file = $this->config['file'] ?? (defined('RUNTIME_PATH') ? RUNTIME_PATH . 'epay' . DIRECTORY_SEPARATOR . $this->config['identify'] . '.log' : sys_get_temp_dir().'/logs/'.$this->config['identify'].'.log');
$dir = dirname($file);
if (!is_dir($dir)) {
@mkdir($dir, 0755, true);
}
if ('single' === $this->config['type']) {
return new StreamHandler($file, $this->config['level']);

View File

@ -49,12 +49,12 @@ final class EdgeIterator implements IteratorAggregate
$point = $this->findNext(0, 0);
while (null !== $point) {
$edge = $this->findEdge($point[0], $point[1]);
$edge = $this->findEdge(($point[0] ?? null), ($point[1] ?? null));
$this->xorEdge($edge);
yield $edge;
$point = $this->findNext($point[0], $point[1]);
$point = $this->findNext(($point[0] ?? null), ($point[1] ?? null));
}
$this->bytes = $originalBytes;

View File

@ -28,7 +28,7 @@ class Express extends Base
// \think\Log::write('expresscallback:'. json_encode($requestData));
$data = json_decode(html_entity_decode($requestData['RequestData']), true);
$expressData = $data['Data'];
$expressData = ($data['Data'] ?? null);
foreach ($expressData as $key => $express) {
// 查找包裹

View File

@ -36,7 +36,7 @@ class Index extends Base
// 商城基本设置
$shoproConfig = json_decode($config['shopro'], true);
$shoproConfig['logo'] = cdnurl($shoproConfig['logo'], true);
$shoproConfig['logo'] = cdnurl(($shoproConfig['logo'] ?? null), true);
$data['shop'] = $shoproConfig;
// 支付设置
@ -44,7 +44,7 @@ class Index extends Base
$paymentConfig = [];
foreach ($payment as $key => $v) {
$val = json_decode($v->value, true);
if ($val && in_array($platform, $val['platform'])) {
if ($val && in_array($platform, ($val['platform'] ?? []))) {
$paymentConfig[] = $v->name;
}
}
@ -74,7 +74,7 @@ class Index extends Base
// 分享设置
$shareConfig = json_decode($config['share'], true);
$data['share'] = [
'title' => $shareConfig['title'],
'title' => ($shareConfig['title'] ?? null),
'image' => isset($shareConfig['image']) ? cdnurl($shareConfig['image'], true) : '',
'goods_poster_bg' => isset($shareConfig['goods_poster_bg']) ? cdnurl($shareConfig['goods_poster_bg'], true) : '',
'user_poster_bg' => isset($shareConfig['user_poster_bg']) ? cdnurl($shareConfig['user_poster_bg'], true) : '',

View File

@ -414,7 +414,7 @@ class User extends Base
$payload = json_decode(htmlspecialchars_decode($params['payload']), true);
// 解析前端主机
if ($payload['event'] !== 'login' && $payload['token'] !== '') {
if (($payload['event'] ?? null)!== 'login' && ($payload['token'] ?? null)!== '') {
$this->auth->init($payload['token']);
}

View File

@ -166,7 +166,7 @@ class Wechat extends Base
break;
}
switch ($message['type']) {
switch (($message['type'] ?? null)) {
case 'text': //回复文本
$content = new \EasyWeChat\Kernel\Messages\Text($message['content']);
break;

View File

@ -26,7 +26,7 @@ class ActivityGrouponAutoOper extends BaseJob
$activityGroupon = ActivityGroupon::where('id', $activity_groupon_id)->find();
// 活动正在进行中, 走这里的说明人数 都没满
if ($activityGroupon && $activityGroupon['status'] == 'ing') {
if ($activityGroupon && ($activityGroupon['status'] ?? null)== 'ing') {
\think\Db::transaction(function () use ($activity, $activityGroupon) {
$rules = $activity['rules'];
// 是否虚拟成团

View File

@ -107,7 +107,7 @@ class OrderAutoOper extends BaseJob
// 获取自动好评内容
$config = Config::where('name', 'order')->cache(300)->find(); // 读取配置自动缓存 5 分钟
$config = isset($config) ? json_decode($config['value'], true) : [];
$config = isset($config) ? json_decode(($config['value'] ?? null), true) : [];
$comment_content = (isset($config['order_comment_content']) && $config['order_comment_content'])
? $config['order_comment_content'] : '用户默认好评'; // 单位天

View File

@ -28,7 +28,7 @@ class OrderPayed extends BaseJob
$order = $data['order'];
$user = $data['user'];
$order = Order::with('item')->where('id', $order['id'])->find();
$order = Order::with('item')->where('id', ($order['id'] ?? null))->find();
// 数据库删订单的问题常见,这里被删的订单直接把队列移除
if ($order) {
@ -51,7 +51,7 @@ class OrderPayed extends BaseJob
}
// 处理消费返积分 TODO: 待测试
$scoreConfig = Config::where('name', 'score')->find();
$scoreConfig = json_decode($scoreConfig['value'], true);
$scoreConfig = json_decode(($scoreConfig['value'] ?? null), true);
if(!empty($scoreConfig['consume_get_score']) && !empty($scoreConfig['consume_get_score_ratio'])) {
$scoreRatio = intval($scoreConfig['consume_get_score_ratio']);
$score = intval($scoreRatio * 0.01 * $order->total_fee);

View File

@ -51,7 +51,7 @@ class Express
if ($result['ret'] == 1) {
$exResult = json_decode($result['msg'], true);
if (!$exResult['Success']) {
if (!($exResult['Success'] ?? null)) {
throw new \Exception($exResult['Reason']);
}
@ -79,7 +79,7 @@ class Express
if ($result['ret'] == 1) {
$exResult = json_decode($result['msg'], true);
if (!$exResult['Success']) {
if (!($exResult['Success'] ?? null)) {
throw new \Exception($exResult['Reason']);
}
@ -198,7 +198,7 @@ class Express
if ($result['ret'] == 1) {
$exResult = json_decode($result['msg'], true);
if (!$exResult['Success']) {
if (!($exResult['Success'] ?? null)) {
throw new \Exception($exResult['Reason']);
}

View File

@ -30,7 +30,7 @@ class PayService
$paymentConfig = json_decode(\addons\shopro\model\Config::get(['name' => $this->payment])->value, true);
// 如果是支付,并且不是 复制地址的支付宝支付
if ($this->type == 'pay' && $this->platform != 'url' && !in_array($this->platform, $paymentConfig['platform'])) {
if ($this->type == 'pay' && $this->platform != 'url' && !in_array($this->platform, ($paymentConfig['platform'] ?? []))) {
new Exception('暂不支持该方式付款');
}
@ -57,7 +57,7 @@ class PayService
case 'wxOfficialAccount':
$platformConfig = json_decode(\addons\shopro\model\Config::get(['name' => $this->platform])->value, true);
if (isset($this->config['mode']) && $this->config['mode'] === 'service') {
$this->config['sub_app_id'] = $platformConfig['app_id'];
$this->config['sub_app_id'] = ($platformConfig['app_id'] ?? null);
$this->config['app_id'] = $this->config['app_id']; // 主商户号,关联的 app_id
} else {
$this->config['app_id'] = $platformConfig['app_id'];
@ -66,7 +66,7 @@ class PayService
case 'wxMiniProgram':
$platformConfig = json_decode(\addons\shopro\model\Config::get(['name' => $this->platform])->value, true);
if (isset($this->config['mode']) && $this->config['mode'] === 'service') {
$this->config['sub_miniapp_id'] = $platformConfig['app_id'];
$this->config['sub_miniapp_id'] = ($platformConfig['app_id'] ?? null);
// $this->config['sub_app_id'] = $platformConfig['app_id'];
$this->config['miniapp_id'] = $this->config['app_id']; // 主商户号,关联的 app_id
} else {
@ -77,7 +77,7 @@ class PayService
case 'H5':
$platformConfig = json_decode(\addons\shopro\model\Config::get(['name' => $this->platform])->value, true);
if (isset($this->config['mode']) && $this->config['mode'] === 'service') {
$this->config['sub_app_id'] = $platformConfig['app_id'];
$this->config['sub_app_id'] = ($platformConfig['app_id'] ?? null);
$this->config['appid'] = $this->config['app_id']; // 主商户号,关联的 app_id
} else {
$this->config['app_id'] = $platformConfig['app_id'];
@ -86,7 +86,7 @@ class PayService
case 'App':
$platformConfig = json_decode(\addons\shopro\model\Config::get(['name' => 'App'])->value, true);
if (isset($this->config['mode']) && $this->config['mode'] === 'service') {
$this->config['sub_appid'] = $platformConfig['app_id'];
$this->config['sub_appid'] = ($platformConfig['app_id'] ?? null);
$this->config['sub_app_id'] = $platformConfig['app_id'];
$this->config['appid'] = $this->config['app_id']; // 主商户号,关联的 app_id
} else {

View File

@ -152,7 +152,7 @@ class Wechat extends Model
if (isset($result['ret']) && $result['ret']) {
// 请求成功
$result = json_decode($result['msg'], true);
$result = json_decode(($result['msg'] ?? null), true);
return $result;
}

View File

@ -130,7 +130,7 @@ class Online
$config = \addons\shopro\model\Config::where('name', 'user')->find();
if ($config) {
$userConfig = json_decode($config['value'], true);
$defaultAvatar = $userConfig['avatar'];
$defaultAvatar = ($userConfig['avatar'] ?? null);
}
if (!$chatUser) {

View File

@ -226,7 +226,7 @@ trait Groupon
// 获取活动
$activity = Activity::where('id', $goodsItem['activity_id'])->find();
$rules = $activity['rules'];
$rules = ($activity['rules'] ?? null);
// 小于 0 不限结束时间单位小时
$expiretime = 0;
@ -398,7 +398,7 @@ trait Groupon
}
// 重新获取团信息
$activityGroupon = ActivityGroupon::where('id', $activityGroupon['id'])->find();
$activityGroupon = ActivityGroupon::where('id', ($activityGroupon['id'] ?? null))->find();
if ($activityGroupon['current_num'] >= $activityGroupon['num'] && !in_array($activityGroupon['status'], ['finish', 'finish-fictitious'])) {
// 查询是否有虚拟团成员
$fictitiousCount = ActivityGrouponLog::where('groupon_id', $activityGroupon['id'])->where('is_fictitious', 1)->count();

View File

@ -394,7 +394,7 @@ trait OrderOper
\think\Hook::listen('order_create_after', $data);
// 重新获取订单
$order = self::where('id', $order['id'])->find();
$order = self::where('id', ($order['id'] ?? null))->find();
return $order;
});
@ -689,7 +689,7 @@ trait OrderOper
'level' => $level,
'content' => $content,
'images' => $images ? implode(',', $images) : $images,
'status' => !empty($config['user_reply']) ? 'show' : 'hidden'
'status' => !empty(($config['user_reply'] ?? null)) ? 'show' : 'hidden'
]);
$item->comment_status = OrderItem::COMMENT_STATUS_OK; // 评价成功

View File

@ -643,7 +643,7 @@ trait OrderOperCreate
public static function preCalcInvoiceAmount($total_fee, $goods_amount)
{
$config = \addons\shopro\model\Config::where('name', 'order')->find();
$config = isset($config) ? json_decode($config['value'], true) : [];
$config = isset($config) ? json_decode(($config['value'] ?? null), true) : [];
if (isset($config['invoice']) && $config['invoice']['enable']) {
$price_type = $config['invoice']['price_type'];

View File

@ -21,7 +21,7 @@ class Update
$activity = $params['activity'];
// 重新查询活动
$activity = Activity::where('id', $activity['id'])->find();
$activity = Activity::where('id', ($activity['id'] ?? null))->find();
if ($this->hasRedis()) {
// 如果存在 redis 将活动存入缓存

View File

@ -25,7 +25,7 @@ class CommissionHook
// 订单支付成功
$order = $params['order'];
// 重新查询订单
$order = Order::with('item')->where('id', $order['id'])->find();
$order = Order::with('item')->where('id', ($order['id'] ?? null))->find();
if (!$order) return false;
$agent = new AgentLibrary($order['user_id']);
if (!$agent->user) return false;
@ -82,7 +82,7 @@ class CommissionHook
// 扣除用户消费总计金额
$orderItem = OrderItem::where(['id' => $item['id'], "refund_status" => ['in', [OrderItem::REFUND_STATUS_FINISH, OrderItem::REFUND_STATUS_OK]]])->find();
if($orderItem && $orderItem->refund_fee > 0) {
$user = \addons\shopro\model\User::get($orderItem['user_id']);
$user = \addons\shopro\model\User::get(($orderItem['user_id'] ?? null));
$user->setDec('total_consume', $orderItem->refund_fee);
}
// 订单退款成功

View File

@ -19,7 +19,7 @@ class Comment
$order = $params['order'];
// 获取订单,判断订单是否全部评价
$order = Order::with('item')->where('id', $order['id'])->find();
$order = Order::with('item')->where('id', ($order['id'] ?? null))->find();
$user = User::where('id', $order['user_id'])->find();
// 更新评价时间

View File

@ -16,7 +16,7 @@ class Confirm
public function orderConfirmAfter(&$params)
{
$order = $params['order'];
$order = Order::where('id', $order['id'])->find();
$order = Order::where('id', ($order['id'] ?? null))->find();
// 更新收货时间
$order->ext = json_encode($order->setExt($order, ['confirm_time' => time()])); // 收货时间
@ -24,7 +24,7 @@ class Confirm
// 添加自动好评队列
$config = Config::where('name', 'order')->cache(300)->find(); // 读取配置自动缓存 5 分钟
$config = isset($config) ? json_decode($config['value'], true) : [];
$config = isset($config) ? json_decode(($config['value'] ?? null), true) : [];
$close_days = (isset($config['order_auto_comment']) && $config['order_auto_comment'] > 0)
? $config['order_auto_comment'] : 7; // 单位天

View File

@ -76,7 +76,7 @@ class Create
// (开新团不判断)参与旧团 增加预拼团人数,上面加入团的时候已经判断过一次了,所以这里 99.99% 会加入成功的
if (isset($activityGroupon) && $activityGroupon) {
// 将团信息缓存,用在后续下单流程
$key = 'grouponinfo-' . $user['id'];
$key = 'grouponinfo-' . ($user['id'] ?? null);
cache($key, json_encode($activityGroupon), 60);
// 增加拼团预成员人数, 拼团只能单独购买
@ -141,7 +141,7 @@ class Create
} else {
// 添加自动关闭队列
$config = Config::where('name', 'order')->cache(300)->find(); // 读取配置自动缓存 5 分钟
$config = isset($config) ? json_decode($config['value'], true) : [];
$config = isset($config) ? json_decode(($config['value'] ?? null), true) : [];
$close_minue = (isset($config['order_auto_close']) && $config['order_auto_close'] > 0)
? $config['order_auto_close'] : 15;

View File

@ -21,7 +21,7 @@ class Payed
$order = $params['order'];
// 重新查询订单
$order = Order::with('item')->where('id', $order['id'])->find();
$order = Order::with('item')->where('id', ($order['id'] ?? null))->find();
$items = $order ? $order['item'] : [];
// 有门店相关的订单

View File

@ -39,7 +39,7 @@ class Send
if ($item['dispatch_type'] != 'selfetch') {
// 添加自动确认收货队列
$config = Config::where('name', 'order')->cache(300)->find(); // 读取配置自动缓存 5 分钟
$config = isset($config) ? json_decode($config['value'], true) : [];
$config = isset($config) ? json_decode(($config['value'] ?? null), true) : [];
$close_days = (isset($config['order_auto_confirm']) && $config['order_auto_confirm'] > 0)
? $config['order_auto_confirm'] : 10; // 单位天

View File

@ -105,7 +105,7 @@ class Decorate extends Model
case 'grid-list':
case 'popup':
case 'nav-list':
foreach ($content['list'] as &$l) {
foreach (($content['list'] ?? []) as &$l) {
$l['image'] && $l['image'] = cdnurl($l['image'], true);
}
break;

View File

@ -190,7 +190,7 @@ class OrderAftersale extends Model
}
$orderItem = OrderItem::where('id', $aftersale['order_item_id'])->find();
if (!$orderItem || in_array($orderItem['refund_status'], [OrderItem::REFUND_STATUS_OK, OrderItem::REFUND_STATUS_FINISH])) {
if (!$orderItem || in_array(($orderItem['refund_status'] ?? null), [OrderItem::REFUND_STATUS_OK, OrderItem::REFUND_STATUS_FINISH])) {
// 不存在, 或者已经退款
new Exception('退款商品不存在或已退款');
}

View File

@ -147,7 +147,7 @@ class TradeOrder extends Model
{
// 添加自动关闭队列
$config = Config::where('name', 'order')->cache(300)->find(); // 读取配置自动缓存 5 分钟
$config = isset($config) ? json_decode($config['value'], true) : [];
$config = isset($config) ? json_decode(($config['value'] ?? null), true) : [];
$close_minue = (isset($config['order_auto_close']) && $config['order_auto_close'] > 0)
? $config['order_auto_close'] : 15;

View File

@ -47,7 +47,7 @@ class User extends Model
//如果不需要启用首字母头像,请使用
//$value = '/assets/img/avatar.png';
$config = json_decode(\addons\shopro\model\Config::get(['name' => 'user'])->value, true);
$value = $config['avatar'];
$value = ($config['avatar'] ?? null);
}
return cdnurl($value, true);

View File

@ -112,7 +112,7 @@ class UserSign extends Model
// 获取积分规则
$config = Config::where('name', 'score')->find();
$config = json_decode($config['value'], true);
$config = json_decode(($config['value'] ?? null), true);
$everyday = $config['everyday'];
$inc_value = $config['inc_value'];
$until_day = $config['until_day'];
@ -180,7 +180,7 @@ class UserSign extends Model
// 获取积分规则
$config = Config::where('name', 'score')->find();
$config = json_decode($config['value'], true);
$config = json_decode(($config['value'] ?? null), true);
$everyday = $config['everyday'];
$inc_value = $config['inc_value'];
$until_day = $config['until_day'];

View File

@ -353,7 +353,7 @@ class UserWalletApply extends Model
public static function getWithdrawConfig()
{
$config = \addons\shopro\model\Config::where('name', 'withdraw')->find();
return json_decode($config['value'], true);
return json_decode(($config['value'] ?? null), true);
}
/**

View File

@ -228,7 +228,7 @@ class Notification
$domain = null;
// 查询商城配置获取 h5 网址,并缓存 5 分钟
$config = Config::where('name', 'shopro')->cache(300)->find();
if ($config && $cv = json_decode($config['value'], true)) {
if ($config && $cv = json_decode(($config['value'] ?? null), true)) {
$domain = isset($cv['domain']) ? $cv['domain'] : null;
}

View File

@ -231,7 +231,7 @@ class Wallet extends Notification implements ShouldQueue
private function walletScoreChangeData($notifiable) {
$currentData = $this->data;
$walletLog = $currentData['walletLog'] ?? [];
$notifiable = User::where('id', $notifiable['id'])->find();
$notifiable = User::where('id', ($notifiable['id'] ?? null))->find();
$data['template'] = self::$returnField[$this->event]['name']; // 模板名称
$data['nickname'] = $notifiable['nickname'];
$data['wallet'] = $walletLog['wallet'];

View File

@ -62,7 +62,7 @@ class Category extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -102,7 +102,7 @@ class Category extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -90,7 +90,7 @@ class Coupons extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -139,7 +139,7 @@ class Coupons extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -82,7 +82,7 @@ class Express extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -124,7 +124,7 @@ class Express extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -86,7 +86,7 @@ class Feedback extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -58,7 +58,7 @@ class Link extends Base
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -99,7 +99,7 @@ class Link extends Base
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -79,7 +79,7 @@ class Autosend extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -137,7 +137,7 @@ class Autosend extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -211,7 +211,7 @@ class Autosend extends Backend
{
if($data['type'] == 'autosend' ) {
$autosend = \app\admin\model\shopro\dispatch\Autosend::where('id', $data['type_ids'])->find();
if($autosend && $autosend['type'] === 'params') {
if($autosend && ($autosend['type'] ?? null)=== 'params') {
$autosend['content'] = json_decode($autosend['content'], true);
}
return $autosend;

View File

@ -80,7 +80,7 @@ class Express extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -132,7 +132,7 @@ class Express extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -81,7 +81,7 @@ class Selfetch extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -134,7 +134,7 @@ class Selfetch extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -81,7 +81,7 @@ class Store extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -134,7 +134,7 @@ class Store extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -105,7 +105,7 @@ class Store extends Backend
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
Db::startTrans();
try {
$result = $this->model->allowField(true)->save($params);
@ -156,7 +156,7 @@ class Store extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -68,7 +68,7 @@ class Group extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -111,7 +111,7 @@ class Group extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -103,7 +103,7 @@ class User extends Backend
{
$params = $this->request->post('data');
$params = json_decode($params, true);
$user = $this->model->get($params['id']);
$user = $this->model->get(($params['id'] ?? null));
if (!$user) {
$this->error('未找到用户');
}

View File

@ -78,7 +78,7 @@ class AutoReply extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -143,7 +143,7 @@ class AutoReply extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -79,7 +79,7 @@ class Material extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {
@ -120,7 +120,7 @@ class Material extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
try {

View File

@ -81,7 +81,7 @@ class Menu extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
if ($this->request->get('act') === 'publish') {
@ -128,7 +128,7 @@ class Menu extends Backend
if ($this->request->isPost()) {
$params = $this->request->post();
if ($params) {
$params = json_decode($params['data'], true);
$params = json_decode(($params['data'] ?? null), true);
$result = false;
Db::startTrans();
if ($this->request->get('act') === 'publish') {
@ -202,7 +202,7 @@ class Menu extends Backend
$this->error(__('No Results were found'));
}
$publish = $this->publishMenu(json_decode($row->content, true));
if (!$publish['result']) {
if (!($publish['result'] ?? null)) {
return $this->error($publish['msg']);
}
return $this->success('发布成功');

View File

@ -365,7 +365,11 @@ trait Backend
}
if ($ext === 'csv') {
$file = fopen($filePath, 'r');
$filePath = tempnam(sys_get_temp_dir(), 'import_csv');
$tmpDir = RUNTIME_PATH . 'temp' . DIRECTORY_SEPARATOR;
if (!is_dir($tmpDir)) {
@mkdir($tmpDir, 0755, true);
}
$filePath = tempnam($tmpDir, 'import_csv');
$fp = fopen($filePath, 'w');
$n = 0;
while ($line = fgets($file)) {

View File

@ -85,7 +85,7 @@ class Datas extends Api
foreach ($postcodes as $k => $rr){
if($rr["POSTCODE"]==$r["postcode"]){
$has = true;
$postcodes[$k]["weight_0_300"] += $weights["w1"];
$postcodes[$k]["weight_0_300"] += ($weights["w1"] ?? null);
$postcodes[$k]["weight_300_500"]+= $weights["w2"];
$postcodes[$k]["weight_500_1000"]+= $weights["w3"];
$postcodes[$k]["weight_1000_1500"]+= $weights["w4"];
@ -206,11 +206,11 @@ class Datas extends Api
foreach ($postcodes as $k => $rr){
if($rr["create_date"]==$r["create_date"]){
$has = true;
$postcodes[$k]["ITEMS_1"] += $weights["w1"];
$postcodes[$k]["ITEMS_1"] += ($weights["w1"] ?? null);
$postcodes[$k]["ITEMS_2_3"]+= $weights["w2"];
$postcodes[$k]["ITEMS_3_5"]+= $weights["w3"];
$postcodes[$k]["ITEMS_qt_5"]+= $weights["w4"];
$postcodes[$k]["GOODSCOUNT_1"] += $weights2["w1"];
$postcodes[$k]["GOODSCOUNT_1"] += ($weights2["w1"] ?? null);
$postcodes[$k]["GOODSCOUNT_2_3"]+= $weights2["w2"];
$postcodes[$k]["GOODSCOUNT_3_5"]+= $weights2["w3"];
$postcodes[$k]["GOODSCOUNT_qt_5"]+= $weights2["w4"];
@ -395,7 +395,7 @@ class Datas extends Api
$tmp_infos = explode(',',$rr);
array_push($ITEMSS,$tmp_infos[3].'('.$tmp_infos[1].')');
}
$ITEMSS = implode($ITEMSS,"\r\n");
$ITEMSS = implode("\r\n",$ITEMSS);
array_push($lists,[$ITEMSS,$COUNT,$STORENAME]);
}
$worksheet->fromArray(
@ -1216,7 +1216,7 @@ class Datas extends Api
}
}
$data = $stockModel ->where(["STOCKID"=>intval($datas['formData']['STOCKID'])])->find();
$YXQ = isset($datas['formData']['YXQ'])?$datas['formData']['YXQ']:$data['YXQ'];
$YXQ = isset($datas['formData']['YXQ'])?$datas['formData']['YXQ']:($data['YXQ'] ?? null);
$saveData = [intval($datas['formData']['STOCKID']),intval($datas['formData']['WEIGHT']),0,0,0,$YXQ];
$data->save(["YXQ"=>$YXQ,"WEIGHT"=>$datas['formData']['WEIGHT']]);
//$result = Wsdl::webservice($saveData,'upateStock');
@ -1511,7 +1511,7 @@ class Datas extends Api
print_r($rr["ruluid"]);
/*if($rrr["iscost"]==0){
$rule = $RuleModel->where(["id"=>$rr["ruluid"]])->find();
print_r($rr["weight"]."|".$rule["id"]."|");
print_r($rr["weight"]."|".($rule["id"] ?? null)."|");
$ruleprice = $this->getOrderPrice($rr["weight"],$rule);
print_r($ruleprice2."|||");
}
@ -1653,7 +1653,7 @@ class Datas extends Api
if($this->auth->check("isstaff")){
if($storeid>0){
$storeids = $StoreModel->where(["STOREID"=>$storeid])->find();
array_push($USERIDS,$storeids["USERID"]);
array_push($USERIDS,($storeids["USERID"] ?? null));
array_push($STORES,$storeids["STOREID"]);
}else{
$STORESS = $WarestoreModel->where(["WAREHOUSEID"=>$WAREHOUSEID])->select();
@ -1696,8 +1696,8 @@ class Datas extends Api
$outAccount = 0;
$Accountdetailout=$AccountdetailModel->field("sum(BALANCE) as BALANCE")->where("ACCOUNTID","in",$ACCOUNTID)->where("CREATIONDATE","BETWEEN",["00".$startOfMonth."000","00".$endOfMonth."999"])->where("TYPE>0")->find();
$Accountdetailin=$AccountdetailModel->field("sum(BALANCE) as BALANCE")->where("ACCOUNTID","in",$ACCOUNTID)->where("CREATIONDATE","BETWEEN",["00".$startOfMonth."000","00".$endOfMonth."999"])->where(["TYPE"=>0])->find();
$inAccount = $Accountdetailin["BALANCE"]?$Accountdetailin["BALANCE"]:0;
$outAccount = $Accountdetailout["BALANCE"]?$Accountdetailout["BALANCE"]:0;
$inAccount = ($Accountdetailin["BALANCE"] ?? null)?($Accountdetailin["BALANCE"] ?? null):0;
$outAccount = ($Accountdetailout["BALANCE"] ?? null)?($Accountdetailout["BALANCE"] ?? null):0;
$this->success("获取成功",["allprice"=>$allprice,"STORES"=>$STORES,"orders"=>$orders,"inAccount"=>$inAccount,"outAccount"=>$outAccount,"Accountdetail"=>$Accountdetail]);
}
}

View File

@ -40,7 +40,7 @@ class Gonghao extends Api
}
$userModel = new \app\common\model\User;
$userinfo = $userModel->where(["wms_userid"=>$wmsuser['userID']])->find();
if($userinfo && $userinfo['id']!=$this->auth->id){
if($userinfo && ($userinfo['id'] ?? null)!=$this->auth->id){
$this->error('工号已被其他用户绑定');
}
$user = $this->auth->getUser();
@ -75,7 +75,7 @@ class Gonghao extends Api
//print_r($settime);
$WarehouseModel = new \app\common\model\Warehouse;
$WAREHOUSE = $WarehouseModel->where(["WAREHOUSEID"=>$WAREHOUSEID])->find();
$workDate = $WAREHOUSE['workDate'];
$workDate = ($WAREHOUSE['workDate'] ?? null);
$settime= strtotime(date('Y-m-d ',$workDate).$params['settime'].':00');
$Token = new \app\common\model\workers\clock\in\Token;
$Token2 = new \app\common\model\workers\clock\in\Token;
@ -101,7 +101,7 @@ class Gonghao extends Api
$clockinModel->where('endtime is null');
}
$WAREHOUSE = $WarehouseModel->where(["WAREHOUSEID"=>$WAREHOUSEID])->find();
$workDate = $WAREHOUSE['workDate'];
$workDate = ($WAREHOUSE['workDate'] ?? null);
$list = $clockinModel->where(["WAREHOUSEID"=>$WAREHOUSEID,"workDate"=>$workDate])->with(['name'])->order('endtime,createtime','desc')->select();
$this->success('获取成功',$list);
}
@ -116,7 +116,7 @@ class Gonghao extends Api
$WarehouseModel = new \app\common\model\Warehouse;
$Token = new \app\common\model\workers\clock\in\Token;
$WAREHOUSE = $WarehouseModel->where(["WAREHOUSEID"=>$WAREHOUSEID])->find();
$workDate = $WAREHOUSE['workDate'];
$workDate = ($WAREHOUSE['workDate'] ?? null);
$time = time();
$tokens = $Token->where("expiretime>".($time))->where(["token"=>$token])->where(["WAREHOUSEID"=>$WAREHOUSEID])->find();
if($tokens){

View File

@ -76,7 +76,7 @@ class Index extends Api
// 商城基本设置
$shoproConfig = json_decode($config['shopro'], true);
$shoproConfig['logo'] = cdnurl($shoproConfig['logo'], true);
$shoproConfig['logo'] = cdnurl(($shoproConfig['logo'] ?? null), true);
$data['shop'] = $shoproConfig;
// 支付设置
@ -84,7 +84,7 @@ class Index extends Api
$paymentConfig = [];
foreach ($payment as $key => $v) {
$val = json_decode($v->value, true);
if ($val && in_array($platform, $val['platform'])) {
if ($val && in_array($platform, ($val['platform'] ?? []))) {
$paymentConfig[] = $v->name;
}
}
@ -107,7 +107,7 @@ class Index extends Api
// 分享设置
$shareConfig = json_decode($config['share'], true);
$data['share'] = [
'title' => $shareConfig['title'],
'title' => ($shareConfig['title'] ?? null),
'image' => isset($shareConfig['image']) ? cdnurl($shareConfig['image'], true) : '',
'goods_poster_bg' => isset($shareConfig['goods_poster_bg']) ? cdnurl($shareConfig['goods_poster_bg'], true) : '',
'user_poster_bg' => isset($shareConfig['user_poster_bg']) ? cdnurl($shareConfig['user_poster_bg'], true) : '',

View File

@ -72,7 +72,7 @@ class Prints extends Api
// 验证仓库是否在允许列表中
$inWarehouseList = false;
foreach($code_data["stores"] as $r){
foreach(($code_data["stores"] ?? []) as $r){
if($r["store_id"] == $warehouse_id){
$inWarehouseList = true;
break;
@ -117,7 +117,7 @@ class Prints extends Api
if($req["ret"]){
$msg = $req["msg"];
$msg = json_decode($msg, true);
if($msg["status"] == "fail"){
if(($msg["status"] ?? null)== "fail"){
$this->PrintComputerModel->where(["id" => $insert_id])->delete();
Log::error("远程绑定接口返回失败");
$this->error($msg["message"]);

View File

@ -86,7 +86,7 @@ class Produce extends Api
foreach($list as $r){
$StoreModel = new \app\common\model\wms\Store;
$store = $StoreModel->where(['STOREID'=>$r['STOREID']])->find();
$r['huozhu'] = $store['TITLE'];
$r['huozhu'] = ($store['TITLE'] ?? null);
}
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {

View File

@ -210,9 +210,9 @@ class Statements extends Api
}
}
$bank = $this->AccountModel->where(["id"=>$line["bank_id"]])->lock(true)->find();
$account = $bank["account"];
$account = ($bank["account"] ?? null);
$type = $this->AccounttypeModel->where(["id"=>$line["type"]])->find();
switch ($type["isin"]) {
switch (($type["isin"] ?? null)) {
case 0:
$account +=$line["account"];
break;
@ -355,9 +355,9 @@ class Statements extends Api
}
}
$bank = $this->AccountModel->where(["id"=>$line["bank_id"]])->lock(true)->find();
$account = $bank["account"];
$account = ($bank["account"] ?? null);
$type = $this->AccounttypeModel->where(["id"=>$line["type"]])->find();
switch ($type["isin"]) {
switch (($type["isin"] ?? null)) {
case 0:
$account -=$line["account"];
break;

View File

@ -320,7 +320,7 @@ class User extends Api
$code = $params['appid'];
$payload = json_decode(htmlspecialchars_decode($params['payload']), true);
// 解析前端主机
if ($payload['event'] !== 'login' && $payload['token'] !== '') {
if (($payload['event'] ?? null)!== 'login' && ($payload['token'] ?? null)!== '') {
$this->auth->init($payload['token']);
}
$wechat = new Wechat('wxOfficialAccount',$code);
@ -642,7 +642,7 @@ class User extends Api
if($req["ret"]){
$msg = $req["msg"];
$msg = json_decode($msg,true);
if($msg["code"]==200){
if(($msg["code"] ?? null)==200){
if($msg["data"]["status"]=="scanned"){
$uuid = Random::uuid();
$this->redis->set("bindCode:".$uuid,$code, 300);
@ -679,7 +679,7 @@ class User extends Api
if($req["ret"]){
$msg = $req["msg"];
$msg = json_decode($msg,true);
if($msg["code"]==200){
if(($msg["code"] ?? null)==200){
$this->success($msg["message"]);
}else{
$this->error($msg["message"]);

View File

@ -59,7 +59,7 @@ class Warehouse extends Api
$WarehouseModel = new \app\common\model\Warehouse;
$WAREHOUSEconfig = $WarehouseModel->where(['WAREHOUSEID'=>$WAREHOUSEID])->find();
$list = $StorageModel->with(['employees','goods'])
->where(['storage.WAREHOUSEID'=>$WAREHOUSEID,'storage.APPLYSTORAGENUM'=>$sn,'storage.SPACEID'=>$WAREHOUSEconfig['SPACEID']])
->where(['storage.WAREHOUSEID'=>$WAREHOUSEID,'storage.APPLYSTORAGENUM'=>$sn,'storage.SPACEID'=>($WAREHOUSEconfig['SPACEID'] ?? null)])
->select();
$this->success("入库单详情",$list);
}
@ -70,7 +70,7 @@ class Warehouse extends Api
$StorageModel = new \app\common\model\wms\Storage;
$WarehouseModel = new \app\common\model\Warehouse;
$WAREHOUSEconfig = $WarehouseModel->where(['WAREHOUSEID'=>$WAREHOUSEID])->find();
$list = $StorageModel->where(['WAREHOUSEID'=>$WAREHOUSEID,'APPLYSTORAGENUM'=>$sn,'SPACEID'=>$WAREHOUSEconfig['SPACEID']])
$list = $StorageModel->where(['WAREHOUSEID'=>$WAREHOUSEID,'APPLYSTORAGENUM'=>$sn,'SPACEID'=>($WAREHOUSEconfig['SPACEID'] ?? null)])
->select();
foreach($list as $r){
$WarehouseModel = new \app\common\model\Storage;

View File

@ -128,7 +128,7 @@ class Wms extends Api
foreach($list as $r){
$StoreModel = new \app\common\model\wms\Store;
$store = $StoreModel->where(['STOREID'=>$r['STOREID']])->find();
$r['huozhu'] = $store['TITLE'];
$r['huozhu'] = ($store['TITLE'] ?? null);
}
if(!$list && $params['query']['his']){
$orderModel = new \app\common\model\wms\Order1;
@ -148,7 +148,7 @@ class Wms extends Api
foreach($list as $r){
$StoreModel = new \app\common\model\wms\Store;
$store = $StoreModel->where(['STOREID'=>$r['STOREID']])->find();
$r['huozhu'] = $store['TITLE'];
$r['huozhu'] = ($store['TITLE'] ?? null);
$r['OPERATERECORDS'] = $r['NOTES'];
}
}

View File

@ -29,7 +29,7 @@ class Work extends Api
$this->WAREHOUSEID = $this->auth->warehouseid;
$this->StockModel = new \app\common\model\wms\Stock;
$ware = $WarehouseModel->where(["WAREHOUSEID"=>$this->WAREHOUSEID])->find();
$this->room2id = $ware["room2"];
$this->room2id = ($ware["room2"] ?? null);
$this->operatorID = $ware["operatorID"];
$this->redis = new \Redis();
$this->redis->connect('127.0.0.1', 6379);
@ -121,7 +121,7 @@ class Work extends Api
$OrderModel = new \app\common\model\wms\Order;
$order = $OrderModel->where(["ID"=>$orderID])->find();
if($order && $order["PLSENDFLAG"]==0){
if($order && ($order["PLSENDFLAG"] ?? null)==0){
$modelUser = new \app\common\model\wms\User;
$user = $modelUser->where(["userID"=>$this->operatorID])->find();
$username = $user?$user->username:"";

View File

@ -57,7 +57,7 @@ class Express extends Frontend
$yunshuList = ["ACCEPT","GOT","ARRIVAL","DEPARTURE","SENT","OUTBOUND","OVERSEA_IN","OVERSEA_OUT","TRANSFER","CLEARANCE_START","CLEARANCE_FINISH","CLEARANCE_FAIL","OVERSEA_ARRIVAL","OVERSEA_DEPARTURE"];
$yichang = ["ISSUE","RETURN","SIGNFAIL","REJECTION","OTHER"];
$content = json_decode(html_entity_decode($params['data']),true);
$postnum = $content['mailno'];
$postnum = ($content['mailno'] ?? null);
$order = $ExpressModel->where(["POSTNUM"=>$postnum])->where('status>-1')->find();
if($order){
$trace = $order->trace?json_decode($order->trace,true):[];

View File

@ -46,7 +46,7 @@ class Index extends Frontend
foreach ($list as $store){
// 1. 检查 business_license 是否已存在(未软删除)
$oldStore = $this->nStoreModel->where(["business_license"=>$store["WARESTOREID"], "deleted_at"=>null])->lock(true)->find();
if($oldStore && $oldStore['company_name'] != $store['TITLE']){
if($oldStore && ($oldStore['company_name'] ?? null)!= $store['TITLE']){
// 归档旧记录
$this->nStoreModel->where(["id"=>$oldStore['id']])->update(["deleted_at"=>date('Y-m-d H:i:s')]);
// 关联store_warehouse全部use_status=0

View File

@ -463,7 +463,7 @@ class Index extends Frontend
$result = json_decode($result, true);
\think\Log::error('拉取图片返回的结果: ' . json_encode($result));
if ($result && $result["code"] == 0 && !empty($result["data"]["cloudUrl"])) {
if ($result && ($result["code"] ?? null)== 0 && !empty(($result["data"]["cloudUrl"] ?? null))) {
return $result["data"]["cloudUrl"];
}
@ -483,7 +483,7 @@ class Index extends Frontend
$result = json_decode($result, true);
\think\Log::error('拉取图片返回的结果: ' . json_encode($result)."\n\n\n\n");
if ($result && $result["code"] == 0 && !empty($result["data"]["cloudUrl"])) {
if ($result && ($result["code"] ?? null)== 0 && !empty(($result["data"]["cloudUrl"] ?? null))) {
return $result["data"]["cloudUrl"];
}
@ -942,7 +942,7 @@ class Index extends Frontend
$result = $this->query->query("getRoomList", [$this->guid, $index]);
$result = json_decode($result, true);
if ($result && $result["code"] == 0) {
if ($result && ($result["code"] ?? null)== 0) {
$data = $result["data"];
$roomList = $data["roomList"];
$insertDatas = [];
@ -992,7 +992,7 @@ class Index extends Frontend
$result = json_decode($result, true);
$insertDatas = [];
if ($result && $result['code'] == 0) {
if ($result && ($result['code'] ?? null)== 0) {
\think\Log::error('返回结果正常: ');
$roomList = $result["data"]["roomList"];
@ -1057,7 +1057,7 @@ class Index extends Frontend
$result = json_decode($result, true);
$insertDatas = [];
if ($result && $result['code'] == 0) {
if ($result && ($result['code'] ?? null)== 0) {
\think\Log::error('返回结果正常: ');
$contactList = $result["data"]["contactList"];
\think\Log::error('返回结果正常: '.json_encode($contactList));
@ -1161,7 +1161,7 @@ class Index extends Frontend
//先通过URL上传文件获取fileId
$result = $this->query->query("cdnBigUploadByUrl", [$this->guid, "照片.png",$imgUrl,1]);
$result = json_decode($result, true);
if($result && $result["code"] == 0){
if($result && ($result["code"] ?? null)== 0){
$fileAesKey = $result["data"]["fileAesKey"];
$fileId = $result["data"]["fileId"];
$fileKey = $result["data"]["fileKey"];
@ -1181,7 +1181,7 @@ class Index extends Frontend
$filename = basename($fileUrl);
$result = $this->query->query("cdnBigUploadByUrl", [$this->guid, $filename,$fileUrl,5]);
$result = json_decode($result, true);
if($result && $result["code"] == 0){
if($result && ($result["code"] ?? null)== 0){
$fileAesKey = $result["data"]["fileAesKey"];
$fileId = $result["data"]["fileId"];
$fileKey = $result["data"]["fileKey"];

View File

@ -1367,7 +1367,7 @@ _________________________________________________________
$Exceptionwmsorder_row->save();
}
if($room && $Exceptionwmsorder_row && $this->excludeWords($msg["MSG"])){
$msg = $this->toMsg($room["room_id"],$msg["STORENAME"]."运单号:".$msg["POSTNUM"]."运方反馈信息:".$msg["MSG"]);
$msg = $this->toMsg(($room["room_id"] ?? null),$msg["STORENAME"]."运单号:".$msg["POSTNUM"]."运方反馈信息:".$msg["MSG"]);
array_push($msg_arr,$msg);
$this->redis->select(2);
$this->redis->lpush("Message",json_encode($msg));
@ -2913,7 +2913,7 @@ _________________________________________________________
foreach($postnums as $postnum){
try{
$order = $this->getOrderInfoByPostnum($postnum,$from);
if($order && $order["ID"]){
if($order && ($order["ID"] ?? null)){
$text = "{$postnum}\n";
$STOREID = $order["STOREID"];
$WAREHOUSEID = $order["WAREHOUSEID"];

View File

@ -401,7 +401,7 @@ class Dianguanjia extends Frontend
$has = true;
$data = json_decode($data,true);
array_push($list,$data);
array_push($skuids,$data["SkuId"]);
array_push($skuids,($data["SkuId"] ?? null));
}else{
$has = false;
}
@ -625,7 +625,7 @@ class Dianguanjia extends Frontend
'TableName' => isset($this->TableName[$k])?$this->TableName[$k]:'LogicOrder',
'Name' => $k,
'Value' => $r,
'Contract' => isset($this->Contract[$k])?$this->Contract[$k]:$op[$k],
'Contract' => isset($this->Contract[$k])?$this->Contract[$k]:($op[$k] ?? null),
'CustomQuery'=>isset($this->CustomQuery[$k])?$this->CustomQuery[$k]:''
];
if($k=="PrintRemark"){
@ -928,7 +928,7 @@ class Dianguanjia extends Frontend
}
public function edit_stock($ids = null){
$row = $this->StockModel->where(["SkuId"=>$ids])->with(['myagent'])->find();
$row["AgentName"] = $this->getStoreName($row["myagent"]["STOREID"]);
$row["AgentName"] = $this->getStoreName(($row["myagent"]["STOREID"] ?? null));
if (!$row) {
$this->error(__('No Results were found'));
}
@ -2734,7 +2734,7 @@ class Dianguanjia extends Frontend
$this->redis->select(2);
$this->redis->lpush("Message",json_encode($msg));
}
$req = json_decode($req["msg"],true);
$req = json_decode(($req["msg"] ?? null),true);
/*if(isset($req["Success"])&&$req["Success"]==false){
$msg = $this->toMsg($this->room_id,"店管家接口错误:".$this->unicode_to_chinese(json_encode($req))."\n--------------".$url."--------------\n".json_encode($data)."\n--------------".$url."--------------\n".json_encode($headers));
@ -3373,7 +3373,7 @@ class Dianguanjia extends Frontend
print_r($data);
$PrintDataJson = $data["Data"][0]["PrintHistoryData"]["PrintDataJson"];
$PrintData = json_decode($PrintDataJson,true);
$encryptedData = $PrintData["PrintDataList"]["task"]["documents"][0]["contents"][0]["encryptedData"];
$encryptedData = ($PrintData["PrintDataList"]["task"]["documents"][0]["contents"][0]["encryptedData"] ?? null);
$signature = $PrintData["PrintDataList"]["task"]["documents"][0]["contents"][0]["signature"];
$printData = [$encryptedData,$signature];
$order->ENCRYPTEDDATA = $encryptedData;

View File

@ -31,7 +31,7 @@ class ExtBot extends Frontend
"method"=>"list"
];
$res = $this->query($query_data);
if(count($res['data'])==0){
if(count(($res['data'] ?? []))==0){
$msg = "无登录的微信";
}
$pids = [];

View File

@ -242,7 +242,7 @@ class Order extends Frontend
}
}
return json(["grabnum"=>!empty($last['grabnum'])?$last['grabnum']:null,"count"=>$count,"hour_sum"=>$hour_sum]);
return json(["grabnum"=>!empty(($last['grabnum'] ?? null))?($last['grabnum'] ?? null):null,"count"=>$count,"hour_sum"=>$hour_sum]);
}
public function closeall(){
$first = $Gongzuomodel->where(["endtime"=>0])->select();

View File

@ -177,7 +177,7 @@ class Pda extends Frontend
$task_count = isset($params['count'])?$params['count']:1;
$insertData = [];
$time = time();
$stores = implode($params["stores"],",");
$stores = implode(",",$params["stores"] ?? []);
$n = "";
for($i=0;$i<$task_count;$i++){
if($task_count>1){

View File

@ -6389,10 +6389,10 @@ class Wms extends Frontend
$price = 0;
switch($rule['type']){
case 1:
$price=$rule["continuedcount"]>0?$order["GOODSCOUNT"]<$rule["fristcount"]?$rule["fristprice"]:round(ceil(($order["GOODSCOUNT"]-$rule["fristcount"])/$rule["continuedcount"])*$rule["continuedprice"]+$rule["fristprice"],2):0;
$price=$rule["continuedcount"]>0?($order["GOODSCOUNT"]<$rule["fristcount"]?$rule["fristprice"]:round(ceil(($order["GOODSCOUNT"]-$rule["fristcount"])/$rule["continuedcount"])*$rule["continuedprice"]+$rule["fristprice"],2)):0;
break;
case 2:
$price=$rule["continuedcount"]>0?$order["STOCKSCOUNT"]<$rule["fristcount"]?$rule["fristprice"]:round((($order["STOCKSCOUNT"]-$rule["fristcount"])/$rule["continuedcount"])*$rule["continuedprice"]+$rule["fristprice"],2):0;
$price=$rule["continuedcount"]>0?($order["STOCKSCOUNT"]<$rule["fristcount"]?$rule["fristprice"]:round((($order["STOCKSCOUNT"]-$rule["fristcount"])/$rule["continuedcount"])*$rule["continuedprice"]+$rule["fristprice"],2)):0;
break;
}
return round($price,2);

View File

@ -427,7 +427,7 @@ class Orders
$data = Wsdl::webservice([$order["warehouseid"],106300,$wmsorder->ID],'createPostNum');
$wmsorder = $orderModel->where(["SOURCEID"=>$order['ordercode']])->find();
if(empty($wmsorder["POSTNUM"])){
if(empty(($wmsorder["POSTNUM"] ?? null))){
if($type==0){
Wsdl::webservice([106300,($wmsorder["ID"] ?? null)],"cancelOrderByIds");
}

View File

@ -116,7 +116,7 @@ abstract class Base
if (!$room) {
$room = (new \app\common\model\Rooms())->where(['room_id' => $groupId])->find();
}
if ($room && intval($room['WAREHOUSEID']) > 0) {
if ($room && intval(($room['WAREHOUSEID'] ?? null)) > 0) {
return ['id' => intval($room['WAREHOUSEID']), 'from' => "group:{$groupId}"];
}
} catch (\Exception $e) {