Exemplo n.º 1
0
 public static function boot()
 {
     parent::boot();
     Deal::deleting(function ($deal) {
         $deal->deleted = 1;
         $deal->update();
     });
 }
Exemplo n.º 2
0
 /**
  * strict singletion
  * for later no paramter call
  *
  * @return self
  */
 static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = call_user_func_array(array('parent', 'getInstance'), func_get_args());
         self::$isInitialized = true;
     }
     return self::$instance;
 }
Exemplo n.º 3
0
 public function __construct()
 {
     parent::__construct();
     $this->option = JRequest::getCmd('option');
     $this->view = JRequest::getCmd('view');
     $this->context = $this->option . '.categories';
     $this->populateState();
 }
Exemplo n.º 4
0
 public static function boot()
 {
     parent::boot();
     RoyaltyShare::deleting(function ($royaltyShare) {
         $royaltyShare->deleted = 1;
         $royaltyShare->update();
     });
 }
Exemplo n.º 5
0
 public static function boot()
 {
     parent::boot();
     RoyaltyProvider::deleting(function ($royaltyProvider) {
         $royaltyProvider->deleted = 1;
         $royaltyProvider->update();
     });
 }
Exemplo n.º 6
0
 public static function boot()
 {
     parent::boot();
     Company::created(function ($company) {
         AuthorizationToken::createAuthorizationToken($company);
         Credit::createCredit($company->id);
         Credit::createCredit($company->id, Credit::PAID);
     });
 }
Exemplo n.º 7
0
 public static function boot()
 {
     parent::boot();
     User::created(function ($user) {
         if ($user->type == User::TYPE_PAYEE) {
             AuthorizationToken::createAuthorizationToken($user);
         }
     });
 }
Exemplo n.º 8
0
 public function __construct()
 {
     parent::__construct();
     $app = JFactory::getApplication();
     $this->option = $app->input->get('option', '', 'CMD');
     $this->view = $app->input->get('view', '', 'CMD');
     $this->context = $this->option . '.categories';
     $this->populateState();
 }
Exemplo n.º 9
0
 public function __construct()
 {
     parent::__construct();
     //vishal - for j3 changes
     $app = JFactory::getApplication();
     $this->option = $app->input->get('option', '', 'CMD');
     $this->view = $app->input->get('view', '', 'CMD');
     //$this->option  = JRequest::getCmd('option');
     //$this->view    = JRequest::getCmd('view');
     $this->context = $this->option . '.categories';
     $this->populateState();
 }
Exemplo n.º 10
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     $id = JRequest::getInt('id', 0);
     if (!$id) {
         $cid = JRequest::getVar('cid', array());
         $id = $cid[0];
     }
     if ($id) {
         $this->setState('id', $id);
     }
 }
Exemplo n.º 11
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     $app = JFactory::getApplication();
     $id = $app->input->get('id', false, 'INT');
     if (!$id) {
         $cid = $app->input->post->get('cid', array(), 'ARRAY');
         $id = @$cid[0];
     }
     if ($id) {
         $this->setState('id', $id);
     }
 }
Exemplo n.º 12
0
 public static function updateApplyApi($newApplyApi = array(), $where = '0')
 {
     $tableName = $this->getTableName();
     $newApplyApi = $this->formatUpdateField($tableName, $newApplyApi);
     if (!$newApplyApi) {
         self::$errMsg = $this->validatemsg;
         return false;
     }
     $updateApplyApi = '';
     foreach ($newApplyApi as $k => $v) {
         $updateApplyApi .= $k . '="' . $v . '",';
     }
     $updateApplyApi = rtrim($updateApplyApi, ',');
     $sql = 'UPDATE `' . C("DB_PREFIX") . 'call_api` SET ' . $updateApplyApi . ' WHERE ' . $where;
     return $this->sql($sql)->update();
 }
Exemplo n.º 13
0
 /**
  * ApiModel::getSkuByPurids($purIds)
  *通过采购id获取sku
  * @return  array
  */
 public static function getSkuByPurids($purIds)
 {
     self::initDB();
     $sql = "SELECT sku FROM pc_goods WHERE purchaseId IN ({$purIds})";
     $query = self::$dbConn->query($sql);
     if ($query) {
         $res = self::$dbConn->fetch_array_all($query);
         if (empty($res)) {
             self::$errMsg = "result empty ---{$sql}";
             return false;
         }
         return $res;
     }
     self::$errMsg = "query error ---{$sql}";
     return false;
 }
Exemplo n.º 14
0
 private function indexAction()
 {
     $startTime = microtime(true);
     $request = $this->getRequest();
     $module = $request->getParam('module');
     $version = $request->getParam('version');
     $method = $request->getParam('method');
     $responseFormat = $request->getParam('responseFormat');
     $param = array();
     $param['request'] = $request->getRequest();
     $param['query'] = $request->getQuery();
     $param['post'] = $request->getPost();
     $param['cookie'] = $request->getCookie();
     $param['input'] = file_get_contents('php://input');
     $api = ApiModel::getInstance($module, $version, $method, $param, $responseFormat);
     $value = null;
     try {
         $value = $api->call();
         $res = $api->getResponse(ApiException::ERROR_OK, 'ok', $value, $startTime);
     } catch (\Exception $exception) {
         $errorLog = ini_get('error_log');
         $logErrors = ini_get('log_errors');
         $displayErrors = ini_get('display_errors');
         $message = $exception->getMessage();
         if ($exception instanceof ApiException) {
             ini_set('log_errors', false);
             ini_set('display_errors', false);
             $value = $exception->getValue();
         } else {
             ini_set('error_log', dirname($errorLog) . '/php_exception.log');
             $url = \Ares333\YafLib\Helper\Http::getUrl('current');
             $exception = new ApiException($url, ApiException::ERROR_SERVER, $exception);
         }
         Error::catchException($exception);
         $res = $api->getResponse($exception->getCode(), $message, $value, $startTime);
         ini_set('error_log', $errorLog);
         ini_set('log_errors', $logErrors);
         ini_set('display_errors', $displayErrors);
     }
     $this->getResponse()->clearHeaders('Content-Type');
     $this->getResponse()->appendBody($res, 'api');
     $this->log();
     return false;
 }
Exemplo n.º 15
0
 function testAction()
 {
     ApiModel::getInstance()->test();
     return false;
 }
Exemplo n.º 16
0
 protected function buildModel($sourcePath, $options)
 {
     $files = CFileHelper::findFiles($sourcePath, $options);
     $model = new ApiModel();
     $model->build($files);
     return $model;
 }
Exemplo n.º 17
0
 /**
  * Returns the attributes
  */
 public function getApiAttributes($names = true)
 {
     $attrs = parent::getAttributes($names);
     unset($attrs['id']);
     return $attrs;
 }
Exemplo n.º 18
0
 public function view_index()
 {
     global $mod, $act;
     session_start();
     $this->smarty->assign('title', '待退回列表');
     $this->smarty->assign('mod', $mod);
     //模块权限
     $this->smarty->assign('web_api', WEB_API);
     //API 接口地址
     $timetype = isset($_GET['timetype']) ? $_GET['timetype'] : '';
     $starttime = isset($_GET['startTime']) ? $_GET['startTime'] : '';
     //,'1354294861');
     $endtime = isset($_GET['endTime']) ? $_GET['endTime'] : '';
     //,'1375290061');
     $sku = isset($_GET['sku']) ? $_GET['sku'] : '';
     $purid = isset($_GET['purid']) ? $_GET['purid'] : '1';
     $status = isset($_GET['status']) ? $_GET['status'] : '';
     $page = isset($_GET['page']) ? $_GET['page'] : '1';
     $condition = ' WHERE 1 ';
     if (!empty($sku)) {
         $condition .= " AND sku = '{$sku}'";
     }
     if ($status !== '') {
         $condition .= " AND returnStatus = '{$status}'";
     }
     if (empty($condition)) {
         $condition = ' AND 1 = 1';
     }
     if ($timetype != 0) {
         if (!empty($starttime) && $endtime >= $starttime) {
             $serstart = strpos($starttime, ':') !== false ? strtotime($starttime) : strtotime($starttime . " 00:00:00");
             $serend = strpos($endtime, ':') !== false ? strtotime($endtime) : strtotime($endtime . " 23:59:59");
             if ($timetype == '1') {
                 $condition .= " AND auditTime BETWEEN " . "'{$serstart}'" . " AND " . "'{$serend}'";
             } else {
                 if ($timetype == '2') {
                     $condition .= " AND startTime BETWEEN " . "'{$serstart}'" . " AND " . "'{$serend}'";
                 } else {
                     if ($timetype == '3') {
                         $condition .= " AND lastModified BETWEEN " . "'{$serstart}'" . " AND " . "'{$serend}'";
                     }
                 }
             }
         }
     }
     if (empty($condition)) {
         $condition = ' AND 1 = 1';
     }
     $qc = new RtnQcDataAct();
     $rtndata = $qc->act_QcData($purid, $condition, $page, 'returngood');
     $data = $rtndata['data'];
     if ($data[1]) {
         $data = $data[1];
         //获取采购id
         $res = commonAct::actGetPurchaseAccess();
         $purid = $res['power_ids'];
         //转换成sku
         $pur_sku = ApiModel::getSkuByPurids($purid);
         $pur_sku_arr = array();
         foreach ($pur_sku as $pur_sku_val) {
             $pur_sku_arr[] = $pur_sku_val['sku'];
         }
         if (!empty($data)) {
             foreach ($data as $key => $val) {
                 if (!in_array($val['sku'], $pur_sku_arr)) {
                     unset($data[$key]);
                     //去除不是自己的sku
                     continue;
                 }
             }
         }
         $perNum = 100;
         $pageArr = pageForArr($data, $perNum);
         $pageStr = $pageArr[1];
         $list = $pageArr[0];
     } else {
         $pageStr = '暂无数据';
     }
     $this->smarty->assign('pageStr', $pageStr);
     //分页输出
     $this->smarty->assign('ser_sku', $sku);
     //选中SKU
     $this->smarty->assign('ser_timetype', $timetype);
     //选中时间类型
     $this->smarty->assign('ser_startTime', $starttime);
     //选中开始时间
     $this->smarty->assign('ser_endTime', $endtime);
     //选中结束时间
     $this->smarty->assign('ser_status', $status);
     //选中状态
     $this->smarty->assign('userid', $_SESSION['userId']);
     //登录用户userid
     $this->smarty->assign('list', $list);
     //循环赋值
     $this->smarty->display('returnGood.htm');
 }
Exemplo n.º 19
0
<?php

require 'ext/Slim/Slim.php';
require 'ApiModel.php';
error_reporting(1);
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->post('/sendPushNotification', function () {
    ApiModel::getInstance()->sendPushNotification();
});
// http://domain.com/registerDevice
$app->post('/registerDevice', function () {
    ApiModel::getInstance()->registerDevice();
});
$app->run();
Exemplo n.º 20
0
 protected function buildModel($sourcePath, $options)
 {
     $files = CFileHelper::findFiles($sourcePath, $options);
     $files[] = $this->root . '/util/XSDataSource.class.php';
     $files[] = $this->root . '/util/XSUtil.class.php';
     $model = new ApiModel();
     $model->build($files);
     return $model;
 }
Exemplo n.º 21
0
 function getCache()
 {
     if (!isset(self::$cache)) {
         $conf = Application::app()->getConfig()->cache->memcached->data;
         $debug = (bool) Application::app()->getConfig()->debug;
         $namespace = \ApiModel::getInstance()->getVersion();
         $namespace .= '.' . $this->getLanguage();
         self::$cache = StorageFactory::factory(array('adapter' => array('name' => 'memcached', 'options' => array('ttl' => 3600, 'namespace' => $namespace, 'servers' => array(array('host' => $conf['host'], 'port' => $conf['port'], 'persistent' => !$debug)))), 'plugins' => array('exception_handler' => array('throw_exceptions' => $debug))));
     }
     return self::$cache;
 }
Exemplo n.º 22
0
 function act_processPurchaseOrder()
 {
     $sku = isset($_GET['sku']) ? trim($_GET['sku']) : '';
     $num = isset($_GET['num']) ? trim($_GET['num']) : '';
     if ($sku == '' || $num == '') {
         self::$errCode = 101;
         self::$errMsg = '参数不合法';
         return false;
     }
     $now_num = $num;
     $purchase_list = self::checkPurchaseSkuIsExist($sku);
     //api拉取采购订单
     BaseModel::begin();
     //开始事务
     $rollback = false;
     if (!empty($purchase_list)) {
         /*** 计算采购成本算法 Start step1 获取原有库存成本***/
         $rtnData = ApiModel::getQtyAndPriceBySku($sku);
         //返回料号未入库的库存及成本单价
         $stockmoney = 0;
         $before_qty = 0;
         $before_price = 0;
         $skumoney = 0;
         $skuqty = 0;
         if (!empty($rtnData)) {
             $before_qty = $rtnData[0]['stock_qty'];
             $before_price = $rtnData[0]['goodsCost'];
             $stockmoney = $before_price * $before_qty;
             //未入库前库存成本
         }
         /*** 计算采购成本算法 End step1 获取原有库存成本***/
         foreach ($purchase_list as $purchase) {
             if ($now_num < 1) {
                 break;
             }
             $orderId = $purchase['id'];
             $sku_id = $purchase['sku_id'];
             $lessnum = $purchase['count'] - $purchase['stockqty'];
             $price = $purchase['price'];
             //采购成本
             $adduserid = $purchase['purchaseuser_id'];
             //采购员编号
             if ($lessnum > 0) {
                 if ($now_num < $lessnum) {
                     $total_num = $purchase['stockqty'] + $now_num;
                     $ret = OmAvailableAct::act_updateTNameRow("ph_order_detail", "SET stockqty = '{$total_num}'", "WHERE po_id = '{$orderId}' AND sku_id = '{$sku_id}'");
                     if ($ret === false) {
                         self::$errCode = 405;
                         self::$errMsg = '更新采购订单料号数量出错!';
                         $rollback = false;
                     } else {
                         $now_num = 0;
                     }
                 } else {
                     $totalCount = $purchase['count'];
                     $reach_time = time();
                     $ret = OmAvailableAct::act_updateTNameRow("ph_order_detail", "SET stockqty = '{$totalCount}', reach_time = '{$reach_time}'", "WHERE po_id = '{$orderId}' AND sku_id = '{$sku_id}'");
                     if ($ret === false) {
                         self::$errCode = 406;
                         self::$errMsg = '更新采购订单料号数量出错!';
                         $rollback = false;
                     } else {
                         $now_num = $now_num - $lessnum;
                         /*** 计算采购成本算法 Start step2 获取订单明细表已到货完成的料号***/
                         $skumoney += $price * $purchase['count'];
                         //采购订单中单个料号的采购总金额
                         $skuqty += $purchase['count'];
                         /*** 计算采购成本算法 End step2 获取订单明细表已到货完成的料号***/
                     }
                 }
                 //检测订单是否完结
                 $otherskus = self::getOrderDetailsById($orderId);
                 $status = true;
                 foreach ($otherskus as $othersku) {
                     if ($othersku['count'] != $othersku['stockqty']) {
                         $status = false;
                         break;
                     }
                 }
                 if ($status) {
                     $ret = OmAvailableAct::act_updateTNameRow("ph_order", "SET status = '4'", "WHERE id = '{$orderId}'");
                     if ($ret === false) {
                         self::$errCode = 407;
                         self::$errMsg = '更新采购订单状态出错!';
                         $rollback = false;
                     }
                 }
             }
         }
         /*** 计算采购成本算法 Start step3 重新计算料号采购成本***/
         $totalmoney = $stockmoney + $skumoney;
         $totalqty = $before_qty + $skuqty;
         $newprice = round($totalmoney / $totalqty, 2);
         //新的料号采购成本
         $rtnApiData = self::updatePcApiPrice($sku, $newprice, $adduserid);
         $errorCode = $rtnApiData['errCode'];
         if ($errCode != 200) {
             $rollback = true;
         }
         if ($rollback == false) {
             BaseModel::commit();
             BaseModel::autoCommit();
         } else {
             BaseModel::rollback();
             BaseModel::autoCommit();
         }
         /*** 计算采购成本算法 End step3 重新计算料号采购成本***/
     }
     return $now_num;
 }
Exemplo n.º 23
0
 public function preDispatch(MvcEvent $event)
 {
     /** @var SessionManager $session */
     $session = $event->getTarget()->getServiceLocator()->get('Zend\\Session\\SessionManager');
     $oldSessionId = $this->getSessionIdFromRequest($event->getRequest());
     if ($oldSessionId) {
         $session->setId($oldSessionId);
     }
     $container = new Container('initialized');
     if ($container->offsetGet('init') === null) {
         $session->regenerateId();
         $container->offsetSet('init', 1);
     }
     $auth = $this->getAuthPlugin();
     $acl = $this->getAcl();
     if ($auth->hasIdentity()) {
         $acl->setUserId($auth->getIdentity());
     }
     /** @var AbstractActionController|SecureControllerInterface $controller */
     $controller = $event->getTarget();
     if ($controller instanceof SecureControllerInterface && !$acl->isAllowed($controller->getPrivileges())) {
         /** @var \Zend\Http\PhpEnvironment\Response $response */
         $response = $controller->getResponse();
         $response->setStatusCode(403);
         $response->setReasonPhrase("Permission denied");
         $model = new ApiModel($response);
         $model->setSessionId($this->getSessionId());
         $event->setViewModel($model);
         $event->stopPropagation(true);
     }
 }