$ret['next'] = $pindex + 1; } } if ($post['type'] == 'sms') { $sql .= " AND `mobile`!=''"; $countSql = 'SELECT COUNT(*)' . $sql; $ret['total'] = pdo_fetchcolumn($countSql, $pars); $ret['total'] = intval($ret['total']); $psize = 1; $pindex = intval($post['next']); $pindex = max(1, $pindex); $start = $psize * ($pindex - 1); $sql = 'SELECT `mobile`' . $sql . " LIMIT {$start}, {$psize}"; $ds = pdo_fetchall($sql, $pars); if (is_array($ds)) { load()->model('cloud'); foreach ($ds as $row) { cloud_sms_send($row['mobile'], $post['content']); if (is_error($r)) { $ret['failed']++; } else { $ret['success']++; } } } if ($start + $psize < $ret['total']) { $ret['next'] = $pindex + 1; } } exit(json_encode($ret)); }
public function payResult($params) { global $_GPC, $_W; $weid = $this->_weid; $sql = 'SELECT * FROM ' . tablename('hotel2_order') . ' WHERE `id` = :id AND `weid` = :weid'; $order = pdo_fetch($sql, array(':id' => $params['tid'], ':weid' => $weid)); pdo_update('hotel2_order', array('paystatus' => 1), array('id' => $params['tid'])); $sql = 'SELECT `email`, `mobile` FROM ' . tablename('hotel2_set') . ' WHERE `weid` = :weid'; $setInfo = pdo_fetch($sql, array(':weid' => $_W['uniacid'])); if ($setInfo['email']) { $body = "<h3>酒店订单</h3> <br />"; $body .= '订单编号:' . $order['ordersn'] . '<br />'; $body .= '姓名:' . $order['name'] . '<br />'; $body .= '手机:' . $order['mobile'] . '<br />'; $body .= '房型:' . $order['style'] . '<br />'; $body .= '订购数量' . $order['nums'] . '<br />'; $body .= '原价:' . $order['oprice'] . '<br />'; $body .= '会员价:' . $order['mprice'] . '<br />'; $body .= '入住日期:' . date('Y-m-d', $order['btime']) . '<br />'; $body .= '退房日期:' . date('Y-m-d', $order['etime']) . '<br />'; $body .= '总价:' . $order['sum_price']; // 发送邮件提醒 if (!empty($setInfo['email'])) { load()->func('communication'); ihttp_email($setInfo['email'], '微酒店订单提醒', $body); } } if ($setInfo['mobile']) { // 发送短信提醒 if (!empty($setInfo['mobile'])) { load()->model('cloud'); cloud_prepare(); $body = '用户' . $order['name'] . ',电话:' . $order['mobile'] . '于' . date('m月d日H:i') . '成功支付微酒店订单' . $order['ordersn'] . ',总金额' . $order['sum_price'] . '元' . '.' . random(3); cloud_sms_send($setInfo['mobile'], $body); } } if ($params['from'] == 'return') { $roomid = $order['roomid']; $room = pdo_fetch("SELECT score FROM " . tablename('hotel2_room') . " WHERE id = {$roomid} AND weid = {$weid} LIMIT 1"); $score = intval($room['score']); if ($score) { $from_user = $this->_from_user; pdo_fetch("UPDATE " . tablename('hotel2_member') . " SET score = (score + " . $score . ") WHERE from_user = '******' AND weid = " . $weid . ""); if ($_W['member']['uid'] > 0) { pdo_query("UPDATE " . tablename('mc_members') . " SET credit1 = (credit1 + " . $score . ") WHERE uid = '" . $_W['member']['uid'] . "' AND uniacid = " . $_W['uniacid'] . ""); } } message('支付成功!', '../../app/' . $this->createMobileUrl('orderdetail', array("id" => $order['id'])), 'success'); } }
public function payResult($params) { global $_W; $fee = intval($params['fee']); $data = array('status' => $params['result'] == 'success' ? 1 : 0); $paytype = array('credit' => '1', 'wechat' => '2', 'alipay' => '2', 'delivery' => '3'); // 卡券代金券备注 if (!empty($params['is_usecard'])) { $cardType = array('1' => '微信卡券', '2' => '系统代金券'); $data['paydetail'] = '使用' . $cardType[$params['card_type']] . '支付了' . ($params['fee'] - $params['card_fee']); $data['paydetail'] .= '元,实际支付了' . $params['card_fee'] . '元。'; } $data['paytype'] = $paytype[$params['type']]; if ($params['type'] == 'wechat') { $data['transid'] = $params['tag']['transaction_id']; } if ($params['type'] == 'delivery') { $data['status'] = 1; } $sql = 'SELECT `goodsid` FROM ' . tablename('shopping_order_goods') . ' WHERE `orderid` = :orderid'; $goodsId = pdo_fetchcolumn($sql, array(':orderid' => $params['tid'])); $sql = 'SELECT `total`, `totalcnf` FROM ' . tablename('shopping_goods') . ' WHERE `id` = :id'; $goodsInfo = pdo_fetch($sql, array(':id' => $goodsId)); // 更改库存 if ($goodsInfo['totalcnf'] == '1' && !empty($goodsInfo['total'])) { pdo_update('shopping_goods', array('total' => $goodsInfo['total'] - 1), array('id' => $goodsId)); } pdo_update('shopping_order', $data, array('id' => $params['tid'])); if ($params['from'] == 'return') { //积分变更 $this->setOrderCredit($params['tid']); $order = pdo_fetch("SELECT `price`, `paytype`, `from_user`, `addressid` FROM " . tablename('shopping_order') . " WHERE id = '{$params['tid']}'"); $ordergoods = pdo_fetchall("SELECT goodsid, total FROM " . tablename('shopping_order_goods') . " WHERE orderid = '{$params['tid']}'", array(), 'goodsid'); $goods = pdo_fetchall("SELECT id, title, thumb, marketprice, unit, total FROM " . tablename('shopping_goods') . " WHERE id IN ('" . implode("','", array_keys($ordergoods)) . "')"); $address = pdo_fetch("SELECT * FROM " . tablename('shopping_address') . " WHERE id = :id", array(':id' => $order['addressid'])); if (!empty($this->module['config']['noticeemail']) || !empty($this->module['config']['mobile'])) { $body = "<h3>购买商品清单</h3> <br />"; if (!empty($goods)) { foreach ($goods as $row) { $body .= "名称:{$row['title']} ,数量:{$ordergoods[$row['id']]['total']} <br />"; } } $paytype = $order['paytype'] == '3' ? '货到付款' : '已付款' . '<br />'; $body .= '总金额:' . $order['price'] . '元' . $paytype . '<br />'; $body .= '<h3>购买用户详情</h3> <br />'; $body .= '真实姓名:' . $address['realname'] . '<br />'; $body .= '地区:' . $address['province'] . ' - ' . $address['city'] . ' - ' . $address['area'] . '<br />'; $body .= '详细地址:' . $address['address'] . '<br />'; $body .= '手机:' . $address['mobile'] . '<br />'; // 邮件提醒 if (!empty($this->module['config']['noticeemail'])) { load()->func('communication'); ihttp_email($this->module['config']['noticeemail'], '微商城订单提醒', $body); } // 短信提醒 if (!empty($this->module['config']['mobile'])) { load()->model('cloud'); $body = str_replace(array('<h3>', '</h3>', '<br />'), array('', '', "\n"), $body); cloud_sms_send($this->module['config']['mobile'], $body); } } //支付成功,打印订单 if (empty($order)) { exit('订单不存在或已经删除'); } //获取所有打印机 $prints = pdo_fetchall('SELECT * FROM ' . tablename('shopping_print') . ' WHERE uniacid = :aid AND status = 1', array(':aid' => $_W['uniacid'])); if (empty($prints)) { // exit('没有有效的打印机'); } $orderinfo = ''; $orderinfo .= '名称 单价 数量 金额<BR>'; $orderinfo .= '--------------------------------<BR>'; foreach ($goods as $row) { $orderInfo .= "{$row['title']}{$row['marketprice']}{$ordergoods[$row['id']]['total']}{$order['price']} <br />"; } $orderInfo .= '--------------------------------<BR>'; $orderinfo .= "合计:{$order['price']}元<BR>"; $orderinfo .= "下单人:{$address['realname']}<BR>"; $orderinfo .= "地址:{$address['province']} - {$address['city']} - {$address['area']} {$address['address']} <BR>"; $orderinfo .= "联系电话:{$address['mobile']}<BR>"; $orderinfo .= "支付方式:{$order['paytype']}<BR>"; include 'wprint.class.php'; //遍历所有打印机 foreach ($prints as $li) { if (!empty($li['qrcode_link'])) { $orderinfo .= "<QR>{$li['qrcode_link']}</QR>"; } if (!empty($li['print_no']) && !empty($li['key'])) { $wprint = new wprint(); $status = $wprint->StrPrint($li['print_no'], $li['key'], $orderinfo, 1); if (!is_error($status)) { $i++; $data = array('uniacid' => $_W['uniacid'], 'sid' => $sid, 'pid' => $li['id'], 'oid' => $id, 'status' => 1, 'foid' => $status, 'addtime' => TIMESTAMP); pdo_insert('shopping_order_print', $data); } } } // if($i > 0) { // pdo_query('UPDATE ' . tablename('str_order') . " SET print_nums = print_nums + {$i} WHERE uniacid = {$_W['uniacid']} AND id = {$id}"); // } else { // exit('发送打印指令失败。没有有效的机器号'); // } // exit('success'); //打印结束 $setting = uni_setting($_W['uniacid'], array('creditbehaviors')); $credit = $setting['creditbehaviors']['currency']; if ($params['type'] == $credit) { message('支付成功!', $this->createMobileUrl('myorder'), 'success'); } else { message('支付成功!', '../../app/' . $this->createMobileUrl('myorder'), 'success'); } } }
public function doMobileResearch() { global $_W, $_GPC; $reid = intval($_GPC['id']); $sql = 'SELECT * FROM ' . tablename('research') . ' WHERE `weid`=:weid AND `reid`=:reid'; $params = array(); $params[':weid'] = $_W['uniacid']; $params[':reid'] = $reid; $activity = pdo_fetch($sql, $params); if (empty($_W['fans']['openid'])) { message('请先关注公众号再来参加活动吧!'); } if ($activity['status'] != '1') { message('当前预约活动已经停止.'); } if (!$activity) { message('非法访问.'); } if ($activity['starttime'] > TIMESTAMP) { message('当前预约活动还未开始!'); } if ($activity['endtime'] < TIMESTAMP) { message('当前预约活动已经结束!'); } $title = $activity['title']; $sql = 'SELECT * FROM ' . tablename('research_fields') . ' WHERE `reid` = :reid ORDER BY `displayorder` DESC, `refid`'; $params = array(); $params[':reid'] = $reid; $ds = pdo_fetchall($sql, $params); if (!$ds) { message('非法访问.'); } $initRange = $initCalendar = false; $binds = array(); foreach ($ds as &$r) { if ($r['type'] == 'range') { $initRange = true; } if ($r['type'] == 'calendar') { $initCalendar = true; } if ($r['value']) { $r['options'] = explode(',', $r['value']); } if ($r['bind']) { $binds[$r['type']] = $r['bind']; } if ($r['type'] == 'reside') { $reside = $r; } } if (checksubmit('submit')) { $sql = 'SELECT COUNT(*) FROM ' . tablename('research_rows') . ' WHERE `reid` = :reid AND `openid` = :openid'; $params = array(':reid' => $reid, ':openid' => $_W['fans']['from_user']); $pretotal = pdo_fetchcolumn($sql, $params); if ($pretotal >= $activity['pretotal']) { message('抱歉,每人只能预约' . $activity['pretotal'] . "次!", referer(), 'error'); } $sql = 'SELECT `rerid` FROM ' . tablename('research_rows') . ' WHERE `reid` = :reid GROUP BY `openid`'; unset($params[':openid']); $allTotal = pdo_fetchall($sql, $params); if (count($allTotal) >= $activity['alltotal']) { pdo_update('research', array('endtime' => TIMESTAMP), array('reid' => $reid)); message('当前预约活动已经结束!'); } $row = array(); $row['reid'] = $reid; $row['openid'] = $_W['fans']['from_user']; $row['createtime'] = TIMESTAMP; $datas = $fields = $update = array(); foreach ($ds as $value) { $fields[$value['refid']] = $value; } foreach ($_GPC as $key => $value) { if (strexists($key, 'field_')) { $bindFiled = substr(strrchr($key, '_'), 1); if (!empty($bindFiled)) { $update[$bindFiled] = $value; } $refid = intval(str_replace('field_', '', $key)); $field = $fields[$refid]; if ($refid && $field) { $entry = array(); $entry['reid'] = $reid; $entry['rerid'] = 0; $entry['refid'] = $refid; if (in_array($field['type'], array('number', 'text', 'calendar', 'email', 'textarea', 'radio', 'range', 'select', 'image'))) { $entry['data'] = strval($value); } if (in_array($field['type'], array('checkbox'))) { if (!is_array($value)) { continue; } $entry['data'] = implode(';', $value); } $datas[] = $entry; } } } if ($_FILES) { load()->func('file'); foreach ($_FILES as $key => $file) { if (strexists($key, 'field_')) { $refid = intval(str_replace('field_', '', $key)); $field = $fields[$refid]; if ($refid && $field && $file['name'] && $field['type'] == 'image') { $entry = array(); $entry['reid'] = $reid; $entry['rerid'] = 0; $entry['refid'] = $refid; $ret = file_upload($file); if (!$ret['success']) { message('上传图片失败, 请稍后重试.'); } $entry['data'] = trim($ret['path']); $datas[] = $entry; } } } } // 兼容会员居住地字段 if (!empty($_GPC['reside'])) { if (in_array('reside', $binds)) { $update['resideprovince'] = $_GPC['reside']['province']; $update['residecity'] = $_GPC['reside']['city']; $update['residedist'] = $_GPC['reside']['district']; } foreach ($_GPC['reside'] as $key => $value) { $resideData = array('reid' => $reside['reid']); $resideData['rerid'] = 0; $resideData['refid'] = $reside['refid']; $resideData['data'] = $value; $datas[] = $resideData; } } // 更新关联会员资料 if (!empty($update)) { load()->model('mc'); mc_update($_W['member']['uid'], $update); } if (empty($datas)) { message('非法访问.', '', 'error'); } if (pdo_insert('research_rows', $row) != 1) { message('保存失败.'); } $rerid = pdo_insertid(); if (empty($rerid)) { message('保存失败.'); } foreach ($datas as &$r) { $r['rerid'] = $rerid; pdo_insert('research_data', $r); } if (empty($activity['starttime'])) { $record = array(); $record['starttime'] = TIMESTAMP; pdo_update('research', $record, array('reid' => $reid)); } if (!empty($datas)) { $image = $body = ''; foreach ($datas as $row) { if (substr($row['data'], 0, 6) != 'images') { $body .= '<h4>' . $fields[$row['refid']]['title'] . ':' . $row['data'] . '</h4>'; } else { $image .= '<p>' . $fields[$row['refid']]['title'] . ': <img src="' . tomedia($row['data']) . '" /></p>'; } } // 发送邮件提醒 if (!empty($activity['noticeemail'])) { load()->func('communication'); ihttp_email($activity['noticeemail'], $activity['title'] . '的预约提醒', $image . $body); } // 发送短信提醒 if (!empty($activity['mobile'])) { load()->model('cloud'); cloud_prepare(); $body = '项目' . $activity['title'] . '于' . date('Y-m-d H:i') . '有了新的预约信息,请到后台查看具体内容.' . random(3); cloud_sms_send($activity['mobile'], $body); } } message($activity['information'], 'refresh'); } // 兼容会员居住地字段 foreach ($binds as $key => $value) { if ($value == 'reside') { unset($binds[$key]); $binds[] = 'resideprovince'; $binds[] = 'residecity'; $binds[] = 'residedist'; break; } } if (!empty($_W['fans']['from_user']) && !empty($binds)) { $profile = fans_search($_W['fans']['from_user'], $binds); if ($profile['gender']) { if ($profile['gender'] == '0') { $profile['gender'] = '保密'; } if ($profile['gender'] == '1') { $profile['gender'] = '男'; } if ($profile['gender'] == '2') { $profile['gender'] = '女'; } } foreach ($ds as &$r) { if ($profile[$r['bind']]) { $r['default'] = $profile[$r['bind']]; } } } load()->func('tpl'); include $this->template('submit'); }
$code = random(6, true); $record['uniacid'] = $_W['uniacid']; $record['receiver'] = $receiver; $record['verifycode'] = $code; $record['total'] = 1; $record['createtime'] = TIMESTAMP; } if (!empty($row)) { pdo_update('uni_verifycode', $record, array('id' => $row['id'])); } else { pdo_insert('uni_verifycode', $record); } if ($receiver_type == 'email') { load()->func('communication'); $content = "您的邮箱验证码为: {$code} 您正在使用{$uniacid_arr['name']}相关功能, 需要你进行身份确认."; $result = ihttp_email($receiver, "{$uniacid_arr['name']}身份确认验证码", $content); } else { load()->model('cloud'); $r = cloud_prepare(); if (is_error($r)) { exit($r['message']); } $setting = uni_setting($_W['uniacid'], 'notify'); $content = "您的短信验证码为: {$code} 您正在使用{$uniacid_arr['name']}相关功能, 需要你进行身份确认. " . random(3); $result = cloud_sms_send($receiver, $content); } if (is_error($result)) { header('error: ' . urlencode($result['message'])); exit($result['message']); } exit('success');
exit('error-limit'); } $code = $row['verifycode']; $record['total']++; } else { $code = random(6, true); $record['uniacid'] = $_W['uniacid']; $record['receiver'] = $post['no']; $record['verifycode'] = $code; $record['total'] = 1; $record['createtime'] = TIMESTAMP; } if ($post['type'] == 'email') { $content = "您的邮箱验证码为: {$code} 您正在使用{$_W['account']['name']}相关功能, 需要你进行身份确认."; $result = ihttp_email($post['no'], "{$_W['account']['name']}身份确认验证码", $content); } else { require model('cloud'); $content = "您的短信验证码为: {$code} 您正在使用{$_W['account']['name']}相关功能, 需要你进行身份确认.【WORMWOOD】"; $result = cloud_sms_send($post['no'], $content); } if (is_error($result)) { header('error: ' . urlencode($result['message'])); exit('error-fail'); } else { if (!empty($row)) { pdo_update('uni_verifycode', $record, array('id' => $row['id'])); } else { pdo_insert('uni_verifycode', $record); } } exit('success');
public function payResult($params) { global $_W; $fee = intval($params['fee']); $data = array('status' => $params['result'] == 'success' ? 1 : 0); $paytype = array('credit' => '1', 'wechat' => '2', 'alipay' => '2', 'delivery' => '3'); // 卡券代金券备注 if (!empty($params['is_usecard'])) { $cardType = array('1' => '微信卡券', '2' => '系统代金券'); $data['paydetail'] = '使用' . $cardType[$params['card_type']] . '支付了' . ($params['fee'] - $params['card_fee']); $data['paydetail'] .= '元,实际支付了' . $params['card_fee'] . '元。'; } $data['paytype'] = $paytype[$params['type']]; if ($params['type'] == 'wechat') { $data['transid'] = $params['tag']['transaction_id']; } if ($params['type'] == 'delivery') { $data['status'] = 1; } $goods = pdo_fetchall("SELECT `goodsid`, `total` FROM " . tablename('shopping_order_goods') . " WHERE `orderid` = :orderid", array(':orderid' => $params['tid'])); if (!empty($goods)) { $row = array(); foreach ($goods as $row) { $goodsInfo = pdo_fetch("SELECT `total`, `totalcnf`, `sales` FROM " . tablename('shopping_goods') . " WHERE `id` = :id", array(':id' => $row['goodsid'])); $goodsupdate = array(); if ($goodsInfo['totalcnf'] == '1' && !empty($goodsInfo['total'])) { $goodsupdate['total'] = $goodsInfo['total'] - $row['total']; $goodsupdate['total'] = $goodsupdate['total'] < 0 ? 0 : $goodsupdate['total']; } $goodsupdate['sales'] = $goodsInfo['sales'] + $row['total']; pdo_update('shopping_goods', $goodsupdate, array('id' => $row['goodsid'])); } } pdo_update('shopping_order', $data, array('id' => $params['tid'])); if ($params['from'] == 'return') { //积分变更 $this->setOrderCredit($params['tid']); if (!empty($this->module['config']['noticeemail']) || !empty($this->module['config']['mobile'])) { $order = pdo_fetch("SELECT `ordersn`, `price`, `paytype`, `from_user`, `address`, `createtime` FROM " . tablename('shopping_order') . " WHERE id = '{$params['tid']}'"); $ordergoods = pdo_fetchall("SELECT goodsid, total FROM " . tablename('shopping_order_goods') . " WHERE orderid = '{$params['tid']}'", array(), 'goodsid'); $goods = pdo_fetchall("SELECT id, title, thumb, marketprice, unit, total FROM " . tablename('shopping_goods') . " WHERE id IN ('" . implode("','", array_keys($ordergoods)) . "')"); // $address = pdo_fetch("SELECT * FROM " . tablename('mc_member_address') . " WHERE id = :id", array(':id' => $order['addressid'])); $address = explode('|', $order['address']); // 邮件提醒 if (!empty($this->module['config']['noticeemail'])) { $body = "<h3>购买商品清单</h3> <br />"; if (!empty($goods)) { foreach ($goods as $row) { $body .= "名称:{$row['title']} ,数量:{$ordergoods[$row['id']]['total']} <br />"; } } $paytype = $order['paytype'] == '3' ? '货到付款' : '已付款' . '<br />'; $body .= '总金额:' . $order['price'] . '元' . $paytype . '<br />'; $body .= '<h3>购买用户详情</h3> <br />'; $body .= '真实姓名:' . $address[0] . '<br />'; $body .= '地区:' . $address[3] . ' - ' . $address[4] . ' - ' . $address[5] . '<br />'; $body .= '详细地址:' . $address[6] . '<br />'; $body .= '手机:' . $address[1] . '<br />'; load()->func('communication'); ihttp_email($this->module['config']['noticeemail'], '微商城订单提醒', $body); } // 短信提醒 if (!empty($this->module['config']['mobile'])) { load()->model('cloud'); cloud_prepare(); $body = '用户' . $address[0] . ',电话:' . $address[1] . '于' . date('m月d日H:i') . '成功支付订单' . $order['ordersn'] . ',总金额' . $order['price'] . '元' . '.' . random(3); cloud_sms_send($this->module['config']['mobile'], $body); } } $setting = uni_setting($_W['uniacid'], array('creditbehaviors')); $credit = $setting['creditbehaviors']['currency']; if ($params['type'] == $credit) { message('支付成功!', $this->createMobileUrl('myorder'), 'success'); } else { message('支付成功!', '../../app/' . $this->createMobileUrl('myorder'), 'success'); } } }