/** * 获得数据列表 */ 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->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']}&cateId={$wArr['cateId']}"; $pageSize = 30; $orderSql = "order by id desc"; $data = Helper_Dao::getList(array('dbName' => "Db_Andyou", 'tblName' => "staff", '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->staffCate = Helper_Staff::getStaffCatePairs(); $output->setTemplate('Staff'); }
/** * 获得数据列表 */ 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 doDefault(ZOL_Request $input, ZOL_Response $output) { $wArr = array(); #搜索字段 $whereSql = ""; $page = (int) $input->get('page') < 1 ? 1 : (int) $input->get('page'); $output->sermemberId = $wArr['memberId'] = $input->get('memberId'); $output->serctype = $wArr['ctype'] = $input->get('ctype'); $member = $input->get('member'); if ($member) { $memInfo = Helper_Member::getMemberInfo(array('phoneOrCardno' => $member)); if ($memInfo) { $output->memberId = $memInfo["id"]; } } $output->member = $member; 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}&member={$member}&ctype={$wArr['ctype']}"; $pageSize = 30; $orderSql = "order by id desc"; $data = Helper_Dao::getList(array('dbName' => "Db_Andyou", 'tblName' => "log_useotherpro", '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->staffArr = Helper_Staff::getStaffPairs(); $output->proCtypeArr = ZOL_Config::get("GLOBAL", "PRO_CTYPE"); $output->setTemplate('LogUseOtherPro'); }
echo $memberNm; ?> " 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) { $staffArr = Helper_Staff::getStaffPairs(); foreach ($data as $v) { $memberId = $v['memberId']; $memInfo = Helper_Member::getMemberInfo(array('id' => $memberId)); $outStr = '<tr>'; $outStr .= '<td>' . $v['bno'] . ' </td>'; $outStr .= '<td>' . $memInfo["name"] . '</td>'; $outStr .= '<td>' . $memInfo["phone"] . '</td>'; $outStr .= '<td>' . ($v['direction'] ? "<font color='blue'>-</font>" : "+"); $outStr .= ' ' . $v['card'] . '</td>'; $outStr .= '<td>' . $v['orgCard'] . '</td>'; $outStr .= '<td>' . date("Y-m-d H:i", $v['dateTm']) . '</td>'; $outStr .= '<td>' . (isset($staffArr[$v['staffid']]) ? $staffArr[$v['staffid']] : '-') . '</td>'; $outStr .= '<td>' . $v['remark'] . '</td>'; $outStr .= '</tr>'; echo $outStr;
/** * 更新用户会员卡余额 */ 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_Andyou::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_Andyou', '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; } }
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'); }
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'); }