Ejemplo n.º 1
0
 /**
  * 根据不同的站点获得员工
  */
 public static function getSiteStaffPairs()
 {
     $db = Db_AndyouYun::instance();
     $res = $db->getAll("select id,name,site,objId from staff");
     $outArr = array();
     if ($res) {
         foreach ($res as $re) {
             $outArr[$re["site"]][$re["objId"]] = $re["name"];
         }
     }
     return $outArr;
 }
Ejemplo n.º 2
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 ($k == 'cateId' && $v) {
                 $whereSql .= ' AND cateId =' . $v;
             } elseif ($k == 'code' && $v) {
                 $whereSql .= ' AND code =\'' . $v . "'";
             } else {
                 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_AndyouYun", 'tblName' => "product", 'cols' => "*", 'pageSize' => $pageSize, 'page' => $page, 'pageUrl' => $pageUrl, 'whereSql' => $whereSql, 'orderSql' => $orderSql, 'iswrite' => true, 'pageTpl' => 9));
     //获得符合条件的库存总量
     $db = Db_AndyouYun::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_Yun_Product::getProductCatePairs();
     //获得所有的种类
     $output->proCtype = ZOL_Config::get("GLOBAL", "PRO_CTYPE");
     $output->setTemplate('Product');
 }
Ejemplo n.º 3
0
 /**
  * 同步所有日志
  */
 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;
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
 /**
  *  记录会员获得会员卡余额历史
  */
 public static function getOtherPros($params)
 {
     $options = array('id' => false, 'phone' => false, 'cardno' => false);
     if (is_array($params)) {
         $options = array_merge($options, $params);
     }
     extract($options);
     $whereSql = '';
     if (!$id && !$phone && !$name && !$phoneOrCardno) {
         return false;
     }
     if ($id) {
         $whereSql .= "and m.id = '{$id}' ";
     }
     if ($phone) {
         $whereSql .= "and m.phone = '{$phone}' ";
     }
     if ($cardno) {
         $whereSql .= "and m.cardno = '{$cardno}' ";
     }
     if ($phoneOrCardno) {
         $whereSql .= "and (m.cardno = '{$phoneOrCardno}' or m.phone = '{$phoneOrCardno}') ";
     }
     $db = Db_AndyouYun::instance();
     $sql = "select p.id,p.proId,p.name,p.proName,p.num,p.ctype,p.buytm from member m left join memeberotherpro p on m.id = p.memberId where p.num > 0  " . $whereSql;
     $data = $db->getAll($sql);
     return $data;
 }
Ejemplo n.º 6
0
 /**
  * 获得会员分类管理列表
  */
 public static function getProductCatePairs()
 {
     $db = Db_AndyouYun::instance();
     return $db->getPairs("select id,name from productcate ", "id", "name");
 }
Ejemplo n.º 7
0
 /**
  *  更新用户会员卡余额
  */
 public function doUpCard(ZOL_Request $input, ZOL_Response $output)
 {
     $mid = (int) $input->post("mid");
     $card = (int) $input->post("card");
     $direction = (int) $input->post("direction");
     $remark = $input->post("remark");
     $staffid = (int) $input->post('staffid');
     $urlStr = "?c={$output->ctlName}";
     if ($mid == 0) {
         echo "<script>alert('Error!');document.location='{$urlStr}';</script>";
         exit;
     }
     if ($card < 0) {
         $card = -$card;
     }
     //生成一个单号
     $output->bno = Helper_Bill::getCommonMaxBno();
     #获得会员信息
     $minfo = Helper_Member::getMemberInfo(array("id" => $mid));
     if (!$minfo) {
         echo "<script>alert('Member Error!');document.location='{$urlStr}';</script>";
         exit;
     }
     if ($direction == 1) {
         //减分的时候判断用户是否有这么多
         if ($minfo["balance"] < $card) {
             echo "<script>alert('Balance Error!');document.location='{$urlStr}';</script>";
             exit;
         }
     }
     $db = Db_AndyouYun::instance();
     $op = $direction == 1 ? "-" : "+";
     $sql = "update member set balance = balance {$op} {$card} where id = {$mid}";
     $db->query($sql);
     $logItem = array("memberId" => $mid, "direction" => $direction, "card" => $card, "dateTm" => SYSTEM_TIME, "adminer" => $output->admin, "remark" => $remark, "orgCard" => $minfo["balance"], "staffid" => $staffid, "bno" => $output->bno);
     $data = Helper_Dao::insertItem(array('addItem' => $logItem, 'dbName' => 'Db_AndyouYun', 'tblName' => 'log_cardchange'));
     if ($direction != 1) {
         //充值大小票
         $output->money = $card;
         #充值的钱
         $output->nowBalance = $card + $minfo["balance"];
         $output->memberInfo = $minfo;
         $staffArr = Helper_Staff::getStaffPairs();
         $output->staffName = $staffArr[$staffid];
         Helper_Bill::createOneCommonBno();
         //生成一个通用订单号
         $output->setTemplate("CardPrint");
     } else {
         echo "<script>document.location='{$urlStr}';</script>";
         exit;
     }
 }