function smarty_function_load_data($params, &$smarty)
{
    (!isset($params['table']) || empty($params['table'])) && exit('`table` is empty!');
    // $Mconfig = include(hopedir."config/hopeconfig.php");
    // print_r($Mconfig);
    $type = isset($params['type']) ? $params['type'] : 'list';
    //total  总数量   one    list 3个分类
    $fileds = isset($params['fileds']) ? $params['fileds'] : '*';
    $where = isset($params['where']) ? $params['where'] : '';
    $where = empty($where) ? '' : ' where ' . $where;
    $orderby = isset($params['orderby']) ? 'order by ' . $params['orderby'] : '';
    $limit = isset($params['limit']) ? 'LIMIT 0,' . $params['limit'] : 'LIMIT 0,1';
    if (!class_exists('mysql_class')) {
        include hopedir . "lib/core/extend/mysql_class.php";
        //core\extend
        $mysql = new mysql_class();
    } else {
        $mysql = new mysql_class();
    }
    $page = intval(IFilter::act(IReq::get('page')));
    $pagesize = intval(IFilter::act(IReq::get('pagesize')));
    $pagesize = isset($params['pagesize']) ? $params['pagesize'] : $pagesize;
    $pagesize = empty($pagesize) ? 10 : $pagesize;
    // $db = $class::factory(array('table' => $params['table']));
    //var_dump($params);
    if (!empty($params['assign'])) {
        //把数据赋值给变量$params['assign'],这样前端就可以使用这个变量了(例如可以结合foreach输出一个列表等)
        //  $smarty->assign($params['assign'], $db->get_block_list(array($params['where']), $params['limit']));
        if ($type == 'total') {
            $result = $mysql->counts("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . "  " . $where . " " . $orderby . " " . $limit . "");
        } elseif ($type == 'one') {
            $result = $mysql->select_one("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . "  " . $where . " " . $orderby . " " . $limit . "");
        } else {
            if (isset($params['showpage']) && $params['showpage'] == true) {
                if (!class_exists('page')) {
                    include hopedir . "lib/core/extend/page.php";
                    //core\extend
                    $pageclass = new page();
                } else {
                    $pageclass = new page();
                }
                $pageclass->setpage($page, $pagesize);
                $result['list'] = $mysql->getarr("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . "  " . $where . "  " . $orderby . "  limit " . $pageclass->startnum() . ", " . $pageclass->getsize() . "");
                $shuliang = $mysql->counts("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . "  " . $where . " ");
                $pageclass->setnum($shuliang);
                if (isset($params['pagetype'])) {
                    $result['pagecontent'] = $pageclass->ajaxbar($params['pagetype']);
                } else {
                    $result['pagecontent'] = $pageclass->getpagebar();
                }
            } else {
                $result['list'] = $mysql->getarr("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . "  " . $where . " " . $orderby . "  " . $limit . "");
            }
        }
        /*
            $result['list'] = array();
             $result['pagecontent'] = ''; */
        $smarty->assign($params['assign'], $result);
    }
}
Esempio n. 2
0
 /**
  * @brief  把cookie的结构转化成为程序所用的数据结构
  * @param  $cartValue 购物车cookie存储结构
  * @return array : [goods]=>array( ['id']=>商品ID , ['data'] => array( [商品ID]=>array ([name]商品名称 , [list_img]图片地址 , [sell_price]价格, [count]购物车中此商品的数量 ,[type]类型goods,product , [goods_id]商品ID值 ) ) ) , [product]=>array( 同上 ) , [count]购物车商品和货品数量 , [sum]商品和货品总额 ;
  */
 private function cartFormat($cartValue)
 {
     //初始化结果
     $result = $this->cartExeStruct;
     $goodsIdArray = array();
     if (isset($cartValue['goods']) && $cartValue['goods']) {
         $goodsIdArray = array_keys($cartValue['goods']);
         $result['goods']['id'] = $goodsIdArray;
         foreach ($goodsIdArray as $gid) {
             $result['goods']['data'][$gid] = array('id' => $gid, 'type' => 'goods', 'goods_id' => $gid, 'count' => $cartValue['goods'][$gid]);
             //购物车中的种类数量累加
             $result['count'] += $cartValue['goods'][$gid];
         }
     }
     if ($goodsIdArray) {
         $goodsArray = array();
         $mysql = new mysql_class();
         $goodsData = $mysql->getarr("select id,name,count as shuliang,cost,img,shopid,sellcount  from " . Mysite::$app->config['tablepre'] . "goods where id in (" . join(",", $goodsIdArray) . ")  order by shopid asc  ");
         foreach ($goodsData as $goodsVal) {
             $goodsArray[$goodsVal['id']] = $goodsVal;
         }
         $tempshopids = array();
         foreach ($result['goods']['data'] as $key => $val) {
             $result['goods']['data'][$key]['img'] = $goodsArray[$val['goods_id']]['img'];
             $result['goods']['data'][$key]['name'] = $goodsArray[$val['goods_id']]['name'];
             $result['goods']['data'][$key]['cost'] = $goodsArray[$val['goods_id']]['cost'];
             $result['goods']['data'][$key]['shopid'] = $goodsArray[$val['goods_id']]['shopid'];
             $result['goods']['data'][$key]['store_num'] = $goodsArray[$val['goods_id']]['shuliang'];
             $result['goods']['data'][$key]['sellcount'] = $goodsArray[$val['goods_id']]['sellcount'];
             //购物车中的金额累加
             $tempshopids[] = $goodsArray[$val['goods_id']]['shopid'];
             $result['sum'] += $goodsArray[$val['goods_id']]['cost'] * $val['count'];
         }
         $result['shopids'] = array_unique($tempshopids);
         $result['shopinfo'] = $mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "shopfast as a left join " . Mysite::$app->config['tablepre'] . "shop as b  on a.shopid = b.id where id in (" . join(",", $result['shopids']) . ")  ");
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * @brief  把cookie的结构转化成为程序所用的数据结构
  * @param  $cartValue 购物车cookie存储结构
  * @return array : [goods]=>array( ['id']=>商品ID , ['data'] => array( [商品ID]=>array ([name]商品名称 , [list_img]图片地址 , [sell_price]价格, [count]购物车中此商品的数量 ,[type]类型goods,product , [goods_id]商品ID值 ) ) ) , [product]=>array( 同上 ) , [count]购物车商品和货品数量 , [sum]商品和货品总额 ;
  */
 private function cartFormat($cartValue)
 {
     //初始化结果
     $result = $this->cartExeStruct;
     $goodsIdArray = array();
     $marketIdArray = array();
     if (isset($cartValue['goods']) && $cartValue['goods']) {
         $goodsIdArray = array_keys($cartValue['goods']);
         $result['goods']['id'] = $goodsIdArray;
         foreach ($goodsIdArray as $gid) {
             $result['goods']['data'][$gid] = array('id' => $gid, 'type' => 'goods', 'goods_id' => $gid, 'count' => $cartValue['goods'][$gid]);
             //购物车中的种类数量累加
             $result['count'] += $cartValue['goods'][$gid];
         }
     }
     if (isset($cartValue['market']) && $cartValue['market']) {
         $marketIdArray = array_keys($cartValue['market']);
         $result['market']['id'] = $marketIdArray;
         foreach ($marketIdArray as $gid) {
             $result['market']['data'][$gid] = array('id' => $gid, 'type' => 'market', 'goods_id' => $gid, 'count' => $cartValue['market'][$gid]);
             //购物车中的种类数量累加
             $result['count'] += $cartValue['market'][$gid];
         }
     }
     $mysql = new mysql_class();
     if ($marketIdArray) {
         $marketArray = array();
         $marketData = $mysql->getarr("select id,name,count as shuliang,cost,img,shopid,sellcount from " . Mysite::$app->config['tablepre'] . "goods where id in (" . join(",", $marketIdArray) . ")  order by id asc  ");
         foreach ($marketData as $goodsVal) {
             $marketArray[$goodsVal['id']] = $goodsVal;
         }
         $tempshopids = array();
         foreach ($result['market']['data'] as $key => $val) {
             $result['market']['data'][$key]['img'] = $marketArray[$val['goods_id']]['img'];
             $result['market']['data'][$key]['name'] = $marketArray[$val['goods_id']]['name'];
             $result['market']['data'][$key]['cost'] = $marketArray[$val['goods_id']]['cost'];
             $result['market']['data'][$key]['shopid'] = $marketArray[$val['goods_id']]['shopid'];
             $result['market']['data'][$key]['store_num'] = $marketArray[$val['goods_id']]['shuliang'];
             $result['market']['data'][$key]['sellcount'] = $marketArray[$val['goods_id']]['sellcount'];
             $result['market']['shopdata'][$marketArray[$val['goods_id']]['shopid']]['list'][] = $key;
             $sumdo = $marketArray[$val['goods_id']]['cost'] * $val['count'];
             $shopid = $marketArray[$val['goods_id']]['shopid'];
             if (!isset($result['goods']['shopdata'][$shopid]['shopinfo'])) {
                 $result['market']['shopdata'][$shopid]['shopinfo'] = $mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where id= '" . $shopid . "' ");
             }
             $result['market']['shopdata'][$shopid]['sum'] = isset($result['market']['shopdata'][$shopid]['sum']) ? $result['market']['shopdata'][$shopid]['sum'] + $sumdo : $sumdo;
             $result['market']['shopdata'][$shopid]['sumcount'] = isset($result['market']['shopdata'][$shopid]['sumcount']) ? $result['market']['shopdata'][$shopid]['sumcount'] + $val['count'] : $val['count'];
             //购物车中的金额累加
             $tempshopids[] = $marketArray[$val['goods_id']]['shopid'];
             //echo '商品ID:'.$shopid;
             $result['sum'] += $sumdo;
         }
         $result['marketshopids'] = array_unique($tempshopids);
     }
     if ($goodsIdArray) {
         $goodsArray = array();
         $goodsData = $mysql->getarr("select id,name,count as shuliang,cost,img,shopid,sellcount  from " . Mysite::$app->config['tablepre'] . "goods where id in (" . join(",", $goodsIdArray) . ")  order by shopid asc  ");
         foreach ($goodsData as $goodsVal) {
             $goodsArray[$goodsVal['id']] = $goodsVal;
         }
         $tempshopids = array();
         foreach ($result['goods']['data'] as $key => $val) {
             $result['goods']['data'][$key]['img'] = $goodsArray[$val['goods_id']]['img'];
             $result['goods']['data'][$key]['name'] = $goodsArray[$val['goods_id']]['name'];
             $result['goods']['data'][$key]['cost'] = $goodsArray[$val['goods_id']]['cost'];
             $result['goods']['data'][$key]['shopid'] = $goodsArray[$val['goods_id']]['shopid'];
             $result['goods']['data'][$key]['store_num'] = $goodsArray[$val['goods_id']]['shuliang'];
             $result['goods']['data'][$key]['sellcount'] = $goodsArray[$val['goods_id']]['sellcount'];
             $result['goods']['shopdata'][$goodsArray[$val['goods_id']]['shopid']]['list'][] = $key;
             $sumdo = $goodsArray[$val['goods_id']]['cost'] * $val['count'];
             $shopid = $goodsArray[$val['goods_id']]['shopid'];
             if (!isset($result['goods']['shopdata'][$shopid]['shopinfo'])) {
                 if ($shopid == 0) {
                     $result['goods']['shopdata'][$shopid]['shopinfo'] = $mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where id= '" . Mysite::$app->config['marketid'] . "' ");
                     $result['goods']['shopdata'][$shopid]['shopinfo']['shopname'] = '商城商品';
                 } else {
                     $result['goods']['shopdata'][$shopid]['shopinfo'] = $mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where id= '" . $shopid . "' ");
                 }
             }
             $result['goods']['shopdata'][$shopid]['sum'] = isset($result['goods']['shopdata'][$shopid]['sum']) ? $result['goods']['shopdata'][$shopid]['sum'] + $sumdo : $sumdo;
             $result['goods']['shopdata'][$shopid]['sumcount'] = isset($result['goods']['shopdata'][$shopid]['sumcount']) ? $result['goods']['shopdata'][$shopid]['sumcount'] + $val['count'] : $val['count'];
             //购物车中的金额累加
             $tempshopids[] = $goodsArray[$val['goods_id']]['shopid'];
             $result['sum'] += $sumdo;
         }
         $result['shopids'] = array_unique($tempshopids);
         //$result['shopinfo'] = $mysql->select_one("select * from ".Mysite::$app->config['tablepre']."shop where id in (".join(",",$result['shopids']).")  ");
     }
     return $result;
 }
Esempio n. 4
0
 /**
  * @brief  把cookie的结构转化成为程序所用的数据结构
  * @param  $cartValue 购物车cookie存储结构
  * @return array : [goods]=>array( ['id']=>商品ID , ['data'] => array( [商品ID]=>array ([name]商品名称 , [list_img]图片地址 , [sell_price]价格, [count]购物车中此商品的数量 ,[type]类型goods,product , [goods_id]商品ID值 ) ) ) , [product]=>array( 同上 ) , [count]购物车商品和货品数量 , [sum]商品和货品总额 ;
  */
 private function cartFormat($cartValue)
 {
     //初始化结果
     $result = $this->cartExeStruct;
     $mysql = new mysql_class();
     $goodsIdArray = array();
     $backdata = $result;
     if (count($cartValue) > 0) {
         $ids = array_keys($cartValue);
         $ids = join(',', $ids);
         $shopinfo = array();
         if (!empty($ids)) {
             $shoplist = $mysql->getarr("select id,shopname,shoplogo,shortname,shoptype from " . Mysite::$app->config['tablepre'] . "shop   where id in (" . $ids . ")  ");
             foreach ($shoplist as $key => $value) {
                 $shopinfo[$value['id']] = $value;
             }
         }
         foreach ($cartValue as $key => $value) {
             if ($key == 0) {
                 $backdata['list'][$key]['shopinfo'] = array('id' => 0, 'shopname' => '商城');
             } else {
                 $backdata['list'][$key]['shopinfo'] = $shopinfo[$key];
             }
             foreach ($value as $k => $v) {
                 $backdata['list'][$key]['data'][$k]['count'] = $v;
                 $backdata['list'][$key]['data'][$k]['id'] = $k;
                 $backdata['list'][$key]['count'] = 0;
                 $backdata['list'][$key]['sum'] = 0;
                 $backdata['list'][$key]['bagcost'] = 0;
                 $goodsIdArray[] = $k;
                 $backdata['count'] += $v;
             }
         }
     }
     if ($goodsIdArray) {
         $goodsArray = array();
         $goodsData = $mysql->getarr("select id,name,count as shuliang,cost,img,shopid,sellcount,bagcost,typeid,daycount  from " . Mysite::$app->config['tablepre'] . "goods where id in (" . join(",", $goodsIdArray) . ")  order by shopid asc  ");
         foreach ($goodsData as $goodsVal) {
             $goodsArray[$goodsVal['id']] = $goodsVal;
         }
         $tempshopids = array();
         foreach ($goodsData as $key => $val) {
             $backdata['list'][$val['shopid']]['data'][$val['id']]['img'] = $val['img'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['name'] = $val['name'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['cost'] = $val['cost'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['shopid'] = $val['shopid'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['store_num'] = $val['shuliang'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['sellcount'] = $val['sellcount'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['daycount'] = $val['daycount'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['bagcost'] = $val['bagcost'];
             $backdata['list'][$val['shopid']]['data'][$val['id']]['typeid'] = $val['typeid'];
             $backdata['list'][$val['shopid']]['sum'] += $val['cost'] * $backdata['list'][$val['shopid']]['data'][$val['id']]['count'];
             $backdata['list'][$val['shopid']]['count'] += $backdata['list'][$val['shopid']]['data'][$val['id']]['count'];
             $backdata['list'][$val['shopid']]['bagcost'] += $backdata['list'][$val['shopid']]['data'][$val['id']]['count'] * $val['bagcost'];
             $backdata['sum'] += $val['cost'] * $backdata['list'][$val['shopid']]['data'][$val['id']]['count'];
         }
     }
     return $backdata;
 }
Esempio n. 5
0
    } else {
        echo 'sign wrong';
    }
} else {
    //usr
    if (isset($Printer->params['usr']) && !empty($Printer->params['usr'])) {
        $nowtime = strtotime(date('Y-m-d', time()));
        //当天最小时间
        $maxtime = strtotime(date('Y-m-d', time()) . ' 23:59:59');
        $shopinfo = $mysql->select_one("select id,uid  from " . $Mconfig['tablepre'] . "shop  where  IMEI = '" . $Printer->params['usr'] . "'");
        if (!empty($shopinfo)) {
            //当店铺不为空时
            //获取订单
            $orderlist = $mysql->select_one("select *  from " . $Mconfig['tablepre'] . "order   where  shopid = '" . $shopinfo['id'] . "' and status > 0 and status < 3 and is_print = 0 and posttime > " . $nowtime . " and posttime < " . $maxtime . "");
            if (!empty($orderlist)) {
                $orderdet = $mysql->getarr("select *  from " . $Mconfig['tablepre'] . "orderdet where order_id = " . $orderlist['id'] . "");
                $contents = '订单编码:' . $orderlist['dno'] . '%%';
                $contents .= '下单时间:' . date('Y-m-d H:i:s', $orderlist['addtime']) . '%%配送时间:' . date('Y-m-d H:i:s', $orderlist['posttime']) . '%%';
                $contents .= '下单人:' . $orderlist['buyername'] . '%%电话:' . $orderlist['buyerphone'] . '' . '%%';
                $contents .= '下单地址:' . $orderlist['buyeraddress'] . '%%';
                if (!empty($orderlist['content'])) {
                    $contents .= '订单备注:' . $orderlist['content'] . '%%';
                }
                $paycontent = $orderlist['paystatus'] == 0 ? '未支付' : '已支付';
                $contents .= '订单总价' . $orderlist['allcost'] . '元,' . $paycontent . '%%';
                foreach ($orderdet as $key => $value) {
                    $contents .= $value['goodsname'] . '(' . $value['goodscount'] . '份)%%';
                }
                // print_r($contents);
                //contents
                $contents = mb_convert_encoding($contents, 'GB2312', 'UTF-8');