Compare commits

...

10 Commits

Author SHA1 Message Date
liufumingren
8d8ea6cfc8 fix:修正领料未拣货接口条件判断 2026-09-29 16:38:40 +08:00
liufumingren
2ac785dea9 修正Redis认证密码: 本机连接 auth('qwe2019') 改为 'qwe2019@' 2026-09-26 02:13:02 +08:00
liufumingren
2afd401ddd Redis连接迁移: 47.100.78.112 DB2 用法改连本机 127.0.0.1(qwe2019@/DB15) 2026-09-26 02:12:11 +08:00
liufumingren
6f4b2c46d3 1 2026-09-21 22:16:37 +08:00
liufumingren
a1b5c356ea 1 2026-09-21 18:39:34 +08:00
liufumingren
f0dfb0b156 1 2026-09-21 17:41:51 +08:00
liufumingren
731cd17802 1 2026-09-21 17:40:39 +08:00
liufumingren
0c8b76b479 1 2026-09-21 17:38:36 +08:00
liufumingren
fac4bc321f 1 2026-09-21 17:34:24 +08:00
liufumingren
83dea0260c 1 2026-09-21 17:27:46 +08:00
7 changed files with 107 additions and 71 deletions

View File

@ -25,9 +25,9 @@ class Express extends Api
$POSTCODE = $params['postcode']; $POSTCODE = $params['postcode'];
$TIMECODE = $params['timecode']; $TIMECODE = $params['timecode'];
$redis = new \Redis(); $redis = new \Redis();
$redis->connect('47.100.78.112', 6379); $redis->connect('127.0.0.1', 6379);
$redis->auth('qwe2019'); $redis->auth('qwe2019@');
$redis->select(2); $redis->select(15);
$data = []; $data = [];
$infos = $redis->get("ExpressSummary_".$POSTCODE."_".$TIMECODE."_".$WAREHOUSEID); $infos = $redis->get("ExpressSummary_".$POSTCODE."_".$TIMECODE."_".$WAREHOUSEID);
if($infos){ if($infos){

View File

@ -29,9 +29,9 @@ class Wms extends Api
$this->redis->auth('qwe2019@'); $this->redis->auth('qwe2019@');
$this->redis->select(2); $this->redis->select(2);
$this->express_redis = new \Redis(); $this->express_redis = new \Redis();
$this->express_redis->connect('47.100.78.112', 6379); $this->express_redis->connect('127.0.0.1', 6379);
$this->express_redis->auth('qwe2019'); $this->express_redis->auth('qwe2019@');
$this->express_redis->select(2); $this->express_redis->select(15);
} }
protected $noNeedLogin = ['resubscribe']; protected $noNeedLogin = ['resubscribe'];
protected $noNeedRight = ['create_subscribe','resubscribe']; protected $noNeedRight = ['create_subscribe','resubscribe'];
@ -737,7 +737,7 @@ class Wms extends Api
$POSTCODE = $this->request->get('POSTCODE'); $POSTCODE = $this->request->get('POSTCODE');
$redis = new \Redis(); $redis = new \Redis();
$redis->connect('127.0.0.1', 6379); $redis->connect('127.0.0.1', 6379);
$redis->auth('qwe2019'); $redis->auth('qwe2019@');
$redis->select(2); $redis->select(2);
$redis->lpush('subscribe_tasks',json_encode(['taskID'=>$taskID,'POSTCODE'=>$POSTCODE])); $redis->lpush('subscribe_tasks',json_encode(['taskID'=>$taskID,'POSTCODE'=>$POSTCODE]));
*/ */

View File

@ -70,7 +70,7 @@ class Express extends Model
$random = Random::alnum(10); $random = Random::alnum(10);
$redis = new \Redis(); $redis = new \Redis();
$redis->connect('127.0.0.1', 6379); $redis->connect('127.0.0.1', 6379);
$redis->auth('qwe2019'); $redis->auth('qwe2019@');
$redis->select(2); $redis->select(2);
$taskID = $random.'_'.$POSTCODE.'_'.time(); $taskID = $random.'_'.$POSTCODE.'_'.time();
$redis->lpush('subscribe_tasks',json_encode(['taskID'=>$taskID,'POSTCODE'=>$POSTCODE])); $redis->lpush('subscribe_tasks',json_encode(['taskID'=>$taskID,'POSTCODE'=>$POSTCODE]));

View File

@ -20,7 +20,7 @@ class Express extends Frontend
$redis = new \Redis(); $redis = new \Redis();
$redis->connect('127.0.0.1', 6379); $redis->connect('127.0.0.1', 6379);
$redis->auth('qwe2019'); $redis->auth('qwe2019@');
$redis->select(2); $redis->select(2);
$dd = $redis->lpush("order",$params['content']); $dd = $redis->lpush("order",$params['content']);
$redis->close(); $redis->close();

View File

@ -401,11 +401,18 @@ class Index extends Frontend
} }
} }
private function getAuthUrl($type, $view) private function getAuthUrl($type, $view, $state = '')
{ {
$component_token = $this->component_token(); $component_token = $this->component_token();
$preauthcode = $this->create_preauthcode(); $preauthcode = $this->create_preauthcode();
$redirect_uri = urlencode("https://ye4s.wms.gztbyc.com/index/index/authNotic");
// 回调地址需携带 auth 传入的 state:微信只额外回传 auth_code/expires_in,
// 不带 state 时 authNotic 无法定位授权上下文
$redirectUri = "https://ye4s.wms.gztbyc.com/index/index/authNotic";
if (!empty($state)) {
$redirectUri .= '?state=' . urlencode($state);
}
$redirect_uri = urlencode($redirectUri);
switch ($view) { switch ($view) {
case 'pc': case 'pc':
@ -422,6 +429,11 @@ class Index extends Frontend
} }
public function authNotic($state=null) { public function authNotic($state=null) {
try { try {
\think\Log::info('授权回调 authNotic: ' . json_encode([
'state' => $state,
'auth_code' => $this->request->get('auth_code', '')
]));
// 1. 基础验证 // 1. 基础验证
if (empty($state) || empty($this->request->get('auth_code'))) { if (empty($state) || empty($this->request->get('auth_code'))) {
return view('error', ['msg' => '参数不完整']); return view('error', ['msg' => '参数不完整']);
@ -524,25 +536,35 @@ class Index extends Frontend
return $this->view->fetch('auth_waiting'); return $this->view->fetch('auth_waiting');
} catch (\Exception $e) { } catch (\Exception $e) {
\think\Log::error('授权回调处理异常:' . $e->getMessage()); \think\Log::error('授权回调处理异常:' . $e->getMessage() . ' @ ' . $e->getFile() . ':' . $e->getLine() . "\n" . $e->getTraceAsString());
return view('error', ['msg' => '系统处理异常,请稍后重试']); // 调试期直接输出异常信息
return view('error', ['msg' => $e->getMessage() . ' @ ' . basename($e->getFile()) . ':' . $e->getLine()]);
} }
} }
public function auth($state = null) public function auth($state)
{ {
// 兼容未传 state 的情况(如直接访问 /index/index/auth),避免"方法参数错误:state"
if (empty($state)) {
$state = $this->request->get('state', '');
}
\think\Log::info('进入授权页 auth,state: ' . $state);
// 获取参数 // 获取参数
$type = $this->request->get('type', 3); // 默认授权所有权限 $type = $this->request->get('type', 3); // 默认授权所有权限
$view = $this->request->get('view', 'pc'); // 默认PC端 $view = $this->request->get('view', 'pc'); // 默认PC端
$appid = $this->request->get('appid', ''); // 可选:指定要授权的公众号appid $appid = $this->request->get('appid', ''); // 可选:指定要授权的公众号appid
$storeId = (int)$this->request->get('store_id', 0); // 门店ID,由跳转方通过URL带入
$userId = (int)$this->request->get('user_id', 0); // 用户ID,由跳转方通过URL带入
// 生成授权链接 // 写入授权上下文,供 authNotic 回跳时读取(跨系统共享)
$authUrl = $this->getAuthUrl($type, $view); $stateKey = 'auth_state:' . $state;
$stateData = [
'store_id' => $storeId,
'user_id' => $userId,
'create_time' => time()
];
$this->redis->setex($stateKey, 600, json_encode($stateData, JSON_UNESCAPED_UNICODE));
\think\Log::info('授权页写入 auth_state: ' . $stateKey . ' => ' . json_encode($stateData, JSON_UNESCAPED_UNICODE));
if (empty($storeId) && empty($userId)) {
\think\Log::error('授权页缺少 store_id/user_id 参数,authNotic 绑定将无法定位门店: state=' . $state);
}
// 生成授权链接(把 state 带入回调地址,微信回跳 authNotic 时才能还原上下文)
$authUrl = $this->getAuthUrl($type, $view, $state);
if (empty($authUrl)) { if (empty($authUrl)) {
$this->error('获取授权链接失败,请检查配置'); $this->error('获取授权链接失败,请检查配置');
@ -664,47 +686,61 @@ class Index extends Frontend
} }
/** /**
* 转发原始请求到测试环境 * 转发原始请求到多个环境(默认:qimen + 测试环境)
* @param string $path 目标路径 * @param string $path 目标路径
* @param string $rawBody 原始报文(POST body) * @param string $rawBody 原始报文(POST body)
* @param string $host 目标域名 * @param array|string $hosts 目标域名(可传单个字符串)
* @return bool * @return array 每个目标地址的转发结果
*/ */
private function forwardToTest($path, $rawBody = '', $host = 'http://test_wms.o.gztbyc.com') private function forwardToTest($path, $rawBody = '', $hosts = [
'http://qimen.wms.gztbyc.com',
'http://test_wms.o.gztbyc.com',
])
{ {
try { if (is_string($hosts)) {
// 拼装目标地址:域名 + 路径 + 原始GET参数 $hosts = [$hosts];
}
// 原始GET参数(所有环境共用)
$query = $this->request->get();
$results = [];
foreach ($hosts as $host) {
$url = rtrim($host, '/') . '/' . ltrim($path, '/'); $url = rtrim($host, '/') . '/' . ltrim($path, '/');
$query = $this->request->get();
if (!empty($query)) { if (!empty($query)) {
$url .= (stripos($url, '?') !== false ? '&' : '?') . http_build_query($query); $url .= (stripos($url, '?') !== false ? '&' : '?') . http_build_query($query);
} }
$ch = curl_init(); try {
curl_setopt($ch, CURLOPT_URL, $url); $ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $rawBody); curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $rawBody);
curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Expect:', 'Content-Type: text/xml']); curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Expect:', 'Content-Type: text/xml']);
$response = curl_exec($ch);
$error = curl_error($ch); $response = curl_exec($ch);
curl_close($ch); $error = curl_error($ch);
curl_close($ch);
if ($error) {
\think\Log::error('转发到测试环境失败: ' . $url . ' 错误: ' . $error); if ($error) {
return false; \think\Log::error('转发失败: ' . $url . ' 错误: ' . $error);
$results[$url] = false;
continue;
}
\think\Log::info('转发成功: ' . $url . ' 返回: ' . $response);
$results[$url] = true;
} catch (\Exception $e) {
\think\Log::error('转发异常: ' . $url . ' 错误: ' . $e->getMessage());
$results[$url] = false;
} }
\think\Log::info('转发到测试环境成功: ' . $url . ' 返回: ' . $response);
return true;
} catch (\Exception $e) {
\think\Log::error('转发到测试环境异常: ' . $e->getMessage());
return false;
} }
return $results;
} }

View File

@ -2191,9 +2191,9 @@ _________________________________________________________
private function lanshou($from,$postnums,$msgid,$info=""){ private function lanshou($from,$postnums,$msgid,$info=""){
if(count($postnums)>0){ if(count($postnums)>0){
$redis = new \Redis(); $redis = new \Redis();
$redis->connect('47.100.78.112', 6379); $redis->connect('127.0.0.1', 6379);
$redis->auth('qwe2019'); $redis->auth('qwe2019@');
$redis->select(2); $redis->select(15);
$msgs = []; $msgs = [];
$text = ""; $text = "";
$posttype = []; $posttype = [];
@ -2405,15 +2405,15 @@ _________________________________________________________
} }
private function reRecord($WAREHOUSEID,$workId,$msgId){ private function reRecord($WAREHOUSEID,$workId,$msgId){
$redis = new \Redis(); $redis = new \Redis();
$redis->connect('47.100.78.112', 6379); $redis->connect('127.0.0.1', 6379);
$redis->auth('qwe2019'); $redis->auth('qwe2019@');
$redis->select(3); $redis->select(3);
$redis->lpush("ware:{$WAREHOUSEID}:reRecord",json_encode([$workId,$msgId])); $redis->lpush("ware:{$WAREHOUSEID}:reRecord",json_encode([$workId,$msgId]));
} }
private function reRecord2($WAREHOUSEID,$workId,$msgId){ private function reRecord2($WAREHOUSEID,$workId,$msgId){
$redis = new \Redis(); $redis = new \Redis();
$redis->connect('47.100.78.112', 6379); $redis->connect('127.0.0.1', 6379);
$redis->auth('qwe2019'); $redis->auth('qwe2019@');
$redis->select(3); $redis->select(3);
$redis->lpush("ware:{$WAREHOUSEID}:reRecord2",json_encode([$workId,$msgId])); $redis->lpush("ware:{$WAREHOUSEID}:reRecord2",json_encode([$workId,$msgId]));
} }

View File

@ -42,9 +42,9 @@ class Wms extends Frontend
$this->redis->auth('qwe2019@'); $this->redis->auth('qwe2019@');
$this->redis->select(2); $this->redis->select(2);
$this->express_redis = new \Redis(); $this->express_redis = new \Redis();
$this->express_redis->connect('47.100.78.112', 6379); $this->express_redis->connect('127.0.0.1', 6379);
$this->express_redis->auth('qwe2019'); $this->express_redis->auth('qwe2019@');
$this->express_redis->select(2); $this->express_redis->select(15);
$this->postcodeList = []; $this->postcodeList = [];
$this->RulesModel = new \app\common\model\wms\PickingRules; $this->RulesModel = new \app\common\model\wms\PickingRules;
$this->wechatServer = "42.194.235.215"; $this->wechatServer = "42.194.235.215";
@ -1425,7 +1425,7 @@ class Wms extends Frontend
$islingliao = false; $islingliao = false;
foreach($tmp as $dd){ foreach($tmp as $dd){
$tmp2 = explode(";",$dd); $tmp2 = explode(";",$dd);
if(strpos($tmp2[0],"领料")!==false || strpos($tmp2[0],"领取快递面单")!==false){ if(strpos($tmp2[0],"领取快递面单")!==false){
$islingliao = true; $islingliao = true;
} }
} }
@ -1458,7 +1458,7 @@ class Wms extends Frontend
$islingliao = false; $islingliao = false;
foreach($tmp as $dd){ foreach($tmp as $dd){
$tmp2 = explode(";",$dd); $tmp2 = explode(";",$dd);
if(strpos($tmp2[0],"领料")!==false){ if(strpos($tmp2[0],"领取快递面单")!==false){
$islingliao = true; $islingliao = true;
$r['username']=$tmp2[2]; $r['username']=$tmp2[2];
$dateTime = date_create_from_format('Y年m月d日 H:i:s', $tmp2[1]); $dateTime = date_create_from_format('Y年m月d日 H:i:s', $tmp2[1]);
@ -1751,8 +1751,8 @@ class Wms extends Frontend
$packedInfo->end_time = time(); $packedInfo->end_time = time();
$packedInfo->save(); $packedInfo->save();
$redis = new \Redis(); $redis = new \Redis();
$redis->connect('47.100.78.112', 6379); $redis->connect('127.0.0.1', 6379);
$redis->auth('qwe2019'); $redis->auth('qwe2019@');
$redis->select(3); $redis->select(3);
$redis->lpush("ware:{$WAREHOUSEID}:reRecord2",json_encode([$packedInfo->id,0])); $redis->lpush("ware:{$WAREHOUSEID}:reRecord2",json_encode([$packedInfo->id,0]));
} }
@ -11313,10 +11313,10 @@ class Wms extends Frontend
public function test2(){ public function test2(){
$redis = new \Redis(); $redis = new \Redis();
try { try {
$redis->connect('47.100.78.112', 6379); $redis->connect('127.0.0.1', 6379);
// 如果有密码认证 // 如果有密码认证
$redis->auth('qwe2019'); $redis->auth('qwe2019@');
$redis->select(2); $redis->select(15);
// 指定要查找的键和目标字符串 // 指定要查找的键和目标字符串
$key = 'GalaxyReceive_5400_back'; $key = 'GalaxyReceive_5400_back';
$targetString = '773385681859002'; $targetString = '773385681859002';