Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. $test = [
  2. [
  3. "id" => "",
  4. "demand_id" => null,
  5. "corp_id" => 168221,
  6. "push_time" => "2018-07-19 11:45",
  7. "push_flg" => 0,
  8. "before_push_flg" => 0,
  9. "display_flg" => 0,
  10. "refusal_flg" => 0,
  11. "rank" => "z",
  12. "auto_call_time" => null,
  13. "auto_call_flg" => null,
  14. "affiliationAreaStat" =>[
  15. "commission_unit_price_category" => null,
  16. "commission_count_category" => 0,
  17. "commission_unit_price_rank" => "z",
  18. ],
  19. "mCorpCategory" => [
  20. "order_fee" => 30,
  21. "order_fee_unit" => 1,
  22. "introduce_fee" => null,
  23. "corp_commission_type" => 1,
  24. ],
  25. "mCorp" => [
  26. "id" => 168221,
  27. ]
  28. ],
  29. [
  30. "id" => "",
  31. "demand_id" => null,
  32. "corp_id" => 167611,
  33. "push_time" => "2018-07-19 11:45",
  34. "push_flg" => 0,
  35. "before_push_flg" => 0,
  36. "display_flg" => 0,
  37. "refusal_flg" => 0,
  38. "rank" => "z",
  39. "auto_call_time" => null,
  40. "auto_call_flg" => null,
  41. "affiliationAreaStat" => [
  42. "commission_unit_price_category" => null,
  43. "commission_count_category" => 0,
  44. "commission_unit_price_rank" => "z",
  45. ],
  46. "mCorpCategory" => [
  47. "order_fee" => 30,
  48. "order_fee_unit" => 1,
  49. "introduce_fee" => null,
  50. "corp_commission_type" => 1,
  51. ],
  52. "mCorp" => [
  53. "id" => 167611,
  54. ]
  55. ]
  56. ];
  57.  
  58. uasort($test, function($a, $b){
  59. if($a['push_time'] != $b['push_time']){
  60. // AuctionInfo.push_time asc
  61. return $a['push_time'] < $b['push_time'] ? -1 : 1;
  62. }else if($a['affiliationAreaStat']['commission_unit_price_category'] != $b['affiliationAreaStat']['commission_unit_price_category']){
  63. // affiliationAreaStat.commission_unit_price_category IS NULL
  64. if(empty($a['affiliationAreaStat']['commission_unit_price_category']) && !empty($b['affiliationAreaStat']['commission_unit_price_category']))
  65. return 1;
  66. else if(!empty($a['affiliationAreaStat']['commission_unit_price_category']) && empty($b['affiliationAreaStat']['commission_unit_price_category']))
  67. return -1;
  68. else
  69. // affiliationAreaStat.commission_unit_price_category desc
  70. return $a['affiliationAreaStat']['commission_unit_price_category'] > $b['affiliationAreaStat']['commission_unit_price_category'] ? -1 : 1;
  71. }else if($a['affiliationAreaStat']['commission_count_category'] != $b['affiliationAreaStat']['commission_count_category']){
  72. // affiliationAreaStat.commission_count_category desc
  73. return $a['affiliationAreaStat']['commission_count_category'] > $b['affiliationAreaStat']['commission_count_category'] ? -1 : 1;
  74. }else{
  75. return 0;
  76. }
  77. });
  78. var_dump($test);
  79. die;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement