管易云PHP SDK。
使用 Composer
composer require lyhiving/guanyierp
或直接在composer.json 添加
{
"require": {
"lyhiving/guanyierp": "1.*"
}
}
请通过 后台->控制面板->应用授权->云ERP授权 获取对应。
use lyhiving\guanyierp\guanyierp;
$config = [
'appkey' => '[APPKEY]',
'secret' => '[SECRET]',
'sessionkey' => '[SESSIONKEY]'
];
$erp = new guanyierp($config);
//获取方法,具体看接口文档
$method='gy.erp.shop.get';
$data =[];
$filed ='shops';
$result = $erp->getTo($method, $data, $filed);
$error = $erp->error(); //出错信息,为否时表示无出错
$errno = $erp->error(true); //出错代号
$total = $erp->total; //条目总数,一般出现在请求列表
$orgi = $this->get('orgi'); //原始的返回内容
方法:gy.erp.shop.get
$data=[];
$data['page_no'] = '1';
$data['page_size'] = '10';
$result = $erp->getShop($data);
方法:gy.erp.supplier.get
里面提到的返回字段supplier是错的,实际上是supplier_list。
$data=[];
$data['page_no'] = '1';
$data['page_size'] = '10';
$result = $erp->getShop($data);
方法:gy.erp.vip.get
里面提到的返回字段vip是错的,实际上是vips。有见及此,使用本Class应该尽量通过getTo的方法进行
$data=[];
$data['page_no'] = '1';
$data['page_size'] = '10';
$result = $erp->getShop($data);
方法:gy.erp.new.stock.get
$data=[];
$data['page_no'] = 1;
$data['page_size'] = 1;
$data['item_code'] = 201495;
$data['warehouse_code'] = 110;
$result = $erp->getStock($data);
$result = $erp->getItemStock(201495,110);
方法:gy.erp.stock.count.add
$note = 'Test setItemStock for demo test';
$warehouse_code = 110;
$item_code = 201495;
$qry = 68;
$result = $erp->setItemStock($warehouse_code, $item_code, $qry, $note);
如果需要一次设置多个商品库存,直接将$item_code 换成数组。如:
$note = 'Test setItemStock for demo test';
$warehouse_code = 110;
$items = [
[
'item_code' => 201497,
'qty' => 12
],
[
'item_code' => 201491,
'qty' => 33
]
];
$result = $erp->setItemStock($warehouse_code, $items, null, 'Test setItemStock for batch test');