作者 王智

修改

... ... @@ -10,10 +10,6 @@ namespace app\api\controller;
use app\common\controller\Api;
define('URL', 'http://v2.api.guanyierp.com/rest/erp_open');
define('APPKEY', '149701');
define('SESSIONKEY', '57a1af5a2c9c4e5990e2859ad47e76f1');
define('SECRET', 'c804b81005504d36a2eb27114ff38ceb');
/**
* 管易云API
... ... @@ -33,41 +29,51 @@ class GuanYiCloud extends Api
$data['method'] = 'gy.erp.shop.get';
$data['page_no'] = '1';
$data['page_size'] = '100';
// $data['code'] = '001';
$data['sign'] = $this->sign($data, SECRET);
$this->success('成功', json_decode($this->mycurl(URL, $data)));
}
// 供应商查询
function getsupplier()
// 会员查询
function getVip()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.supplier.get';
$data['method'] = 'gy.erp.vip.get';
$data['page_no'] = '1';
$data['page_size'] = '10';
// $data['start_date'] = '2015-10-10 09:09:09';
// $data['end_date'] = '2015-12-10 09:09:09';
// $data['code'] = '001';
$data['sign'] = $this->sign($data, SECRET);
$this->success('成功', json_decode($this->mycurl(URL, $data)));
}
// 会员查询
function getVip()
// 会员新增
function addVip()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.vip.get';
$data['page_no'] = '1';
$data['page_size'] = '10';
// $data['start_created'] = '2016-01-01 08:00:00';
// $data['end_created'] = '2016-06-22 08:00:00';
// $data['level_code'] = '02';
// $data['shop_code'] = 'feiniu';
// $data['code'] = '18662591592';
$data['method'] = 'gy.erp.vip.add';
//会员代码
$data['code'] = 'bronettest111';
//会员名称
$data['name'] = '百荣测试会员新增';
//所属店铺
$data['shop_code'] = 'ZCZXCX';
//地址列表
$receive_infos = array();
$receive_infos[] = array(
//名称
'name' => '地址',
//收货人
'receiver' => '收货人',
//收获手机
'mobile' => 13292442918,
//收货详细地址
'address' => '收货详细地址'
);
$data['receive_infos'] = $receive_infos;
$data['sign'] = $this->sign($data, SECRET);
$this->success('成功', json_decode($this->mycurl(URL, $data)));
}
... ... @@ -144,195 +150,6 @@ class GuanYiCloud extends Api
return $Json;
}
//获取发货单
function getDelivery()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.trade.deliverys.get';
$data['page_no'] = '1';
$data['page_size'] = '10';
$data['start_create'] = '2015-10-1 09:06:01';
$data['end_create'] = '2016-1-27 09:06:01';
// $data['deliveryprint_begintime'] = '2015-8-1 09:06:01';
// $data['deliveryprintend_time'] = '2016-1-27 09:06:01';
// $data['start_delivery_date'] = '2015-8-1 09:06:01';
// $data['end_delivery_date'] = '2016-1-27 09:06:01';
// $data['outer_code'] = '110';
// $data['warehouse_code'] = 'ck01';
// $data['shop_code'] = 'cj02';
// $data['delivery'] = '1';
$data['sign'] = $this->sign($data, SECRET);
$this->success('成功', json_decode($this->mycurl(URL, $data)));
}
// 获取库存(新)
function getNewStock()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.new.stock.get';
$data['page_no'] = '1';
$data['page_size'] = '10';
$data['start_date'] = '2015-11-03 16:06:03';
$data['end_date'] = '2015-11-04 10:06:03';
// $data['barcode'] = '6921314113412';
$data['sign'] = $this->sign($data, SECRET);
$this->success('成功', json_decode($this->mycurl(URL, $data)));
}
//新增商品
function addGoods()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.item.add';
$random_code = time(); //获取当前时间戳,以时间戳做商品代码可以防止重复,避免出错,此方式仅为测试
$data['code'] = $random_code;
$data['name'] = '测试商品';
$data['simple_name'] = '测试商品简称';
$data['weight'] = '124.00';
$skus = array();
$skus[] = array(
'sku_code' => $random_code . '011',
'sku_name' => '红色 S',
'sku_sales_price' => '12.00',
'sku_note' => ''
);
$skus[] = array(
'sku_code' => $random_code . '012',
'sku_name' => '红色 M',
'sku_sales_price' => '12.00',
'sku_note' => ''
);
$data['skus'] = $skus;
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
// 商品修改
function updateGoods()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.item.update';
$data['id'] = '11589572901';
$skus = array();
$skus[] = array(
'sku_id' => '11589572902',
'sku_code' => '规格wwwwwwwwwww',
'sku_weight' => '70800',
'sku_purchase_price' => '71',
'sku_sales_price' => '72',
'sku_agent_price' => '72',
'sku_cost_price' => '73',
'sku_package_point' => '7',
'sku_sales_point' => '8',
'sku_note' => 'haha'
);
$data['skus'] = $skus;
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
// 商品删除
function deleteGoods()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.item.delete';
$data['page_no'] = '1';
$data['page_size'] = '10';
// $data['code'] = '001';
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
// 商品规格增加
function addSku()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.item.sku.add';
$data['item_id'] = '17391916228';
$data['code'] = '143330110673603';
$data['name'] = '规格3';
$data['stock_status_code'] = '01';
$data['weight'] = '1000';
$data['sales_point'] = '10';
$data['package_point'] = '11';
$data['purchase_price'] = '10';
$data['sales_price'] = '10';
$data['agent_price'] = '162';
$data['cost_price'] = '163';
$data['note'] = '1.0000';
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
// 商品规格修改
function updateSku()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.item.sku.update';
$data['item_id'] = '17391916228';
// $data['id'] = '17391916228';
// $data['code'] = '143330110673603';
$data['name'] = '规格3';
$data['stock_status_code'] = '01';
$data['weight'] = '1000';
$data['sales_point'] = '10';
$data['package_point'] = '11';
$data['purchase_price'] = '10';
$data['sales_price'] = '10';
$data['agent_price'] = '162';
$data['cost_price'] = '163';
$data['note'] = '1.0000';
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
// 商品规格删除
function deleteSku()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.item.sku.delete';
$data['item_id'] = '17391916228';
$data['id'] = '1739213845111';
// $data['code'] = '143330110673602';
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
// 获取退换货单
function getTradeReturns()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.trade.return.get';
$data['page_no'] = '1';
$data['page_size'] = '10';
$data['code'] = 'WTO4244996172';
$data['warehousein_code'] = '001';
$data['shop_code'] = '111';
// $data['in_begin_time'] = '2015-02-06 00:00:00';
$data['receive'] = '1';
$data['agree'] = '1';
$data['cancel'] = '2';
$data['sign'] = $this->sign($data, SECRET);
$this->success('成功', json_decode($this->mycurl(URL, $data)));
}
//新增订单
function addOrder()
... ... @@ -412,179 +229,10 @@ class GuanYiCloud extends Api
// dump($Array['code']);
}
//新增退货单
function addTradeReturn()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.trade.return.add';
$data['type_code'] = '001';
$data['vip_code'] = 'test';
$data['shop_code'] = '004';
$data['note'] = 'thisistrade_return';
// $data['trade_platform_code'] = '2015100901211341';
$data['trade_code'] = 'SO12386172818';
$item_detail = array();
$item_detail[] = array(
'item_code' => 'TTTT',
// 'sku_code' => '红色 S',
'qty' => 1,
'originPrice' => '21.00',
'price' => '10.00',
'note' => 'good1'
);
$item_detail[] = array(
'item_code' => 'TTTT',
// 'sku_code' => '红色 S',
'qty' => 1,
'originPrice' => '21.00',
'price' => '10.00',
'note' => 'good1'
);
$data['item_detail'] = $item_detail;
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
//入库退货单
function approveTradeReturn()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.trade.return.approve';
$data['code'] = 'RGO6999332255';
$data['warehouse_code'] = 'CK02';
$data['express_code'] = 'STO';
$data['express_no'] = '681989898989';
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
//更新订单退款状态
function updateOrderRefund()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.trade.refund.update';
$data['tid'] = '201510CP15100166';
$data['oid'] = '201510CP15100166201507CG290000074';
$data['refund_state'] = 1;
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
//发货单修改(回写物流信息及订单状态)
function updateDelivery()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.trade.deliverys.update';
$data['code'] = 'SDO11915496068';
$data['express_code'] = 'STO';
$data['mail_no'] = '213141';
$deliverys_state_paramlist = array();
$deliverys_state_paramlist[] = array(
'area_id' => '0',
'operator' => 'test',
'operator_date' => '2015-01-09 11:11:11',
'sku_note' => ''
);
$deliverys_state_paramlist[] = array(
'area_id' => '1',
'operator' => 'test1',
'operator_date' => '2015-01-09 11:11:11',
'sku_note' => ''
);
$data['deliverys_state_paramlist'] = $deliverys_state_paramlist;
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
// 新增退款单
function addTraderefund()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.trade.refund.add';
$data['refund_code'] = '45685456231';// 退款单号
$data['refund_type'] = 0;
$data['trade_code'] = 'SO11931230506';// 銷售订单号
$data['shop_code'] = '2';
$data['payment_type_code'] = 'zhifubao';
$data['amount'] = '100';
$data['note'] = '2015100901211341';
$item_detail = array();
$item_detail[] = array(
'barcode' => '6921314113412',
'qty' => 2,
'price' => '12.00',
'note' => 'good1!@#$%'
);
// $item_detail[] = array(
// 'barcode' => '6921314113412',
// 'qty' => 2,
// 'price' => '12.00',
// 'note' => 'good1!@#$%'
// );
$data['item_detail'] = $item_detail;
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
// 更新订单备注
function updateOrderMemo()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.trade.memo.update';
$data['tid'] = '69456325698984964135';
$data['memo'] = '请配仓:罗湖太宁路,距离:20.62。111';
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
// 获取商品条码
function getItemBarcode()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.item.barcode.get';
$data['page_no'] = '1';
$data['page_size'] = '10';
// $data['barcode'] = '661313146666663348';
// $data['item_code'] = 'gytest001_mary';
// $data['sku_code'] = '22211';
// $data['start_date'] = '2015-08-28 16:30:00';
// $data['end_date'] = '2015-08-28 18:00:00';
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->mycurl(URL, $data);
}
// 新增商品条码
function addItemBarcode()
{
$data = array();
$data['appkey'] = APPKEY;
$data['sessionkey'] = SESSIONKEY;
$data['method'] = 'gy.erp.item.barcode.add';
$data['item_code'] = 'SSSSSSSSS';
$data['sku_code'] = '201512CG140000065';
$data['barcode'] = '185632165adsa';
$data['sign'] = $this->sign($data, SECRET);
echo 'response: ' . $this->$this->mycurl(URL, $data);
}
/*Config*/
function mycurl($url, $data)
{
$data_string = $this->json_encode_ch($data);
// echo 'request: ' . $data_string . "\n";
$data_string = urlencode($data_string);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
... ...
... ... @@ -11,7 +11,6 @@ use think\Validate;
use think\Db;
use EasyWeChat\Foundation\Application;
use think\response;
/**
* 用户接口
*/
... ... @@ -46,8 +45,8 @@ class User extends Api
$options = [
// ...
'mini_program' => [
'app_id' => 'wxf0764538543e66eb',
'secret' => '195607cd34fd72688810735f51582fb1',
'app_id' => appid,
'secret' => secret,
'token' => 'component-token',
'aes_key' => 'component-aes-key'
],
... ... @@ -134,8 +133,8 @@ class User extends Api
// ...
'mini_program' => [
'app_id' => 'wxf0764538543e66eb',
'secret' => '195607cd34fd72688810735f51582fb1',
'app_id' => appid,
'secret' => secret,
'token' => 'component-token',
'aes_key' => 'component-aes-key'
],
... ...
... ... @@ -16,21 +16,21 @@ use think\Route;
use think\Validate;
use EasyWeChat\Foundation\Application;
/*小程序Config*/
define('appid', 'wxf0764538543e66eb');
define('secret', '195607cd34fd72688810735f51582fb1');
/*管易云Api
Config*/
define('URL', 'http://v2.api.guanyierp.com/rest/erp_open');
define('APPKEY', '149701');
define('SESSIONKEY', '57a1af5a2c9c4e5990e2859ad47e76f1');
define('SECRET', 'c804b81005504d36a2eb27114ff38ceb');
/**
* API控制器基类
*/
class Api
{
public function AppId()
{
return 'wxf0764538543e66eb';
}
public function Secret()
{
return '195607cd34fd72688810735f51582fb1';
}
/**
* @var Request Request 实例
*/
... ... @@ -563,8 +563,8 @@ class Api
{
//小程序码
$options = [
'app_id' => $this->AppId(),
'secret' => $this->Secret(),
'app_id' => appid,
'secret' => secret,
];
$app = new Application($options);
// 获取 access token 实例
... ... @@ -594,8 +594,8 @@ class Api
{
//小程序码
$options = [
'app_id' => $this->AppId(),
'secret' => $this->Secret(),
'app_id' => appid,
'secret' => secret,
];
$app = new Application($options);
// 获取 access token 实例
... ...