|
|
@@ -0,0 +1,141 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace common\components;
|
|
|
+
|
|
|
+use Yii;
|
|
|
+use yii\helpers\Json;
|
|
|
+use linslin\yii2\curl;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 微信小程序发货信息管理服务-核心接口工具类
|
|
|
+ * 仅封装图片中列出的接口,风格参考 expressUtil.php
|
|
|
+ */
|
|
|
+class shippingUtil
|
|
|
+{
|
|
|
+ public static function getAccessToken($merchant, $ptStyle = 0)
|
|
|
+ {
|
|
|
+ return miniUtil::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发货信息录入接口
|
|
|
+ * https://api.weixin.qq.com/wxa/sec/order/shipping?access_token=ACCESS_TOKEN
|
|
|
+ */
|
|
|
+ public static function shipping($merchant, $data, $ptStyle = 0)
|
|
|
+ {
|
|
|
+ $accessToken = self::getAccessToken($merchant, $ptStyle);
|
|
|
+ $url = "https://api.weixin.qq.com/wxa/sec/order/shipping?access_token={$accessToken}";
|
|
|
+ $curl = new curl\Curl();
|
|
|
+ $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
+ return Json::decode($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发货信息合单录入接口
|
|
|
+ * https://api.weixin.qq.com/wxa/sec/order/shippingcombine?access_token=ACCESS_TOKEN
|
|
|
+ */
|
|
|
+ public static function shippingCombine($merchant, $data, $ptStyle = 0)
|
|
|
+ {
|
|
|
+ $accessToken = self::getAccessToken($merchant, $ptStyle);
|
|
|
+ $url = "https://api.weixin.qq.com/wxa/sec/order/shippingcombine?access_token={$accessToken}";
|
|
|
+ $curl = new curl\Curl();
|
|
|
+ $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
+ return Json::decode($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询订单发货状态
|
|
|
+ * https://api.weixin.qq.com/wxa/sec/order/getshippinginfo?access_token=ACCESS_TOKEN
|
|
|
+ */
|
|
|
+ public static function getShippingInfo($merchant, $data, $ptStyle = 0)
|
|
|
+ {
|
|
|
+ $accessToken = self::getAccessToken($merchant, $ptStyle);
|
|
|
+ $url = "https://api.weixin.qq.com/wxa/sec/order/getshippinginfo?access_token={$accessToken}";
|
|
|
+ $curl = new curl\Curl();
|
|
|
+ $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
+ return Json::decode($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询订单列表
|
|
|
+ * https://api.weixin.qq.com/wxa/sec/order/getorderlist?access_token=ACCESS_TOKEN
|
|
|
+ */
|
|
|
+ public static function getOrderList($merchant, $data, $ptStyle = 0)
|
|
|
+ {
|
|
|
+ $accessToken = self::getAccessToken($merchant, $ptStyle);
|
|
|
+ $url = "https://api.weixin.qq.com/wxa/sec/order/getorderlist?access_token={$accessToken}";
|
|
|
+ $curl = new curl\Curl();
|
|
|
+ $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
+ return Json::decode($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 确认收货提醒接口
|
|
|
+ * https://api.weixin.qq.com/wxa/sec/order/confirmreceivemsg?access_token=ACCESS_TOKEN
|
|
|
+ */
|
|
|
+ public static function confirmReceiveMsg($merchant, $data, $ptStyle = 0)
|
|
|
+ {
|
|
|
+ $accessToken = self::getAccessToken($merchant, $ptStyle);
|
|
|
+ $url = "https://api.weixin.qq.com/wxa/sec/order/confirmreceivemsg?access_token={$accessToken}";
|
|
|
+ $curl = new curl\Curl();
|
|
|
+ $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
+ return Json::decode($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 消息跳转路径设置接口
|
|
|
+ * https://api.weixin.qq.com/wxa/sec/order/setmsgjump?access_token=ACCESS_TOKEN
|
|
|
+ */
|
|
|
+ public static function setMsgJump($merchant, $data, $ptStyle = 0)
|
|
|
+ {
|
|
|
+ $accessToken = self::getAccessToken($merchant, $ptStyle);
|
|
|
+ $url = "https://api.weixin.qq.com/wxa/sec/order/setmsgjump?access_token={$accessToken}";
|
|
|
+ $curl = new curl\Curl();
|
|
|
+ $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
+ return Json::decode($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询小程序是否已开通发货信息管理服务
|
|
|
+ */
|
|
|
+ public static function isTradeManage($merchant, $data = [], $ptStyle = 0)
|
|
|
+ {
|
|
|
+ $accessToken = self::getAccessToken($merchant, $ptStyle);
|
|
|
+ $url = "https://api.weixin.qq.com/wxa/sec/order/is_trade_managed?access_token={$accessToken}";
|
|
|
+ $curl = new curl\Curl();
|
|
|
+ $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
+ return Json::decode($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询小程序是否已完成交易结算管理确认
|
|
|
+ */
|
|
|
+ public static function isTradeManageConfirmComplete($merchant, $data = [], $ptStyle = 0)
|
|
|
+ {
|
|
|
+ $accessToken = self::getAccessToken($merchant, $ptStyle);
|
|
|
+ $url = "https://api.weixin.qq.com/wxa/sec/order/is_trade_management_confirmation_completed?access_token={$accessToken}";
|
|
|
+ $curl = new curl\Curl();
|
|
|
+ $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
+ return Json::decode($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 相关消息推送(无需主动调用,文档留档)
|
|
|
+ * 仅做占位说明
|
|
|
+ */
|
|
|
+ // public static function messagePush() {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 特殊发货报备
|
|
|
+ * https://api.weixin.qq.com/wxa/sec/order/opspecialorder?access_token=ACCESS_TOKEN
|
|
|
+ */
|
|
|
+ public static function opSpecialOrder($merchant, $data, $ptStyle = 0)
|
|
|
+ {
|
|
|
+ $accessToken = self::getAccessToken($merchant, $ptStyle);
|
|
|
+ $url = "https://api.weixin.qq.com/wxa/sec/order/opspecialorder?access_token={$accessToken}";
|
|
|
+ $curl = new curl\Curl();
|
|
|
+ $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
+ return Json::decode($result);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|