DianYingUtil.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Http\Utils\DianYing;
  3. use App\Exceptions\CommonException;
  4. use App\Http\Bean\Util\KenDeJi\GetKfcOrdersParamBean;
  5. use App\Http\Enum\ErrorEnum;
  6. use App\Http\Utils\BaseUtil;
  7. use Tool\ShanTaoTool\HttpCurl;
  8. class DianYingUtil extends BaseUtil
  9. {
  10. /**
  11. * 获取肯德基活动转链
  12. * @param $sid string 推广位ID
  13. * @param string $phone 手机号码
  14. */
  15. public static function getDianYingActUrl($sid, $phone = "")
  16. {
  17. $url = "http://api.jutuike.com/Cinema/act";
  18. $params = [
  19. "apikey"=>env("JU_TUI_KE_API_KEY"),
  20. "sid"=>$sid
  21. ];
  22. if($phone){
  23. $params["mobile"] = $phone;
  24. }
  25. $res = HttpCurl::getCurl($url,$params);
  26. if($res["code"]!= 1){
  27. throw new CommonException(ErrorEnum::ERROR_KFC_URL);
  28. }
  29. return $res["data"];
  30. }
  31. /**
  32. * 获取kfc订单
  33. * @param GetKfcOrdersParamBean $getKfcOrdersParamBean
  34. */
  35. public static function getDianYingOrders(GetKfcOrdersParamBean $getKfcOrdersParamBean)
  36. {
  37. $url = "http://api.jutuike.com/Cinema/orders";
  38. $params = [
  39. "apikey"=>env("JU_TUI_KE_API_KEY"),
  40. "start_time"=>$getKfcOrdersParamBean->getStartTime(),
  41. "end_time"=>$getKfcOrdersParamBean->getEndTime(),
  42. "query_type"=>$getKfcOrdersParamBean->getQueryType(),
  43. "status"=>$getKfcOrdersParamBean->getStatus(),
  44. "page"=>$getKfcOrdersParamBean->getPage(),
  45. "pageSize"=>$getKfcOrdersParamBean->getPageSize()
  46. ];
  47. $res = HttpCurl::getCurl($url,$params);
  48. if($res["code"]==1){
  49. return $res["data"];
  50. }
  51. if($res["msg"]=="【对应条件内无数据】"){
  52. return [];
  53. }
  54. }
  55. }