예제 #1
0
 /**
  * 读取VBA配置
  */
 public function doGetConfig(ZOL_Request $input, ZOL_Response $output)
 {
     $dbName = $input->get('db');
     $tblName = $input->get('tbl');
     $data = Helper_Dao::getOne(array('dbName' => 'Db_UserData', 'tblName' => 'vba_config', 'cols' => 'content', 'whereSql' => ' and dbName="' . $dbName . '" and tableName="' . $tblName . '"'));
     echo mb_convert_encoding($data, "UTF-8", "GBK");
     exit;
 }
예제 #2
0
 public function doGetMemberOtherPro(ZOL_Request $input, ZOL_Response $output)
 {
     $phone = $input->get('phone');
     $phonecard = $input->get('phonecard');
     if ((!$phone || !is_numeric($phone)) && (!$phonecard || !is_numeric($phonecard))) {
         echo "{}";
         exit;
     }
     $list = Helper_Member::getOtherPros(array('phone' => $phone, 'phoneOrCardno' => $phonecard));
     if ($list) {
         echo api_json_encode($list);
     } else {
         echo "{}";
     }
     exit;
 }
예제 #3
0
 /**
  * 根据电话号码获得产品信息
  */
 public function doGetProductByCode(ZOL_Request $input, ZOL_Response $output)
 {
     $code = $input->get('code');
     $fromScore = (int) $input->get('fromScore');
     if (!$code) {
         echo "{}";
         exit;
     }
     $proList = Helper_Product::getProductList(array('code' => $code, 'num' => 30, 'canByScore' => $fromScore));
     if ($proList) {
         //完善产品的分类信息
         $catePairs = Helper_Product::getProductCatePairs();
         foreach ($proList as $k => $p) {
             $proList[$k]['cateName'] = $catePairs[$p["cateId"]];
         }
         $data = array('num' => count($proList), 'data' => $proList);
         echo api_json_encode($data);
     } else {
         echo "{}";
     }
     exit;
 }
예제 #4
0
 /**
  * 获得数据列表
  */
 public function doDefault(ZOL_Request $input, ZOL_Response $output)
 {
     $wArr = array();
     #搜索字段
     $whereSql = "";
     $page = (int) $input->get('page') < 1 ? 1 : (int) $input->get('page');
     $output->sername = $wArr['name'] = $input->get('name');
     $output->sercode = $wArr['code'] = $input->get('code');
     $output->sercateId = $wArr['cateId'] = $input->get('cateId');
     if (!empty($wArr)) {
         foreach ($wArr as $k => $v) {
             if (gettype($v) == 'string') {
                 $whereSql .= !empty($v) ? ' AND ' . $k . ' like binary "%' . $v . '%" ' : '';
             } else {
                 $whereSql .= !empty($v) ? ' AND ' . $k . '=' . $v : '';
             }
         }
     }
     $pageUrl = "?c={$output->ctlName}&a={$output->actName}&page={$page}&name={$wArr['name']}&code={$wArr['code']}&cateId={$wArr['cateId']}";
     $pageSize = 30;
     $orderSql = "order by id desc";
     $data = Helper_Dao::getList(array('dbName' => "Db_Andyou", 'tblName' => "product", 'cols' => "*", 'pageSize' => $pageSize, 'page' => $page, 'pageUrl' => $pageUrl, 'whereSql' => $whereSql, 'orderSql' => $orderSql, 'iswrite' => true, 'pageTpl' => 9));
     //获得符合条件的库存总量
     $db = Db_Andyou::instance();
     $sql = "select sum(stock) sumstock,sum(stock*price) sumprice from product where ctype = 1 {$whereSql}";
     $tmp = $db->getRow($sql);
     $output->sumstock = $tmp["sumstock"];
     $output->sumprice = $tmp["sumprice"];
     if ($data) {
         $output->pageBar = $data['pageBar'];
         $output->allCnt = $data['allCnt'];
         $output->data = $data['data'];
         $output->pageUrl = $pageUrl;
     }
     $output->cateInfo = Helper_Product::getProductCatePairs();
     $output->setTemplate('ProductSm');
 }
예제 #5
0
파일: Item.php 프로젝트: dalinhuang/andyou
 /**
  * 同步所有日志
  */
 public function doUpData(ZOL_Request $input, ZOL_Response $output)
 {
     set_time_limit(0);
     $token = $input->get("token");
     //token的验证
     //
     if ($token != md5("c=Rsync_Item&a=UpData" . "AAFDFDF&RE3")) {
         echo "001";
         exit;
     }
     $db = Db_AndyouYun::instance();
     $data = $input->post("data");
     $table = $input->post("table");
     if ($data) {
         $data = base64_decode($data);
         $data = api_json_decode($data);
         if ($data) {
             if (in_array($table, array("staff", "product", "membercate", "productcate", "staffcate", "options", "billsitem"))) {
                 //log_cardchange
                 $okIdArr = array();
                 foreach ($data as $d) {
                     $site = $d['site'];
                     $objId = $d['objId'];
                     $subSql = "site = '{$site}' and objId = '{$objId}'";
                     $sql = "select 'x' from {$table} where {$subSql} limit 1 ";
                     $has = $db->getOne($sql);
                     $okIdArr[] = $objId;
                     unset($d['id']);
                     unset($d['rsync']);
                     unset($d['rowTm']);
                     $item = $d;
                     if (!$has) {
                         //如果不存在就插入到本地
                         Helper_Dao::insertItem(array('addItem' => $item, 'dbName' => "Db_AndyouYun", 'tblName' => $table));
                     } else {
                         Helper_Dao::updateItem(array('addItem' => $item, 'dbName' => "Db_AndyouYun", 'tblName' => $table, 'where' => $subSql));
                     }
                 }
                 echo json_encode($okIdArr);
             }
         }
     }
     exit;
 }
예제 #6
0
 /**
  * 获得数据列表
  */
 public function doDefault(ZOL_Request $input, ZOL_Response $output)
 {
     $output->ctype = (int) $input->get("ctype");
     //其他产品的消费类型
     if (!$output->ctype) {
         $output->ctype = 2;
     }
     //获得所有会员类型
     $output->memberCate = Helper_Member::getMemberCatePairs();
     //获得所有的员工
     $output->staffArr = Helper_Staff::getStaffPairs();
     $output->proCtypeArr = ZOL_Config::get("GLOBAL", "PRO_CTYPE");
     if (!isset($output->proCtypeArr[$output->ctype])) {
         echo "ERROR";
         exit;
     }
     $output->ctypeName = $output->proCtypeArr[$output->ctype]['name'];
     $output->setTemplate('CheckoutOtherPro');
 }
예제 #7
0
파일: Item.php 프로젝트: dalinhuang/andyou
 public function doUpData(ZOL_Request $input, ZOL_Response $output)
 {
     set_time_limit(0);
     $db = Db_Andyou::instance();
     $isAll = (int) $input->get("isAll");
     $whereSql = "";
     if (!$isAll) {
         //获取一个同步的时间
         $sql = "select tm from log_yunrsync where name = 'itemtimestamp_up'";
         $lastUpTm = (int) $db->getOne($sql);
         if ($lastUpTm > 0) {
             $lastUpTm = $lastUpTm - 1;
         } else {
             $lastUpTm = SYSTEM_TIME;
         }
         $whereSql .= " and rowTm > '" . date("Y-m-d H:i:s", $lastUpTm) . "'";
     }
     $tableArr = array("staff", "product", "membercate", "productcate", "staffcate", "options", "billsitem");
     $hasFlag = false;
     if ($tableArr) {
         foreach ($tableArr as $table) {
             $sql = "select * from {$table} where 1 {$whereSql}";
             $output->data = $db->getAll($sql);
             if ($output->data) {
                 $output->url = "c=Rsync_Item&a=UpData";
                 $output->table = $table;
                 $rtnJson = $this->doPost($input, $output);
                 echo "<hr/>";
                 echo $rtnJson;
                 $hasFlag = true;
             }
         }
     }
     if ($hasFlag) {
         $db->query("delete from log_yunrsync where name = 'itemtimestamp_up'");
         $db->query("insert into log_yunrsync(name,tm) values('itemtimestamp_up'," . SYSTEM_TIME . ")");
     }
     echo "OK";
     exit;
 }
예제 #8
0
 /**
  * ajax获得指定数据
  */
 public function doAjaxData(ZOL_Request $input, ZOL_Response $output)
 {
     $id = (int) $input->get('id');
     $arr = Helper_Dao::getRows(array('dbName' => "Db_Andyou", 'tblName' => "staffcate", 'cols' => "*", 'whereSql' => ' and id=' . $id));
     $data = ZOL_String::convToU8($arr);
     if (isset($data[0])) {
         echo json_encode($data[0]);
     }
     exit;
 }
예제 #9
0
 /**
  * 更新会员的增量信息
  */
 public function doUpNew(ZOL_Request $input, ZOL_Response $output)
 {
     set_time_limit(600);
     error_reporting(E_ALL);
     ini_set("display_errors", 1);
     $db = Db_Andyou::instance();
     $onlyGetFromYun = (int) $input->get("onlyGetFromYun");
     //是否仅更新云端数据
     $allData = (int) $input->get("allData");
     //是否获得所有数据
     //------------------------------------
     //将本地最新添加或者修改的会员同步到远端
     //------------------------------------
     //获取一个同步的时间
     $sql = "select tm from log_yunrsync where name = 'memberinfo_up'";
     $lastUpTm = (int) $db->getOne($sql);
     if ($lastUpTm > 0) {
         $lastUpTm = $lastUpTm - 1;
     }
     if ($allData) {
         $lastUpTm = 0;
     }
     if (!$onlyGetFromYun) {
         //是否仅仅获得远端数据
         //获得最新添加、修改的会员
         $sql = "select id,name,phone,cardno,cateId,byear,bmonth,bday,addTm,remark,introducer,introducerId,allsum,upTm " . " from member where (addTm > {$lastUpTm} or upTm > {$lastUpTm} or rsync = 0) limit 1000";
         $res = $db->getAll($sql);
         $data = array();
         if ($res) {
             foreach ($res as $re) {
                 $re["site"] = $output->sysName;
                 $re["siteObjId"] = $re["id"];
                 $data[] = $re;
             }
         }
         $jsonstr = base64_encode(api_json_encode($data));
         $token = md5("c=Rsync_Member&a=UpNew" . "AAFDFDF&RE3");
         $rtnJson = ZOL_Http::curlPost(array('url' => $output->yunUrl . "?c=Rsync_Member&a=UpNew&token={$token}", 'postdata' => "data={$jsonstr}", 'timeout' => 3));
         #设置同步状态
         $okIdArr = json_decode($rtnJson);
         if ($okIdArr && is_array($okIdArr)) {
             foreach ($okIdArr as $id) {
                 echo "{$id} OK<br/>";
                 $db->query("update member set rsync = 1 where id = {$id} ");
             }
         }
     }
     //获得云端最新的数据
     $urlPart = "c=Rsync_Member&a=GetNew&tm=" . $lastUpTm;
     $token = md5($urlPart . "AAFDFDF&RE3");
     $url = $output->yunUrl . "?{$urlPart}&token={$token}";
     $html = ZOL_Http::curlPage(array('url' => $url, 'timeout' => 30));
     if ($html) {
         $data = api_json_decode($html);
         if ($data) {
             foreach ($data as $d) {
                 $phone = $d["phone"];
                 $sql = "select * from member where phone = '{$phone}' limit 1 ";
                 $info = $db->getRow($sql);
                 if (!$info) {
                     //如果不存在就插入到云端
                     unset($d["id"]);
                     $item = $d;
                     Helper_Dao::insertItem(array('addItem' => $item, 'dbName' => "Db_Andyou", 'tblName' => "member"));
                 } else {
                     #如果云端已经存在了
                     if ($info["upTm"] < $d["upTm"]) {
                         //云端的更新时间比较老
                         $item = array('name' => $d["name"], 'cardno' => $d["cardno"], 'cateId' => $d["cateId"], 'byear' => $d["byear"], 'bmonth' => $d["bmonth"], 'bday' => $d["bday"], 'remark' => $d["remark"], 'score' => $d["score"], 'balance' => $d["balance"], 'allsum' => $d["allsum"], 'introducer' => $d["introducer"], 'introducerId' => $d["introducerId"], 'upTm' => $d["upTm"]);
                         Helper_Dao::updateItem(array('editItem' => $item, 'dbName' => "Db_Andyou", 'tblName' => "member", 'where' => "phone = '{$phone}'"));
                     }
                 }
             }
         }
         if (!$onlyGetFromYun) {
             //是否仅仅获得远端数据
             $db->query("delete from log_yunrsync where name = 'memberinfo_up'");
             $db->query("insert into log_yunrsync(name,tm) values('memberinfo_up'," . SYSTEM_TIME . ")");
         }
     }
     echo "OK";
     exit;
 }
예제 #10
0
파일: Login.php 프로젝트: dalinhuang/andyou
 public function doToLogin(ZOL_Request $input, ZOL_Response $output)
 {
     $output->msg = $input->get("msg");
     $output->setTemplate('ToLogin');
 }
예제 #11
0
 /** 
  * 获得最新的数据
  */
 public function doGetNew(ZOL_Request $input, ZOL_Response $output)
 {
     $token = $input->get("token");
     $tm = (int) $input->get("tm");
     //token的验证
     //
     if ($token != md5("c=Rsync_Member&a=GetNew&tm={$tm}" . "AAFDFDF&RE3")) {
         echo "001";
         exit;
     }
     $db = Db_AndyouYun::instance();
     $sql = "select name,phone,cardno,cateId,byear,bmonth,bday,addTm,remark,introducer,introducerId,allsum,upTm,score,balance,site,siteObjId " . " from member where (addTm > {$tm} or upTm > {$tm})";
     $data = $db->getAll($sql);
     $jsonstr = api_json_encode($data);
     echo $jsonstr;
     exit;
 }
예제 #12
0
 /**
  * 广告位频道
  * lvj 2014-4-9
  */
 public function doGetUserSubcate(ZOL_Request $input, ZOL_Response $output)
 {
     $sel = (int) $input->get('sel');
     #选中状态
     $userId = htmlspecialchars($input->get('userId'));
     $manuId = (int) $input->get('val');
     echo Helper_Func_Form::getUserSubcateSelect(array('type' => 3, 'userId' => $userId, 'manuId' => $manuId, 'sel' => $sel));
     exit;
 }
예제 #13
0
 /**
  * ajax获得指定数据
  */
 public function doAjaxData(ZOL_Request $input, ZOL_Response $output)
 {
     $id = (int) $input->get('id');
     $arr = Helper_Dao::getRows(array('dbName' => "Db_Andyou", 'tblName' => "membercate", 'cols' => "*", 'whereSql' => ' and id=' . $id));
     //数据补充
     if ($arr) {
         foreach ($arr as $k => $v) {
             if ($v["discountStr"]) {
                 $tmparr = json_decode($v["discountStr"], true);
                 foreach ($tmparr as $i => $iv) {
                     $arr[$k]["disc_" . $i] = $iv;
                 }
             }
         }
     }
     $data = ZOL_String::convToU8($arr);
     if (isset($data[0])) {
         echo json_encode($data[0]);
     }
     exit;
 }
예제 #14
0
 /**
  * 登录显示的页面
  */
 public function doLoginShow(ZOL_Request $input, ZOL_Response $output)
 {
     $output->errMsg = $input->get("errMsg");
     $output->setTemplate('M/Login');
 }