Compare commits
No commits in common. "8d8ea6cfc84657017527c8988337c949229daca1" and "f57c656369846a2744b2225ba9e3271adc074d63" have entirely different histories.
8d8ea6cfc8
...
f57c656369
@ -25,9 +25,9 @@ class Express extends Api
|
||||
$POSTCODE = $params['postcode'];
|
||||
$TIMECODE = $params['timecode'];
|
||||
$redis = new \Redis();
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
$redis->auth('qwe2019@');
|
||||
$redis->select(15);
|
||||
$redis->connect('47.100.78.112', 6379);
|
||||
$redis->auth('qwe2019');
|
||||
$redis->select(2);
|
||||
$data = [];
|
||||
$infos = $redis->get("ExpressSummary_".$POSTCODE."_".$TIMECODE."_".$WAREHOUSEID);
|
||||
if($infos){
|
||||
|
||||
@ -29,9 +29,9 @@ class Wms extends Api
|
||||
$this->redis->auth('qwe2019@');
|
||||
$this->redis->select(2);
|
||||
$this->express_redis = new \Redis();
|
||||
$this->express_redis->connect('127.0.0.1', 6379);
|
||||
$this->express_redis->auth('qwe2019@');
|
||||
$this->express_redis->select(15);
|
||||
$this->express_redis->connect('47.100.78.112', 6379);
|
||||
$this->express_redis->auth('qwe2019');
|
||||
$this->express_redis->select(2);
|
||||
}
|
||||
protected $noNeedLogin = ['resubscribe'];
|
||||
protected $noNeedRight = ['create_subscribe','resubscribe'];
|
||||
@ -737,7 +737,7 @@ class Wms extends Api
|
||||
$POSTCODE = $this->request->get('POSTCODE');
|
||||
$redis = new \Redis();
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
$redis->auth('qwe2019@');
|
||||
$redis->auth('qwe2019');
|
||||
$redis->select(2);
|
||||
$redis->lpush('subscribe_tasks',json_encode(['taskID'=>$taskID,'POSTCODE'=>$POSTCODE]));
|
||||
*/
|
||||
|
||||
@ -70,7 +70,7 @@ class Express extends Model
|
||||
$random = Random::alnum(10);
|
||||
$redis = new \Redis();
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
$redis->auth('qwe2019@');
|
||||
$redis->auth('qwe2019');
|
||||
$redis->select(2);
|
||||
$taskID = $random.'_'.$POSTCODE.'_'.time();
|
||||
$redis->lpush('subscribe_tasks',json_encode(['taskID'=>$taskID,'POSTCODE'=>$POSTCODE]));
|
||||
|
||||
@ -20,7 +20,7 @@ class Express extends Frontend
|
||||
|
||||
$redis = new \Redis();
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
$redis->auth('qwe2019@');
|
||||
$redis->auth('qwe2019');
|
||||
$redis->select(2);
|
||||
$dd = $redis->lpush("order",$params['content']);
|
||||
$redis->close();
|
||||
|
||||
@ -401,18 +401,11 @@ class Index extends Frontend
|
||||
}
|
||||
}
|
||||
|
||||
private function getAuthUrl($type, $view, $state = '')
|
||||
private function getAuthUrl($type, $view)
|
||||
{
|
||||
$component_token = $this->component_token();
|
||||
$preauthcode = $this->create_preauthcode();
|
||||
|
||||
// 回调地址需携带 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);
|
||||
$redirect_uri = urlencode("https://ye4s.wms.gztbyc.com/index/index/authNotic");
|
||||
|
||||
switch ($view) {
|
||||
case 'pc':
|
||||
@ -429,11 +422,6 @@ class Index extends Frontend
|
||||
}
|
||||
public function authNotic($state=null) {
|
||||
try {
|
||||
\think\Log::info('授权回调 authNotic: ' . json_encode([
|
||||
'state' => $state,
|
||||
'auth_code' => $this->request->get('auth_code', '')
|
||||
]));
|
||||
|
||||
// 1. 基础验证
|
||||
if (empty($state) || empty($this->request->get('auth_code'))) {
|
||||
return view('error', ['msg' => '参数不完整']);
|
||||
@ -536,35 +524,25 @@ class Index extends Frontend
|
||||
return $this->view->fetch('auth_waiting');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\think\Log::error('授权回调处理异常:' . $e->getMessage() . ' @ ' . $e->getFile() . ':' . $e->getLine() . "\n" . $e->getTraceAsString());
|
||||
// 调试期直接输出异常信息
|
||||
return view('error', ['msg' => $e->getMessage() . ' @ ' . basename($e->getFile()) . ':' . $e->getLine()]);
|
||||
\think\Log::error('授权回调处理异常:' . $e->getMessage());
|
||||
return view('error', ['msg' => '系统处理异常,请稍后重试']);
|
||||
}
|
||||
}
|
||||
public function auth($state)
|
||||
public function auth($state = null)
|
||||
{
|
||||
// 兼容未传 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); // 默认授权所有权限
|
||||
$view = $this->request->get('view', 'pc'); // 默认PC端
|
||||
$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 回跳时读取(跨系统共享)
|
||||
$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);
|
||||
// 生成授权链接
|
||||
$authUrl = $this->getAuthUrl($type, $view);
|
||||
|
||||
if (empty($authUrl)) {
|
||||
$this->error('获取授权链接失败,请检查配置');
|
||||
@ -686,61 +664,47 @@ class Index extends Frontend
|
||||
}
|
||||
|
||||
/**
|
||||
* 转发原始请求到多个环境(默认:qimen + 测试环境)
|
||||
* @param string $path 目标路径
|
||||
* @param string $rawBody 原始报文(POST body)
|
||||
* @param array|string $hosts 目标域名(可传单个字符串)
|
||||
* @return array 每个目标地址的转发结果
|
||||
* 转发原始请求到测试环境
|
||||
* @param string $path 目标路径
|
||||
* @param string $rawBody 原始报文(POST body)
|
||||
* @param string $host 目标域名
|
||||
* @return bool
|
||||
*/
|
||||
private function forwardToTest($path, $rawBody = '', $hosts = [
|
||||
'http://qimen.wms.gztbyc.com',
|
||||
'http://test_wms.o.gztbyc.com',
|
||||
])
|
||||
private function forwardToTest($path, $rawBody = '', $host = 'http://test_wms.o.gztbyc.com')
|
||||
{
|
||||
if (is_string($hosts)) {
|
||||
$hosts = [$hosts];
|
||||
}
|
||||
|
||||
// 原始GET参数(所有环境共用)
|
||||
$query = $this->request->get();
|
||||
|
||||
$results = [];
|
||||
foreach ($hosts as $host) {
|
||||
try {
|
||||
// 拼装目标地址:域名 + 路径 + 原始GET参数
|
||||
$url = rtrim($host, '/') . '/' . ltrim($path, '/');
|
||||
$query = $this->request->get();
|
||||
if (!empty($query)) {
|
||||
$url .= (stripos($url, '?') !== false ? '&' : '?') . http_build_query($query);
|
||||
}
|
||||
|
||||
try {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $rawBody);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Expect:', 'Content-Type: text/xml']);
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $rawBody);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Expect:', 'Content-Type: text/xml']);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
$response = curl_exec($ch);
|
||||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($error) {
|
||||
\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;
|
||||
if ($error) {
|
||||
\think\Log::error('转发到测试环境失败: ' . $url . ' 错误: ' . $error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
\think\Log::info('转发到测试环境成功: ' . $url . ' 返回: ' . $response);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
\think\Log::error('转发到测试环境异常: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2191,9 +2191,9 @@ _________________________________________________________
|
||||
private function lanshou($from,$postnums,$msgid,$info=""){
|
||||
if(count($postnums)>0){
|
||||
$redis = new \Redis();
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
$redis->auth('qwe2019@');
|
||||
$redis->select(15);
|
||||
$redis->connect('47.100.78.112', 6379);
|
||||
$redis->auth('qwe2019');
|
||||
$redis->select(2);
|
||||
$msgs = [];
|
||||
$text = "";
|
||||
$posttype = [];
|
||||
@ -2405,15 +2405,15 @@ _________________________________________________________
|
||||
}
|
||||
private function reRecord($WAREHOUSEID,$workId,$msgId){
|
||||
$redis = new \Redis();
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
$redis->auth('qwe2019@');
|
||||
$redis->connect('47.100.78.112', 6379);
|
||||
$redis->auth('qwe2019');
|
||||
$redis->select(3);
|
||||
$redis->lpush("ware:{$WAREHOUSEID}:reRecord",json_encode([$workId,$msgId]));
|
||||
}
|
||||
private function reRecord2($WAREHOUSEID,$workId,$msgId){
|
||||
$redis = new \Redis();
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
$redis->auth('qwe2019@');
|
||||
$redis->connect('47.100.78.112', 6379);
|
||||
$redis->auth('qwe2019');
|
||||
$redis->select(3);
|
||||
$redis->lpush("ware:{$WAREHOUSEID}:reRecord2",json_encode([$workId,$msgId]));
|
||||
}
|
||||
|
||||
@ -42,9 +42,9 @@ class Wms extends Frontend
|
||||
$this->redis->auth('qwe2019@');
|
||||
$this->redis->select(2);
|
||||
$this->express_redis = new \Redis();
|
||||
$this->express_redis->connect('127.0.0.1', 6379);
|
||||
$this->express_redis->auth('qwe2019@');
|
||||
$this->express_redis->select(15);
|
||||
$this->express_redis->connect('47.100.78.112', 6379);
|
||||
$this->express_redis->auth('qwe2019');
|
||||
$this->express_redis->select(2);
|
||||
$this->postcodeList = [];
|
||||
$this->RulesModel = new \app\common\model\wms\PickingRules;
|
||||
$this->wechatServer = "42.194.235.215";
|
||||
@ -1425,7 +1425,7 @@ class Wms extends Frontend
|
||||
$islingliao = false;
|
||||
foreach($tmp as $dd){
|
||||
$tmp2 = explode(";",$dd);
|
||||
if(strpos($tmp2[0],"领取快递面单")!==false){
|
||||
if(strpos($tmp2[0],"领料")!==false || strpos($tmp2[0],"领取快递面单")!==false){
|
||||
$islingliao = true;
|
||||
}
|
||||
}
|
||||
@ -1458,7 +1458,7 @@ class Wms extends Frontend
|
||||
$islingliao = false;
|
||||
foreach($tmp as $dd){
|
||||
$tmp2 = explode(";",$dd);
|
||||
if(strpos($tmp2[0],"领取快递面单")!==false){
|
||||
if(strpos($tmp2[0],"领料")!==false){
|
||||
$islingliao = true;
|
||||
$r['username']=$tmp2[2];
|
||||
$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->save();
|
||||
$redis = new \Redis();
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
$redis->auth('qwe2019@');
|
||||
$redis->connect('47.100.78.112', 6379);
|
||||
$redis->auth('qwe2019');
|
||||
$redis->select(3);
|
||||
$redis->lpush("ware:{$WAREHOUSEID}:reRecord2",json_encode([$packedInfo->id,0]));
|
||||
}
|
||||
@ -11313,10 +11313,10 @@ class Wms extends Frontend
|
||||
public function test2(){
|
||||
$redis = new \Redis();
|
||||
try {
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
$redis->connect('47.100.78.112', 6379);
|
||||
// 如果有密码认证
|
||||
$redis->auth('qwe2019@');
|
||||
$redis->select(15);
|
||||
$redis->auth('qwe2019');
|
||||
$redis->select(2);
|
||||
// 指定要查找的键和目标字符串
|
||||
$key = 'GalaxyReceive_5400_back';
|
||||
$targetString = '773385681859002';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user