/** * 更新库存 */ 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; }
/** * 更新数据 */ 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; }
/** * 读取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 static function init($paramArr) { $options = array('dbName' => 'Db_UserData', 'tblName' => ''); if (is_array($paramArr)) { $options = array_merge($options, $paramArr); } extract($options); self::$initDbName = $dbName; self::$initTblName = $tblName; return true; }
/** * 获得所有配置数组 */ public static function getAllOptions() { $data = Helper_Dao::getRows(array('dbName' => 'Db_Andyou', 'tblName' => 'options', 'cols' => '*')); $outArr = array(); if ($data) { foreach ($data as $d) { $d["value"] = $d["isInt"] ? (int) $d["value"] : $d["value"]; $outArr[$d["name"]] = $d; } } return $outArr; }
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'); }
/** * 获得一条管理员管理信息 */ public static function getAdminUserInfo($params) { $options = array('userId' => false); if (is_array($params)) { $options = array_merge($options, $params); } extract($options); $whereSql = ''; if ($userId) { $whereSql .= "and userId = '{$userId}' "; } $data = Helper_Dao::getRow(array('dbName' => 'Db_AndyouYun', 'tblName' => 'yun_adminuser', 'cols' => '*', 'whereSql' => $whereSql)); return $data; }
/** * 同步所有日志 */ 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; }
/** * 执行注册的动作 */ public function doReg(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->showRegErrorMsg("该手机号已经注册过了,请直接登录"); } //创建登录信息 $passwd = Helper_Yun_Member::mkLoginPasswd(array('passwd' => $passwd, 'salt' => $phone)); $item = array('phone' => $phone, 'passwd' => $passwd, 'regtm' => SYSTEM_TIME); Helper_Dao::insertItem(array('addItem' => $item, 'dbName' => 'Db_AndyouYun', 'tblName' => 'member_login')); $output->message = "恭喜您,注册成功"; $this->showMessage($input, $output); exit; }
/** * 获得一条订单明细管理信息 */ public static function getBillsItemInfo($params) { $options = array('id' => false); if (is_array($params)) { $options = array_merge($options, $params); } extract($options); $whereSql = ''; if ($id) { $whereSql .= "and id = '{$id}' "; } $data = Helper_Dao::getRow(array('dbName' => 'Db_Andyou', 'tblName' => 'billsItem', 'cols' => 'id id,bid bid,bno bno,proId proId,num num,discount discount,price price,staffid staffid,memberId memberId,tm tm', 'whereSql' => $whereSql)); return $data; }
/** * 获得日志列表 */ public static function getList($paramArr) { $options = array('appName' => '', 'subId' => 0, 'objId' => 0, 'num' => 10, 'offset' => '', 'getNum' => 0, 'whereSql' => ""); if (is_array($paramArr)) { $options = array_merge($options, $paramArr); } extract($options); $idMap = ZOL_Config::get("Star/InnerApp", "ID"); #顶级的分类 if (!isset($idMap[$appName])) { return false; } $subIdMap = ZOL_Config::get("Star/InnerApp", "SUBID"); #二级的分类 #将subid从英文形式转换为数字 if (isset($subIdMap[$appName]) && isset($subIdMap[$appName][$subId])) { $subId = $subIdMap[$appName][$subId]["id"]; } if ($appName) { $whereSql .= " and appId = " . $idMap[$appName]["id"]; } if ($subId) { $whereSql .= " and subId = " . $subId; } if ($objId) { $whereSql .= " and objId = '" . $objId . "'"; } $res = Helper_Dao::getRows(array('dbName' => "Db_Star", 'tblName' => "log_operations", 'offset' => $offset, 'limit' => $num, 'whereSql' => $whereSql . " order by id desc ", 'debug' => 0)); if ($getNum) { #是否获得数量 $cnt = Helper_Dao::getCount(array('dbName' => "Db_Star", 'tblName' => "log_operations", 'whereSql' => $whereSql, 'debug' => 0)); return array('allNum' => $cnt, 'data' => $res); } return $res; }
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 static function getStaffCateInfo($params) { $options = array('id' => false); if (is_array($params)) { $options = array_merge($options, $params); } extract($options); $whereSql = ''; if ($id) { $whereSql .= "and id = '{$id}' "; } $data = Helper_Dao::getRow(array('dbName' => 'Db_Andyou', 'tblName' => 'staffcate', 'cols' => 'id id,name name,salary salary,percentage percentage', 'whereSql' => $whereSql)); return $data; }
/** * 更新会员的增量信息 */ 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; }
/** * 同步最新数据 */ public function doUpNew(ZOL_Request $input, ZOL_Response $output) { $token = $input->get("token"); //token的验证 // if ($token != md5("c=Rsync_Member&a=UpNew" . "AAFDFDF&RE3")) { echo "001"; exit; } $db = Db_AndyouYun::instance(); //获得本地的会员 $data = $input->post("data"); if ($data) { $data = base64_decode($data); $data = api_json_decode($data); if ($data) { $okIdArr = array(); foreach ($data as $d) { $phone = $d["phone"]; $sql = "select * from member where phone = '{$phone}' limit 1 "; $info = $db->getRow($sql); if (!$info) { //如果不存在就插入到云端 $okIdArr[] = $d["id"]; unset($d["id"]); unset($d["rsync"]); $item = $d; $item["upTm"] = SYSTEM_TIME; Helper_Dao::insertItem(array('addItem' => $item, 'dbName' => "Db_AndyouYun", '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"], 'introducer' => $d["introducer"], 'introducerId' => $d["introducerId"], 'upTm' => $d["upTm"]); Helper_Dao::updateItem(array('editItem' => $item, 'dbName' => "Db_AndyouYun", 'tblName' => "member", 'where' => "phone = '{$phone}'")); } } } echo json_encode($okIdArr); } } exit; }
public static function getMemberOtherPro($params) { $options = array('memberId' => false, 'id' => false, 'proId' => false); if (is_array($params)) { $options = array_merge($options, $params); } extract($options); $whereSql = ''; if ($id) { $whereSql .= "and id = '{$id}' "; } if ($proId) { $whereSql .= "and proId = {$proId} "; } if ($memberId) { $whereSql .= "and memberId = {$memberId} "; } $data = Helper_Dao::getRow(array('dbName' => 'Db_Andyou', 'tblName' => 'memeberotherpro', 'cols' => '*', 'whereSql' => $whereSql)); return $data; }
/** * 网站内链资讯手工导入恒星 */ public static function getSeoModuleSyncStar($paramArr) { $options = array('typeId' => '', 'moduleId' => '', 'mode' => 1, 'configArr' => array()); if (is_array($paramArr)) { $options = array_merge($options, $paramArr); } extract($options); if (!$mode) { return false; } if ($mode == 1) { if (empty($configArr)) { return false; } #如果是导产品库,一定要手工和位置类型对应数组 } $whereSql = ' AND d.status=0 '; if ($typeId) { $whereSql .= ' AND m.type_id in(' . $typeId . ') '; } if ($moduleId) { $whereSql .= ' AND m.module_id in(' . $moduleId . ') '; } $tempModuleList = Helper_Dao::getRows(array('dbName' => "Db_Document", 'tblName' => " template_module_class m left join template_module_data d on m.module_id=d.module_id ", 'cols' => "m.module_name,d.title,d.url,d.date", 'whereSql' => $whereSql)); if (empty($tempModuleList)) { return false; } foreach ($tempModuleList as $val) { $nameArr = explode('#', $val['module_name']); if (empty($nameArr[1]) || empty($nameArr[2])) { continue; } if (empty($configArr[$nameArr[1]])) { continue; } $insertArr = array('title' => $val['title'], 'subId' => $nameArr[2], 'url' => $val['url'], 'addTime' => strtotime($val['date']), 'startTime' => strtotime($val['date']), 'endTime' => strtotime('2014-12-31 23:59:59'), 'areaId' => $configArr[$nameArr[1]], 'objId' => $mode); Helper_Dao::insertItem(array('addItem' => $insertArr, 'dbName' => 'Db_Star', 'tblName' => 'seo_weblink_list')); } return true; }
/** * 记录会员获得会员卡余额历史 */ public static function addCardLog($params) { $options = array('memberId' => false, 'direction' => 1, 'card' => 0, 'orgCard' => -1, 'bno' => 0, 'remark' => ''); if (is_array($params)) { $options = array_merge($options, $params); } extract($options); if (!$memberId) { return false; } $arr = $options; $arr['dateTm'] = SYSTEM_TIME; if ($orgScore === -1) { $info = self::getMemberInfo(array("id" => $memberId)); if ($info) { $arr['orgCard'] = $info["balance"]; } } Helper_Dao::insertItem(array('addItem' => $arr, 'dbName' => 'Db_AndyouYun', 'tblName' => 'member_login')); return true; }
/** * 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; }
/** * 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; }