JosVoucherInfoGetRequest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace ACES\Common\domain;
  3. class JosVoucherInfoGetRequest
  4. {
  5. private $customerUserId;
  6. private $accessToken;
  7. /**
  8. * JosVoucherInfoGetRequest constructor.
  9. * @param $customerUserId
  10. */
  11. public function __construct($accessToken)
  12. {
  13. // 区分accessToken和customerUserId
  14. if (isset($accessToken)) {
  15. if (stripos($accessToken, '_') === 0) {
  16. $split = explode('_', $accessToken);
  17. $this->customerUserId = $split[1];
  18. }else{
  19. $this->accessToken = $accessToken;
  20. }
  21. }
  22. }
  23. /**
  24. * @param JosBaseInfo $josBaseInfo
  25. * @return array
  26. */
  27. public function toFormParams($josBaseInfo)
  28. {
  29. return $josBaseInfo->getFormParams($this);
  30. }
  31. public function to360buyParamJson()
  32. {
  33. $paramJson = array();
  34. if (isset($this->customerUserId)) {
  35. $paramJson['customer_user_id'] = $this->customerUserId;
  36. }
  37. if (isset($this->accessToken)) {
  38. $paramJson['access_token'] = $this->accessToken;
  39. }
  40. return json_encode($paramJson);
  41. }
  42. public function getJosMethod()
  43. {
  44. return 'jingdong.jos.voucher.info.get';
  45. }
  46. }