Exemple #1
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->memberPhone = $input->get("memberPhone");
     //会员电话
     $output->memberNm = $input->get("memberNm");
     //会员姓名
     //获得会员信息
     $memInfo = Helper_Member::getMemberInfo(array('phone' => $output->memberPhone, 'name' => $output->memberNm));
     if ($memInfo) {
         $whereSql = " and memberId = {$memInfo['id']} ";
     }
     $pageUrl = "?c={$output->ctlName}&a={$output->actName}&page={$page}&memberPhone={$output->memberPhone}&memberNm={$output->memberNm}";
     $pageSize = 30;
     $orderSql = "order by id desc";
     $data = Helper_Dao::getList(array('dbName' => "Db_Andyou", 'tblName' => "log_scorechange", 'cols' => "*", 'pageSize' => $pageSize, 'page' => $page, 'pageUrl' => $pageUrl, 'whereSql' => $whereSql, 'orderSql' => $orderSql, 'iswrite' => true, 'pageTpl' => 9));
     if ($data) {
         $output->pageBar = $data['pageBar'];
         $output->allCnt = $data['allCnt'];
         $output->data = $data['data'];
         $output->pageUrl = $pageUrl;
     }
     $output->setTemplate('LogScoreChange');
 }
 /**
  * 获得数据列表
  */
 public function doDefault(ZOL_Request $input, ZOL_Response $output)
 {
     $wArr = array();
     #搜索字段
     $whereSql = "";
     $page = (int) $input->get('page') < 1 ? 1 : (int) $input->get('page');
     $member = $input->get('member');
     if ($member) {
         $memInfo = Helper_Member::getMemberInfo(array('phoneOrCardno' => $member));
         if ($memInfo) {
             $output->memberId = $memInfo["id"];
         }
     }
     if ($output->serctype) {
         $whereSql .= " AND ctype = " . $output->serctype;
     }
     if ($output->memberId) {
         $whereSql .= " AND memberId = " . $output->memberId;
     }
     $pageUrl = "?c={$output->ctlName}&a={$output->actName}&page={$page}&memberId={$output->memberId}&ctype={$wArr['ctype']}";
     $pageSize = 30;
     $orderSql = "order by id desc";
     $data = Helper_Dao::getList(array('dbName' => "Db_Andyou", 'tblName' => "memeberotherpro", 'cols' => "*", 'pageSize' => $pageSize, 'page' => $page, 'pageUrl' => $pageUrl, 'whereSql' => $whereSql, 'orderSql' => $orderSql, 'iswrite' => true, 'pageTpl' => 9));
     if ($data) {
         $output->pageBar = $data['pageBar'];
         $output->allCnt = $data['allCnt'];
         $output->data = $data['data'];
         $output->pageUrl = $pageUrl;
     }
     $output->member = $member;
     $output->proCtypeArr = ZOL_Config::get("GLOBAL", "PRO_CTYPE");
     $output->setTemplate('MemeberOtherPro');
 }
Exemple #3
0
 /**
  * 获得数据列表
  */
 public function doDefault(ZOL_Request $input, ZOL_Response $output)
 {
     $wArr = array();
     #搜索字段
     $output->isAddUser = (int) $input->get("isAddUser");
     $whereSql = "";
     $page = (int) $input->get('page') < 1 ? 1 : (int) $input->get('page');
     $output->serbno = $wArr['bno'] = $input->get('bno');
     $output->serstaffid = $wArr['staffid'] = $input->get('staffid');
     $output->sermemberId = $wArr['memberId'] = $input->get('memberId');
     $output->sermemberPhone = $input->get('memberPhone');
     $output->isBuyScore = $input->get('isBuyScore');
     $output->hasChangePrice = (int) $input->get("hasChangePrice");
     //销售员修改过的订单
     //如果传入了会员电话
     if ($output->sermemberPhone) {
         $memInfo = Helper_Member::getMemberInfo(array('phone' => $output->sermemberPhone));
         if ($memInfo) {
             $output->sermemberId = $wArr['memberId'] = (int) $memInfo["id"];
         }
     }
     if ($output->isBuyScore == 1) {
         $whereSql .= " and  isBuyScore = 1";
     }
     if ($output->isBuyScore == 2) {
         $whereSql .= " and  isBuyScore = 0";
     }
     //销售员修改了价格
     if ($output->hasChangePrice) {
         $whereSql .= " and  priceTrue > 0 ";
     }
     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 : '';
             }
         }
     }
     if ($output->isAddUser) {
         $whereSql .= " AND memberId = 0 ";
     }
     $pageUrl = "?c={$output->ctlName}&a={$output->actName}&page={$page}&bno={$wArr['bno']}&isAddUser={$output->isAddUser}&staffid={$wArr['staffid']}&memberPhone={$output->sermemberPhone}&hasChangePrice={$output->hasChangePrice}";
     $pageSize = 30;
     $orderSql = "order by id desc";
     $data = Helper_Dao::getList(array('dbName' => "Db_Andyou", 'tblName' => "bills", 'cols' => "*", 'pageSize' => $pageSize, 'page' => $page, 'pageUrl' => $pageUrl, 'whereSql' => $whereSql, 'orderSql' => $orderSql, 'iswrite' => true, 'pageTpl' => 9));
     if ($data) {
         $output->pageBar = $data['pageBar'];
         $output->allCnt = $data['allCnt'];
         $output->data = $data['data'];
         $output->pageUrl = $pageUrl;
     }
     $output->staffInfo = Helper_Staff::getStaffPairs();
     $output->setTemplate('Bills');
 }
 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 #5
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 #6
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 #7
0
 /**
  * 父类的Validate
  */
 public function baseValidate(ZOL_Request $input, ZOL_Response $output)
 {
     $output->yunUrl = "http://182.92.5.73/andyou/Html/Yun/index.php";
     $output->execName = $input->execName = $input->getExecName();
     $output->actName = $input->actName = $input->getActionName();
     $output->ctlName = $input->ctlName = $input->getControllerName();
     $output->admin = $input->cookie(Helper_Member::$strUid);
     $output->userId = $input->cookie(Helper_Member::$strUid);
     #用户名
     $cipher = $input->cookie(Helper_Member::$strCipher);
     $output->sysCfg = Helper_Option::getAllOptions();
     $output->sysName = $output->sysCfg['SysName']["value"];
     if (!$output->noLoginCheck) {
         #验证登录
         $output->isLogin = Helper_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_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;
     }
     #头尾html
     $output->header = $output->fetchCol("Part/Header");
     //左侧
     $output->navi = $output->fetchCol("Part/Navi");
     $output->footer = $output->fetchCol("Part/Footer");
     return true;
 }
Exemple #8
0
 public function doDefault(ZOL_Request $input, ZOL_Response $output)
 {
     $sqlArr = array("create table `bno` (`id` int (11)   NOT NULL AUTO_INCREMENT  COMMENT 'ID',  `tm` int (11)   NOT NULL  COMMENT '日期' , PRIMARY KEY ( `id` )  )", "alter table `bno` add index `tm` ( `tm` )", "alter table `log_scorechange` add column `rsync` tinyint (1)  DEFAULT '0' NOT NULL  COMMENT '表示该记录是否同步到云端'", "update log_scorechange set rsync = 1", "alter table `log_cardchange` add column `rsync` tinyint (1)  DEFAULT '0' NOT NULL  COMMENT '表示该记录是否同步到云端'", "update log_cardchange set rsync = 1", "alter table `member` add column `upTm` int (11)   NOT NULL  COMMENT '信息修改时间'", "alter table `member` add column `rsync` tinyint (11)   NOT NULL  COMMENT '表示该记录是否同步到云端'", "create table `log_yunrsync` (    `id` int (11)   NOT NULL AUTO_INCREMENT ,  `name` varchar (20)   NOT NULL  COMMENT '同步实例名称',  `tm` int (20)   NOT NULL  COMMENT '同步时间' , PRIMARY KEY ( `id` )  )", "alter table `member` add column `site` varchar (11)   NOT NULL  COMMENT '来自哪个站点'", "alter table `member` add column `siteObjId` int (11)   NOT NULL  COMMENT '在那个站点的ID'", "alter table `memeberotherpro` add column `phone` varchar (20)   NOT NULL  COMMENT '电话' after `memberId`, add column `upTm` int (11)   NOT NULL  COMMENT '更新时间' after `ctype`, add column `site` varchar (20)   NOT NULL  COMMENT '站点' after `upTm`, add column `siteObjId` int (11)   NOT NULL  COMMENT '在那个站点的ID' after `site`", "alter table `log_useotherpro` add column `phone` varchar (20)   NOT NULL  COMMENT '电话' after `memberId`", "alter table `bills` add column `phone` varchar (20)   NOT NULL  COMMENT '会员电话' after `memberId`, add column `rsync` tinyint (1)   NOT NULL  COMMENT '是否同步' after `isBuyScore`", "alter table `memeberotherpro` add column `rsync` tinyint (1)   NOT NULL  COMMENT '是否同步'", "alter table `product` add column `rowTm` timestamp   NOT NULL  COMMENT '更新时间戳'", "alter table `staff` add column `rowTm` timestamp   NOT NULL  COMMENT '更新时间戳'", "alter table `membercate` add column `rowTm` timestamp   NOT NULL  COMMENT '更新时间戳'", "alter table `productcate` add column `rowTm` timestamp   NOT NULL  COMMENT '更新时间戳'", "alter table `staffcate` add column `rowTm` timestamp   NOT NULL  COMMENT '更新时间戳'", "alter table `options` add column `rowTm` timestamp   NOT NULL  COMMENT '更新时间戳'", "alter table `billsitem` add column `rowTm` timestamp   NOT NULL  COMMENT '更新时间戳'");
     $db = Db_Andyou::instance();
     if ($sqlArr) {
         foreach ($sqlArr as $sql) {
             echo $sql . "<br/>";
             $db->query($sql);
         }
     }
     $sql = "select memberId from memeberotherpro where phone = '' union select memberId from log_useotherpro where phone = ''";
     $res = $db->getAll($sql);
     if ($res) {
         foreach ($res as $re) {
             $memberId = $re["memberId"];
             $minfo = Helper_Member::getMemberInfo(array('id' => $memberId));
             $phone = $minfo["phone"];
             $db->query("update memeberotherpro set phone = '{$phone}' where memberId = {$memberId}");
             $db->query("update log_useotherpro set phone = '{$phone}' where memberId = {$memberId}");
         }
     }
     echo "OK";
 }
Exemple #9
0
 /**
  * 获得一条会员信息
  */
 public static function getMemberInfo($params)
 {
     $options = array('id' => false, 'phone' => false, 'cardno' => false, 'phoneOrCardno' => false, 'name' => false);
     if (is_array($params)) {
         $options = array_merge($options, $params);
     }
     extract($options);
     $whereSql = '';
     if (!$id && !$phone && !$name && !$phoneOrCardno) {
         return false;
     }
     if ($id) {
         $whereSql .= "and id = '{$id}' ";
     }
     if ($phone) {
         $whereSql .= "and phone = '{$phone}' ";
     }
     if ($cardno) {
         $whereSql .= "and cardno = '{$cardno}' ";
     }
     if ($phoneOrCardno) {
         $whereSql .= "and (cardno = '{$phoneOrCardno}' or phone = '{$phoneOrCardno}') ";
     }
     if ($name) {
         $whereSql .= "and name like '%{$name}%' ";
     }
     $data = Helper_Dao::getRow(array('dbName' => 'Db_Andyou', 'tblName' => 'member', 'cols' => '*', 'whereSql' => $whereSql));
     //获得会员类型
     $memberCate = Helper_Member::getMemberCateInfoPairs();
     if ($data) {
         if (isset($memberCate[$data["cateId"]])) {
             $data['cateName'] = $memberCate[$data["cateId"]]["name"];
             $data['discount'] = $memberCate[$data["cateId"]]["discount"];
             if ($memberCate[$data["cateId"]]['discountStr']) {
                 //折扣的分类
                 $data['discountArr'] = json_decode($memberCate[$data["cateId"]]['discountStr'], true);
             }
         } else {
             $data['cateName'] = "未分类";
             $data['discount'] = 1;
         }
     }
     return $data;
 }
?>
" name="member" placeholder="">
<button type="submit" class="btn-ser">查看</button></form></div>
				    
				    <!-- 列表 -->
                    <table class="table table-center table-striped table-bordered bootstrap-datatable ">
                     <thead>
                        <tr>
                        <th>会员</th><th>会员ID</th><th>商品名</th><th>服务名</th><th>数量</th><th>购买时间</th><th>类型</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 
if ($data) {
    foreach ($data as $v) {
        $memInfo = Helper_Member::getMemberInfo(array('id' => $v['memberId']));
        $outStr = '<tr>';
        $outStr .= '<td>' . ($memInfo ? $memInfo["name"] : "") . '</td>';
        $outStr .= '<td>' . ($memInfo ? $memInfo["phone"] : "") . '</td>';
        $outStr .= '<td>' . $v['proName'] . '</td>';
        $outStr .= '<td>' . $v['name'] . '</td>';
        $outStr .= '<td>' . $v['num'] . '</td>';
        $outStr .= '<td>' . date("Y-m-d H:i", $v['buytm']) . '</td>';
        $outStr .= '<td>' . $proCtypeArr[$v['ctype']]['name'] . '</td>';
        /*
        $outStr.='<td rel="'.$v['id'].'">
        <a title="修改" class="btn btn-info editbtnMemeberOtherPro"><i class="halflings-icon white edit"></i></a>
        <a title="删除" class="btn btn-danger delbtn"><i class="halflings-icon white trash"></i></a></td>';
        */
        $outStr .= '</tr>';
        echo $outStr;
" name="memberNm" >
<button type="submit" class="btn-ser">查看</button></form></div>
				    
				    <!-- 列表 -->
                    <table class="table table-center table-striped table-bordered bootstrap-datatable ">
                     <thead>
<tr>
<th>会员名</th><th>会员手机</th><th>变化积分</th><th>原积分</th><th>备注</th><th>订单号</th><th>时间</th><th>操作人</th>
</tr>
</thead>
<tbody>
<?php 
if ($data) {
    foreach ($data as $v) {
        $memberId = $v['memberId'];
        $memInfo = Helper_Member::getMemberInfo(array('id' => $memberId));
        $outStr = '<tr>';
        $outStr .= '<td>' . $memInfo["name"] . '</td>';
        $outStr .= '<td>' . $memInfo["phone"] . '</td>';
        $outStr .= '<td>' . ($v['direction'] ? "<font color='blue'>-</font>" : "+");
        $outStr .= ' ' . $v['score'] . '</td>';
        $outStr .= '<td>' . $v['orgScore'] . '</td>';
        $outStr .= '<td>' . $v['remark'] . '</td>';
        $outStr .= '<td>' . $v['bno'] . '</td>';
        $outStr .= '<td>' . date("Y-m-d H:i", $v['dateTm']) . '</td>';
        $outStr .= '<td>' . $v['adminer'] . '&nbsp;</td>';
        $outStr .= '</tr>';
        echo $outStr;
    }
}
?>
Exemple #12
0
 private function doPost(ZOL_Request $input, ZOL_Response $output)
 {
     $db = Db_Andyou::instance();
     $res = $output->data;
     if ($res) {
         $data = array();
         foreach ($res as $re) {
             $re["site"] = $output->sysName;
             //获得会员的信息
             if (in_array($output->table, array("log_scorechange", "log_cardchange"))) {
                 $minfo = Helper_Member::getMemberInfo(array("id" => $re["memberId"]));
                 $re["phone"] = $minfo["phone"];
             }
             if (in_array($output->table, array("bills"))) {
                 if (empty($re["phone"])) {
                     $minfo = Helper_Member::getMemberInfo(array("id" => $re["memberId"]));
                     $re["phone"] = $minfo["phone"];
                     $db->query("update {$output->table} set phone = '{$minfo["phone"]}' where memberId = {$re["memberId"]}");
                 }
             }
             $data[] = $re;
         }
         $jsonstr = base64_encode(api_json_encode($data));
         echo $jsonstr . "<hr/>";
         $token = md5($output->url . "AAFDFDF&RE3");
         $rtn = ZOL_Http::curlPost(array('url' => $output->yunUrl . "?" . $output->url . "&token={$token}", 'postdata' => "table={$output->table}&data={$jsonstr}", 'timeout' => 3));
         return $rtn;
     }
     return false;
 }
Exemple #13
0
 /**
  * 添加记录
  */
 public function doAddItem(ZOL_Request $input, ZOL_Response $output)
 {
     $Arr = array();
     $Arr['name'] = $input->post('name');
     $Arr['cardno'] = $input->post('cardno');
     $Arr['phone'] = $input->post('phone');
     $Arr['cateId'] = $input->post('cateId');
     $Arr['byear'] = $input->post('byear');
     $Arr['bmonth'] = $input->post('bmonth');
     $Arr['bday'] = $input->post('bday');
     $Arr['addTm'] = SYSTEM_TIME;
     $Arr['score'] = $input->post('score');
     $Arr['balance'] = $input->post('balance');
     $Arr['remark'] = $input->post('remark');
     $Arr['introducer'] = $input->post('introducer');
     //查看该电话是否注册了
     $minfo = Helper_Member::getMemberInfo(array('phone' => $Arr['phone']));
     $urlStr = "?c={$output->ctlName}&t={$output->rnd}";
     if ($minfo) {
         echo "<script>alert('该手机号已经存在了!');document.location='?c=Member&phone={$Arr['phone']}';</script>";
         exit;
     }
     $pageUrl = $input->request('pageUrl');
     $data = Helper_Dao::insertItem(array('addItem' => $Arr, 'dbName' => 'Db_Andyou', 'tblName' => 'member'));
     /*backUrl*/
     echo "<script>document.location='{$urlStr}';</script>";
     exit;
 }
Exemple #14
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');
 }