162 lines
4.4 KiB
PHP
162 lines
4.4 KiB
PHP
<?php
|
|
namespace addon\aliapp\api\controller;
|
|
use addon\alipay\data\sdk\AopClient;
|
|
use app\api\controller\BaseApi;
|
|
use app\model\order\OrderCommon as OrderCommonModel;
|
|
class Order extends BaseApi
|
|
{
|
|
public $aop;
|
|
public $orderStatus=[
|
|
0=>'CREATE',//创建
|
|
1=>'WAIT_PAY',//代支付
|
|
2=>'CLOSED',//关闭
|
|
3=>'REFUNDING',//退款中
|
|
4=>'REFUNDED',//已退款
|
|
5=>'FINISHED',//已完成
|
|
6=>'IN_DELIVERY',//已发货配送中
|
|
7=>'REFUND_PART',//部分退款
|
|
8=>'RETURN_PART',//部分退货
|
|
9=>'TO_SEND_GOODS',//待发货
|
|
10=>'PARTIAL_DELIVERY',//部分发货
|
|
11=>'SIGNED',//已签收
|
|
12=>'PAID',//支付完成
|
|
|
|
|
|
15=>'TO_BE_DELIVERED',//待配送
|
|
13=>'CENTRE_DELIVERY',//社区团购中心仓配货
|
|
14=>'GRID_DELIVERY',//网格仓配送
|
|
];
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$config_info = config('alipay.platform');
|
|
// 获取支付宝支付参数(统一支付到平台账户)
|
|
$this->aop = new AopClient();
|
|
$this->aop->alipayrsaPublicKey = $config_info['public_key'] ?? "";
|
|
$this->aop->alipayPublicKey = $config_info['alipay_public_key'] ?? "";
|
|
$this->aop->appId = $config_info["appid"] ?? "";
|
|
$this->aop->rsaPrivateKey = $config_info['private_key'] ?? "";
|
|
$this->aop->alipaySdkVersion = "alipay-sdk-php-20200415";
|
|
$this->aop->apiVersion = '1.0';
|
|
$this->aop->signType = 'RSA2';
|
|
$this->aop->postCharset = 'UTF-8';
|
|
$this->aop->format = 'json';
|
|
}
|
|
|
|
/***
|
|
* 单个订单查询
|
|
* spi.alipay.merchant.order.realtimeinfo.query
|
|
* @return void
|
|
*/
|
|
public function query()
|
|
{
|
|
file_put_contents('query.txt', json_encode(input('')));
|
|
$merchant_order_no=input('merchant_order_no','');
|
|
$result=[];
|
|
if($merchant_order_no){
|
|
$order_common_model = new OrderCommonModel();
|
|
$condition=[
|
|
['out_trade_no','=',$merchant_order_no]
|
|
];
|
|
$orderInfo=$order_common_model->getOrderInfo($condition);
|
|
$result=[
|
|
'merchant_order_status'=>'',
|
|
];
|
|
}
|
|
$data = [
|
|
'code' => 10000,
|
|
'msg' => 'Success',
|
|
'success' => true,
|
|
'result' => [],
|
|
'error_code' => '',
|
|
'error_desc' => '',
|
|
];
|
|
if(empty($result)){
|
|
$data['code']='40004';
|
|
$data['success']=false;
|
|
$data['error_code']='BIZ_ERROR';
|
|
$data['error_desc']='未找到当前订单';
|
|
}
|
|
$response = [
|
|
'response' =>$data ,
|
|
'sign' => $this->sign($data),
|
|
];
|
|
// return json($response);
|
|
}
|
|
|
|
|
|
/***
|
|
* 批量订单查询
|
|
* @return void
|
|
*/
|
|
public function batchquery()
|
|
{
|
|
file_put_contents('batchquery.txt', json_encode(input('')));
|
|
$data = [
|
|
'code' => 10000,
|
|
'msg' => 'Success',
|
|
'success' => true,
|
|
'error_code' => '',
|
|
'error_desc' => '',
|
|
'journey_order_list' => [],
|
|
];
|
|
if(empty($result)){
|
|
$data['code']='40004';
|
|
$data['success']=false;
|
|
$data['error_code']='BIZ_ERROR';
|
|
$data['error_desc']='未找到当前订单';
|
|
}
|
|
$response = [
|
|
'response' =>$data ,
|
|
'sign' => $this->sign($data),
|
|
];
|
|
// return json($response);
|
|
}
|
|
|
|
/**
|
|
* 支付宝
|
|
* 本地生活
|
|
* 查询订单是否可退款
|
|
* @return void
|
|
*/
|
|
public function refundconfirm()
|
|
{
|
|
|
|
file_put_contents('refundconfirm.txt', json_encode(input('')));
|
|
}
|
|
|
|
|
|
/***
|
|
* 本地生活
|
|
* 三方凭证发放
|
|
* 商家发送核销凭证
|
|
* @return void
|
|
*/
|
|
public function send()
|
|
{
|
|
file_put_contents('Minsend.txt', json_encode(input('')));
|
|
}
|
|
|
|
|
|
/**
|
|
* 小程序商品动态数据查询
|
|
* @return void
|
|
*/
|
|
public function MinBatchquery()
|
|
{
|
|
file_put_contents('MinBatchquery.txt', json_encode(input('')));
|
|
}
|
|
|
|
|
|
/***
|
|
* 签名
|
|
* @param $response
|
|
* @return string|null
|
|
*/
|
|
private function sign($response = [])
|
|
{
|
|
ksort($response);
|
|
$sign=$this->aop->sign(json_encode($response), "RSA2");
|
|
return $sign;
|
|
}
|
|
} |