| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <?php
- namespace app\extra\dyLife\data;
- use app\extra\dyLife\BasicLife;
- /**
- * 订单相关
- */
- class OrderData extends BasicLife
- {
- /**
- * 通过订单ID获取 encrypted_code
- * https://developer.open-douyin.com/docs/resource/zh-CN/local-life/develop/OpenAPI/general-capabilities/life.capacity.fulfilment/certificate.query
- * @param string $orderId
- * @param string $accountId
- * data['certificates'][0]['encrypted_code']
- * @return array
- */
- public function getCertificate(string $orderId = "",string $accountId = ""): array
- {
- $param = [
- "account_id" => $accountId,
- "order_id" => $orderId
- ];
- return $this->curlPostApi("goodlife/v1/fulfilment/certificate/query/",$param);
- }
- /**
- * 查询订单详情
- * @param string $orderId
- * @return array
- */
- public function getOrderData(string $orderId = ""): array
- {
- $param = [
- "account_id" => $this->baseAccountId,
- "order_id" => $orderId,
- "page_num" => 1,
- "page_size" => 10
- ];
- return $this->curlPostApi("goodlife/v1/trade/order/query/",$param);
- }
- /**
- * 发起核销
- * https://developer.open-douyin.com/docs/resource/zh-CN/local-life/develop/OpenAPI/general-capabilities/life.capacity.fulfilment/certificate.verify
- * @param array $data
- * data['verify_results'][0]
- * certificate_id、verify_id
- * @return array
- */
- public function verifyCertificate(array $data = []): array
- {
- $param = [
- "account_id" => $data['account_id'],
- "verify_token" => $data['pay_sn'],
- "encrypted_codes" => $data['encrypted_code'],
- "order_id" => $data['order_id'],
- "poi_id" => $data['poi_id']
- ];
- return $this->curlPostApi("goodlife/v1/fulfilment/certificate/verify/",$param);
- }
- /**
- * 撤销核销
- * https://developer.open-douyin.com/docs/resource/zh-CN/local-life/develop/OpenAPI/general-capabilities/life.capacity.fulfilment/certificate.cancel
- * @param array $data
- * data['cancel_results'][0]
- * result_code
- * @return array
- */
- public function cancelCertificate(array $data = []): array
- {
- $param = [
- "certificate_id" => $data['certificate_id'],
- "verify_id" => $data['verify_id'],
- "account_id" => $data['account_id']
- ];
- return $this->curlPostApi("goodlife/v1/fulfilment/certificate/verify/",$param);
- }
- /**
- * 订单退款
- * https://developer.open-douyin.com/docs/resource/zh-CN/local-life/develop/OpenAPI/general-capabilities/groupon-refund/order-refund-apply
- * @param string $orderId
- * @param array $codeList
- * @return array
- */
- public function cancelOrder(string $orderId = "",array $codeList = []): array
- {
- $param = [
- "refund_reason_code" => [305],
- "order_id" => $orderId,
- "certificate_id_list" => $codeList,
- "account_id" => $this->baseAccountId
- ];
- echo "手动退款参数\n";
- print_r($param);
- return $this->curlPostApi("goodlife/v1/groupon/order/refund/apply/",$param);
- }
- /**
- * 开发者发起退款
- * https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/locallife/general-ability/agency-trade-system/refund/apply
- */
- public function refundOrderOp(array $data = []): array
- {
- $param = [
- "out_order_no" => $data['out_order_no'], // AL开头订单号
- "out_refund_no" => $data['out_order_no']."1",
- "order_entry_schema" => [
- "path" => "pages/order/detail",
- "params" => json_encode(['order' => $data['out_order_no']])
- ],
- "notify_url" => "https://tran.jsshuita.cn/notify/refund",
- "item_order_detail" => [
- [
- "item_order_id" => $data['item_order_id'],
- ]
- ]
- ];
- return $this->curlPostApi("api/apps/trade/v2/refund/create_refund",$param);
- }
- /**
- * 小程序版核销 - 三方码
- * https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/locallife/general-ability/agency-trade-system/fulfillment/third-code/push-delivery
- * @param array $data
- * @return array
- * {
- * "data": {
- * "verify_results": [
- * {
- * "certificate_id": "7676385765337382962",
- * "item_order_id": "800014550969473945813031711",
- * "verify_id": "7676388522927933482",
- * "verify_time": 1787298487000
- * }
- * ],
- * "error_code": 0,
- * "description": ""
- * },
- * }
- */
- public function verifyOrder(array $data = []): array
- {
- $param = [
- "delivery_status" => 2,
- "item_order_list" => [
- [
- "item_order_id" => $data['item_order_id'],
- ]
- ],
- "poi_info" => json_encode([
- "shop_name" => $data['poi']['poi_name'],
- "ext_valid_shop_id" => $data['poi']['poi_id'],
- "valid_poi_id_str" => $data['poi']['poi_id'],
- ]),
- "out_order_no" => $data['out_order_no'],
- "use_all" => true
- ];
- return $this->curlPostApi("api/apps/trade/v2/fulfillment/push_delivery/",$param);
- }
- /**
- * 退款审核推送
- * https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/locallife/general-ability/agency-trade-system/refund/audit-callback
- * @param array $data
- * @return array
- */
- public function auditOrder(array $data = []): array
- {
- $param = [
- "out_refund_no" => "R".$data['out_order_no'],
- "refund_audit_status" => 1
- ];
- return $this->curlPostApi("api/apps/trade/v2/refund/merchant_audit_callback",$param);
- }
- }
|