ReturnsData.php 8.84 KB
<?php
namespace LibModels\Web\Home;

use Api\Yohobuy;
use Api\Sign;

class ReturnsData
{
    const URI_SEND_MESSAGE = 'inbox/service/v1/inbox';

    /**
     * 退换货订单列表数据
     * @param $uid
     * @param int $limit
     * @param int $page
     * @return mixed
     */
    public static function getReturnsData($uid, $limit = 10, $page = 1)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.refund.getList';
        $param['uid'] = $uid;
        $param['limit'] = $limit;
        $param['page'] = $page;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }


    /**
     * 可退货商品列表
     * @param $orderCode
     * @param $uid
     * @return mixed
     */
    public static function getRefundGoodsList($orderCode, $uid)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.refund.goodsList';
        $param['order_code'] = $orderCode;
        $param['uid'] = $uid;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }

    /**
     * 可换货商品列表
     * @param $orderCode
     * @param $uid
     * @return mixed
     */
    public static function getChangeGoodsList($orderCode, $uid)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.change.goodsList';
        $param['order_code'] = $orderCode;
        $param['uid'] = $uid;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }


    /**
     * 换货详情
     * @param $uid
     * @param $id
     * @return mixed
     */
    public static function getChangeDetail($uid, $id)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.change.detail';
        $param['uid'] = $uid;
        $param['id'] = $id;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }


    /**
     * 退货详情
     * @param $uid
     * @param $id
     * @return mixed
     */
    public static function getRefundDetail($uid, $id)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.refund.detail';
        $param['uid'] = $uid;
        $param['id'] = $id;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }


    /**
     * 快递公司列表
     * @return mixed
     */
    public static function getExpressCompany()
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.express.getExpressCompany';
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }


    /**
     * 设置快递
     * @param $id
     * @param $expressId
     * @param $expressNumber
     * @param $uid
     * @param $expressCompany
     * @param $isChange
     * @return mixed
     */
    public static function setExpressNumber($id, $expressId, $expressNumber,$uid, $expressCompany, $isChange)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = $isChange ? 'app.change.setexpress' : 'app.refund.setexpress';
        $param['id'] = $id;
        $param['express_id'] = $expressId;
        $param['express_number'] = $expressNumber;
        $param['uid'] = $uid;
        $param['express_company'] = $expressCompany;
        $param['client_secret'] = Sign::getSign($param);
        
        return Yohobuy::post(yohobuy::API_URL, $param);
    }


    /**
     * 可退货商品列表数据
     * @param $orderCode
     * @param $uid
     * @return mixed
     */
    public static function getRefundGoodsData($orderCode, $uid)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.refund.goodsList';
        $param['order_code'] = $orderCode;
        $param['uid'] = $uid;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }


    /**
     * 可换货商品列表数据
     * @param $orderCode
     * @param $uid
     * @return mixed
     */
    public static function getChangeGoodsData($orderCode, $uid)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.change.goodsList';
        $param['order_code'] = $orderCode;
        $param['uid'] = $uid;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }

    /**
     * save退货申请
     * @param $orderCode
     * @param $uid
     * @param $goods
     * @param $payment
     * @return mixed
     */
    public static function refundSubmit($orderCode, $uid, $goods, $payment)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.refund.submit';
        $param['order_code'] = $orderCode;
        $param['uid'] = $uid;
        $param['goods'] = json_encode($goods);
        $param['payment'] = json_encode($payment);
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }

    /**
     * save换货申请
     * @param $orderCode
     * @param $uid
     * @param $goods
     * @param $consigneeName
     * @param $areaCode
     * @param $address
     * @param $mobile
     * @param $zipCode
     * @param $deliveryType
     * @return mixed
     */
    public static function exchangeSubmit($orderCode, $uid, $goods, $consigneeName, $areaCode, $address, $mobile, $zipCode, $deliveryType)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.change.submit';
        $param['order_code'] = $orderCode;
        $param['uid'] = $uid;
        $param['goods'] = json_encode($goods);
        $param['consignee_name'] = $consigneeName;
        $param['area_code'] = $areaCode;
        $param['address'] = $address;
        $param['mobile'] = $mobile;
        $param['zip_code'] = $zipCode;
        $param['delivery_tpye'] = $deliveryType;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }

    /**
     * 获取换货方式
     * @param $uid
     * @param $areaCode
     * @param $gender
     * @param $yhChannel
     * @return mixed
     */
    public static function getDelivery($uid, $areaCode, $gender, $yhChannel)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.change.getDelivery';
        $param['uid'] = $uid;
        $param['area_code'] = $areaCode;
        $param['gender'] = $gender;
        $param['yh_channel'] = $yhChannel;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }


    /**
     * 获取商品信息
     * @param $productSkn
     * @return mixed
     */
    public static function getProductData($productSkn)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.product.data';
        $param['product_skn'] = $productSkn;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post(yohobuy::API_URL, $param);
    }

    /**
     * 获取商品信息(组装批量调接口)
     * @param $productSkn
     * @return string
     */
    public static function getProductDataUrl($productSkn)
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'app.product.data';
        $param['product_skn'] = $productSkn;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
    }

    /**
     * 发送站内信
     *
     * @param int $uid
     * @param string $title
     * @param int $content
     * @param int $type
     * @param string $verify_key
     * @param int $send_uid
     * @param string $call_back
     * @return array
     */
    public static function sendMessage($uid, $title, $content, $type = 1, $verify_key = '', $send_uid = 0, $call_back = '')
    {
        $param = array();
        $param = Yohobuy::param();
        $param['method'] = 'web.inbox.setSingleMessage';
        $param['uid'] = $uid;
        $param['send_uid'] = $send_uid;
        $param['verify_key'] = $verify_key;
        $param['content'] = $content;
        $param['title'] = $title;
        $param['type'] = $type;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::post('http://192.168.102.205:8080/gateway', $param);
    }
}