FaceSheetSettingLogic.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\adminapi\logic\express_assistant;
  3. use app\common\enum\ThirdPartyEnum;
  4. use app\common\logic\BaseLogic;
  5. use app\common\service\ConfigService;
  6. class FaceSheetSettingLogic extends BaseLogic
  7. {
  8. /**
  9. * @notes 获取面单类型
  10. * @author Tab
  11. * @date 2021/11/22 11:44
  12. */
  13. public static function getFaceSheetType()
  14. {
  15. $data = [];
  16. foreach(ThirdPartyEnum::FACE_SHEET_TYPE as $value) {
  17. $temp['key'] = $value;
  18. $temp['value'] = ThirdPartyEnum::getThirdPartyDesc($value);
  19. $data[] = $temp;
  20. }
  21. return $data;
  22. }
  23. /**
  24. * @notes 获取电子面单设置
  25. * @author Tab
  26. * @date 2021/11/22 11:24
  27. */
  28. public static function getConfig()
  29. {
  30. $config = [
  31. 'type' => ConfigService::get('face_sheet', 'type', ThirdPartyEnum::KUAIDI100),
  32. 'key' => ConfigService::get('kuaidi100', 'key', ''),
  33. 'secret' => ConfigService::get('kuaidi100', 'secret', ''),
  34. 'siid' => ConfigService::get('kuaidi100', 'siid', '')
  35. ];
  36. return $config;
  37. }
  38. /**
  39. * @notes 电子面单设置
  40. * @author Tab
  41. * @date 2021/11/22 11:57
  42. */
  43. public static function setConfig($params)
  44. {
  45. try {
  46. $faceTypeEnName = ThirdPartyEnum::getThirdPartyDesc($params['type'], 'en');
  47. ConfigService::set('face_sheet', 'type', $params['type']);
  48. ConfigService::set($faceTypeEnName, 'key', $params['key']);
  49. ConfigService::set($faceTypeEnName, 'secret', $params['secret']);
  50. ConfigService::set($faceTypeEnName, 'siid', $params['siid']);
  51. return true;
  52. } catch (\Exception $e) {
  53. self::$error = $e->getMessage();
  54. return false;
  55. }
  56. }
  57. }