Exemple #1
0
 /**
  * 更新库存
  */
 public function doAddIn(ZOL_Request $input, ZOL_Response $output)
 {
     $db = Db_Andyou::instance();
     $itemIdArr = $input->post("item_id");
     //所有产品ID
     $itemNumArr = $input->post("item_num");
     //所有产品产品数量
     if ($itemIdArr) {
         foreach ($itemIdArr as $i => $pid) {
             $num = $itemNumArr[$i];
             if ($num) {
                 $orgNum = (int) $db->getOne("select stock from product where id = {$pid}");
                 //获得以前的库存数
                 //更新库存信息
                 $sql = "update product set stock = stock + {$num} where id = {$pid} ";
                 $db->query($sql);
                 //获得当前产品的信息
                 $proInfo = Helper_Product::getProductInfo(array('id' => $pid));
                 //记录日志 log_productInStorage
                 $item = array('proId' => $pid, 'adminer' => $output->admin, 'dateTm' => SYSTEM_TIME, 'orgNum' => $orgNum, 'addNum' => $num, 'cateId' => $proInfo["cateId"], 'name' => $proInfo["name"], 'code' => $proInfo["code"]);
                 Helper_Dao::insertItem(array('addItem' => $item, 'dbName' => 'Db_Andyou', 'tblName' => 'log_productInStorage'));
             }
         }
     }
     $urlStr = "?c={$output->ctlName}";
     echo "<script>alert('Success!');document.location='{$urlStr}';</script>";
     exit;
 }
Exemple #2
0
 /**
  * 父类的Validate
  */
 public function baseValidate(ZOL_Request $input, ZOL_Response $output)
 {
     $output->execName = $input->execName = $input->getExecName();
     $output->actName = $input->actName = $input->getActionName();
     $output->ctlName = $input->ctlName = $input->getControllerName();
     return true;
 }
Exemple #3
0
 /**
  * 执行登录的动作
  */
 public function doLogin(ZOL_Request $input, ZOL_Response $output)
 {
     $phone = $input->post("phone");
     $passwd = $input->post("passwd");
     if (empty($phone) || empty($passwd)) {
         $this->showRegErrorMsg("请输入完整");
     }
     if (!preg_match("#^1\\d{10}\$#", $phone, $mt)) {
         $this->showRegErrorMsg("手机号输入错误");
     }
     //获得登录信息
     $loginInfo = Helper_Yun_Member::getLoginInfo(array('phone' => $phone));
     if (!$loginInfo) {
         //已经注册过了
         $this->showLoginErrorMsg("<a href='?c=M_Member&a=RegShow'>该手机号还没有注册过,请注册</a>");
     }
     $passwd = Helper_Yun_Member::mkLoginPasswd(array('passwd' => $passwd, 'salt' => $phone));
     if ($passwd == $loginInfo["passwd"]) {
         $output->message = "恭喜您,登录成功";
         $this->showMessage($input, $output);
     } else {
         $this->showLoginErrorMsg("用户名或密码错误");
     }
     exit;
 }
Exemple #4
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;
 }
 public function doDone(ZOL_Request $input, ZOL_Response $output)
 {
     $otherProIdArr = $input->post("otherProId");
     //所有商品
     $staffid = (int) $input->post("staffid");
     //员工
     $remark = $input->post("remark");
     //填写的备注
     $memberId = (int) $input->post("memberId");
     //会员ID
     if (!$staffid || empty($otherProIdArr)) {
         $this->showErrMsg();
     }
     //获得会员信息
     $memberInfo = Helper_Member::getMemberInfo(array("id" => $memberId));
     if (!$memberInfo) {
         $this->showErrMsg();
     }
     //获得商品列表
     $proInfoArr = array();
     foreach ($otherProIdArr as $id) {
         $info = Helper_Product::getMemberOtherPro(array('id' => $id, 'memberId' => $memberId));
         if ($info && $info["num"] > 0) {
             //筛选一下商品
             $proInfoArr[] = $info;
         }
     }
     //生成一个单号
     $bno = Helper_Bill::getCommonMaxBno();
     $db = Db_Andyou::instance();
     if ($proInfoArr) {
         foreach ($proInfoArr as $info) {
             //数量减少
             $sql = "update memeberotherpro set num = num - 1 where id = " . $info["id"];
             $db->query($sql);
             //记录消费日志
             $tmpLogRow = array('memberId' => $memberId, 'phone' => $memberInfo["phone"], 'otherproId' => $info["id"], 'name' => $info["name"], 'direction' => 1, 'cvalue' => 1, 'orgcvalue' => $info["num"], 'ctype' => $info["ctype"], 'dateTm' => SYSTEM_TIME, 'staffid' => $staffid, 'bno' => $bno, 'remark' => $remark);
             Helper_Dao::insertItem(array('addItem' => $tmpLogRow, 'dbName' => 'Db_Andyou', 'tblName' => 'log_useotherpro'));
         }
     }
     $staffArr = Helper_Staff::getStaffPairs();
     //准备进入打印页面
     $output->proInfoArr = $proInfoArr;
     $output->bno = $bno;
     $output->memberId = $memberId;
     $output->memberInfo = $memberInfo;
     //会员信息
     $output->staffid = $staffid;
     $output->staffName = $staffArr[$staffid];
     Helper_Bill::createOneCommonBno();
     //生成一个通用订单号
     $output->setTemplate('OtherProPrint');
 }
Exemple #6
0
 public function doLogin(ZOL_Request $input, ZOL_Response $output)
 {
     $userId = $input->post("userId");
     $passWd = $input->post("passwd");
     $rtnFlag = Helper_Member::login(array('userId' => $userId, 'password' => $passWd));
     if ($rtnFlag == 1) {
         #怬OK
         Helper_Front::JumpToHome();
     } else {
         #µÇ¼ʧ°Ü
         Helper_Front::JumpToLogin(array('msg' => 'Óû§Ãû»òÃÜÂë´íÎó'));
     }
 }
Exemple #7
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;
 }
Exemple #8
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;
 }
Exemple #9
0
 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;
 }
Exemple #10
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;
 }
Exemple #11
0
 public static function handler($exception)
 {
     if ($exception instanceof Exception) {
         $debugging = defined('IS_DEBUGGING') ? IS_DEBUGGING : false;
         $production = defined('IS_PRODUCTION') ? IS_PRODUCTION : false;
         if (true == $debugging) {
             if (true == $production) {
                 ZOL_Log::write(ZOL_String::clean($exception), ZOL_Log::TYPE_EXCEPTION);
             } else {
                 echo ZOL_Request::resolveType() == ZOL_Request::CLI ? ZOL_String::clean($exception) : $exception;
             }
         } else {
             header('location: ' . SYSTEM_HOMEPAGE);
         }
     }
 }
Exemple #12
0
 public static function handler($level, $errorMsg, $file, $line, $context = null)
 {
     if ('.tpl.php' == substr($file, -8)) {
         return;
     }
     $str = new ZOL_Exception($errorMsg, $level, $file, $line);
     $debugging = IS_DEBUGGING;
     $production = IS_PRODUCTION;
     if ($debugging) {
         $content = "<br />\n<h2>Error Info:</h2>\n" . '<b>MESSAGE:</b> ' . $errorMsg . "<br />\n" . '<b>TYPE:</b> ' . (isset(self::$levels[$level]) ? self::$levels[$level] : $level) . "<br />\n" . '<b>FILE:</b> ' . $file . "<br />\n" . '<b>LINE:</b> ' . $line . "<br />\n" . $str;
         if ($production) {
             ZOL_Log::write(ZOL_String::clean($content), ZOL_Log::TYPE_ERROR);
         } else {
             echo ZOL_Request::resolveType() == ZOL_Request::CLI ? ZOL_String::clean($content) : $content;
         }
     }
 }
Exemple #13
0
 /**
  * 父类的Validate
  */
 public function baseValidate(ZOL_Request $input, ZOL_Response $output)
 {
     $output->execName = $input->execName = $input->getExecName();
     $output->actName = $input->actName = $input->getActionName();
     $output->ctlName = $input->ctlName = $input->getControllerName();
     $output->admin = $input->cookie(Helper_Yun_Member::$strUid);
     $output->userId = $input->cookie(Helper_Yun_Member::$strUid);
     #用户名
     $cipher = $input->cookie(Helper_Yun_Member::$strCipher);
     $output->sysCfg = Helper_Yun_Option::getAllOptions();
     $output->sysName = empty($output->sysCfg['SysName']) ? "" : $output->sysCfg['SysName']["value"];
     if (!$output->noLoginCheck) {
         #验证登录
         $output->isLogin = Helper_Yun_Member::checkLogin(array('userid' => $output->userId, 'cipher' => $cipher));
         if (!$output->isLogin) {
             #如果登录不OK
             $backUrl = isset($_SERVER['REQUEST_URI']) ? 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] : '';
             if (strpos($backUrl, "Login")) {
                 $backUrl = "";
             }
             Helper_Front::JumpToLogin(array('backUrl' => $backUrl));
         }
     }
     #获得管理员身份
     $output->adminInfo = Helper_Yun_AdminUser::getAdminUserInfo(array('userId' => $output->userId));
     $output->adminType = (int) $output->adminInfo["isAdmin"];
     //管理员类型,用于权限判断
     if ($output->permission && !in_array($output->adminType, $output->permission)) {
         echo "Permission denied";
         exit;
     }
     //所有站点的名字
     $output->siteNames = ZOL_Config::get("Yun_Sites", "NAMES");
     #头尾html
     $output->header = $output->fetchCol("Part/Header");
     //左侧
     $output->navi = $output->fetchCol("Part/Navi");
     $output->footer = $output->fetchCol("Part/Footer");
     return true;
     return true;
 }
Exemple #14
0
 /**
  * 获得注释
  */
 public function getSqlComment()
 {
     if (!$this->sqlComment) {
         $typeStr = "WEB";
         $isCli = false;
         switch (ZOL_Request::resolveType()) {
             case ZOL_Request::CLI:
                 $typeStr = "CLI";
                 $isCli = true;
                 break;
             case ZOL_Request::AJAX:
                 $typeStr = "AJAX";
                 break;
             case ZOL_Request::BROWSER:
             default:
                 $typeStr = "WEB";
                 break;
         }
         if (ZOL_Registry::exists('request')) {
             $request = ZOL_Registry::get('request');
             $c = $request->getControllerName();
             $a = $request->getActionName();
         } else {
             $c = $a = "";
             if (!defined('APP_NAME')) {
                 define("APP_NAME", "");
             }
         }
         if ($isCli) {
             #如果是命令行执行
             $this->sqlComment = "/*" . $_SERVER["HOSTNAME"] . ":{$typeStr}:" . APP_NAME . ":c={$c}&a={$a}*/";
         } else {
             $this->sqlComment = "/*" . $_SERVER["HTTP_HOST"] . ":{$typeStr}:" . APP_NAME . ":c={$c}&a={$a}*/";
         }
     }
     return $this->sqlComment;
 }
Exemple #15
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;
 }
Exemple #16
0
 /**
  * 更新数据
  */
 public function doUpItem(ZOL_Request $input, ZOL_Response $output)
 {
     $Arr = array();
     $input->request('name') ? $Arr['name'] = $input->request('name') : '';
     $input->request('code') ? $Arr['code'] = $input->request('code') : '';
     $input->request('cateId') ? $Arr['cateId'] = $input->request('cateId') : '';
     $input->request('price') ? $Arr['price'] = $input->request('price') : '';
     $input->request('inPrice') ? $Arr['inPrice'] = $input->request('inPrice') : '';
     $input->request('stock') ? $Arr['stock'] = $input->request('stock') : '';
     $input->request('score') ? $Arr['score'] = $input->request('score') : '';
     $input->request('discut') ? $Arr['discut'] = $input->request('discut') : '';
     //产品报价,保存以分为单位的价格
     if (isset($Arr['price'])) {
         $Arr['price'] = $Arr['price'] * 100;
     }
     if (isset($Arr['inPrice'])) {
         $Arr['inPrice'] = $Arr['inPrice'] * 100;
     }
     $pageUrl = $input->request('pageUrl');
     $data = Helper_Dao::updateItem(array('editItem' => $Arr, 'dbName' => 'Db_Andyou', 'tblName' => 'product', 'where' => ' id=' . $input->request('dataid')));
     /*backUrl*/
     $urlStr = $pageUrl ? $pageUrl : "?c={$output->ctlName}&t={$output->rnd}";
     echo "<script>document.location='{$urlStr}';</script>";
     exit;
 }
Exemple #17
0
 public function doDone(ZOL_Request $input, ZOL_Response $output)
 {
     $billInfo = $input->post("bill");
     $itemIdArr = $input->post("item_id");
     //所有产品ID
     $itemDiscArr = $input->post("item_disc");
     //所有产品折扣
     $itemNumArr = $input->post("item_num");
     //所有产品产品数量
     $staffid = (int) $input->post("staffid");
     //员工
     $isBuyScore = (int) $input->post("isBuyScore");
     //是否是从积分兑换页面的提交
     $remark = $input->post("remark");
     //填写的备注
     $endSumModifyFlag = (int) $input->post("endSumModifyFlag");
     //是否手工调整了最总价格
     $endBillPrice = $billInfo["bill_end_sum"];
     //最终的价格,这个价格是可以修改的
     $db = Db_Andyou::instance();
     //----------------------
     //获得会员信息
     //----------------------
     $memberId = (int) $input->post("memberId");
     //会员ID
     $memberInfo = Helper_Member::getMemberInfo(array("id" => $memberId));
     if ($memberInfo) {
         $memberScore = $memberInfo["score"];
         //会员的积分
         $memberCard = $memberInfo["balance"];
         //会员的卡内余额
     } else {
         //如果没有这个会员
         $memberScore = $memberCard = 0;
         $billInfo["bill_member_card"] = 0;
         //传递过来的会员扣费,强制失效掉
         $billInfo["bill_member_score"] = 0;
     }
     //----------------------
     //获得说有的商品信息
     //----------------------
     $proInfoArr = array();
     $sumPrice = 0;
     //原价总金额
     $orgSumPrice = 0;
     //商品总额
     //折扣获得的金额
     $discGetMoney = 0;
     //记录所有商品的总价格
     $itemSumPrice = 0;
     //判断是否购买了其他的服务,如次卡
     $hasBuyOtherPro = false;
     $otherProItemArr = array();
     if ($itemIdArr) {
         foreach ($itemIdArr as $idx => $pid) {
             $proInfo = Helper_Product::getProductInfo(array('id' => $pid));
             $num = (int) $itemNumArr[$idx];
             $price = $num * $proInfo["oprice"] * $itemDiscArr[$idx];
             $orgSumPrice += $num * $proInfo["oprice"];
             $sumPrice += $price;
             $itemSumPrice += $price;
             $proInfoArr[] = array('proId' => $pid, 'num' => $num, 'discount' => $itemDiscArr[$idx], 'price' => $price, 'staffid' => $staffid);
             if ($proInfo["ctype"] != 1) {
                 //购买非商品类的服务
                 $hasBuyOtherPro = true;
                 $otherProItemArr[] = array('info' => $proInfo, 'num' => $num);
             }
         }
     }
     //生成一个单号
     #$bno = Helper_Bill::getMaxBno();
     $bno = Helper_Bill::getCommonMaxBno();
     //----------------------
     //计算总金额
     //----------------------
     $billDisc = $billInfo["bill_disc"];
     //总折扣
     $sumPriceAftDisc = $sumPrice;
     //$orgSumPrice * $billDisc;//总折扣的价格  $sumPrice * $billDisc; //不可以给商品设置单价了
     $discGetMoney = $orgSumPrice - $sumPriceAftDisc;
     //折扣省下来的金额
     //扣除会员卡内余额
     $leftCard = $memberCard;
     //扣除后,卡内还有的余额
     $useCardFlag = false;
     $useCardMoney = 0;
     if ($sumPriceAftDisc && $memberCard && $billInfo["bill_member_card"]) {
         $useCard = min($memberCard, $billInfo["bill_member_card"]);
         $useCard = $useCard * 100;
         $useCard = min($useCard, $sumPriceAftDisc);
         //卡余额和收费的金额比较
         $leftCard = $memberCard - $useCard / 100;
         $useCardMoney = $useCard / 100;
         //记录用了多少卡的金额
         $sumPriceAftDisc = $sumPriceAftDisc - $useCard;
         $useCardFlag = true;
     }
     //会员积分计算
     $sysOptions = Helper_Option::getAllOptions();
     $scoreRatio = !empty($sysOptions["ScoreRatio"]) ? $sysOptions["ScoreRatio"]["value"] : 0;
     $useScore = (int) $billInfo["bill_member_score"];
     if ($useScore && $memberScore > 0) {
         $duihuanRatio = !empty($sysOptions["DuihuanRatio"]) ? $sysOptions["DuihuanRatio"]["value"] : 0;
         $sumPriceAftDisc = $sumPriceAftDisc - round($useScore / $duihuanRatio) * 100;
     }
     /*
              * 先不用会员积分了
             if($sumPriceAftDisc && $memberScore && $billInfo["bill_member_score"]){
                 $useScore = min($memberScore,$billInfo["bill_member_score"]);//需要花多少积分,避免比用户的积分还多
                 
                 //将用户的积分转换成钱
                 $scoreMoney = round($useScore / $scoreRatio,2);// 9 = 270 /30
                 $scoreMoney = $scoreMoney * 100;             // 900 = 9 * 100
                 $scoreMoney = min($scoreMoney,$sumPriceAftDisc); //避免花费的积分比剩余金额还多 
                 
                 $sumPriceAftDisc = $sumPriceAftDisc - $scoreMoney;
                 
             }*/
     //获得订单的信息
     $sumPriceAftDisc = round($sumPriceAftDisc / 100) * 100;
     //金额的四舍五入
     $billDetail = array('useScore' => $useScore, 'useScoreAsMoney' => round($scoreMoney / 100, 2), 'useCard' => $billInfo["bill_member_card"], 'price' => $sumPriceAftDisc, 'discount' => $billDisc, 'orgPrice' => $orgSumPrice, 'staffid' => $staffid, 'memberId' => $memberId, 'bno' => $bno, 'tm' => SYSTEM_TIME, 'dateDay' => date("Ymd"), 'memberScore' => $memberScore, 'memberCard' => $memberCard, 'remark' => $remark, 'isBuyScore' => $isBuyScore);
     if ($memberInfo) {
         $billDetail["phone"] = $memberInfo["phone"];
     }
     //如果销售眼前台修改了应收款,不是计算出来的,就记录
     if ($endSumModifyFlag) {
         if ($sumPriceAftDisc != $endBillPrice) {
             $billDetail["priceTrue"] = $billDetail["price"];
             $billDetail["price"] = $endBillPrice * 100;
             //使用销售员修改的
         }
     }
     //积分的重新计算
     //         =  积分剩余额                                    +  实际消费产品的积分
     $leftScore = $memberScore - (int) $billDetail["useScore"] + ($billDetail["price"] / 100 + $billDetail["useCard"]) * $scoreRatio;
     $memLeftInfo = array();
     $memLeftInfo['score'] = round($leftScore);
     if ($useCardFlag) {
         //使用了会员卡
         $memLeftInfo['balance'] = $leftCard;
     }
     //计算用户的总消费额
     $memLeftInfo['allsum'] = $memberInfo['allsum'] + $endBillPrice + $billInfo["bill_member_card"];
     //记入订单库
     $output->newScore = (int) (($billDetail['useCard'] + $billDetail['price'] / 100) * $scoreRatio);
     //获得的积分
     $billDetail["getScore"] = $output->newScore;
     $bid = Helper_Dao::insertItem(array('addItem' => $billDetail, 'dbName' => 'Db_Andyou', 'tblName' => 'bills'));
     //记入订单详情
     if ($proInfoArr) {
         foreach ($proInfoArr as $item) {
             //补充信息
             $item["bid"] = $bid;
             $item["bno"] = $bno;
             $item["memberId"] = $memberId;
             $item["tm"] = SYSTEM_TIME;
             Helper_Dao::insertItem(array('addItem' => $item, 'dbName' => 'Db_Andyou', 'tblName' => 'billsitem'));
         }
     }
     //更新用户详情信息
     Helper_Dao::updateItem(array('editItem' => $memLeftInfo, 'dbName' => 'Db_Andyou', 'tblName' => 'member', 'where' => ' id=' . $memberId));
     $staffArr = Helper_Staff::getStaffPairs();
     //更新商品的库存情况
     if ($itemIdArr) {
         foreach ($itemIdArr as $idx => $pid) {
             $num = (int) $itemNumArr[$idx];
             $db->query("update product set stock = stock - {$num} where id =  {$pid} ");
             /*
                            $proInfo = Helper_Product::getProductInfo(array('id'=>$pid));
                            $stock   = (int)$proInfo["stock"];
                            if($stock){
                $num = (int)$itemNumArr[$idx];
                $stock = $stock - $num;
                //if($stock < 0)$stock = 0; 不限制负数了,一直减下去
                
                 Helper_Dao::updateItem(array(
                         'editItem'       =>  array("stock"=>$stock),
                         'dbName'         =>  'Db_Andyou',
                         'tblName'        =>  'product',
                         'where'          =>  ' id=' . $pid, 
                 ));
                
                            }
             */
         }
     }
     //记录积分历史
     if ($output->newScore && $memberId) {
         //记录自己的积分历史
         Helper_Member::addScoreLog(array('memberId' => $memberId, 'direction' => 0, 'score' => $output->newScore, 'orgScore' => $memberInfo["score"], 'bno' => $bno, 'remark' => '消费'));
         //给介绍人增加积分
         if ($sysOptions && !empty($sysOptions["MemberParentRatio"]) && !empty($sysOptions["MemberParentRatio"]["value"])) {
             $introducerId = $memberInfo["introducerId"];
             $introducer = $memberInfo["introducer"];
             if (empty($memberInfo["allsum"])) {
                 //如果用户从来没有消费过,也就是第一次消费才给介绍人增加积分
                 if (!$introducerId || !$introducer) {
                     #如果没有ID,就尝试活儿
                     $introInfo = Helper_Member::getMemberInfo(array('phone' => $introducer, 'id' => $introducerId));
                     $introducerId = $introInfo["id"];
                     $iscore = $output->newScore * $sysOptions["MemberParentRatio"]["value"];
                     //更新积分
                     $sql = "update member set score = score + {$iscore}  where id = {$introducerId}";
                     $db->query($sql);
                     //记录积分
                     Helper_Member::addScoreLog(array('memberId' => $introducerId, 'direction' => 0, 'score' => $iscore, 'orgScore' => $introInfo["score"], 'bno' => $bno, 'remark' => '介绍【' . $memberInfo["phone"] . "-" . $memberInfo["name"] . '】消费得积分' . $output->newScore . '*' . $sysOptions["MemberParentRatio"]["value"]));
                 }
             }
         }
     }
     //记录会员会员卡使用记录
     if ($memberId && $billDetail["useCard"]) {
         Helper_Member::addCardLog(array('memberId' => $memberId, 'direction' => 1, 'card' => $billDetail["useCard"], 'orgCard' => $memberInfo["balance"], 'bno' => $bno, 'remark' => '消费'));
     }
     //记录会员会员卡使用记录
     if ($memberId && $billDetail["useScore"]) {
         Helper_Member::addScoreLog(array('memberId' => $memberId, 'direction' => 1, 'score' => $billDetail["useScore"], 'orgScore' => $memberInfo["score"], 'bno' => $bno, 'remark' => '积分兑换'));
     }
     //记录订单的一些额外的信息,但是不记录到数据库
     $billDetail['itemSumPrice'] = $itemSumPrice;
     //所有商品折扣后的累计金额
     //购买了其他商品的服务,如次卡
     if ($hasBuyOtherPro && $memberId) {
         foreach ($otherProItemArr as $re) {
             $info = $re["info"];
             $num = (int) $re["num"];
             $tmpRow = array('memberId' => $memberId, 'phone' => $memberInfo["phone"], 'proId' => $info["id"], 'name' => $info["othername"], 'proName' => $info["name"], 'num' => $info["num"], 'ctype' => $info["ctype"], 'buytm' => SYSTEM_TIME);
             $tmpLogRow = array('memberId' => $memberId, 'phone' => $memberInfo["phone"], 'otherproId' => $info["id"], 'name' => $info["othername"], 'direction' => 0, 'cvalue' => $info["num"], 'orgcvalue' => 0, 'ctype' => $info["ctype"], 'dateTm' => SYSTEM_TIME, 'staffid' => $staffid, 'bno' => $bno);
             //记录用户的所有服务
             for ($i = 0; $i < $num; $i++) {
                 Helper_Dao::insertItem(array('addItem' => $tmpRow, 'dbName' => 'Db_Andyou', 'tblName' => 'memeberotherpro'));
                 //数据变化日志
                 Helper_Dao::insertItem(array('addItem' => $tmpLogRow, 'dbName' => 'Db_Andyou', 'tblName' => 'log_useotherpro'));
             }
         }
     }
     //准备进入打印页面
     $output->bno = $bno;
     $output->bid = $bid;
     $output->bsn = substr(md5($bid . "HOOHAHA"), 0, 10);
     $output->billDetail = $billDetail;
     $output->proInfoArr = $proInfoArr;
     $output->memLeftInfo = $memLeftInfo;
     $output->staffid = $staffid;
     $output->staffName = $staffArr[$staffid];
     $output->memberInfo = $memberInfo;
     //会员信息
     $output->discGetMoney = $discGetMoney;
     //折扣省下的钱
     $output->orgSumPrice = $orgSumPrice;
     //原始总价
     $output->isBuyScore = $isBuyScore;
     Helper_Bill::createOneCommonBno();
     //生成一个通用订单号
     $output->setTemplate('BillPrint');
 }
Exemple #18
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;
 }
Exemple #19
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;
 }
Exemple #20
0
 /**
  * 获取指定文章打赏成功的用户
  */
 public static function doGetRewardUser(ZOL_Request $input, ZOL_Response $output)
 {
     $articleId = $input->request('articleId');
     $callback = $input->request('callback');
     $articleId = 5591168;
     if (!$articleId) {
         Helper_Reward_RewardFunc::ajaxExit(array('flag' => 'error', 'msg' => '文章id未知!', 'toLog' => 0));
     }
     $res1 = Helper_Reward_RewardModel::getRewardUser(array('articleId' => $articleId, 'orderStatus' => 1, 'debug' => 0));
     //var_dump($res1);
     if ($res1['data']) {
         # 获取用户的头像,先获取6个用户名
         $userArr = $guestUserArr = array();
         foreach ($res1['data'] as $k => $v) {
             if ($v['custmer'] == 'guest') {
                 $guestUserArr[] = $v;
             } else {
                 $userArr[] = $v;
             }
         }
         $userArr = array_merge($userArr, $guestUserArr);
         $i = 1;
         foreach ($userArr as $k => $v) {
             if ($i > 6) {
                 break;
             }
             if ($v['custmer'] == 'guest') {
                 continue;
             }
             $dataArr = ZOL_Api::run("User.Base.getUserInfo", array('userid' => $v['custmer'], 'rtnCols' => 'photo,nickName'));
             $userArr[$k]['photo'] = $dataArr['photo'];
             $userArr[$k]['nickName'] = $dataArr['nickName'];
             $userArr[$k]['myCenter'] = 'http://my.zol.com.cn/' . $v['custmer'];
             $i++;
         }
         #var_dump($userArr);exit();
         Helper_Reward_RewardFunc::ajaxExit(array('flag' => 'success', 'data' => $userArr, 'callback' => $callback, 'totalCount' => $res1['totalCount'], 'toLog' => 0));
     } else {
         Helper_Reward_RewardFunc::ajaxExit(array('flag' => 'error', 'data' => '没有数据!', 'toLog' => 0));
     }
 }
Exemple #21
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;
 }
Exemple #22
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;
 }