<?php
namespace eapie\source\request;
use eapie\main;
use eapie\error;
class shop extends main {
const AUTHORITY_GOODS_ADMINISTRATOR = "shop_goods_administrator" const AUTHORITY_ORDER_ADMINISTRATOR = 'shop_order_administrator';
const AUTHORITY_GOODS_READ = "shop_goods_read";
const AUTHORITY_GOODS_ADD = "shop_goods_add";
const AUTHORITY_GOODS_EDIT = "shop_goods_edit";
const AUTHORITY_GOODS_TRASH = "shop_goods_trash" const AUTHORITY_GOODS_TRASH_READ = "shop_goods_trash_read" const AUTHORITY_GOODS_TRASH_RESTORE = "shop_goods_trash_restore"
const AUTHORITY_GOODS_REMOVE = "shop_goods_remove"
const AUTHORITY_GOODS_TYPE_EDIT = "shop_goods_type_edit"
const AUTHORITY_GOODS_SPU_ADD = "shop_goods_spu_add" const AUTHORITY_GOODS_SPU_EDIT = "shop_goods_spu_edit" const AUTHORITY_GOODS_SPU_REMOVE = "shop_goods_spu_remove"
const AUTHORITY_GOODS_SKU_ADD = "shop_goods_sku_add" const AUTHORITY_GOODS_SKU_EDIT = "shop_goods_sku_edit" const AUTHORITY_GOODS_SKU_REMOVE = "shop_goods_sku_remove"
const AUTHORITY_GOODS_IMAGE_UPLOAD = "shop_goods_image_upload" const AUTHORITY_GOODS_IMAGE_REMOVE = "shop_goods_image_remove" const AUTHORITY_GOODS_IMAGE_EDIT = "shop_goods_image_edit"
const AUTHORITY_GOODS_FILE_UPLOAD = "shop_goods_file_upload" const AUTHORITY_GOODS_FILE_REMOVE = "shop_goods_file_remove" const AUTHORITY_GOODS_FILE_EDIT = "shop_goods_file_edit"
const AUTHORITY_GOODS_WHEN_READ = "shop_goods_when_read";
const AUTHORITY_GOODS_WHEN_ADD = "shop_goods_when_add";
const AUTHORITY_GOODS_WHEN_EDIT = "shop_goods_when_edit";
const AUTHORITY_GOODS_WHEN_REMOVE = "shop_goods_when_remove"
const AUTHORITY_GOODS_GROUP_READ = 'shop_goods_group_read';
const AUTHORITY_GOODS_GROUP_ADD = 'shop_goods_group_add';
const AUTHORITY_GOODS_GROUP_EDIT = 'shop_goods_group_edit';
const AUTHORITY_GOODS_GROUP_REMOVE = 'shop_goods_group_remove';
const AUTHORITY_GOODS_REGION_READ = "shop_goods_region_read";
const AUTHORITY_GOODS_REGION_ADD = "shop_goods_region_add";
const AUTHORITY_GOODS_REGION_EDIT = "shop_goods_region_edit";
const AUTHORITY_GOODS_REGION_REMOVE = "shop_goods_region_remove"
const AUTHORITY_ORDER_READ = "shop_order_read" const AUTHORITY_ORDER_DETAILS_READ = "shop_order_details_read" const AUTHORITY_ORDER_TRASH_READ = "shop_order_trash_read" const AUTHORITY_ORDER_TRASH = "shop_order_trash" const AUTHORITY_ORDER_TRASH_RESTORE = "shop_order_trash_restore" const AUTHORITY_ORDER_AUDIT = "shop_order_goods_state"; const AUTHORITY_ORDER_WRITE_OFF = 'shop_order_write_off'
const AUTHORITY_ORDER_GROUP_READ = 'shop_order_group_read';
const AUTHORITY_ORDER_GROUP_EDIT = 'shop_order_group_edit';
const AUTHORITY_ORDER_SHIPPING = "shop_order_shipping" const AUTHORITY_ORDER_STATE = "shop_order_state"
const AUTHORITY_CONFIG_READ = 'shop_config_read';
const AUTHORITY_CONFIG_EDIT = 'shop_config_edit';
const AUTHORITY_GROUP_GOODS_READ = "shop_group_goods_read";
const AUTHORITY_GROUP_GOODS_ADD = "shop_group_goods_add";
const AUTHORITY_GROUP_GOODS_EDIT = "shop_group_goods_edit";
const AUTHORITY_GROUP_GOODS_REMOVE = "shop_group_goods_remove";
const AUTHORITY_SHOP_READ = "shop_read" const AUTHORITY_SHOP_EDIT = "shop_edit" const AUTHORITY_SHOP_REMOVE = "shop_remove" const AUTHORITY_SHOP_ADD = "shop_add"
const AUTHORITY_SHOP_GOODS_STOCK_LOG_READ = "shop_goods_stock_log_read"
public function event_order_found($order_id){
$application = object(parent::MAIN)->api_application();
$parse_url = http(function($http){
return $http['parse_url'];
});
$parse_url['path'] = '/index.php';
$parse_url['data'] = array(
'data'=> array(
array('SHOPEVENTORDERFOUND', array($order_id) )
),
'application' => $application["application_id"],
'temp' => 1
);
$http_async = object(parent::PLUGIN_HTTP_SOCKET)->async_post($parse_url);
if( !empty($http_async['errno']) ){
return $http_async;
}
}
public function event_order_shipping_send($order_id){
$application = object(parent::MAIN)->api_application();
$parse_url = http(function($http){
return $http['parse_url'];
});
$parse_url['path'] = '/index.php';
$parse_url['data'] = array(
'data'=> array(
array('SHOPEVENTORDERSHIPPINGSEND', array($order_id) )
),
'application' => $application["application_id"],
'temp' => 1
);
$http_async = object(parent::PLUGIN_HTTP_SOCKET)->async_post($parse_url);
if( !empty($http_async['errno']) ){
return $http_async;
}
}
public function event_order_shipping_take($order_id){
$application = object(parent::MAIN)->api_application();
$parse_url = http(function($http){
return $http['parse_url'];
});
$parse_url['path'] = '/index.php';
$parse_url['data'] = array(
'data'=> array(
array('SHOPEVENTORDERSHIPPINGTAKE', array($order_id) )
),
'application' => $application["application_id"],
'temp' => 1
);
$http_async = object(parent::PLUGIN_HTTP_SOCKET)->async_post($parse_url);
if( !empty($http_async['errno']) ){
return $http_async;
}
}
public function event_order_payment_complete($order_id){
$application = object(parent::MAIN)->api_application();
$parse_url = http(function($http){
return $http['parse_url'];
});
$parse_url['path'] = '/index.php';
$parse_url['data'] = array(
'data'=> array(
array('SHOPEVENTORDERPAYMENTCOMPLETE', array($order_id) )
),
'application' => $application["application_id"],
'temp' => 1
);
$http_async = object(parent::PLUGIN_HTTP_SOCKET)->async_post($parse_url);
if( !empty($http_async['errno']) ){
return $http_async;
}
}
public function event_order_payment_moiety($order_id){
$application = object(parent::MAIN)->api_application();
$parse_url = http(function($http){
return $http['parse_url'];
});
$parse_url['path'] = '/index.php';
$parse_url['data'] = array(
'data'=> array(
array('SHOPEVENTORDERPAYMENTMOIETY', array($order_id) )
),
'application' => $application["application_id"],
'temp' => 1
);
$http_async = object(parent::PLUGIN_HTTP_SOCKET)->async_post($parse_url);
if( !empty($http_async['errno']) ){
return $http_async;
}
}
public function event_order_group_refund(){
$application = object(parent::MAIN)->api_application();
$parse_url = http(function($http){
return $http['parse_url'];
});
$parse_url['path'] = '/index.php';
$parse_url['data'] = array(
'data'=> array(
array('SHOPEVENTORDERGROUPREFUND')
),
'application' => $application["application_id"],
'temp' => 1
);
$http_async = object(parent::PLUGIN_HTTP_SOCKET)->async_post($parse_url);
if( !empty($http_async['errno']) ){
return $http_async;
}
}
protected function check_identity()
{
object(parent::REQUEST_USER)->check();
$user_id = $_SESSION['user_id'];
$merchant_user = object(parent::TABLE_MERCHANT_USER)->find_where(array(array('user_id = [+]', $user_id)));
if (empty($merchant_user)) {
throw new error('不是商家用户');
}
if ($merchant_user['merchant_user_state'] == 0) {
throw new error('已封禁');
}
return $merchant_user['merchant_id'];
}
}