链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
4.3 KiB

6 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
5 years ago
6 years ago
5 years ago
6 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
  1. <?php
  2. namespace App\Admin\Common;
  3. use Graze\GuzzleHttp\JsonRpc\Client;
  4. class Rpc
  5. {
  6. const SEPARATE_ACCOUNTS = "/order/onlineComplete";
  7. const ORDER_REFUND = "/order/onlineRefund";
  8. const ORDER_SINGLE_REFUND = "/order/onlineSingleRefund";
  9. const GET_DISTANCE = "/location/getDistanceByTencent";
  10. const DO_BY_ORDER = "/badge/doByOrder";
  11. const ALI_SMS_SENT = "/alisms/sent";
  12. /**
  13. * 订单完成时分账流水
  14. * @param $oid
  15. * @param $uid
  16. * @return string
  17. */
  18. public static function doByOrder($userId, $storeIds, $globalOrderId, $orderState){
  19. $client = Client::factory(env('RPC_SITE_HOST'));
  20. $request = $client->request(
  21. uniqid(),
  22. self::DO_BY_ORDER,
  23. ['userId' => $userId,'storeIds'=>$storeIds,'globalOrderId'=>$globalOrderId,'orderState'=>$orderState]);
  24. $response = $client->send($request);
  25. return $response->getBody()->getContents();
  26. }
  27. /**
  28. * 订单完成时分账流水
  29. * @param $oid
  30. * @param $uid
  31. * @return string
  32. */
  33. public static function separateAccounts($global_order_id,$uid){
  34. $client = Client::factory(env('RPC_SITE_HOST'));
  35. $request = $client->request(
  36. uniqid(),
  37. self::SEPARATE_ACCOUNTS,
  38. ['global_order_id' => $global_order_id,'user_id'=>$uid]);
  39. $response = $client->send($request);
  40. return $response->getBody()->getContents();
  41. }
  42. /**
  43. * 订单整笔退款
  44. * @param $global_order_id
  45. * @param $uid
  46. * @return string
  47. */
  48. public static function orderRefund($global_order_id,$uid){
  49. $client = Client::factory(env('RPC_SITE_HOST'));
  50. $request = $client->request(
  51. uniqid(),
  52. self::ORDER_REFUND,
  53. ['global_order_id' => $global_order_id,'user_id'=>$uid]);
  54. $response = $client->send($request);
  55. return $response->getBody()->getContents();
  56. }
  57. /**
  58. * @param $lng1
  59. * @param $lat1
  60. * @param $lng2
  61. * @param $lat2
  62. * @return mixed
  63. */
  64. public static function getDistance($lng1, $lat1, $lng2, $lat2){
  65. $client = Client::factory(env('RPC_SITE_HOST'));
  66. $request = $client->request(
  67. uniqid(),
  68. self::GET_DISTANCE,
  69. ['lng1' => $lng1,'lat1'=>$lat1,'lng2'=>$lng2,'lat2'=>$lat2]);
  70. $response = $client->send($request);
  71. return json_decode($response->getBody()->getContents(),true);
  72. }
  73. /**
  74. * 线上订单单笔退款,主要用于后台强行操作退单退款
  75. * 支持单商品、单店、整单
  76. * 按比例计算红包进行退款
  77. * 比如:两个子订单和子订单商品,分别是2元,98元,使用了10元优惠券
  78. * 退2元商品时,退款金额为
  79. * 红包 (2/(98+2)*10 = 0.2
  80. * 退款:2-0.2=1.8
  81. * @param $user_id
  82. * @param $note
  83. * @param $global_order_id
  84. * @param null $order_child_id
  85. * @param null $order_goods_id
  86. * @return mixed
  87. */
  88. public static function onlineSingleRefund($user_id, $note, $global_order_id, $order_child_id=null, $order_goods_id=null){
  89. $client = Client::factory(env('RPC_SITE_HOST'));
  90. $request = $client->request(
  91. uniqid(),
  92. self::ORDER_SINGLE_REFUND,
  93. [
  94. 'user_id' => $user_id,
  95. 'note'=>$note,
  96. 'global_order_id'=>$global_order_id,
  97. 'order_child_id'=>$order_child_id,
  98. 'order_goods_id'=>$order_goods_id
  99. ]);
  100. $response = $client->send($request);
  101. return json_decode($response->getBody()->getContents(),true);
  102. }
  103. /**
  104. * 阿里大于
  105. * @param $phone
  106. * @param $template
  107. * @param $templateParams
  108. * @param string $signName
  109. * @return string
  110. */
  111. public static function alisSmsSent($phone, $template, $templateParams, $signName='懒族生活'){
  112. $client = Client::factory(env('RPC_SITE_HOST'));
  113. $request = $client->request(uniqid(),
  114. self::ALI_SMS_SENT,
  115. [
  116. 'phone' => $phone,
  117. 'template'=>$template,
  118. 'templateParams'=> json_encode($templateParams),
  119. 'signName'=>$signName,
  120. ]);
  121. $response = $client->send($request);
  122. return $response->getBody()->getContents();
  123. }
  124. }