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.
167 lines
5.3 KiB
167 lines
5.3 KiB
<?php
|
|
|
|
|
|
namespace App\Admin\Common;
|
|
|
|
use Graze\GuzzleHttp\JsonRpc\Client;
|
|
|
|
class Rpc
|
|
{
|
|
|
|
const SEPARATE_ACCOUNTS = "/orders/onlineComplete";//订单完成
|
|
const ORDER_REFUND = "/orders/onlineRefund";//整笔订单退款
|
|
const ORDER_SINGLE_REFUND = "/orders/onlineSingleRefund";//订单单个商品退款
|
|
const GET_DISTANCE = "/location/getDistanceByTencent";//获取骑行距离
|
|
const DO_BY_ORDER = "/badge/doByOrder";//订单状态变更
|
|
const ALI_SMS_SENT = "/alisms/sent";//发短信
|
|
const FEI_E_PRINT = '/feie/doPrint';//订单打印
|
|
const ORDER_DELIVERY_START= '/orders/onlineDeliveryStart';//订单打印
|
|
|
|
|
|
|
|
/**
|
|
* 订单完成时分账流水
|
|
* @param $oid
|
|
* @param $uid
|
|
* @return string
|
|
*/
|
|
public static function doByOrder($userId, $storeIds, $globalOrderId, $orderState){
|
|
$client = Client::factory(env('RPC_SITE_HOST'));
|
|
$request = $client->request(
|
|
uniqid(),
|
|
self::DO_BY_ORDER,
|
|
['userId' => $userId,'storeIds'=>$storeIds,'globalOrderId'=>$globalOrderId,'orderState'=>$orderState]);
|
|
$response = $client->send($request);
|
|
return $response->getBody()->getContents();
|
|
}
|
|
/**
|
|
* 订单完成时分账流水
|
|
* @param $oid
|
|
* @param $uid
|
|
* @return string
|
|
*/
|
|
public static function separateAccounts($global_order_id,$uid){
|
|
$client = Client::factory(env('RPC_SITE_HOST'));
|
|
$request = $client->request(
|
|
uniqid(),
|
|
self::SEPARATE_ACCOUNTS,
|
|
['global_order_id' => $global_order_id,'user_id'=>$uid]);
|
|
$response = $client->send($request);
|
|
return $response->getBody()->getContents();
|
|
}
|
|
|
|
/**
|
|
* 订单整笔退款
|
|
* @param $global_order_id
|
|
* @param $uid
|
|
* @return string
|
|
*/
|
|
public static function orderRefund($global_order_id,$uid){
|
|
$client = Client::factory(env('RPC_SITE_HOST'));
|
|
$request = $client->request(
|
|
uniqid(),
|
|
self::ORDER_REFUND,
|
|
['global_order_id' => $global_order_id,'user_id'=>$uid]);
|
|
$response = $client->send($request);
|
|
return $response->getBody()->getContents();
|
|
}
|
|
|
|
/**
|
|
* @param $lng1
|
|
* @param $lat1
|
|
* @param $lng2
|
|
* @param $lat2
|
|
* @return mixed
|
|
*/
|
|
public static function getDistance($lng1, $lat1, $lng2, $lat2){
|
|
$client = Client::factory(env('RPC_SITE_HOST'));
|
|
$request = $client->request(
|
|
uniqid(),
|
|
self::GET_DISTANCE,
|
|
['lng1' => $lng1,'lat1'=>$lat1,'lng2'=>$lng2,'lat2'=>$lat2]);
|
|
$response = $client->send($request);
|
|
return json_decode($response->getBody()->getContents(),true);
|
|
}
|
|
|
|
/**
|
|
* 线上订单单笔退款,主要用于后台强行操作退单退款
|
|
* 支持单商品、单店、整单
|
|
* 按比例计算红包进行退款
|
|
* 比如:两个子订单和子订单商品,分别是2元,98元,使用了10元优惠券
|
|
* 退2元商品时,退款金额为
|
|
* 红包 :(2/(98+2))*10 = 0.2
|
|
* 退款:2-0.2=1.8元
|
|
* @param $user_id
|
|
* @param $note
|
|
* @param $global_order_id
|
|
* @param null $order_child_id
|
|
* @param null $order_goods_id
|
|
* @return mixed
|
|
*/
|
|
public static function onlineSingleRefund($user_id, $note, $global_order_id, $order_child_id=null, $order_goods_id=null){
|
|
$client = Client::factory(env('RPC_SITE_HOST'));
|
|
$request = $client->request(
|
|
uniqid(),
|
|
self::ORDER_SINGLE_REFUND,
|
|
[
|
|
'user_id' => $user_id,
|
|
'note'=>$note,
|
|
'global_order_id'=>$global_order_id,
|
|
'order_child_id'=>$order_child_id,
|
|
'order_goods_id'=>$order_goods_id
|
|
]);
|
|
$response = $client->send($request);
|
|
return json_decode($response->getBody()->getContents(),true);
|
|
}
|
|
|
|
/**
|
|
* 阿里大于
|
|
* @param $phone
|
|
* @param $template
|
|
* @param $templateParams
|
|
* @param string $signName
|
|
* @return string
|
|
*/
|
|
public static function alisSmsSent($phone, $template, $templateParams, $signName='链街生活'){
|
|
$client = Client::factory(env('RPC_SITE_HOST'));
|
|
$request = $client->request(uniqid(),
|
|
self::ALI_SMS_SENT,
|
|
[
|
|
'phone' => $phone,
|
|
'template'=>$template,
|
|
'templateParams'=> json_encode($templateParams),
|
|
'signName'=>$signName,
|
|
]);
|
|
$response = $client->send($request);
|
|
return $response->getBody()->getContents();
|
|
}
|
|
|
|
/**
|
|
* 订单打印
|
|
* @param $oid
|
|
* @return string
|
|
*/
|
|
public static function doPrint($oid)
|
|
{
|
|
$client = Client::factory(env('RPC_SITE_HOST'));
|
|
$request = $client->request(uniqid(),
|
|
self::FEI_E_PRINT,
|
|
['oid' => $oid]
|
|
);
|
|
$response = $client->send($request);
|
|
return $response->getBody()->getContents();
|
|
}
|
|
|
|
|
|
public static function onlineDeliveryStart($global_order_id)
|
|
{
|
|
$client = Client::factory(env('RPC_SITE_HOST'));
|
|
$request = $client->request(uniqid(),
|
|
self::ORDER_DELIVERY_START,
|
|
['global_order_id' => $global_order_id]
|
|
);
|
|
$response = $client->send($request);
|
|
return $response->getBody()->getContents();
|
|
}
|
|
|
|
}
|