PackageController.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Http\Controllers\api\thirdPart\hengli;
  3. use App\Http\Controllers\api\thirdPart\weight\WeightBaseController;
  4. use App\Log;
  5. use Illuminate\Http\Request;
  6. class PackageController extends WeightBaseController
  7. {
  8. // 参数
  9. protected $weight = 'weight'; // 重量
  10. protected $length = 'length'; // 长
  11. protected $width = 'width'; // 宽
  12. protected $height = 'height'; // 高
  13. protected $code = 'code'; // 快递单号
  14. protected $weight_at = 'weight_at'; // 称重时间
  15. protected $hid = 'hid'; // 称重设备id
  16. protected $name = 'HengLi'; // 名称
  17. public function new_(Request $request)
  18. {
  19. return $this->new($request);
  20. }
  21. public function conversionRequest($request)
  22. {
  23. $params = [];
  24. $arr = $request->all();
  25. $data = array_key_first($arr);
  26. $data = explode(',',$data);
  27. foreach ($data as $key=>$value){
  28. switch ($key){
  29. case '0':
  30. $params['code'] = $value;
  31. break;
  32. case '1':
  33. $params['weight'] = $value;
  34. break;
  35. case '2':
  36. $params['weight_at'] = $value;
  37. break;
  38. default:
  39. break;
  40. }
  41. }
  42. $params['hid'] = 123;
  43. return $params;
  44. }
  45. // 信息返回
  46. // 返回称重成功信息
  47. public function getSuccessMessage($params, $orderPackage): array
  48. {
  49. return ['success' => true, 'error' => '称重成功'];
  50. }
  51. // 返回包裹未找到异常
  52. public function getNotFindOrderPackageMessage($params, $orderPackage): string
  53. {
  54. return json_encode(['success'=>false,'message'=>'未找打包裹信息',JSON_UNESCAPED_UNICODE]);
  55. }
  56. // 返回富勒信息未找到异常
  57. public function getNotFindOrderHeaderMessage($params, $orderPackage):string
  58. {
  59. return json_encode(['success'=>false,'message'=> '富勒信息未找到'],JSON_UNESCAPED_UNICODE);
  60. }
  61. // 返回称重下发错误
  62. public function getWeightMessage($orderPackage,$e)
  63. {
  64. return json_encode(['success'=>false,'message'=> $e->getMessage],JSON_UNESCAPED_UNICODE);
  65. }
  66. }