🔓 Ultimate Webshell - Penetration Testing Tool

📖 File Reader

<?php
namespace app\common;
use app\BaseController;
use app\api\common\Common_config;
use think\facade\Db;
use think\facade\View;
/**
 * Class Common_yinbao  银豹收银接口处理
 * Api接口:http://www.pospal.cn/openplatform/productorderapi.html
 */
class Common_yinbao extends BaseController
{
    protected $appid = '';
    protected $appkey = '';
    protected function initialize()
    {
        $config = Common_config::config("'yinbao_appid','yinbao_appkey'");
        $this->appid = $config["yinbao_appid"];
        $this->appkey = $config["yinbao_appkey"];
    }

    /**
     * 获取产品详情页
     * @param string $goods_number 产品编号
     */
    public function goods_info($goods_number='')
    {
        $data = [
            "appId"=> $this->appid,
            'barcode'=>$goods_number,
        ];
        $jsonData = json_encode($data);
        $signature = strtoupper(md5($this->appkey . $jsonData));
        $mill_time = $this->getCurrentMilis();//时间毫秒
        $headerArray = array(
            "User-Agent: openApi;",
            "Content-Type: application/json; charset=utf-8",
            //"accept-encoding: gzip,deflate",
            "time-stamp: ".$mill_time.";",
            "data-signature:".$signature
        );
        $url = 'https://area64-win.pospal.cn:443/pospal-api2/openapi/v1/productOpenApi/queryProductByBarcode';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
        curl_setopt($ch, CURLOPT_POST, 1);
        $output = curl_exec($ch);
        curl_close($ch);
        $res = json_decode($output, true);
        return $res;
    }

    /**
     * 更新产品信息
     * @param array $goods_info 产品详情
     * @param int $stock 库存数量
     */
    public function goods_update($goods_info=[],$stock=0)
    {
        $data = [
            "appId"=> $this->appid,
            'productInfo'=>[
                'uid'=>$goods_info["uid"],
                'stock'=>$stock,
            ],
        ];
        $jsonData = json_encode($data);
        $signature = strtoupper(md5($this->appkey . $jsonData));
        $mill_time = $this->getCurrentMilis();//时间毫秒
        $headerArray = array(
            "User-Agent: openApi;",
            "Content-Type: application/json; charset=utf-8",
            //"accept-encoding: gzip,deflate",
            "time-stamp: ".$mill_time.";",
            "data-signature:".$signature
        );
        $url = 'https://area64-win.pospal.cn:443/pospal-api2/openapi/v1/productOpenApi/updateProductInfo';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
        curl_setopt($ch, CURLOPT_POST, 1);
        $output = curl_exec($ch);
        curl_close($ch);
        $res = json_decode($output, true);
        return $res;
    }

    /*获取毫秒时间*/
    public function getCurrentMilis()
    {
        $mill_time = microtime();
        $timeInfo = explode(' ', $mill_time);
        $milis_time = sprintf('%d%03d', $timeInfo[1], $timeInfo[0] * 1000);
        return $milis_time;
    }
}