示例#1
0
 private function getRights()
 {
     $gid = (int) $_COOKIE['gid'];
     $cacheName = "action_code_group_" . $gid;
     /*$cache = memcache_init();
     		//$cache->init ( array ("dir" => SlightPHP::$appDir . "/cache", "depth" => 3 ) );
     		$rs = $cache->get ( $cacheName );
     		if ($cache and $rs) {
     		} else {
     			$rsObj = base_mAPI::get ( 'm_group', $gid );
     			$rs = $rsObj->get ();
     			$cache->set ( $cacheName, $rs );
     		}*/
     $rsObj = base_mAPI::get('m_group', $gid);
     $rs = $rsObj->get();
     $action = unserialize($rs['action_code']);
     $mc = memcache_init();
     $head_title = $mc->get($_SERVER['HTTP_APPVERSION'] . "head_title");
     if (!$head_title) {
         $modelObj = new base_m();
         $rs = $modelObj->_db->selectOne(base_Constant::TABLE_PREFIX . "system", "", "sysname");
         $head_title = $rs['rsystem_name'];
         $mc->set($_SERVER['HTTP_APPVERSION'] . "head_title", $head_title);
     }
     $this->params['head_title'] = $head_title;
     $this->params['menu'] = $action['menu'];
     $this->params['_userid'] = $_COOKIE['admin_id'];
     $this->params['_adminname'] = $_COOKIE['admin_name'];
 }
示例#2
0
 function pagepurchase($inPath)
 {
     $url = $this->getUrlParams($inPath);
     $goods_id = $url['gid'] ? (int) $url['gid'] : (int) $_POST['goods_id'];
     $url['ac'] = $url['ac'] ? $url['ac'] : "add";
     $purchaseObj = new m_purchase((int) $url['id']);
     switch ($url['ac']) {
         case "add":
             $goodsObj = base_mAPI::get("m_goods", $goods_id);
             if ($_POST) {
                 $goods_sn = base_Utils::getStr($_POST['goods_sn']);
                 $rs = $goodsObj->get("goods_sn = '{$goods_sn}'");
                 if (!$rs) {
                     $this->ShowMsg("没有该商品信息");
                 }
                 $data['goods_id'] = $rs['goods_id'];
                 $data['goods_sn'] = $rs['goods_sn'];
                 $data['in_num'] = (double) $_POST['in_num'];
                 $data['in_price'] = (double) $_POST['in_price'];
                 if (!$data['in_num'] or !$data['in_price']) {
                     $this->showMsg("数量和单价不能够为空!");
                 }
                 $data['content'] = base_Utils::getStr($_POST['content']);
                 if ($purchaseObj->create($data)) {
                     $this->ShowMsg("入库成功!", $this->createUrl("/purchase/index"), 2, 1);
                 }
                 $this->ShowMsg("入库出错!原因:" . $purchaseObj->getError());
             }
             if ($url['id']) {
                 $this->params['goods'] = $purchaseObj->get();
             } else {
                 $this->params['goods'] = $goodsObj->get();
             }
             break;
         case "del":
             if ($url['gid']) {
                 if ($purchaseObj->deleteOne($url['gid'])) {
                     $this->ShowMsg("删除成功!", $this->createUrl("/purchase/index"), 2, 1);
                 }
                 $this->ShowMsg("删除出错!原因:" . $purchaseObj->getError());
             }
             break;
     }
     $this->params['ac'] = $url['ac'];
     return $this->render('purchase/purchase.html', $this->params);
 }
示例#3
0
 private function getRights()
 {
     $gid = (int) $_COOKIE['gid'];
     $cacheName = "action_code_group_" . $gid;
     $cache = SCache::getCacheEngine('file');
     $cache->init(array("dir" => SlightPHP::$appDir . "/cache", "depth" => 3));
     $rs = $cache->get($cacheName);
     if ($cache and $rs) {
     } else {
         $rsObj = base_mAPI::get('m_group', $gid);
         $rs = $rsObj->get();
         $cache->set($cacheName, $rs);
     }
     $action = unserialize($rs['action_code']);
     $this->params['head_title'] = base_Constant::DEFAULT_TITLE;
     $this->params['menu'] = $action['menu'];
     $this->params['_userid'] = $_COOKIE['admin_id'];
     $this->params['_adminname'] = $_COOKIE['admin_name'];
 }
示例#4
0
 /**
  * 商品退货
  * @param int $goods_id
  * @param float $num
  * @param int $amount 总退款
  */
 public function backStock($goods_id, $num = 1, $amount)
 {
     if ($goods_id) {
         $rs = $this->select("goods_id = {$goods_id} and isdel=0 and out_num>0", "id,in_num,out_num", "", "order by id desc")->items;
         //后出后进
         if (!$rs) {
             $this->setError(0, "该商品没有出库记录");
             return false;
         }
         foreach ($rs as $v) {
             if ($v['out_num'] >= $num) {
                 $this->update("id={$v['id']}", "out_num=out_num-{$num}");
                 break;
             } else {
                 $this->update("id={$v['id']}", "out_num=0");
                 $num = $num - $v['out_num'];
             }
         }
         $goodsObj = base_mAPI::get("m_goods");
         if ($goodsObj->setStock($goods_id, $amount, 0)) {
             $logObj = base_mAPI::get("m_log");
             $logObj->create($goods_id, "退款商品ID:{$goods_id}数量:{$num}退款总金额:{$amount}", 2);
             return true;
         } else {
             $this->setError(0, "修改商品信息错误" . $goodsObj->getError());
             return false;
         }
     }
     return false;
 }
示例#5
0
 /**
  * 计算用户的积分
  * @param int $mid
  */
 public function setCredit($mid)
 {
     $salesObj = base_mAPI::get("m_sales");
     $credit = (int) $salesObj->getUserConsumption($mid);
     $rs = $this->update("mid={$mid}", "credit=credit+{$credit},lastdateline='{$this->_time}'");
     if ($rs) {
         return true;
     }
     return false;
 }
示例#6
0
 /**
  * 修改库存
  * @param int $goods_id
  * @param float $amount
  * @param int $isadd 1加 0减
  */
 public function setStock($goods_id, $amount = 0, $isadd = 1)
 {
     if (!$goods_id) {
         return false;
     }
     $purchaseObj = base_mAPI::get("m_purchase");
     $stock = $purchaseObj->getStockAmount($goods_id);
     if ($stock) {
         $this->setPkid($goods_id);
         if ($amount > 0) {
             if ($isadd == 1) {
                 $salesamount = $this->getData("salesamount") + $amount;
                 $this->set("salesamount", $salesamount);
             } else {
                 $salesamount = $this->getData("salesamount") - $amount;
                 $this->set("salesamount", $salesamount);
             }
         }
         $this->set("countamount", $stock['countamount']);
         $this->set("stock", $stock['stock']);
         $this->set("lastinymd", date("Y-m-d", $this->_time));
         $this->set("lastindateline", $this->_time);
         if ($this->save()) {
             return true;
         }
     }
     $this->setError(0, "库存异常");
     return false;
 }