|
@@ -1,14 +1,19 @@
|
|
|
<?php
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
+use App\Model\ErrorTable;
|
|
|
use App\Service\FinishedOrderService;
|
|
|
use Closure;
|
|
|
use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
|
class YongYou
|
|
|
{
|
|
|
+ const type_one = 1; //包装 =》 产成品入库
|
|
|
+ const type_two = 2; //发货 =》 发货出库
|
|
|
+
|
|
|
/**
|
|
|
* Handle an incoming request.
|
|
|
*
|
|
@@ -31,6 +36,7 @@ class YongYou
|
|
|
*/
|
|
|
public function terminate(Request $request, Response $response)
|
|
|
{
|
|
|
+ $time = time();
|
|
|
$userData = $request->userData->toArray();
|
|
|
$return = json_decode($response->content(),true);
|
|
|
|
|
@@ -39,9 +45,31 @@ class YongYou
|
|
|
$package_data = $return['data']['package_data'];
|
|
|
if(! empty($package_data)) {
|
|
|
$service = new FinishedOrderService();
|
|
|
- $service->U8Rdrecord10Save($package_data,$userData);
|
|
|
+ list($status,$msg) = $service->U8Rdrecord10Save($package_data,$userData);
|
|
|
+ if(! $status) $this->recordErrorTable($msg,$userData,$package_data,$time,self::type_one);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(! empty($return['data']['send_data'])){
|
|
|
+ $package_data = $return['data']['send_data'];
|
|
|
+ if(! empty($package_data)) {
|
|
|
+ $service = new FinishedOrderService();
|
|
|
+ list($status,$msg) = $service->U8Rdrecord32Save($package_data,$userData);
|
|
|
+ if(! $status) $this->recordErrorTable($msg,$userData,$package_data,$time,self::type_one);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private function recordErrorTable($msg,$user,$data,$time,$type){
|
|
|
+ // 连接到指定数据库连接
|
|
|
+ ErrorTable::insert([
|
|
|
+ 'msg' => $msg,
|
|
|
+ 'data' => json_encode($data),
|
|
|
+ 'user_id' => $user['id'],
|
|
|
+ 'user_operation_time' => $time,
|
|
|
+ 'type' => $type,
|
|
|
+ 'order_no' => $data['order_no'] ?? ""
|
|
|
+ ]);
|
|
|
+ }
|
|
|
}
|