chore: 删除ewei_shopv2目录

This commit is contained in:
2025-11-15 13:53:42 +08:00
parent 57dea2ca87
commit cbc4529a34
69122 changed files with 0 additions and 1407557 deletions

View File

@@ -1,53 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="15;url=http://www.www.pnp8.com/">
<title>您所下载的资源-来源于易源码pnp8.com资源</title>
<meta name="keywords" content="网站源码,小程序源码,源码资源,微擎小程序,微信小程序,PHP源码,公众号应用,html模板,应用模块,易源码pnp8.com" />
<meta name="description" content="
易源码pnp8.com(www.www.pnp8.com)旨为互联网从业者提供精品源码下载和建站资源的交流分享,包括网站源码、微信应用、小程序源码、公众号应用、微擎微赞模块、商城系统、资讯教程、工具软件等站长资源。" />
<meta name="Copyright" content="易源码pnp8.com-优质建站资源" />
<style>
body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{margin:0;padding:0;word-wrap:break-word}
body,html,input{font:12px/1.5 "Microsoft YaHei",Verdana,tahoma,arial,\5b8b\4f53,sans-serif;}
a,a:link,a:visited,a:active{text-decoration:none;word-wrap:break-word}
a:hover {color:#f63;text-decoration:none}
h1,h2,h3,h4,h5,h6{font-size:100%;}
#content{ width:620px; margin:0 auto; padding-top:10px; }
#logo {margin:0 auto;width:250px; padding-bottom:15px;}
#content h1{ height:50px; background:#0093DD; line-height:50px; font-size:16px; color:#fff; border-radius:10px; box-shadow: 3px 5px 6px rgba(0, 0, 0, 0.4);text-align:center; display:block; margin-bottom:20px;}
#content a{ color:#f63; font-size:16px;}
#content p{ line-height:26px; color:#333; text-indent:2em; font-size:14px;}
.grey {COLOR: #ACACAC; border-top:2px solid #CCC; line-height:30px; margin-top:10px;}
.grey A:hover {COLOR: #DDD; TEXT-DECORATION: underline}
</style>
</head>
<body>
<!-- 易源码pnp8.com-优质建站资源 www.www.pnp8.com -->
<div id="content">
<div id="logo"></div>
<h1>您所下载的资源-来源于易源码pnp8.com资源</h1>
<p>易源码pnp8.com资源【<a href="http://www.www.pnp8.com/" target="_blank" title="易源码pnp8.com-优质建站资源">www.www.pnp8.com</a>】)是一个旨为互联网从业者提供精品源码下载和建站资源的交流分享,包括网站源码、微信应用、小程序源码、公众号应用、微擎微赞模块、商城系统、资讯教程、工具软件等站长资源。</p>
<p><strong>下载声明:</strong></p>
<p>1、本站所有素材资源包括素材、软件、学习资料等仅供学习与参考请勿用于商业用途。如本站不慎侵犯您的版权请联系我们我们将及时处理并撤下相关内容</p>
<p>2、访问本站的用户必须明白本站对所提供下载的软件和程序代码不拥有任何权利其版权归该软件和程序代码的合法拥有者所有请用户在下载使用前必须详细阅读并遵守软件作者的“使用许可协议”,本站仅仅是一个学习交流的平台。</p>
<p>3、如下载的压缩包需要解压密码若无特殊说明那么文件的解压密码则为www.www.pnp8.com</p>
<p><strong>关键词:</strong>易源码pnp8.com资源,站长论坛,商业源码VIP源码,网站源码下载,源码交伍六一,源码下载,企业公司源码</p>
<div class="grey">Copyright &copy; 2020 www.www.pnp8.com All rights reserved.</div>
</div>
<script type="text/javascript" src=""></script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>

View File

@@ -1,21 +0,0 @@
<p>// +----------------------------------------------------------------------
</p>
<p>// | Program Name: <EFBFBD><EFBFBD>ӭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>վ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>pnp8.comwww. pnp8 .com <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧϰ<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD> </p>
<p>// +---------------------------------------------------------------------- </p>
<p>// | Copyright: (c) 2013-2019 http://www.www.pnp8.com! All rights reserved. </p>
<p>// +---------------------------------------------------------------------- </p>
<p>// | Developer: <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>pnp8.comwww .pnp8 .com Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳ </p>
<p>// +---------------------------------------------------------------------- </p>
<p>* <EFBFBD><EFBFBD>л֧<EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>վ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD> </p>
<p>* <EFBFBD><EFBFBD>ӭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>VIP<EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </p>

View File

@@ -1 +0,0 @@
/core/ping.php

View File

@@ -1 +0,0 @@
支付目录

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class H5app_EweiShopV2ComModel extends ComModel
{}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,213 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Qiniu_EweiShopV2ComModel extends ComModel
{
public function save($url, $config = NULL, $enforce = false)
{
global $_W;
global $_GPC;
$oldurl = $url;
set_time_limit(0);
if (empty($url)) {
return '';
}
$ext = strrchr($url, '.');
if (($ext != '.jpeg') && ($ext != '.gif') && ($ext != '.jpg') && ($ext != '.png')) {
return '';
}
if (!$config) {
$config = $this->getConfig();
}
if (empty($config)) {
if (!empty($_W['setting']['remote']['type']) && !(strexists($url, 'http:') || strexists($url, 'https:'))) {
if (is_file(ATTACHMENT_ROOT . $url)) {
load()->func('file');
$remotestatus = file_remote_upload($url, false);
if (is_error($remotestatus)) {
return $url;
}
}
$remoteurl = $_W['attachurl_remote'] . $url;
return $remoteurl;
}
return $url;
}
if (strexists($url, $config['url'])) {
return $url;
}
if (strexists($url, '../addons/ewei_shopv2')) {
$url = str_replace('../addons/ewei_shopv2', 'addons/ewei_shopv2', $url);
}
if (!strexists($url, 'addons/ewei_shopv2')) {
$url = tomedia($url);
}
if (!empty($_W['setting']['remote']['type'])) {
$enforce = true;
}
$outlinkEnforce = false;
if (!strexists($url, $_W['siteroot'])) {
if (strexists($url, 'http:') || strexists($url, 'https:')) {
if (!$enforce) {
return $url;
}
$outlinkEnforce = true;
}
}
if (!$outlinkEnforce) {
if (strexists($url, 'http:') || strexists($url, 'https:')) {
if (!strexists($url, 'addons/ewei_shopv2')) {
$url = ATTACHMENT_ROOT . str_replace($_W['siteroot'] . 'attachment/', '', str_replace($_W['attachurl'], '', $url));
}
else {
$url = IA_ROOT . '/' . $url;
}
}
else {
$outlinkEnforce = true;
if (strexists($url, 'addons/ewei_shopv2')) {
$url = IA_ROOT . '/' . $url;
$outlinkEnforce = false;
}
}
}
$key = ($outlinkEnforce ? md5($url) : md5_file($url)) . $ext;
if ($outlinkEnforce) {
$local = ATTACHMENT_ROOT . 'ewei_shopv2_temp/';
load()->func('file');
if (!is_dir($local)) {
mkdirs($local);
}
$filename = $local . $key;
load()->func('communication');
$resp = ihttp_get($url);
if ($resp['code'] != 200) {
return $oldurl;
}
file_put_contents($filename, $resp['content']);
$url = $filename;
}
require_once IA_ROOT . '/framework/library/qiniu/autoload.php';
$auth = new \Qiniu\Auth($config['access_key'], $config['secret_key']);
if (is_callable('\\Qiniu\\Zone::zone0')) {
$zone = \Qiniu\Zone::zone0();
if ($config['zone'] == 'zone1') {
$zone = \Qiniu\Zone::zone1();
}
$uploadmgr = new \Qiniu\Storage\UploadManager(new \Qiniu\Config($zone));
$putpolicy = \Qiniu\base64_urlSafeEncode(json_encode(array('scope' => $config['bucket'] . ':' . $url)));
$uploadtoken = $auth->uploadToken($config['bucket'], $key, 3600, $putpolicy);
}
else {
$uploadmgr = new \Qiniu\Storage\UploadManager();
$uploadtoken = $auth->uploadToken($config['bucket'], $key, 3600);
}
$ret = $uploadmgr->putFile($uploadtoken, $key, $url);
if (!empty($ret[1])) {
$err = $ret[1]->getResponse()->error;
return error(1, $err);
}
if ($outlinkEnforce) {
@unlink($url);
}
if (strexists($config['url'], 'http:') || strexists($config['url'], 'https:')) {
return trim($config['url']) . '/' . $ret[0]['key'];
}
return 'http://' . trim($config['url']) . '/' . $ret[0]['key'];
}
/**
* 获取配置
* @return boolean
*/
public function getConfig()
{
global $_W;
global $_GPC;
$config = false;
$set = m('common')->getSysset('qiniu');
if (isset($set['user']) && is_array($set['user']) && !empty($set['user']['upload']) && !empty($set['user']['access_key']) && !empty($set['user']['secret_key']) && !empty($set['user']['bucket']) && !empty($set['user']['url'])) {
$config = $set['user'];
}
else {
$path = IA_ROOT . '/addons/ewei_shopv2/data/global';
$admin = m('cache')->getArray('qiniu', 'global');
if (empty($admin['upload']) && is_file($path . '/qiniu.cache')) {
$data_authcode = authcode(file_get_contents($path . '/qiniu.cache'), 'DECODE', 'global');
$admin = json_decode($data_authcode, true);
}
if (is_array($admin) && !empty($admin['upload']) && !empty($admin['access_key']) && !empty($admin['secret_key']) && !empty($admin['bucket']) && !empty($admin['url'])) {
$config = $admin;
}
}
return $config;
}
public function deletewqfile($attachment)
{
global $_W;
$attachment = trim($attachment);
$media = pdo_get('core_attachment', array('uniacid' => $_W['uniacid'], 'attachment' => $attachment));
if (empty($media)) {
return false;
}
if (empty($_W['isfounder']) && ($_W['role'] != 'manager')) {
return false;
}
load()->func('file');
if (!empty($_W['setting']['remote']['type'])) {
$status = file_remote_delete($media['attachment']);
}
else {
$status = file_delete($media['attachment']);
}
if (is_error($status)) {
return $status['message'];
}
pdo_delete('core_attachment', array('uniacid' => $_W['uniacid'], 'id' => $media['id']));
return true;
}
}
?>

View File

@@ -1,195 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
function sort_enoughs($a, $b) {
$enough1 = floatval($a['enough']);
$enough2 = floatval($b['enough']);
if ( $enough1==$enough2) {
return 0;
} else {
return ($enough1 < $enough2) ? 1 : -1;
}
}
class Sale_EweiShopV2ComModel extends ComModel {
public function getEnoughsGoods() {
global $_W,$_S;
$set = $_S['sale'];
$goodsids = $set['goodsids'];
return $goodsids;
}
public function getEnoughs() {
global $_W,$_S;
$set = $_S['sale'];
$allenoughs = array();
$enoughs = $set['enoughs'];
if (floatval($set['enoughmoney']) > 0 && floatval($set['enoughdeduct']) > 0) {
$allenoughs[] = array('enough' => floatval($set['enoughmoney']), 'money' => floatval($set['enoughdeduct']));
}
if (is_array($enoughs)) {
foreach ($enoughs as $e) {
if (floatval($e['enough']) > 0 && floatval($e['give']) > 0) {
$allenoughs[] = array('enough' => floatval($e['enough']), 'money' => floatval($e['give']));
}
}
}
usort($allenoughs, "sort_enoughs");
return $allenoughs;
}
public function getEnoughFree(){
global $_W,$_S;
$set = $_S['sale'];
if(!empty($set['enoughfree'])){
return $set['enoughorder']>0?$set['enoughorder']:-1;
}
return false;
}
public function getRechargeActivity() {
global $_S;
$set = $_S['sale'];
$recharges = iunserializer($set['recharges']);
if (is_array($recharges)) {
usort($recharges, "sort_enoughs");
return $recharges;
}
return false;
}
public function setRechargeActivity($log) {
global $_W,$_S;
$set = m('common')->getPluginset('sale');
$recharges = iunserializer($set['recharges']);
$credit2 = 0;
$enough = 0;
$give = '';
if (is_array($recharges)) {
usort($recharges, "sort_enoughs");
foreach ($recharges as $r) {
if (empty($r['enough']) || empty($r['give'])) {
continue;
}
if ($log['money'] >= floatval($r['enough'])) {
if (strexists($r['give'], '%')) {
$credit2 = round(floatval(str_replace('%', '', $r['give'])) / 100 * $log['money'], 2);
} else {
$credit2 = round(floatval($r['give']), 2);
}
$enough = floatval($r['enough']);
$give = $r['give'];
break;
}
}
}
if ($credit2 > 0) {
m('member')->setCredit($log['openid'], 'credit2', $credit2, array('0', $_S['shop']['name'] . '充值满' . $enough . '赠送' . $give, '现金活动'));
pdo_update('ewei_shop_member_log', array('gives' => $credit2), array('id' => $log['id']));
}
$this->getCredit1($log['openid'],$log['money'],21,2);
}
public function getCredit1($openid,$price = 0,$paytype = 1,$type=1,$refund=0,$desc = '') {
global $_W;
$type = intval($type);
if (empty($openid) || empty($price) || empty($type)){
return 0;
}
$data = m('common')->getPluginset('sale');
$credit1 = iunserializer($data['credit1']);
if ($type == '1'){
$name = '积分活动购物送积分';
$enoughs = empty($credit1['enough1']) ? array() : $credit1['enough1'];
if (empty($credit1['paytype'])){
return 0;
}
if (!empty($credit1['paytype']) && !in_array($paytype,array_keys($credit1['paytype']))){
return 0;
}
}elseif ($type='2'){
$name = '积分活动充值送积分';
$enoughs = empty($credit1['enough2']) ? array() : $credit1['enough2'];
}
if (!empty($desc)){
$name = $desc;
}
$allenoughs = array();
if (is_array($enoughs)) {
foreach ($enoughs as $e) {
if (floatval($e['enough'.$type.'_1'])<=$price && floatval($e['enough'.$type.'_2'])>=$price){
if (floatval($e['give'.$type]) > 0) {
$allenoughs[] = floatval($e['give'.$type]);
}
}
}
}
$money = 0;
if (!empty($allenoughs)){
$money = (float)max($allenoughs);
}
if ($money>0){
$money *= $price;
$money = floor($money);
if (empty($refund)){
m('member')->setCredit($openid,'credit1',$money,$name.': '.$money.'积分');
}else{
m('member')->setCredit($openid,'credit1',-$money,$name.'退款 : '.-$money.'积分');
}
}
return $money;
}
public function getPeerPay()
{
global $_W;
$res = array(
'万水千山总是情,这单帮我一定行',
array(
'无名侠',
'支持一下,么么哒!'
),
'self_peerpay'=>0,
'peerpay_price'=>0,
'peerpay_privilege'=>0,
);
$data = m('common')->getPluginset('sale');
$data = $data['peerpay'];
if (empty($data['open'])){
return false;
}
$enough1 = empty($data['enough1']) ? array() : $data['enough1'];
$enough2 = empty($data['enough2']) ? array() : $data['enough2'];
if (!empty($enough1)){
$key = array_rand($enough1);
$res[0] = $enough1[$key];
}
if (!empty($enough2)){
$key = array_rand($enough2);
$res[1][0] = $enough2[$key]['enough2_1'];
$res[1][1] = $enough2[$key]['enough2_2'];
}
if (!empty($data['self_peerpay'])){
$res['self_peerpay'] = (float)$data['self_peerpay'];
}
if (!empty($data['peerpay_price'])){
$res['peerpay_price'] = (float)$data['peerpay_price'];
$res['peerpay_privilege'] = (float)$data['peerpay_privilege'];
}
return $res;
}
}

View File

@@ -1,194 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Sendticket_EweiShopV2ComModel extends ComModel {
function getInfo(){
global $_W,$_GPC;
$openid = $_W['openid'];
if(!com('coupon')){
return false;
}
$member = m('member')->getMember($_W['openid']);
$condition = ' WHERE uniacid = :uniacid AND openid = :openid';
$paramso = array(
':uniacid' => intval($_W['uniacid']),
':openid' => trim($openid),
);
$osql = 'SELECT * FROM '.tablename('ewei_shop_order').$condition;
$order = pdo_fetchall($osql,$paramso);
if (empty($order)) {
$sql2 = 'SELECT * FROM '.tablename('ewei_shop_sendticket').' WHERE uniacid = '.intval($_W['uniacid']);
$ticket = pdo_fetch($sql2);
if ($ticket['status'] == 1) {
if ($ticket['expiration'] == 1) {
if (TIMESTAMP > $ticket['endtime']) {
$status = array('status' => 0);
pdo_update('ewei_shop_sendticket',$status,array('id' => $ticket['id']));
return false;
} else {
$cpinfo = $this -> getCoupon($ticket['cpid']);
if (empty($cpinfo)) {
return false;
} else {
$insert = $this -> insertDraw($openid,$cpinfo);
if ($insert) {
if(count($cpinfo) == count($cpinfo, 1)){
$status = $this -> sendTicket($openid,$cpinfo['id'],14);
if (!$status) {
return false;
} else {
$cpinfo['did'] = $status;
}
}else{
foreach ($cpinfo as $cpk => $cpv) {
$status = $this -> sendTicket($openid,$cpv['id'],14);
if (!$status) {
return false;
} else {
$cpinfo[$cpk]['did'] = $status;
}
}
}
return $cpinfo;
} else {
return false;
}
}
}
} else {
$cpinfo = $this -> getCoupon($ticket['cpid']);
if (empty($cpinfo)) {
return false;
} else {
$insert = $this -> insertDraw($openid,$cpinfo);
if ($insert) {
if(count($cpinfo) == count($cpinfo, 1)){
$status = $this -> sendTicket($openid,$cpinfo['id'],14);
if (!$status) {
return false;
} else {
$cpinfo['did'] = $status;
}
}else{
foreach ($cpinfo as $cpk => $cpv) {
$status = $this -> sendTicket($openid,$cpv['id'],14);
if (!$status) {
return false;
} else {
$cpinfo[$cpk]['did'] = $status;
}
}
}
return $cpinfo;
} else {
return false;
}
}
}
} else if ($ticket['status'] == 0) {
return false;
}
} else {
return false;
}
}
function getCoupon($cpid){
global $_W,$_GPC;
if (strpos($cpid,',')) {
$cpids = explode(',',$cpid);
} else {
$cpids = $cpid;
}
if(is_array($cpids)){
$cpinfo = array();
foreach ($cpids as $cpk => $cpv) {
$cpsql = 'SELECT * FROM '.tablename('ewei_shop_coupon').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.intval($cpv);
$list = pdo_fetch($cpsql);
if($list['timelimit'] == 1) {
if (TIMESTAMP < $list['timeend']) {
$cpinfo[$cpk] = $list;
}
}else if($list['timelimit'] == 0){
$cpinfo[$cpk] = $list;
}
}
return $cpinfo;
}else {
$cpsql = 'SELECT * FROM '.tablename('ewei_shop_coupon').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.intval($cpid);
$cpinfo = pdo_fetch($cpsql);
return $cpinfo;
}
}
function sendTicket($openid, $couponid,$gettype=0) {
global $_W, $_GPC;
$couponlog = array(
'uniacid' => $_W['uniacid'],
'openid' => $openid,
'logno' => m('common')->createNO('coupon_log', 'logno', 'CC'),
'couponid' => $couponid,
'status' => 1,
'paystatus' => -1,
'creditstatus' => -1,
'createtime' => time(),
'getfrom' => 3
);
$log = pdo_insert('ewei_shop_coupon_log', $couponlog);
$data = array(
'uniacid' => $_W['uniacid'],
'openid' => $openid,
'couponid' => $couponid,
'gettype' => $gettype,
'gettime' => time()
);
$data = pdo_insert('ewei_shop_coupon_data', $data);
$did = pdo_insertid();
if ($log && $data) {
return $did;
} else {
return false;
}
}
function share($money){
$activity = $this -> activity($money);
if (!empty($activity)) {
return true;
}else{
return false;
}
}
function activity($money){
global $_W;
$sql = 'SELECT * FROM '.tablename('ewei_shop_sendticket_share').' WHERE uniacid = '.intval($_W['uniacid']).' AND status = 1 AND (enough = '.$money.' OR enough <= '.$money.') AND (expiration = 0 OR (expiration = 1 AND endtime >= '.TIMESTAMP.')) ORDER BY enough DESC,createtime DESC LIMIT 1';
$activity = pdo_fetch($sql);
return $activity;
}
}

View File

@@ -1,403 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Sms_EweiShopV2ComModel extends ComModel
{
/**
* 发送短信
* @param int $mobile 手机号
* @param string $tplid 商城短信模板iID
* @param array $data 发送数据 $replace=true $data替换模板数据 $replace=false 则直接使用$data作为发送数据
* @param true $replace 是否替换数据
* @return array return status
*/
public function send($mobile, $tplid, $data, $replace = true)
{
global $_W;
$smsset = $this->sms_set();
$template = $this->sms_verify($tplid, $smsset);
if (empty($template['status'])) {
return $template;
}
if ($template['type'] == 'aliyun_new' || $template['type'] == 'aliyun') {
foreach ($data as $key => $val) {
if (20 < mb_strlen($val)) {
$data[$key] = mb_substr($val, 0, 7, 'UTF-8') . '....' . mb_substr($val, -8, NULL, 'UTF-8');
}
}
}
$params = $this->sms_data($template['type'], $data, $replace, $template);
if ($template['type'] == 'juhe') {
$data = array('mobile' => $mobile, 'tpl_id' => $template['smstplid'], 'tpl_value' => $params, 'key' => $smsset['juhe_key']);
load()->func('communication');
$result = ihttp_post('http://v.juhe.cn/sms/send', $data);
$result = json_decode($result['content'], true);
if (empty($result) || isset($result['error_code']) && 0 < $result['error_code']) {
return array('status' => 0, 'message' => '短信发送失败(' . $result['error_code'] . ')' . $result['reason']);
}
}
else if ($template['type'] == 'dayu') {
include_once EWEI_SHOPV2_VENDOR . 'dayu/TopSdk.php';
$dayuClient = new TopClient();
$dayuClient->appkey = $smsset['dayu_key'];
$dayuClient->secretKey = $smsset['dayu_secret'];
$dayuRequest = new AlibabaAliqinFcSmsNumSendRequest();
$dayuRequest->setSmsType('normal');
$dayuRequest->setSmsFreeSignName($template['smssign']);
$dayuRequest->setSmsParam($params);
$dayuRequest->setRecNum('' . $mobile);
$dayuRequest->setSmsTemplateCode($template['smstplid']);
$dayuResult = $dayuClient->execute($dayuRequest);
$dayuResult = (array) $dayuResult;
if (empty($dayuResult) || !empty($dayuResult['code'])) {
return array('status' => 0, 'message' => '短信发送失败(' . $dayuResult['sub_msg'] . '/code: ' . $dayuResult['code'] . '/sub_code: ' . $dayuResult['sub_code'] . ')');
}
}
else if ($template['type'] == 'aliyun') {
load()->func('communication');
$paramstr = http_build_query(array('ParamString' => $params, 'RecNum' => $mobile, 'SignName' => $template['smssign'], 'TemplateCode' => $template['smstplid']));
$header = array('Authorization' => 'APPCODE ' . $smsset['aliyun_appcode']);
$request = ihttp_request('http://sms.market.alicloudapi.com/singleSendSms?' . $paramstr, '', $header);
$result = json_decode($request['content'], true);
if (!$result['success'] || $request['code'] != 200) {
if ($request['code'] != 200) {
$result['message'] = $request['headers']['X-Ca-Error-Message'];
}
return array('status' => 0, 'message' => '短信发送失败(错误信息: ' . $result['message'] . ')');
}
}
else if ($template['type'] == 'aliyun_new') {
include_once EWEI_SHOPV2_VENDOR . 'aliyun/sendSms.php';
$option = array('keyid' => $smsset['aliyun_new_keyid'], 'keysecret' => $smsset['aliyun_new_keysecret'], 'phonenumbers' => $mobile, 'signname' => $template['smssign'], 'templatecode' => $template['smstplid'], 'templateparam' => $params);
$result = sendSms($option);
if ($result['Message'] != 'OK') {
return array('status' => 0, 'message' => '短信发送失败(错误信息: ' . $result['Message'] . ')');
}
}
else if ($template['type'] == 'emay') {
include_once EWEI_SHOPV2_VENDOR . 'emay/SMSUtil.php';
$balance = $this->sms_num('emay', $smsset);
if ($balance <= 0) {
return array('status' => 0, 'message' => '短信发送失败(亿美软通余额不足, 当前余额' . $balance . ')');
}
$emayClient = new SMSUtil($smsset['emay_url'], $smsset['emay_sn'], $smsset['emay_pw'], $smsset['emay_sk'], array('proxyhost' => $smsset['emay_phost'], 'proxyport' => $smsset['pport'], 'proxyusername' => $smsset['puser'], 'proxypassword' => $smsset['ppw']), $smsset['emay_out'], $smsset['emay_outresp']);
$emayResult = $emayClient->send($mobile, '【' . $template['smssign'] . '】' . $params);
if (!empty($emayResult)) {
return array('status' => 0, 'message' => '短信发送失败(错误信息: ' . $emayResult . ')');
}
}
else {
return array('status' => 0, 'message' => '短信发送失败(未识别的短信服务商)');
}
return array('status' => 1);
}
public function sms_set()
{
global $_W;
return pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_sms_set') . ' WHERE uniacid=:uniacid ', array(':uniacid' => $_W['uniacid']));
}
public function sms_temp()
{
global $_W;
$list = pdo_fetchall('SELECT id, `type`, `name` FROM ' . tablename('ewei_shop_sms') . ' WHERE status=1 and uniacid=:uniacid ', array(':uniacid' => $_W['uniacid']));
foreach ($list as $i => &$item) {
if ($item['type'] == 'juhe') {
$item['name'] = '[聚合]' . $item['name'];
}
else if ($item['type'] == 'dayu') {
$item['name'] = '[大于]' . $item['name'];
}
else if ($item['type'] == 'aliyun') {
$item['name'] = '[阿里云]' . $item['name'];
}
else if ($item['type'] == 'aliyun_new') {
$item['name'] = '[新版阿里云]' . $item['name'];
}
else {
if ($item['type'] == 'emay') {
$item['name'] = '[亿美]' . $item['name'];
}
}
}
unset($item);
return $list;
}
public function sms_num($type, $smsset = NULL)
{
if (empty($type)) {
return NULL;
}
if (empty($smsset) || !is_array($smsset)) {
$smsset = $this->sms_set();
}
if ($type == 'emay') {
include_once EWEI_SHOPV2_VENDOR . 'emay/SMSUtil.php';
$emayClient = new SMSUtil($smsset['emay_url'], $smsset['emay_sn'], $smsset['emay_pw'], $smsset['emay_sk'], array('proxyhost' => $smsset['emay_phost'], 'proxyport' => $smsset['pport'], 'proxyusername' => $smsset['puser'], 'proxypassword' => $smsset['ppw']), $smsset['emay_out'], $smsset['emay_outresp']);
$num = $emayClient->getBalance();
if (!empty($smsset['emay_warn']) && !empty($smsset['emay_mobile']) && $num < $smsset['emay_warn'] && $smsset['emay_warn_time'] + 60 * 60 * 24 < time()) {
$emayClient = new SMSUtil($smsset['emay_url'], $smsset['emay_sn'], $smsset['emay_pw'], $smsset['emay_sk'], array('proxyhost' => $smsset['emay_phost'], 'proxyport' => $smsset['pport'], 'proxyusername' => $smsset['puser'], 'proxypassword' => $smsset['ppw']), $smsset['emay_out'], $smsset['emay_outresp']);
$emayResult = $emayClient->send($smsset['emay_mobile'], '【系统预警】' . '您的亿美软通SMS余额为:' . $num . ',低于预警值:' . $smsset['emay_warn'] . ' (24小时内仅通知一次)');
if (empty($emayResult)) {
pdo_update('ewei_shop_sms_set', array('emay_warn_time' => time()), array('id' => $smsset['id']));
}
}
return $num;
}
}
protected function sms_verify($tplid, $smsset)
{
global $_W;
$template = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_sms') . ' WHERE id=:id and uniacid=:uniacid ', array(':id' => $tplid, ':uniacid' => $_W['uniacid']));
$template['data'] = iunserializer($template['data']);
if (empty($template)) {
return array('status' => 0, 'message' => '模板不存在!');
}
if (empty($template['status'])) {
return array('status' => 0, 'message' => '模板未启用!');
}
if (empty($template['type'])) {
return array('status' => 0, 'message' => '模板类型错误!');
}
if ($template['type'] == 'juhe') {
if (empty($smsset['juhe'])) {
return array('status' => 0, 'message' => '未开启聚合数据!');
}
if (empty($smsset['juhe_key'])) {
return array('status' => 0, 'message' => '未填写聚合数据Key!');
}
if (empty($template['data']) || !is_array($template['data'])) {
return array('status' => 0, 'message' => '模板类型错误!');
}
}
else if ($template['type'] == 'dayu') {
if (empty($smsset['dayu'])) {
return array('status' => 0, 'message' => '未开启阿里大于!');
}
if (empty($smsset['dayu_key'])) {
return array('status' => 0, 'message' => '未填写阿里大于Key!');
}
if (empty($smsset['dayu_secret'])) {
return array('status' => 0, 'message' => '未填写阿里大于Secret!');
}
if (empty($template['data']) || !is_array($template['data'])) {
return array('status' => 0, 'message' => '模板类型错误!');
}
if (empty($template['smssign'])) {
return array('status' => 0, 'message' => '未填写阿里大于短信签名!');
}
}
else if ($template['type'] == 'aliyun') {
if (empty($smsset['aliyun'])) {
return array('status' => 0, 'message' => '未开启阿里云短信(旧版)!');
}
if (empty($smsset['aliyun_appcode'])) {
return array('status' => 0, 'message' => '未填写阿里云短信AppCode!');
}
if (empty($template['data']) || !is_array($template['data'])) {
return array('status' => 0, 'message' => '模板类型错误!');
}
if (empty($template['smssign'])) {
return array('status' => 0, 'message' => '未填写阿里云短信(旧版)签名!');
}
}
else if ($template['type'] == 'aliyun_new') {
if (empty($smsset['aliyun_new'])) {
return array('status' => 0, 'message' => '未开启阿里云短信(新版)!');
}
if (empty($smsset['aliyun_new_keyid'])) {
return array('status' => 0, 'message' => '未填写阿里云短信(新版)KeyID!');
}
if (empty($smsset['aliyun_new_keysecret'])) {
return array('status' => 0, 'message' => '未填写阿里云短信(新版)keySecret!');
}
if (empty($template['data']) || !is_array($template['data'])) {
return array('status' => 0, 'message' => '模板类型错误!');
}
if (empty($template['smssign'])) {
return array('status' => 0, 'message' => '未填写阿里云短信(新版)签名!');
}
}
else {
if ($template['type'] == 'emay') {
if (empty($smsset['emay'])) {
return array('status' => 0, 'message' => '未开启亿美软通!');
}
if (empty($smsset['emay_url'])) {
return array('status' => 0, 'message' => '未填写亿美软通网关!');
}
if (empty($smsset['emay_sn'])) {
return array('status' => 0, 'message' => '未填写亿美软通序列号!');
}
if (empty($smsset['emay_pw'])) {
return array('status' => 0, 'message' => '未填写亿美软通密码!');
}
if (empty($smsset['emay_sk'])) {
return array('status' => 0, 'message' => '未填写亿美软通SessionKey!');
}
if (empty($template['smssign'])) {
return array('status' => 0, 'message' => '未填写亿美软通短信签名!');
}
}
}
return $template;
}
protected function sms_data($type, $data, $replace, $template)
{
if ($replace) {
if ($type == 'emay') {
$tempdata = $template['content'];
foreach ($data as $key => $value) {
$tempdata = str_replace('[' . $key . ']', $value, $tempdata);
}
$data = $tempdata;
}
else {
$tempdata = iunserializer($template['data']);
foreach ($tempdata as &$td) {
foreach ($data as $key => $value) {
$td['data_shop'] = str_replace('[' . $key . ']', $value, $td['data_shop']);
}
}
unset($td);
$newdata = array();
foreach ($tempdata as $td) {
$newdata[$td['data_temp']] = $td['data_shop'];
}
$data = $newdata;
}
}
if ($type == 'juhe') {
$result = '';
$count = count($data);
$i = 0;
foreach ($data as $key => $value) {
if (0 < $i && $i < $count) {
$result .= '&';
}
$result .= '#' . $key . '#=' . $value;
++$i;
}
}
else {
if ($type == 'dayu' || $type == 'aliyun' || $type == 'aliyun_new') {
$result = json_encode($data);
}
else {
if ($type == 'emay') {
$result = $data;
}
}
}
return $result;
}
protected function http_post($url, $postData)
{
$postData = http_build_query($postData);
$options = array(
'http' => array('method' => 'POST', 'header' => 'Content-type:application/x-www-form-urlencoded', 'content' => $postData, 'timeout' => 15 * 60)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if (!is_array($result)) {
$result = json_decode($result, true);
}
return $result;
}
protected function http_get($url)
{
$result = file_get_contents($url, false);
if (!is_array($result)) {
$result = json_decode($result, true);
}
return $result;
}
public function callsms(array $params)
{
global $_W;
$tag = isset($params['tag']) ? $params['tag'] : '';
$datas = isset($params['datas']) ? $params['datas'] : array();
$tm = $_W['shopset']['notice'];
if (empty($tm)) {
$tm = m('common')->getSysset('notice');
}
$smsid = $tm[$tag . '_sms'];
$smsclose = $tm[$tag . '_close_sms'];
if (!empty($smsid) && empty($smsclose) && !empty($params['mobile'])) {
$sms_data = array();
foreach ($datas as $i => $value) {
$sms_data[$value['name']] = $value['value'];
}
$this->send($params['mobile'], $smsid, $sms_data);
}
}
}
?>

View File

@@ -1,16 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Tmessage_EweiShopV2ComModel extends ComModel
{
public function perms()
{
return array(
'tmessage' => array('text' => $this->getName(), 'isplugin' => true, 'view' => '浏览', 'add' => '添加-log', 'edit' => '修改-log', 'delete' => '删除-log', 'send' => '发送-log')
);
}
}
?>

View File

@@ -1,575 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Verify_EweiShopV2ComModel extends ComModel {
public function createQrcode($orderid = 0) {
global $_W, $_GPC;
$path = IA_ROOT . "/addons/ewei_shopv2/data/qrcode/" . $_W['uniacid'];
if (!is_dir($path)) {
load()->func('file');
mkdirs($path);
}
$url = mobileUrl('verify/detai', array('id' => $orderid));
$file = 'order_verify_qrcode_' . $orderid . '.png';
$qrcode_file = $path . '/' . $file;
if (!is_file($qrcode_file)) {
require IA_ROOT . '/framework/library/qrcode/phpqrcode.php';
QRcode::png($url, $qrcode_file, QR_ECLEVEL_H, 4);
}
return $_W['siteroot'] . '/addons/ewei_shopv2/data/qrcode/' . $_W['uniacid'] . '/' . $file;
}
public function allow($orderid, $times = 0,$verifycode = '',$openid = '') {
global $_W, $_GPC;
if(empty($openid)){
$openid = $_W['openid'];
}
$uniacid = $_W['uniacid'];
$store = false; //当前门店
$merchid = 0;
$lastverifys = 0; //剩余核销次数
$verifyinfo = false; //核销码信息
if ($times <= 0) { //按次核销 需要核销的次数
$times = 1;
}
//多商户
$merch_plugin = p('merch');
$order = pdo_fetch('select * from ' . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $orderid, ':uniacid' => $uniacid));
if (empty($order)) {
return error(-1, "订单不存在!");
}
if (empty($order['isverify']) && empty($order['dispatchtype']) && empty($order['istrade'])) {
return error(-1, "订单无需核销!");
}
if($order['verifyendtime'] < time() && $order['verifyendtime'] > 0){
return error(-1, "该记录已失效,兑换期限已过!");
}
if($order['paytype'] != 3 && $order['status'] < 1){
return error(-1, "该订单尚未支付!");
}
$merchid = $order['merchid'];
if (empty($merchid)) {
$saler = pdo_fetch('select * from ' . tablename('ewei_shop_saler') . ' where openid=:openid and uniacid=:uniacid and status=1 limit 1', array(
':uniacid' => $_W['uniacid'], ':openid' => $openid
));
} else {
if ($merch_plugin) {
$saler = pdo_fetch('select * from ' . tablename('ewei_shop_merch_saler') . ' where openid=:openid and uniacid=:uniacid and status=1 and merchid=:merchid limit 1', array(
':uniacid' => $_W['uniacid'], ':openid' => $openid, ':merchid' => $merchid
));
}
}
if (empty($saler)) {
return error(-1, '无核销权限!');
}
if(!empty($order['storeid'])&&!empty($saler['storeid'])&&$order['storeid']!=$saler['storeid'])
{
return error(1, '该商品无法在您所属门店核销!请重新确认!');
}
$newstore_plugin = p('newstore');
$sqlstr = "";
if ($newstore_plugin) {
$sqlstr .= ",og.trade_time,og.optime,og.peopleid,og.trade_time,og.optime,g.tempid";
}
$allgoods = pdo_fetchall("select og.goodsid,og.price,g.title,g.thumb,og.total,g.credit,og.optionid,o.title as optiontitle,g.isverify,g.storeids,g.status".$sqlstr." from " . tablename('ewei_shop_order_goods') . " og "
. " left join " . tablename('ewei_shop_goods') . " g on g.id=og.goodsid "
. " left join " . tablename('ewei_shop_goods_option') . " o on o.id=og.optionid "
. " where og.orderid=:orderid and og.uniacid=:uniacid ", array(':uniacid' => $uniacid, ':orderid' => $orderid));
if (empty($allgoods)) {
return error(-1, '订单异常!');
}
$goods = $allgoods[0];
if ($order['isverify'] || $order['istrade']) {
//核销单,判断是否有赠品
if (count($allgoods) != 1) {
$gift = false;
foreach($allgoods as $key => $value){
if($value['status']==2){
$gift = true;
}
}
if($gift){
return error(-1, '核销单异常!');
}
}
if ($order['refundid'] > 0 && $order['refundstate'] > 0) {
return error(-1, '订单维权中,无法核销!');
}
if ($order['status'] == -1 && $order['refundtime'] > 0) {
return error(-1, '订单状态变更,无法核销!');
}
$storeids = array();
if (!empty($goods['storeids'])) {
$storeids = explode(',', $goods['storeids']);
}
if (!empty($storeids)) {
//全部门店
if (!empty($saler['storeid'])) {
if (!in_array($saler['storeid'], $storeids)) {
return error(-1, '您无此门店的核销权限!');
}
}
}
if ($order['verifytype'] == 0) {
//整单核销
if (!empty($order['verified'])) {
return error(-1, "此订单已核销!");
}
} else if ($order['verifytype'] == 1) {
//按次核销
$verifyinfo = iunserializer($order['verifyinfo']);
if (!is_array($verifyinfo)) {
$verifyinfo = array();
}
$lastverifys = $goods['total'] - count($verifyinfo);
if ($lastverifys <= 0) {
return error(-1, "此订单已全部使用!");
}
if ($times > $lastverifys) {
return error(-1, "最多核销 {$lastverifys} 次!");
}
} else if ($order['verifytype'] == 2) {
//按消费码核销
$verifyinfo = iunserializer($order['verifyinfo']);
$verifys = 0;
foreach ($verifyinfo as $v) {
if(!empty($verifycode) && trim($v['verifycode'])===trim($verifycode)){
if($v['verified']){
return error(-1, "消费码 {$verifycode} 已经使用!");
}
}
if ($v['verified']) {
$verifys++;
}
}
$lastverifys = count($verifyinfo) - $verifys;
if ($verifys >= count($verifyinfo)) {
return error(-1, "消费码都已经使用过了!");
}
} else if ($order['verifytype'] == 3) {
//门店核销
if (!empty($order['verified'])) {
return error(-1, "此订单已核销!");
}
}
if (!empty($saler['storeid'])) {
if ($merchid > 0) {
$store = pdo_fetch('select * from ' . tablename('ewei_shop_merch_store') . ' where id=:id and uniacid=:uniacid and merchid = :merchid limit 1', array(':id' => $saler['storeid'], ':uniacid' => $_W['uniacid'], ':merchid' => $merchid));
} else {
$store = pdo_fetch('select * from ' . tablename('ewei_shop_store') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $saler['storeid'], ':uniacid' => $_W['uniacid']));
}
}
} else if ($order['dispatchtype'] == 1) {
//自提核销
if ($order['status'] >= 3) {
return error(-1, "订单已经完成,无法进行自提!");
}
if ($order['refundid'] > 0 && $order['refundstate'] > 0) {
return error(-1, '订单维权中,无法进行自提!');
}
if ($order['status'] == -1 && $order['refundtime'] > 0) {
return error(-1, '订单状态变更,无法进行自提!');
}
if (!empty($order['storeid'])) {
if ($merchid > 0) {
$store = pdo_fetch('select * from ' . tablename('ewei_shop_merch_store') . ' where id=:id and uniacid=:uniacid and merchid = :merchid limit 1', array(':id' => $order['storeid'], ':uniacid' => $_W['uniacid'], ':merchid' => $merchid));
} else {
$store = pdo_fetch('select * from ' . tablename('ewei_shop_store') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $order['storeid'], ':uniacid' => $_W['uniacid']));
}
}
if (empty($store)) {
return error(-1, "订单未选择自提门店!");
}
if (!empty($saler['storeid'])) {
if ($saler['storeid'] != $order['storeid']) {
return error(-1, '您无此门店的自提权限!');
}
}
}
$carrier = unserialize($order['carrier']);
return array('order' => $order,
'store' => $store,
'saler' => $saler,
'lastverifys' => $lastverifys,
'allgoods' => $allgoods,
'goods' => $goods,
'verifyinfo' => $verifyinfo,
'carrier' => $carrier
);
}
public function verify($orderid = 0, $times = 0,$verifycode = '',$openid = '') {
global $_W, $_GPC;
$current_time = time();
if(empty($openid)){
$openid = $_W['openid'];
}
$data = $this->allow($orderid, $times,$verifycode,$openid);
if (is_error($data)) {
return $data;
}
$this->verifyLog($data, 0);
extract($data);
if ($order['isverify'] || $order['istrade']) {
if ($order['verifytype'] == 0 || $order['verifytype'] == 3) {
$change_data = array('status' => 3, 'sendtime' => $current_time, 'finishtime' => $current_time, 'verifytime' => $current_time, 'verified' => 1, 'verifyopenid' => $openid, 'verifystoreid' => $saler['storeid']);
$newstore_plugin = p('newstore');
if ($newstore_plugin && !empty($order['istrade'])) {
//预约核销
if ($order['tradestatus'] == 1) {
$change_data['tradestatus'] = 2;
$change_data['tradepaytype'] = 11;
$change_data['tradepaytime'] = $current_time;
}
}
pdo_update('ewei_shop_order', $change_data, array('id' => $order['id']));
$verifyorder_log = array();
$verifyorder_log['uniacid'] = $_W['uniacid'];
$verifyorder_log['orderid'] = $order['id'];
$verifyorder_log['salerid'] = $saler['id'];
$verifyorder_log['storeid'] = $store['id'];
$verifyorder_log['verifytime'] = time();
pdo_insert('ewei_shop_verifyorder_log', $verifyorder_log);
if ($newstore_plugin && !empty($order['istrade'])) {
$og = $newstore_plugin->getOrderGoods($order['id']);
$insert_data = array();
$insert_data['uniacid'] = $_W['uniacid'];
$insert_data['storeid'] = $saler['storeid'];
$insert_data['goodsid'] = intval($og['goodsid']);
$insert_data['orderid'] = $order['id'];
$insert_data['openid'] = $openid;
$insert_data['verifytime'] = $current_time;
$insert_data['verifycode'] = $order['verifycode'];
$insert_data['verifytype'] = 0;
$insert_data['merchid'] = 0;
pdo_insert('ewei_shop_newstore_trade_log', $insert_data);
}
$this->finish($openid,$order);
if ($order['status'] != 3) {
//余额赠送
m('order')->setGiveBalance($orderid, 1);
//处理积分
m('order')->setStocksAndCredits($orderid, 3);//订单完成后赠送积分
}
m('member')->upgradeLevel($order['openid'], $orderid);
//整单核销
m('notice')->sendOrderMessage($orderid);
//打印机打印
com_run('printer::sendOrderMessage',$orderid,array('type'=>0));
} else if ($order['verifytype'] == 1) {
//按次核销
$verifyinfo = iunserializer($order['verifyinfo']);
//核销记录
for ($i = 1; $i <= $times; $i++) {
$verifyinfo[] = array(
'verifyopenid' => $openid,
'verifystoreid' => $store['id'],
'verifytime' => $current_time
);
}
pdo_update('ewei_shop_order',
array('verifyinfo' => iserializer($verifyinfo)), array('id' => $orderid));
$verifyorder_log = array();
$verifyorder_log['uniacid'] = $_W['uniacid'];
$verifyorder_log['orderid'] = $order['id'];
$verifyorder_log['salerid'] = $saler['id'];
$verifyorder_log['storeid'] = $store['id'];
$verifyorder_log['verifytime'] = time();
$verifyorder_log['verifyinfo'] = iserializer($verifyinfo);
pdo_insert('ewei_shop_verifyorder_log', $verifyorder_log);
//打印机打印
// com_run('printer::sendOrderMessage',$orderid,
// array('type'=>1,'times'=>$times,'lastverifys'=>$data['lastverifys']-$times));
//
if ($order['status'] != 3) {
pdo_update('ewei_shop_order', array('status' => 3, 'sendtime' => $current_time, 'finishtime' => $current_time), array('id' => $order['id']));
$this->finish($openid,$order);
//余额赠送
m('order')->setGiveBalance($orderid, 1);
//处理积分
m('order')->setStocksAndCredits($orderid, 3);
}
m('member')->upgradeLevel($order['openid'], $orderid);
m('notice')->sendOrderMessage($orderid);
} else if ($order['verifytype'] == 2) {
if ($order['status'] != 3) {
pdo_update('ewei_shop_order', array('status' => 3, 'sendtime' => $current_time, 'finishtime' => $current_time, 'verifytime' => $current_time, 'verified' => 1, 'verifyopenid' => $openid, 'verifystoreid' => $saler['storeid']), array('id' => $order['id']));
$this->finish($openid,$order);
//余额赠送
m('order')->setGiveBalance($orderid, 1);
//处理积分
m('order')->setStocksAndCredits($orderid, 3);//订单完成后赠送积分
// $this->finish(array('status' => 3, 'sendtime' => $current_time, 'finishtime' => $current_time, 'verifytime' => $current_time, 'verified' => 1, 'verifyopenid' => $openid, 'verifystoreid' => $saler['storeid']),$order);
}
$verifyinfo = iunserializer($order['verifyinfo']);
if(!empty($verifycode)){
//单号核销
foreach ($verifyinfo as &$v) {
if(!$v['verified'] && trim($v['verifycode'])===trim($verifycode)){
$v['verifyopenid'] = $openid;
$v['verifystoreid'] = $store['id'];
$v['verifytime'] = $current_time;
$v['verified'] = 1;
}
}
unset($v);
//打印机打印
com_run('printer::sendOrderMessage',$orderid,array('type'=>2,'verifycode'=>$verifycode,'lastverifys'=>$data['lastverifys']-1));
} else{
//按号核销
$selecteds = array();
$printer_code = array();
$printer_code_all = array();
foreach ($verifyinfo as $v) {
if ($v['select']) {
$selecteds[] = $v;
$printer_code[] = $v['verifycode'];
}
// 去除已核销的
if (empty($v['verified'])) {
$printer_code_all[] = $v['verifycode'];
}
}
if (count($selecteds) <= 0) {
//全部核销
foreach ($verifyinfo as &$v) {
if (empty($v['verified'])) {
$v['verifyopenid'] = $openid;
$v['verifystoreid'] = $store['id'];
$v['verifytime'] = $current_time;
$v['verified'] = 1;
unset($v['select']);
}
}
unset($v);
//打印机打印
com_run('printer::sendOrderMessage',$orderid,array('type'=>2,'verifycode'=>implode(',',$printer_code_all),'lastverifys'=>0));
} else {
//选择核销
foreach ($verifyinfo as &$v) {
if ($v['select']) {
$v['verifyopenid'] = $openid;
$v['verifystoreid'] = $store['id'];
$v['verifytime'] = $current_time;
$v['verified'] = 1;
unset($v['select']);
}
}
unset($v);
//打印机打印
com_run('printer::sendOrderMessage',$orderid,array('type'=>2,'verifycode'=>implode(',',$printer_code),'lastverifys'=>$data['lastverifys']-count($selecteds)));
}
}
pdo_update('ewei_shop_order', array('verifyinfo' => iserializer($verifyinfo)), array('id' => $order['id']));
$verifyorder_log = array();
$verifyorder_log['uniacid'] = $_W['uniacid'];
$verifyorder_log['orderid'] = $order['id'];
$verifyorder_log['salerid'] = $saler['id'];
$verifyorder_log['storeid'] = $store['id'];
$verifyorder_log['verifytime'] = time();
$verifyorder_log['verifyinfo'] = iserializer($verifyinfo);
pdo_insert('ewei_shop_verifyorder_log', $verifyorder_log);
m('member')->upgradeLevel($order['openid'], $orderid);
m('notice')->sendOrderMessage($orderid);
}
} else if ($order['dispatchtype'] == 1) {
pdo_update('ewei_shop_order', array('status' => 3, 'fetchtime' => $current_time,'sendtime'=>$current_time, 'finishtime' => $current_time,'verifytime' => $current_time, 'verified' => 1, 'verifyopenid' => $openid, 'verifystoreid' => $saler['storeid']), array('id' => $order['id']));
$this->finish($openid,$order);
//余额赠送
m('order')->setGiveBalance($orderid, 1);
//处理积分
m('order')->setStocksAndCredits($orderid, 3);
//打印机打印
com_run('printer::sendOrderMessage',$orderid,array('type'=>0));
m('member')->upgradeLevel($order['openid'], $orderid);
m('notice')->sendOrderMessage($orderid);
}
return true;
}
protected function finish($openid,$order){
//会员升级
// m('member')->upgradeLevel($openid, $order['id']);
//游戏营销
if(p('lottery')){
//type 1:消费 2:签到 3:任务 4:其他
$res = p('lottery')->getLottery($order['openid'],1,array('money'=>$order['price'],'paytype'=>2));
if($res){
//发送模版消息
p('lottery')->getLotteryList($order['openid'],array('lottery_id'=>$res));
}
}
//商品全返
m('order')->fullback($order['id']);
//发送赠送优惠券
if (com('coupon')) {
$refurnid = com('coupon')->sendcouponsbytask($order['id']); //订单支付
}
//订单满额
if(p('task')){
p('task')->checkTaskProgress($order['price'],'order_full','',$openid);//?这个需要移动到确认收货
}
//优惠券返利
if (com('coupon') && !empty($order['couponid'])) {
com('coupon')->backConsumeCoupon($order['id']); //手机收货
}
//分销检测
if (p('commission')) {
p('commission')->checkOrderFinish($order['id']);
}
}
public function perms() {
return array(
'verify' => array(
'text' => $this->getName(), 'isplugin' => true,
'child' => array(
'keyword' => array('text' => '关键词设置-log'),
'store' => array('text' => '门店', 'view' => '浏览', 'add' => '添加-log', 'edit' => '修改-log', 'delete' => '删除-log'),
'saler' => array('text' => '核销员', 'view' => '浏览', 'add' => '添加-log', 'edit' => '修改-log', 'delete' => '删除-log'),
)
)
);
}
public function getSalerInfo($openid, $merchid = 0) {
global $_W;
$condition = " s.uniacid = :uniacid and s.openid = :openid";
$params = array(':uniacid' => $_W['uniacid'], ':openid' => $openid);
if (empty($merchid)) {
$table_name = tablename('ewei_shop_saler');
} else {
$table_name = tablename('ewei_shop_merch_saler');
$condition .= " and s.merchid = :merchid";
$params['merchid'] = $merchid;
}
$sql = "SELECT m.id as salerid,m.nickname as salernickname,s.salername FROM {$table_name} s "
. " left join " . tablename('ewei_shop_member') . " m on s.openid=m.openid and m.uniacid = s.uniacid "
. " WHERE {$condition} Limit 1";
$data = pdo_fetch($sql, $params);
return $data;
}
public function getStoreInfo($storeid, $merchid = 0) {
global $_W;
$condition = " uniacid = :uniacid and id = :storeid";
$params = array(':uniacid' => $_W['uniacid'], ':storeid' => $storeid);
if (empty($merchid)) {
$table_name = tablename('ewei_shop_store');
} else {
$table_name = tablename('ewei_shop_merch_store');
$condition .= " and merchid = :merchid";
$params['merchid'] = $merchid;
}
$sql = "SELECT * FROM {$table_name} WHERE {$condition} Limit 1";
$data = pdo_fetch($sql, $params);
return $data;
}
public function verifyLog($data, $type = 0)
{
$result = [];
$result['storeid'] = $data['saler']['storeid'];
$result['uniacid'] = $data['saler']['uniacid'];
$result['openid'] = $data['saler']['openid'];
$result['saler_id'] = $data['saler']['id'];
$result['order_id'] = $data['order']['id'];
$result['verify_time'] = time();
$result['type'] = $type;
$ret = pdo_insert('ewei_shop_saler_verify_log', $result);
if (empty($ret)) {
return show_json(0, '核销失败,请检查数据');
}
}
}

View File

@@ -1,264 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Virtual_EweiShopV2ComModel extends ComModel
{
public function updateGoodsStock($id = 0)
{
global $_W;
global $_GPC;
$goods = pdo_fetch('select `virtual`,merchid from ' . tablename('ewei_shop_goods') . ' where id=:id and type=3 and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($goods)) {
return NULL;
}
$merchid = $goods['merchid'];
$stock = 0;
if (!empty($goods['virtual'])) {
$stock = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_virtual_data') . ' where typeid=:typeid and uniacid=:uniacid and merchid = :merchid and openid=\'\' limit 1', array(':typeid' => $goods['virtual'], ':uniacid' => $_W['uniacid'], ':merchid' => $merchid));
}
else {
$virtuals = array();
$alloptions = pdo_fetchall('select id, `virtual` from ' . tablename('ewei_shop_goods_option') . (' where goodsid=' . $id));
foreach ($alloptions as $opt) {
if (empty($opt['virtual'])) {
continue;
}
$c = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_virtual_data') . ' where typeid=:typeid and uniacid=:uniacid and merchid = :merchid and openid=\'\' limit 1', array(':typeid' => $opt['virtual'], ':uniacid' => $_W['uniacid'], ':merchid' => $merchid));
pdo_update('ewei_shop_goods_option', array('stock' => $c), array('id' => $opt['id']));
if (!in_array($opt['virtual'], $virtuals)) {
$virtuals[] = $opt['virtual'];
$stock += $c;
}
}
}
pdo_update('ewei_shop_goods', array('total' => $stock), array('id' => $id));
}
public function updateStock($typeid = 0)
{
global $_W;
$goodsids = array();
$goods = pdo_fetchall('select id from ' . tablename('ewei_shop_goods') . ' where `type`=3 and `virtual`=:virtual and uniacid=:uniacid', array(':virtual' => $typeid, ':uniacid' => $_W['uniacid']));
foreach ($goods as $g) {
$goodsids[] = $g['id'];
}
$alloptions = pdo_fetchall('select id, goodsid from ' . tablename('ewei_shop_goods_option') . ' where `virtual`=:virtual and uniacid=:uniacid', array(':uniacid' => $_W['uniacid'], ':virtual' => $typeid));
foreach ($alloptions as $opt) {
if (!in_array($opt['goodsid'], $goodsids)) {
$goodsids[] = $opt['goodsid'];
}
}
foreach ($goodsids as $gid) {
$this->updateGoodsStock($gid);
}
}
public function pay_befo($order)
{
global $_W;
global $_GPC;
$orderid_cache = m('cache')->getString('orderid_' . $order['id']);
if (empty($orderid_cache)) {
m('cache')->set('orderid_' . $order['id'], 1);
}
else {
return false;
}
$open_redis = function_exists('redis') && !is_error(redis());
$goods = pdo_fetch('select id,goodsid,total,realprice from ' . tablename('ewei_shop_order_goods') . ' where orderid=:orderid and uniacid=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':orderid' => $order['id']));
$g = pdo_fetch('select id,credit,sales,salesreal from ' . tablename('ewei_shop_goods') . ' where id=:id and uniacid=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':id' => $goods['goodsid']));
$last_where = '';
if ($open_redis) {
$redis = redis();
$last_id = $redis->get($_W['uniacid'] . '_last_virtual_id_' . $order['virtual'] . '_' . $order['merchid']);
$last_used = pdo_fetch('select id,typeid,is_top,sort_time from ' . tablename('ewei_shop_virtual_data') . ' where id=:id and uniacid=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':id' => $last_id));
if (!empty($last_id) && !empty($last_used) && $last_used['is_top'] == 0) {
$last_id = intval($last_id);
$last_where = ' and id>' . $last_id;
}
}
$sort_order = 'orderid ASC,is_top desc,sort_time desc,id ASC';
$virtual_data = pdo_fetchall('SELECT id,typeid,fields FROM ' . tablename('ewei_shop_virtual_data') . ' WHERE typeid=:typeid and orderid=:orderid and uniacid=:uniacid and merchid = :merchid ' . $last_where . ' order by ' . $sort_order . ' limit ' . $goods['total'], array(':orderid' => 0, ':typeid' => $order['virtual'], ':uniacid' => $_W['uniacid'], ':merchid' => $order['merchid']));
if (count($virtual_data) < $goods['total']) {
return array('error' => -1, 'message' => '库存不足');
}
if (!empty($virtual_data)) {
$last_virtual_id = max(array_column($virtual_data, 'id'));
if ($open_redis && !empty($last_virtual_id)) {
$redis = redis();
$redis->set($_W['uniacid'] . '_last_virtual_id_' . $order['virtual'] . '_' . $order['merchid'], $last_virtual_id, 30);
}
}
$type = pdo_fetch('select fields from ' . tablename('ewei_shop_virtual_type') . ' where id=:id and uniacid=:uniacid and merchid = :merchid limit 1 ', array(':id' => $order['virtual'], ':uniacid' => $_W['uniacid'], ':merchid' => $order['merchid']));
$fields = iunserializer($type['fields'], true);
$virtual_info = array();
$virtual_str = array();
foreach ($virtual_data as $vd) {
$virtual_info[] = $vd['fields'];
$strs = array();
$vddatas = iunserializer($vd['fields']);
foreach ($vddatas as $vk => $vv) {
$strs[] = $fields[$vk] . ': ' . $vv;
}
$virtual_str[] = implode(' ', $strs);
pdo_update('ewei_shop_virtual_data', array('openid' => $order['openid'], 'orderid' => $order['id'], 'ordersn' => $order['ordersn'], 'price' => round($goods['realprice'] / $goods['total'], 2), 'usetime' => time()), array('id' => $vd['id']));
pdo_update('ewei_shop_virtual_type', 'usedata=usedata+1', array('id' => $vd['typeid']));
}
$this->updateStock($order['virtual']);
$virtual_str = implode('
', $virtual_str);
$virtual_info = '[' . implode(',', $virtual_info) . ']';
$time = time();
pdo_update('ewei_shop_order', array('virtual_info' => $virtual_info, 'virtual_str' => $virtual_str, 'sendtime' => $time), array('id' => $order['id']));
if ($open_redis && !empty($virtual_str)) {
$redis = redis();
$redis->set($order['id'] . '_virtual_str', $virtual_str, 30);
}
return true;
}
public function pay($order, $ispeerpay = false)
{
global $_W;
global $_GPC;
$goods = pdo_fetch('select id,goodsid,total,realprice from ' . tablename('ewei_shop_order_goods') . ' where orderid=:orderid and uniacid=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':orderid' => $order['id']));
$g = pdo_fetch('select id,credit,sales,salesreal from ' . tablename('ewei_shop_goods') . ' where id=:id and uniacid=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':id' => $goods['goodsid']));
$virtual_data = pdo_fetchall('SELECT id,typeid,fields FROM ' . tablename('ewei_shop_virtual_data') . ' WHERE typeid=:typeid and openid=:openid and uniacid=:uniacid and merchid = :merchid order by id asc limit ' . $goods['total'], array(':openid' => '', ':typeid' => $order['virtual'], ':uniacid' => $_W['uniacid'], ':merchid' => $order['merchid']));
$type = pdo_fetch('select fields from ' . tablename('ewei_shop_virtual_type') . ' where id=:id and uniacid=:uniacid and merchid = :merchid limit 1 ', array(':id' => $order['virtual'], ':uniacid' => $_W['uniacid'], ':merchid' => $order['merchid']));
$time = time();
pdo_update('ewei_shop_order', array('status' => '3', 'paytime' => $time, 'sendtime' => $time, 'finishtime' => $time), array('id' => $order['id']));
$credits = 0;
$gcredit = trim($g['credit']);
if (!empty($gcredit)) {
if (strexists($gcredit, '%')) {
$credits += intval(floatval(str_replace('%', '', $gcredit)) / 100 * $goods['realprice']);
}
else {
$credits += intval($g['credit']) * $goods['total'];
}
}
if (0 < $credits) {
$shopset = m('common')->getSysset('shop');
m('member')->setCredit($order['openid'], 'credit1', $credits, array(0, $shopset['name'] . '购物积分 订单号: ' . $order['ordersn']));
}
else {
$money = com_run('sale::getCredit1', $order['openid'], (double) $order['price'], $order['paytype'], 1);
if (0 < $money) {
m('notice')->sendMemberPointChange($order['openid'], $money, 0, 3);
}
}
$salesreal = pdo_fetchcolumn('select ifnull(sum(total),0) from ' . tablename('ewei_shop_order_goods') . ' og ' . ' left join ' . tablename('ewei_shop_order') . ' o on o.id = og.orderid ' . ' where og.goodsid=:goodsid and o.status>=1 and o.uniacid=:uniacid limit 1', array(':goodsid' => $g['id'], ':uniacid' => $_W['uniacid']));
pdo_update('ewei_shop_goods', array('salesreal' => $salesreal), array('id' => $g['id']));
m('order')->fullback($order['id']);
m('member')->upgradeLevel($order['openid'], $order['id']);
m('notice')->sendOrderMessage($order['id']);
m('order')->setGiveBalance($order['id'], 1);
com_run('printer::sendOrderMessage', $order['id']);
if (com('coupon')) {
com('coupon')->sendcouponsbytask($order['id']);
}
if (com('coupon') && !empty($order['couponid'])) {
com('coupon')->backConsumeCoupon($order['id']);
}
if (p('commission')) {
p('commission')->checkOrderPay($order['id']);
p('commission')->checkOrderFinish($order['id']);
}
if (p('task')) {
if (0 < $order['deductcredit2']) {
$order['price'] = floatval($order['price']) + floatval($order['deductcredit2']);
}
if (0 < $order['deductcredit']) {
$order['price'] = floatval($order['price']) + floatval($order['deductprice']);
}
if ($order['agentid']) {
p('task')->checkTaskReward('commission_order', 1);
}
p('task')->checkTaskReward('cost_total', $order['price']);
p('task')->checkTaskReward('cost_enough', $order['price']);
p('task')->checkTaskReward('cost_count', 1);
$goodslist = pdo_fetchall('SELECT goodsid FROM ' . tablename('ewei_shop_order_goods') . ' WHERE orderid = :orderid AND uniacid = :uniacid', array(':orderid' => $order['id'], ':uniacid' => $order['uniacid']));
foreach ($goodslist as $item) {
p('task')->checkTaskReward('cost_goods' . $item['goodsid'], 1, $order['openid']);
}
if (0 < $order['deductcredit2']) {
$order['price'] = floatval($order['price']) + floatval($order['deductcredit2']);
}
if (0 < $order['deductcredit']) {
$order['price'] = floatval($order['price']) + floatval($order['deductprice']);
}
p('task')->checkTaskProgress($order['price'], 'order_full');
p('task')->checkTaskProgress($order['price'], 'order_all');
$goodslist = pdo_fetchall('SELECT goodsid FROM ' . tablename('ewei_shop_order_goods') . ' WHERE orderid = :orderid AND uniacid = :uniacid', array(':orderid' => $order['id'], ':uniacid' => $order['uniacid']));
foreach ($goodslist as $item) {
p('task')->checkTaskProgress(1, 'goods', 0, '', $item['goodsid']);
}
if (pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_order') . (' where openid = \'' . $order['openid'] . '\' and uniacid = ' . $order['uniacid'])) == 1) {
p('task')->checkTaskProgress(1, 'order_first');
}
}
if (p('lottery') && empty($ispeerpay)) {
if (0 < $order['deductcredit2']) {
$order['price'] = floatval($order['price']) + floatval($order['deductcredit2']);
}
if (0 < $order['deductcredit']) {
$order['price'] = floatval($order['price']) + floatval($order['deductprice']);
}
$res = p('lottery')->getLottery($order['openid'], 1, array('money' => $order['price'], 'paytype' => 1));
if ($res) {
p('lottery')->getLotteryList($order['openid'], array('lottery_id' => $res));
}
}
return true;
}
}
?>

View File

@@ -1,14 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Wap_EweiShopV2ComModel extends ComModel
{
public function getSet()
{
return '';
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,959 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobileLoginPage
{
protected function merchData()
{
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if ($merch_plugin && $merch_data['is_openmerch']) {
$is_openmerch = 1;
}
else {
$is_openmerch = 0;
}
return array('is_openmerch' => $is_openmerch, 'merch_plugin' => $merch_plugin, 'merch_data' => $merch_data);
}
public function main()
{
global $_W;
global $_GPC;
$trade = m('common')->getSysset('trade');
$merchdata = $this->merchData();
extract($merchdata);
if ($is_openmerch == 1) {
include $this->template('merch/order/index');
}
else {
include $this->template();
}
}
public function get_list()
{
global $_W;
global $_GPC;
$uniacid = $_W['uniacid'];
$openid = $_W['openid'];
$pindex = max(1, intval($_GPC['page']));
$psize = 50;
$show_status = $_GPC['status'];
$r_type = array('退款', '退货退款', '换货');
$condition = ' and openid=:openid and ismr=0 and deleted=0 and uniacid=:uniacid and istrade=0 ';
$params = array(':uniacid' => $uniacid, ':openid' => $openid);
$merchdata = $this->merchData();
extract($merchdata);
$condition .= ' and merchshow=0 ';
if ($show_status != '') {
$show_status = intval($show_status);
switch ($show_status) {
case 0:
$condition .= ' and status=0 and paytype<>3';
break;
case 1:
$condition .= ' and (status=1 or (status=0 and paytype=3))';
break;
case 2:
$condition .= ' and (status=2 or (status=1 and sendtype>0))';
break;
case 4:
$condition .= ' and refundstate>0';
break;
case 5:
$condition .= ' and userdeleted=1 ';
break;
default:
$condition .= ' and status=' . intval($show_status);
}
if ($show_status != 5) {
$condition .= ' and userdeleted=0 ';
}
}
else {
$condition .= ' and userdeleted=0 ';
}
$com_verify = com('verify');
$s_string = '';
$list = pdo_fetchall('select id,addressid,ordersn,price,dispatchprice,status,iscomment,isverify,verifyendtime,
verified,verifycode,verifytype,iscomment,refundid,expresscom,express,expresssn,finishtime,`virtual`,sendtype,
paytype,expresssn,refundstate,dispatchtype,verifyinfo,merchid,isparent,iscycelbuy,cycelbuy_periodic,userdeleted' . $s_string . '
from ' . tablename('ewei_shop_order') . (' where 1 ' . $condition . ' order by createtime desc LIMIT ') . ($pindex - 1) * $psize . ',' . $psize, $params);
$total = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_order') . (' where 1 ' . $condition), $params);
$refunddays = intval($_W['shopset']['trade']['refunddays']);
if ($is_openmerch == 1) {
$merch_user = $merch_plugin->getListUser($list, 'merch_user');
}
foreach ($list as &$row) {
$param = array();
if ($row['isparent'] == 1) {
$scondition = ' og.parentorderid=:parentorderid';
$param[':parentorderid'] = $row['id'];
}
else {
$scondition = ' og.orderid=:orderid';
$param[':orderid'] = $row['id'];
}
$sql = 'SELECT og.id,og.goodsid,og.total,g.title,g.thumb,g.type,g.status,og.price,og.title as gtitle,og.optionname as optiontitle,og.optionid,op.specs,g.merchid,og.seckill,og.seckill_taskid,
og.sendtype,og.expresscom,og.expresssn,og.express,og.sendtime,og.finishtime,og.remarksend,og.single_refundid,og.single_refundstate
FROM ' . tablename('ewei_shop_order_goods') . ' og ' . ' left join ' . tablename('ewei_shop_goods') . ' g on og.goodsid = g.id ' . ' left join ' . tablename('ewei_shop_goods_option') . ' op on og.optionid = op.id ' . (' where ' . $scondition . ' order by og.id asc');
$goods = pdo_fetchall($sql, $param);
$ismerch = 0;
$merch_array = array();
$row['isonlyverifygoods'] = false;
foreach ($goods as &$r) {
$r['seckilltask'] = false;
if ($r['seckill']) {
$r['seckill_task'] = plugin_run('seckill::getTaskInfo', $r['seckill_taskid']);
}
$merchid = (int) $r['merchid'];
$merch_array[$merchid] = $merchid;
if (!empty($r['specs'])) {
$thumb = m('goods')->getSpecThumb($r['specs']);
if (!empty($thumb)) {
$r['thumb'] = $thumb;
}
}
if ($r['type'] == 5) {
$row['isonlyverifygoods'] = true;
}
if (empty($r['gtitle']) != true) {
$r['title'] = $r['gtitle'];
}
}
unset($r);
if (!empty($merch_array)) {
if (1 < count($merch_array)) {
$ismerch = 1;
}
}
$goods = set_medias($goods, 'thumb');
if (empty($goods)) {
$goods = array();
}
foreach ($goods as &$r) {
$r['thumb'] .= '?t=' . random(50);
}
unset($r);
$goods_list = array();
if ($ismerch) {
$getListUser = $merch_plugin->getListUser($goods);
$merch_user = $getListUser['merch_user'];
foreach ($getListUser['merch'] as $k => $v) {
$goods_list[$k]['shopname'] = '';
if (empty($merch_user[$k]['merchname'])) {
$goods_list[$k]['shopname'] = $_W['shopset']['shop']['name'];
}
else {
$goods_list[$k]['shopname'] = $merch_user[$k]['merchname'];
}
$goods_list[$k]['goods'] = $v;
}
}
else {
$goods_list[0]['shopname'] = '';
if ($merchid == 0) {
$goods_list[0]['shopname'] = $_W['shopset']['shop']['name'];
}
else {
$merch_data = $merch_plugin->getListUserOne($merchid);
$goods_list[0]['shopname'] = $merch_data['merchname'];
}
$goods_list[0]['goods'] = $goods;
}
$row['goods'] = $goods_list;
$row['goods_num'] = count($goods);
$cycelbuy_periodic = explode(',', $row['cycelbuy_periodic']);
$row['phaseNum'] = $cycelbuy_periodic[2];
$statuscss = 'text-cancel';
switch ($row['status']) {
case '-1':
$status = '已取消';
break;
case '0':
if ($row['paytype'] == 3) {
$status = '待发货';
}
else {
$status = '待付款';
}
$statuscss = 'text-cancel';
break;
case '1':
if ($row['isverify'] == 1) {
$status = '使用中';
if (0 < $row['verifyendtime'] && $row['verifyendtime'] < time()) {
$row['status'] = -1;
$status = '已过期';
}
}
else if (empty($row['addressid'])) {
if (!empty($row['ccard'])) {
$status = '充值中';
}
else {
$status = '待取货';
}
}
else {
$status = '待发货';
if (0 < $row['sendtype']) {
$status = '部分发货';
}
}
$statuscss = 'text-warning';
break;
case '2':
$status = '待收货';
$statuscss = 'text-danger';
break;
case '3':
if (empty($row['iscomment'])) {
if ($show_status == 5) {
$status = '已完成';
}
else {
$status = empty($_W['shopset']['trade']['closecomment']) ? '待评价' : '已完成';
}
}
else {
$status = '交易完成';
}
$statuscss = 'text-success';
break;
}
$row['statusstr'] = $status;
$row['statuscss'] = $statuscss;
if (0 < $row['refundstate'] && !empty($row['refundid'])) {
$refund = pdo_fetch('select * from ' . tablename('ewei_shop_order_refund') . ' where id=:id and uniacid=:uniacid and orderid=:orderid limit 1', array(':id' => $row['refundid'], ':uniacid' => $uniacid, ':orderid' => $row['id']));
if (!empty($refund)) {
$row['statusstr'] = '待' . $r_type[$refund['rtype']];
}
}
$canrefund = false;
$row['canrefund'] = $canrefund;
$row['canverify'] = false;
$canverify = false;
if ($com_verify) {
$showverify = ($row['dispatchtype'] || $row['isverify']) && !$row['isonlyverifygoods'];
if ($row['isverify']) {
if (!$row['isonlyverifygoods']) {
if ($row['verifytype'] == 0 || $row['verifytype'] == 1 || $row['verifytype'] == 3) {
$vs = iunserializer($row['verifyinfo']);
$verifyinfo = array(
array('verifycode' => $row['verifycode'], 'verified' => $row['verifytype'] == 0 ? $row['verified'] : $row['goods'][0]['goods']['total'] <= count($vs))
);
if ($row['verifytype'] == 0 || $row['verifytype'] == 3) {
$canverify = empty($row['verified']) && $showverify;
}
else {
if ($row['verifytype'] == 1) {
$canverify = count($vs) < $row['goods'][0]['goods']['total'] && $showverify;
}
}
}
else {
$verifyinfo = iunserializer($row['verifyinfo']);
$last = 0;
foreach ($verifyinfo as $v) {
if (!$v['verified']) {
++$last;
}
}
$canverify = 0 < $last && $showverify;
}
}
}
else {
if (!empty($row['dispatchtype'])) {
$canverify = $row['status'] == 1 && $showverify;
}
}
}
$row['canverify'] = $canverify;
if ($is_openmerch == 1) {
$row['merchname'] = $merch_user[$row['merchid']]['merchname'] ? $merch_user[$row['merchid']]['merchname'] : $_W['shopset']['shop']['name'];
}
if ($row['isonlyverifygoods']) {
$row['canverify'] = false;
$verifygood = pdo_fetch('select * from ' . tablename('ewei_shop_verifygoods') . ' where orderid=:orderid limit 1', array(':orderid' => $row['id']));
if (!empty($verifygood)) {
$row['verifygoods_id'] = $verifygood['id'];
$verifynum = pdo_fetchcolumn('select sum(verifynum) from ' . tablename('ewei_shop_verifygoods_log') . ' where verifygoodsid =:id ', array(':id' => $verifygood['id']));
if (empty($verifygood['limittype'])) {
$limitdate = intval($verifygood['starttime']) + intval($verifygood['limitdays']) * 86400;
}
else {
$limitdate = intval($verifygood['limitdate']);
}
$row['canverify'] = time() <= $limitdate;
if (0 < $verifygood['limitnum']) {
$row['canverify'] = $verifynum < $verifygood['limitnum'];
}
}
}
}
unset($row);
show_json(1, array('list' => $list, 'pagesize' => $psize, 'total' => $total));
}
public function alipay()
{
global $_W;
global $_GPC;
$url = urldecode($_GPC['url']);
if (!is_weixin()) {
header('location: ' . $url);
exit();
}
include $this->template();
}
public function detail()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$member = m('member')->getMember($openid, true);
$orderid = intval($_GPC['id']);
$ispeerpay = m('order')->checkpeerpay($orderid);
$isshow = $_GPC['isshow'];
if (empty($orderid)) {
header('location: ' . mobileUrl('order'));
exit();
}
$order = pdo_fetch('select * from ' . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1', array(':id' => $orderid, ':uniacid' => $uniacid, ':openid' => $openid));
if ($order['iscycelbuy'] == 1) {
header('location:' . mobileUrl('cycelbuy/order/detail', array('id' => $order['id'])));
}
if (empty($order)) {
header('location: ' . mobileUrl('order'));
exit();
}
if ($order['merchshow'] == 1) {
header('location: ' . mobileUrl('order'));
exit();
}
if ($order['userdeleted'] == 2) {
$this->message('订单已经被删除!', '', 'error');
}
if (!empty($order['istrade'])) {
header('location: ' . mobileUrl('newstore/norder/detail', array('id' => $orderid)));
exit();
}
$isonlyverifygoods = m('order')->checkisonlyverifygoods($order['id']);
if ($order['refundid'] != 0) {
$refund = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_order_refund') . ' WHERE orderid = :orderid and uniacid=:uniacid order by id desc', array(':orderid' => $order['id'], ':uniacid' => $_W['uniacid']));
}
$area_set = m('util')->get_area_config_set();
$new_area = intval($area_set['new_area']);
$address_street = intval($area_set['address_street']);
$merchdata = $this->merchData();
extract($merchdata);
$merchid = $order['merchid'];
$diyform_plugin = p('diyform');
$diyformfields = '';
if ($diyform_plugin) {
$diyformfields = ',og.diyformfields,og.diyformdata';
}
$param = array();
$param[':uniacid'] = $_W['uniacid'];
if ($order['isparent'] == 1) {
$scondition = ' og.parentorderid=:parentorderid';
$param[':parentorderid'] = $orderid;
}
else {
$scondition = ' og.orderid=:orderid';
$param[':orderid'] = $orderid;
}
$condition1 = '';
if (p('ccard')) {
$condition1 .= ',g.ccardexplain,g.ccardtimeexplain';
}
$goodsid_array = array();
$goods = pdo_fetchall('select og.id,og.single_refundstate,og.sendtime,og.goodsid,og.price,g.title,og.title as gtitle,g.thumb,g.status, g.cannotrefund, og.total,g.credit,og.optionid,
og.optionname as optiontitle,g.isverify,g.storeids,g.type,og.seckill,g.isfullback,g.refund,g.returngoods,g.exchange,
og.seckill_taskid' . $diyformfields . $condition1 . ',og.prohibitrefund from ' . tablename('ewei_shop_order_goods') . ' og ' . ' left join ' . tablename('ewei_shop_goods') . ' g on g.id=og.goodsid ' . (' where ' . $scondition . ' and og.uniacid=:uniacid '), $param);
$prohibitrefund = false;
$isfullback = false;
foreach ($goods as &$g) {
if ($g['isfullback']) {
$isfullback = true;
$fullbackgoods = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_fullback_goods') . ' WHERE goodsid = :goodsid and uniacid = :uniacid limit 1 ', array(':goodsid' => $g['goodsid'], ':uniacid' => $uniacid));
if ($g['optionid']) {
$option = pdo_fetch('select `day`,allfullbackprice,fullbackprice,allfullbackratio,fullbackratio,isfullback
from ' . tablename('ewei_shop_goods_option') . ' where id = :id and uniacid = :uniacid ', array(':id' => $g['optionid'], ':uniacid' => $uniacid));
$fullbackgoods['minallfullbackallprice'] = $option['allfullbackprice'];
$fullbackgoods['fullbackprice'] = $option['fullbackprice'];
$fullbackgoods['minallfullbackallratio'] = $option['allfullbackratio'];
$fullbackgoods['fullbackratio'] = $option['fullbackratio'];
$fullbackgoods['day'] = $option['day'];
}
$g['fullbackgoods'] = $fullbackgoods;
unset($fullbackgoods);
unset($option);
}
$g['seckill_task'] = false;
if ($g['seckill']) {
$g['seckill_task'] = plugin_run('seckill::getTaskInfo', $g['seckill_taskid']);
}
if (!empty($g['prohibitrefund'])) {
$prohibitrefund = true;
}
if (empty($g['gtitle']) != true) {
$g['title'] = $g['gtitle'];
}
}
unset($g);
$goodsrefund = true;
$refundgoods = array('refund' => true, 'returngoods' => true, 'exchange' => true);
if (!empty($goods)) {
$entity = true;
foreach ($goods as &$g) {
$goodsid_array[] = $g['goodsid'];
if (!empty($g['optionid'])) {
$thumb = m('goods')->getOptionThumb($g['goodsid'], $g['optionid']);
if (!empty($thumb)) {
$g['thumb'] = $thumb;
}
}
if (empty($g['cannotrefund'])) {
$g['refund'] = true;
$g['returngoods'] = true;
$g['exchange'] = true;
}
if (($g['type'] == 2 || $g['type'] == 3) && $g['isverify'] < 2 || $order['paytype'] == -1) {
$g['refund'] = false;
$g['returngoods'] = false;
$g['exchange'] = false;
}
if (2 <= $order['status']) {
if (!empty($g['cannotrefund']) && empty($g['refund']) && empty($g['returngoods']) && empty($g['exchange'])) {
$goodsrefund = false;
}
}
if ($order['status'] == 1) {
if (!empty($g['cannotrefund']) && empty($g['refund'])) {
$goodsrefund = false;
}
$g['returngoods'] = false;
$g['exchange'] = false;
}
$refundgoods['refund'] = empty($refundgoods['refund']) ? false : $g['refund'];
$refundgoods['returngoods'] = empty($refundgoods['returngoods']) ? false : $g['returngoods'];
$refundgoods['exchange'] = empty($refundgoods['exchange']) ? false : $g['exchange'];
if ($g['type'] == 1 && ($entity = true)) {
$entity = true;
}
}
unset($g);
}
$diyform_flag = 0;
if ($diyform_plugin) {
foreach ($goods as &$g) {
$g['diyformfields'] = iunserializer($g['diyformfields']);
$g['diyformdata'] = iunserializer($g['diyformdata']);
unset($g);
}
if (!empty($order['diyformfields']) && !empty($order['diyformdata'])) {
$order_fields = iunserializer($order['diyformfields']);
$order_data = iunserializer($order['diyformdata']);
}
}
$address = false;
if (!empty($order['addressid'])) {
$address = iunserializer($order['address']);
if (!is_array($address)) {
$address = pdo_fetch('select * from ' . tablename('ewei_shop_member_address') . ' where id=:id limit 1', array(':id' => $order['addressid']));
}
}
$carrier = @iunserializer($order['carrier']);
if (!is_array($carrier) || empty($carrier)) {
$carrier = false;
}
$store = false;
if (!empty($order['storeid'])) {
if (0 < $merchid) {
$store = pdo_fetch('select * from ' . tablename('ewei_shop_merch_store') . ' where id=:id limit 1', array(':id' => $order['storeid']));
}
else {
$store = pdo_fetch('select * from ' . tablename('ewei_shop_store') . ' where id=:id limit 1', array(':id' => $order['storeid']));
}
}
$stores = false;
$showverify = false;
$canverify = false;
$verifyinfo = false;
if (com('verify')) {
$showverify = $order['dispatchtype'] || $order['isverify'];
if ($order['isverify']) {
if (0 < $order['verifyendtime'] && $order['verifyendtime'] < time()) {
$order['status'] = -1;
}
$storeids = array();
foreach ($goods as $g) {
if (!empty($g['storeids'])) {
$storeids = array_merge(explode(',', $g['storeids']), $storeids);
}
}
if (empty($storeids)) {
if (0 < $merchid) {
$stores = pdo_fetchall('select * from ' . tablename('ewei_shop_merch_store') . ' where uniacid=:uniacid and merchid=:merchid and status=1 and type in(2,3)', array(':uniacid' => $_W['uniacid'], ':merchid' => $merchid));
}
else {
$stores = pdo_fetchall('select * from ' . tablename('ewei_shop_store') . ' where uniacid=:uniacid and status=1 and type in(2,3)', array(':uniacid' => $_W['uniacid']));
}
}
else if (0 < $merchid) {
$stores = pdo_fetchall('select * from ' . tablename('ewei_shop_merch_store') . ' where id in (' . implode(',', $storeids) . ') and uniacid=:uniacid and merchid=:merchid and status=1 and type in(2,3)', array(':uniacid' => $_W['uniacid'], ':merchid' => $merchid));
}
else {
$stores = pdo_fetchall('select * from ' . tablename('ewei_shop_store') . ' where id in (' . implode(',', $storeids) . ') and uniacid=:uniacid and status=1 and type in(2,3)', array(':uniacid' => $_W['uniacid']));
}
if ($order['verifytype'] == 0 || $order['verifytype'] == 1 || $order['verifytype'] == 3) {
$vs = iunserializer($order['verifyinfo']);
$verifyinfo = array(
array('verifycode' => $order['verifycode'], 'verified' => $order['verifytype'] == 0 || $order['verifytype'] == 3 ? $order['verified'] : $goods[0]['total'] <= count($vs))
);
if ($order['verifytype'] == 0 || $order['verifytype'] == 3) {
$canverify = empty($order['verified']) && $showverify;
}
else {
if ($order['verifytype'] == 1) {
$canverify = count($vs) < $goods[0]['total'] && $showverify;
}
}
}
else {
$verifyinfo = iunserializer($order['verifyinfo']);
$last = 0;
foreach ($verifyinfo as $v) {
if (!$v['verified']) {
++$last;
}
}
$canverify = 0 < $last && $showverify;
}
}
else {
if (!empty($order['dispatchtype'])) {
$verifyinfo = array(
array('verifycode' => $order['verifycode'], 'verified' => $order['status'] == 3)
);
$canverify = $order['status'] == 1 && $showverify;
}
}
}
$order['canverify'] = $canverify;
$order['showverify'] = $showverify;
$order['virtual_str'] = str_replace('
', '<br/>', $order['virtual_str']);
$canreturn = false;
$tradeset = m('common')->getSysset('trade');
if ($order['status'] == 1) {
$canrefund = $goodsrefund;
}
else if ($order['status'] == 2) {
$canrefund = true;
if ($order['status'] == 2 && $order['price'] == $order['dispatchprice']) {
if (0 < $order['refundstate']) {
$canrefund = true;
}
else {
$canrefund = false;
if (!$goodsrefund) {
$canreturn = false;
}
else {
$canreturn = true;
}
}
}
}
else if ($order['status'] == 3) {
if ($order['isverify'] != 1 && empty($order['virtual'])) {
if (0 < $order['refundstate']) {
$canrefund = true;
}
else {
$refunddays = intval($tradeset['refunddays']);
if (0 < $refunddays) {
$days = intval((time() - $order['finishtime']) / 3600 / 24);
if ($days <= $refunddays) {
$canrefund = true;
}
}
}
}
}
else {
if ($order['status'] == -1 && $order['isverify'] == 1 && $entity) {
$canrefund = true;
}
}
if (!empty($order['isnewstore']) && 1 < $order['status']) {
$canrefund = false;
}
if ($prohibitrefund) {
$canrefund = false;
}
if (!$goodsrefund && $canrefund) {
$canrefund = false;
}
if ($canrefund && ($refundgoods['refund'] || $refundgoods['returngoods'] || $refundgoods['exchange'])) {
$canrefund = true;
}
else {
$canrefund = false;
}
if (p('ccard')) {
if (!empty($order['ccard']) && 1 < $order['status']) {
$canrefund = false;
}
$comdata = m('common')->getPluginset('commission');
if (!empty($comdata['become_goodsid']) && !empty($goodsid_array)) {
if (in_array($comdata['become_goodsid'], $goodsid_array)) {
$canrefund = false;
}
}
}
$haveverifygoodlog = m('order')->checkhaveverifygoodlog($orderid);
if ($haveverifygoodlog) {
$canrefund = false;
}
$order['canrefund'] = $canrefund;
$express = false;
$order_goods = array();
if (2 <= $order['status'] && empty($order['isvirtual']) && empty($order['isverify'])) {
$expresslist = m('util')->getExpressList($order['express'], $order['expresssn']);
if (0 < count($expresslist)) {
$express = $expresslist[0];
}
}
if (0 < $order['sendtype'] && 1 <= $order['status']) {
$order_goods = pdo_fetchall('select orderid,goodsid,sendtype,expresscom,expresssn,express,sendtime from ' . tablename('ewei_shop_order_goods') . '
where orderid = ' . $orderid . ' and uniacid = ' . $uniacid . ' and sendtype > 0 group by sendtype order by sendtime asc ');
$expresslist = m('util')->getExpressList($order['express'], $order['expresssn']);
if (0 < count($expresslist)) {
$express = $expresslist[0];
}
$order['sendtime'] = $order_goods[0]['sendtime'];
}
$shopname = $_W['shopset']['shop']['name'];
if ($order['canverify'] && $order['status'] != -1 && $order['status'] != 0) {
$query = array('id' => $order['id'], 'verifycode' => $order['verifycode']);
if (!$isonlyverifygoods) {
if (empty($order['istrade'])) {
$url = mobileUrl('verify/detail', $query, true);
}
else {
$url = mobileUrl('verify/tradedetail', $query, true);
}
$verifycode = $order['verifycode'];
$qrcodeimg = m('qrcode')->createQrcode($url);
if (strlen($verifycode) == 8) {
$verifycode = substr($verifycode, 0, 4) . ' ' . substr($verifycode, 4, 4);
}
else {
if (strlen($verifycode) == 9) {
$verifycode = substr($verifycode, 0, 3) . ' ' . substr($verifycode, 3, 3) . ' ' . substr($verifycode, 6, 3);
}
}
}
}
if (!empty($order['merchid']) && $is_openmerch == 1) {
$merch_user = $merch_plugin->getListUser($order['merchid']);
$shopname = $merch_user['merchname'];
$shoplogo = tomedia($merch_user['logo']);
}
if (com('coupon')) {
$activity = com('coupon')->activity($order['price']);
}
if (!empty($order['virtual']) && !empty($order['virtual_str'])) {
$ordervirtual = m('order')->getOrderVirtual($order);
$virtualtemp = pdo_fetch('SELECT linktext, linkurl,description FROM ' . tablename('ewei_shop_virtual_type') . ' WHERE id=:id AND uniacid=:uniacid LIMIT 1', array(':id' => $order['virtual'], ':uniacid' => $_W['uniacid']));
}
if (0 < $order['seckilldiscountprice'] && p('diypage')) {
$diypagedata = m('common')->getPluginset('diypage');
$diypage = p('diypage')->seckillPage($diypagedata['seckill']);
if (!empty($diypage)) {
$seckill_color = $diypage['seckill_color'];
}
}
$use_membercard = false;
$membercard_info = array();
$plugin_membercard = p('membercard');
if ($plugin_membercard) {
$ifuse = $plugin_membercard->if_order_use_membercard($orderid);
if ($ifuse) {
$use_membercard = true;
$card_text = $ifuse['name'] . '优惠';
$card_dec_price = $ifuse['dec_price'];
}
}
if ($order['isvirtualsend'] && $order['isvirtual']) {
$order['canrefund'] = false;
}
if (empty($order['ispackage']) && empty($ispeerpay) && empty($isfullback) && !empty($tradeset['single_refund']) || $order['refundstate'] == 3) {
$is_single_refund = true;
}
else {
$is_single_refund = false;
}
if ($order['paytype'] == -1) {
$order['canrefund'] = false;
}
include $this->template();
}
public function express()
{
global $_W;
global $_GPC;
global $_W;
global $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$orderid = intval($_GPC['id']);
$sendtype = intval($_GPC['sendtype']);
$bundle = trim($_GPC['bundle']);
if (empty($orderid)) {
header('location: ' . mobileUrl('order'));
exit();
}
$order = pdo_fetch('select * from ' . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1', array(':id' => $orderid, ':uniacid' => $uniacid, ':openid' => $openid));
if (empty($order)) {
header('location: ' . mobileUrl('order'));
exit();
}
$bundlelist = array();
if (0 < $order['sendtype'] && $sendtype == 0) {
$i = 1;
while ($i <= intval($order['sendtype'])) {
$bundlelist[$i]['sendtype'] = $i;
$bundlelist[$i]['orderid'] = $orderid;
$bundlelist[$i]['goods'] = pdo_fetchall('select g.title,g.thumb,og.total,og.optionname as optiontitle,og.expresssn,og.express,
og.sendtype,og.expresscom,og.sendtime from ' . tablename('ewei_shop_order_goods') . ' og ' . ' left join ' . tablename('ewei_shop_goods') . ' g on g.id=og.goodsid ' . ' where og.orderid=:orderid and og.sendtype = ' . $i . ' and og.uniacid=:uniacid ', array(':uniacid' => $uniacid, ':orderid' => $orderid));
if (empty($bundlelist[$i]['goods'])) {
unset($bundlelist[$i]);
}
++$i;
}
$bundlelist = array_values($bundlelist);
}
if (empty($order['addressid'])) {
$this->message('订单非快递单,无法查看物流信息!');
}
if (!(2 <= $order['status']) && !(1 <= $order['status'] && 0 < $order['sendtype'])) {
$this->message('订单未发货,无法查看物流信息!');
}
$condition = '';
if (0 < $sendtype) {
$condition = ' and og.sendtype = ' . $sendtype;
}
$goods = pdo_fetchall('select og.goodsid,og.price,g.title,g.thumb,og.total,g.credit,og.optionid,og.optionname as optiontitle,g.isverify,og.expresssn,og.express,
og.sendtype,og.expresscom,og.sendtime,g.storeids' . $diyformfields . '
from ' . tablename('ewei_shop_order_goods') . ' og ' . ' left join ' . tablename('ewei_shop_goods') . ' g on g.id=og.goodsid ' . ' where og.orderid=:orderid and og.single_refundtime=0 ' . $condition . ' and og.uniacid=:uniacid ', array(':uniacid' => $uniacid, ':orderid' => $orderid));
if (0 < $sendtype) {
$order['express'] = $goods[0]['express'];
$order['expresssn'] = $goods[0]['expresssn'];
$order['expresscom'] = $goods[0]['expresscom'];
}
$user['mobile'] = '';
if ($order['express'] == 'shunfeng') {
if (empty($order['addressid'])) {
$user = unserialize($order['carrier']);
}
else {
$user = iunserializer($order['address']);
if (!is_array($user)) {
$user = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_member_address') . ' WHERE id = :id and uniacid=:uniacid', array(':id' => $item['addressid'], ':uniacid' => $_W['uniacid']));
}
}
}
$expresslist = m('util')->getExpressList($order['express'], $order['expresssn'], $user['mobile']);
include $this->template();
}
public function dispatch()
{
global $_W;
global $_GPC;
$merchid = intval($_GPC['merchid']);
$list = m('dispatch')->getDispatchList($merchid);
include $this->template();
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,527 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Log_EweiShopV2Page extends WebPage
{
protected function main($type = 0)
{
global $_W;
global $_GPC;
$pindex = max(1, intval($_GPC['page']));
$psize = 20;
$condition = ' and log.uniacid=:uniacid and log.type=:type and log.money<>0';
$condition1 = '';
$params = array(':uniacid' => $_W['uniacid'], ':type' => $type);
if (!empty($_GPC['keyword'])) {
$_GPC['keyword'] = trim($_GPC['keyword']);
if ($_GPC['searchfield'] == 'logno') {
$condition .= ' and log.logno like :keyword';
}
else {
if ($_GPC['searchfield'] == 'member') {
$condition1 .= ' and (m.realname like :keyword or m.nickname like :keyword or m.mobile like :keyword)';
}
}
$params[':keyword'] = '%' . $_GPC['keyword'] . '%';
}
if (!empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) {
$starttime = strtotime($_GPC['time']['start']);
$endtime = strtotime($_GPC['time']['end']);
$params[':starttime'] = $starttime;
$params[':endtime'] = $endtime;
}
else {
if (empty($starttime) || empty($endtime)) {
$starttime = strtotime('-12 month');
$endtime = time();
$params[':starttime'] = $starttime;
$params[':endtime'] = $endtime;
}
}
$condition .= ' AND log.createtime >= :starttime AND log.createtime <= :endtime ';
if (!empty($_GPC['level'])) {
$condition1 .= ' and m.level=' . intval($_GPC['level']);
}
if (!empty($_GPC['groupid'])) {
$condition1 .= ' and m.groupid=' . intval($_GPC['groupid']);
}
$member_sql = '';
if (!empty($_GPC['rechargetype'])) {
$_GPC['rechargetype'] = trim($_GPC['rechargetype']);
if ($_GPC['rechargetype'] == 'system1') {
$condition .= ' AND log.rechargetype=\'system\' and log.money<0';
}
else {
$condition .= ' AND log.rechargetype=:rechargetype';
$params[':rechargetype'] = $_GPC['rechargetype'];
}
}
if ($_GPC['status'] != '') {
$condition .= ' and log.status=' . intval($_GPC['status']);
}
$sql = 'select log.id,log.openid,log.logno,log.type,log.status,log.rechargetype,log.sendmoney,log.money,log.createtime,log.realmoney,log.deductionmoney,log.charge,log.remark,log.alipay,log.bankname,log.bankcard,log.realname as applyrealname,log.applytype,m.nickname,m.id as mid,m.avatar,m.level,m.groupid,m.realname,m.mobile,g.groupname,l.levelname from ' . tablename('ewei_shop_member_log') . ' log ' . ' left join ' . tablename('ewei_shop_member') . ' m on m.openid = log.openid ' . ' left join ' . tablename('ewei_shop_member_group') . ' g on g.id = m.groupid ' . ' left join ' . tablename('ewei_shop_member_level') . ' l on l.id = m.level ' . (' where 1 ' . $condition . ' ' . $condition1 . ' GROUP BY log.id ORDER BY log.createtime DESC ');
if (empty($_GPC['export'])) {
$sql .= 'LIMIT ' . ($pindex - 1) * $psize . ',' . $psize;
}
$list = pdo_fetchall($sql, $params);
$apply_type = array(0 => '微信钱包', 2 => '支付宝', 3 => '银行卡');
$openids = array();
if (!empty($list)) {
foreach ($list as $key => $value) {
$list[$key]['typestr'] = $apply_type[$value['applytype']];
$list[$key]['bankcard'] = $list[$key]['bankcard'] . ' ';
if ($value['deductionmoney'] == 0) {
$list[$key]['realmoney'] = $value['money'];
}
if (!strexists($value['openid'], 'sns_wa_')) {
array_push($openids, $value['openid']);
}
else {
array_push($openids, substr($value['openid'], 7));
}
}
$openids = array_filter($openids);
$members_sql = 'select id as mid, realname,avatar,weixin,nickname,mobile,openid,openid_wa from ' . tablename('ewei_shop_member') . ' m where uniacid=:uniacid and (openid IN (\'' . implode('\',\'', array_unique($openids)) . '\') OR openid_wa IN (\'' . implode('\',\'', array_unique($openids)) . '\'))';
$members = pdo_fetchall($members_sql, array(':uniacid' => $_W['uniacid']), 'openid');
$rs = array();
if (!empty($members)) {
foreach ($members as $key => &$row) {
if (!empty($row['openid_wa'])) {
$rs['sns_wa_' . $row['openid_wa']] = $row;
}
else {
$rs[] = $row;
}
}
}
$member_openids = array_keys($members);
foreach ($list as $key => $value) {
if (in_array($list[$key]['openid'], $member_openids)) {
$list[$key] = array_merge($list[$key], $members[$list[$key]['openid']]);
}
else {
$list[$key] = array_merge($list[$key], isset($rs[$list[$key]['openid']]) ? $rs[$list[$key]['openid']] : array());
}
}
}
if ($_GPC['export'] == 1) {
if ($_GPC['type'] == 1) {
plog('finance.log.withdraw.export', '导出提现记录');
}
else {
plog('finance.log.recharge.export', '导出充值记录');
}
foreach ($list as &$row) {
$row['createtime'] = date('Y-m-d H:i', $row['createtime']);
$row['groupname'] = empty($row['groupname']) ? '无分组' : $row['groupname'];
$row['levelname'] = empty($row['levelname']) ? '普通会员' : $row['levelname'];
$row['typestr'] = $apply_type[$row['applytype']];
if ($row['status'] == 0) {
if ($row['type'] == 0) {
$row['status'] = '未充值';
}
else {
$row['status'] = '申请中';
}
}
else if ($row['status'] == 1) {
if ($row['type'] == 0) {
$row['status'] = '充值成功';
}
else {
$row['status'] = '完成';
}
}
else {
if ($row['status'] == -1) {
if ($row['type'] == 0) {
$row['status'] = '';
}
else {
$row['status'] = '失败';
}
}
}
if ($row['rechargetype'] == 'system') {
$row['rechargetype'] = '后台';
}
else if ($row['rechargetype'] == 'wechat') {
$row['rechargetype'] = '微信';
}
else {
if ($row['rechargetype'] == 'alipay') {
$row['rechargetype'] = '支付宝';
}
}
}
unset($row);
$columns = array();
$columns[] = array('title' => '昵称', 'field' => 'nickname', 'width' => 12);
$columns[] = array('title' => '姓名', 'field' => 'realname', 'width' => 12);
$columns[] = array('title' => '手机号', 'field' => 'mobile', 'width' => 12);
$columns[] = array('title' => '会员等级', 'field' => 'levelname', 'width' => 12);
$columns[] = array('title' => '会员分组', 'field' => 'groupname', 'width' => 12);
$columns[] = array('title' => empty($type) ? '充值金额' : '提现金额', 'field' => 'money', 'width' => 12);
if (!empty($type)) {
$columns[] = array('title' => '到账金额', 'field' => 'realmoney', 'width' => 12);
$columns[] = array('title' => '手续费金额', 'field' => 'deductionmoney', 'width' => 12);
$columns[] = array('title' => '提现方式', 'field' => 'typestr', 'width' => 12);
$columns[] = array('title' => '提现姓名', 'field' => 'applyrealname', 'width' => 24);
$columns[] = array('title' => '支付宝', 'field' => 'alipay', 'width' => 24);
$columns[] = array('title' => '银行', 'field' => 'bankname', 'width' => 24);
$columns[] = array('title' => '银行卡号', 'field' => 'bankcard', 'width' => 24);
$columns[] = array('title' => '申请时间', 'field' => 'applytime', 'width' => 24);
}
$columns[] = array('title' => empty($type) ? '充值时间' : '提现申请时间', 'field' => 'createtime', 'width' => 12);
if (empty($type)) {
$columns[] = array('title' => '充值方式', 'field' => 'rechargetype', 'width' => 12);
}
$columns[] = array('title' => '备注', 'field' => 'remark', 'width' => 24);
m('excel')->export($list, array('title' => (empty($type) ? '会员充值数据-' : '会员提现记录') . date('Y-m-d-H-i', time()), 'columns' => $columns));
}
if ($condition1 != '') {
$condition_member = pdo_fetchall('SELECT openid FROM ' . tablename('ewei_shop_member') . ('m WHERE m.uniacid = :uniacid ' . $condition1), array(':uniacid' => $_W['uniacid'], ':keyword' => '%' . $_GPC['keyword'] . '%'));
$condition_member2 = pdo_fetchall('SELECT CONCAT(\'sns_wa_\',openid_wa) FROM ' . tablename('ewei_shop_member') . (' m WHERE m.uniacid = :uniacid ' . $condition1), array(':uniacid' => $_W['uniacid'], ':keyword' => '%' . $_GPC['keyword'] . '%'));
$condition_member = array_column($condition_member, 'openid');
$condition_member2 = array_column($condition_member2, 'openid');
$member_sql = ' and (openid IN (\'' . implode('\',\'', array_unique($condition_member)) . '\') OR openid IN (\'' . implode('\',\'', array_unique($condition_member2)) . '\'))';
unset($params[':keyword']);
}
$total = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_member_log') . ' log ' . (' where 1 ' . $condition . ' ' . $member_sql), $params);
$pager = pagination2($total, $pindex, $psize);
$groups = m('member')->getGroups();
$levels = m('member')->getLevels();
include $this->template();
}
public function refund($tid = 0, $fee = 0, $reason = '')
{
global $_W;
global $_GPC;
$set = $_W['shopset']['shop'];
$id = intval($_GPC['id']);
$log = pdo_fetch('select * from ' . tablename('ewei_shop_member_log') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($log)) {
show_json(0, '未找到记录!');
}
if (!empty($log['type'])) {
show_json(0, '非充值记录!');
}
if ($log['rechargetype'] == 'system') {
show_json(0, '后台充值无法退款!');
}
$current_credit = m('member')->getCredit($log['openid'], 'credit2');
if ($current_credit < $log['money']) {
show_json(0, '会员账户余额不足,无法进行退款!');
}
$out_refund_no = 'RR' . substr($log['logno'], 2);
if ($log['rechargetype'] == 'wechat') {
if ($log['apppay'] == 2) {
$result = m('finance')->wxapp_refund($log['openid'], $log['logno'], $out_refund_no, $log['money'] * 100, $log['money'] * 100, !empty($log['apppay']) ? true : false);
}
else if (empty($log['isborrow'])) {
$result = m('finance')->refund($log['openid'], $log['logno'], $out_refund_no, $log['money'] * 100, $log['money'] * 100, !empty($log['apppay']) ? true : false);
}
else {
$result = m('finance')->refundBorrow($log['openid'], $log['logno'], $out_refund_no, $log['money'] * 100, $log['money'] * 100);
}
}
else if ($log['rechargetype'] == 'alipay') {
$sec = m('common')->getSec();
$sec = iunserializer($sec['sec']);
if (!empty($log['apppay'])) {
if (!empty($sec['app_alipay']['private_key_rsa2'])) {
$sign_type = 'RSA2';
$privatekey = $sec['app_alipay']['private_key_rsa2'];
}
else {
$sign_type = 'RSA';
$privatekey = $sec['app_alipay']['private_key'];
}
if (empty($privatekey) || empty($sec['app_alipay']['appid'])) {
show_json(0, '支付参数错误私钥为空或者APPID为空!');
}
$params = array('out_trade_no' => $log['logno'], 'refund_amount' => $log['money'], 'refund_reason' => '会员充值退款: ' . $log['money'] . '元 订单号: ' . $log['logno'] . '/' . $out_refund_no);
$config = array('app_id' => $sec['app_alipay']['appid'], 'privatekey' => $privatekey, 'publickey' => '', 'alipublickey' => '', 'sign_type' => $sign_type);
$result = m('finance')->newAlipayRefund($params, $config);
}
else if (!empty($sec['alipay_pay'])) {
if (empty($sec['alipay_pay']['private_key']) || empty($sec['alipay_pay']['appid'])) {
show_json(0, '支付参数错误私钥为空或者APPID为空!');
}
if ($sec['alipay_pay']['alipay_sign_type'] == 1) {
$sign_type = 'RSA2';
}
else {
$sign_type = 'RSA';
}
$params = array('out_request_no' => time(), 'out_trade_no' => $log['logno'], 'refund_amount' => $log['money'], 'refund_reason' => '会员充值退款: ' . $log['money'] . '元 订单号: ' . $log['logno'] . '/' . $out_refund_no);
$config = array('app_id' => $sec['alipay_pay']['appid'], 'privatekey' => $sec['alipay_pay']['private_key'], 'publickey' => '', 'alipublickey' => '', 'sign_type' => $sign_type);
$result = m('finance')->newAlipayRefund($params, $config);
}
else {
if (empty($log['transid'])) {
show_json(0, '仅支持 升级后此功能后退款的订单!');
}
$setting = uni_setting($_W['uniacid'], array('payment'));
if (!is_array($setting['payment'])) {
return error(1, '没有设定支付参数');
}
$alipay_config = $setting['payment']['alipay'];
$batch_no_money = $log['money'] * 100;
$batch_no = date('Ymd') . 'RC' . $log['id'] . 'MONEY' . $batch_no_money;
$res = m('finance')->AlipayRefund(array('trade_no' => $log['transid'], 'refund_price' => $log['money'], 'refund_reason' => '会员充值退款: ' . $log['money'] . '元 订单号: ' . $log['logno'] . '/' . $out_refund_no), $batch_no, $alipay_config);
if (is_error($res)) {
show_json(0, $res['message']);
}
show_json(1, array('url' => $res));
}
}
else {
$result = m('finance')->pay($log['openid'], 1, $log['money'] * 100, $out_refund_no, $set['name'] . '充值退款');
}
if (is_error($result)) {
show_json(0, $result['message']);
}
pdo_update('ewei_shop_member_log', array('status' => 3), array('id' => $id, 'uniacid' => $_W['uniacid']));
$refundmoney = $log['money'] + $log['gives'];
m('member')->setCredit($log['openid'], 'credit2', 0 - $refundmoney, array(0, $set['name'] . '充值退款'));
$money = com_run('sale::getCredit1', $log['openid'], (double) $log['money'], 21, 2, 1);
if (0 < $money) {
m('notice')->sendMemberPointChange($log['openid'], $money, 1);
}
m('notice')->sendMemberLogMessage($log['id']);
$member = m('member')->getMember($log['openid']);
plog('finance.log.refund', '充值退款 ID: ' . $log['id'] . ' 金额: ' . $log['money'] . ' <br/>会员信息: ID: ' . $member['id'] . ' / ' . $member['openid'] . '/' . $member['nickname'] . '/' . $member['realname'] . '/' . $member['mobile']);
show_json(1, array('url' => referer()));
}
public function wechat()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$log = pdo_fetch('select * from ' . tablename('ewei_shop_member_log') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($log)) {
show_json(0, '未找到记录!');
}
if ($log['deductionmoney'] == 0) {
$realmoney = $log['money'];
}
else {
$realmoney = $log['realmoney'];
}
$set_name = $_W['shopset']['shop']['name'];
$account_name = $_W['account']['name'];
$shop_name = empty($account_name) ? $set_name : $account_name;
$desc = $shop_name . '余额提现';
$data = m('common')->getSysset('pay');
if (!empty($data['paytype']['withdraw'])) {
if (strpos($log['openid'], 'sns_wa_') === false) {
$result = m('finance')->payRedPack($log['openid'], $realmoney * 100, $log['logno'], $log, $desc, $data['paytype']);
pdo_update('ewei_shop_member_log', array('sendmoney' => $result['sendmoney'], 'senddata' => json_encode($result['senddata'])), array('id' => $log['id']));
if ($result['sendmoney'] == $realmoney) {
$result = true;
}
else {
$result = $result['error'];
}
}
else {
show_json(0, '小程序用户打款,请将余额提现打款方式改为企业打款!');
}
}
else {
$result = m('finance')->pay($log['openid'], 1, $realmoney * 100, $log['logno'], $desc);
}
if (is_error($result)) {
show_json(0, array('message' => $result['message']));
}
pdo_update('ewei_shop_member_log', array('status' => 1), array('id' => $id, 'uniacid' => $_W['uniacid']));
m('notice')->sendMemberLogMessage($log['id']);
$member = m('member')->getMember($log['openid']);
plog('finance.log.wechat', '余额提现 ID: ' . $log['id'] . ' 方式: 微信 提现金额: ' . $log['money'] . ' ,到账金额: ' . $realmoney . ' ,手续费金额 : ' . $log['deductionmoney'] . '<br/>会员信息: ID: ' . $member['id'] . ' / ' . $member['openid'] . '/' . $member['nickname'] . '/' . $member['realname'] . '/' . $member['mobile']);
show_json(1);
}
public function alipay()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$log = pdo_fetch('select * from ' . tablename('ewei_shop_member_log') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($log)) {
show_json(0, '未找到记录!');
}
if ($log['deductionmoney'] == 0) {
$realmoeny = $log['money'];
}
else {
$realmoeny = $log['realmoney'];
}
$set = $_W['shopset']['shop'];
$sec = m('common')->getSec();
$sec = iunserializer($sec['sec']);
if (!empty($sec['alipay_pay']['open'])) {
if ($sec['alipay_pay']['sign_type'] == 1) {
$batch_no_money = $realmoeny * 100;
$batch_no = 'D' . date('YmdHis') . 'RW' . $log['id'] . 'MONEY' . $batch_no_money;
$single_res = m('finance')->singleAliPay(array('account' => $log['alipay'], 'name' => $log['realname'], 'money' => $realmoeny), $batch_no, $sec['alipay_pay'], $log['title']);
if ($single_res['errno'] == '-1') {
show_json(0, $single_res['message']);
}
$order_id = $single_res['order_id'];
$query_res = m('finance')->querySingleAliPay($sec['alipay_pay'], $order_id, $batch_no);
if ($query_res['errno'] == '-1') {
show_json(0, $query_res['message']);
}
pdo_update('ewei_shop_member_log', array('status' => 1), array('id' => $id, 'uniacid' => $_W['uniacid']));
m('notice')->sendMemberLogMessage($log['id']);
$member = m('member')->getMember($log['openid']);
plog('finance.log.alipay', '余额提现 ID: ' . $log['id'] . ' 方式: 支付宝 提现金额: ' . $log['money'] . ' ,到账金额: ' . $realmoney . ' ,手续费金额 : ' . $log['deductionmoney'] . '<br/>会员信息: ID: ' . $member['id'] . ' / ' . $member['openid'] . '/' . $member['nickname'] . '/' . $member['realname'] . '/' . $member['mobile']);
show_json(1);
}
else {
$batch_no_money = $realmoeny * 100;
$batch_no = 'D' . date('Ymd') . 'RW' . $log['id'] . 'MONEY' . $batch_no_money;
$res = m('finance')->AliPay(array('account' => $log['alipay'], 'name' => $log['realname'], 'money' => $realmoeny), $batch_no, $sec['alipay_pay'], $log['title']);
if (is_error($res)) {
show_json(0, $res['message']);
}
show_json(1, array('url' => $res));
}
}
show_json(0, '未开启,支付宝打款!');
}
public function manual()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$log = pdo_fetch('select * from ' . tablename('ewei_shop_member_log') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($log)) {
show_json(0, '未找到记录!');
}
$member = m('member')->getMember($log['openid']);
pdo_update('ewei_shop_member_log', array('status' => 1), array('id' => $id, 'uniacid' => $_W['uniacid']));
m('notice')->sendMemberLogMessage($log['id']);
plog('finance.log.manual', '余额提现 方式: 手动 ID: ' . $log['id'] . ' <br/>会员信息: ID: ' . $member['id'] . ' / ' . $member['openid'] . '/' . $member['nickname'] . '/' . $member['realname'] . '/' . $member['mobile']);
show_json(1);
}
public function refuse()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$log = pdo_fetch('select * from ' . tablename('ewei_shop_member_log') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($log)) {
show_json(0, '未找到记录!');
}
if ($log['status'] == -1) {
show_json(0, '退款申请已经处理!');
}
pdo_update('ewei_shop_member_log', array('status' => -1), array('id' => $id, 'uniacid' => $_W['uniacid']));
if (0 < $log['money']) {
m('member')->setCredit($log['openid'], 'credit2', $log['money'], array(0, '余额提现退回'));
}
$member = pdo_fetchall('SELECT * FROM ' . tablename('ewei_shop_member') . ' WHERE uniacid =:uniacid AND openid=:openid', array(':uniacid' => $_W['uniacid'], ':openid' => $log['openid']));
m('notice')->sendMemberLogMessage($log['id']);
plog('finance.log.refuse', '拒绝余额度提现 ID: ' . $log['id'] . ' 金额: ' . $log['money'] . ' <br/>会员信息: ID: ' . $member['id'] . ' / ' . $member['openid'] . '/' . $member['nickname'] . '/' . $member['realname'] . '/' . $member['mobile']);
show_json(1);
}
public function recharge()
{
$this->main(0);
}
public function withdraw()
{
$this->main(1);
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,214 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Dispatch_EweiShopV2Page extends WebPage
{
public function main()
{
global $_W;
global $_GPC;
$pindex = max(1, intval($_GPC['page']));
$psize = 20;
$condition = ' and uniacid=:uniacid and merchid=0';
$params = array(':uniacid' => $_W['uniacid']);
if ($_GPC['enabled'] != '') {
$condition .= ' and enabled=' . intval($_GPC['enabled']);
}
if (!empty($_GPC['keyword'])) {
$_GPC['keyword'] = trim($_GPC['keyword']);
$condition .= ' and dispatchname like :keyword';
$params[':keyword'] = '%' . $_GPC['keyword'] . '%';
}
$list = pdo_fetchall('SELECT * FROM ' . tablename('ewei_shop_dispatch') . (' WHERE 1 ' . $condition . ' ORDER BY displayorder DESC limit ') . ($pindex - 1) * $psize . ',' . $psize, $params);
$total = pdo_fetchcolumn('SELECT count(*) FROM ' . tablename('ewei_shop_dispatch') . (' WHERE 1 ' . $condition), $params);
$pager = pagination2($total, $pindex, $psize);
include $this->template();
}
public function add()
{
$this->post();
}
public function edit()
{
$this->post();
}
protected function post()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
if ($_W['ispost']) {
$areas = array();
$randoms = $_GPC['random'];
if (is_array($randoms)) {
foreach ($randoms as $random) {
$citys = trim($_GPC['citys'][$random]);
if (empty($citys)) {
continue;
}
if ($_GPC['firstnum'][$random] < 1) {
$_GPC['firstnum'][$random] = 1;
}
if ($_GPC['secondnum'][$random] < 1) {
$_GPC['secondnum'][$random] = 1;
}
$areas[] = array('citys' => $_GPC['citys'][$random], 'citys_code' => $_GPC['citys_code'][$random], 'firstprice' => $_GPC['firstprice'][$random], 'firstweight' => max(0, $_GPC['firstweight'][$random]), 'secondprice' => $_GPC['secondprice'][$random], 'secondweight' => $_GPC['secondweight'][$random] <= 0 ? 1000 : $_GPC['secondweight'][$random], 'firstnumprice' => $_GPC['firstnumprice'][$random], 'firstnum' => $_GPC['firstnum'][$random], 'secondnumprice' => $_GPC['secondnumprice'][$random], 'secondnum' => $_GPC['secondnum'][$random], 'freeprice' => $_GPC['freeprice'][$random]);
}
}
$_GPC['default_firstnum'] = trim($_GPC['default_firstnum']);
if ($_GPC['default_firstnum'] < 1) {
$_GPC['default_firstnum'] = 1;
}
$_GPC['default_secondnum'] = trim($_GPC['default_secondnum']);
if ($_GPC['default_secondnum'] < 1) {
$_GPC['default_secondnum'] = 1;
}
$data = array('uniacid' => $_W['uniacid'], 'merchid' => 0, 'displayorder' => intval($_GPC['displayorder']), 'dispatchtype' => intval($_GPC['dispatchtype']), 'isdefault' => intval($_GPC['isdefault']), 'dispatchname' => trim($_GPC['dispatchname']), 'express' => trim($_GPC['express']), 'calculatetype' => trim($_GPC['calculatetype']), 'firstprice' => trim($_GPC['default_firstprice']), 'firstweight' => trim(max(0, $_GPC['default_firstweight'])), 'secondprice' => trim($_GPC['default_secondprice']), 'secondweight' => intval($_GPC['default_secondweight']) <= 0 ? 1000 : trim($_GPC['default_secondweight']), 'firstnumprice' => trim($_GPC['default_firstnumprice']), 'firstnum' => $_GPC['default_firstnum'], 'secondnumprice' => trim($_GPC['default_secondnumprice']), 'secondnum' => $_GPC['default_secondnum'], 'freeprice' => $_GPC['default_freeprice'], 'areas' => iserializer($areas), 'nodispatchareas' => !empty($_GPC['nodispatchareas']) ? iserializer($_GPC['nodispatchareas']) : '', 'nodispatchareas_code' => !empty($_GPC['nodispatchareas_code']) ? iserializer($_GPC['nodispatchareas_code']) : '', 'isdispatcharea' => intval($_GPC['isdispatcharea']), 'enabled' => intval($_GPC['enabled']));
if ($data['isdefault']) {
pdo_update('ewei_shop_dispatch', array('isdefault' => 0), array('uniacid' => $_W['uniacid'], 'merchid' => 0));
}
if (!empty($id)) {
plog('shop.dispatch.edit', '修改配送方式 ID: ' . $id);
pdo_update('ewei_shop_dispatch', $data, array('id' => $id));
}
else {
pdo_insert('ewei_shop_dispatch', $data);
$id = pdo_insertid();
plog('shop.dispatch.add', '添加配送方式 ID: ' . $id);
}
show_json(1, array('url' => webUrl('shop/dispatch', array('op' => 'display'))));
}
$dispatch = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_dispatch') . (' WHERE id = \'' . $id . '\' and merchid=0 and uniacid = \'' . $_W['uniacid'] . '\''));
if (!empty($dispatch)) {
$dispatch_areas = unserialize($dispatch['areas']);
$dispatch_carriers = unserialize($dispatch['carriers']);
$dispatch_nodispatchareas = unserialize($dispatch['nodispatchareas']);
$dispatch_nodispatchareas_code = unserialize($dispatch['nodispatchareas_code']);
}
$area_set = m('util')->get_area_config_set();
$new_area = intval($area_set['new_area']);
$areas = m('common')->getAreas();
$express_list = m('express')->getExpressList();
include $this->template();
}
public function delete()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
if (empty($id)) {
$id = is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0;
}
$items = pdo_fetchall('SELECT id,dispatchname FROM ' . tablename('ewei_shop_dispatch') . (' WHERE id in( ' . $id . ' ) AND merchid=0 AND uniacid=') . $_W['uniacid']);
foreach ($items as $item) {
pdo_delete('ewei_shop_dispatch', array('id' => $item['id']));
plog('shop.dispatch.delete', '删除配送方式 ID: ' . $item['id'] . ' 标题: ' . $item['dispatchname'] . ' ');
}
show_json(1, array('url' => referer()));
}
public function enabled()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
if (empty($id)) {
$id = is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0;
}
$items = pdo_fetchall('SELECT id,dispatchname FROM ' . tablename('ewei_shop_dispatch') . (' WHERE id in( ' . $id . ' ) AND merchid=0 AND uniacid=') . $_W['uniacid']);
foreach ($items as $item) {
pdo_update('ewei_shop_dispatch', array('enabled' => intval($_GPC['enabled'])), array('id' => $item['id']));
plog('shop.dispatch.edit', '修改配送方式状态<br/>ID: ' . $item['id'] . '<br/>标题: ' . $item['dispatchname'] . '<br/>状态: ' . $_GPC['enabled'] == 1 ? '显示' : '隐藏');
}
show_json(1, array('url' => referer()));
}
public function setdefault()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
if (empty($id)) {
$id = is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0;
}
if ($_GPC['isdefault'] == 1) {
pdo_update('ewei_shop_dispatch', array('isdefault' => 0), array('uniacid' => $_W['uniacid'], 'merchid' => 0));
}
$items = pdo_fetchall('SELECT id,dispatchname FROM ' . tablename('ewei_shop_dispatch') . (' WHERE id in( ' . $id . ' ) AND merchid=0 AND uniacid=') . $_W['uniacid']);
foreach ($items as $item) {
pdo_update('ewei_shop_dispatch', array('isdefault' => intval($_GPC['isdefault'])), array('id' => $item['id']));
plog('shop.dispatch.edit', '设为默认配送方式<br/>ID: ' . $item['id'] . '<br/>标题: ' . $item['dispatchname'] . '<br/>状态: ' . $_GPC['isdefault'] == 1 ? '是' : '否');
}
show_json(1, array('url' => referer()));
}
public function displayorder()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$displayorder = intval($_GPC['value']);
$item = pdo_fetchall('SELECT id,dispatchname FROM ' . tablename('ewei_shop_dispatch') . (' WHERE id in( ' . $id . ' ) AND merchid=0 AND uniacid=') . $_W['uniacid']);
if (!empty($item)) {
pdo_update('ewei_shop_dispatch', array('displayorder' => $displayorder), array('id' => $id));
plog('shop.dispatch.edit', '修改配送方式排序 ID: ' . $item['id'] . ' 标题: ' . $item['dispatchname'] . ' 排序: ' . $displayorder . ' ');
}
show_json(1);
}
public function tpl()
{
global $_W;
global $_GPC;
$random = random(16);
ob_start();
include $this->template('shop/dispatch/tpl');
$contents = ob_get_contents();
ob_clean();
exit(json_encode(array('random' => $random, 'html' => $contents)));
}
}
?>

View File

@@ -1,9 +0,0 @@
<?php
class ComModel
{}
if (!defined('IN_IA')) {
exit('Access Denied');
}
?>

View File

@@ -1,41 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
require dirname(__DIR__) . '/../defines.php';
class ComProcessor extends WeModuleProcessor
{
public $model;
public $modulename;
public $message;
public function __construct($name = '')
{
$this->modulename = 'ewei_shopv2';
$this->pluginname = $name;
$this->loadModel();
}
/**
* 加载插件model
*/
private function loadModel()
{
$modelfile = IA_ROOT . '/addons/' . $this->modulename . '/core/com/' . $this->pluginname . '.php';
if (is_file($modelfile)) {
$classname = ucfirst($this->pluginname) . '_EweiShopV2ComModel';
require $modelfile;
$this->model = new $classname($this->pluginname);
}
}
public function respond()
{
$this->message = $this->message;
}
}
?>

View File

@@ -1,23 +0,0 @@
<?php
class DataModel
{
public function read($key = '')
{
global $_W;
global $_GPC;
return m('cache')->getArray('data_' . $_W['uniacid'] . '_' . $key);
}
public function write($key, $data)
{
global $_W;
global $_GPC;
m('cache')->set('data_' . $_W['uniacid'] . '_' . $key, $data);
}
}
if (!defined('IN_IA')) {
exit('Access Denied');
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,564 +0,0 @@
<?php
//20200612
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Page extends WeModuleSite
{
public function runTasks()
{
global $_W;
load()->func('communication');
$lasttime = strtotime(m('cache')->getString('receive', 'global'));
$interval = m('common')->getSysset('task')['receive_time'];
if (empty($interval)) {
$interval = 60;
}
$interval *= 60;
//如果上次收货时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('receive', date('Y-m-d H:i:s', $current), 'global');
(ihttp_request(EWEI_SHOPV2_TASK_URL . "order/receive.php", null, null, 10));
}
//自动关闭订单
$lasttime = strtotime(m('cache')->getString('closeorder', 'global'));
$interval = m('common')->getSysset('task')['closeorder_time'];
if (empty($interval)) {
$interval = 60;
}
$interval *= 60;
//如果上次自动关闭时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('closeorder', date('Y-m-d H:i:s', $current), 'global');
ihttp_request(EWEI_SHOPV2_TASK_URL . "order/close.php", null, null, 10);
}
//自动关闭虚拟卡密订单
$lasttime = strtotime(m('cache')->getString('closeorder_virtual', 'global'));
$interval_v = intval(m('cache')->getString('closeorder_virtual_time', 'global'));
if (empty($interval_v)) {
$interval_v = 60;
}
//如果上次自动关闭时间小
$current = time();
if ($lasttime + $interval_v <= $current) {
m('cache')->set('closeorder_virtual', date('Y-m-d H:i:s', $current), 'global');
ihttp_request(EWEI_SHOPV2_TASK_URL . "order/close.php", array('uniacid'=>$_W['uniacid']), null, 10);
}
//自动商品全返
$lasttime = strtotime(m('cache')->getString('fullback_receive', 'global'));
$interval = m('common')->getSysset('task')['fullback_receive_time'];
if (empty($interval)) {
$interval = 60;
}
$interval *= 60;
//如果上次自动关闭时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('fullback_receive', date('Y-m-d H:i:s', $current), 'global');
ihttp_request(EWEI_SHOPV2_TASK_URL . "order/fullback.php", null, null, 10);
}
/*
* 预售商品到期自动下架
* */
$lasttime = strtotime(m('cache')->getString('presell_status', 'global'));
$interval = m('common')->getSysset('task')['presell_status_time'];
if (empty($interval)) {
$interval = 60;
}
$interval *= 60;
//如果上次自动关闭时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('presell_status', date('Y-m-d H:i:s', $current), 'global');
ihttp_request(EWEI_SHOPV2_TASK_URL . "goods/presell.php", null, null, 10);
}
/*
* 商品自动上下架
* */
$lasttime = strtotime(m('cache')->getString('status_receive', 'global'));
$interval = m('common')->getSysset('task')['status_receive_time'];
if (empty($interval)) {
$interval = 60;
}
$interval *= 60;
//如果上次自动关闭时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('status_receive', date('Y-m-d H:i:s', $current), 'global');
ihttp_request(EWEI_SHOPV2_TASK_URL . "goods/status.php", null, null, 10);
}
//即将关闭订单
if (com('coupon')) {
$lasttime = strtotime(m('cache')->getString('willcloseorder', 'global'));
$interval = m('common')->getSysset('task')['willcloseorder_time'];
if (empty($interval)) {
$interval = 20; //20
}
$interval *= 60;//60
//如果上次执行时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('willcloseorder', date('Y-m-d H:i:s', $current), 'global');
//require_once EWEI_SHOPV2_PATH.'core/task/order/willclose.php';
ihttp_request(EWEI_SHOPV2_TASK_URL . "order/willclose.php", null, null, 10);
}
}
//优惠券自动返利
if (com('coupon')) {
$lasttime = strtotime(m('cache')->getString('couponback', 'global'));
$interval = m('common')->getSysset('task')['couponback_time'];
if (empty($interval)) {
$interval = 60;
}
$interval *= 60;
//如果上次执行时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('couponback', date('Y-m-d H:i:s', $current), 'global');
ihttp_request(EWEI_SHOPV2_TASK_URL . "coupon/back.php", null, null, 10);
}
}
//自动发送卖家通知
$lasttime = strtotime(m('cache')->getString('sendnotice', 'global'));
$interval = intval(m('cache')->getString('sendnotice_time', 'global'));
if (empty($interval)) {
$interval = 60;
}
$interval *= 60;
//如果上次自动关闭时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('sendnotice', date('Y-m-d H:i:s', $current), 'global');
ihttp_request(EWEI_SHOPV2_TASK_URL . "notice/sendnotice.php", array('uniacid' => $_W['uniacid']), null, 10);
}
//自动发送周期购卖家发货通知
$lasttime = strtotime(m('cache')->getString('sendcycelbuy', 'global'));
$interval = intval(m('cache')->getString('sendcycelbuy_time', 'global'));
if (empty($interval)) {
$interval = 60;
}
$interval *= 60;
//如果上次自动关闭时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('sendcycelbuy', date('Y-m-d H:i:s', $current), 'global');
ihttp_request(EWEI_SHOPV2_TASK_URL . "cycelbuy/sendnotice.php", array('uniacid' => $_W['uniacid']), null, 10);
}
//周期购每期自动收货
$lasttime = strtotime(m('cache')->getString('cycelbuyreceive', 'global'));
$interval = intval(m('cache')->getString('cycelbuyreceive_time', 'global'));
if (empty($interval)) {
$interval = 60;
}
$interval *= 60;
//如果上次自动关闭时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('cycelbuyreceive', date('Y-m-d H:i:s', $current), 'global');
ihttp_request(EWEI_SHOPV2_TASK_URL . "cycelbuy/receive.php", array('uniacid' => $_W['uniacid']), null, 10);
}
if (p('groups')) {
/*
* 拼团未付款订单自动取消
* */
$groups_order_lasttime = strtotime(m('cache')->getString('groups_order_cancelorder', 'global'));
$groups_order_interval = m('common')->getSysset('task')['groups_order_cancelorder_time'];
if (empty($groups_order_interval)) {
$groups_order_interval = 60;
}
$groups_order_interval *= 60;
//如果上次自动关闭时间小
$groups_order_current = time();
if ($groups_order_lasttime + $groups_order_interval <= $groups_order_current) {
m('cache')->set('groups_order_cancelorder', date('Y-m-d H:i:s', $groups_order_current), 'global');
ihttp_request($_W['siteroot'] . "addons/ewei_shopv2/plugin/groups/task/order.php", null, null, 10);
}
/*
* 拼团失败自动退款
* */
$groups_team_lasttime = strtotime(m('cache')->getString('groups_team_refund', 'global'));
$groups_team_interval = m('common')->getSysset('task')['groups_team_refund_time'];
if (empty($groups_team_interval)) {
$groups_team_interval = 60;
}
$groups_team_interval *= 60;
//如果上次自动关闭时间小
$groups_team_current = time();
if ($groups_team_lasttime + $groups_team_interval <= $groups_team_current) {
m('cache')->set('groups_team_refund', date('Y-m-d H:i:s', $groups_team_current), 'global');
ihttp_request($_W['siteroot'] . "addons/ewei_shopv2/plugin/groups/task/refund.php?uniacid={$_W['uniacid']}", null, null, 10);
}
/*
* 拼团发货自动收货
* */
$groups_receive_lasttime = strtotime(m('cache')->getString('groups_receive', 'global'));
$groups_receive_interval = m('common')->getSysset('task')['groups_receive_time'];
if (empty($groups_receive_interval)) {
$groups_receive_interval = 60;
}
$groups_receive_interval *= 60;
//如果上次自动关闭时间小
$groups_receive_current = time();
if ($groups_receive_lasttime + $groups_receive_interval <= $groups_receive_current) {
m('cache')->set('groups_receive', date('Y-m-d H:i:s', $groups_receive_current), 'global');
ihttp_request($_W['siteroot'] . "addons/ewei_shopv2/plugin/groups/task/receive.php", null, null, 10);
}
}
if (p('seckill')) {
$lasttime = strtotime(m('cache')->getString('seckill_delete_lasttime', 'global'));
$interval = 5 * 60;
//如果上次执行时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('seckill_delete_lasttime', date('Y-m-d H:i:s', $current), 'global');
ihttp_request($_W['siteroot'] . "addons/ewei_shopv2/plugin/seckill/task/delete.php", null, null, 10);
}
}
//卡密延迟60秒发送
// ihttp_request($url=EWEI_SHOPV2_TASK_URL . "order/virtualsend.php", array('uniacid'=>$_W['uniacid'],'acid'=>$_W['acid']),null,1);
// exit('run finished.');
/**
* 发送瓜分券失败通知
*/
if (p('friendcoupon')) {
$lasttime = strtotime(m('cache')->getString('friendcoupon_send_failed_message', 'global'));
$interval = 60;
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('friendcoupon_send_failed_message', date('Y-m-d H:i:s', $current), 'global');
ihttp_request($_W['siteroot'] . "addons/ewei_shopv2/plugin/friendcoupon/task/sendMessage.php?uniacid={$_W['uniacid']}", null, null, 10);
}
}
//多商户到期自动下架商品
if (p('merch')) {
$lasttime = strtotime(m('cache')->getString('merch_expire', 'global'));
$interval = 5 * 60;
//如果上次自动关闭时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('merch_expire', date('Y-m-d H:i:s', $current), 'global');
ihttp_request(EWEI_SHOPV2_TASK_URL . "plugin/merch.php", null, null, 10);
}
}
/** 检测核销订单是否快超过时间
* TODO
*/
$lasttime = strtotime(m('cache')->getString('willcloseverifyorder', 'global'));
$interval = m('common')->getSysset('task')['willcloseverifyorder_time'];
if (empty($interval)) {
$interval = 20; //20
}
$interval *= 60;//60
//如果上次执行时间小
$current = time();
if ($lasttime + $interval <= $current) {
m('cache')->set('willcloseverifyorder', date('Y-m-d H:i:s', $current), 'global');
//require_once EWEI_SHOPV2_PATH.'core/task/order/willclose.php';
ihttp_request(EWEI_SHOPV2_TASK_URL . "order/willcloseverify.php", null, null, 10);
}
}
public function template($filename = '', $type = TEMPLATE_INCLUDEPATH, $account = false){
global $_W, $_GPC;
// 判断是否V3
// $set = m('common')->getSysset('template');
$isv3 = true;
if(isset($_W['shopversion'])){
$isv3 = $_W['shopversion'];
}
if($isv3 && !empty($_GPC['v2'])){
$isv3 = false;
}
if(!empty($_W['plugin']) && $isv3){
$plugin_config = m('plugin')->getConfig($_W['plugin']);
if((is_array($plugin_config) && empty($plugin_config['v3'])) || !$plugin_config){
$isv3 = false;
}
}
$bsaeTemp = array('_header', '_header_base', '_footer', '_tabs', 'funbar');
if($_W['plugin']=='merch' && $_W['merch_user'] && (!in_array($filename, $bsaeTemp) || !$isv3)){
return $this->template_merch($filename, $isv3);
}
// 主商城模板处理
if (empty($filename)) {
$filename = str_replace(".", "/", $_W['routes']);
}
if ( $_GPC['do'] == 'web' || defined('IN_SYS')) {
$filename = str_replace("/add", "/post", $filename);
$filename = str_replace("/edit", "/post", $filename);
$filename_default = str_replace("/add", "/post", $filename);
$filename_default = str_replace("/edit", "/post", $filename_default);
$filename = 'web/' . $filename_default;
$filename_v3 = 'web_v3/' . $filename_default;
}
$name = 'ewei_shopv2';
$moduleroot = IA_ROOT . "/addons/ewei_shopv2";
// 管理端
if (defined('IN_SYS')) {
if(!$isv3){
$compile = IA_ROOT . "/data/tpl/web/{$_W['template']}/{$name}/{$filename}.tpl.php";
$source = $moduleroot . "/template/{$filename}.html";
if (!is_file($source)) {
$source = $moduleroot . "/template/{$filename}/index.html";
}
}
if($isv3 || !is_file($source)){
if($isv3){
$compile = IA_ROOT . "/data/tpl/web_v3/{$_W['template']}/{$name}/{$filename}.tpl.php";
}
$source = $moduleroot . "/template/{$filename_v3}.html";
if (!is_file($source)) {
$source = $moduleroot . "/template/{$filename_v3}/index.html";
}
}
if (!is_file($source)) {
$explode = array_slice(explode('/', $filename), 1);
$temp = array_slice($explode, 1);
if($isv3){
$source = $moduleroot . "/plugin/" . $explode[0] . "/template/web_v3/" . implode('/', $temp) . ".html";
if (!is_file($source)) {
$source = $moduleroot . "/plugin/" . $explode[0] . "/template/web_v3/" . implode('/', $temp) . "/index.html";
}
}
if(!$isv3 || !is_file($source)){
$source = $moduleroot . "/plugin/" . $explode[0] . "/template/web/" . implode('/', $temp) . ".html";
if (!is_file($source)) {
$source = $moduleroot . "/plugin/" . $explode[0] . "/template/web/" . implode('/', $temp) . "/index.html";
}
}
}
}
// account页面
elseif ($account){
$template = $_W['shopset']['wap']['style'];
if (empty($template)) {
$template = "default";
}
if (!is_dir($moduleroot . "/template/account/" . $template)) {
$template = "default";
}
$compile = IA_ROOT . "/data/tpl/app/{$name}/{$template}/account/{$filename}.tpl.php";
$source = IA_ROOT . "/addons/{$name}/template/account/{$template}/{$filename}.html";
if (!is_file($source)) {
$source = IA_ROOT . "/addons/{$name}/template/account/default/{$filename}.html";
}
if (!is_file($source)) {
$source = IA_ROOT . "/addons/{$name}/template/account/default/{$filename}/index.html";
}
}
// 手机端商城页面
else{
$template = m('cache')->getString('template_shop');
if (empty($template)) {
$template = "default";
}
if (!is_dir($moduleroot . "/template/mobile/" . $template)) {
$template = "default";
}
$compile = IA_ROOT . "/data/tpl/app/{$name}/{$template}/mobile/{$filename}.tpl.php";
$source = IA_ROOT . "/addons/{$name}/template/mobile/{$template}/{$filename}.html";
if (!is_file($source)) {
$source = IA_ROOT . "/addons/{$name}/template/mobile/{$template}/{$filename}/index.html";
}
if (!is_file($source)) {
$source = IA_ROOT . "/addons/{$name}/template/mobile/default/{$filename}.html";
}
if (!is_file($source)) {
$source = IA_ROOT . "/addons/{$name}/template/mobile/default/{$filename}/index.html";
}
// 插件页面
if (!is_file($source)) {
//如果还没有就是插件的
$names = explode('/', $filename);
$pluginname = $names[0];
$ptemplate = m('cache')->getString('template_' . $pluginname);
if (empty($ptemplate) || $pluginname == 'creditshop') {
$ptemplate = "default";
}
if (!is_dir($moduleroot . "/plugin/" . $pluginname . "/template/mobile/" . $ptemplate)) {
$ptemplate = "default";
}
unset($names[0]);
$pfilename = implode('/', $names);
$compile = IA_ROOT . "/data/tpl/app/{$name}/plugin/{$pluginname}/{$ptemplate}/mobile/{$filename}.tpl.php";
$source = $moduleroot . "/plugin/" . $pluginname . "/template/mobile/" . $ptemplate . "/{$pfilename}.html";
if (!is_file($source)) {
$source = $moduleroot . "/plugin/" . $pluginname . "/template/mobile/" . $ptemplate . "/" . $pfilename . "/index.html";
}
if (!is_file($source)) {
$source = $moduleroot . "/plugin/" . $pluginname . "/template/mobile/default/{$pfilename}.html";
}
if (!is_file($source)) {
$source = $moduleroot . "/plugin/" . $pluginname . "/template/mobile/default/" . $pfilename . "/index.html";
}
}
}
if (!is_file($source)) {
exit("Error: template source '{$filename}' is not exist!");
}
if (DEVELOPMENT || !is_file($compile) || filemtime($source) > filemtime($compile)) {
shop_template_compile($source, $compile, true);
}
return $compile;
}
public function template_merch($filename, $isv3) {
global $_W;
if (empty($filename)) {
$filename = str_replace(".", "/", $_W['routes']);
}
$filename = str_replace("/add", "/post", $filename);
$filename = str_replace("/edit", "/post", $filename);
$name = 'ewei_shopv2';
$moduleroot = IA_ROOT . "/addons/ewei_shopv2";
$compile = IA_ROOT . "/data/tpl/web/{$_W['template']}/merch/{$name}/{$filename}.tpl.php";
$explode = explode('/', $filename);
if($isv3){
$source = $moduleroot . "/plugin/merch/template/web_v3/manage/" . implode('/', $explode) . ".html";
if (!is_file($source)) {
$source = $moduleroot . "/plugin/merch/template/web_v3/manage/" . implode('/', $explode) . "/index.html";
}
}
if(!$isv3 || !is_file($source)){
$source = $moduleroot . "/plugin/merch/template/web/manage/" . implode('/', $explode) . ".html";
if (!is_file($source)) {
$source = $moduleroot . "/plugin/merch/template/web/manage/" . implode('/', $explode) . "/index.html";
}
}
//别的插件
if (!is_file($source)) {
$explode = explode('/', $filename);
$temp = array_slice($explode, 1);
if($isv3){
$source = $moduleroot . "/plugin/" . $explode[0] . "/template/web_v3/" . implode('/', $temp) . ".html";
if (!is_file($source)) {
$source = $moduleroot . "/plugin/" . $explode[0] . "/template/web_v3/" . implode('/', $temp) . "/index.html";
}
}
if(!$isv3 || !is_file($source)){
$source = $moduleroot . "/plugin/" . $explode[0] . "/template/web/" . implode('/', $temp) . ".html";
if (!is_file($source)) {
$source = $moduleroot . "/plugin/" . $explode[0] . "/template/web/" . implode('/', $temp) . "/index.html";
}
}
}
if (!is_file($source)) {
exit("Error: template source '{$filename}' is not exist!");
}
if (DEVELOPMENT || !is_file($compile) || filemtime($source) > filemtime($compile)) {
shop_template_compile($source, $compile, true);
}
return $compile;
}
function message($msg, $redirect = '', $type = '')
{
global $_W;
$title = "";
$buttontext = "";
$message = $msg;
$buttondisplay = true;
if (is_array($msg)) {
$message = isset($msg['message']) ? $msg['message'] : '';
$title = isset($msg['title']) ? $msg['title'] : '';
$buttontext = isset($msg['buttontext']) ? $msg['buttontext'] : '';
$buttondisplay = isset($msg['buttondisplay']) ? $msg['buttondisplay'] : true;
}
if (empty($redirect)) {
$redirect = 'javascript:history.back(-1);';
} elseif ($redirect == 'close') {
$redirect = 'javascript:WeixinJSBridge.call("closeWindow")';
} elseif ($redirect == 'exit') {
$redirect = "";
}
include $this->template('_message');
exit;
}
function checkSubmit($key, $time = 2, $message = '操作频繁,请稍后再试!')
{
global $_W;
$open_redis = function_exists('redis') && !is_error(redis());
if ($open_redis) {
$redis_key = "{$_W['setting']['site']['key']}_{$_W['account']['key']}_{$_W['uniacid']}_{$_W['openid']}_mobilesubmit_{$key}";
$redis = redis();
if ($redis->setnx($redis_key, time())) {
$redis->expireAt($redis_key, time() + $time);
} else {
return error(-1, $message);
}
}
return true;
}
function checkSubmitGlobal($key, $time = 2, $message = '操作频繁,请稍后再试!')
{
global $_W;
$open_redis = function_exists('redis') && !is_error(redis());
if ($open_redis) {
$redis_key = "{$_W['setting']['site']['key']}_{$_W['account']['key']}_{$_W['uniacid']}_mobilesubmit_{$key}";
$redis = redis();
if ($redis->setnx($redis_key, time())) {
$redis->expireAt($redis_key, time() + $time);
} else {
return error(-1, $message);
}
}
return true;
}
}

View File

@@ -1,682 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class MobilePage extends Page
{
public $footer = array();
public $followBar = false;
protected $merch_user = array();
public function __construct()
{
global $_W;
global $_GPC;
m('shop')->checkClose();
$preview = intval($_GPC['preview']);
$wap = m('common')->getSysset('wap');
if (!empty($wap['open']) && !is_weixin() && empty($preview)) {
if ($this instanceof MobileLoginPage || $this instanceof PluginMobileLoginPage) {
if (empty($_W['openid'])) {
$_W['openid'] = m('account')->checkLogin();
}
}
else {
$_W['openid'] = m('account')->checkOpenid();
}
}
else {
if ($preview && !is_weixin()) {
$_W['openid'] = 'ooyv91cPbLRIz1qaX7Fim_cRfjZk';
}
if (EWEI_SHOPV2_DEBUG) {
$_W['openid'] = 'ooyv91cPbLRIz1qaX7Fim_cRfjZk';
}
}
$member = m('member')->checkMember();
$_W['mid'] = !empty($member) ? $member['id'] : '';
$_W['mopenid'] = !empty($member) ? $member['openid'] : '';
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if (!empty($_GPC['merchid']) && ($merch_plugin && $merch_data['is_openmerch'])) {
$this->merch_user = pdo_fetch('select * from ' . tablename('ewei_shop_merch_user') . ' where id=:id limit 1', array(':id' => intval($_GPC['merchid'])));
}
}
public function followBar($diypage = false, $merch = false)
{
global $_W;
global $_GPC;
if (is_h5app() || !is_weixin()) {
return NULL;
}
$openid = $_W['openid'];
$followed = m('user')->followed($openid);
$mid = intval($_GPC['mid']);
$memberid = m('member')->getMid();
if (p('diypage')) {
if ($merch && p('merch')) {
$diypagedata = p('merch')->getSet('diypage', $merch);
}
else {
$diypagedata = m('common')->getPluginset('diypage');
}
$diyfollowbar = $diypagedata['followbar'];
}
if ($diypage) {
$diyfollowbar['params']['isopen'] = 1;
}
@session_start();
if (!$followed || !empty($diyfollowbar['params']['showtype']) && !empty($diyfollowbar['params']['isopen'])) {
$set = $_W['shopset'];
$followbar = array('followurl' => $set['share']['followurl'], 'shoplogo' => tomedia($set['shop']['logo']), 'shopname' => $set['shop']['name'], 'qrcode' => tomedia($set['share']['followqrcode']), 'share_member' => false);
$friend = false;
if (!empty($mid) && $memberid != $mid) {
if (!empty($_SESSION[EWEI_SHOPV2_PREFIX . '_shareid']) && $_SESSION[EWEI_SHOPV2_PREFIX . '_shareid'] == $mid) {
$mid = $_SESSION[EWEI_SHOPV2_PREFIX . '_shareid'];
}
$member = m('member')->getMember($mid);
if (!empty($member)) {
$_SESSION[EWEI_SHOP_PREFIX . '_shareid'] = $mid;
$friend = true;
$followbar['share_member'] = array('id' => $member['id'], 'nickname' => $member['nickname'], 'realname' => $member['realname'], 'avatar' => $member['avatar']);
}
}
$showdiyfollowbar = false;
if (p('diypage')) {
if (!empty($diyfollowbar) && !empty($diyfollowbar['params']['isopen']) || !empty($diyfollowbar) && $diypage) {
$showdiyfollowbar = true;
if (!empty($followbar['share_member'])) {
if (!empty($diyfollowbar['params']['sharetext'])) {
$touser = m('member')->getMember($memberid);
$diyfollowbar['text'] = str_replace('[商城名称]', '<span style="color:' . $diyfollowbar['style']['highlight'] . ';">' . $set['shop']['name'] . '</span>', $diyfollowbar['params']['sharetext']);
$diyfollowbar['text'] = str_replace('[邀请人]', '<span style="color:' . $diyfollowbar['style']['highlight'] . ';">' . $followbar['share_member']['nickname'] . '</span>', $diyfollowbar['text']);
$diyfollowbar['text'] = str_replace('[访问者]', '<span style="color:' . $diyfollowbar['style']['highlight'] . ';">' . $touser['nickname'] . '</span>', $diyfollowbar['text']);
}
else {
$diyfollowbar['text'] = '来自好友<span class="text-danger">' . $followbar['share_member']['nickname'] . '</span>的推荐<br>' . '关注公众号,享专属服务';
}
}
else if (!empty($diyfollowbar['params']['defaulttext'])) {
$diyfollowbar['text'] = str_replace('[商城名称]', '<span style="color:' . $diyfollowbar['style']['highlight'] . ';">' . $set['shop']['name'] . '</span>', $diyfollowbar['params']['defaulttext']);
}
else {
$diyfollowbar['text'] = '欢迎进入<span class="text-danger">' . $set['shop']['name'] . '</span><br>' . '关注公众号,享专属服务';
}
$diyfollowbar['text'] = nl2br($diyfollowbar['text']);
$diyfollowbar['logo'] = tomedia($set['shop']['logo']);
if ($diyfollowbar['params']['icontype'] == 1 && !empty($followbar['share_member'])) {
$diyfollowbar['logo'] = tomedia($followbar['share_member']['avatar']);
}
else {
if ($diyfollowbar['params']['icontype'] == 3 && !empty($diyfollowbar['params']['iconurl'])) {
$diyfollowbar['logo'] = tomedia($diyfollowbar['params']['iconurl']);
}
}
if (empty($diyfollowbar['params']['btnclick'])) {
if (empty($diyfollowbar['params']['btnlinktype'])) {
$diyfollowbar['link'] = $set['share']['followurl'];
}
else {
$diyfollowbar['link'] = $diyfollowbar['params']['btnlink'];
}
}
else if (empty($diyfollowbar['params']['qrcodetype'])) {
$diyfollowbar['qrcode'] = tomedia($set['share']['followqrcode']);
}
else {
$diyfollowbar['qrcode'] = tomedia($diyfollowbar['params']['qrcodeurl']);
}
}
}
if ($showdiyfollowbar) {
include $this->template('diypage/followbar');
}
else {
include $this->template('_followbar');
}
}
}
public function MemberBar($diypage = false, $merch = false)
{
global $_W;
global $_GPC;
if (is_h5app() || !is_weixin()) {
return NULL;
}
$mid = intval($_GPC['mid']);
$cmember_plugin = p('cmember');
if (!$cmember_plugin) {
return NULL;
}
$openid = $_W['openid'];
$followed = m('user')->followed($openid);
if (!$followed) {
return NULL;
}
$check = $cmember_plugin->checkMember($openid);
if (!empty($check)) {
return NULL;
}
$data = m('common')->getPluginset('commission');
if (!empty($data['become_goodsid'])) {
$goods = pdo_fetch('select id,title,thumb from ' . tablename('ewei_shop_goods') . ' where id=:id and uniacid=:uniacid limit 1 ', array(':id' => $data['become_goodsid'], ':uniacid' => $_W['uniacid']));
}
else {
return NULL;
}
$buy_member_url = mobileUrl('goods/detail', array('id' => $goods['id'], 'mid' => $mid));
include $this->template('cmember/_memberbar');
}
public function footerMenus($diymenuid = NULL, $ismerch = false, $texts = array())
{
global $_W;
global $_GPC;
$params = array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']);
$cartcount = pdo_fetchcolumn('select ifnull(sum(total),0) from ' . tablename('ewei_shop_member_cart') . ' where uniacid=:uniacid and openid=:openid and deleted=0 and isnewstore=0 and selected =1', $params);
$commission = array();
if (p('commission') && intval(0 < $_W['shopset']['commission']['level'])) {
$member = m('member')->getMember($_W['openid']);
if (!$member['agentblack']) {
if ($member['isagent'] == 1 && $member['status'] == 1) {
$commission = array('url' => mobileUrl('commission'), 'text' => empty($_W['shopset']['commission']['texts']['center']) ? '分销中心' : $_W['shopset']['commission']['texts']['center']);
}
else {
$commission = array('url' => mobileUrl('commission/register'), 'text' => empty($_W['shopset']['commission']['texts']['become']) ? '成为分销商' : $_W['shopset']['commission']['texts']['become']);
}
}
}
$showdiymenu = false;
$routes = explode('.', $_W['routes']);
$controller = $routes[0];
if ($controller == 'member' || $controller == 'cart' || $controller == 'order' || $controller == 'goods' || $controller == 'quick') {
$controller = 'shop';
}
if (empty($diymenuid)) {
$pageid = !empty($controller) ? $controller : 'shop';
$pageid = $pageid == 'index' ? 'shop' : $pageid;
if (!empty($_GPC['merchid']) && ($_W['routes'] == 'shop.category' || $_W['routes'] == 'goods')) {
$pageid = 'merch';
}
if ($pageid == 'sale' && $_W['routes'] == 'sale.coupon.my.showcoupongoods') {
$pageid = 'shop';
}
if ($pageid == 'merch' && !empty($_GPC['merchid']) && p('merch')) {
$merchdata = p('merch')->getSet('diypage', $_GPC['merchid']);
if (!empty($merchdata['menu'])) {
$diymenuid = $merchdata['menu']['shop'];
if (!is_weixin() || is_h5app()) {
$diymenuid = $merchdata['menu']['shop_wap'];
}
}
}
else {
$diypagedata = m('common')->getPluginset('diypage');
if (!empty($diypagedata['menu'])) {
$diymenuid = $diypagedata['menu'][$pageid];
if (!is_weixin() || is_h5app()) {
$diymenuid = $diypagedata['menu'][$pageid . '_wap'];
}
}
}
}
if (!empty($diymenuid)) {
$menu = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_diypage_menu') . ' WHERE id=:id and uniacid=:uniacid limit 1 ', array(':id' => $diymenuid, ':uniacid' => $_W['uniacid']));
if (!empty($menu)) {
$menu = $menu['data'];
$menu = base64_decode($menu);
$diymenu = json_decode($menu, true);
$showdiymenu = true;
}
}
if ($showdiymenu) {
include $this->template('diypage/menu');
}
else {
if ($controller == 'commission' && $routes[1] != 'myshop') {
include $this->template('commission/_menu');
}
else if ($controller == 'creditshop') {
include $this->template('creditshop/_menu');
}
else if ($controller == 'groups') {
include $this->template('groups/_groups_footer');
}
else if ($controller == 'merch') {
include $this->template('merch/_menu');
}
else if ($controller == 'mr') {
include $this->template('mr/_menu');
}
else if ($controller == 'newmr') {
include $this->template('newmr/_menu');
}
else if ($controller == 'sign') {
include $this->template('sign/_menu');
}
else if ($controller == 'sns') {
include $this->template('sns/_menu');
}
else if ($controller == 'seckill') {
include $this->template('seckill/_menu');
}
else if ($controller == 'mmanage') {
include $this->template('mmanage/_menu');
}
else if ($ismerch) {
include $this->template('merch/_menu');
}
else {
include $this->template('_menu');
}
}
}
public function shopShare()
{
global $_W;
global $_GPC;
$trigger = false;
if (empty($_W['shopshare'])) {
$set = $_W['shopset'];
$_W['shopshare'] = array('title' => empty($set['share']['title']) ? $set['shop']['name'] : $set['share']['title'], 'imgUrl' => empty($set['share']['icon']) ? tomedia($set['shop']['logo']) : tomedia($set['share']['icon']), 'desc' => empty($set['share']['desc']) ? $set['shop']['description'] : $set['share']['desc'], 'link' => empty($set['share']['url']) ? mobileUrl('', NULL, true) : $set['share']['url']);
$plugin_commission = p('commission');
if ($plugin_commission) {
$set = $plugin_commission->getSet();
if (!empty($set['level'])) {
$openid = $_W['openid'];
$member = m('member')->getMember($openid);
if (!empty($member) && $member['status'] == 1 && $member['isagent'] == 1) {
if (empty($set['closemyshop'])) {
$myshop = $plugin_commission->getShop($member['id']);
$_W['shopshare'] = array('title' => $myshop['name'], 'imgUrl' => tomedia($myshop['logo']), 'desc' => $myshop['desc'], 'link' => mobileUrl('commission/myshop', array('mid' => $member['id']), true));
}
else {
$_W['shopshare']['link'] = empty($_W['shopset']['share']['url']) ? mobileUrl('', array('mid' => $member['id']), true) : $_W['shopset']['share']['url'];
}
if (empty($set['become_reg']) && (empty($member['realname']) || empty($member['mobile']))) {
$trigger = true;
}
}
else {
if (!empty($_GPC['mid'])) {
$m = m('member')->getMember($_GPC['mid']);
if (!empty($m) && $m['status'] == 1 && $m['isagent'] == 1) {
if (empty($set['closemyshop'])) {
$myshop = $plugin_commission->getShop($_GPC['mid']);
$_W['shopshare'] = array('title' => $myshop['name'], 'imgUrl' => tomedia($myshop['logo']), 'desc' => $myshop['desc'], 'link' => mobileUrl('commission/myshop', array('mid' => $member['id']), true));
}
else {
$_W['shopshare']['link'] = empty($_W['shopset']['share']['url']) ? mobileUrl('', array('mid' => $_GPC['mid']), true) : $_W['shopset']['share']['url'];
}
}
else {
$_W['shopshare']['link'] = empty($_W['shopset']['share']['url']) ? mobileUrl('', array('mid' => $_GPC['mid']), true) : $_W['shopset']['share']['url'];
}
}
}
}
}
}
return $trigger;
}
public function diyPage($type)
{
global $_W;
global $_GPC;
if (empty($type) || !p('diypage')) {
return false;
}
if (method_exists(m('plugin'), 'permission')) {
if (p('membercard') && m('plugin')->permission('membercard')) {
$list_membercard = p('membercard')->get_Mycard('', 0, 100);
$all_membercard = p('membercard')->get_Allcard(1, 100);
if (p('membercard') && $list_membercard['total'] <= 0 && $all_membercard['total'] <= 0) {
$canmembercard = false;
}
else {
$canmembercard = true;
}
}
}
$merch = intval($_GPC['merchid']);
if ($merch && $type != 'member' && $type != 'commission') {
if (!p('merch')) {
return false;
}
$diypagedata = p('merch')->getSet('diypage', $merch);
}
else {
$diypagedata = m('common')->getPluginset('diypage');
if (p('commission')) {
$comm_set = p('commission')->getSet();
}
}
if (!empty($diypagedata)) {
$diypageid = $diypagedata['page'][$type];
if (!empty($diypageid)) {
$page = p('diypage')->getPage($diypageid, true);
if (!empty($page)) {
p('diypage')->setShare($page);
$diyitems = $page['data']['items'];
$diyitem_search = array();
$diy_topmenu = array();
if (!empty($diyitems) && is_array($diyitems)) {
$jsondiyitems = json_encode($diyitems);
if (strexists($jsondiyitems, 'fixedsearch') || strexists($jsondiyitems, 'topmenu')) {
foreach ($diyitems as $diyitemid => $diyitem) {
if ($diyitem['id'] == 'fixedsearch') {
$diyitem_search = $diyitem;
unset($diyitems[$diyitemid]);
}
else {
if ($diyitem['id'] == 'topmenu') {
$diy_topmenu = $diyitem;
}
}
}
unset($diyitem);
}
}
$startadv = p('diypage')->getStartAdv($page['diyadv']);
if ($type == 'home') {
$cpinfos = false;
$sale_sql = 'SELECT * FROM ' . tablename('ewei_shop_sendticket') . ' WHERE uniacid = ' . intval($_W['uniacid']);
$sale_set = pdo_fetch($sale_sql);
if (!empty($sale_set) && $sale_set['status'] == 1) {
if (com('coupon')) {
$cpinfos = com('coupon')->getInfo();
}
}
$trade = m('common')->getSysset('trade');
if (empty($trade['shop_strengthen'])) {
$order = pdo_fetch('select id,price,`virtual`,createtime from ' . tablename('ewei_shop_order') . ' where uniacid=:uniacid and status = 0 and paytype<>3 and openid=:openid order by createtime desc limit 1', array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']));
if (!empty($order)) {
$close_time = 0;
$mintimes = 0;
if (!empty($order['virtual'])) {
if (isset($trade['closeorder_virtual']) && !empty($trade['closeorder_virtual'])) {
$mintimes = 60 * intval($trade['closeorder_virtual']);
}
else {
$mintimes = 60 * 15;
}
}
else {
$days = intval($trade['closeorder']);
if (0 < $days) {
$mintimes = 86400 * $days;
}
}
if (!empty($mintimes)) {
$close_time = intval($order['createtime']) + $mintimes;
}
$goods = pdo_fetchall('select g.*,og.total as totals from ' . tablename('ewei_shop_order_goods') . ' og inner join ' . tablename('ewei_shop_goods') . ' g on og.goodsid = g.id where og.uniacid=:uniacid and og.orderid=:orderid limit 3', array(':uniacid' => $_W['uniacid'], ':orderid' => $order['id']));
$goodstotal = pdo_fetchcolumn('select COUNT(*) from ' . tablename('ewei_shop_order_goods') . ' og inner join ' . tablename('ewei_shop_goods') . ' g on og.goodsid = g.id where og.uniacid=:uniacid and og.orderid=:orderid ', array(':uniacid' => $_W['uniacid'], ':orderid' => $order['id']));
}
}
}
include $this->template('diypage');
exit();
}
}
}
}
public function diyLayer($v = false, $diy = false, $merch = false, $goods = array(), $order = array())
{
global $_W;
global $_GPC;
if (!p('diypage') || $diy) {
return NULL;
}
if ($merch) {
if (!p('merch')) {
return false;
}
$diypagedata = p('merch')->getSet('diypage', $merch);
}
else {
$diypagedata = m('common')->getPluginset('diypage');
}
if (!empty($diypagedata)) {
$diylayer = $diypagedata['layer'];
if (empty($diylayer['params']['imgurl'])) {
return false;
}
if (!$diylayer['params']['isopen'] && $v) {
return NULL;
}
if (!empty($goods)) {
$diylayer['params']['linkurl'] .= '&goodsid=' . $goods['id'] . '&merch=' . $goods['merch'];
}
if (!empty($order)) {
$diylayer['params']['linkurl'] .= '&orderid=' . $order['id'];
}
include $this->template('diypage/layer');
}
}
public function diyGotop($v = false, $diy = false, $merch = false)
{
global $_W;
global $_GPC;
if (!p('diypage') || $diy) {
return NULL;
}
if ($merch) {
if (!p('merch')) {
return false;
}
$diypagedata = p('merch')->getSet('diypage', $merch);
$page = p('diypage')->getPage($diypagedata['page']['home'], true);
}
else {
$diypagedata = m('common')->getPluginset('diypage');
}
if (!empty($diypagedata)) {
$diygotop = $diypagedata['gotop'];
if ($merch) {
if (!$page['data']['page']['diygotop']) {
return NULL;
}
}
else {
if (!$diygotop['params']['isopen'] && $v) {
return NULL;
}
}
include $this->template('diypage/gotop');
}
}
public function diyDanmu($diy = false)
{
global $_W;
global $_GPC;
if (!p('diypage')) {
return NULL;
}
$diypagedata = m('common')->getPluginset('diypage');
$danmu = $diypagedata['danmu'];
if (empty($danmu) || !$diy && empty($danmu['params']['isopen'])) {
return NULL;
}
if (empty($danmu['params']['datatype'])) {
$condition = !empty($_W['openid']) ? ' AND openid!=\'' . $_W['openid'] . '\' ' : '';
$danmu['data'] = pdo_fetchall('SELECT nickname, avatar as imgurl FROM' . tablename('ewei_shop_member') . ' WHERE uniacid=:uniacid AND nickname!=\'\' AND avatar!=\'\' ' . $condition . ' ORDER BY rand() LIMIT 10', array(':uniacid' => $_W['uniacid']));
$randstart = !empty($danmu['params']['starttime']) ? intval($danmu['params']['starttime']) : 0;
$randend = !empty($danmu['params']['endtime']) ? intval($danmu['params']['endtime']) : 0;
if ($randend <= $randstart) {
$randend = $randend + rand(100, 999);
}
}
else if ($danmu['params']['datatype'] == 1) {
$danmu['data'] = pdo_fetchall('SELECT m.nickname, m.avatar as imgurl, o.createtime as time FROM' . tablename('ewei_shop_order') . ' o LEFT JOIN ' . tablename('ewei_shop_member') . ' m ON m.openid=o.openid WHERE o.uniacid=:uniacid AND m.nickname!=\'\' AND m.avatar!=\'\' ORDER BY o.createtime DESC LIMIT 10', array(':uniacid' => $_W['uniacid']));
}
else {
if ($danmu['params']['datatype'] == 2) {
$danmu['data'] = set_medias($danmu['data'], 'imgurl');
}
}
if (empty($danmu['data']) || !is_array($danmu['data'])) {
return NULL;
}
foreach ($danmu['data'] as $index => $item) {
if (strpos($item['nickname'], '\'') !== false) {
$danmu['data'][$index]['nickname'] = str_replace('\'', '`', $item['nickname']);
$danmu['data'][$index]['nickname'] = str_replace('"', '`', $danmu['data'][$index]['nickname']);
$danmu['data'][$index]['nickname'] = str_replace(PHP_EOL, '', $danmu['data'][$index]['nickname']);
}
if (empty($danmu['params']['datatype'])) {
$time = rand($randstart, $randend);
$danmu['data'][$index]['time'] = p('diypage')->getDanmuTime($time);
}
else if ($danmu['params']['datatype'] == 1) {
$danmu['data'][$index]['time'] = p('diypage')->getDanmuTime(time() - $item['time']);
}
else {
if ($danmu['params']['datatype'] == 2) {
$danmu['data'][$index]['time'] = p('diypage')->getDanmuTime($danmu['data'][$index]['time']);
}
}
}
include $this->template('diypage/danmu');
}
public function backliving()
{
global $_W;
global $_GPC;
if (!p('live')) {
return NULL;
}
if (strexists($_W['routes'], 'live')) {
return false;
}
$liveid = intval($_GPC['liveid']);
if (empty($liveid)) {
return NULL;
}
$living = p('live')->isLiving($liveid);
if (!$living) {
return NULL;
}
include $this->template('live/backliving');
}
public function wapQrcode()
{
global $_W;
$currenturl = '';
if (!is_mobile()) {
$currenturl = $_W['siteroot'] . 'app/index.php?' . $_SERVER['QUERY_STRING'];
}
$shop = m('common')->getSysset('shop');
$shopname = $shop['name'];
include $this->template('_wapqrcode');
}
private function checkOpen()
{
global $_GPC;
if ($_GPC['canChenk']) {
$key = pdo_fetchall('SELECT * FROM ' . tablename('ewei_shop_open_plugin'));
}
}
}
?>

View File

@@ -1,16 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class MobileLoginPage extends MobilePage
{
public function __construct()
{
global $_W;
global $_GPC;
parent::__construct();
}
}
?>

View File

@@ -1,275 +0,0 @@
<?php
use Twig\Loader\FilesystemLoader;
use Twig\Environment;
class PluginMobilePage extends MobilePage
{
/**
* @var Environment
*/
protected $twig;
/**
* 默认模板后缀
* @var string
*/
const DEFAULT_TEMPLATE_SUFFIX = '.twig';
public $model;
public $set;
public function __construct()
{
parent::__construct();
$this->model = m('plugin')->loadModel($GLOBALS["_W"]['plugin']);
$this->set = $this->model->getSet();
}
public function getSet()
{
return $this->set;
}
public function qr()
{
global $_W, $_GPC;
$url = trim($_GPC['url']);
require IA_ROOT . '/framework/library/qrcode/phpqrcode.php';
QRcode::png($url, false, QR_ECLEVEL_L, 16, 1);
}
/**
* 解析模板路径参数
* @param $template
* @return string
* @author: Vencenty
* @time: 2019/5/20 15:43
*/
protected function resolveTemplatePath($template)
{
$template = trim($template);
// 把 path/to/template | path.to.template 全部替换成 path/to/template
$replaceTemplate = str_replace(array('.', '/'), '/', $template);
// 拆解参数
$params = explode('/', $replaceTemplate);
// 获取最后一个参数
$lastElement = array_pop($params);
// 最后一个参数拼接上文件后缀
$templateFile = $lastElement . static::DEFAULT_TEMPLATE_SUFFIX;
// 然后在拼接到原先数组
array_push($params, $templateFile);
// 拼接地址 path/to/template.twig
$relativePath = implode('/', $params);
return $relativePath;
}
/**
* 渲染模板
* eg.
* $this->view('index') 渲染当前插件下 template/mobile/default/index.twig模板
* $this->view('goods.detail.index') | $this->view('goods/detail/index') 则是渲染当前插件下 template/mobile/default/goods/detail/index.twig 模板
* @param $template
* @param array $params
* @return string
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @author: Vencenty
* @time: 2019/5/24 14:31
*/
protected function view($template, $params = array())
{
// 获取模板地址
global $_GPC;
// 获取模板相对文件路径
$templateFilePath = $this->resolveTemplatePath($template);
$routeParams = isset($_GPC['r']) ? $_GPC['r'] : null;
$routeParams = explode('.', $routeParams);
// 获取当前插件名字
$plugin = current($routeParams);
$pluginTemplatePath = EWEI_SHOPV2_PLUGIN . "{$plugin}" . "/template/mobile/default/";
// 模板需要的全局变量
if ($plugin == 'pc') {
$loader = new FilesystemLoader($pluginTemplatePath);
$this->twig = new Environment($loader, array(
'debug' => true
));
// 注册全局函数
$this->addFunction();
// 注册全局参数
$this->addGlobal();
// 注册全局过滤器
$this->addFilter();
}
// 模板需要的默认参数
$defaultParams = array(
'basePath' => EWEI_SHOPV2_LOCAL . "plugin/{$plugin}/static",
'staticPath' => EWEI_SHOPV2_LOCAL . "static/",
'appJsPath' => EWEI_SHOPV2_LOCAL . "static/js/app",
'title' => '人人商城',
);
if (empty($params)) {
$params = array();
}
// 合并默认参数
$params = array_merge($defaultParams, $params);
// 模板文件绝对路径
$templateFileRealPath = $pluginTemplatePath . $templateFilePath;
if (!file_exists($templateFileRealPath)) {
die("模板文件 {$templateFileRealPath} 不存在");
}
return $this->twig->render($templateFilePath, $params);
}
/**
* 添加全局函数
* @author: Vencenty
* @time: 2019/5/27 20:45
*/
private function addFunction()
{
// 需要扩展的函数
$extendFunctions = array(
'tomedia' => function ($src) {
return tomedia($src);
},
'html2html' => function ($data) {
return trim(htmlspecialchars_decode($data));
},
// mobileUrl 别名
'pcUrl' => function ($do = '', $query = [], $full = false) {
global $_W, $_GPC;
$result = m('common')->getPluginSet('pc');
if (strpos($do, 'pc') === false) {
$do = 'pc.' . $do;
}
if (isset($result['domain']) && mb_strlen($result['domain'])) {
return ($full === true ? $_W['siteroot'] : './') . (empty($do) ? '' : ('?r=' . $do . '&')) . http_build_query($query);
} else {
return mobileUrl($do, $query, $full);
}
},
// 获取时间戳
'time' => function ($format = null) {
// 如果传入了格式化运算符,那么按照传入的格式进行格式化
if (!empty($format)) {
return date($format, time());
}
return time();
},
'ispc' => function () {
// 如果传入了格式化运算符,那么按照传入的格式进行格式化
$result = m('common')->getPluginSet('pc');
if (mb_strlen($result['domain']) > 0) {
return true;
}
return false;
},
// 获取数组长度
'count' => function ($array = array(), $model = COUNT_NORMAL) {
return count($array, $model);
},
// 打印变量
'dump' => function ($params) {
return print_r($params);
},
// 检查登录状态
'checkLogin' => function () {
return $this->model->checkLogin();
}
);
foreach ($extendFunctions as $functionName => $callback) {
$function = new Twig_SimpleFunction($functionName, $callback);
$this->twig->addFunction($function);
}
}
/**
* 增加全局变量
* @author: Vencenty
* @time: 2019/5/27 20:37
*/
protected function addGlobal()
{
global $_W, $_GPC;
$params = array(
// 从model里面获取所有的模板全局变量
'global' => p('pc')->getTemplateGlobalVariables(),
// 版本,目前先挂上时间戳,不然每次更新
'v' => str_replace('.', '', microtime(true)),
// 挂载到window全局对象下的参数,一般用来书写全局变量
'params' => json_encode($_GPC),
// 挂载到window全局对象下的属性,一般书写需要的路由
'api' => json_encode(array(
// 加入购物车
'addShopCart' => pcUrl('goods.addShopCart', array(), true),
// 评论列表
'commentList' => pcUrl('goods.comment_list', array(), true),
// 具体的评论
'comments' => pcUrl('goods.comments', array(), true),
// 计算多规格商品价格 目前该接口废弃,直接传给前端所有规格数据来进行计算
'calcSpecGoodsPrice' => pcUrl('goods.calcSpecGoodsPrice', array(), true),
// 图片上传
'imageUpload' => pcUrl('foundation.imageUpload', array(), true)
), JSON_UNESCAPED_UNICODE),
);
foreach ($params as $key => $value) {
$this->twig->addGlobal($key, $value);
}
}
/**
* 添加全局过滤器
* @author: Vencenty
* @time: 2019/5/27 20:45
*/
protected function addFilter()
{
// 扩展过滤器
$extendFilters = array(
// 强转float
'float' => function ($number) {
return (float)$number;
},
// 强转布尔
'bool' => function ($params) {
return (bool)$params;
},
// 字符串超出部分...显示
'format' => function ($string) {
$output = $string;
if (mb_strlen($output) > 8) {
$output = mb_substr($output, 0, 8, 'utf-8');
}
return $output;
}
);
foreach ($extendFilters as $filterName => $extendFilter) {
$filter = new Twig_SimpleFilter($filterName, $extendFilter);
$this->twig->addFilter($filter);
}
}
}

View File

@@ -1,16 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class PluginMobileLoginPage extends PluginMobilePage
{
public function __construct()
{
global $_W;
global $_GPC;
parent::__construct();
}
}
?>

View File

@@ -1,24 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class PluginPfMobilePage extends Page
{
public $model;
public $set;
public function __construct()
{
m('shop')->checkClose();
$this->model = m('plugin')->loadModel($GLOBALS['_W']['plugin']);
$this->set = $this->model->getSet();
}
public function getSet()
{
return $this->set;
}
}
?>

View File

@@ -1,22 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class SystemPage extends WebPage
{
public function __construct()
{
parent::__construct(false);
global $_W;
define('IS_EWEI_SHOPV2_SYSTEM', true);
$routes = explode('.', $_W['routes']);
$_W['current_menu'] = isset($routes[1]) ? $routes[1] : '';
if (!$_W['isfounder']) {
$this->message('您无权访问');
}
}
}
?>

View File

@@ -1,125 +0,0 @@
<?php
if (!(defined('IN_IA')))
{
exit('Access Denied');
}
class WebPage extends Page
{
public function __construct($_init = true)
{
if ($_init)
{
$this->init();
}
$GLOBALS['_W']['shopversion'] = 1;
}
private function init()
{
global $_W;
if (($_W['role'] != 'manager') && ($_W['role'] != 'founder') && ($_W['routes'] != 'shop'))
{
$perm = cv($_W['routes']);
if (com('perm'))
{
$perm_type = com('perm')->getLogTypes(true);
$perm_type_value = array();
foreach ($perm_type as $val )
{
$perm_type_value[] = $val['value'];
}
$is_xxx = com('perm')->check_xxx($_W['routes']);
if ($is_xxx)
{
if (!($perm))
{
foreach ($is_xxx as $item )
{
if (in_array($item, $perm_type_value))
{
$this->message('你没有相应的权限查看');
}
}
}
}
else
{
if (strexists($_W['routes'], 'edit'))
{
if (!(cv($_W['routes'])))
{
$view = str_replace('edit', 'view', $_W['routes']);
$perm_view = cv($view);
}
}
else
{
$main = $_W['routes'] . '.main';
$perm_main = cv($main);
if (!($perm_main) && in_array($main, $perm_type_value))
{
$this->message('你没有相应的权限查看');
}
else if (!($perm) && in_array($_W['routes'], $perm_type_value))
{
$this->message('你没有相应的权限查看');
}
}
if (isset($perm_view) && !($perm_view))
{
$this->message('你没有相应的权限查看');
}
}
}
}
if ($_W['ispost'])
{
rc();
}
m('system')->history_url();
}
public function isOpenPlugin()
{
$name = com_run('perm::allPerms');
unset($name['shop'], $name['goods'], $name['member'], $name['order'], $name['finance'], $name['statistics'], $name['sysset'], $name['sale']);
$name_keys = array_keys($name);
return implode('|', $name_keys);
}
public function frame_menus()
{
global $_GPC;
global $_W;
if ($_W['plugin'])
{
include $this->template($_W['plugin'] . '/tabs');
}
else if ($_W['controller'] == 'system')
{
$routes = explode('.', $_W['routes']);
$tabs = $routes[0] . ((isset($routes[1]) ? '/' . $routes[1] : '')) . '/tabs';
include $this->template($tabs);
}
else
{
include $this->template($_W['controller'] . '/tabs');
}
}
public function show_funbar()
{
global $_W;
$funbardata = pdo_fetch('select * from ' . tablename('ewei_shop_funbar') . ' where uid=:uid and uniacid=:uniacid limit 1', array(':uid' => $_W['uid'], ':uniacid' => $_W['uniacid']));
if (!(empty($funbardata['datas'])) && !(is_array($funbardata['datas'])))
{
if (strexists($funbardata['datas'], '{"'))
{
$funbardata['datas'] = json_decode($funbardata['datas'], true);
}
else
{
$funbardata['datas'] = unserialize($funbardata['datas']);
}
}
include $this->template('funbar');
}
}
?>

View File

@@ -1,18 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class ComWebPage extends WebPage
{
public function __construct($_com = '')
{
parent::__construct();
if (com('perm') && !com('perm')->check_com($_com)) {
$this->message('你没有相应的权限查看');
}
}
}
?>

View File

@@ -1,122 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class PluginWebPage extends WebPage
{
public $pluginname;
/**
* @var $model AppModel
*/
public $model;
public $plugintitle;
public $set;
public $beforeRequest = array();
public $afterRequest;
public function __construct($_init = true)
{
parent::__construct($_init);
global $_W,$_GPC;
if (com('perm') && !com('perm')->check_plugin($_W['plugin'])) {
$this->message("你没有相应的权限查看");
}
$this->pluginname = $_W['plugin'];
$this->modulename = 'ewei_shopv2';
$this->plugintitle = m('plugin')->getName($this->pluginname);
//判断是否是第三方的应用
if(strpos($this->pluginname,'open_messikefu')!==false){
$redis = redis();
if(!function_exists('redis') || is_error($redis)){
$this->message('请联系管理员开启 redis 支持,才能使用第三方插件','','error');
exit;
}
$key = pdo_fetch("SELECT * FROM ".tablename('ewei_shop_open_plugin')." WHERE plugin = :plugin", array(':plugin' => $this->pluginname));
// 如果key为空或者没有设置的有问题的时候
if(empty($key['key']) || $key['status'] ==2){
$this->message('key未填写或key验证失败', webUrl('util.open', array('plugin' => $this->pluginname,'title'=>$this->plugintitle)), 'error');
}
$redis_key = $this->pluginname;
if($key['expirtime'] <=time() || is_null($redis->get($redis_key))){
$info = $this->checkOpen($key['key'],$key['plugin'],$key['domain']);
//过期时间一个月
if($info && $info['errno']==-1){
$this->message($info['errmsg'], webUrl('util.open', array('plugin' => $this->pluginname,'title'=>$this->plugintitle)),'error');
}
if (!is_error($redis)) {
if ($redis->setnx($redis_key, time())) {
$redis->expireAt($redis_key, time() + 172800);
}
}
pdo_update('ewei_shop_open_plugin',array('expirtime'=>time()+ 172800),array('id'=>$key['id']));
}
}
// PC插件必须开启全网通和用户手机号绑定
if ($this->pluginname == 'pc') {
$wapSetting = m('common')->getSysset('wap');
if (!$wapSetting['open']) {
$this->message('使用PC必须开启全网通WAP访问');
}
if (!$wapSetting['mustbind']) {
$this->message('使用PC必须开启强制绑定手机号');
}
}
$this->model = m('plugin')->loadModel($this->pluginname);
$this->set = $this->model->getSet();
if ($_W['ispost']) {
rc($this->pluginname);
}
}
public function getSet()
{
return $this->set;
}
public function updateSet($data = array())
{
$this->model->updateSet($data);
}
private function checkOpen($key='',$plugin='',$domain=''){
global $_W;
$auth = get_auth();
$ip = $_SERVER['HTTP_ALI_CDN_REAL_IP'];
if(!$ip){
$ip = gethostbyname($domain);
}
$data = array(
'ip' =>$ip,
'site_id' => $auth['id'],
'auth_key' => $auth['code'],
'domain' => $domain,
'plugins'=>$plugin,
'app_key'=>$key
);
$resp = ihttp_post(EWEI_SHOPV2_AUTH_WXAPP . "/grant", $data);
if (empty($resp['content']))
{
return array('errno'=>-1,'errmsg'=>'访问失败');
}
$result = json_decode($resp['content'], true);
return $result;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,77 +0,0 @@
<?php
class PluginModel
{
private $pluginname;
private $set;
public function __construct($name = '')
{
$this->pluginname = $name;
$this->set = $this->getSet();
}
public function getSet()
{
if (empty($GLOBALS['_S'][$this->pluginname])) {
return m('common')->getPluginset($this->pluginname);
}
return $GLOBALS['_S'][$this->pluginname];
}
public function updateSet($data = array())
{
m('common')->updatePluginset(array($this->pluginname => $data));
}
public function getName()
{
return pdo_fetchcolumn('select name from ' . tablename('ewei_shop_plugin') . ' where identity=:identity limit 1', array(':identity' => $this->pluginname));
}
public function checkSubmit($key, $time = 2, $message = '操作频繁,请稍后再试!')
{
global $_W;
$open_redis = function_exists('redis') && !is_error(redis());
if ($open_redis) {
$redis_key = $_W['setting']['site']['key'] . '_' . $_W['account']['key'] . '_' . $_W['uniacid'] . '_' . $_W['openid'] . '_mobilesubmit_' . $key;
$redis = redis();
if ($redis->setnx($redis_key, time())) {
$redis->expireAt($redis_key, time() + $time);
}
else {
return error(-1, $message);
}
}
return true;
}
public function checkSubmitGlobal($key, $time = 2, $message = '操作频繁,请稍后再试!')
{
global $_W;
$open_redis = function_exists('redis') && !is_error(redis());
if ($open_redis) {
$redis_key = $_W['setting']['site']['key'] . '_' . $_W['account']['key'] . '_' . $_W['uniacid'] . '_mobilesubmit_' . $key;
$redis = redis();
if ($redis->setnx($redis_key, time())) {
$redis->expireAt($redis_key, time() + $time);
}
else {
return error(-1, $message);
}
}
return true;
}
}
if (!defined('IN_IA')) {
exit('Access Denied');
}
?>

View File

@@ -1,58 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
require dirname(__DIR__) . '/../defines.php';
class PluginProcessor extends WeModuleProcessor
{
public $model;
public $modulename;
public $message;
public function __construct($name = '')
{
global $_W;
$this->modulename = 'ewei_shopv2';
$this->pluginname = $name;
$secure = $this->getIsSecureConnection();
$http = $secure ? 'https' : 'http';
$_W['siteroot'] = strexists($_W['siteroot'], 'https://') ? $_W['siteroot'] : str_replace('http', $http, $_W['siteroot']);
$this->loadModel();
}
/**
* 加载插件model
*/
private function loadModel()
{
$modelfile = IA_ROOT . '/addons/' . $this->modulename . '/plugin/' . $this->pluginname . '/core/model.php';
if (is_file($modelfile)) {
$classname = ucfirst($this->pluginname) . 'Model';
require $modelfile;
$this->model = new $classname($this->pluginname);
}
}
public function respond($obj = '')
{
$this->message = $this->message;
}
public function getIsSecureConnection()
{
if (isset($_SERVER['HTTPS']) && ('1' == $_SERVER['HTTPS'] || 'on' == strtolower($_SERVER['HTTPS']))) {
return true;
}
if (isset($_SERVER['SERVER_PORT']) && '443' == $_SERVER['SERVER_PORT']) {
return true;
}
return false;
}
}
?>

View File

@@ -1,48 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Processor extends WeModuleProcessor
{
public function respond()
{
$rule = pdo_fetch('select * from ' . tablename('rule') . ' where id=:id limit 1', array(':id' => $this->rule));
if (empty($rule)) {
return false;
}
$names = explode(':', $rule['name']);
$plugin = (isset($names[1]) ? $names[1] : '');
$processname = $plugin;
if (!empty($plugin)) {
if ($plugin == 'com') {
$com = (isset($names[2]) ? $names[2] : '');
if (empty($com)) {
return false;
}
$processname = $com;
$processor_file = EWEI_SHOPV2_PROCESSOR . $com . '.php';
}
else {
$processor_file = EWEI_SHOPV2_PLUGIN . $plugin . '/core/processor.php';
}
if (is_file($processor_file)) {
require $processor_file;
$processor_class = ucfirst($processname) . 'Processor';
$proc = new $processor_class($plugin);
if (method_exists($proc, 'respond')) {
return $proc->respond($this);
}
}
}
}
}
?>

View File

@@ -1,121 +0,0 @@
<?php
//20200612
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Receiver extends WeModuleReceiver {
public function receive() {
global $_W;
$type = $this->message['type'];
$event = $this->message['event'];
//redis 防止并发
$open_redis = function_exists('redis') && !is_error(redis());
$redis_key = "receive_".$this->message['from'];
// $file_key = __DIR__."/{$this->message['from']}.json";
if($open_redis){
$redis = redis();
if($redis->get($redis_key)){
return $this->responseEmpty();
}
$redis->set($redis_key, 2,2);
}else{
$handle = opendir(__DIR__); //当前目录
while (false !== ($file = readdir($handle))) { //遍历该php文件所在目录
list($filesname,$kzm)=explode(".",$file);//获取扩展名
if($kzm=="json") { //文件过滤
if (!is_dir('./'.$file)) { //文件夹过滤
$info = filectime(__DIR__.'/'.$file);
if($info<time()){
@unlink(__DIR__.'/'.$file);
}
}
}
}
if(file_exists($file_key)){
return $this->responseEmpty();
}
fopen($file_key,'a+');
}
if($event == 'subscribe' && $type == 'subscribe') {
$this->saleVirtual();
}
}
public function saleVirtual($obj=null)
{
global $_W;
if (empty($obj)){
$obj = $this;
}
$sale = m('common')->getSysset('sale');
$data = $sale['virtual'];
if (empty($data['status'])){
return false;
}
load()->model('account');
$account = account_fetch($_W['uniacid']);
//会员统计查询
$open_redis = function_exists('redis') && !is_error(redis());
if( $open_redis ) {
$redis_key1 = "ewei_{$_W['uniacid']}_member_salevirtual_isagent";
$redis_key2 = "ewei_{$_W['uniacid']}_member_salevirtual";
$redis = redis();
if (!is_error($redis)) {
if ($redis->get($redis_key1) != false) {
$totalagent = $redis->get($redis_key1);
$totalmember = $redis->get($redis_key2);
} else {
$totalagent = pdo_fetchcolumn("select count(*) from" . tablename('ewei_shop_member') . " where uniacid =" . $_W['uniacid'] . " and isagent =1");
$totalmember = pdo_fetchcolumn("select count(*) from" . tablename('ewei_shop_member') . " where uniacid =" . $_W['uniacid']);
$redis->set($redis_key1, $totalagent, array('nx', 'ex' => '3600')); //设置缓存 过期时间为1小时
$redis->set($redis_key2, $totalmember, array('nx', 'ex' => '3600')); //设置缓存 过期时间为1小时
}
}
}else{
$totalagent = pdo_fetchcolumn("select count(*) from" . tablename('ewei_shop_member') . " where uniacid =" . $_W['uniacid'] . " and isagent =1");
$totalmember = pdo_fetchcolumn("select count(*) from" . tablename('ewei_shop_member') . " where uniacid =" . $_W['uniacid']);
}
$acc = WeAccount::create();
$member = abs((int)$data['virtual_people']) + (int)$totalmember;
$commission =abs((int)$data['virtual_commission']) + (int)$totalagent;
$user = m('member')->checkMemberFromPlatform($obj->message['from'],$acc);
//超级海报会员关注
if ($_SESSION['eweishop']['poster_member']){
$user['isnew'] = true;
$_SESSION['eweishop']['poster_member'] = null;
}
if ($user['isnew'])
{
$message = str_replace('[会员数]', $member, $data['virtual_text']);
$message = str_replace('[排名]', $member+1, $message);
} else{
$message = str_replace('[会员数]', $member, $data['virtual_text2']);
}
$message = str_replace('[分销商数]', $commission, $message);
$message = str_replace('[昵称]', $user['nickname'], $message);
$message = htmlspecialchars_decode($message,ENT_QUOTES);
$message = str_replace('"','\"',$message);
return $this->sendText($acc,$obj->message['from'],$message);
}
public function sendText($acc,$openid,$content){
$send['touser'] = trim($openid);
$send['msgtype'] = 'text';
$send['text'] = array('content' => urlencode($content));
$data = $acc->sendCustomNotice($send);
return $data;
}
private function responseEmpty() {
ob_clean();
ob_start();
echo '';
ob_flush();
ob_end_flush();
exit(0);
}
}

View File

@@ -1,105 +0,0 @@
<?php
namespace core\job;
class sendPoster
{
public $openid;
public $acid;
public $uniacid;
public $content;
public function __construct($config = array())
{
if (!empty($config)){
foreach ($config as $name => $value) {
$this->$name = $value;
}
}
}
public function execute($queue)
{
global $_W;
$_W['uniacid'] = $this->uniacid;
$_W['acid'] = $this->acid;
$openid = $this->openid;
$content = $this->content;
//用户
if(empty($openid)){
return;
}
$member = m('member')->getMember($openid);
if(empty($member)){
return;
}
if (strexists($content, '+')) {
$msg = explode('+', $content);
$poster = pdo_fetch('select * from ' . tablename('ewei_shop_poster') . ' where keyword2=:keyword and type=3 and isdefault=1 and uniacid=:uniacid limit 1', array(':keyword' => $msg[0], ':uniacid' => $_W['uniacid']));
if (empty($poster)) {
m('message')->sendCustomNotice($openid, '未找到商品海报类型!');
return;
}
$goodsid = intval($msg[1]);
if (empty($goodsid)) {
m('message')->sendCustomNotice($openid, '未找到商品, 无法生成海报 !');
return;
}
} else {
//查找二维码类型
$poster = pdo_fetch('select * from ' . tablename('ewei_shop_poster') . ' where keyword2=:keyword and isdefault=1 and uniacid=:uniacid limit 1', array(':keyword' => $content, ':uniacid' => $_W['uniacid']));
if (empty($poster)) {
m('message')->sendCustomNotice($openid, '未找到海报类型!');
return;
}
}
if ($member['isagent'] != 1 || $member['status'] != 1) {
$set = array();
if(p('commission')){
$set = p('commission')->getSet();
}
//如果不分销商
if (empty($poster['isopen']) ) {
$opentext = !empty($poster['opentext'])?$poster['opentext']:'您还不是我们'.$set['texts']['agent'].',去努力成为'.$set['texts']['agent'].',拥有你的专属海报吧!';
m('message')->sendCustomNotice($openid, $opentext, trim($poster['openurl']));
return;
}
}
$waittext = !empty($poster['waittext'])?htmlspecialchars_decode($poster['waittext'],ENT_QUOTES):'您的专属海报正在拼命生成中,请等待片刻...';
$waittext = str_replace('"','\"',$waittext);
m('message')->sendCustomNotice($openid, $waittext);
//获取二维码图片
$qr = p('poster')->getQR($poster, $member, $goodsid);
if (is_error($qr)) {
m('message')->sendCustomNotice($openid, '生成二维码出错: ' . $qr['message']);
return;
}
//生成海报
$img = p('poster')->createPoster($poster, $member, $qr);
$mediaid = $img['mediaid'];
if(!empty($mediaid)){
//发送海报
m('message')->sendImage($openid,$mediaid);
}
else{
$oktext= "<a href='".$img['img']."'>点击查看您的专属海报</a>";
m('message')->sendCustomNotice($openid, $oktext);
}
}
}

View File

@@ -1,96 +0,0 @@
<?php
namespace core\job;
class sendPostera
{
public $openid;
public $_W;
public $content;
public function __construct($config = array())
{
if (!empty($config)){
foreach ($config as $name => $value) {
$this->$name = $value;
}
}
}
public function execute($queue)
{
global $_W;
$_W = $this->_W;
$openid = $this->openid;
$content = $this->content;
//用户
if(empty($openid)){
return;
}
$member = m('member')->getMember($openid);
if(empty($member)){
return;
}
//查找二维码
$poster = pdo_fetch('select * from ' . tablename('ewei_shop_postera') . ' where keyword2=:keyword and uniacid=:uniacid limit 1', array(':keyword' => $content, ':uniacid' => $_W['uniacid']));
if (empty($poster)) {
m('message')->sendCustomNotice($openid, '未找到海报!');
return;
}
$time = time();
if($poster['timestart']>$time){
$starttext =empty($poster['starttext'])?"活动于 [starttime] 开始,请耐心等待...":$poster['starttext'];
$starttext =str_replace("[starttime]",date('Y年m月d日 H:i',$poster['timestart']),$starttext);
$starttext =str_replace("[endtime]",date('Y年m月d日 H:i',$poster['timeend']),$starttext);
m('message')->sendCustomNotice($openid,$starttext);
return;
}
if( $poster['timeend']<time()){
$endtext = empty($poster['endtext'])?"活动已结束,谢谢您的关注!":$poster['endtext'];
$endtext =str_replace("[starttime]",date('Y-m-d H:i',$poster['timestart']),$endtext);
$endtext =str_replace("[endtime]",date('Y-m-d- H:i',$poster['timeend']),$endtext);
m('message')->sendCustomNotice($openid,$endtext);
return;
}
if ($member['isagent'] != 1 || $member['status'] != 1) {
//如果不分销商
if (empty($poster['isopen']) ) {
$opentext = !empty($poster['opentext'])?htmlspecialchars_decode($poster['opentext'],ENT_QUOTES):'您还不是我们分销商,去努力成为分销商,拥有你的专属海报吧!';
m('message')->sendCustomNotice($openid, $opentext, trim($poster['openurl']));
return;
}
}
$waittext = !empty($poster['waittext'])?htmlspecialchars_decode($poster['waittext'],ENT_QUOTES):'您的专属海报正在拼命生成中,请等待片刻...';
$waittext =str_replace("[starttime]",date('Y年m月d日 H:i',$poster['timestart']),$waittext);
$waittext =str_replace("[endtime]",date('Y年m月d日 H:i',$poster['timeend']),$waittext);
m('message')->sendCustomNotice($openid, $waittext);
//获取二维码图片
$qr = p('postera')->getQR($poster, $member);
if (is_error($qr)) {
m('message')->sendCustomNotice($openid, '生成二维码出错: ' . $qr['message']);
return;
}
//生成海报
$img = p('postera')->createPoster($poster, $member, $qr);
$mediaid = $img['mediaid'];
if(!empty($mediaid)){
//发送海报
m('message')->sendImage($openid,$mediaid);
}
else{
$oktext= "<a href='".$img['img']."'>点击查看您的专属海报</a>";
m('message')->sendCustomNotice($openid, $oktext);
}
}
}

View File

@@ -1,21 +0,0 @@
<p>// +----------------------------------------------------------------------
</p>
<p>// | Program Name: <EFBFBD><EFBFBD>ӭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>վ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>pnp8.comwww. pnp8 .com <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧϰ<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD> </p>
<p>// +---------------------------------------------------------------------- </p>
<p>// | Copyright: (c) 2013-2019 http://www.www.pnp8.com! All rights reserved. </p>
<p>// +---------------------------------------------------------------------- </p>
<p>// | Developer: <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>pnp8.comwww .pnp8 .com Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳ </p>
<p>// +---------------------------------------------------------------------- </p>
<p>* <EFBFBD><EFBFBD>л֧<EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>վ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD> </p>
<p>* <EFBFBD><EFBFBD>ӭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>VIP<EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> </p>

View File

@@ -1,305 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobilePage
{
protected function getWapSet()
{
global $_W;
global $_GPC;
$set = m('common')->getSysset(array('shop', 'wap'));
$set['wap']['color'] = empty($set['wap']['color']) ? '#fff' : $set['wap']['color'];
$params = array();
if (!empty($_GPC['mid'])) {
$params['mid'] = $_GPC['mid'];
}
if (!empty($_GPC['backurl'])) {
$params['backurl'] = $_GPC['backurl'];
}
$set['wap']['loginurl'] = mobileUrl('account/login', $params);
$set['wap']['regurl'] = mobileUrl('account/register', $params);
$set['wap']['forgeturl'] = mobileUrl('account/forget', $params);
return $set;
}
public function agr(){
global $_W;
global $_GPC;
$set = $this->getWapSet()['wap'];
$type = $_GPC['type'];
if($type == 1){
$agr_content = m('common')->html_to_images($set['content']);
}else{
$agr_content = m('common')->html_to_images($set['content1']);
}
include $this->template('agr', NULL, true);
}
public function login()
{
global $_W;
global $_GPC;
if (is_weixin() || !empty($_GPC['__ewei_shopv2_member_session_' . $_W['uniacid']])) {
header('location: ' . mobileUrl());
}
if ($_W['ispost']) {
$mobile = trim($_GPC['mobile']);
$pwd = trim($_GPC['pwd']);
$member = pdo_fetch('select id,openid,mobile,pwd,salt from ' . tablename('ewei_shop_member') . ' where mobile=:mobile and mobileverify=1 and uniacid=:uniacid limit 1', array(':mobile' => $mobile, ':uniacid' => $_W['uniacid']));
if (empty($member)) {
show_json(0, '用户不存在');
}
if (md5($pwd . $member['salt']) !== $member['pwd']) {
show_json(0, '用户或密码错误');
}
m('account')->setLogin($member);
show_json(1, '登录成功');
}
$set = $this->getWapSet();
$backurl = '';
if (!empty($_GPC['backurl'])) {
$backurl = $_W['siteroot'] . 'app/index.php?' . base64_decode(urldecode($_GPC['backurl']));
}
$wapset = $_W['shopset']['wap'];
$sns = $wapset['sns'];
include $this->template('login', NULL, true);
}
public function register()
{
$this->rf(0);
}
public function forget()
{
$this->rf(1);
}
protected function rf($type)
{
global $_W;
global $_GPC;
if (is_weixin() || !empty($_GPC['__ewei_shopv2_member_session_' . $_W['uniacid']])) {
header('location: ' . mobileUrl());
}
if ($_W['ispost']) {
$mobile = trim($_GPC['mobile']);
$verifycode = trim($_GPC['verifycode']);
$pwd = trim($_GPC['pwd']);
if (empty($mobile)) {
show_json(0, '请输入正确的手机号');
}
if (empty($verifycode)) {
show_json(0, '请输入验证码');
}
if (empty($pwd)) {
show_json(0, '请输入密码');
}
$key = '__ewei_shopv2_member_verifycodesession_' . $_W['uniacid'] . '_' . $mobile;
if (!isset($_SESSION[$key]) || $_SESSION[$key] !== $verifycode || !isset($_SESSION['verifycodesendtime']) || $_SESSION['verifycodesendtime'] + 600 < time()) {
show_json(0, '验证码错误或已过期!');
}
$member = pdo_fetch('select id,openid,mobile,pwd,salt from ' . tablename('ewei_shop_member') . ' where mobile=:mobile and mobileverify=1 and uniacid=:uniacid limit 1', array(':mobile' => $mobile, ':uniacid' => $_W['uniacid']));
if (empty($type)) {
if (!empty($member)) {
show_json(0, '此手机号已注册, 请直接登录');
}
$salt = empty($member) ? '' : $member['salt'];
if (empty($salt)) {
$salt = m('account')->getSalt();
}
$openid = empty($member) ? '' : $member['openid'];
$nickname = empty($member) ? '' : $member['nickname'];
if (empty($openid)) {
$openid = 'wap_user_' . $_W['uniacid'] . '_' . $mobile;
$nickname = substr($mobile, 0, 3) . 'xxxx' . substr($mobile, 7, 4);
}
$data = array('uniacid' => $_W['uniacid'], 'mobile' => $mobile, 'nickname' => $nickname, 'openid' => $openid, 'pwd' => md5($pwd . $salt), 'salt' => $salt, 'createtime' => time(), 'mobileverify' => 1, 'comefrom' => 'mobile');
}
else {
if (empty($member)) {
show_json(0, '此手机号未注册');
}
$salt = m('account')->getSalt();
$data = array('salt' => $salt, 'pwd' => md5($pwd . $salt));
}
if (empty($member)) {
pdo_insert('ewei_shop_member', $data);
if (method_exists(m('member'), 'memberRadisCountDelete')) {
m('member')->memberRadisCountDelete();
}
}
else {
pdo_update('ewei_shop_member', $data, array('id' => $member['id']));
}
if (p('commission')) {
p('commission')->checkAgent($openid);
}
unset($_SESSION[$key]);
show_json(1, empty($type) ? '注册成功' : '密码重置成功');
}
$sendtime = $_SESSION['verifycodesendtime'];
if (empty($sendtime) || $sendtime + 60 < time()) {
$endtime = 0;
}
else {
$endtime = 60 - (time() - $sendtime);
}
$set = $this->getWapSet();
include $this->template('rf', NULL, true);
}
public function logout()
{
global $_W;
global $_GPC;
$key = '__ewei_shopv2_member_session_' . $_W['uniacid'];
isetcookie($key, false, -100);
header('location: ' . mobileUrl());
exit();
}
public function cancellation()
{
global $_W;
global $_GPC;
pdo_delete('ewei_shop_member',array('openid'=>$_W['openid'],'uniacid'=>$_W['uniacid']));
show_json(1);
}
public function sns()
{
global $_W;
global $_GPC;
if (is_weixin() || !empty($_GPC['__ewei_shopv2_member_session_' . $_W['uniacid']])) {
header('location: ' . mobileUrl());
}
$sns = trim($_GPC['sns']);
if ($_W['ispost'] && !empty($sns) && !empty($_GPC['openid'])) {
m('member')->checkMemberSNS($sns);
}
if ($_GET['openid']) {
if ($sns == 'qq') {
$_GET['openid'] = 'sns_qq_' . $_GET['openid'];
}
if ($sns == 'wx') {
$_GET['openid'] = 'sns_wx_' . $_GET['openid'];
}
m('account')->setLogin($_GET['openid']);
}
$backurl = '';
if (!empty($_GPC['backurl'])) {
$backurl = $_W['siteroot'] . 'app/index.php?' . base64_decode(urldecode($_GPC['backurl']));
}
$backurl = empty($backurl) ? mobileUrl(NULL, NULL, true) : trim($backurl);
header('location: ' . $backurl);
}
public function verifycode()
{
global $_W;
global $_GPC;
@session_start();
$set = $this->getWapSet();
$mobile = trim($_GPC['mobile']);
$temp = trim($_GPC['temp']);
$imgcode = trim($_GPC['imgcode']);
if (empty($mobile)) {
show_json(0, '请输入手机号');
}
if (empty($temp)) {
show_json(0, '参数错误');
}
if (!empty($_SESSION['verifycodesendtime']) && time() < $_SESSION['verifycodesendtime'] + 60) {
show_json(0, '请求频繁请稍后重试');
}
if (!empty($set['wap']['smsimgcode'])) {
if (empty($imgcode)) {
show_json(0, '请输入图形验证码');
}
$key = function_exists('complex_authkey') ? complex_authkey() : $_W['config']['setting']['authkey'];
$imgcodehash = md5(strtolower($imgcode) . $key);
if ($imgcodehash != trim($_GPC['__code'])) {
show_json(-1, '请输入正确的图形验证码');
}
}
$member = pdo_fetch('select id,openid,mobile,pwd,salt from ' . tablename('ewei_shop_member') . ' where mobile=:mobile and mobileverify=1 and uniacid=:uniacid limit 1', array(':mobile' => $mobile, ':uniacid' => $_W['uniacid']));
if ($temp == 'sms_forget' && empty($member)) {
show_json(0, '此手机号未注册');
}
if ($temp == 'sms_reg' && !empty($member)) {
show_json(0, '此手机号已注册,请直接登录');
}
$sms_id = $set['wap'][$temp];
if (empty($sms_id)) {
show_json(0, '短信发送失败(NOSMSID)');
}
$key = '__ewei_shopv2_member_verifycodesession_' . $_W['uniacid'] . '_' . $mobile;
@session_start();
$code = random(5, true);
$shopname = $_W['shopset']['shop']['name'];
$ret = array('status' => 0, 'message' => '发送失败');
if (com('sms')) {
$ret = com('sms')->send($mobile, $sms_id, array('验证码' => $code, '商城名称' => !empty($shopname) ? $shopname : '商城名称'));
}
if ($ret['status']) {
$_SESSION[$key] = $code;
$_SESSION['verifycodesendtime'] = time();
show_json(1, '短信发送成功');
}
show_json(0, $ret['message']);
}
}
?>

View File

@@ -1,33 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Code_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$id = intval($_GPC['id']);
$goodsid = intval($_GPC['goodsid']);
$codegoods = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_goodscode_good') . " WHERE\r\n uniacid = " . $uniacid . ' and goodsid = ' . $goodsid . ' and id = ' . $id . ' and status = 1 ');
if (empty($codegoods)) {
$this->message(array('message' => '该商品不存在或已删除'), mobileUrl(''), 'error');
}
$goods = pdo_fetch('SELECT title,content FROM ' . tablename('ewei_shop_goods') . " WHERE\r\n uniacid = " . $uniacid . ' and id = ' . $goodsid . ' and deleted=0 and status = 1 ');
if (empty($goods)) {
$this->message(array('message' => '该商品不存在或已删除'), mobileUrl(''), 'error');
}
$goods['content'] = m('ui')->lazy($goods['content']);
include $this->template();
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,110 +0,0 @@
<?php
if (!(defined('IN_IA'))) {
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
global $_GPC;
$allcategory = m('shop')->getCategory();
$catlevel = intval($_W['shopset']['category']['level']);
$opencategory = true;
$plugin_commission = p('commission');
if ($plugin_commission && (0 < intval($_W['shopset']['commission']['level']))) {
$mid = intval($_GPC['mid']);
if (!(empty($mid)) && empty($_W['shopset']['commission']['closemyshop']) && !(empty($_W['shopset']['commission']['select_goods']))) {
$shop = p('commission')->getShop($mid);
if (empty($shop['selectcategory']) && !(empty($shop['selectgoods']))) {
$opencategory = false;
}
}
}
include $this->template();
}
public function gift()
{
global $_W;
global $_GPC;
$uniacid = $_W['uniacid'];
$giftid = intval($_GPC['id']);
$gift = pdo_fetch('select * from ' . tablename('ewei_shop_gift') . ' where uniacid = ' . $uniacid . ' and id = ' . $giftid . ' and starttime <= ' . time() . ' and endtime >= ' . time() . ' and status = 1 ');
$giftgoodsid = explode(',', $gift['giftgoodsid']);
$giftgoods = array();
if (!(empty($giftgoodsid))) {
foreach ($giftgoodsid as $key => $value ) {
$giftgoods[$key] = pdo_fetch('select id,status,title,thumb,marketprice from ' . tablename('ewei_shop_goods') . ' where uniacid = ' . $uniacid . ' and deleted = 0 and total > 0 and id = ' . $value . ' and status = 2 ');
}
$giftgoods = array_filter($giftgoods);
}
include $this->template();
}
public function get_list()
{
global $_GPC;
global $_W;
$args = array('pagesize' => 10, 'page' => intval($_GPC['page']), 'isnew' => trim($_GPC['isnew']), 'ishot' => trim($_GPC['ishot']), 'isrecommand' => trim($_GPC['isrecommand']), 'isdiscount' => trim($_GPC['isdiscount']), 'istime' => trim($_GPC['istime']), 'issendfree' => trim($_GPC['issendfree']), 'keywords' => trim($_GPC['keywords']), 'cate' => trim($_GPC['cate']), 'order' => trim($_GPC['order']), 'by' => trim($_GPC['by']));
$plugin_commission = p('commission');
if ($plugin_commission && (0 < intval($_W['shopset']['commission']['level'])) && empty($_W['shopset']['commission']['closemyshop']) && !(empty($_W['shopset']['commission']['select_goods']))) {
$frommyshop = intval($_GPC['frommyshop']);
$mid = intval($_GPC['mid']);
if (!(empty($mid)) && !(empty($frommyshop))) {
$shop = p('commission')->getShop($mid);
if (!(empty($shop['selectgoods']))) {
$args['ids'] = $shop['goodsids'];
}
}
}
$this->_condition($args);
}
public function query()
{
global $_GPC;
global $_W;
$args = array('pagesize' => 10, 'page' => intval($_GPC['page']), 'isnew' => trim($_GPC['isnew']), 'ishot' => trim($_GPC['ishot']), 'isrecommand' => trim($_GPC['isrecommand']), 'isdiscount' => trim($_GPC['isdiscount']), 'istime' => trim($_GPC['istime']), 'keywords' => trim($_GPC['keywords']), 'cate' => trim($_GPC['cate']), 'order' => trim($_GPC['order']), 'by' => trim($_GPC['by']));
$this->_condition($args);
}
private function _condition($args)
{
global $_GPC;
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if ($merch_plugin && $merch_data['is_openmerch']) {
$args['merchid'] = intval($_GPC['merchid']);
}
if (isset($_GPC['nocommission'])) {
$args['nocommission'] = intval($_GPC['nocommission']);
}
$goods = m('goods')->getList($args);
show_json(1, array('list' => $goods['list'], 'total' => $goods['total'], 'pagesize' => $args['pagesize']));
}
}
?>

View File

@@ -1,98 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Package_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$goodsid = intval($_GPC['goodsid']);
$packages_goods = array();
$packages = array();
$goodsid_array = array();
if ($goodsid) {
$packages_goods = pdo_fetchall('SELECT id,pid FROM ' . tablename('ewei_shop_package_goods') . "\r\n WHERE uniacid = " . $uniacid . ' and goodsid = ' . $goodsid . ' group by pid ORDER BY id DESC');
foreach ($packages_goods as $key => $value) {
$packages[$key] = pdo_fetch('SELECT id,title,thumb,price,goodsid FROM ' . tablename('ewei_shop_package') . "\r\n WHERE uniacid = " . $uniacid . ' and id = ' . $value['pid'] . ' and starttime <= ' . time() . ' and endtime >= ' . time() . ' and deleted = 0 and status = 1 ORDER BY id DESC');
}
$packages = array_values(array_filter($packages));
}
else {
$packages = pdo_fetchall('SELECT id,title,thumb,price,goodsid FROM ' . tablename('ewei_shop_package') . "\r\n WHERE uniacid = " . $uniacid . ' and starttime <= ' . time() . ' and endtime >= ' . time() . ' and deleted = 0 and status = 1 ORDER BY id DESC');
}
if (empty($packages)) {
$this->message('套餐不存在或已删除!', mobileUrl(), 'error');
}
foreach ($packages as $key => $value) {
$goods = explode(',', $value['goodsid']);
foreach ($goods as $k => $val) {
$g = pdo_fetch('SELECT id,marketprice FROM ' . tablename('ewei_shop_goods') . "\r\n WHERE uniacid = " . $uniacid . ' and id = ' . $val . ' ORDER BY id DESC');
$goods['goodsprice'] += $g['marketprice'];
}
$packages[$key]['goodsprice'] = $goods['goodsprice'];
}
$packages = set_medias($packages, array('thumb'));
include $this->template();
}
public function detail()
{
global $_W;
global $_GPC;
$uniacid = $_W['uniacid'];
$pid = intval($_GPC['pid']);
$package = pdo_fetch('SELECT id,title,price,freight,share_title,share_icon,share_desc FROM ' . tablename('ewei_shop_package') . "\r\n WHERE uniacid = " . $uniacid . ' and id = ' . $pid . ' ');
$packgoods = array();
$packgoods = pdo_fetchall('SELECT id,title,thumb,marketprice,packageprice,`option`,goodsid FROM ' . tablename('ewei_shop_package_goods') . "\r\n WHERE uniacid = " . $uniacid . ' and pid = ' . $pid . ' ORDER BY id DESC');
$packgoods = set_medias($packgoods, array('thumb'));
$option = array();
foreach ($packgoods as $key => $value) {
$option_array = array();
$option_array = explode(',', $value['option']);
if (0 < $option_array[0]) {
$pgo = pdo_fetch('SELECT id,title,packageprice FROM ' . tablename('ewei_shop_package_goods_option') . "\r\n WHERE uniacid = " . $uniacid . ' and pid = ' . $pid . ' and goodsid = ' . $value['goodsid'] . ' and optionid = ' . $option_array[0] . ' ');
$packgoods[$key]['packageprice'] = $pgo['packageprice'];
}
}
$_W['shopshare'] = array('title' => !empty($package['share_title']) ? $package['share_title'] : $package['title'], 'imgUrl' => !empty($package['share_icon']) ? tomedia($package['share_icon']) : tomedia($package['thumb']), 'desc' => !empty($package['share_desc']) ? $package['share_desc'] : $_W['shopset']['shop']['name'], 'link' => mobileUrl('goods/package/detail', array('pid' => $package['id']), true));
include $this->template('goods/packdetail');
}
public function option()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$uniacid = intval($_W['uniacid']);
$pid = intval($_GPC['pid']);
$goodsid = intval($_GPC['goodsid']);
$optionid = array();
$option = array();
$packgoods = pdo_fetch('SELECT id,title,`option` FROM ' . tablename('ewei_shop_package_goods') . "\r\n WHERE uniacid = " . $uniacid . ' and goodsid = ' . $goodsid . ' and pid = ' . $pid . ' ORDER BY id DESC');
$optionid = explode(',', $packgoods['option']);
foreach ($optionid as $key => $value) {
$option[$key] = pdo_fetch('SELECT id,title,packageprice,optionid,goodsid FROM ' . tablename('ewei_shop_package_goods_option') . "\r\n WHERE uniacid = " . $uniacid . ' and goodsid = ' . $goodsid . ' and optionid = ' . intval($value) . ' ORDER BY id DESC');
}
show_json(1, $option);
}
}
?>

View File

@@ -1,686 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Picker_EweiShopV2Page extends MobilePage {
function main()
{
global $_W, $_GPC;
$id = intval($_GPC['id']);
$action = trim($_GPC['action']);
$rank = intval($_SESSION[$id . '_rank']);
$log_id = intval($_SESSION[$id . '_log_id']);
$join_id = intval($_SESSION[$id . '_join_id']);
$cremind = false;
$seckillinfo = false;
$seckill = p('seckill');
if( $seckill){
$time = time();
$seckillinfo = $seckill->getSeckill($id);
if(!empty($seckillinfo)){
if($time >= $seckillinfo['starttime'] && $time<$seckillinfo['endtime']){
$seckillinfo['status'] = 0;
}elseif( $time < $seckillinfo['starttime'] ){
$seckillinfo['status'] = 1;
}else {
$seckillinfo['status'] = -1;
}
}
}
/* 直播间商品 处理Step.1 */
$liveid = intval($_GPC['liveid']);
if(!empty($liveid)){
$isliving=false;
if(p('live')){
$isliving = p('live')->isLiving($liveid);
}
if(!$isliving){
$liveid = 0;
}
}
//商品
$goods = pdo_fetch('select id,thumb,title,marketprice,total,maxbuy,minbuy,unit,hasoption,showtotal,diyformid,diyformtype,diyfields,isdiscount,presellprice,isdiscount_time,isdiscount_time_start,isdiscount_discounts,discounts,hascommission,nocommission,commission,commission1_rate,marketprice,commission1_pay,needfollow, followtip, followurl, `type`, isverify, maxprice, minprice, merchsale,ispresell,preselltimeend,unite_total,
threen,preselltimestart,presellovertime,presellover,islive,liveprice,minliveprice,maxliveprice,isnodiscount
from ' . tablename('ewei_shop_goods') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($goods)) {
show_json(0);
}
$threenprice = json_decode($goods['threen'],1);
$goods['thistime'] = time();
$goods = set_medias($goods, 'thumb');
/* 直播间商品 处理Step.2 */
if(!empty($liveid)){
$islive =false;
if(p('live')){
$islive = p('live')->getLivePrice($goods, $liveid);
}
if($islive){
$goods['minprice'] = $islive['minprice'];
$goods['maxprice'] = $islive['maxprice'];
}
}
$openid = $_W['openid'];
if (is_weixin()) {
$follow = m("user")->followed($openid);
if (!empty($goods['needfollow']) && !$follow) {
$followtip = empty($goods['followtip']) ? "如果您想要购买此商品,需要您关注我们的公众号,点击【确定】关注后再来购买吧~" : $goods['followtip'];
$followqrcode = $_W['shopset']['share']['followqrcode'];
$followqrcode = tomedia($followqrcode);
$followurl = empty($goods['followurl']) ? $_W['shopset']['share']['followurl'] : $goods['followurl'];
show_json(2, array('followtip' => $followtip, 'followurl' => $followurl, 'followqrcode' => $followqrcode));
}
}
$openid =$_W['openid'];
$member = m('member')->getMember($openid);
// 验证是否登录
if(empty($openid)){
$sendtime = $_SESSION['verifycodesendtime'];
if(empty($sendtime) || $sendtime+60<time()){
$endtime = 0;
}else{
$endtime = 60 - (time() - $sendtime);
}
show_json(4, array(
'endtime'=>$endtime,
'imgcode'=>$_W['shopset']['wap']['smsimgcode']
));
}
// 验证手机号
if(!empty($_W['shopset']['wap']['open']) && !empty($_W['shopset']['wap']['mustbind']) && empty($member['mobileverify'])){
$sendtime = $_SESSION['verifycodesendtime'];
if(empty($sendtime) || $sendtime+60<time()){
$endtime = 0;
}else{
$endtime = 60 - (time() - $sendtime);
}
show_json(3, array(
'endtime'=>$endtime,
'imgcode'=>$_W['shopset']['wap']['smsimgcode']
));
}
//预售
if($goods['ispresell'] > 0){
$times = $goods['presellovertime'] * 60 * 60 * 24 + $goods['preselltimeend'];
if(!($goods['presellover']>0 && $times <= time())){
if($goods['preselltimestart'] > 0 && $goods['preselltimestart'] > time()){
show_json(5,'预售未开始');
}
if($goods['preselltimeend'] > 0 && $goods['preselltimeend'] < time()){
show_json(5,'预售已结束');
}
}
//预售结束转为正常销售
/*$times = $goods['presellovertime'] * 60 * 60 * 24 + $goods['preselltimeend'];
if($goods['presellover']>0 && $times <= time() && $goods['preselltimeend'] > 0 && $goods['preselltimeend'] < time()){
}else{
show_json(5,'预售已结束');
}*/
}
if($goods['isdiscount'] && $goods['isdiscount_time']>=time() && $goods['isdiscount_time_start'] < time() ){
//有促销
$isdiscount = true;
$isdiscount_discounts = json_decode($goods['isdiscount_discounts'],true);
$levelid = $member['level'];
$key = empty($levelid)?'default':'level'.$levelid;
} else {
$isdiscount = false;
}
//任务活动购买商品
$task_goods_data = m('goods')->getTaskGoods($openid, $id, $rank, $log_id, $join_id);
if (empty($task_goods_data['is_task_goods'])) {
$is_task_goods = 0;
} else {
$is_task_goods = $task_goods_data['is_task_goods'];
$is_task_goods_option = $task_goods_data['is_task_goods_option'];
$task_goods = $task_goods_data['task_goods'];
}
$specs =false;
$options = false;
if (!empty($goods) && $goods['hasoption']) {
$specs = pdo_fetchall('select * from ' . tablename('ewei_shop_goods_spec') . ' where goodsid=:goodsid and uniacid=:uniacid order by displayorder asc', array(':goodsid' => $id, ':uniacid' => $_W['uniacid']));
foreach($specs as &$spec) {
$spec['items'] = pdo_fetchall('select * from '.tablename('ewei_shop_goods_spec_item')." where specid=:specid and `show`=1 order by displayorder asc",array(':specid'=>$spec['id']));
}
unset($spec);
$options = pdo_fetchall('select * from ' . tablename('ewei_shop_goods_option') . ' where goodsid=:goodsid and uniacid=:uniacid order by displayorder asc', array(':goodsid' => $id, ':uniacid' => $_W['uniacid']));
}
if (!empty($options) && !empty($goods['unite_total'])) {
foreach($options as &$option){
$option['stock'] = $goods['total'];
}
unset($option);
}
/* 直播间商品 处理Step.3 */
if(!empty($liveid) && !empty($options)){
// 重新获取直播商品规格价格
//$options =array();
if(p('live')){
$options = p('live')->getLiveOptions($goods['id'], $liveid, $options);
}
$prices = array();
foreach ($options as $option){
$prices[] = price_format($option['marketprice']);
}
unset($option);
$goods['minprice'] = min($prices);
$goods['maxprice'] = max($prices);
}
if( $seckillinfo && $seckillinfo['status']==0){
$minprice = $maxprice = $goods['marketprice'] = $seckillinfo['price'];
if(count($seckillinfo['options'])>0 && !empty($options)){
foreach($options as &$option){
foreach($seckillinfo['options'] as $so){
if($option['id']==$so['optionid']){
$option['marketprice'] = $so['price'];
}
}
}
unset($option);
}
} else{
$minprice = $goods['minprice'];
$maxprice = $goods['maxprice'] ;
}
//价格显示
if (!empty($is_task_goods)) {
if ( isset($options) && count($options) > 0 && $goods['hasoption']) {
$prices = array();
foreach ($task_goods['spec'] as $k => $v) {
$prices[] = $v['marketprice'];
}
$minprice = min($prices);
$maxprice = max($prices);
foreach ($options as $k => $v) {
$option_id = $v['id'];
if (array_key_exists($option_id, $task_goods['spec'])) {
if($goods['ispresell']>0 && ($goods['preselltimeend'] == 0 || $goods['preselltimeend'] > time())){
$options[$k]['marketprice'] = $task_goods['spec'][$option_id]['presellprice'];
}else{
$options[$k]['marketprice'] = $task_goods['spec'][$option_id]['marketprice'];
}
$options[$k]['stock'] = $task_goods['spec'][$option_id]['total'];
}
$prices[] = $v['marketprice'];
}
} else {
$minprice = $task_goods['marketprice'];
$maxprice = $task_goods['marketprice'];
}
} else {
if($goods['isdiscount'] && $goods['isdiscount_time']>=time() && $goods['isdiscount_time_start'] < time() ){
$goods['oldmaxprice'] = $maxprice;
$isdiscount_discounts = json_decode($goods['isdiscount_discounts'],true);
$prices = array();
if (!isset($isdiscount_discounts['type']) || empty($isdiscount_discounts['type'])) {
//统一促销
$level = m('member')->getLevel($openid);
$prices_array = m('order')->getGoodsDiscountPrice($goods, $level, 1);
$prices[] = $prices_array['price'];
} else {
//详细促销
$goods_discounts = m('order')->getGoodsDiscounts($goods, $isdiscount_discounts, $levelid, $options);
$prices = $goods_discounts['prices'];
$options = $goods_discounts['options'];
}
$minprice = min($prices);
$maxprice = max($prices);
}
}
//取出后台设置会员折扣的额度,如果商品没有设置就走后台的额度
$leveldiscount = pdo_fetch('SELECT * FROM' . tablename('ewei_shop_member_level') . 'where id=:id and uniacid=:uniacid limit 1 ',array(':id' =>$member['level'], ':uniacid' => $_W['uniacid']));
$leveldis = $leveldiscount['discount'];
// 获取商品的会员价
if($goods['isnodiscount'] ==0){
// 获取会员等级
$member_levelid = intval($member['level']);
if(!empty($member_levelid)){
$member_level = pdo_fetch('select * from ' . tablename('ewei_shop_member_level') . ' where id=:id and uniacid=:uniacid and enabled=1 limit 1', array(':id' =>$member_levelid, ':uniacid' => $_W['uniacid']));
$member_level = empty($member_level)? array(): $member_level;
}
$discounts = json_decode($goods['discounts'], true);
//判断是否开启折扣状态
if (empty($leveldiscount['enabled'])){
$discounts = json_decode($goods['discounts'], true);
}else{
//将会员折扣赋值给商品折扣中
if ($discounts['default'] == 0){
$discounts['default'] = $leveldis;
}
}
/* if (empty($discounts['default'])){
}*/
if (is_array($discounts)) {
$key = !empty($member_level['id']) ? 'level' . $member_level['id'] : 'default';
if (!isset($discounts['type']) || empty($discounts['type'])) {
$memberprice_dis = 0;
if (!empty($discounts[$key])){
$dd = floatval($discounts[$key]); //设置的会员折扣
if ($dd > 0 && $dd < 10) {
$memberprice_dis = round($dd / 10 * $goods['minprice'], 2);
}
}else{
$dd = floatval($discounts[$key.'_pay']); //设置的会员折扣
$md = floatval($member_level['discount']); //会员等级折扣
if (!empty($dd)){
$memberprice_dis = round($dd, 2);
}else if ($md > 0 && $md < 10) {
$memberprice_dis = round($md / 10 * $goods['minprice'], 2);
}
}
$goods['show'] =0;
$goods['member_discount'] = number_format($memberprice_dis,2,'.','');
}
if($goods['hasoption'] ==1&$discounts['type']==1 & empty($isdiscount)) {
//详细折扣
$options = m('goods')->getOptions($goods);
foreach ($options as &$option){
$discount = trim($discounts[$key]['option' . $option['id']]);
if($discount==''){
$discount = round(floatval($member_level['discount'])*10,2).'%';
}
if (!empty($discount)) {
if (strexists($discount, '%')) {
//促销折扣
$dd = floatval(str_replace('%', '', $discount));
if ($dd > 0 && $dd < 100) {
$price = round($dd / 100 * $option['marketprice'], 2);
}
} else if (floatval($discount) > 0) {
//促销价格
$price = round(floatval($discount), 2);
}
}
if($price>0){
$option['member_discount'] = number_format($price,2,'.','');
}else{
$option['member_discount'] = 0;
}
$price = 0;
}
unset($goods['member_discount']);
$goods['show'] =1;
unset($option);
}elseif($goods['hasoption'] ==1&$discounts['type']==0 & empty($isdiscount)){
$options = m('goods')->getOptions($goods);
foreach ($options as &$option){
if (!empty($discounts[$key])){
$dd = floatval($discounts[$key]); //设置的会员折扣
if ($dd > 0 && $dd < 10) {
$memberprice = round($dd / 10 * $option['marketprice'], 2);
}
}else{
$dd = floatval($discounts[$key.'_pay']); //设置的会员折扣
$md = floatval($member_level['discount']); //会员等级折扣
if (!empty($dd)){
$memberprice = round($dd, 2);
}else if ($md > 0 && $md < 10) {
$memberprice = round($md / 10 * $option['marketprice'], 2);
}
}
if($memberprice>0){
$option['member_discount'] = number_format($memberprice,2,'.','');
}else{
$option['member_discount'] = 0;
}
}
unset($option);
unset($goods['member_discount']);
$goods['show'] =1;
}
}
}
// 获取不同规格的不同佣金
$clevel = $this->getcLevel($_W['openid']);
$set = array();
if(p('commission')) {
$set = $this->getSet();
$goods['cansee'] = $set['cansee'];
$goods['seetitle'] = $set['seetitle'];
}else{
$goods['cansee'] = 0;
$goods['seetitle'] = '';
}
if(p('seckill')){
if(!p('seckill')->getSeckill($goods['id'])){
// 秒杀
if($goods['nocommission'] ==1){
$seecommission = 0;
}else if($goods['hascommission'] == 1 && $goods['nocommission'] ==0){
$price = $goods['maxprice'];
$levelid = 'default';
if($clevel == 'false'){
$seecommission = 0;
}else {
if($clevel) {
$levelid = 'level' . $clevel['id'];
}
$goods_commission = !empty($goods['commission']) ? json_decode($goods['commission'], true) : array();
if($goods_commission['type'] == 0) {
$seecommission = $set['level'] >= 1 ? ($goods['commission1_rate'] > 0 ? ($goods['commission1_rate'] * $goods['marketprice'] / 100) : $goods['commission1_pay']) : 0;
if(is_array($options) && !empty($options)){
foreach ($options as $k => $v) {
$seecommission = $set['level'] >= 1 ? ($goods['commission1_rate'] > 0 ? ($goods['commission1_rate'] * $v['marketprice'] / 100) : $v['commission1_pay']) : 0;
$options[$k]['seecommission'] = $seecommission;
}
}
} else {
//获取每个规格的佣金
if(is_array($options)) {
foreach ($goods_commission[$levelid] as $key => $value) {
foreach ($options as $k => $v) {
if(('option' . $v['id']) == $key) {
if(strexists($value[0], '%')) {
$options[$k]['seecommission'] = (floatval(str_replace('%', '', $value[0]) / 100) * $v['marketprice']);
continue;
} else {
$options[$k]['seecommission'] = $value[0];
continue;
}
}
}
}
}
}
}
}elseif($goods['hasoption'] ==1&&$goods['hascommission'] == 0 && $goods['nocommission'] ==0){
foreach($options as $ke=>$vl){
if ($clevel!='false' && $clevel) {
$options[$ke]['seecommission'] = $set['level'] >= 1 ? round($clevel['commission1'] * $vl['marketprice'] / 100, 2) : 0;
} else {
$options[$ke]['seecommission'] = $set['level'] >= 1 ? round($set['commission1'] * $vl['marketprice'] / 100, 2) : 0;
}
}
}else{
if ($clevel!='false' && $clevel) {
$seecommission = $set['level'] >= 1 ? round($clevel['commission1'] * $goods['marketprice'] / 100, 2) : 0;
} else {
$seecommission = $set['level'] >= 1 ? round($set['commission1'] * $goods['marketprice'] / 100, 2) : 0;
}
}
}
}
if($goods['ispresell']>0 && ($goods['preselltimeend'] == 0 || $goods['preselltimeend'] > time())){
$presell = pdo_fetch("select min(presellprice) as minprice,max(presellprice) as maxprice from ".tablename('ewei_shop_goods_option')." where goodsid = ".$id);
$minprice = $presell['minprice'];
$maxprice = $presell['maxprice'];
}
$goods['minprice'] = number_format( $minprice,2); $goods['maxprice'] =number_format( $maxprice,2);
$diyformhtml = "";
if ($action == 'cremind') {
$cremind_plugin = p('cremind');
$cremind_data = m('common')->getPluginset('cremind');
if ($cremind_plugin && $cremind_data['remindopen']) {
$cremind = true;
}
ob_start();
include $this->template('cremind/formfields');
$cremindformhtml = ob_get_contents();
ob_clean();
} else {
//自定义表单
$diyform_plugin = p('diyform');
if($diyform_plugin){
$fields = false;
if($goods['diyformtype'] == 1){
//模板
if(!empty($goods['diyformid'])){
$diyformid = $goods['diyformid'];
$formInfo = $diyform_plugin->getDiyformInfo($diyformid);
$fields = $formInfo['fields'];
}
} else if($goods['diyformtype'] == 2){
//自定义
$diyformid = 0;
$fields = iunserializer($goods['diyfields']);
if(empty($fields)){
$fields = false;
}
}
if(!empty($fields)){
ob_start();
$inPicker = true;
$openid = $_W['openid'];
$member = m('member')->getMember($openid, true);
$f_data = $diyform_plugin->getLastData(3, 0, $diyformid, $id, $fields, $member);
$flag = 0;
if (!empty($f_data)) {
foreach ($f_data as $k => $v) {
if (!empty($v)) {
$flag = 1;
break;
}
}
}
if (empty($flag)) {
$f_data = $diyform_plugin->getLastCartData($id);
}
$area_set = m('util')->get_area_config_set();
$new_area = intval($area_set['new_area']);
$address_street = intval($area_set['address_street']);
include $this->template('diyform/formfields');
$diyformhtml = ob_get_contents();
ob_clean();
}
}
}
if (!empty($specs))
{
foreach ($specs as $key => $value)
{
foreach ($specs[$key]['items'] as $k=>&$v)
{
$v['thumb'] = tomedia($v['thumb']);
}
}
}
//是否可以加入购物车
$goods['canAddCart'] = true;
if ($goods['isverify'] == 2 || $goods['type'] == 2 || $goods['type'] == 3 || $goods['type'] == 20) {
$goods['canAddCart'] = false;
}
if(!empty($seckillinfo)){
$goods['canAddCart'] = false;
}
if (p('task')){
$task_id = intval($_SESSION[$id . '_task_id']);
if (!empty($task_id)){
$rewarded = pdo_fetchcolumn("SELECT `rewarded` FROM ".tablename('ewei_shop_task_extension_join')." WHERE id = :id AND uniacid = :uniacid",array(':id'=>$task_id,':uniacid'=>$_W['uniacid']));
$taskGoodsInfo = unserialize($rewarded);
$taskGoodsInfo = $taskGoodsInfo['goods'][$id];
if (empty($taskGoodsInfo['option'])){
$goods['marketprice'] = $taskGoodsInfo['price'];
}else{//有规格
foreach($options as $gk =>$gv){
if ($options[$gk]['id'] == $taskGoodsInfo){
$options[$gk]['marketprice'] = $taskGoodsInfo['price'];
}
}
}
}
}
//赠品
$sale_plugin = com('sale');
$giftid = 0;
$goods['cangift'] = false;
$gifttitle = '';
if($sale_plugin){
$giftinfo = array();
$isgift = 0;
$gifts = array();
$giftgoods = array();
$gifts = pdo_fetchall("select id,goodsid,giftgoodsid,thumb,title from ".tablename('ewei_shop_gift')." where uniacid = ".$_W['uniacid']." and activity = 2 and status = 1 and starttime <= ".time()." and endtime >= ".time()." ");
foreach($gifts as $key => &$value){
$gid = explode(",",$value['goodsid']);
foreach ($gid as $ke => $val){
if($val==$id){
$giftgoods = explode(",",$value['giftgoodsid']);
foreach($giftgoods as $k => $val){
$giftdata = pdo_fetch("select id,title,thumb,marketprice,total from ".tablename('ewei_shop_goods')." where uniacid = ".$_W['uniacid']." and deleted = 0 and total > 0 and status = 2 and id = ".$val." ");
if(!empty($giftdata)){
$isgift = 1;
$gifts[$key]['gift'][$k] = $giftdata;
$gifts[$key]['gift'][$k]['thumb'] = tomedia( $gifts[$key]['gift'][$k]['thumb']);
$gifttitle = !empty($value['gift'][$k]['title']) ? $value['gift'][$k]['title'] : '赠品';
}
}
}
}
if(empty($value['gift'])){
unset($gifts[$key]);
}
}
if($isgift){
if($_GPC['cangift']){
$goods['cangift'] = true;
}
$gifts = array_values($gifts);
$giftid = $gifts[0]['id'];
$giftinfo = $gifts;
}
}
$goods['giftid'] = $giftid;
$goods['giftinfo'] = $giftinfo;
$goods['gifttitle'] = $gifttitle;
$goods['gifttotal'] = count($goods['giftinfo']);
show_json(1, array(
'goods' => $goods,
'seckillinfo'=>$seckillinfo,
'specs' => $specs,
'options' => $options,
'diyformhtml'=>$diyformhtml,
'cremind'=>$cremind,
'cremindformhtml'=>$cremindformhtml
));
}
//获取分销商等级
function getcLevel($openid)
{
global $_W;
$level = 'false';
if (empty($openid)) {
return $level;
}
$member = m('member')->getMember($openid);
if (empty($member['isagent']) || $member['status']==0 || $member['agentblack'] ==1) {
return $level;
}
$level = pdo_fetch('select * from ' . tablename('ewei_shop_commission_level') . ' where uniacid=:uniacid and id=:id limit 1', array(':uniacid' => $_W['uniacid'], ':id' => $member['agentlevel']));
return $level;
}
function getSet()
{
$set = m('common')->getPluginset('commission');
$set['texts'] = array(
'agent' => empty($set['texts']['agent']) ? '分销商' : $set['texts']['agent'],
'shop' => empty($set['texts']['shop']) ? '小店' : $set['texts']['shop'],
'myshop' => empty($set['texts']['myshop']) ? '我的小店' : $set['texts']['myshop'],
'center' => empty($set['texts']['center']) ? '分销中心' : $set['texts']['center'],
'become' => empty($set['texts']['become']) ? '成为分销商' : $set['texts']['become'],
'withdraw' => empty($set['texts']['withdraw']) ? '提现' : $set['texts']['withdraw'],
'commission' => empty($set['texts']['commission']) ? '佣金' : $set['texts']['commission'],
'commission1' => empty($set['texts']['commission1']) ? '分销佣金' : $set['texts']['commission1'],
'commission_total' => empty($set['texts']['commission_total']) ? '累计佣金' : $set['texts']['commission_total'],
'commission_ok' => empty($set['texts']['commission_ok']) ? '可提现佣金' : $set['texts']['commission_ok'],
'commission_apply' => empty($set['texts']['commission_apply']) ? '已申请佣金' : $set['texts']['commission_apply'],
'commission_check' => empty($set['texts']['commission_check']) ? '待打款佣金' : $set['texts']['commission_check'],
'commission_lock' => empty($set['texts']['commission_lock']) ? '未结算佣金' : $set['texts']['commission_lock'],
'commission_detail' => empty($set['texts']['commission_detail']) ? '提现明细' : ($set['texts']['commission_detail'] == '佣金明细' ? '提现明细' : $set['texts']['commission_detail']),
'commission_pay' => empty($set['texts']['commission_pay']) ? '成功提现佣金' : $set['texts']['commission_pay'],
'commission_wait' => empty($set['texts']['commission_wait']) ? '待收货佣金' : $set['texts']['commission_wait'],
'commission_fail' => empty($set['texts']['commission_fail']) ? '无效佣金' : $set['texts']['commission_fail'],
'commission_charge' => empty($set['texts']['commission_charge']) ? '扣除提现手续费' : $set['texts']['commission_charge'],
'order' => empty($set['texts']['order']) ? '分销订单' : $set['texts']['order'],
'c1' => empty($set['texts']['c1']) ? '一级' : $set['texts']['c1'],
'c2' => empty($set['texts']['c2']) ? '二级' : $set['texts']['c2'],
'c3' => empty($set['texts']['c3']) ? '三级' : $set['texts']['c3'],
'mydown' => empty($set['texts']['mydown']) ? '我的下线' : $set['texts']['mydown'],
'down' => empty($set['texts']['down']) ? '下线' : $set['texts']['down'],
'up' => empty($set['texts']['up']) ? '推荐人' : $set['texts']['up'],
'yuan' => empty($set['texts']['yuan']) ? '元' : $set['texts']['yuan'],
'icode' => empty($set['texts']['icode']) ? '邀请码' : $set['texts']['icode']
);
return $set;
}
}

View File

@@ -1,45 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Recent_EweiShopV2Page extends MobilePage {
function main() {
global $_W, $_GPC;
$uniacid = $_W['uniacid'];
$id = intval($_GPC['id']);
$sql = "select distinct og.openid from "
.tablename('ewei_shop_order_goods')
." as og left join "
.tablename('ewei_shop_order')
." as o on og.orderid=o.id "
." where og.uniacid={$uniacid} and og.goodsid={$id} and o.status>0 order by og.id desc limit 8";
$count_sql = "select count(distinct og.openid) as count from "
.tablename('ewei_shop_order_goods')
." as og left join "
.tablename('ewei_shop_order')
." as o on og.orderid=o.id "
." where og.uniacid={$uniacid} and og.goodsid={$id} and o.status>0";
$openids = pdo_fetchall($sql);
$count = pdo_fetch($count_sql);
$ret = array();
foreach($openids as $key => $value){
$temp = m('member')->getMember($value['openid']);
$ret[] = array('headimg'=>$temp['avatar_wechat']);
}
echo json_encode(array(
'status' => 1,
'msg' => $ret,
'count' => $count['count'],
));
}
}

View File

@@ -1,124 +0,0 @@
<?php
if (!(defined('IN_IA')))
{
exit('Access Denied');
}
class Wholesalepicker_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$action = trim($_GPC['action']);
$cremind = false;
$goods = pdo_fetch('select id,thumb,title,marketprice,total,maxbuy,minbuy,unit,hasoption,showtotal,diyformid,diyformtype,diyfields,isdiscount,presellprice,' . "\n" . ' isdiscount_time,isdiscount_discounts, needfollow, followtip, followurl, `type`,intervalfloor,intervalprice, isverify, maxprice, minprice, merchsale,ispresell,preselltimeend,unite_total,threen' . "\n" . ' from ' . tablename('ewei_shop_goods') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($goods))
{
show_json(0);
}
$intervalprice = iunserializer($goods['intervalprice']);
$goods['minprice'] = 0;
$goods['maxprice'] = 0;
if (0 < $goods['intervalfloor'])
{
$goods['intervalprice1'] = $intervalprice[0]['intervalprice'];
$goods['intervalnum1'] = $intervalprice[0]['intervalnum'];
$goods['maxprice'] = $intervalprice[0]['intervalprice'];
}
if (1 < $goods['intervalfloor'])
{
$goods['intervalprice2'] = $intervalprice[1]['intervalprice'];
$goods['intervalnum2'] = $intervalprice[1]['intervalnum'];
$goods['minprice'] = $intervalprice[1]['intervalprice'];
}
if (2 < $goods['intervalfloor'])
{
$goods['intervalprice3'] = $intervalprice[2]['intervalprice'];
$goods['intervalnum3'] = $intervalprice[2]['intervalnum'];
$goods['minprice'] = $intervalprice[2]['intervalprice'];
}
$goods['thistime'] = time();
$goods = set_medias($goods, 'thumb');
$openid = $_W['openid'];
if (is_weixin())
{
$follow = m('user')->followed($openid);
if (!(empty($goods['needfollow'])) && !($follow))
{
$followtip = ((empty($goods['followtip']) ? '如果您想要购买此商品,需要您关注我们的公众号,点击【确定】关注后再来购买吧~' : $goods['followtip']));
$followurl = ((empty($goods['followurl']) ? $_W['shopset']['share']['followurl'] : $goods['followurl']));
show_json(2, array('followtip' => $followtip, 'followurl' => $followurl));
}
}
$member = m('member')->getMember($_W['openid']);
if (empty($openid))
{
show_json(4);
}
if (!(empty($_W['shopset']['wap']['open'])) && !(empty($_W['shopset']['wap']['mustbind'])) && empty($member['mobileverify']))
{
show_json(3);
}
$specs = false;
$options = false;
if (!(empty($goods)) && $goods['hasoption'])
{
$specs1 = pdo_fetch('select * from ' . tablename('ewei_shop_goods_spec') . ' where goodsid=:goodsid and uniacid=:uniacid order by displayorder asc limit 1', array(':goodsid' => $id, ':uniacid' => $_W['uniacid']));
if (!(empty($specs1)))
{
$hasoption = 1;
$spec1items = pdo_fetchall('select * from ' . tablename('ewei_shop_goods_spec_item') . ' where specid=:specid and `show`=1 order by displayorder asc', array(':specid' => $specs1['id']));
if (!(empty($spec1items)))
{
foreach ($spec1items as &$v )
{
$v['thumb'] = tomedia($v['thumb']);
}
unset($v);
}
}
$specs2 = pdo_fetch('select * from ' . tablename('ewei_shop_goods_spec') . ' where goodsid=:goodsid and uniacid=:uniacid order by displayorder asc limit 1,1', array(':goodsid' => $id, ':uniacid' => $_W['uniacid']));
if (!(empty($specs2)))
{
$hasoption = 2;
$spec2items = pdo_fetchall('select * from ' . tablename('ewei_shop_goods_spec_item') . ' where specid=:specid and `show`=1 order by displayorder asc', array(':specid' => $specs2['id']));
if (!(empty($spec2items)))
{
foreach ($spec2items as &$v )
{
$v['thumb'] = tomedia($v['thumb']);
}
unset($v);
}
}
$optionlist = pdo_fetchall('select * from ' . tablename('ewei_shop_goods_option') . ' where goodsid=:goodsid and uniacid=:uniacid order by displayorder asc', array(':goodsid' => $id, ':uniacid' => $_W['uniacid']));
$options = array();
foreach ($optionlist as $option )
{
$key = $option['specs'];
if (strstr($key, '_'))
{
$keys = explode('_', $key);
sort($keys);
$key = implode('_', $keys);
}
$options[$key] = $option;
}
}
else
{
$hasoption = 0;
}
if (!(empty($options)) && !(empty($goods['unite_total'])))
{
foreach ($options as &$option )
{
$option['stock'] = $goods['total'];
}
}
$goods['canAddCart'] = true;
show_json(1, array('goods' => $goods, 'spec1items' => $spec1items, 'spec2items' => $spec2items, 'options' => $options, 'hasoption' => $hasoption));
}
}
?>

View File

@@ -1,181 +0,0 @@
<?php
/**
* 微信支付服务器端下单
* 使用示例
* 构造方法参数
* 'appid' => //填写微信分配的公众账号ID
* 'mch_id' => //填写微信支付分配的商户号
* 'notify_url'=> //填写微信支付结果回调地址
* 'key' => //填写微信商户支付密钥
* );
* 统一下单方法
* $WechatAppPay = new wechatAppPay($options);
* $params['body'] = '商品描述'; //商品描述
* $params['out_trade_no'] = '1217752501201407'; //自定义的订单号,不能重复
* $params['total_fee'] = '100'; //订单金额 只能为整数 单位为分
* $params['trade_type'] = 'APP'; //交易类型 JSAPI | NATIVE |APP | WAP
* $wechatAppPay->unifiedOrder( $params );
*/
class WxH5Pay
{
protected $mchid;
protected $appid;
protected $apiKey;
protected $totalFee;
protected $outTradeNo;
protected $orderName;
protected $notifyUrl;
protected $returnUrl;
protected $wapUrl;
protected $wapName;
public function __construct($mchid, $appid, $key)
{
$this->mchid = $mchid;
$this->appid = $appid;
$this->apiKey = $key;
}
public function setTotalFee($totalFee)
{
$this->totalFee = $totalFee;
}
public function setOutTradeNo($outTradeNo)
{
$this->outTradeNo = $outTradeNo;
}
public function setOrderName($orderName)
{
$this->orderName = $orderName;
}
public function setWapUrl($wapUrl)
{
$this->wapUrl = $wapUrl;
}
public function setWapName($wapName)
{
$this->wapName = $wapName;
}
public function setNotifyUrl($notifyUrl)
{
$this->notifyUrl = $notifyUrl;
}
public function setReturnUrl($returnUrl)
{
$this->returnUrl = $returnUrl;
}
/**
* 发起订单
* @return array
*/
public function createJsBizPackage()
{
$config = array(
'mch_id' => $this->mchid,
'appid' => $this->appid,
'key' => $this->apiKey,
);
$scene_info = array(
'h5_info' =>array(
'type'=>'Wap',
'wap_url'=>$this->wapUrl,
'wap_name'=>$this->wapName,
)
);
$unified = array(
'appid' => $config['appid'],
'attach' => 'pay', //商家数据包原样返回如果填写中文请注意转换为utf-8
'body' => $this->orderName,
'mch_id' => $config['mch_id'],
'nonce_str' => self::createNonceStr(),
'notify_url' => $this->notifyUrl,
'out_trade_no' => $this->outTradeNo,
'spbill_create_ip' => $_SERVER['REMOTE_ADDR'],
'total_fee' => intval($this->totalFee * 100), //单位 转为分
'trade_type' => 'MWEB',
'scene_info'=>json_encode($scene_info)
);
$unified['sign'] = self::getSign($unified, $config['key']);
$responseXml = self::curlPost('https://api.mch.weixin.qq.com/pay/unifiedorder', self::arrayToXml($unified));
$unifiedOrder = simplexml_load_string($responseXml, 'SimpleXMLElement', LIBXML_NOCDATA);
if ($unifiedOrder->return_code != 'SUCCESS') {
die($unifiedOrder->return_msg);
}
if($unifiedOrder->mweb_url){
return $unifiedOrder->mweb_url.'&redirect_url='.urlencode($this->returnUrl);
}
exit('error');
}
public static function curlPost($url = '', $postData = '', $options = array())
{
if (is_array($postData)) {
$postData = http_build_query($postData);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //设置cURL允许执行的最长秒数
if (!empty($options)) {
curl_setopt_array($ch, $options);
}
//https请求 不验证证书和host
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
public static function createNonceStr($length = 16)
{
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$str = '';
for ($i = 0; $i < $length; $i++) {
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
return $str;
}
public static function arrayToXml($arr)
{
$xml = "<xml>";
foreach ($arr as $key => $val) {
if (is_numeric($val)) {
$xml .= "<" . $key . ">" . $val . "</" . $key . ">";
} else
$xml .= "<" . $key . "><![CDATA[" . $val . "]]></" . $key . ">";
}
$xml .= "</xml>";
return $xml;
}
/**
* 获取签名
*/
public static function getSign($params, $key)
{
ksort($params, SORT_STRING);
$unSignParaString = self::formatQueryParaMap($params, false);
$signStr = strtoupper(md5($unSignParaString . "&key=" . $key));
return $signStr;
}
protected static function formatQueryParaMap($paraMap, $urlEncode = false)
{
$buff = "";
ksort($paraMap);
foreach ($paraMap as $k => $v) {
if (null != $v) {
if ($urlEncode) {
$v = urlencode($v);
}
$buff .= $k . "=" . $v . "&";
}
}
$reqPar = '';
if (strlen($buff) > 0) {
$reqPar = substr($buff, 0, strlen($buff) - 1);
}
return $reqPar;
}
}

View File

@@ -1,82 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobilePage
{
public function main()
{
require_once 'WxH5Pay.php';
/** 请填写以下配置信息 */
$mchid = '1519916881'; //微信支付商户号 PartnerID 通过微信支付商户资料审核后邮件发送
$appid = 'wx550f32f595f73648'; //微信支付申请对应的公众号的APPID
$appKey = '5be3e742595667db63d862e6ccea28fb'; //微信支付申请对应的公众号的APP Key
$apiKey = 'QWERTYUIOPasdfghjklZXCVBNM123456'; //https://pay.weixin.qq.com 帐户设置-安全设置-API安全-API密钥-设置API密钥
$outTradeNo = uniqid(); //你自己的商品订单号
$payAmount = 0.01; //付款金额,单位:元
$orderName = '支付测试'; //订单标题
$notifyUrl = 'https://xcx10.5g-quickapp.com/app/index.php?i=1102&c=entry&m=ewei_shopv2&do=mobile&r=hwwxpay1'; //付款成功后的回调地址(不要有问号)
$returnUrl = 'https://xcx10.5g-quickapp.com'; //付款成功后,页面跳转的地址
$wapUrl = 'xcx10.5g-quickapp.com'; //WAP网站URL地址
$wapName = 'H5支付'; //WAP 网站名
/** 配置结束 */
$wxPay = new WxH5Pay($mchid,$appid,$apiKey);
$wxPay->setTotalFee($payAmount);
$wxPay->setOutTradeNo($outTradeNo);
$wxPay->setOrderName($orderName);
$wxPay->setNotifyUrl($notifyUrl);
$wxPay->setReturnUrl($returnUrl);
$wxPay->setWapUrl($wapUrl);
$wxPay->setWapName($wapName);
$prepayid = '';
$mwebUrl= $wxPay->createJsBizPackage($payAmount,$outTradeNo,$orderName,$notifyUrl);
if($mwebUrl){
$item = explode('?',$mwebUrl);
$item = explode('=',$item[1]);
$item = explode('&',$item[1]);
$prepayid = $item[0];
}
dump($item);
echo "<h1><a href='{$mwebUrl}'>点击跳转至支付页面</a></h1>";
exit();
/* $_POST['title'] = ' 1 积分';
$_POST['money'] = '1';
$appid = 'wx6327c615d1061c61';
$mch_id = '1519916881';
$key = 'QWERTYUIOPasdfghjklZXCVBNM123456';
$notify_url = 'https://xcx10.5g-quickapp.com/app/index.php?i=1102&c=entry&m=ewei_shopv2&do=mobile&r=hwwxpay1';
$wechatAppPay = new WxH5Pay($appid, $mch_id, $notify_url, $key);
$params['body'] = '购买' . $_POST['title']; // $params['body'] = '微信H5支付测试';
$params['out_trade_no'] = date('Ymd') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8); // 订单号
$params['total_fee'] = $_POST['money']; // 订单金额 只能为整数 单位为分
$params['trade_type'] = 'MWEB'; // 交易类型 MWEB
$host = "https://xcx8.5g-quickapp.com/"; // 来源地址
$name = '牙膏'; // $name = '微信支付测试订单';
$params['scene_info'] = '{"h5_info": {"type":"Wap","wap_url": ' . $host . ',"wap_name":"' . $name . '"}}';
$result = $wechatAppPay->unifiedOrder($params);
if (isset($result['err_msg'])) {
return false; // 错误返回信息,看需求定义返回!
}
$url = $result['mweb_url'] . '&redirect_url=' . urlencode($notify_url); // 可以在MWEB_URL后拼接上 redirect_url 参数,来指定回调页面
// dump($url);
// 跳转此链接拉起微信支付
header("location:" . $url); // 拉起微信支付链接(并且附上$return_url)
/*global $_W;
global $_GPC;
include $this->template();*/
}
}
?>

View File

@@ -1,278 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobilePage
{
public function success(){
// file_put_contents(__DIR__ . '/debug.txt', var_export($_REQUEST,true).PHP_EOL,FILE_APPEND);
// echo 99;
// include $this->template('order/pay/success');
$this->message('支付完成', mobileUrl(''), 'success');
}
public function main()
{
global $_W;
global $_GPC;
$_SESSION['newstoreid'] = 0;
$this->diypage('home');
$trade = m('common')->getSysset('trade');
if (empty($trade['shop_strengthen'])) {
$order = pdo_fetch('select id,price,`virtual`,createtime from ' . tablename('ewei_shop_order') . ' where uniacid=:uniacid and status = 0 and paytype<>3 and openid=:openid order by createtime desc limit 1', array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']));
if (!empty($order)) {
$close_time = 0;
$mintimes = 0;
if (!empty($order['virtual'])) {
if (isset($trade['closeorder_virtual']) && !empty($trade['closeorder_virtual'])) {
$mintimes = 60 * intval($trade['closeorder_virtual']);
}
else {
$mintimes = 60 * 15;
}
}
else {
$days = intval($trade['closeorder']);
if (0 < $days) {
$mintimes = 86400 * $days;
}
}
if (!empty($mintimes)) {
$close_time = intval($order['createtime']) + $mintimes;
}
$goods = pdo_fetchall('select g.*,og.total as totals from ' . tablename('ewei_shop_order_goods') . ' og inner join ' . tablename('ewei_shop_goods') . ' g on og.goodsid = g.id where og.uniacid=:uniacid and og.orderid=:orderid limit 3', array(':uniacid' => $_W['uniacid'], ':orderid' => $order['id']));
$goodstotal = pdo_fetchcolumn('select COUNT(*) from ' . tablename('ewei_shop_order_goods') . ' og inner join ' . tablename('ewei_shop_goods') . ' g on og.goodsid = g.id where og.uniacid=:uniacid and og.orderid=:orderid ', array(':uniacid' => $_W['uniacid'], ':orderid' => $order['id']));
}
}
$mid = intval($_GPC['mid']);
$index_cache = $this->getpage();
if (!empty($mid)) {
$index_cache = preg_replace_callback('/href=[\\\'"]?([^\\\'" ]+).*?[\\\'"]/', function($matches) use($mid) {
$preg = $matches[1];
if (strexists($preg, 'mid=')) {
return 'href=\'' . $preg . '\'';
}
if (!strexists($preg, 'javascript')) {
$preg = preg_replace('/(&|\\?)mid=[\\d+]/', '', $preg);
if (strexists($preg, '?')) {
$newpreg = $preg . ('&mid=' . $mid);
}
else {
$newpreg = $preg . ('?mid=' . $mid);
}
return 'href=\'' . $newpreg . '\'';
}
}, $index_cache);
}
$shop_data = m('common')->getSysset('shop');
if (com('coupon')) {
$cpinfos = com('coupon')->getInfo();
}
include $this->template();
}
public function get_recommand()
{
global $_W;
global $_GPC;
$args = array('page' => $_GPC['page'], 'pagesize' => 6, 'isrecommand' => 1, 'order' => 'displayorder desc,createtime desc', 'by' => '');
$recommand = m('goods')->getList($args);
show_json(1, array('list' => $recommand['list'], 'pagesize' => $args['pagesize'], 'total' => $recommand['total'], 'page' => intval($_GPC['page'])));
}
private function getcache()
{
global $_W;
global $_GPC;
return m('common')->createStaticFile(mobileUrl('getpage', NULL, true));
}
public function getpage()
{
global $_W;
global $_GPC;
$uniacid = $_W['uniacid'];
$defaults = array(
'adv' => array('text' => '幻灯片', 'visible' => 1),
'search' => array('text' => '搜索栏', 'visible' => 1),
'nav' => array('text' => '导航栏', 'visible' => 1),
'notice' => array('text' => '公告栏', 'visible' => 1),
'cube' => array('text' => '魔方栏', 'visible' => 1),
'banner' => array('text' => '广告栏', 'visible' => 1),
'goods' => array('text' => '推荐栏', 'visible' => 1)
);
$sorts = isset($_W['shopset']['shop']['indexsort']) ? $_W['shopset']['shop']['indexsort'] : $defaults;
$sorts['recommand'] = array('text' => '系统推荐', 'visible' => 1);
$advs = pdo_fetchall('select id,advname,link,thumb from ' . tablename('ewei_shop_adv') . ' where uniacid=:uniacid and iswxapp=0 and enabled=1 order by displayorder desc', array(':uniacid' => $uniacid));
$navs = pdo_fetchall('select id,navname,url,icon from ' . tablename('ewei_shop_nav') . ' where uniacid=:uniacid and iswxapp=0 and status=1 order by displayorder desc', array(':uniacid' => $uniacid));
$cubes = is_array($_W['shopset']['shop']['cubes']) ? $_W['shopset']['shop']['cubes'] : array();
$banners = pdo_fetchall('select id,bannername,link,thumb from ' . tablename('ewei_shop_banner') . ' where uniacid=:uniacid and iswxapp=0 and enabled=1 order by displayorder desc', array(':uniacid' => $uniacid));
$bannerswipe = $_W['shopset']['shop']['bannerswipe'];
if (!empty($_W['shopset']['shop']['indexrecommands'])) {
$goodids = implode(',', $_W['shopset']['shop']['indexrecommands']);
if (!empty($goodids)) {
$indexrecommands = pdo_fetchall('select * from ' . tablename('ewei_shop_goods') . (' where id in( ' . $goodids . ' ) and uniacid=:uniacid and deleted = 0 and status=1 order by instr(\'' . $goodids . '\',id),displayorder desc'), array(':uniacid' => $uniacid));
$level = $this->getLevel($_W['openid']);
$set = $this->getSet();
foreach ($indexrecommands as $key => $value) {
if (0 < $value['ispresell']) {
$indexrecommands[$key]['minprice'] = $value['presellprice'];
}
$indexrecommands[$key]['seecommission'] = $this->getCommission($value, $level, $set);
if (0 < $indexrecommands[$key]['seecommission']) {
$indexrecommands[$key]['seecommission'] = round($indexrecommands[$key]['seecommission'], 2);
}
$indexrecommands[$key]['cansee'] = $set['cansee'];
$indexrecommands[$key]['seetitle'] = $set['seetitle'];
}
}
}
$goodsstyle = $_W['shopset']['shop']['goodsstyle'];
$notices = pdo_fetchall('select id, title, link, thumb from ' . tablename('ewei_shop_notice') . ' where uniacid=:uniacid and iswxapp=0 and status=1 order by displayorder desc limit 5', array(':uniacid' => $uniacid));
$seckillinfo = plugin_run('seckill::getTaskSeckillInfo');
ob_start();
ob_implicit_flush(false);
require $this->template('index_tpl');
return ob_get_clean();
}
public function seckillinfo()
{
$seckillinfo = plugin_run('seckill::getTaskSeckillInfo');
include $this->template('shop/index/seckill_tpl');
exit();
}
public function qr()
{
global $_W;
global $_GPC;
$url = trim($_GPC['url']);
require IA_ROOT . '/framework/library/qrcode/phpqrcode.php';
QRcode::png($url, false, QR_ECLEVEL_L, 16, 1);
}
public function share_url()
{
global $_W;
global $_GPC;
$url = trim($_GPC['url']);
$account_api = WeAccount::create($_W['acid']);
$jssdkconfig = $account_api->getJssdkConfig($url);
show_json(1, $jssdkconfig);
}
public function getLevel($openid)
{
global $_W;
$level = 'false';
if (empty($openid)) {
return $level;
}
$member = m('member')->getMember($openid);
if (empty($member['isagent']) || $member['status'] == 0 || $member['agentblack'] == 1) {
return $level;
}
$level = pdo_fetch('select * from ' . tablename('ewei_shop_commission_level') . ' where uniacid=:uniacid and id=:id limit 1', array(':uniacid' => $_W['uniacid'], ':id' => $member['agentlevel']));
return $level;
}
public function getSet()
{
$set = m('common')->getPluginset('commission');
$set['texts'] = array('agent' => empty($set['texts']['agent']) ? '分销商' : $set['texts']['agent'], 'shop' => empty($set['texts']['shop']) ? '小店' : $set['texts']['shop'], 'myshop' => empty($set['texts']['myshop']) ? '我的小店' : $set['texts']['myshop'], 'center' => empty($set['texts']['center']) ? '分销中心' : $set['texts']['center'], 'become' => empty($set['texts']['become']) ? '成为分销商' : $set['texts']['become'], 'withdraw' => empty($set['texts']['withdraw']) ? '提现' : $set['texts']['withdraw'], 'commission' => empty($set['texts']['commission']) ? '佣金' : $set['texts']['commission'], 'commission1' => empty($set['texts']['commission1']) ? '分销佣金' : $set['texts']['commission1'], 'commission_total' => empty($set['texts']['commission_total']) ? '累计佣金' : $set['texts']['commission_total'], 'commission_ok' => empty($set['texts']['commission_ok']) ? '可提现佣金' : $set['texts']['commission_ok'], 'commission_apply' => empty($set['texts']['commission_apply']) ? '已申请佣金' : $set['texts']['commission_apply'], 'commission_check' => empty($set['texts']['commission_check']) ? '待打款佣金' : $set['texts']['commission_check'], 'commission_lock' => empty($set['texts']['commission_lock']) ? '未结算佣金' : $set['texts']['commission_lock'], 'commission_detail' => empty($set['texts']['commission_detail']) ? '提现明细' : ($set['texts']['commission_detail'] == '佣金明细' ? '提现明细' : $set['texts']['commission_detail']), 'commission_pay' => empty($set['texts']['commission_pay']) ? '成功提现佣金' : $set['texts']['commission_pay'], 'commission_wait' => empty($set['texts']['commission_wait']) ? '待收货佣金' : $set['texts']['commission_wait'], 'commission_fail' => empty($set['texts']['commission_fail']) ? '无效佣金' : $set['texts']['commission_fail'], 'commission_charge' => empty($set['texts']['commission_charge']) ? '扣除提现手续费' : $set['texts']['commission_charge'], 'order' => empty($set['texts']['order']) ? '分销订单' : $set['texts']['order'], 'c1' => empty($set['texts']['c1']) ? '一级' : $set['texts']['c1'], 'c2' => empty($set['texts']['c2']) ? '二级' : $set['texts']['c2'], 'c3' => empty($set['texts']['c3']) ? '三级' : $set['texts']['c3'], 'mydown' => empty($set['texts']['mydown']) ? '我的下线' : $set['texts']['mydown'], 'down' => empty($set['texts']['down']) ? '下线' : $set['texts']['down'], 'up' => empty($set['texts']['up']) ? '推荐人' : $set['texts']['up'], 'yuan' => empty($set['texts']['yuan']) ? '元' : $set['texts']['yuan'], 'icode' => empty($set['texts']['icode']) ? '邀请码' : $set['texts']['icode']);
return $set;
}
/**
* 计算出此商品的佣金
* @param type $goodsid
* @return type
*/
public function getCommission($goods, $level, $set)
{
global $_W;
$commission = 0;
if ($level == 'false') {
return $commission;
}
if ($goods['hascommission'] == 1) {
$price = $goods['maxprice'];
$levelid = 'default';
if ($level) {
$levelid = 'level' . $level['id'];
}
$goods_commission = !empty($goods['commission']) ? json_decode($goods['commission'], true) : array();
if ($goods_commission['type'] == 0) {
$commission = 1 <= $set['level'] ? (0 < $goods['commission1_rate'] ? $goods['commission1_rate'] * $goods['marketprice'] / 100 : $goods['commission1_pay']) : 0;
}
else {
$price_all = array();
foreach ($goods_commission[$levelid] as $key => $value) {
foreach ($value as $k => $v) {
if (strexists($v, '%')) {
array_push($price_all, floatval(str_replace('%', '', $v) / 100) * $price);
continue;
}
array_push($price_all, $v);
}
}
$commission = max($price_all);
}
}
else {
if ($level != 'false' && !empty($level)) {
if ($goods['marketprice'] <= 0) {
$goods['marketprice'] = $goods['maxprice'];
}
$commission = 1 <= $set['level'] ? round($level['commission1'] * $goods['marketprice'] / 100, 2) : 0;
}
else {
if ($goods['marketprice'] <= 0) {
$goods['marketprice'] = $goods['maxprice'];
}
$commission = 1 <= $set['level'] ? round($set['commission1'] * $goods['marketprice'] / 100, 2) : 0;
}
}
return $commission;
}
}
?>

View File

@@ -1,296 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Activation_EweiShopV2Page extends MobileLoginPage
{
function main()
{
global $_W, $_GPC;
$iserror = false;
$card_id = $_GPC['card_id'];
$encrypt_code = $_GPC['encrypt_code'];
if (empty($card_id) || empty($encrypt_code)) {
$iserror = true;
}
$encrypt_code = htmlspecialchars_decode($encrypt_code, ENT_QUOTES);
$result = com_run('wxcard::wxCardCodeDecrypt', $encrypt_code);
if (empty($result) || is_wxerror($result)) {
$iserror = true;
}
$code = $result['code'];
if (empty($_W['openid'])) {
$iserror = true;
}
$item = pdo_fetch("select * from " . tablename("ewei_shop_member") . " where uniacid=:uniacid and openid =:openid limit 1 ", array(":uniacid" => $_W['uniacid'], ":openid" => $_W['openid']));
if ($iserror) {
$this->message(array("message" => "激活链接错误!", "title" => "激活链接错误!", "buttondisplay" => true), mobileUrl('member'), 'error');
}
$arr = array(
'membercardid' => $card_id,
'membercardcode' => $code,
'membershipnumber' => $code,
'membercardactive' => 0
);
$CardActivation = m('common')->getSysset('memberCardActivation');
pdo_update('ewei_shop_member', $arr, array('openid' => $_W['openid'], 'uniacid' => $_W['uniacid']));
if (empty($CardActivation['openactive'])) {
$result = com_run('wxcard::ActivateMembercardbyopenid', $_W['openid']);
if (empty($result) || is_wxerror($result)) {
$this->message(array("message" => "会员卡激活失败!", "title" => "激活链接错误!", "buttondisplay" => true), mobileUrl('member'), 'error');
} else {
if (empty($item['membercardactive'])) {
pdo_update('ewei_shop_member', array('membercardactive' => 1), array('openid' => $_W['openid'], 'uniacid' => $_W['uniacid']));
$this->sendGift($_W['openid']);
$this->message(array("message" => "您的会员卡已成功激活!", "title" => "激活成功!", "buttondisplay" => true), mobileUrl('member'), 'success');
} else {
header('location: ' . mobileUrl('member'));
}
}
}
if (empty($CardActivation)) {
$needrealname = 0;
$needmobile = 0;
$needsmscode = 0;
$needsbirthday = 0;
$needsidnumber = 0;
} else {
$needrealname = intval($CardActivation['realname']);
$needmobile = intval($CardActivation['mobile']);
$needsmscode = intval($CardActivation['sms_active']);
$needsbirthday = intval($CardActivation['birthday']);
$needsidnumber = intval($CardActivation['idnumber']);
}
include $this->template();
}
public function submit()
{
global $_W, $_GPC;
$iserror = false;
$card_id = $_GPC['card_id'];
$open_redis = function_exists('redis') && !is_error(redis());
$ret = pdo_get('ewei_shop_member', array(
'uniacid' => $_W['uniacid'],
'openid' => $_W['openid']
));
if (!empty($ret['membercardactive'])) {
show_json(0, '您已经领取过会员卡了~');
}
if ($open_redis) {
$redis_key = "{$_W['uniacid']}_member_card__active_{$_W['openid']}";
$redis = redis();
if (!is_error($redis)) {
if ($redis->get($redis_key)) {
show_json(0, '请勿重复点击');
}
$redis->setex($redis_key, 1, time());
}
}
$encrypt_code = $_GPC['encrypt_code'];
if (empty($card_id) || empty($encrypt_code)) {
show_json(0, "激活链接错误!");
}
$encrypt_code = htmlspecialchars_decode($encrypt_code, ENT_QUOTES);
$result = com_run('wxcard::wxCardCodeDecrypt', $encrypt_code);
if (empty($result) || is_wxerror($result)) {
show_json(0, "激活链接错误!");
}
$code = $result['code'];
if (empty($_W['openid'])) {
show_json(0, "激活链接错误!");
}
$item = pdo_fetch("select * from " . tablename("ewei_shop_member") . " where uniacid=:uniacid and openid =:openid limit 1 ", array(":uniacid" => $_W['uniacid'], ":openid" => $_W['openid']));
$arr = array(
'membercardid' => $card_id,
'membercardcode' => $code,
'membershipnumber' => $code,
'membercardactive' => 0
);
$CardActivation = m('common')->getSysset('memberCardActivation');
if (!empty($CardActivation['openactive'])) {
if (!empty($CardActivation['sms_active']) && !empty($CardActivation['mobile'])) {
@session_start();
$key = '__ewei_shopv2_member_verifycodesession_' . $_W['uniacid'] . '_' . trim($_GPC['mobile']);
$code = $_SESSION[$key];
if (empty($code)) {
show_json(0, "请获取验证码!");
}
if (trim($_GPC['sms_code']) != $code) {
show_json(0, "验证码错误!");
}
}
if (!empty($CardActivation['realname'])) {
if (empty($_GPC['realname'])) {
show_json(0, "真实姓名不能为空!");
}
$arr['realname'] = trim($_GPC['realname']);
}
if (!empty($CardActivation['mobile'])) {
if (empty($_GPC['mobile'])) {
show_json(0, "电话号码不能为空");
}
$arr['mobile'] = trim($_GPC['mobile']);
}
if (!empty($CardActivation['birthday'])) {
if (empty($_GPC['birthyear'])) {
show_json(0, "出生日期未选择");
}
$arr['birthyear'] = trim($_GPC['birthyear']);
$arr['birthmonth'] = trim($_GPC['birthmonth']);
$arr['birthday'] = trim($_GPC['birthday']);
}
if (!empty($CardActivation['idnumber'])) {
if (empty($_GPC['idnumber'])) {
show_json(0, "身份证号码未填写");
}
$arr['idnumber'] = trim($_GPC['idnumber']);
}
}
pdo_begin();
pdo_update('ewei_shop_member', $arr, array('openid' => $_W['openid'], 'uniacid' => $_W['uniacid']));
$result = com_run('wxcard::ActivateMembercardbyopenid', $_W['openid']);
if (empty($result) || is_wxerror($result)) {
pdo_rollback();
show_json(0, "会员卡激活失败");
} else {
if (empty($item['membercardactive'])) {
$this->sendGift($_W['openid']);
}
pdo_update('ewei_shop_member', array('membercardactive' => 1), array('openid' => $_W['openid'], 'uniacid' => $_W['uniacid']));
pdo_commit();
show_json(1, "您的会员卡已成功激活");
}
}
function sendGift($openid)
{
$CardActivation = m('common')->getSysset('memberCardActivation');
$credit1 = intval($CardActivation['credit1']);
$credit2 = intval($CardActivation['credit2']);
$couponid = intval($CardActivation['couponid']);
$levelid = intval($CardActivation['levelid']);
if (!empty($credit1)) {
m("member")->setCredit($openid, "credit1", $credit1, array(0, '激活会员卡,积分+' . $credit1));
}
if (!empty($credit2)) {
m("member")->setCredit($openid, "credit2", $credit2, array(0, '激活会员卡,余额+' . $credit2));
}
if (!empty($couponid)) {
$member = m('member')->getMember($openid);
if (com('coupon')) {
com("coupon")->poster($member, $couponid, 1, 10);
}
}
if (!empty($levelid)) {
$member = m('member')->upgradeLevelByLevelId($openid, $levelid);
}
}
public function verifycode()
{
global $_W, $_GPC;
@session_start();
$mobile = trim($_GPC['mobile']);
if (empty($mobile)) {
show_json(0, '请输入手机号');
}
if (!empty($_SESSION['verifycodesendtime']) && $_SESSION['verifycodesendtime'] + 60 > time()) {
show_json(0, '请求频繁请稍后重试');
}
$member = pdo_fetch('select id,openid,mobile,pwd,salt from ' . tablename('ewei_shop_member') . ' where mobile=:mobile and openid <>:openid and mobileverify=1 and uniacid=:uniacid limit 1', array(':mobile' => $mobile, ':openid' => $_W['openid'], ':uniacid' => $_W['uniacid']));
if (!empty($member)) {
show_json(0, '该手机号已经被绑定');
}
$CardActivation = m('common')->getSysset('memberCardActivation');
$sms_id = $CardActivation['sms_id'];
if (empty($sms_id)) {
show_json(0, '短信发送失败(NOSMSID)');
}
$key = '__ewei_shopv2_member_verifycodesession_' . $_W['uniacid'] . '_' . $mobile;
$code = random(5, true);
$shopname = $_W['shopset']['shop']['name'];
$ret = array('status' => 0, 'message' => '发送失败');
if (com('sms')) {
$ret = com('sms')->send($mobile, $sms_id, array('验证码' => $code, '商城名称' => !empty($shopname) ? $shopname : "商城名称"));
}
if ($ret['status']) {
$_SESSION[$key] = $code;
$_SESSION['verifycodesendtime'] = time();
show_json(1, "短信发送成功");
}
show_json(0, $ret['message']);
}
public function success()
{
$this->message(array("message" => "您的会员卡已成功激活!", "title" => "激活成功!", "buttondisplay" => true), mobileUrl('member'), 'success');
}
}

View File

@@ -1,342 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Address_EweiShopV2Page extends MobileLoginPage {
function main() {
global $_W, $_GPC, $_S;
$area_set = m('util')->get_area_config_set();
$new_area = intval($area_set['new_area']);
$address_street = intval($area_set['address_street']);
$pindex = intval($_GPC['page']);
$psize = 20;
$condition = ' and openid=:openid and deleted=0 and `uniacid` = :uniacid ';
$params = array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']);
$sql = 'SELECT COUNT(*) FROM ' . tablename('ewei_shop_member_address') . " where 1 $condition";
$total = pdo_fetchcolumn($sql, $params);
$sql = 'SELECT * FROM ' . tablename('ewei_shop_member_address') . ' where 1 ' . $condition . ' ORDER BY `id` DESC';
if ($pindex != 0) {
$sql .= 'LIMIT ' . ($pindex - 1) * $psize . ',' . $psize;
}
$list = pdo_fetchall($sql, $params);
include $this->template();
}
function post() {
global $_W, $_GPC;
$id = intval($_GPC['id']);
$area_set = m('util')->get_area_config_set();
$new_area = intval($area_set['new_area']);
$address_street = intval($area_set['address_street']);
$is_from_wx = $_GPC['is_from_wx'];
if($is_from_wx){
$wx_province = $_GPC['province'];
$wx_city = $_GPC['city'];
$wx_area = $_GPC['area'];
$wx_address = $_GPC['address'];
$wx_name = $_GPC['realname'];
$wx_mobile = $_GPC['mobile'];
$wx_address_info = array(
'province' => $wx_province,
'city' => $wx_city,
'area' => $wx_area,
'address' => $wx_address,
'realname' => $wx_name,
'mobile' => $wx_mobile,
);
}
if(!empty($id) || !empty($wx_address_info)){
if(empty($wx_address_info)){
$address = pdo_fetch('select * from ' . tablename('ewei_shop_member_address') . ' where id=:id and openid=:openid and uniacid=:uniacid limit 1 ', array(':id' => $id, ':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']));
}else{
$address = $wx_address_info;
}
//如果地址code为空的情况
if(empty($address['datavalue'])){
//读取新版地址库获取code
$provinceName=$address['province'];
$citysName=$address['city'];
$countyName=$address['area'];
//地址code
$province_code=0;
$citys_code=0;
$county_code=0;
$path = EWEI_SHOPV2_PATH."static/js/dist/area/AreaNew.xml";
$xml = file_get_contents($path);
$array = xml2array($xml);
$newArr = array();
if(is_array($array['province']))
{
foreach ($array['province'] as $i=>$v)
{
if($i>0)
{
if($v['@attributes']['name']==$provinceName && !is_null($provinceName) && $provinceName!="")
{
$province_code = $v['@attributes']['code'];
if(is_array($v['city']))
{
if(!isset($v['city'][0])){
$v['city'] = array(0=>$v['city']);
}
foreach ($v['city'] as $ii=>$vv)
{
if($vv['@attributes']['name']==$citysName && !is_null($citysName) && $citysName!="")
{
$citys_code= $vv['@attributes']['code'];
if(is_array($vv['county']))
{
if(!isset($vv['county'][0]))
{
$vv['county'] = array(0=>$vv['county']);
}
foreach ($vv['county'] as $iii=>$vvv)
{
if($vvv['@attributes']['name']==$countyName && !is_null($countyName) && $countyName!="")
{
$county_code= $vvv['@attributes']['code'];
}
}
}
}
}
}
}
}
}
}
if($province_code!=0 &&$citys_code!=0&&$county_code!=0){
$address['datavalue']=$province_code." ".$citys_code." ".$county_code;
if(empty($wx_address_info)){
pdo_update('ewei_shop_member_address', $address, array('id' => $id, 'uniacid' => $_W['uniacid'], 'openid' => $_W['openid']));
}
}
}
// $address_street = 1;
// $new_area = 0;
$show_data = 1;
if((!empty($new_area) && empty($address['datavalue'])) || (empty($new_area) && !empty($address['datavalue']))) {
$show_data = 0;
}
}
include $this->template();
}
function setdefault() {
global $_W, $_GPC;
$id = intval($_GPC['id']);
$data = pdo_fetch('select id from ' . tablename('ewei_shop_member_address') . ' where id=:id and deleted=0 and uniacid=:uniacid limit 1', array(
':uniacid' => $_W['uniacid'],
':id' => $id
));
if (empty($data)) {
show_json(0, '地址未找到');
}
pdo_update('ewei_shop_member_address', array('isdefault' => 0), array('uniacid' => $_W['uniacid'], 'openid' => $_W['openid']));
pdo_update('ewei_shop_member_address', array('isdefault' => 1), array('id' => $id, 'uniacid' => $_W['uniacid'], 'openid' => $_W['openid']));
show_json(1);
}
/**
* 删除字符串中的空格,提取手机号码
*
* @author 烟承田 <yanchengtian0536@163.com>
* @date 2018/8/8
* @param $string mobile 含有unicode编码的手机号码
* @return string
*/
private function extractNumber($string)
{
$string = preg_replace('# #', '', $string);
preg_match('/\d{11}/', $string, $result);
return (string)$result[0];
}
function submit() {
global $_W, $_GPC;
$id = intval($_GPC['id']);
$data = $_GPC['addressdata'];
$data['mobile'] = $this->extractNumber($data['mobile']); //去除手机号中的空格
$areas = explode(' ', $data['areas']);
$data['province'] = $areas[0];
$data['city'] = $areas[1];
$data['area'] = $areas[2];
$data['street'] = trim($data['street']);
$data['datavalue'] = trim($data['datavalue']);
$data['streetdatavalue'] = trim($data['streetdatavalue']);
$post = $data;
$post['id'] = $id;
$post['is_from_wx'] = $_GPC['is_from_wx'];
if($this->is_repeated_address($post)){
return show_json(0, '此地址已经添加过');
}
if(empty($data['mobile'])){
return show_json(0, '请填写手机号');
}
$area_set = m('util')->get_area_config_set();
if($area_set['new_area'] && $area_set['address_street'] && empty($data['street'])){
return show_json(0, '请选择所在街道');
}
// 默认地址
$isdefault = intval($data['isdefault']);
unset($data['isdefault']);
unset($data['areas']);
$data['openid'] = $_W['openid'];
$data['uniacid'] = $_W['uniacid'];
if (empty($id)) {
$addresscount = pdo_fetchcolumn('SELECT count(*) FROM ' . tablename('ewei_shop_member_address') . ' where openid=:openid and deleted=0 and `uniacid` = :uniacid ', array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']));
if ($addresscount <= 0) {
$data['isdefault'] = 1;
}
pdo_insert('ewei_shop_member_address', $data);
$id = pdo_insertid();
} else {
//修改地址后置空经纬度-》同城配送
$data['lng']='';
$data['lat']='';
pdo_update('ewei_shop_member_address', $data, array('id' => $id, 'uniacid' => $_W['uniacid'], 'openid' => $_W['openid']));
}
// 更新默认地址
if(!empty($isdefault)){
pdo_update('ewei_shop_member_address', array('isdefault' => 0), array('uniacid' => $_W['uniacid'], 'openid' => $_W['openid']));
pdo_update('ewei_shop_member_address', array('isdefault' => 1), array('id' => $id, 'uniacid' => $_W['uniacid'], 'openid' => $_W['openid']));
}
show_json(1, array('addressid' => $id));
}
function delete() {
global $_W, $_GPC;
$id = intval($_GPC['id']);
$data = pdo_fetch('select id,isdefault from ' . tablename('ewei_shop_member_address') . ' where id=:id and openid=:openid and deleted=0 and uniacid=:uniacid limit 1', array(
':uniacid' => $_W['uniacid'],
':openid' => $_W['openid'],
':id' => $id
));
if (empty($data)) {
show_json(0, '地址未找到');
}
pdo_update('ewei_shop_member_address', array('deleted' => 1), array('id' => $id));
//如果删除默认地址
if ($data['isdefault'] == 1) {
//将最近添加的地址设置成默认的
pdo_update('ewei_shop_member_address', array('isdefault' => 0), array('uniacid' => $_W['uniacid'], 'openid' => $_W['openid'], 'id' => $id));
$data2 = pdo_fetch('select id from ' . tablename('ewei_shop_member_address') . ' where openid=:openid and deleted=0 and uniacid=:uniacid order by id desc limit 1', array(
':uniacid' => $_W['uniacid'],
':openid' => $_W['openid']
));
if (!empty($data2)) {
pdo_update('ewei_shop_member_address', array('isdefault' => 1), array('uniacid' => $_W['uniacid'], 'openid' => $_W['openid'], 'id' => $data2['id']));
show_json(1, array('defaultid' => $data2['id']));
}
}
show_json(1);
}
function selector() {
global $_W, $_GPC;
$area_set = m('util')->get_area_config_set();
$new_area = intval($area_set['new_area']);
$address_street = intval($area_set['address_street']);
$condition = ' and openid=:openid and deleted=0 and `uniacid` = :uniacid ';
$params = array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']);
$sql = 'SELECT * FROM ' . tablename('ewei_shop_member_address') . ' where 1 ' . $condition . ' ORDER BY isdefault desc, id DESC ';
$list = pdo_fetchall($sql, $params);
include $this->template();
exit;
}
function getselector() {
global $_W, $_GPC;
$condition = ' and openid=:openid and deleted=0 and `uniacid` = :uniacid ';
$params = array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']);
$keywords = $_GPC['keywords'];
if (!empty($keywords)) {
$condition .= ' AND (`realname` LIKE :keywords OR `mobile` LIKE :keywords OR `province` LIKE :keywords OR `city` LIKE :keywords OR `area` LIKE :keywords OR `address` LIKE :keywords OR `street` LIKE :keywords)';
$params[':keywords'] = '%' . trim($keywords) . '%';
}
$sql = 'SELECT * FROM ' . tablename('ewei_shop_member_address') . ' where 1 ' . $condition . ' ORDER BY isdefault desc, id DESC ';
$list = pdo_fetchall($sql, $params);
foreach($list as &$item)
{
$item['editurl']=mobileUrl('member/address/post',array('id'=>$item['id']));
}
unset($item);
if(count($list)>0)
{
show_json(1,array("list"=>$list));
}else
{
show_json(0);
}
}
/**
* 验证地址是否重复添加
* @param $post
* author
* @return bool
*/
private function is_repeated_address($post){
global $_W;
if(empty($post['is_from_wx']) || $post['id']){
return false;
}
if(empty($post['province']) || empty($post['city']) || empty($post['area'])){
return false;
}
$condition = 'uniacid=:uniacid and openid=:openid and realname=:realname and mobile=:mobile and mobile=:mobile and province=:province and city=:city and area=:area and address=:address and deleted=0';
$params = [
':uniacid' => $_W['uniacid'],
':openid' => $_W['openid'],
':realname' => $post['realname'],
':mobile' => $post['mobile'],
':province' => $post['province'],
':city' => $post['city'],
':area' => $post['area'],
':address' => $post['address'],
];
$address = pdo_fetch("SELECT id FROM " . tablename('ewei_shop_member_address') . " where {$condition} limit 1",$params);
if($address){
return true;
}
return false;
}
}

View File

@@ -1,224 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
?>
<?php
if (!(defined('IN_IA'))) {
exit('Access Denied');
}
class Bind_EweiShopV2Page extends MobileLoginPage
{
protected $member;
public function __construct()
{
global $_W;
global $_GPC;
parent::__construct();
}
public function main()
{
global $_W;
global $_GPC;
@session_start();
$member = m('member')->getMember($_W['openid']);
$wapset = m('common')->getSysset('wap');
$appset = m('common')->getSysset('app');
if (!(p('threen'))) {
if (empty($wapset['open']) && !(empty($appset['isclose']))) {
$this->message('未开启绑定设置');
}
}
$bind = ((!(empty($member['mobile'])) && !(empty($member['mobileverify'])) ? 1 : 0));
if ($_W['ispost']) {
$mobile = trim($_GPC['mobile']);
$verifycode = trim($_GPC['verifycode']);
$pwd = trim($_GPC['pwd']);
$confirm = intval($_GPC['confirm']);
$key = '__ewei_shopv2_member_verifycodesession_' . $_W['uniacid'] . '_' . $mobile;
if (!(isset($_SESSION[$key])) || ($_SESSION[$key] !== $verifycode) || !(isset($_SESSION['verifycodesendtime'])) || (($_SESSION['verifycodesendtime'] + 600) < time())) {
show_json(0, '验证码错误或已过期');
}
$member2 = pdo_fetch('select * from ' . tablename('ewei_shop_member') . ' where mobile=:mobile and uniacid=:uniacid and mobileverify=1 limit 1', array(':mobile' => $mobile, ':uniacid' => $_W['uniacid']));
if (empty($member2)) {
$salt = m('account')->getSalt();
$data = array('mobile' => $mobile, 'pwd' => md5($pwd . $salt), 'salt' => $salt, 'mobileverify' => 1);
if (!(empty($_GPC['realname']))) {
$data['realname'] = trim($_GPC['realname']);
}
if (!(empty($_GPC['birthyear']))) {
$data['birthyear'] = trim($_GPC['birthyear']);
$data['birthmonth'] = trim($_GPC['birthmonth']);
$data['birthday'] = trim($_GPC['birthday']);
}
if (!(empty($_GPC['idnumber']))) {
$data['idnumber'] = trim($_GPC['idnumber']);
}
if (!(empty($_GPC['bindwechat']))) {
$data['weixin'] = trim($_GPC['bindwechat']);
}
m('bind')->update($member['id'], $data);
unset($_SESSION[$key]);
m('account')->setLogin($member['id']);
if (empty($member['mobileverify'])) {
m('bind')->sendCredit($member);
}
if (p('task')) {
p('task')->checkTaskReward('member_info', 1, $_W['openid']);
}
if (p('task')) {
p('task')->checkTaskProgress(1, 'info_phone');
}
show_json(1, 'bind success (0)');
}
if ($member['id'] == $member2['id']) {
show_json(0, '此手机号已与当前账号绑定');
}
if (m('bind')->iswxm($member) && m('bind')->iswxm($member2)) {
if ($confirm) {
$salt = m('account')->getSalt();
m('bind')->update($member['id'], array('mobile' => $mobile, 'pwd' => md5($pwd . $salt), 'salt' => $salt, 'mobileverify' => 1));
m('bind')->update($member2['id'], array('mobileverify' => 0));
unset($_SESSION[$key]);
m('account')->setLogin($member['id']);
if (p('task')) {
p('task')->checkTaskReward('member_info', 1, $_W['openid']);
}
if (p('task')) {
p('task')->checkTaskProgress(1, 'info_phone');
}
show_json(1, 'bind success (1)');
}
else {
show_json(-1, '<center>此手机号已与其他帐号绑定<br>如果继续将会解绑之前帐号<br>确定继续吗?</center>');
}
}
if (!(m('bind')->iswxm($member2))) {
if ($confirm) {
$result = m('bind')->merge($member2, $member);
if (empty($result['errno'])) {
show_json(0, $result['message']);
}
$salt = m('account')->getSalt();
m('bind')->update($member['id'], array('mobile' => $mobile, 'pwd' => md5($pwd . $salt), 'salt' => $salt, 'mobileverify' => 1));
unset($_SESSION[$key]);
m('account')->setLogin($member['id']);
if (p('task')) {
p('task')->checkTaskReward('member_info', 1, $_W['openid']);
}
if (p('task')) {
p('task')->checkTaskProgress(1, 'info_phone');
}
show_json(1, 'bind success (2)');
}
else {
show_json(-1, '<center>此手机号已通过其他方式注册<br>如果继续将会合并账号信息<br>确定继续吗?</center>');
}
}
if (!(m('bind')->iswxm($member))) {
if ($confirm) {
$result = m('bind')->merge($member, $member2);
if (empty($result['errno'])) {
show_json(0, $result['message']);
}
$salt = m('account')->getSalt();
m('bind')->update($member2['id'], array('mobile' => $mobile, 'pwd' => md5($pwd . $salt), 'salt' => $salt, 'mobileverify' => 1));
unset($_SESSION[$key]);
m('account')->setLogin($member2['id']);
if (p('task')) {
p('task')->checkTaskReward('member_info', 1, $_W['openid']);
}
if (p('task')) {
p('task')->checkTaskProgress(1, 'info_phone');
}
show_json(1, 'bind success (3)');
}
else {
show_json(-1, '<center>此手机号已通过其他方式注册<br>如果继续将会合并账号信息<br>确定继续吗?</center>');
}
}
}
$sendtime = $_SESSION['verifycodesendtime'];
if (empty($sendtime) || (($sendtime + 60) < time())) {
$endtime = 0;
}
else {
$endtime = 60 - time() - $sendtime;
}
include $this->template();
}
public function getbindinfo()
{
$wap = m('common')->getSysset('wap');
$nohasbindinfo = 0;
if (empty($wap['bindrealname']) && empty($wap['bindbirthday']) && empty($wap['bindidnumber']) && empty($wap['bindwechat'])) {
$nohasbindinfo = 1;
}
show_json(1, array('nohasbindinfo' => $nohasbindinfo, 'bindrealname' => (empty($wap['bindrealname']) ? 0 : 1), 'bindbirthday' => (empty($wap['bindbirthday']) ? 0 : 1), 'bindidnumber' => (empty($wap['bindidnumber']) ? 0 : 1), 'bindwechat' => (empty($wap['bindwechat']) ? 0 : 1)));
}
}
?>

View File

@@ -1,802 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Cart_EweiShopV2Page extends MobileLoginPage {
function main() {
global $_W,$_GPC;
$route = '';
if ($_GPC['merchid']) {
$route = 'merch';
}
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if ($merch_plugin && $merch_data['is_openmerch']) {
include $this->template('merch/member/cart');
exit;
}
include $this->template();
}
function get_list(){
global $_W,$_GPC;
$uniacid = $_W['uniacid'];
$openid =$_W['openid'];
if(p('newstore'))
{
$condition = ' and f.uniacid= :uniacid and f.openid=:openid and f.deleted=0 and f.isnewstore=0';
}else{
$condition = ' and f.uniacid= :uniacid and f.openid=:openid and f.deleted=0';
}
$params = array(':uniacid' => $uniacid, ':openid' => $openid);
$list = array();
$total = 0;
$totalprice = 0;
$ischeckall = true;
$level = m('member')->getLevel($openid);
$sql = 'SELECT f.id,f.total,f.goodsid,g.status,g.total as stock,g.preselltimeend,g.presellprice as gpprice,g.hasoption, o.stock as optionstock,g.presellprice,g.ispresell, g.maxbuy,g.title,g.thumb,ifnull(o.marketprice, g.marketprice) as marketprice,'
. ' g.deleted,g.productprice,o.title as optiontitle,o.presellprice,f.optionid,o.specs,g.minbuy,g.maxbuy,g.unit,g.merchid,g.checked,g.isdiscount_discounts,g.isdiscount,g.isdiscount_time,g.isnodiscount,g.discounts,g.merchsale'
. ' ,f.selected,g.type,g.intervalfloor,g.intervalprice FROM ' . tablename('ewei_shop_member_cart') . ' f '
. ' left join ' . tablename('ewei_shop_goods') . ' g on f.goodsid = g.id '
. ' left join ' . tablename('ewei_shop_goods_option') . ' o on f.optionid = o.id '
. ' where 1 ' . $condition . ' ORDER BY `id` DESC ';
$list = pdo_fetchall($sql, $params);
$invalidGoods = array();
$saleoutGoods = array();
foreach ($list as $index => &$g) {
$g['cart_number'] = $g['total'];
if($g['type']==4)
{
$intervalprice = iunserializer($g['intervalprice']);
if($g['intervalfloor']>0)
{
$g['intervalprice1']=$intervalprice[0]['intervalprice'];
$g['intervalnum1']=$intervalprice[0]['intervalnum'];
}
if($g['intervalfloor']>1)
{
$g['intervalprice2']=$intervalprice[1]['intervalprice'];
$g['intervalnum2']=$intervalprice[1]['intervalnum'];
}
if($g['intervalfloor']>2)
{
$g['intervalprice3']=$intervalprice[2]['intervalprice'];
$g['intervalnum3']=$intervalprice[2]['intervalnum'];
}
}
if($g['ispresell']>0 && ($g['preselltimeend'] == 0 || $g['preselltimeend'] > time())){
$g['marketprice'] = intval($g['hasoption'])>0 ? $g['presellprice'] : $g['gpprice'];
}
$g['thumb'] = tomedia($g['thumb']);
$seckillinfo = plugin_run('seckill::getSeckill',$g['goodsid'] ,$g['optionid'] ,true, $_W['openid']);
if (!empty($g['optionid'])) {
$g['stock'] = $g['optionstock'];
if (!empty($g['specs'])) {
$thumb = m('goods')->getSpecThumb($g['specs']);
if (!empty($thumb)) {
$g['thumb'] =tomedia( $thumb );
}
}
$optionData = pdo_fetch('SELECT * FROM '.tablename('ewei_shop_goods_option').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.intval($g['optionid']));
if(empty($optionData) || $optionData == false){
pdo_update('ewei_shop_member_cart',array('deleted'=>1),array('id'=>$g['id']));
}
}
if ($g['status'] == 0 || $g['stock'] == 0 || ($g['hasoption'] == 1 && $g['optionstock'] == 0) ) {
$g['selected'] = false;
pdo_update('ewei_shop_member_cart', array('selected' => 0), array('id' => $g['id']));
}
if ($g['status'] == 0 || $g['deleted'] == 1 ) {
$g['desc'] = '失效';
$invalidGoods[] = $g;
pdo_update('ewei_shop_member_cart', array('selected' => 0), array('id' => $g['id']));
unset($list[$index]);
continue;
}
if ($g['hasoption'] == 1 && $g['optionstock'] == 0) {
$g['desc']= '售罄';
$saleoutGoods[] = $g;
unset($list[$index]);
} else if($g['stock'] == 0) {
$saleoutGoods[] = $g;
unset($list[$index]);
}
if ($g['status'] == 2) {
unset($list[$index]);
pdo_update('ewei_shop_member_cart', array('deleted' => 1), array('id' => $g['id']));
}
if($g['selected']){
$prices = m('order')->getGoodsDiscountPrice($g, $level, 1);
$total+=$g['total'];
$g['marketprice'] = $g['ggprice'] = $prices['price'];
$g['discounttype'] = $prices['discounttype'];
if( $seckillinfo && $seckillinfo['status']==0){
$seckilllast = 0;
if( $seckillinfo['maxbuy']>0) {
$seckilllast = $seckillinfo['maxbuy'] - $seckillinfo['selfcount'];
}
$normal = $g['total'] - $seckilllast;
if($normal<=0){
$normal = 0;
}
$totalprice+= $seckillinfo['price'] * $seckilllast + $g['marketprice'] * $normal;
$g['seckillmaxbuy'] = $seckillinfo['maxbuy'];
$g['seckillselfcount'] = $seckillinfo['selfcount'];
$g['seckillprice'] = $seckillinfo['price'];
$g['seckilltag'] = $seckillinfo['tag'];
$g['seckilllast'] = $seckilllast;
} else{
$totalprice+=$g['marketprice'] * $g['total'];
}
}
$totalmaxbuy = $g['stock'];
if( $seckillinfo && $seckillinfo['status']==0){
if( $totalmaxbuy > $g['seckilllast']){
$totalmaxbuy = $g['seckilllast'];
}
if($g['total']>$totalmaxbuy){
$g['total'] = $totalmaxbuy;
}
$g['minbuy'] = 0;
} else if($g['type'] == 4){
}
else {
if ($g['maxbuy'] > 0) {
if ($totalmaxbuy != -1) {
if ($totalmaxbuy > $g['maxbuy']) {
$totalmaxbuy = $g['maxbuy'];
}
} else {
$totalmaxbuy = $g['maxbuy'];
}
}
if ($g['usermaxbuy'] > 0) {
$order_goodscount = pdo_fetchcolumn('select ifnull(sum(og.total),0) from ' . tablename('ewei_shop_order_goods') . ' og '
. ' left join ' . tablename('ewei_shop_order') . ' o on og.orderid=o.id '
. ' where og.goodsid=:goodsid and o.status>=1 and o.openid=:openid and og.uniacid=:uniacid ', array(':goodsid' => $g['goodsid'], ':uniacid' => $uniacid, ':openid' => $openid));
$last = $g['usermaxbuy'] - $order_goodscount;
if ($last <= 0) {
$last = 0;
}
if ($totalmaxbuy != -1) {
if ($totalmaxbuy > $last) {
$totalmaxbuy = $last;
}
} else {
$totalmaxbuy = $last;
}
}
if ($g['minbuy'] > 0) {
if ($g['minbuy'] > $totalmaxbuy) {
$g['minbuy'] = $totalmaxbuy;
}
}
}
$g['totalmaxbuy'] = $totalmaxbuy;
$g['unit'] = empty($data['unit']) ? '件' : $data['unit'];
$g['productprice'] = price_format($g['productprice']);
}
unset($g);
array_walk($list, function ($value) use (&$ischeckall) {
if ($value['selected'] == 0) {
$ischeckall = false;
}
});
$list = array_merge($list, $saleoutGoods, $invalidGoods);
$list = set_medias($list, 'thumb');
$merch_user = array();
$merch = array();
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if ($merch_plugin && $merch_data['is_openmerch']) {
$getListUser = $merch_plugin->getListUser($list);
$merch_user = $getListUser['merch_user'];
$merch = $getListUser['merch'];
}
if(empty($list)){
$list = array();
}else{
foreach ($list as $g){
$goodsmerchid = $g['merchid'];
if(!isset($merch_user[$goodsmerchid])){
$merch_user[$goodsmerchid] = array(
'goods_count' => 0,
'goods_selected' => 0
);
}
$merch_user[$goodsmerchid]['goods_count'] = intval($merch_user[$goodsmerchid]['goods_count']);
$merch_user[$goodsmerchid]['goods_selected'] = intval($merch_user[$goodsmerchid]['goods_selected']);
$merch_user[$goodsmerchid]['goods_count']++;
if(!empty($g['selected'])){
$merch_user[$goodsmerchid]['goods_selected']++;
}
}
foreach ($merch_user as $merchid=>$merchuser) {
if (!isset($merchuser['goods_selected']) || !isset($merchuser['goods_count'])) {
continue;
}
if($merchuser['goods_selected'] == $merchuser['goods_count']){
$merch_user[$merchid]['selectedall'] = 1;
}else{
$merch_user[$merchid]['selectedall'] = 0;
}
}
}
$shopSet = m('common')->getSysset('shop');
$saleout_icon = isset($shopSet['saleout']) ? tomedia($shopSet['saleout']) : '';
show_json(1, array(
'saleout_icon' => $saleout_icon,
'ischeckall' => $ischeckall,
'list' => $list ,
'total' => $total,
'totalprice' => round($totalprice,2),
'merch_user' => $merch_user ,
'merch' => $merch
));
}
function select(){
global $_W,$_GPC;
$id = intval($_GPC['id']);
$select = intval($_GPC['select']);
if(!empty($id)){
$data = pdo_fetch("select id,goodsid,optionid, total from " . tablename('ewei_shop_member_cart') . " "
. " where id=:id and uniacid=:uniacid and openid=:openid limit 1 ", array(':id' => $id, ':uniacid' => $_W['uniacid'],':openid'=>$_W['openid']));
if (!empty($data)) {
pdo_update('ewei_shop_member_cart', array('selected' => $select), array('id' => $id, 'uniacid' => $_W['uniacid']));
}
} else {
$cartGoods = pdo_fetchall(
"select c.id as cartid,g.id as goodsid, g.total as stock, g.status, c.optionid, o.stock as optionstock from " . tablename('ewei_shop_member_cart') . " c"
. " left join " . tablename('ewei_shop_goods') . " g on g.id = c.goodsid"
. " left join " . tablename('ewei_shop_goods_option') . " o on o.id = c.optionid"
. " where c.uniacid = :uniacid and c.openid = :openid and c.deleted = 0 and g.status <> 0",
array(
':openid' => $_W['openid'],
':uniacid' => $_W['uniacid']
));
$ret = array();
foreach ($cartGoods as $cartGoodItem) {
if ($cartGoodItem['optionid']) {
$cartGoodItem['stock'] = $cartGoodItem['optionstock'];
}
if ($cartGoodItem['stock'] == 0 || $cartGoodItem['status'] == 0) {
continue;
}
$ret[] = $cartGoodItem['cartid'];
}
$ret = implode(',', $ret);
pdo_query("update ". tablename('ewei_shop_member_cart') . " set selected = {$select} where id in ({$ret})");
}
show_json(1);
}
function update(){
global $_W,$_GPC;
$id = intval($_GPC['id']);
$goodstotal = intval($_GPC['total']);
$optionid = intval($_GPC['optionid']);
$type = intval($_GPC['type']);
if($type == 0){
return;
}
if(empty($goodstotal)){
$goodstotal = 1;
}
$data = pdo_fetch("select id,goodsid,optionid,total,selected from " . tablename('ewei_shop_member_cart') . " "
. " where id=:id and uniacid=:uniacid and openid=:openid limit 1 ", array(':id' => $id, ':uniacid' => $_W['uniacid'],':openid'=>$_W['openid']));
if (empty($data)) {
show_json(0,'无购物车记录');
}
pdo_update('ewei_shop_member_cart', array('total' => $goodstotal,'optionid'=>$optionid), array('id' => $id, 'uniacid' => $_W['uniacid'],'openid'=>$_W['openid']));
$seckillinfo = plugin_run('seckill::getSeckill',$data['goodsid'] ,$data['optionid'] ,true, $_W['openid']);
if( $seckillinfo && $seckillinfo['status']==0) {
$g =array();
$g['seckillmaxbuy'] = $seckillinfo['maxbuy'];
$g['seckillselfcount'] = $seckillinfo['selfcount'];
$g['seckillprice'] = $seckillinfo['price'];
show_json(1,array('seckillinfo'=>$g));
}
show_json(1);
}
function add() {
global $_W, $_GPC;
$id = intval($_GPC['id']);
$total = intval($_GPC['total']);
$this->_validateCartOverLimit();
$total <= 0 && $total = 1;
$optionid = intval($_GPC['optionid']);
$goods = pdo_fetch('select id,marketprice,diyformid,diyformtype,diyfields, isverify, `type`,merchid, cannotrefund,hasoption from '.tablename('ewei_shop_goods').' where id=:id and uniacid=:uniacid limit 1',array(':id'=>$id,':uniacid'=>$_W['uniacid']));
if (empty($goods)) {
show_json(0, '商品未找到');
}
if($goods['hasoption']>0 && empty($optionid)){
show_json(0, '请选择规格');
}
$member = m('member')->getMember($_W['openid']);
if(!empty($_W['shopset']['wap']['open']) && !empty($_W['shopset']['wap']['mustbind']) && empty($member['mobileverify'])){
show_json(0, array('message'=>"请先绑定手机", 'url'=>mobileUrl('member/bind', null, true)));
}
if ($goods['isverify'] == 2 || $goods['type'] == 2 || $goods['type'] == 3 ) {
show_json(0, '此商品不可加入购物车<br>请直接点击立刻购买');
}
$giftid = intval($_GPC['giftid']);
$gift = pdo_fetch("select * from ".tablename('ewei_shop_gift')." where uniacid = ".$_W['uniacid']." and id = ".$giftid." and starttime >= ".time()." and endtime <= ".time()." and status = 1 ");
$diyform_plugin = p('diyform');
$diyformid = 0;
$diyformfields = iserializer(array());
$diyformdata = iserializer(array());
if ($diyform_plugin) {
$diyformdata = $_GPC['diyformdata'];
if (!empty($diyformdata) && is_array($diyformdata)) {
$diyformfields = false;
if( $goods['diyformtype']==1){
$diyformid = intval($goods['diyformid']);
$formInfo = $diyform_plugin->getDiyformInfo($diyformid);
if(!empty($formInfo)){
$diyformfields = $formInfo['fields'];
}
} else if($goods['diyformtype']==2){
$diyformfields = iunserializer($goods['diyfields']);
}
if(!empty($diyformfields)){
$insert_data = $diyform_plugin->getInsertData($diyformfields, $diyformdata);
$diyformdata = $insert_data['data'];
$diyformfields = iserializer($diyformfields);
}
}
}
$data = pdo_fetch("select id,total,diyformid from " . tablename('ewei_shop_member_cart') . ' where goodsid=:id and openid=:openid and optionid=:optionid and deleted=0 and uniacid=:uniacid limit 1', array(
':uniacid' => $_W['uniacid'],
':openid' => $_W['openid'],
':optionid' => $optionid,
':id' => $id
));
if (empty($data)) {
$data = array(
'uniacid' => $_W['uniacid'],
'merchid' => $goods['merchid'],
'openid' => $_W['openid'],
'goodsid' => $id,
'optionid' => $optionid,
'marketprice' => $goods['marketprice'],
'total' => $total,
'selected'=>1,
'diyformid'=>$diyformid,
'diyformdata'=> $diyformdata,
'diyformfields'=> $diyformfields,
'createtime' => time()
);
pdo_insert('ewei_shop_member_cart', $data);
} else {
$data['diyformid'] = $diyformid;
$data['diyformdata'] = $diyformdata;
$data['diyformfields'] = $diyformfields;
$data['total']+=$total;
pdo_update('ewei_shop_member_cart', $data, array('id' => $data['id']));
}
$cartcount = pdo_fetchcolumn('select sum(total) from ' . tablename('ewei_shop_member_cart') . ' where openid=:openid and deleted=0 and uniacid=:uniacid limit 1', array(
':uniacid' => $_W['uniacid'],
':openid' => $_W['openid']
));
show_json(1, array('isnew' => false, 'cartcount' => $cartcount,'goodsid'=>$id));
}
function addwholesale() {
global $_W, $_GPC;
$id = intval($_GPC['id']);
$optionsjson = $_GPC['options'];
$optionsdata = json_decode(htmlspecialchars_decode($optionsjson,ENT_QUOTES),true);
$this->_validateCartOverLimit();
$goods = pdo_fetch('select id,marketprice,diyformid,diyformtype,diyfields, isverify, `type`,merchid, cannotrefund from '.tablename('ewei_shop_goods').' where id=:id and uniacid=:uniacid limit 1',array(':id'=>$id,':uniacid'=>$_W['uniacid']));
if (empty($goods)) {
show_json(0, '商品未找到');
}
$member = m('member')->getMember($_W['openid']);
if(!empty($_W['shopset']['wap']['open']) && !empty($_W['shopset']['wap']['mustbind']) && empty($member['mobileverify'])){
show_json(0, array('message'=>"请先绑定手机", 'url'=>mobileUrl('member/bind', null, true)));
}
foreach($optionsdata as $option) {
if(empty($option['total']))
{
continue;
}
$data = pdo_fetch("select id,total,diyformid from " . tablename('ewei_shop_member_cart') . ' where goodsid=:id and openid=:openid and optionid=:optionid and deleted=0 and uniacid=:uniacid limit 1', array(
':uniacid' => $_W['uniacid'],
':openid' => $_W['openid'],
':optionid' => $option['optionid'],
':id' => $id
));
if (empty($data)) {
$data = array(
'uniacid' => $_W['uniacid'],
'merchid' => $goods['merchid'],
'openid' => $_W['openid'],
'goodsid' => $id,
'optionid' => $option['optionid'],
'marketprice' => $goods['marketprice'],
'total' => intval($option['total']),
'selected' => 1,
'createtime' => time()
);
pdo_insert('ewei_shop_member_cart', $data);
} else {
$data['total'] += intval($option['total']);
pdo_update('ewei_shop_member_cart', $data, array('id' => $data['id']));
}
}
$cartcount = pdo_fetchcolumn('select sum(total) from ' . tablename('ewei_shop_member_cart') . ' where openid=:openid and deleted=0 and uniacid=:uniacid limit 1', array(
':uniacid' => $_W['uniacid'],
':openid' => $_W['openid']
));
show_json(1, array('isnew' => false, 'cartcount' => $cartcount));
}
private function _validateCartOverLimit()
{
global $_W, $_GPC;
$listCount = pdo_fetch("select count(*) sum from" .tablename('ewei_shop_member_cart') . " where uniacid = :uniacid and openid = :openid and deleted = 0", array('uniacid'=>$_W['uniacid'], 'openid'=>$_W['openid']));
$listCount = empty($listCount['sum']) ? 0 : $listCount['sum'] ;
$wholesaleCount = 0;
$simpleGoodsCount = 1;
if (isset($_GPC['options'])) {
$optionsdata = json_decode(htmlspecialchars_decode($_GPC['options'],ENT_QUOTES),true);
foreach($optionsdata as $item) {
if(!empty($item['total'])) {
$wholesaleCount ++;
}
}
}
if ($listCount + $simpleGoodsCount + $wholesaleCount > 50) {
show_json(0, "您的购物车宝贝超过50个了建议您先去结算或清理");
}
}
function remove(){
global $_W,$_GPC;
$ids = $_GPC['ids'];
if (empty($ids) || !is_array($ids)) {
show_json(0, '参数错误');
}
$sql = "update " . tablename('ewei_shop_member_cart') . ' set deleted=1 where uniacid=:uniacid and openid=:openid and id in (' . implode(',', $ids) . ')';
pdo_query($sql, array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']));
show_json(1);
}
function tofavorite(){
global $_W,$_GPC;
$uniacid =$_W['uniacid'];
$openid =$_W['openid'];
$ids = $_GPC['ids'];
if (empty($ids) || !is_array($ids)) {
show_json(0, '参数错误');
}
foreach ($ids as $id) {
$goodsid = pdo_fetchcolumn('select goodsid from ' . tablename('ewei_shop_member_cart') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1 ', array(':id' => $id, ':uniacid' => $uniacid, ':openid' => $openid));
if (!empty($goodsid)) {
$fav = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_member_favorite') . ' where goodsid=:goodsid and uniacid=:uniacid and openid=:openid and deleted=0 limit 1 ', array(':goodsid' => $goodsid, ':uniacid' => $uniacid, ':openid' => $openid));
if ($fav <= 0) {
$fav = array(
'uniacid' => $uniacid,
'goodsid' => $goodsid,
'openid' => $openid,
'deleted' => 0,
'createtime' => time()
);
pdo_insert('ewei_shop_member_favorite', $fav);
}
}
}
$sql = "update " . tablename('ewei_shop_member_cart') . ' set deleted=1 where uniacid=:uniacid and openid=:openid and id in (' . implode(',', $ids) . ')';
pdo_query($sql, array(':uniacid' => $uniacid, ':openid' => $openid));
show_json(1);
}
function caculategoodsprice(){
global $_W,$_GPC;
$goods = $_GPC['goods'];
$goods =m("goods")->wholesaleprice($goods);
$cartgoods =array();
foreach($goods as $g)
{
$cartgoods[$g['id']]=$g;
}
show_json(1, array('goods'=>$cartgoods));
}
private function cartGoodsCheckedStatus($id, $checked = false)
{
$selected = $checked ? 1 : 0;
pdo_update('ewei_shop_member_cart', array('selected' => $selected), array('id'=>$id));
}
function submit(){
global $_W,$_GPC;
$uniacid = $_W['uniacid'];
$openid =$_W['openid'];
$member = m('member')->getMember($openid);
$condition = ' and f.uniacid= :uniacid and f.openid=:openid and f.selected=1 and f.deleted=0 ';
$params = array(':uniacid' => $uniacid, ':openid' => $openid);
$sql = 'SELECT f.id,f.total,f.goodsid,g.total as stock, o.stock as optionstock, g.hasoption,g.maxbuy,g.title,g.thumb,ifnull(o.marketprice, g.marketprice) as marketprice,'
. ' g.productprice,o.title as optiontitle,f.optionid,o.specs,g.minbuy,g.maxbuy,g.usermaxbuy,g.unit,g.merchid,g.checked,g.isdiscount_discounts,g.isdiscount,g.isdiscount_time,g.isnodiscount,g.discounts,g.merchsale'
. ' ,f.selected,g.status,g.deleted as goodsdeleted,g.type,g.intervalfloor,g.intervalprice FROM ' . tablename('ewei_shop_member_cart') . ' f '
. ' left join ' . tablename('ewei_shop_goods') . ' g on f.goodsid = g.id '
. ' left join ' . tablename('ewei_shop_goods_option') . ' o on f.optionid = o.id '
. ' where 1 ' . $condition . ' ORDER BY `id` DESC ';
$list = pdo_fetchall($sql, $params);
if(empty($list)){
show_json(0,'没有选择任何商品');
}
$list =m("goods")->wholesaleprice($list);
$array = pdo_fetchall('select og.optionid from ' . tablename('ewei_shop_order_goods') . ' og '
. ' left join ' . tablename('ewei_shop_order') . ' o on og.orderid=o.id '
. ' where o.status>=1 and o.openid=:openid and og.uniacid=:uniacid ', array( ':uniacid' => $uniacid, ':openid' => $openid));
$t = 0;
foreach ($list as $key=>$a) {
foreach ($array as $k=>$b) {
if($list['hasoption']){
if($list['optionid']==$array['optionid']){
$t +=1;
}
}
}
$list[$key]['allt'] = $t;
$t =0;
}
foreach ($list as &$g) {
if(empty($g['unit'])){
$g['unit'] = "";
}
if ($g['optionid']) {
$g['stock'] = $g['optionstock'];
}
if( ($g['stock'] - $g['total'] < 0) && ( !$g['optionid'] || ($g['optionid'] && $g['stock'] != -1))) {
pdo_update('ewei_shop_member_cart', array('selected' => 0, 'total'=> $g['stock']), array('id'=>$g['id']));
$optionTitle = !empty($g['optiontitle']) ? $g['optiontitle'] : '';
show_json(0, $g['title'] . "<br/>" . $optionTitle . " 库存不足!");
}
if($g['status'] == 0 || $g['goodsdeleted']==1){
$this->cartGoodsCheckedStatus($g['id']);
show_json(0,$g['title'].'<br/> 已经下架');
}
if($g['type']==5 && count($list)>1){
show_json(0,$g['title'].'<br/> 为记次商品,无法合并付款,请单独购买');
}
$seckillinfo = plugin_run('seckill::getSeckill',$g['goodsid'] ,$g['optionid'] ,true, $_W['openid']);
if (!empty($g['optionid'])) {
$g['stock'] = $g['optionstock'];
}
if( $seckillinfo && $seckillinfo['status']==0){
$check_buy = plugin_run('seckill::checkBuy', $seckillinfo , $g['title'] ,$g['unit']);
if(is_error($check_buy)){
show_json(-1 , $check_buy['message']);
}
} else{
$levelid = intval($member['level']);
if (empty($member['groupid'])){
$groupid = array();
}else{
$groupid = explode(',',$member['groupid']);
}
if ($g['buylevels'] != '') {
$buylevels = explode(',', $g['buylevels']);
if (!in_array($levelid, $buylevels)) {
show_json(0, '您的会员等级无法购买<br/>' . $g['title'] . '!');
}
}
if ($g['buygroups'] != '' ) {
if(empty($groupid)){
$groupid[]=0;
}
$buygroups = explode(',', $g['buygroups']);
$intersect = array_intersect($groupid, $buygroups);
if (empty($intersect)) {
show_json(0, '您所在会员组无法购买<br/>' . $g['title'] . '!');
}
}
if($g['type']==4)
{
if ($g['goodsalltotal'] < $g['minbuy']) {
show_json(0, $g['title'] . '<br/> ' . $g['minbuy'] . $g['unit'] . "起批!");
}
}else
{
if ($g['minbuy'] > 0) {
if ($g['total'] < $g['minbuy']) {
show_json(0, $g['title'] . '<br/> ' . $g['minbuy'] . $g['unit'] . "起售!");
}
}
if ($g['maxbuy'] > 0) {
if ($g['total'] > $g['maxbuy']) {
show_json(0, $g['title'] . '<br/> 一次限购 ' . $g['maxbuy'] . $g['unit'] . "!");
}
}
}
if ($g['usermaxbuy'] > 0) {
if ($g['total'] > $g['usermaxbuy'] ||$g['allt'] > $g['usermaxbuy'] ) show_json(0, $g['title'] . '<br/> 最多限购 ' . $g['usermaxbuy'] . $g['unit'] . "!");
$order_goodscount = pdo_fetchcolumn('select ifnull(sum(og.total),0) from ' . tablename('ewei_shop_order_goods') . ' og '
. ' left join ' . tablename('ewei_shop_order') . ' o on og.orderid=o.id '
. ' where og.goodsid=:goodsid and o.status>=1 and o.openid=:openid and og.uniacid=:uniacid ', array(':goodsid' => $g['goodsid'], ':uniacid' => $uniacid, ':openid' => $openid));
if ($order_goodscount > $g['usermaxbuy'] ||$order_goodscount + $g['allt'] > $g['usermaxbuy']) {
show_json(0, $g['title'] . '<br/> 最多限购 ' . $g['usermaxbuy'] . $g['unit'] . "!");
}
$total_buy = $order_goodscount + $g['total'];
if ($total_buy > $g['usermaxbuy'] || $order_goodscount + $g['allt'] > $g['usermaxbuy']) {
show_json(0, $g['title'] . '<br/> 最多限购 ' . $g['usermaxbuy'] . $g['unit'] . "!");
}
}
if (!empty($g['optionid'])) {
$option = pdo_fetch('select id,title,marketprice,goodssn,productsn,stock,`virtual`,weight from ' . tablename('ewei_shop_goods_option') . ' where id=:id and goodsid=:goodsid and uniacid=:uniacid limit 1', array(':uniacid' => $uniacid, ':goodsid' => $g['goodsid'], ':id' => $g['optionid']));
if (!empty($option)) {
if ($option['stock'] != -1) {
if (empty($option['stock'])) {
show_json(-1, $g['title'] . "<br/>" . $option['title'] . " 库存不足!");
}
}
}
}
else{
if ($g['stock'] != -1) {
if (empty($g['stock'])) {
show_json(0, $g['title'] . "<br/>库存不足!");
}
}
}
}
}
show_json(1);
}
}

View File

@@ -1,72 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Changepwd_EweiShopV2Page extends MobileLoginPage
{
protected $member;
public function __construct()
{
global $_W;
global $_GPC;
parent::__construct();
$this->member = m('member')->getMember($_W['openid']);
}
public function main()
{
global $_W;
global $_GPC;
$member = $this->member;
$wapset = m('common')->getSysset('wap');
if (is_weixin() || empty($_GPC['__ewei_shopv2_member_session_' . $_W['uniacid']])) {
header('location: ' . mobileUrl());
}
if ($_W['ispost']) {
$mobile = trim($_GPC['mobile']);
$verifycode = trim($_GPC['verifycode']);
$pwd = trim($_GPC['pwd']);
@session_start();
$key = '__ewei_shopv2_member_verifycodesession_' . $_W['uniacid'] . '_' . $mobile;
if (!isset($_SESSION[$key]) || ($_SESSION[$key] !== $verifycode) || !isset($_SESSION['verifycodesendtime']) || (($_SESSION['verifycodesendtime'] + 600) < time())) {
show_json(0, '验证码错误或已过期!');
}
$member = pdo_fetch('select id,openid,mobile,pwd,salt,credit1,credit2, createtime from ' . tablename('ewei_shop_member') . ' where mobile=:mobile and uniacid=:uniacid and mobileverify=1 limit 1', array(':mobile' => $mobile, ':uniacid' => $_W['uniacid']));
$salt = (empty($member) ? '' : $member['salt']);
if (empty($salt)) {
$salt = random(16);
while (1) {
$count = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_member') . ' where salt=:salt limit 1', array(':salt' => $salt));
if ($count <= 0) {
break;
}
$salt = random(16);
}
}
pdo_update('ewei_shop_member', array('mobile' => $mobile, 'pwd' => md5($pwd . $salt), 'salt' => $salt, 'mobileverify' => 1), array('id' => $this->member['id'], 'uniacid' => $_W['uniacid']));
unset($_SESSION[$key]);
show_json(1);
}
$sendtime = $_SESSION['verifycodesendtime'];
if (empty($sendtime) || (($sendtime + 60) < time())) {
$endtime = 0;
}
else {
$endtime = 60 - time() - $sendtime;
}
include $this->template();
}
}
?>

View File

@@ -1,155 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Favorite_EweiShopV2Page extends MobileLoginPage
{
function main()
{
global $_W, $_GPC;
include $this->template();
/* $merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if ($merch_plugin && $merch_data['is_openmerch'])
{
include $this->template('merch/member/favorite');
}
else
{
include $this->template();
}*/
}
function get_list()
{
global $_W, $_GPC;
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
$pindex = max(1, intval($_GPC['page']));
$psize = 10;
$condition = ' and f.uniacid = :uniacid and f.openid=:openid and f.deleted=0';
if ($merch_plugin && $merch_data['is_openmerch']) {
$condition = ' and f.uniacid = :uniacid and f.openid=:openid and f.deleted=0 and f.type=0';
}
$params = array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']);
$sql = 'SELECT COUNT(*) FROM ' . tablename('ewei_shop_member_favorite') . " f where 1 {$condition}";
$total = pdo_fetchcolumn($sql, $params);
$list = array();
if (!empty($total)) {
$sql = 'SELECT f.id,f.goodsid,f.thumb as favthumb,f.title as favtitle,f.marketprice as favmarketprice,f.productprice as favproductprice,g.title,g.thumb,g.marketprice,g.productprice,g.merchid,g.minprice,g.maxprice,
CASE
g.deleted
WHEN g.title IS NULL THEN 0
ELSE 1
END
as deleted
FROM ' . tablename('ewei_shop_member_favorite') . ' f '
. ' left join ' . tablename('ewei_shop_goods') . ' g on f.goodsid = g.id '
. ' where 1 ' . $condition . ' ORDER BY deleted asc ,`id` DESC LIMIT ' . ($pindex - 1) * $psize . ',' . $psize;
$list = pdo_fetchall($sql, $params);
//判断如果商品被删除了 就走默认的图片
if (!empty($list)) {
foreach ($list as &$item) {
if (empty($item['title'])){
$item['title'] = $item['favtitle'];
$item['delete'] = 1;
}
if (empty($item['thumb'])){
$item['thumb'] = $item['favthumb'];
}
if (empty($item['marketprice'])){
$item['marketprice'] = $item['favmarketprice'];
}
if (empty($item['productprice'])){
$item['productprice'] = $item['favproductprice'];
}
// 那么这个商品有可能是多规格产品
if ((float)$item['marketprice'] == 0 && (float)$item['productprice'] == 0) {
$item['marketprice'] = $item['minprice'];
}
}
unset($item);
}
$list = set_medias($list, 'thumb');
if (!empty($list) && $merch_plugin && $merch_data['is_openmerch']) {
$merch_user = $merch_plugin->getListUser($list, 'merch_user');
foreach ($list as &$row) {
$row['merchname'] = $merch_user[$row['merchid']]['merchname'] ? $merch_user[$row['merchid']]['merchname'] : $_W['shopset']['shop']['name'];
}
unset($row);
}
}
show_json(1, array('list' => $list, 'total' => $total, 'pagesize' => $psize));
}
function toggle()
{
global $_W, $_GPC;
$id = intval($_GPC['id']);
$isfavorite = intval($_GPC['isfavorite']);
$goods = pdo_fetch('select * from ' . tablename('ewei_shop_goods') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($goods)) {
show_json(0, '商品未找到');
}
$data = pdo_fetch('select id,deleted from ' . tablename('ewei_shop_member_favorite') . ' where uniacid=:uniacid and goodsid=:id and openid=:openid limit 1', array(
':uniacid' => $_W['uniacid'],
':openid' => $_W['openid'],
':id' => $id
));
if (empty($data)) {
if (!empty($isfavorite)) {
$data = array(
'uniacid' => $_W['uniacid'],
'goodsid' => $id,
'openid' => $_W['openid'], //兼容1.x
'createtime' => time(),
'thumb' => $goods['thumb'],
'title' => $goods['title'],
'marketprice' => $goods['marketprice'],
'productprice' => $goods['productprice']
);
pdo_insert('ewei_shop_member_favorite', $data);
}
} else {
pdo_update('ewei_shop_member_favorite', array('deleted' => $isfavorite ? 0 : 1), array('id' => $data['id'], 'uniacid' => $_W['uniacid']));
}
show_json(1, array('isfavorite' => $isfavorite == 1));
}
function remove()
{
global $_W, $_GPC;
$ids = $_GPC['ids'];
if (empty($ids) || !is_array($ids)) {
show_json(0, '参数错误');
}
// 遍历强转int
foreach ($ids as &$id) {
$id = (int)$id;
}
// 去重、去空
$ids = array_unique(array_filter($ids));
if (empty($ids)) {
show_json(0, '参数错误');
}
$sql = "update " . tablename('ewei_shop_member_favorite') . ' set deleted=1 where openid=:openid and id in (' . implode(',', $ids) . ')';
pdo_query($sql, array(':openid' => $_W['openid']));
show_json(1);
}
}

View File

@@ -1,98 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Fullback_EweiShopV2Page extends MobileLoginPage
{
public function main()
{
global $_W;
global $_GPC;
$_GPC['type'] = intval($_GPC['type']);
$_GPC['orderid'] = intval($_GPC['orderid']);
$orderid = $_GPC['orderid'];
$condition = ' where uniacid=:uniacid and openid =:openid ';
$params = array('uniacid' => $_W['uniacid'], 'openid' => $_W['openid']);
if ($orderid) {
$params['orderid'] = $orderid;
$condition .= ' and orderid=:orderid ';
}
$info = pdo_fetchall('SELECT * FROM' . tablename('ewei_shop_fullback_log') . $condition, $params);
$alldata = array();
$allday = array();
$fullbackday = array();
$createtime = array();
if (is_array($info) && !empty($info)) {
foreach ($info as &$value) {
$alldata['allprice'] += $value['price'];
$alldata['hasprice'] += $value['priceevery'] * $value['fullbackday'];
array_push($createtime, $value['createtime']);
array_push($allday, $value['day']);
array_push($fullbackday, $value['fullbackday']);
}
unset($value);
}
$alldata['day'] = max($allday);
$alldata['fullbackday'] = max($fullbackday);
$alldata['createtime'] = min($createtime);
include $this->template();
}
public function get_list()
{
global $_W;
global $_GPC;
$isfullback = intval($_GPC['type']);
$pindex = max(1, intval($_GPC['page']));
$orderid = intval($_GPC['orderid']);
$psize = 10;
$condition = ' and fl.openid=:openid and fl.uniacid=:uniacid and fl.isfullback=:isfullback';
$params = array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid'], ':isfullback' => $isfullback);
if ($orderid) {
$condition .= ' and fl.orderid=:orderid';
$params['orderid'] = $orderid;
}
$list = array();
$list = pdo_fetchall('select fl.*,g.thumb,g.title from ' . tablename('ewei_shop_fullback_log') . ' as fl
left join ' . tablename('ewei_shop_goods') . ' as g on g.id = fl.goodsid
left join ' . tablename('ewei_shop_order_goods') . (' as og on og.orderid = fl.orderid and og.goodsid = fl.goodsid
where 1 ' . $condition . ' group by fl.id order by fl.createtime desc LIMIT ') . ($pindex - 1) * $psize . ',' . $psize, $params);
$total = pdo_fetchcolumn('select count(1) from ' . tablename('ewei_shop_fullback_log') . (' as fl
where 1 ' . $condition . ' order by fl.createtime desc '), $params);
foreach ($list as &$row) {
$row['createtime'] = date('Y/m/d H:i:s', $row['createtime']);
$row['price'] = price_format($row['price'], 2);
$row['priceevery'] = price_format($row['priceevery'], 2);
if (0 < $row['optionid']) {
$optionname = pdo_get('ewei_shop_order_goods', array('optionid' => $row['optionid']), array('optionname'));
$row['optionname'] = $optionname['optionname'];
}
if ($row['fullbackday'] < $row['day']) {
$row['surplusday'] = $row['day'] - $row['fullbackday'];
$row['surplusprice'] = $row['priceevery'] * $row['fullbackday'];
}
else {
$row['surplusday'] = 0;
$row['surplusprice'] = $row['price'];
}
$row = set_medias($row, array('thumb'));
}
unset($row);
show_json(1, array('list' => $list, 'total' => $total, 'pagesize' => $psize));
}
}
?>

View File

@@ -1,75 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class History_EweiShopV2Page extends MobileLoginPage {
function main() {
global $_W, $_GPC;
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if ($merch_plugin && $merch_data['is_openmerch'])
{
include $this->template('merch/member/history');
}
else
{
include $this->template();
}
}
function get_list() {
global $_W, $_GPC;
$pindex = max(1, intval($_GPC['page']));
$psize = 10;
$condition = ' and f.uniacid = :uniacid and f.openid=:openid and f.deleted=0';
$params = array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']);
$sql = 'SELECT COUNT(*) FROM ' . tablename('ewei_shop_member_history') . " f where 1 {$condition}";
$total = pdo_fetchcolumn($sql, $params);
$sql = 'SELECT f.id,f.goodsid,g.title,g.thumb,g.marketprice,g.productprice,f.createtime,g.merchid FROM ' . tablename('ewei_shop_member_history') . ' f '
. ' left join ' . tablename('ewei_shop_goods') . ' g on f.goodsid = g.id '
. ' where 1 ' . $condition . ' ORDER BY `id` DESC LIMIT ' . ($pindex - 1) * $psize . ',' . $psize;
$list = pdo_fetchall($sql, $params);
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if (!empty($list) && $merch_plugin && $merch_data['is_openmerch'])
{
$merch_user = $merch_plugin->getListUser($list,'merch_user');
}
foreach ($list as &$row) {
$row['createtime'] = date('Y-m-d H:i:s', $row['createtime']);
$row['thumb'] = tomedia($row['thumb']);
$row['merchname'] = $merch_user[$row['merchid']]['merchname'] ? $merch_user[$row['merchid']]['merchname'] : $_W['shopset']['shop']['name'];
}
unset($row);
show_json(1, array('list' => $list, 'total' => $total, 'pagesize' => $psize));
}
function remove() {
global $_W, $_GPC;
$ids = $_GPC['ids'];
if (empty($ids) || !is_array($ids)) {
show_json(0, '参数错误');
}
foreach ($ids as &$id) {
$id = (int)$id;
}
$ids = array_unique(array_filter($ids));
if (empty($ids)) {
show_json(0, '参数错误');
}
$sql = "update " . tablename('ewei_shop_member_history') . ' set deleted=1 where openid=:openid and id in (' . implode(',', $ids) . ')';
pdo_query($sql, array(':openid' => $_W['openid']));
show_json(1);
}
}

View File

@@ -1,203 +0,0 @@
<?php if( !defined("IN_IA") )
{
exit( "Access Denied" );
}
class Index_EweiShopV2Page extends MobileLoginPage
{
public function main()
{
global $_W;
global $_GPC;
$usermembercard = false;
$member = m("member")->getMember($_W["openid"], true);
if( p("membercard") )
{
$list_membercard = p("membercard")->get_Mycard("", 0, 100);
$all_membercard = p("membercard")->get_Allcard(1, 100);
if( p("membercard") && $list_membercard["total"] <= 0 && $all_membercard["total"] <= 0 )
{
$usermembercard = false;
}
else
{
$usermembercard = true;
}
}
$level = m("member")->getLevel($_W["openid"]);
if( com("wxcard") )
{
$wxcardupdatetime = intval($member["wxcardupdatetime"]);
if( $wxcardupdatetime + 86400 < time() )
{
com_run("wxcard::updateMemberCardByOpenid", $_W["openid"]);
pdo_update("ewei_shop_member", array( "wxcardupdatetime" => time() ), array( "openid" => $_W["openid"] ));
}
}
$this->diypage("member");
$open_creditshop = p("creditshop") && $_W["shopset"]["creditshop"]["centeropen"];
$params = array( ":uniacid" => $_W["uniacid"], ":openid" => $_W["openid"] );
$merch_plugin = p("merch");
$merch_data = m("common")->getPluginset("merch");
if( $merch_plugin && $merch_data["is_openmerch"] )
{
$statics = array( "order_0" => pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and status=0 and (isparent=1 or (isparent=0 and parentid=0)) and paytype<>3 and uniacid=:uniacid and istrade=0 and userdeleted=0", $params), "order_1" => pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and (status=1 or (status=0 and paytype=3)) and isparent=0 and refundid=0 and uniacid=:uniacid and istrade=0 and userdeleted=0", $params), "order_2" => pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and (status=2 or (status=1 and sendtype>0)) and isparent=0 and refundid=0 and uniacid=:uniacid and istrade=0 and userdeleted=0", $params), "order_4" => pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and refundstate=1 and isparent=0 and uniacid=:uniacid and istrade=0 and userdeleted=0", $params), "cart" => pdo_fetchcolumn("select ifnull(sum(total),0) from " . tablename("ewei_shop_member_cart") . " where uniacid=:uniacid and openid=:openid and deleted=0", $params), "favorite" => pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_member_favorite") . " where uniacid=:uniacid and openid=:openid and deleted=0", $params) );
}
else
{
$statics = array( "order_0" => pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and ismr=0 and status=0 and isparent=0 and paytype<>3 and uniacid=:uniacid and istrade=0 and userdeleted=0", $params), "order_1" => pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and ismr=0 and (status=1 or (status=0 and paytype=3)) and isparent=0 and refundid=0 and uniacid=:uniacid and istrade=0 and userdeleted=0", $params), "order_2" => pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and ismr=0 and (status=2 or (status=1 and sendtype>0)) and isparent=0 and refundid=0 and uniacid=:uniacid and istrade=0 and userdeleted=0", $params), "order_4" => pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and ismr=0 and refundstate=1 and isparent=0 and uniacid=:uniacid and istrade=0 and userdeleted=0", $params), "order_5" => pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and ismr=0 and uniacid=:uniacid and iscycelbuy=1 and status in(0,1,2)", $params), "cart" => pdo_fetchcolumn("select ifnull(sum(total),0) from " . tablename("ewei_shop_member_cart") . " where uniacid=:uniacid and openid=:openid and deleted=0 and selected = 1", $params), "favorite" => ($merch_plugin && $merch_data["is_openmerch"] ? pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_member_favorite") . " where uniacid=:uniacid and openid=:openid and deleted=0 and `type`=0", $params) : pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_member_favorite") . " where uniacid=:uniacid and openid=:openid and deleted=0", $params)) );
}
$newstore_plugin = p("newstore");
if( $newstore_plugin )
{
$statics["norder_0"] = pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and ismr=0 and status=0 and isparent=0 and istrade=1 and uniacid=:uniacid", $params);
$statics["norder_1"] = pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and ismr=0 and status=1 and isparent=0 and istrade=1 and refundid=0 and uniacid=:uniacid", $params);
$statics["norder_3"] = pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and ismr=0 and status=3 and isparent=0 and istrade=1 and uniacid=:uniacid", $params);
$statics["norder_4"] = pdo_fetchcolumn("select count(*) from " . tablename("ewei_shop_order") . " where openid=:openid and ismr=0 and refundstate=1 and isparent=0 and istrade=1 and uniacid=:uniacid", $params);
}
$hascoupon = false;
$hascouponcenter = false;
$plugin_coupon = com("coupon");
if( $plugin_coupon )
{
$time = time();
$sql = "select count(*) from " . tablename("ewei_shop_coupon_data") . " d";
$sql .= " left join " . tablename("ewei_shop_coupon") . " c on d.couponid = c.id";
$sql .= " where d.openid=:openid and d.uniacid=:uniacid and d.used=0 ";
$sql .= " and ( (c.timelimit = 0 and ( c.timedays=0 or c.timedays*86400 + d.gettime >=unix_timestamp() ) ) or (c.timelimit =1 and c.timestart<=" . $time . " && c.timeend>=" . $time . ")) order by d.gettime desc";
$statics["coupon"] = pdo_fetchcolumn($sql, array( ":openid" => $_W["openid"], ":uniacid" => $_W["uniacid"] ));
$pcset = $_W["shopset"]["coupon"];
if( empty($pcset["closemember"]) )
{
$hascoupon = true;
}
if( empty($pcset["closecenter"]) )
{
$hascouponcenter = true;
}
if( $hascoupon )
{
$couponnum = com("coupon")->getCanGetCouponNum($_W["merchid"]);
}
}
$hasglobonus = false;
$plugin_globonus = p("globonus");
if( $plugin_globonus )
{
$plugin_globonus_set = $plugin_globonus->getSet();
$hasglobonus = !empty($plugin_globonus_set["open"]) && !empty($plugin_globonus_set["openmembercenter"]);
}
$haslive = false;
$haslive = p("live");
if( $haslive )
{
$live_set = $haslive->getSet();
$haslive = $live_set["ismember"];
}
$hasThreen = false;
$hasThreen = p("threen");
if( $hasThreen )
{
$plugin_threen_set = $hasThreen->getSet();
$hasThreen = !empty($plugin_threen_set["open"]) && !empty($plugin_threen_set["threencenter"]);
}
$hasauthor = false;
$plugin_author = p("author");
if( $plugin_author )
{
$plugin_author_set = $plugin_author->getSet();
$hasauthor = !empty($plugin_author_set["open"]) && !empty($plugin_author_set["openmembercenter"]);
}
$hasabonus = false;
$plugin_abonus = p("abonus");
if( $plugin_abonus )
{
$plugin_abonus_set = $plugin_abonus->getSet();
$hasabonus = !empty($plugin_abonus_set["open"]) && !empty($plugin_abonus_set["openmembercenter"]);
}
$card = m("common")->getSysset("membercard");
$actionset = m("common")->getSysset("memberCardActivation");
$haveverifygoods = m("verifygoods")->checkhaveverifygoods($_W["openid"]);
if( !empty($haveverifygoods) )
{
$verifygoods = m("verifygoods")->getCanUseVerifygoods($_W["openid"]);
}
$showcard = 0;
if( !empty($card) )
{
$membercardid = $member["membercardid"];
if( !empty($membercardid) && $card["card_id"] == $membercardid )
{
$cardtag = "查看微信会员卡信息";
$showcard = 1;
}
else
{
if( !empty($actionset["centerget"]) )
{
$showcard = 1;
$cardtag = "领取微信会员卡";
}
}
}
$hasqa = false;
$plugin_qa = p("qa");
if( $plugin_qa )
{
$plugin_qa_set = $plugin_qa->getSet();
if( !empty($plugin_qa_set["showmember"]) )
{
$hasqa = true;
}
}
$hassign = false;
$com_sign = p("sign");
if( $com_sign )
{
$com_sign_set = $com_sign->getSet();
if( !empty($com_sign_set["iscenter"]) && !empty($com_sign_set["isopen"]) )
{
$hassign = (empty($_W["shopset"]["trade"]["credittext"]) ? "积分" : $_W["shopset"]["trade"]["credittext"]);
$hassign .= (empty($com_sign_set["textsign"]) ? "签到" : $com_sign_set["textsign"]);
}
}
$hasLineUp = false;
$lineUp = p("lineup");
if( $lineUp )
{
$lineUpSet = $lineUp->getSet();
if( !empty($lineUpSet["isopen"]) && !empty($lineUpSet["mobile_show"]) )
{
$hasLineUp = true;
}
}
$wapset = m("common")->getSysset("wap");
$appset = m("common")->getSysset("app");
$needbind = false;
if( (empty($member["mobileverify"]) || empty($member["mobile"])) && (empty($_W["shopset"]["app"]["isclose"]) && !empty($_W["shopset"]["app"]["openbind"]) || !empty($_W["shopset"]["wap"]["open"]) || $hasThreen) )
{
$needbind = true;
}
if( p("mmanage") )
{
$roleuser = pdo_fetch("SELECT id, uid, username, status FROM" . tablename("ewei_shop_perm_user") . "WHERE openid=:openid AND uniacid=:uniacid AND status=1 LIMIT 1", array( ":openid" => $_W["openid"], ":uniacid" => $_W["uniacid"] ));
}
$hasFullback = true;
$ishidden = m("common")->getSysset("fullback");
if( $ishidden["ishidden"] == true )
{
$hasFullback = false;
}
$hasdividend = false;
$plugin_dividend = p("dividend");
if( $plugin_dividend )
{
$plugin_dividend_set = $plugin_dividend->getSet();
if( !empty($plugin_dividend_set["open"]) && !empty($plugin_dividend_set["membershow"]) )
{
$hasdividend = true;
}
}
include($this->template());
}
}
?>

View File

@@ -1,139 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Info_EweiShopV2Page extends MobileLoginPage
{
protected $member;
public function __construct()
{
global $_W;
global $_GPC;
parent::__construct();
$this->member = m('member')->getInfo($_W['openid']);
}
protected function diyformData()
{
$template_flag = 0;
$diyform_plugin = p('diyform');
if ($diyform_plugin) {
$set_config = $diyform_plugin->getSet();
$user_diyform_open = $set_config['user_diyform_open'];
if ($user_diyform_open == 1) {
$template_flag = 1;
$diyform_id = $set_config['user_diyform'];
if (!empty($diyform_id)) {
$formInfo = $diyform_plugin->getDiyformInfo($diyform_id);
$fields = $formInfo['fields'];
$diyform_data = iunserializer($this->member['diymemberdata']);
$f_data = $diyform_plugin->getDiyformData($diyform_data, $fields, $this->member);
}
}
}
return array('template_flag' => $template_flag, 'set_config' => $set_config, 'diyform_plugin' => $diyform_plugin, 'formInfo' => $formInfo, 'diyform_id' => $diyform_id, 'diyform_data' => $diyform_data, 'fields' => $fields, 'f_data' => $f_data);
}
public function main()
{
global $_W;
global $_GPC;
$diyform_data = $this->diyformData();
extract($diyform_data);
$returnurl = urldecode(trim($_GPC['returnurl']));
$member = $this->member;
$wapset = m('common')->getSysset('wap');
$area_set = m('util')->get_area_config_set();
$new_area = intval($area_set['new_area']);
$show_data = 1;
if (!empty($new_area) && empty($member['datavalue']) || empty($new_area) && !empty($member['datavalue'])) {
$show_data = 0;
}
include $this->template();
}
public function submit()
{
global $_W;
global $_GPC;
$diyform_data = $this->diyformData();
extract($diyform_data);
$memberdata = $_GPC['memberdata'];
if ($template_flag == 1) {
$data = array();
$m_data = array();
$mc_data = array();
$insert_data = $diyform_plugin->getInsertData($fields, $memberdata);
$data = $insert_data['data'];
$m_data = $insert_data['m_data'];
$mc_data = $insert_data['mc_data'];
$m_data['diymemberid'] = $diyform_id;
$m_data['diymemberfields'] = iserializer($fields);
$m_data['diymemberdata'] = $data;
unset($mc_data['credit1']);
unset($m_data['credit2']);
pdo_update('ewei_shop_member', $m_data, array('openid' => $_W['openid'], 'uniacid' => $_W['uniacid']));
if (!empty($this->member['uid'])) {
if (!empty($mc_data)) {
unset($mc_data['credit1']);
unset($mc_data['credit2']);
m('member')->mc_update($this->member['uid'], $mc_data);
}
}
}
else {
$arr = array('realname' => trim($memberdata['realname']), 'weixin' => trim($memberdata['weixin']), 'birthyear' => intval($memberdata['birthyear']), 'birthmonth' => intval($memberdata['birthmonth']), 'birthday' => intval($memberdata['birthday']), 'province' => trim($memberdata['province']), 'city' => trim($memberdata['city']), 'datavalue' => trim($memberdata['datavalue']), 'mobile' => trim($memberdata['mobile']), 'nickname' => trim($memberdata['nickname']), 'avatar' => trim($memberdata['avatar']));
if (empty($_W['shopset']['app']['isclose']) && !empty($_W['shopset']['app']['openbind']) || !empty($_W['shopset']['wap']['open'])) {
unset($arr['mobile']);
}
pdo_update('ewei_shop_member', $arr, array('openid' => $_W['openid'], 'uniacid' => $_W['uniacid']));
if (!empty($this->member['uid'])) {
$mcdata = $_GPC['mcdata'];
unset($mcdata['credit1']);
unset($mcdata['credit2']);
m('member')->mc_update($this->member['uid'], $mcdata);
}
}
show_json(1);
}
public function face()
{
global $_W;
global $_GPC;
$member = $this->member;
if ($_W['ispost']) {
$nickname = trim($_GPC['nickname']);
$avatar = trim($_GPC['avatar']);
if (empty($nickname)) {
show_json(0, '请填写昵称');
}
if (empty($avatar)) {
show_json(0, '请上传头像');
}
pdo_update('ewei_shop_member', array('avatar' => $avatar, 'nickname' => $nickname), array('id' => $member['id'], 'uniacid' => $_W['uniacid']));
show_json(1);
}
include $this->template();
}
}
?>

View File

@@ -1,60 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Log_EweiShopV2Page extends MobileLoginPage
{
public function main()
{
global $_W;
global $_GPC;
$_GPC['type'] = intval($_GPC['type']);
include $this->template();
}
public function get_list()
{
global $_W;
global $_GPC;
$type = intval($_GPC['type']);
$pindex = max(1, intval($_GPC['page']));
$psize = 10;
$apply_type = array(0 => '微信钱包', 2 => '支付宝', 3 => '银行卡');
$condition = ' and openid=:openid and uniacid=:uniacid and type=:type';
$params = array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid'], ':type' => intval($_GPC['type']));
$uidinfo = M('member')->getInfo($_W['openid']);
$uid = $uidinfo['uid'];
$credit_condition = ' and r.uniacid=' . $_W['uniacid'] . ' and r.credittype=\'credit2\' and r.uid = ' . $uid . ' and r.num > 0 and remark not like \'%充值%\' order by r.createtime desc LIMIT ';
if (0 < $uid) {
$r = pdo_fetchall('select m.uid,m.mobile,m.nickname,r.remark title,r.num money,r.createtime from ' . tablename('ewei_shop_member_credit_record') . 'r left join ' . tablename('ewei_shop_member') . ' m on m.uid = r.uid where 1 ' . $credit_condition . ($pindex - 1) * $psize . ',' . $psize);
foreach ($r as &$item) {
$item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
$item['rechargetype'] = 'credit';
}
unset($item);
}
$list = pdo_fetchall('select * from ' . tablename('ewei_shop_member_log') . (' where 1 ' . $condition . ' order by createtime desc LIMIT ') . ($pindex - 1) * $psize . ',' . $psize, $params);
$total = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_member_log') . (' where 1 ' . $condition), $params);
foreach ($list as &$row) {
$row['createtime'] = date('Y-m-d H:i', $row['createtime']);
$row['typestr'] = $apply_type[$row['applytype']];
}
unset($row);
if (is_array($r)) {
$list = array_merge($r, $list);
}
show_json(1, array('list' => $list, 'total' => $total, 'pagesize' => $psize));
}
}
?>

View File

@@ -1,47 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Notice_EweiShopV2Page extends MobileLoginPage
{
public function main()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$member = m('member')->getMember($openid);
$notice = iunserializer($member['noticeset']);
$hascommission = false;
if (p('commission')) {
$cset = p('commission')->getSet();
$hascommission = !empty($cset['level']);
}
if ($_W['ispost']) {
$type = trim($_GPC['type']);
if (empty($type)) {
show_json(0, '参数错误');
}
$checked = intval($_GPC['checked']);
if (empty($checked)) {
$notice[$type] = 1;
}
else {
unset($notice[$type]);
}
pdo_update('ewei_shop_member', array('noticeset' => iserializer($notice)), array('openid' => $openid, 'uniacid' => $uniacid));
show_json(1);
}
include $this->template();
}
}
?>

View File

@@ -1,222 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
function ranksort($a,$b){
return ($a['credit1'] > $b['credit1']) ? -1 : 1;
}
class Rank_EweiShopV2Page extends MobileLoginPage {
protected function status()
{
global $_W;
if( empty($_W['shopset']['rank']['status'])){
$err = '未开启积分排名';
if($_W['isajax']) {
show_json(0, $err);
}
$this->message($err, '','error');
}
}
protected function getRank($update = false)
{
global $_W;
$rank_cache = m('cache')->getArray('member_rank');
if (empty($rank_cache) || $rank_cache['time'] < TIMESTAMP || $update)
{
$num = intval($_W['shopset']['rank']['num']);
$result = pdo_fetchall("SELECT sm.id,sm.uid,m.credit1,sm.nickname,sm.avatar,sm.openid FROM ".tablename('ewei_shop_member')." sm RIGHT JOIN ".tablename('mc_members')." m ON m.uid=sm.uid WHERE sm.uniacid = :uniacid ORDER BY m.credit1 DESC LIMIT {$num}",array(':uniacid'=>$_W['uniacid']));
$result1 = pdo_fetchall("SELECT id,uid,credit1,nickname,avatar,openid FROM ".tablename('ewei_shop_member')." WHERE uniacid = :uniacid AND uid=0 ORDER BY credit1 DESC LIMIT {$num}",array(':uniacid'=>$_W['uniacid']));
foreach ($result1 as $key=>$value){
$result1[$key]['avatar']=tomedia($value['avatar']);
}
$result = array_merge($result,$result1);
usort($result,"ranksort");
$result = array_slice($result,0,$num);
m('cache')->set('member_rank',array('time'=>TIMESTAMP+3600,'result'=>$result));
}
return $rank_cache;
}
public function main() {
global $_W, $_GPC;
$this->status();
$user = m('member')->getMember($_W['openid'],true);
$rank_cache = $this->getRank();
$result = $rank_cache['result'];
$paiming = 0;
foreach ($result as $key=>$val){
if ($val['openid'] == $_W['openid']) {
$paiming += $key+1;
}
}
$num = intval($_W['shopset']['rank']['num']);
$user['credit1'] = intval($user['credit1']);
$user['paiming'] = empty($paiming) ? '未上榜' : $paiming;
$seven=$this->creditChange($user['uid'],'credit1',7,$_W['openid']);
$user['seven'] = empty($seven) ? 0 : $seven;
include $this->template();
}
public function ajaxpage()
{
global $_W,$_GPC;
$this->status();
$pindex = max(1, (int)$_GPC['page']);
$psize = 20;
$num = intval($_W['shopset']['rank']['num']);
if($num<=0){
$num = 50;
}
$stop = false;
if ( $pindex*$psize >=$num)
{
$psize = $num%$psize == 0 ? 20 : $num%$psize;
$pindex = ceil($num/$psize);
$stop = true;
}
$rank_cache = $this->getRank();
$result = $rank_cache['result'];
$result = array_slice($result,($pindex - 1) * $psize,$psize);
show_json(1,array('list'=>$result,'stop'=>$stop));
}
protected function creditChange($uid,$credittype='credit1',$day=7,$openid='')
{
global $_W;
$day = (int)$day;
if ($day != 0) {
$createtime1 = strtotime(date('Y-m-d', time() - $day * 3600 * 24));
$createtime2 = strtotime(date('Y-m-d', time()));
} else {
$createtime1 = strtotime(date('Y-m-d', time()));
$createtime2 = strtotime(date('Y-m-d', time() + 3600 * 24));
}
if($uid){
$sql = 'select sum(num) from ' . tablename('mc_credits_record') . ' where uniacid = :uniacid and uid = :uid and credittype = :credittype and `module` = "ewei_shopv2" and createtime between :createtime1 and :createtime2 and uid<>0';
$param = array(
':uniacid' => $_W['uniacid'],
':uid' => (int)$uid,
':createtime1' => $createtime1,
':createtime2' => $createtime2,
':credittype' => $credittype,
);
}else{
$sql = 'select sum(num) from ' . tablename('ewei_shop_member_credit_record') . ' where uniacid = :uniacid and openid = :openid and credittype = :credittype and createtime between :createtime1 and :createtime2';
$param = array(
':uniacid' => $_W['uniacid'],
':openid' => $openid,
':createtime1' => $createtime1,
':createtime2' => $createtime2,
':credittype' => $credittype,
);
}
return pdo_fetchcolumn($sql, $param);
}
protected function orderStatus()
{
global $_W;
if( empty($_W['shopset']['rank']['order_status'])){
$err = '未开启订单排名';
if($_W['isajax']) {
show_json(0, $err);
}
$this->message($err, '','error');
}
}
public function order_rank()
{
global $_W, $_GPC;
$this->orderStatus();
$user = m('member')->getMember($_W['openid'],true);
$result_one = pdo_fetch("select a.openid, sum(price) as price,a.uniacid,a.status
from (
(select openid, sum(price) price,uniacid,status from ".tablename('ewei_shop_order')." where uniacid = :uniacid and status >= 1 group by openid)
union all (select openid, sum(price+freight) price,uniacid,status from ".tablename('ewei_shop_groups_order')." where uniacid = :uniacid and status >= 1 group by openid)
) a where a.openid = :openid group by a.openid ",
array(':uniacid'=>$_W['uniacid'],':openid'=>$user['openid']));
$result_all = pdo_fetchall("select a.openid, sum(price) as price,a.uniacid,a.status
from (
(select openid, sum(price) price,uniacid,status from ".tablename('ewei_shop_order')." where uniacid = :uniacid and status >= 1 group by openid)
union all (select openid, sum(price+freight) price,uniacid,status from ".tablename('ewei_shop_groups_order')." where uniacid = :uniacid and status >= 1 group by openid)
) a group by a.openid HAVING price>=:price ORDER BY price DESC",
array(':uniacid'=>$_W['uniacid'],':price'=>$result_one['price']));
foreach ($result_all as $k => $v){
$res = m('member')->getMember($v['openid']);
if (empty($res)){
unset($result_all[$k]);
}
}
$user['paiming'] = count($result_all);
$seven=$this->orderChange($user['openid']);
$user['seven'] = empty($seven) ? 0 : $seven;
include $this->template('member/order_rank');
}
public function ajaxorderpage()
{
global $_W,$_GPC;
$this->orderStatus();
$pindex = max(1, (int)$_GPC['page']);
$psize = 20;
$num = intval($_W['shopset']['rank']['order_num']);
if($num<=0){
$num = 50;
}
$stop = false;
if ( $pindex*$psize >=$num)
{
$psize = $num%$psize == 0 ? 20 : $num%$psize;
$pindex = ceil($num/$psize);
$stop = true;
}
$limit = ' LIMIT ' . ($pindex - 1) * $psize . ',' . $psize;
$condition = " and o.uniacid=:uniacid";
$condition1=' and m.uniacid=:uniacid';
$sql = "SELECT m.id,m.uid,m.nickname,m.avatar,m.openid,"
. "(select ifnull(sum(o.price),0) from " . tablename('ewei_shop_order') . " o where o.openid=m.openid and o.status>=1 {$condition}) as price"
. " from " . tablename('ewei_shop_member') . " m "
. " where 1 {$condition1} order by price desc,createtime desc".$limit;
$result = pdo_fetchall($sql, array(':uniacid'=>$_W['uniacid']));
show_json(1,array('list'=>$result,'stop'=>$stop));
}
protected function orderChange($openid,$day=7)
{
global $_W;
$day = (int)$day;
if ($day != 0) {
$createtime1 = strtotime(date('Y-m-d', time() - $day * 3600 * 24));
$createtime2 = strtotime(date('Y-m-d', time() + 3600 * 24));
} else {
$createtime1 = strtotime(date('Y-m-d', time()));
$createtime2 = strtotime(date('Y-m-d', time() + 3600 * 24));
}
$sql = 'select sum(price) from ' . tablename('ewei_shop_order') . ' where uniacid = :uniacid and openid = :openid and status >= 1 and createtime between :createtime1 and :createtime2';
$param = array(
':uniacid' => $_W['uniacid'],
':openid' => $openid,
':createtime1' => $createtime1,
':createtime2' => $createtime2,
);
return pdo_fetchcolumn($sql, $param);
}
}

View File

@@ -1,307 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Recharge_EweiShopV2Page extends MobileLoginPage {
function main() {
global $_W, $_GPC;
$set = $_W['shopset'];
$set['pay']['weixin'] = !empty($set['pay']['weixin_sub']) ? 1 : $set['pay']['weixin'];
$set['pay']['weixin_jie'] = !empty($set['pay']['weixin_jie_sub']) ? 1 : $set['pay']['weixin_jie'];
$sec = m('common')->getSec();
$sec =iunserializer($sec['sec']);
$status = 1;
if (!empty($set['trade']['closerecharge'])) {
$this->message('系统未开启充值!', '', 'error');
}
if (empty($set['trade']['minimumcharge'])) {
$minimumcharge = 0;
} else {
$minimumcharge = $set['trade']['minimumcharge'];
}
$credit = m('member')->getCredit($_W['openid'], 'credit2');
$wechat = array('success' => false);
if (is_weixin()) {
$data = m('common')->getSysset('pay');
if (isset($set['pay']) && $set['pay']['weixin'] == 1 && !empty($data['weixin_id'])) {
list(,$payment) = m('common')->public_build();
if ($payment['is_new']){
if ($payment['type'] == 2 || $payment['type'] == 3){
if (!empty($payment['sub_appsecret'])){
m('member')->wxuser($payment['sub_appid'],$payment['sub_appsecret']);
}
}
}
if (is_array($payment) && !is_error($payment)) {
$wechat['success'] = true;
}elseif ($set['pay']['weixin']){
$wechat['success'] = true;
}
}
if (isset($set['pay']) && $set['pay']['weixin_jie'] == 1 && !$wechat['success']) {
if (!empty($set['pay']['weixin_jie_sub']) && !empty($sec['sub_secret_jie_sub'])){
m('member')->wxuser($sec['sub_appid_jie_sub'],$sec['sub_secret_jie_sub']);
}elseif(!empty($sec['secret'])){
m('member')->wxuser($sec['appid'],$sec['secret']);
}
$wechat['success'] = true;
}
}
$alipay = array('success' => false);
if (isset($set['pay']['alipay']) && $set['pay']['alipay'] == 1) {
load()->model('payment');
$setting = uni_setting($_W['uniacid'], array('payment'));
if (is_array($setting['payment']['alipay']) && ($setting['payment']['alipay']['switch'] || $setting['payment']['alipay']['recharge_switch'])) {
$alipay['success'] = true;
}
}
$acts = com_run('sale::getRechargeActivity');
if(is_h5app()){
$payinfo = array(
'wechat' => !empty($sec['app_wechat']['merchname']) && !empty($set['pay']['app_wechat']) && !empty($sec['app_wechat']['appid']) && !empty($sec['app_wechat']['appsecret']) && !empty($sec['app_wechat']['merchid']) && !empty($sec['app_wechat']['apikey']) ? true : false,
'alipay' => false,
'mcname' => $sec['app_wechat']['merchname'],
'aliname' => empty($_W['shopset']['shop']['name']) ? $sec['app_wechat']['merchname'] : $_W['shopset']['shop']['name'],
'logno' => null,
'money' => null,
'attach' => $_W['uniacid'] . ":1",
'type' => 1
);
if( !empty($set['pay']['app_alipay']) && ( !empty($sec['app_alipay']['public_key'])|| !empty($sec['app_alipay']['public_key_rsa2']) ) ){
$payinfo['alipay']=true;
}
}
include $this->template();
}
function submit() {
global $_W, $_GPC;
$set = $_W['shopset'];
if (empty($set['trade']['minimumcharge'])||$set['trade']['minimumcharge']<=0) {
$minimumcharge = 1;
} else {
$minimumcharge = $set['trade']['minimumcharge'];
}
$money = floatval($_GPC['money']);
if ($money <= 0) {
show_json(0, '充值金额必须大于0!');
}
if ($money < $minimumcharge && $minimumcharge > 0) {
show_json(0, '最低充值金额为' .$minimumcharge . '元!');
}
if (empty($money)) {
show_json(0, '请填写充值金额!');
}
$sql = "DELETE FROM " . tablename('ewei_shop_member_log') . " WHERE openid= '{$_W['openid']}' AND status = 0 AND uniacid = {$_W['uniacid']} AND createtime < (unix_timestamp()-86400)";
pdo_fetch($sql);
$logno = m('common')->createNO('member_log', 'logno', 'RC');
$log = array(
'uniacid' => $_W['uniacid'],
'logno' => $logno,
'title' => $set['shop']['name'] . "会员充值",
'openid' => $_W['openid'],
'money'=>$money,
'type' => 0,
'createtime' => time(),
'status' => 0,
'couponid' => intval($_GPC['couponid'])
);
pdo_insert('ewei_shop_member_log', $log);
$logid = pdo_insertid();
$type = $_GPC['type'];
if (empty($logid) || (int)$logid<1) {
show_json(0, '充值订单创建失败请重试!');
}
if(is_h5app()){
show_json(1, array(
'logno'=>$logno,
'money'=>$money
));
}
$set = m('common')->getSysset(array('shop', 'pay'));
$set['pay']['weixin'] = !empty($set['pay']['weixin_sub']) ? 1 : $set['pay']['weixin'];
$set['pay']['weixin_jie'] = !empty($set['pay']['weixin_jie_sub']) ? 1 : $set['pay']['weixin_jie'];
if ($type == 'wechat') {
if (!is_weixin()) {
show_json(0, '非微信环境!');
}
if (empty($set['pay']['weixin'])&&empty($set['pay']['weixin_jie'])) {
show_json(0, '未开启微信支付!');
}
$wechat = array('success' => false);
$jie = intval($_GPC['jie']);
$params = array();
$params['tid'] = $log['logno'];
$params['user'] = $_W['openid'];
$params['fee'] = $money;
$params['title'] = $log['title'];
if (isset($set['pay']) && $set['pay']['weixin'] == 1&&$jie!==1) {
load()->model('payment');
$setting = uni_setting($_W['uniacid'], array('payment'));
$options = array();
if (is_array($setting['payment'])) {
$options = $setting['payment']['wechat'];
$options['appid'] = $_W['account']['key'];
$options['secret'] = $_W['account']['secret'];
}
$wechat = m('common')->wechat_build($params, $options, 1);
if (!is_error($wechat)) {
$wechat['success'] = true;
if (!empty($wechat['code_url'])){
$wechat['weixin_jie'] = true;
}else{
$wechat['weixin'] = true;
}
}
}
if ((isset($set['pay']) && $set['pay']['weixin_jie'] == 1&& !$wechat['success'])||$jie===1) {
$params['tid'] = $params['tid'].'_borrow';
$sec = m('common')->getSec();
$sec =iunserializer($sec['sec']);
$options = array();
$options['appid'] = $sec['appid'];
$options['mchid'] = $sec['mchid'];
$options['apikey'] = $sec['apikey'];
if (!empty($set['pay']['weixin_jie_sub']) && !empty($sec['sub_secret_jie_sub'])){
$wxuser = m('member')->wxuser($sec['sub_appid_jie_sub'],$sec['sub_secret_jie_sub']);
$params['openid'] = $wxuser['openid'];
}elseif(!empty($sec['secret'])){
$wxuser = m('member')->wxuser($sec['appid'],$sec['secret']);
$params['openid'] = $wxuser['openid'];
}
$wechat = m('common')->wechat_native_build($params, $options, 1);
if (!is_error($wechat)) {
$wechat['success'] = true;
if (!empty($params['openid'])){
$wechat['weixin'] = true;
}else{
$wechat['weixin_jie'] = true;
}
}
}
$wechat['jie'] = $jie;
if (!$wechat['success']) {
show_json(0, '微信支付参数错误!');
}
show_json(1, array(
'wechat' => $wechat,
'logid' => $logid
));
} else if ($type == 'alipay') {
$alipay = array('success' => false);
$params = array();
$params['tid'] = $log['logno'];
$params['user'] = $_W['openid'];
$params['fee'] = $money;
$params['title'] = $log['title'];
load()->func('communication');
load()->model('payment');
$setting = uni_setting($_W['uniacid'], array('payment'));
if (is_array($setting['payment'])) {
$options = $setting['payment']['alipay'];
$alipay = m('common')->alipay_build($params, $options, 1, $_W['openid']);
if (!empty($alipay['url'])) {
$alipay['url'] = urlencode($alipay['url']);
$alipay['success'] = true;
}
}
list(,$payment) = m('common')->public_build();
if ($payment['type'] == '4'){
$params = array(
'service' => 'pay.alipay.native',
'body' => $params['title'],
'out_trade_no' => $params['tid'],
'total_fee' => $money
);
if (!empty($order['ordersn2'])) {
$params['out_trade_no'] = $log['logno'] . '_B';
} else {
$params['out_trade_no'] = $log['logno'] . '_borrow';
}
$redis = redis();
if (!is_error($redis)) {
$cacheResult = $redis->get($params['tid']);
$cacheResult = json_decode($cacheResult, true);
if ($cacheResult['service'] == $params['service'] && $params['total_fee'] == $cacheResult['total_fee']) {
$AliPay = $cacheResult['result'];
}
}
if (empty($Alipay)) {
$AliPay = m('pay')->build($params, $payment, 1);
}
if (!empty($AliPay) && !is_error($AliPay)){
$alipay['url'] = urlencode($AliPay['code_url']);
$alipay['success'] = true;
}
}
show_json(1, array('alipay' => $alipay,'logid' => $logid, 'logno'=>$logno));
}
show_json(0, '未找到支付方式');
}
function wechat_complete() {
global $_W, $_GPC;
$logid = intval($_GPC['logid']);
$log = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_member_log') . ' WHERE `id`=:id and `uniacid`=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':id' => $logid));
if(empty($log)){
$logno = intval($_GPC['logno']);
$log = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_member_log') . ' WHERE `logno`=:logno and `uniacid`=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':logno' => $logno));
}
if (!empty($log)) {
if (empty($log['status']))
{
show_json(0);
}
else
{
if($_W['ispost']){
show_json(1);
}else{
header('location: ' . mobileUrl('member'));
}
}
}
if($_W['ispost']){
show_json(0);
}else{
header('location: ' . mobileUrl('member'));
}
}
public function getstatus(){
global $_W, $_GPC;
$logno = $_GPC['logno'];
$log = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_member_log') . ' WHERE `logno`=:logno and `uniacid`=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':logno' => $logno));
if (!empty($log) && !empty($log['status'])) {
show_json(1);
}else{
show_json(0);
}
}
}

View File

@@ -1,255 +0,0 @@
<?php
//20200628
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Withdraw_EweiShopV2Page extends MobileLoginPage {
function main() {
global $_W, $_GPC;
//参数
$set = $_W['shopset']['trade'];
$status = 1;
$openid = $_W['openid'];
if (empty($set['withdraw'])) {
$this->message('系统未开启提现!', '', 'error');
}
$withdrawcharge = $set['withdrawcharge'];
$withdrawbegin = floatval($set['withdrawbegin']);
$withdrawend = floatval($set['withdrawend']);
$withdrawmoney = 0;
if(floatval($set['withdrawmoney']) > 0) $withdrawmoney = floatval($set['withdrawmoney']);
//当前余额
$credit = m('member')->getCredit($_W['openid'], 'credit2');
$last_data = $this->getLastApply($openid);
// 判断openid是否是微信公众号的
$canusewechat = !strexists($openid, 'wap_user_') && !strexists($openid, 'sns_qq_') && !strexists($openid, 'sns_wx_') && !strexists($openid, 'sns_wa_');
//提现方式
$type_array = array();
if($set['withdrawcashweixin'] == 1 && $canusewechat) {
$type_array[0]['title'] = '提现到微信钱包';
}
if($set['withdrawcashalipay'] == 1) {
$type_array[2]['title'] = '提现到支付宝';
if (!empty($last_data)) {
if ($last_data['applytype'] != 2) {
$type_last = $this->getLastApply($openid, 2);
if (!empty($type_last)) {
$last_data['alipay'] = $type_last['alipay'];
}
}
}
}
if($set['withdrawcashcard'] == 1) {
$type_array[3]['title'] = '提现到银行卡';
if (!empty($last_data)) {
if ($last_data['applytype'] != 3) {
$type_last = $this->getLastApply($openid, 3);
if (!empty($type_last)) {
$last_data['bankname'] = $type_last['bankname'];
$last_data['bankcard'] = $type_last['bankcard'];
}
}
}
$condition = " and uniacid=:uniacid";
$params = array(':uniacid' => $_W['uniacid']);
$banklist = pdo_fetchall("SELECT * FROM " . tablename('ewei_shop_commission_bank') . " WHERE 1 {$condition} ORDER BY displayorder DESC", $params);
}
if (!empty($last_data)) {
if (array_key_exists($last_data['applytype'], $type_array)) {
$type_array[$last_data['applytype']]['checked'] = 1;
}
}
include $this->template();
}
function submit() {
global $_W, $_GPC;
$set = $_W['shopset']['trade'];
if (empty($set['withdraw'])) {
show_json(0,'系统未开启提现!');
}
$set_array = array();
$set_array['charge'] = $set['withdrawcharge'];
$set_array['begin'] = floatval($set['withdrawbegin']);
$set_array['end'] = floatval($set['withdrawend']);
$money = floatval($_GPC['money']);
$credit = m('member')->getCredit($_W['openid'], 'credit2');
if($money <= 0){
show_json(0,'提现金额错误!');
}
if ($money > $credit) {
show_json(0, '提现金额过大!');
}
//高并发下单支付库款多次的问题
$open_redis = function_exists('redis') && !is_error(redis());
if( $open_redis ) {
$redis_key = "{$_W['uniacid']}_member_withdraw__pay_{$_W['openid']}";
$redis = redis();
if (!is_error($redis)) {
if($redis->get($redis_key)) {
show_json(0,'请勿重复点击');
}
$redis->setex($redis_key, 1,time());
}
}
//生成申请
$apply = array();
//提现方式
$type_array = array();
if($set['withdrawcashweixin'] == 1) {
$type_array[0]['title'] = '提现到微信钱包';
}
if($set['withdrawcashalipay'] == 1) {
$type_array[2]['title'] = '提现到支付宝';
}
if($set['withdrawcashcard'] == 1) {
$type_array[3]['title'] = '提现到银行卡';
$condition = " and uniacid=:uniacid";
$params = array(':uniacid' => $_W['uniacid']);
$banklist = pdo_fetchall("SELECT * FROM " . tablename('ewei_shop_commission_bank') . " WHERE 1 {$condition} ORDER BY displayorder DESC", $params);
}
$applytype = intval($_GPC['applytype']);
if (!array_key_exists($applytype, $type_array)) {
show_json(0, '未选择提现方式,请您选择提现方式后重试!');
}
if ($applytype == 2) {
//支付宝
$realname = trim($_GPC['realname']);
$alipay = trim($_GPC['alipay']);
$alipay1 = trim($_GPC['alipay1']);
if (empty($realname)) {
show_json(0, '请填写姓名!');
}
if (empty($alipay)) {
show_json(0, '请填写支付宝帐号!');
}
if (empty($alipay1)) {
show_json(0, '请填写确认帐号!');
}
if ($alipay != $alipay1) {
show_json(0, '支付宝帐号与确认帐号不一致!');
}
$apply['realname'] = $realname;
$apply['alipay'] = $alipay;
} else if ($applytype == 3) {
//银行卡号
$realname = trim($_GPC['realname']);
$bankname = trim($_GPC['bankname']);
$bankcard = trim($_GPC['bankcard']);
$bankcard1 = trim($_GPC['bankcard1']);
$bankopen = trim($_GPC['openbank']);
if (empty($realname)) {
show_json(0, '请填写姓名!');
}
if (empty($bankname)) {
show_json(0, '请选择银行!');
}
if (empty($bankopen)) {
show_json(0, '请填写开户行!');
}
if (empty($bankcard)) {
show_json(0, '请填写银行卡号!');
}
if (empty($bankcard1)) {
show_json(0, '请填写确认卡号!');
}
if ($bankcard != $bankcard1) {
show_json(0, '银行卡号与确认卡号不一致!');
}
$apply['realname'] = $realname;
$apply['bankname'] = $bankname;
$apply['bankcard'] = $bankcard;
$apply['bankopen'] = $bankopen;
}
$realmoney = $money;
if (!empty($set_array['charge'])) {
$money_array = m('member')->getCalculateMoney($money, $set_array);
if($money_array['flag']) {
$realmoney = $money_array['realmoney'];
$deductionmoney = $money_array['deductionmoney'];
}
}
m('member')->setCredit($_W['openid'], 'credit2', -$money, array(0,$_W['shopset']['set'][''].'余额提现预扣除: ' . $money . ',实际到账金额:' . $realmoney . ',手续费金额:' . $deductionmoney ));
$logno = m('common')->createNO('member_log', 'logno', 'RW');
$apply['uniacid'] = $_W['uniacid'];
$apply['logno'] = $logno;
$apply['openid'] = $_W['openid'];
$apply['title'] = '余额提现';
$apply['type'] = 1;
$apply['createtime'] = time();
$apply['status'] = 0;
$apply['money'] = $money;
$apply['realmoney'] = $realmoney;
$apply['deductionmoney'] = $deductionmoney;
$apply['charge'] = $set_array['charge'];
$apply['applytype'] = $applytype;
pdo_insert('ewei_shop_member_log', $apply);
$logid = pdo_insertid();
if (empty($logid)) {
m('member')->setCredit($_W['openid'], 'credit2', $money, array(0,$_W['shopset']['set'][''].'余额提现申请失败,余额退回: ' . $money ));
}
//模板消息
m('notice')->sendMemberLogMessage($logid);
show_json(1);
}
function getLastApply($openid, $applytype = -1)
{
global $_W;
$params = array(':uniacid' => $_W['uniacid'],':openid'=>$openid);
$sql = "select applytype,alipay,bankname,bankcard,realname from " . tablename('ewei_shop_member_log') . " where openid=:openid and uniacid=:uniacid";
if ($applytype > -1) {
$sql .= " and applytype=:applytype";
$params[':applytype'] = $applytype;
}
$sql .= " order by id desc Limit 1";
$data = pdo_fetch($sql, $params);
return $data;
}
}

View File

@@ -1,108 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Comment_EweiShopV2Page extends MobileLoginPage
{
public function __construct()
{
parent::__construct();
$trade = m('common')->getSysset('trade');
if (!empty($trade['closecomment'])) {
$this->message('不允许评论!', '', 'error');
}
}
public function main()
{
global $_W;
global $_GPC;
$uniacid = $_W['uniacid'];
$openid = $_W['openid'];
$orderid = intval($_GPC['id']);
$order = pdo_fetch('select id,status,iscomment from ' . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1', array(':id' => $orderid, ':uniacid' => $uniacid, ':openid' => $openid));
if (empty($order)) {
header('location: ' . mobileUrl('order'));
exit();
}
if (($order['status'] != 3) && ($order['status'] != 4)) {
$this->message('订单未收货,不能评价!', mobileUrl('order/detail', array('id' => $orderid)));
}
if (2 <= $order['iscomment']) {
$this->message('您已经评价过了!', mobileUrl('order/detail', array('id' => $orderid)));
}
$goods = pdo_fetchall('select og.id,og.goodsid,og.price,g.title,g.thumb,og.total,g.credit,og.optionid,o.title as optiontitle from ' . tablename('ewei_shop_order_goods') . ' og ' . ' left join ' . tablename('ewei_shop_goods') . ' g on g.id=og.goodsid ' . ' left join ' . tablename('ewei_shop_goods_option') . ' o on o.id=og.optionid ' . ' where og.orderid=:orderid and og.uniacid=:uniacid ', array(':uniacid' => $uniacid, ':orderid' => $orderid));
$goods = set_medias($goods, 'thumb');
include $this->template();
}
public function submit()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$orderid = intval($_GPC['orderid']);
$order = pdo_fetch('select id,status,iscomment from ' . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1', array(':id' => $orderid, ':uniacid' => $uniacid, ':openid' => $openid));
if (empty($order)) {
show_json(0, '订单未找到');
}
$member = m('member')->getMember($openid);
$comments = $_GPC['comments'];
if (!is_array($comments)) {
show_json(0, '数据出错,请重试!');
}
$trade = m('common')->getSysset('trade');
if (!empty($trade['commentchecked'])) {
$checked = 0;
}
else {
$checked = 1;
}
foreach ($comments as $c) {
$old_c = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_order_comment') . ' where uniacid=:uniacid and orderid=:orderid and goodsid=:goodsid limit 1', array(':uniacid' => $_W['uniacid'], ':goodsid' => $c['goodsid'], ':orderid' => $orderid));
if (empty($old_c)) {
$comment = array('uniacid' => $uniacid, 'orderid' => $orderid, 'goodsid' => $c['goodsid'], 'level' => $c['level'], 'content' => trim($c['content']), 'images' => is_array($c['images']) ? iserializer($c['images']) : iserializer(array()), 'openid' => $openid, 'nickname' => $member['nickname'], 'headimgurl' => $member['avatar'], 'createtime' => time(), 'checked' => $checked);
pdo_insert('ewei_shop_order_comment', $comment);
if (p('task')) {
p('task')->checkTaskReward('cost_comment', 1);
}
if (p('task')) {
p('task')->checkTaskProgress(1, 'comment');
}
}
else {
$comment = array('append_content' => trim($c['content']), 'append_images' => is_array($c['images']) ? iserializer($c['images']) : iserializer(array()), 'replychecked' => $checked);
pdo_update('ewei_shop_order_comment', $comment, array('uniacid' => $_W['uniacid'], 'goodsid' => $c['goodsid'], 'orderid' => $orderid));
}
}
if ($order['iscomment'] <= 0) {
$d['iscomment'] = 1;
}
else {
$d['iscomment'] = 2;
}
pdo_update('ewei_shop_order', $d, array('id' => $orderid, 'uniacid' => $uniacid));
show_json(1);
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,503 +0,0 @@
<?php
if (!defined('IN_IA'))
{
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobileLoginPage
{
protected function merchData()
{
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if ($merch_plugin && $merch_data['is_openmerch'])
{
$is_openmerch = 1;
}
else
{
$is_openmerch = 0;
}
return array('is_openmerch' => $is_openmerch, 'merch_plugin' => $merch_plugin, 'merch_data' => $merch_data);
}
public function main()
{
global $_W;
global $_GPC;
$trade = m('common')->getSysset('trade');
$merchdata = $this->merchData();
extract($merchdata);
if ($is_openmerch == 1)
{
include $this->template('merch/order/index');
return NULL;
}
include $this->template();
}
public function get_list()
{
global $_W;
global $_GPC;
$uniacid = $_W['uniacid'];
$openid = $_W['openid'];
$pindex = max(1, intval($_GPC['page']));
$psize = 50;
$show_status = $_GPC['status'];
$r_type = array('退款', '退货退款', '换货');
$condition = ' and openid=:openid and ismr=0 and deleted=0 and uniacid=:uniacid ';
$params = array(':uniacid' => $uniacid, ':openid' => $openid);
$merchdata = $this->merchData();
extract($merchdata);
$condition .= ' and merchshow=0 ';
$show_status = intval($show_status);
switch ($show_status)
{
case 0: $condition .= ' and status=0 and paytype!=3';
break;
case 2: $condition .= ' and (status=2 or status=0 and paytype=3)';
break;
case 4: $condition .= ' and refundstate>0';
break;
case 5: $condition .= ' and userdeleted=1 ';
break;
default: $condition .= ' and status=' . intval($show_status);
}
if ($show_status != 5)
{
$condition .= ' and userdeleted=0 ';
}
$com_verify = com('verify');
$list = pdo_fetchall('select id,addressid,ordersn,price,dispatchprice,status,iscomment,isverify,' . "\n" . 'verified,verifycode,verifytype,iscomment,refundid,expresscom,express,expresssn,finishtime,`virtual`,' . "\n" . 'paytype,expresssn,refundstate,dispatchtype,verifyinfo,merchid,isparent,userdeleted' . "\n" . ' from ' . tablename('ewei_shop_order') . ' where 1 ' . $condition . ' order by createtime desc LIMIT ' . (($pindex - 1) * $psize) . ',' . $psize, $params);
$total = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_order') . ' where 1 ' . $condition, $params);
$refunddays = intval($_W['shopset']['trade']['refunddays']);
if ($is_openmerch == 1)
{
$merch_user = $merch_plugin->getListUser($list, 'merch_user');
}
foreach ($list as &$row)
{
$param = array();
if ($row['isparent'] == 1)
{
$scondition = ' og.parentorderid=:parentorderid';
$param[':parentorderid'] = $row['id'];
}
else
{
$scondition = ' og.orderid=:orderid';
$param[':orderid'] = $row['id'];
}
$sql = 'SELECT og.goodsid,og.total,g.title,g.thumb,og.price,og.optionname as optiontitle,og.optionid,op.specs FROM ' . tablename('ewei_shop_order_goods') . ' og ' . ' left join ' . tablename('ewei_shop_goods') . ' g on og.goodsid = g.id ' . ' left join ' . tablename('ewei_shop_goods_option') . ' op on og.optionid = op.id ' . ' where ' . $scondition . ' order by og.id asc';
$goods = pdo_fetchall($sql, $param);
foreach ($goods as &$r )
{
if (!empty($r['specs']))
{
$thumb = m('goods')->getSpecThumb($r['specs']);
if (!empty($thumb))
{
$r['thumb'] = $thumb;
}
}
}
unset($r);
$row['goods'] = set_medias($goods, 'thumb');
foreach ($row['goods'] as &$r )
{
$r['thumb'] .= '?t=' . random(50);
}
unset($r);
$statuscss = 'text-cancel';
switch ($row['status'])
{
case '-1': $status = '已取消';
break;
case '0': if ($row['paytype'] == 3)
{
$status = '待发货';
}
else
{
$status = '待付款';
}
$statuscss = 'text-cancel';
break;
case '1': if ($row['isverify'] == 1)
{
$status = '使用中';
}
else if (empty($row['addressid']))
{
$status = '待取货';
}
else
{
$status = '待发货';
}
$statuscss = 'text-warning';
break;
case '2': $status = '待收货';
$statuscss = 'text-danger';
break;
case '3': if (empty($row['iscomment']))
{
if ($show_status == 5)
{
$status = '已完成';
}
else
{
$status = ((empty($_W['shopset']['trade']['closecomment']) ? '待评价' : '已完成'));
}
}
else
{
$status = '交易完成';
}
$statuscss = 'text-success';
break;
}
$row['statusstr'] = $status;
$row['statuscss'] = $statuscss;
if ((0 < $row['refundstate']) && !empty($row['refundid']))
{
$refund = pdo_fetch('select * from ' . tablename('ewei_shop_order_refund') . ' where id=:id and uniacid=:uniacid and orderid=:orderid limit 1', array(':id' => $row['refundid'], ':uniacid' => $uniacid, ':orderid' => $row['id']));
if (!empty($refund))
{
$row['statusstr'] = '待' . $r_type[$refund['rtype']];
}
}
$canrefund = false;
$row['canrefund'] = $canrefund;
$row['canverify'] = false;
$canverify = false;
if ($com_verify)
{
$showverify = $row['dispatchtype'] || $row['isverify'];
if ($row['isverify'])
{
if (($row['verifytype'] == 0) || ($row['verifytype'] == 1))
{
$vs = iunserializer($row['verifyinfo']);
$verifyinfo = array( array('verifycode' => $row['verifycode'], 'verified' => ($row['verifytype'] == 0 ? $row['verified'] : $row['goods'][0]['total'] <= count($vs))) );
if ($row['verifytype'] == 0)
{
$canverify = empty($row['verified']) && $showverify;
}
else if ($row['verifytype'] == 1)
{
$canverify = (count($vs) < $row['goods'][0]['total']) && $showverify;
}
}
else
{
$verifyinfo = iunserializer($row['verifyinfo']);
$last = 0;
foreach ($verifyinfo as $v )
{
if (!$v['verified'])
{
++$last;
}
}
$canverify = (0 < $last) && $showverify;
}
}
else if (!empty($row['dispatchtype']))
{
$canverify = ($row['status'] == 1) && $showverify;
}
}
$row['canverify'] = $canverify;
if ($is_openmerch == 1)
{
$row['merchname'] = ($merch_user[$row['merchid']]['merchname'] ? $merch_user[$row['merchid']]['merchname'] : $_W['shopset']['shop']['name']);
}
}
unset($row);
show_json(1, array('list' => $list, 'pagesize' => $psize, 'total' => $total));
}
public function alipay()
{
global $_W;
global $_GPC;
$url = urldecode($_GPC['url']);
if (!is_weixin())
{
header('location: ' . $url);
exit();
}
include $this->template();
}
public function detail()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$member = m('member')->getMember($openid, true);
$orderid = intval($_GPC['id']);
if (empty($orderid))
{
header('location: ' . mobileUrl('order'));
exit();
}
$order = pdo_fetch('select * from ' . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1', array(':id' => $orderid, ':uniacid' => $uniacid, ':openid' => $openid));
if (empty($order))
{
header('location: ' . mobileUrl('order'));
exit();
}
if ($order['merchshow'] == 1)
{
header('location: ' . mobileUrl('order'));
exit();
}
if ($order['userdeleted'] == 2)
{
$this->message('订单已经被删除!', '', 'error');
}
$merchdata = $this->merchData();
extract($merchdata);
$merchid = $order['merchid'];
$diyform_plugin = p('diyform');
$diyformfields = '';
if ($diyform_plugin)
{
$diyformfields = ',og.diyformfields,og.diyformdata';
}
$param = array();
$param[':uniacid'] = $_W['uniacid'];
if ($order['isparent'] == 1)
{
$scondition = ' og.parentorderid=:parentorderid';
$param[':parentorderid'] = $orderid;
}
else
{
$scondition = ' og.orderid=:orderid';
$param[':orderid'] = $orderid;
}
$goods = pdo_fetchall('select og.goodsid,og.price,g.title,g.thumb,og.total,g.credit,og.optionid,og.optionname as optiontitle,g.isverify,g.storeids' . $diyformfields . ' from ' . tablename('ewei_shop_order_goods') . ' og ' . ' left join ' . tablename('ewei_shop_goods') . ' g on g.id=og.goodsid ' . ' where ' . $scondition . ' and og.uniacid=:uniacid ', $param);
if (!empty($goods))
{
foreach ($goods as &$g )
{
if (!empty($g['optionid']))
{
$thumb = m('goods')->getOptionThumb($g['goodsid'], $g['optionid']);
if (!empty($thumb))
{
$g['thumb'] = $thumb;
}
}
}
unset($g);
}
$diyform_flag = 0;
if ($diyform_plugin)
{
foreach ($goods as &$g )
{
$g['diyformfields'] = iunserializer($g['diyformfields']);
$g['diyformdata'] = iunserializer($g['diyformdata']);
unset($g);
}
if (!empty($order['diyformfields']) && !empty($order['diyformdata']))
{
$order_fields = iunserializer($order['diyformfields']);
$order_data = iunserializer($order['diyformdata']);
}
}
$address = false;
if (!empty($order['addressid']))
{
$address = iunserializer($order['address']);
if (!is_array($address))
{
$address = pdo_fetch('select * from ' . tablename('ewei_shop_member_address') . ' where id=:id limit 1', array(':id' => $order['addressid']));
}
}
$carrier = @iunserializer($order['carrier']);
if (!is_array($carrier) || empty($carrier))
{
$carrier = false;
}
$store = false;
if (!empty($order['storeid']))
{
if (0 < $merchid)
{
$store = pdo_fetch('select * from ' . tablename('ewei_shop_merch_store') . ' where id=:id limit 1', array(':id' => $order['storeid']));
}
else
{
$store = pdo_fetch('select * from ' . tablename('ewei_shop_store') . ' where id=:id limit 1', array(':id' => $order['storeid']));
}
}
$stores = false;
$showverify = false;
$canverify = false;
$verifyinfo = false;
if (com('verify'))
{
$showverify = $order['dispatchtype'] || $order['isverify'];
if ($order['isverify'])
{
$storeids = array();
foreach ($goods as $g )
{
if (!empty($g['storeids']))
{
$storeids = array_merge(explode(',', $g['storeids']), $storeids);
}
}
if (empty($storeids))
{
if (0 < $merchid)
{
$stores = pdo_fetchall('select * from ' . tablename('ewei_shop_merch_store') . ' where uniacid=:uniacid and merchid=:merchid and status=1 and type in(2,3)', array(':uniacid' => $_W['uniacid'], ':merchid' => $merchid));
}
else
{
$stores = pdo_fetchall('select * from ' . tablename('ewei_shop_store') . ' where uniacid=:uniacid and status=1 and type in(2,3)', array(':uniacid' => $_W['uniacid']));
}
}
else if (0 < $merchid)
{
$stores = pdo_fetchall('select * from ' . tablename('ewei_shop_merch_store') . ' where id in (' . implode(',', $storeids) . ') and uniacid=:uniacid and merchid=:merchid and status=1 and type in(2,3)', array(':uniacid' => $_W['uniacid'], ':merchid' => $merchid));
}
else
{
$stores = pdo_fetchall('select * from ' . tablename('ewei_shop_store') . ' where id in (' . implode(',', $storeids) . ') and uniacid=:uniacid and status=1 and type in(2,3)', array(':uniacid' => $_W['uniacid']));
}
if (($order['verifytype'] == 0) || ($order['verifytype'] == 1))
{
$vs = iunserializer($order['verifyinfo']);
$verifyinfo = array( array('verifycode' => $order['verifycode'], 'verified' => ($order['verifytype'] == 0 ? $order['verified'] : $goods[0]['total'] <= count($vs))) );
if ($order['verifytype'] == 0)
{
$canverify = empty($order['verified']) && $showverify;
}
else if ($order['verifytype'] == 1)
{
$canverify = (count($vs) < $goods[0]['total']) && $showverify;
}
}
else
{
$verifyinfo = iunserializer($order['verifyinfo']);
$last = 0;
foreach ($verifyinfo as $v )
{
if (!$v['verified'])
{
++$last;
}
}
$canverify = (0 < $last) && $showverify;
}
}
else if (!empty($order['dispatchtype']))
{
$verifyinfo = array( array('verifycode' => $order['verifycode'], 'verified' => $order['status'] == 3) );
$canverify = ($order['status'] == 1) && $showverify;
}
}
$order['canverify'] = $canverify;
$order['showverify'] = $showverify;
$order['virtual_str'] = str_replace("\n", '<br/>', $order['virtual_str']);
if (($order['status'] == 1) || ($order['status'] == 2))
{
$canrefund = true;
if (($order['status'] == 2) && ($order['price'] == $order['dispatchprice']))
{
if (0 < $order['refundstate'])
{
$canrefund = true;
}
else
{
$canrefund = false;
}
}
}
else if ($order['status'] == 3)
{
if (($order['isverify'] != 1) && empty($order['virtual']))
{
if (0 < $order['refundstate'])
{
$canrefund = true;
}
else
{
$tradeset = m('common')->getSysset('trade');
$refunddays = intval($tradeset['refunddays']);
if (0 < $refunddays)
{
$days = intval((time() - $order['finishtime']) / 3600 / 24);
if ($days <= $refunddays)
{
$canrefund = true;
}
}
}
}
}
$order['canrefund'] = $canrefund;
$express = false;
if ((2 <= $order['status']) && empty($order['isvirtual']) && empty($order['isverify']))
{
$expresslist = m('util')->getExpressList($order['express'], $order['expresssn']);
if (0 < count($expresslist))
{
$express = $expresslist[0];
}
}
$shopname = $_W['shopset']['shop']['name'];
if (!empty($order['merchid']) && ($is_openmerch == 1))
{
$merch_user = $merch_plugin->getListUser($order['merchid']);
$shopname = $merch_user['merchname'];
$shoplogo = tomedia($merch_user['logo']);
}
include $this->template();
}
public function express()
{
global $_W;
global $_GPC;
global $_W;
global $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$orderid = intval($_GPC['id']);
if (empty($orderid))
{
header('location: ' . mobileUrl('order'));
exit();
}
$order = pdo_fetch('select * from ' . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1', array(':id' => $orderid, ':uniacid' => $uniacid, ':openid' => $openid));
if (empty($order))
{
header('location: ' . mobileUrl('order'));
exit();
}
if (empty($order['addressid']))
{
$this->message('订单非快递单,无法查看物流信息!');
}
if ($order['status'] < 2)
{
$this->message('订单未发货,无法查看物流信息!');
}
$goods = pdo_fetchall('select og.goodsid,og.price,g.title,g.thumb,og.total,g.credit,og.optionid,og.optionname as optiontitle,g.isverify,g.storeids' . $diyformfields . ' from ' . tablename('ewei_shop_order_goods') . ' og ' . ' left join ' . tablename('ewei_shop_goods') . ' g on g.id=og.goodsid ' . ' where og.orderid=:orderid and og.uniacid=:uniacid ', array(':uniacid' => $uniacid, ':orderid' => $orderid));
$expresslist = m('util')->getExpressList($order['express'], $order['expresssn']);
include $this->template();
}
}
?>

View File

@@ -1,175 +0,0 @@
<?php
//20171209修复购物送积分问题完成送积分
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Op_EweiShopV2Page extends MobileLoginPage
{
/**
* 取消订单
* @global type $_W
* @global type $_GPC
*/
public function cancel()
{
global $_W;
global $_GPC;
$orderid = intval($_GPC['id']);
$order = pdo_fetch('select id,ordersn,openid,status,deductcredit,deductcredit2,deductprice,couponid,isparent,`virtual`,`virtual_info` from ' . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1', array(':id' => $orderid, ':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']));
if (empty($order)) {
show_json(0, '订单未找到');
}
if (0 < $order['status']) {
show_json(0, '订单已支付,不能取消!');
}
if ($order['status'] < 0) {
show_json(0, '订单已经取消!');
}
if (!empty($order['virtual']) && ($order['virtual'] != 0)) {
$goodsid = pdo_fetch('SELECT goodsid FROM ' . tablename('ewei_shop_order_goods') . ' WHERE uniacid = ' . $_W['uniacid'] . ' AND orderid = ' . $order['id']);
$typeid = $order['virtual'];
$vkdata = ltrim($order['virtual_info'], '[');
$vkdata = rtrim($vkdata, ']');
$arr = explode('}', $vkdata);
foreach ($arr as $k => $v) {
if (!$v) {
unset($arr[$k]);
}
}
$vkeynum = count($arr);
pdo_query('update ' . tablename('ewei_shop_virtual_data') . ' set openid="",usetime=0,orderid=0,ordersn="",price=0,merchid=0 where typeid=' . intval($typeid) . ' and orderid = ' . $order['id']);
pdo_query('update ' . tablename('ewei_shop_virtual_type') . ' set usedata=usedata-' . $vkeynum . ' where id=' . intval($typeid));
}
m('order')->setStocksAndCredits($orderid, 2);
if (0 < $order['deductprice']) {
m('member')->setCredit($order['openid'], 'credit1', $order['deductcredit'], array('0', $_W['shopset']['shop']['name'] . '购物返还抵扣积分 积分: ' . $order['deductcredit'] . ' 抵扣金额: ' . $order['deductprice'] . ' 订单号: ' . $order['ordersn']));
}
m('order')->setDeductCredit2($order);
if (com('coupon') && !empty($order['couponid'])) {
com('coupon')->returnConsumeCoupon($orderid);
}
pdo_update('ewei_shop_order', array('status' => -1, 'canceltime' => time(), 'closereason' => trim($_GPC['remark'])), array('id' => $order['id'], 'uniacid' => $_W['uniacid']));
if (!empty($order['isparent'])) {
pdo_update('ewei_shop_order', array('status' => -1, 'canceltime' => time(), 'closereason' => trim($_GPC['remark'])), array('parentid' => $order['id'], 'uniacid' => $_W['uniacid']));
}
m('notice')->sendOrderMessage($orderid);
show_json(1);
}
/**
* 确认收货
* @global type $_W
* @global type $_GPC
*/
public function finish()
{
global $_W;
global $_GPC;
$orderid = intval($_GPC['id']);
$order = pdo_fetch('select id,status,openid,couponid,refundstate,refundid,ordersn,price from ' . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1', array(':id' => $orderid, ':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']));
if (empty($order)) {
show_json(0, '订单未找到');
}
if ($order['status'] != 2) {
show_json(0, '订单不能确认收货');
}
if ((0 < $order['refundstate']) && !empty($order['refundid'])) {
$change_refund = array();
$change_refund['status'] = -2;
$change_refund['refundtime'] = time();
pdo_update('ewei_shop_order_refund', $change_refund, array('id' => $order['refundid'], 'uniacid' => $_W['uniacid']));
}
pdo_update('ewei_shop_order', array('status' => 3, 'finishtime' => time(), 'refundstate' => 0), array('id' => $order['id'], 'uniacid' => $_W['uniacid']));
m('order')->setStocksAndCredits($orderid, 3);
m('order')->fullback($orderid);
m('member')->upgradeLevel($order['openid'], $orderid);
m('order')->setGiveBalance($orderid, 1);
if (com('coupon')) {
$refurnid = com('coupon')->sendcouponsbytask($orderid);
}
if (com('coupon') && !empty($order['couponid'])) {
com('coupon')->backConsumeCoupon($orderid);
}
m('notice')->sendOrderMessage($orderid);
com_run('printer::sendOrderMessage', $orderid);
if (p('lineup')) {
p('lineup')->checkOrder($order);
}
if (p('commission')) {
p('commission')->checkOrderFinish($orderid);
}
if (p('lottery')) {
$res = p('lottery')->getLottery($_W['openid'], 1, array('money' => $order['price'], 'paytype' => 2));
if ($res) {
p('lottery')->getLotteryList($_W['openid'], array('lottery_id' => $res));
}
}
show_json(1, array('url' => mobileUrl('order', array('status' => 3))));
}
/**
* 删除或恢复订单
* @global type $_W
* @global type $_GPC
*/
public function delete()
{
global $_W;
global $_GPC;
$orderid = intval($_GPC['id']);
$userdeleted = intval($_GPC['userdeleted']);
$order = pdo_fetch('select id,status,refundstate,refundid from ' . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1', array(':id' => $orderid, ':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']));
if (empty($order)) {
show_json(0, '订单未找到!');
}
if ($userdeleted == 0) {
if ($order['status'] != 3) {
show_json(0, '无法恢复');
}
}
else {
if (($order['status'] != 3) && ($order['status'] != -1)) {
show_json(0, '无法删除');
}
if ((0 < $order['refundstate']) && !empty($order['refundid'])) {
$change_refund = array();
$change_refund['status'] = -2;
$change_refund['refundtime'] = time();
pdo_update('ewei_shop_order_refund', $change_refund, array('id' => $order['refundid'], 'uniacid' => $_W['uniacid']));
}
}
pdo_update('ewei_shop_order', array('userdeleted' => $userdeleted, 'refundstate' => 0), array('id' => $order['id'], 'uniacid' => $_W['uniacid']));
show_json(1);
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,220 +0,0 @@
<?php
//dezend by www.yunziyuan.com.cn
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Pay_Alipay_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
global $_GPC;
$url = urldecode($_GPC['url']);
if (!is_weixin()) {
header('location: ' . $url);
exit();
}
include $this->template('order/alipay');
}
public function complete()
{
global $_GPC;
global $_W;
$set = m('common')->getSysset(array('shop', 'pay'));
$fromwechat = intval($_GPC['fromwechat']);
$tid = $_GPC['out_trade_no'];
if (is_h5app()) {
$sec = m('common')->getSec();
$sec = iunserializer($sec['sec']);
$public_key = $sec['app_alipay']['public_key'];
if (empty($set['pay']['app_alipay']) || empty($public_key)) {
$this->message('支付出现错误,请重试(1)!', mobileUrl('order'));
}
$alidata = base64_decode($_GET['alidata']);
$alidata = json_decode($alidata, true);
$alisign = m('finance')->RSAVerify($alidata, $public_key, false);
$tid = $this->str($alidata['out_trade_no']);
if ($alisign == 0) {
$this->message('支付出现错误,请重试(2)!', mobileUrl('order'));
}
if (strexists($tid, 'GJ')) {
$tids = explode('GJ', $tid);
$tid = $tids[0];
}
}
else {
if (empty($set['pay']['alipay'])) {
$this->message('未开启支付宝支付!', mobileUrl('order'));
}
if (!m('finance')->isAlipayNotify($_GET)) {
$log = pdo_fetch('SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniacid`=:uniacid AND `module`=:module AND `tid`=:tid limit 1', array(':uniacid' => $_W['uniacid'], ':module' => 'ewei_shopv2', ':tid' => $tid));
if (($log['status'] == 1) && ($log['fee'] == $_GPC['total_fee'])) {
if ($fromwechat) {
$this->message(array('message' => '请返回微信查看支付状态', 'title' => '支付成功!', 'buttondisplay' => false), NULL, 'success');
}
else {
$this->message(array('message' => '请返回商城查看支付状态', 'title' => '支付成功!'), mobileUrl('order'), 'success');
}
}
$this->message(array('message' => '支付出现错误,请重试(支付验证失败)!', 'buttondisplay' => $fromwechat ? false : true), $fromwechat ? NULL : mobileUrl('order'));
}
}
$log = pdo_fetch('SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniacid`=:uniacid AND `module`=:module AND `tid`=:tid limit 1', array(':uniacid' => $_W['uniacid'], ':module' => 'ewei_shopv2', ':tid' => $tid));
if (empty($log)) {
$this->message(array('message' => '支付出现错误,请重试(支付验证失败2)!', 'buttondisplay' => $fromwechat ? false : true), $fromwechat ? NULL : mobileUrl('order'));
}
if (is_h5app()) {
$alidatafee = $this->str($alidata['total_fee']);
$alidatastatus = $this->str($alidata['success']);
if (($log['fee'] != $alidatafee) || !$alidatastatus) {
$this->message('支付出现错误,请重试(4)!', mobileUrl('order'));
}
}
if ($log['status'] != 1) {
$record = array();
$record['status'] = '1';
$record['type'] = 'alipay';
pdo_update('core_paylog', $record, array('plid' => $log['plid']));
$orderid = pdo_fetchcolumn('select id from ' . tablename('ewei_shop_order') . ' where ordersn=:ordersn and uniacid=:uniacid', array(':ordersn' => $log['tid'], ':uniacid' => $_W['uniacid']));
if (!empty($orderid)) {
m('order')->setOrderPayType($orderid, 22);
$data_alipay = array('transid' => $_GET['trade_no']);
if (is_h5app()) {
$data_alipay['transid'] = $alidata['trade_no'];
$data_alipay['apppay'] = 1;
}
pdo_update('ewei_shop_order', $data_alipay, array('id' => $orderid));
}
$ret = array();
$ret['result'] = 'success';
$ret['type'] = 'alipay';
$ret['from'] = 'return';
$ret['tid'] = $log['tid'];
$ret['user'] = $log['openid'];
$ret['fee'] = $log['fee'];
$ret['weid'] = $log['weid'];
$ret['uniacid'] = $log['uniacid'];
m('order')->payResult($ret);
}
if (is_h5app()) {
$url = mobileUrl('order/detail', array('id' => $orderid), true);
exit('<script>top.window.location.href=\'' . $url . '\'</script>');
}
else if ($fromwechat) {
$this->message(array('message' => '请返回微信查看支付状态', 'title' => '支付成功!', 'buttondisplay' => false), NULL, 'success');
}
else {
$this->message(array('message' => '请返回商城查看支付状态', 'title' => '支付成功!'), mobileUrl('order'), 'success');
}
}
public function recharge_complete()
{
global $_W;
global $_GPC;
$fromwechat = intval($_GPC['fromwechat']);
$logno = trim($_GPC['out_trade_no']);
$notify_id = trim($_GPC['notify_id']);
$sign = trim($_GPC['sign']);
$set = m('common')->getSysset(array('shop', 'pay'));
if (is_h5app()) {
$sec = m('common')->getSec();
$sec = iunserializer($sec['sec']);
$public_key = $sec['app_alipay']['public_key'];
if (empty($_GET['alidata'])) {
$this->message('支付出现错误,请重试(1)!', mobileUrl('member'));
}
if (empty($set['pay']['app_alipay']) || empty($public_key)) {
$this->message('支付出现错误,请重试(2)!', mobileUrl('order'));
}
$alidata = base64_decode($_GET['alidata']);
$alidata = json_decode($alidata, true);
$alisign = m('finance')->RSAVerify($alidata, $public_key, false);
$logno = $this->str($alidata['out_trade_no']);
if ($alisign == 0) {
$this->message('支付出现错误,请重试(3)!', mobileUrl('member'));
}
$transid = $alidata['trade_no'];
}
else {
if (empty($logno)) {
$this->message(array('message' => '支付出现错误,请重试(支付验证失败1)!', 'buttondisplay' => $fromwechat ? false : true), $fromwechat ? NULL : mobileUrl('member'));
}
if (empty($set['pay']['alipay'])) {
$this->message(array('message' => '支付出现错误,请重试(未开启支付宝支付)!', 'buttondisplay' => $fromwechat ? false : true), $fromwechat ? NULL : mobileUrl('member'));
}
if (!m('finance')->isAlipayNotify($_GET)) {
$log = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_member_log') . ' WHERE `logno`=:logno and `uniacid`=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':logno' => $logno));
if (!empty($log) && !empty($log['status'])) {
if ($fromwechat) {
$this->message(array('message' => '请返回微信查看支付状态', 'title' => '支付成功!', 'buttondisplay' => false), NULL, 'success');
}
else {
$this->message(array('message' => '请返回商城查看支付状态', 'title' => '支付成功!'), mobileUrl('member'), 'success');
}
}
$this->message(array('message' => '支付出现错误,请重试(支付验证失败2)!', 'buttondisplay' => $fromwechat ? false : true), $fromwechat ? NULL : mobileUrl('member'));
}
$transid = $_GET['trade_no'];
}
$log = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_member_log') . ' WHERE `logno`=:logno and `uniacid`=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':logno' => $logno));
if (!empty($log) && empty($log['status'])) {
pdo_update('ewei_shop_member_log', array('status' => 1, 'rechargetype' => 'alipay', 'apppay' => is_h5app() ? 1 : 0, 'transid' => $transid), array('id' => $log['id']));
m('member')->setCredit($log['openid'], 'credit2', $log['money'], array(0, $_W['shopset']['shop']['name'] . '会员充值:alipayreturn:credit2:' . $log['money']));
m('member')->setRechargeCredit($log['openid'], $log['money']);
com_run('sale::setRechargeActivity', $log);
com_run('coupon::useRechargeCoupon', $log);
m('notice')->sendMemberLogMessage($log['id']);
}
if (is_h5app()) {
$url = mobileUrl('member', NULL, true);
exit('<script>top.window.location.href=\'' . $url . '\'</script>');
}
else if ($fromwechat) {
$this->message(array('message' => '请返回微信查看支付状态', 'title' => '支付成功!', 'buttondisplay' => false), NULL, 'success');
}
else {
$this->message(array('message' => '请返回商城查看支付状态', 'title' => '支付成功!'), mobileUrl('member'), 'success');
}
}
protected function str($str)
{
$str = str_replace('"', '', $str);
$str = str_replace('\'', '', $str);
return $str;
}
}
?>

View File

@@ -1,360 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Refund_EweiShopV2Page extends MobileLoginPage {
protected function globalData() {
global $_W, $_GPC;
$uniacid = $_W['uniacid'];
$openid = $_W['openid'];
$orderid = intval($_GPC['id']);
$order = pdo_fetch("select id,status,price,refundid,goodsprice,dispatchprice,deductprice,deductcredit2,finishtime,isverify,`virtual`,refundstate,merchid,random_code,iscycelbuy,paytype from " . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1'
, array(':id' => $orderid, ':uniacid' => $uniacid, ':openid' => $openid));
$orderprice = $order['price'];
if( $order['iscycelbuy'] == 1 ){
//查询分期订单下面是否存在有开始的周期商品
$order_goods = pdo_fetch( "select * from ".tablename( 'ewei_shop_cycelbuy_periods' )."where orderid = {$order['id']} and status != 0" );
if( !empty($order_goods) ){
show_json( 0 , '订单已经开始,无法进行退款' );
}
}
$refund = pdo_fetch("select * from ".tablename('ewei_shop_order_refund')." where uniacid = :uniacid and orderid = :orderid and status > 0 limit 1 ",array(':uniacid'=>$uniacid,':orderid'=>$orderid));
if(!empty($refund) && $refund['rtype'] == 0){
if ($_W['isajax']){
show_json(0, '此订单已完成维权,不能申请退款');
}else{
show_message('此订单已完成维权,不能申请退款');
}
}
if (empty($order)) {
if (!$_W['isajax']) {
header('location: ' . mobileUrl('order'));
exit;
} else {
show_json(0, '订单未找到');
}
}
$_err = '';
if ($order['status'] <= 0) {
$_err = '订单未付款或已关闭,不能申请退款!';
} else {
if ($order['status'] == 3) {
if (!empty($order['virtual']) || $order['isverify'] == 1) {
$_err = '此订单不允许退款!';
} else {
if ($order['refundstate'] == 0) {
//申请退款
$tradeset = m('common')->getSysset('trade');
$refunddays = intval($tradeset['refunddays']);
if ($refunddays > 0) {
$days = intval((time() - $order['finishtime']) / 3600 / 24);
if ($days > $refunddays) {
$_err = '订单完成已超过 ' . $refunddays . ' 天, 无法发起退款申请!';
}
} else {
$_err = '订单完成, 无法申请退款!';
}
}
}
}
}
if (!empty($_err)) {
if ($_W['isajax']) {
show_json(0, $_err);
} else {
$this->message($_err, '', 'error');
}
}
//订单不能退货商品
/*********************************************************************/
$order['cannotrefund'] = true;
$refundgoods = array(
'refund' => true,
'returngoods' => true,
'exchange' => true,
);
if($order['status'] >= 1){
$goods = pdo_fetchall("select og.goodsid, og.price, og.total, og.optionname, g.cannotrefund,g.refund,g.returngoods,g.exchange,g.type, g.thumb, g.title,g.isfullback from".tablename("ewei_shop_order_goods") ." og left join ".tablename("ewei_shop_goods")." g on g.id=og.goodsid where og.orderid=".$order['id']);
if(!empty($goods)){
foreach ($goods as $g){
/*
* 退款优化V1.10
* 张洪利2019-09-16
* */
if(empty($g['cannotrefund'])){
$g['refund'] = true ;
$g['returngoods'] = true;
$g['exchange'] = true;
}
if($order['status']>=2){
/*
* 退款优化V1.10
* 张洪利2019-09-16
* */
if(!empty($g['cannotrefund']) && empty($g['refund']) && empty($g['returngoods']) && empty($g['exchange'])){
$order['cannotrefund'] = false ;
}
}
if($order['status']==1){
/*
* 退款优化V1.10
* 张洪利2019-09-16
* */
if(!empty($g['cannotrefund']) && empty($g['refund'])){
$order['cannotrefund'] = false ;
}
}
//虚拟商品完成订单
if($order['status']>=3 && $g['type']==2 ){
$g['returngoods'] = false;
$g['exchange'] = false;
}
$refundgoods['refund'] = empty($refundgoods['refund']) ? false :$g['refund'];
$refundgoods['returngoods'] = empty($refundgoods['returngoods']) ? false :$g['returngoods'];
$refundgoods['exchange'] = empty($refundgoods['exchange']) ? false :$g['exchange'];
}
}
}
if($order['cannotrefund'] && empty($refundgoods['refund']) && empty($refundgoods['returngoods']) && empty($refundgoods['exchange'])){
$this->message("此订单不可退换货");
}
//是否全返商品,并检测是否允许退款
$fullback_log = pdo_fetchall("select * from ".tablename('ewei_shop_fullback_log')." where orderid = ".$orderid." and uniacid = ".$uniacid." ");
$fullbackkprice = 0;
if($fullback_log&&is_array($fullback_log)){
foreach ($fullback_log as $key=>$value){
$fullbackgoods = pdo_fetch("select refund from ".tablename('ewei_shop_fullback_goods')." where goodsid = ".$value['goodsid']." and uniacid = ".$uniacid." ");
if($fullbackgoods['refund'] ==0){
$this->message("此订单包含全返产品不允许退款");
}
}
foreach ($fullback_log as $k=>$val){
if($val['fullbackday']>0){
if($val['fullbackday']<$val['day']){
$fullbackkprice += $val['priceevery'] * $val['fullbackday'];
}else{
$fullbackkprice += $val['price'];
}
}
}
}
$order['price'] = $order['price'] - $fullbackkprice;
//应该退的钱 在线支付的+积分抵扣的+余额抵扣的(运费包含在在线支付或余额里)
$order['refundprice'] = $order['price'] + $order['deductcredit2'];
if ($order['status'] >= 2) {
//如果发货,扣除运费
$order['refundprice']-= $order['dispatchprice'];
}
$order['refundprice'] = round($order['refundprice'],2);
return array(
'uniacid' => $uniacid,
'refundgoods' => $refundgoods,
'openid' => $_W['openid'],
'orderid' => $orderid,
'order' => $order,
'refundid' => $order['refundid'],
'fullback_log'=>$fullback_log,
'fullbackgoods'=>$fullbackgoods,
'orderprice'=>$orderprice
);
}
function main() {
global $_W, $_GPC;
extract($this->globalData());
if($order['status'] == 2 && $order['price'] == $order['dispatchprice']) {
$canreturns = 1;
}
if ( $order['status'] == '-1')
$this->message('请不要重复提交!','','error');
$refund = false;
$imgnum = 0;
if ($order['refundstate'] > 0) {
if (!empty($refundid)) {
$refund = pdo_fetch("select * from " . tablename('ewei_shop_order_refund') . ' where id=:id and uniacid=:uniacid and orderid=:orderid limit 1'
, array(':id' => $refundid, ':uniacid' => $uniacid, ':orderid' => $orderid));
if (!empty($refund['refundaddress'])) {
$refund['refundaddress'] = iunserializer($refund['refundaddress']);
}
}
if (!empty($refund['imgs'])) {
$refund['imgs'] = iunserializer($refund['imgs']);
}
}
if (empty($refund)) {
$show_price =round( $order['refundprice'],2);
} else {
$show_price = round($refund['applyprice'],2);
}
$express_list = m('express')->getExpressList();
$trade = m('common')->getSysset('trade', $_W['uniacid']);
include $this->template();
}
//提交
function submit() {
global $_W, $_GPC;
extract($this->globalData());
if ( $order['status'] == '-1')
show_json(0, '订单已经处理完毕!');
if($order['paytype'] ==11){
show_json(0, '后台付款订单不允许售后');
}
$price = trim($_GPC['price']);
$rtype = intval($_GPC['rtype']);
if ($rtype != 2) {
if (empty($price) && $order['deductprice'] == 0) {
show_json(0, '退款金额不能为0元');
}
if ($price > $order['refundprice']) {
show_json(0, '退款金额不能超过' . $order['refundprice'] . '元');
}
}
//全返退款,退款退货
if(($rtype==0 || $rtype==1) && $order['status']>=3){
// if(($fullback_log['price']>=$orderprice || $fullbackgoods['refund'] == 0) && $fullback_log){
// show_json(0, "此订单不可退款");
// }
//全返管理停止
if($fullback_log){
m('order')->fullbackstop($orderid);
}
}
$refund = array(
'uniacid' => $uniacid,
'merchid' => $order['merchid'],
'applyprice' => $price,
'rtype' => $rtype,
'reason' => trim($_GPC['reason']),
'content' => trim($_GPC['content']),
'imgs' => iserializer($_GPC['images']),
'price' => $price,
);
if ($refund['rtype'] == 2) {
$refundstate = 2;
} else {
$refundstate = 1;
}
if ($order['refundstate'] == 0) {
//新建一条退款申请
$refund['createtime'] = time();
$refund['orderid'] = $orderid;
$refund['orderprice'] = $order['refundprice'];
$refund['refundno'] = m('common')->createNO('order_refund', 'refundno', 'SR');
pdo_insert('ewei_shop_order_refund', $refund);
$refundid = pdo_insertid();
pdo_update('ewei_shop_order', array('refundid' => $refundid, 'refundstate' => $refundstate), array('id' => $orderid, 'uniacid' => $uniacid));
} else {
//修改退款申请
pdo_update('ewei_shop_order', array('refundstate' => $refundstate), array('id' => $orderid, 'uniacid' => $uniacid));
pdo_update('ewei_shop_order_refund', $refund, array('id' => $refundid, 'uniacid' => $uniacid));
}
//模板消息
m('notice')->sendOrderMessage($orderid, true);
show_json(1);
}
//取消
function cancel() {
global $_W, $_GPC;
extract($this->globalData());
$change_refund = array();
$change_refund['status'] = -2;
$change_refund['refundtime'] = time();
pdo_update('ewei_shop_order_refund', $change_refund, array('id' => $refundid, 'uniacid' => $uniacid));
pdo_update('ewei_shop_order', array('refundstate' => 0), array('id' => $orderid, 'uniacid' => $uniacid));
show_json(1);
}
//填写快递单号
function express() {
global $_W, $_GPC;
extract($this->globalData());
if (empty($refundid)) {
show_json(0, '参数错误!');
}
if (empty($_GPC['expresssn'])) {
show_json(0, '请填写快递单号');
}
$refund = array(
'status'=>4,
'express'=>trim($_GPC['express']),
'expresscom'=>trim($_GPC['expresscom']),
'expresssn'=>trim($_GPC['expresssn']),
'sendtime'=>time()
);
pdo_update('ewei_shop_order_refund', $refund, array('id' => $refundid, 'uniacid' => $uniacid));
show_json(1);
}
//收到换货商品
function receive(){
global $_W, $_GPC;
extract($this->globalData());
$refundid = intval($_GPC['refundid']);
$refund = pdo_fetch("select * from " . tablename('ewei_shop_order_refund') . ' where id=:id and uniacid=:uniacid and orderid=:orderid limit 1'
, array(':id' => $refundid, ':uniacid' => $uniacid, ':orderid' => $orderid));
if (empty($refund)) {
show_json(0, '换货申请未找到!');
}
$time = time();
$refund_data = array();
$refund_data['status'] = 1;
$refund_data['refundtime'] = $time;
pdo_update('ewei_shop_order_refund', $refund_data, array('id'=>$refundid, 'uniacid' => $uniacid));
$order_data = array();
$order_data['refundstate'] = 0;
$order_data['status'] = 3;
$order_data['refundtime'] = $time;
$order_data['finishtime'] = $time;
pdo_update('ewei_shop_order', $order_data, array('id'=>$orderid, 'uniacid' => $uniacid));
show_json(1);
}
//查询商家重新发货快递
function refundexpress() {
global $_W, $_GPC;
extract($this->globalData());
$express = trim($_GPC['express']);
$expresssn = trim($_GPC['expresssn']);
$expresscom = trim($_GPC['expresscom']);
$expresslist = m('util')->getExpressList($express, $expresssn);
include $this->template('order/refundexpress');
}
}

View File

@@ -1,348 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Single_Refund_EweiShopV2Page extends MobileLoginPage {
protected function globalData() {
global $_W, $_GPC;
$order_goodsid = intval($_GPC['id']);
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
//订单商品
$order = pdo_fetch('select o.id,o.price,o.couponprice,o.iscycelbuy,o.status,o.virtual,o.isverify,o.refundstate,o.finishtime,o.deductprice,o.deductcredit2,o.dispatchprice,o.deductenough,o.merchdeductenough,g.cannotrefund,g.refund,g.returngoods,g.exchange,g.type,og.single_refundid,og.single_refundstate,og.single_refundtime,og.realprice as og_realprice,o.grprice,og.consume,o.ispackage,og.sendtime from ' . tablename('ewei_shop_order') .' o '
. ' left join ' . tablename('ewei_shop_order_goods') . ' og on og.orderid=o.id'
. ' left join ' . tablename('ewei_shop_goods') . ' g on g.id=og.goodsid'
. ' where og.id=:ogid and o.openid=:openid and o.uniacid=:uniacid'
, array(':ogid' => $order_goodsid,':openid' => $openid,':uniacid' => $uniacid));
// dump(iunserializer($order['consume']));die;
if (empty($order)) {
if (!$_W['isajax']) {
header('location: ' . mobileUrl('order'));
exit;
} else {
show_json(0, '订单未找到');
}
}
$_err = '';
if($order['iscycelbuy'] == 1 ){
//查询分期订单下面是否存在有开始的周期商品
$order_goods = pdo_fetch( "select * from ".tablename( 'ewei_shop_cycelbuy_periods' )."where orderid = {$order['id']} and status != 0" );
if( !empty($order_goods) ){
$_err='订单已经开始,无法进行单商品退款';
}
}
if(!empty($order['ispackage'])){
$_err = '套餐订单,无法进行单品维权!';
}
//代付
$ispeerpay = m('order')->checkpeerpay($order['id']);//检查是否是代付订单
if(!empty($ispeerpay)){
$_err = '代付订单,无法进行单品维权!';
}
//存在全返,无法进行单商品退款
$fullback_goods_count = pdo_fetchcolumn('select count(og.id) from ' . tablename('ewei_shop_order_goods') .' og '
. ' left join ' . tablename('ewei_shop_goods') . ' g on g.id=og.goodsid'
. ' where og.orderid=:orderid and g.isfullback>0 and og.uniacid=:uniacid'
, array(':orderid' => $order['id'], ':uniacid' => $uniacid));
if(!empty($fullback_goods_count)){
$_err = '全返订单,无法进行单商品退款';
}
$refundgoods = array(
'refund' => $order['refund'] ? true : false,
'returngoods' => $order['returngoods'] ? true : false,
'exchange' => $order['exchange'] ? true : false,
);
//虚拟商品完成订单
if($order['status']>=3 && $order['type']==2 ){
$refundgoods['returngoods'] = false;
$refundgoods['exchange'] = false;
}
if ($order['status'] == 0) {
$_err = '订单未付款,不能申请退款!';
} elseif($order['status']==2 && !empty($order['cannotrefund']) && empty($order['refund']) && empty($order['returngoods']) && empty($order['exchange']) ) {
$_err = '此商品不可退换货!';
}elseif($order['status'] == 3) {
if (!empty($order['virtual']) || $order['isverify'] == 1) {
$_err = '此订单不允许退款!';
} else {
//申请退款
$tradeset = m('common')->getSysset('trade');
$refunddays = intval($tradeset['refunddays']);
if ($refunddays > 0) {
$days = intval((time() - $order['finishtime']) / 3600 / 24);
if ($days > $refunddays) {
$_err = '订单完成已超过 ' . $refunddays . ' 天, 无法发起退款申请!';
}
} else {
$_err = '订单完成, 无法申请退款!';
}
}
}
if (!empty($_err)) {
if ($_W['isajax']) {
show_json(0, $_err);
} else {
$this->message($_err, '', 'error');
}
}
//订单所有商品 关联 退款表
$order_goods = pdo_fetchall('select og.id,og.single_refundid,og.single_refundstate,r.applyprice from ' . tablename('ewei_shop_order_goods') .' og '
. ' left join ' . tablename('ewei_shop_order_single_refund') . ' r on r.id=og.single_refundid'
. ' where og.orderid=:orderid and og.uniacid=:uniacid'
, array(':orderid' => $order['id'], ':uniacid' => $uniacid));
$is_last=true;//是否是订单最后一个退款商品
$refund_price=0;//订单商品退款总额
foreach ($order_goods as $og){
//过滤当前申请的ordergoods
if(intval($og['id']) != $order_goodsid){
if(empty($og['single_refundid'])){
$is_last=false;
break;
}
//其他商品退款总额
$refund_price+=$og['applyprice'];
}
}
if($is_last){
//应退金额=订单实际付款金额-其他商品退款总额
$order['single_refundprice']=$order['price']-$refund_price;
if ($order['status'] > 2) {
//如果已经发货,退款金额减去运费
$order['single_refundprice'] -= $order['dispatchprice'];
}
}else{
//订单优惠金额(不包含商品促销或会员折扣) = 积分抵扣金额+余额抵扣金额+商城满减金额+多商户满减金额+优惠券金额
$order_discount=$order['deductprice']+$order['deductcredit2']+$order['deductenough']+$order['merchdeductenough']+$order['couponprice'];
//商品优惠金额 = 订单优惠金额 x ( 商品实际付款金额(折扣后的商品价格,不包含运费) / 订单商品实际总价(折扣后的订单总价,不包含运费) )
$goods_discount =round($order_discount*($order['og_realprice']/$order['grprice']),2);
//应退金额=商品实际付款金额(折扣后的商品价格,不包含运费)-商品优惠金额
$order['single_refundprice']=$order['og_realprice']-$goods_discount;
}
if($order['single_refundprice']<=0){
$order['single_refundprice']=0;
}
return array(
'uniacid' => $uniacid,
'refundgoods' => $refundgoods,
'openid' => $_W['openid'],
'order_goodsid' => $order_goodsid,
'order' => $order,
'single_refundid' => $order['single_refundid'],
);
}
function main() {
global $_W, $_GPC;
extract($this->globalData());
if($order['status'] == 2 && $order['price'] == $order['dispatchprice']) {
$canreturns = 1;
}
// if ( $order['status'] == '-1'){
// $this->message('请不要重复提交!','','error');
// }
$refund = false;
if (!empty($single_refundid)) {
$refund = pdo_fetch("select * from " . tablename('ewei_shop_order_single_refund') . ' where id=:id and ordergoodsid=:ordergoodsid and uniacid=:uniacid limit 1'
, array(':id' => $single_refundid,':ordergoodsid' => $order_goodsid,':uniacid' => $uniacid));
if (!empty($refund['refundaddress'])) {
$refund['refundaddress'] = iunserializer($refund['refundaddress']);
}
}
if (!empty($refund['imgs'])) {
$refund['imgs'] = iunserializer($refund['imgs']);
}
$express_list = m('express')->getExpressList();
$trade = m('common')->getSysset('trade', $_W['uniacid']);
include $this->template();
}
//提交
function submit() {
global $_W, $_GPC;
extract($this->globalData());
if ($order['single_refundstate'] == '9'){
show_json(0, '商品维权已经处理完毕!');
}
$price = floatval($_GPC['price']);
$rtype = intval($_GPC['rtype']);
if ($rtype != 2) {
if (empty($price) && $order['deductprice'] == 0) {
show_json(0, '退款金额不能为0元');
}
//
if (round($price,2) > round($order['single_refundprice'],2)) {
show_json(0, '退款金额不能超过' . $order['single_refundprice'] . '元');
}
}
$refund = array(
'uniacid' => $uniacid,
'merchid' => $order['merchid'],
'applyprice' => $price,
'rtype' => $rtype,
'reason' => trim($_GPC['reason']),
'content' => trim($_GPC['content']),
'imgs' => iserializer($_GPC['images'])
);
if ($refund['rtype'] == 2) {
$refundstate = 2;
} else {
$refundstate = 1;
}
if ($order['single_refundstate'] == 0) {
//新建一条退款申请
$refund['createtime'] = time();
$refund['orderid'] = $order['id'];
$refund['ordergoodsid'] = $order_goodsid;
$refund['ordergoodsrealprice'] = $order['og_realprice'];//商品实际付款金额(折扣后的商品价格,不包含运费)
$refund['refundno'] = m('common')->createNO('order_refund', 'refundno', 'SR');
pdo_insert('ewei_shop_order_single_refund', $refund);
$single_refundid = pdo_insertid();
pdo_update('ewei_shop_order_goods', array('single_refundid' => $single_refundid, 'single_refundstate' => $refundstate), array('id' => $order_goodsid, 'uniacid' => $uniacid));
} else {
//修改退款申请
$refund['status']=0;
pdo_update('ewei_shop_order_goods', array('single_refundstate' => $refundstate), array('id' => $order_goodsid, 'uniacid' => $uniacid));
pdo_update('ewei_shop_order_single_refund', $refund, array('id' => $single_refundid, 'uniacid' => $uniacid));
}
pdo_update('ewei_shop_order', array('refundstate' => 3,'refundtime'=>0), array('id' => $order['id'], 'uniacid' => $uniacid));
//模板消息
m('notice')->sendOrderMessage($order['id'], true);
show_json(1);
}
//取消
function cancel() {
global $_W, $_GPC;
extract($this->globalData());
$change_refund = array();
$change_refund['status'] = -2;
$change_refund['refundtime'] = time();
pdo_update('ewei_shop_order_single_refund', $change_refund, array('id' => $single_refundid, 'uniacid' => $uniacid));
pdo_update('ewei_shop_order_goods', array('single_refundstate' => 0), array('id' => $order_goodsid, 'uniacid' => $uniacid));
$order_goods=pdo_fetchall("select single_refundid,single_refundstate,single_refundtime from ".tablename('ewei_shop_order_goods')." where orderid=:orderid",array(':orderid'=>$order['id']));
$refund_num=0;//退款过的订单商品数量
$apply_refund_num=0;//申请维权中的订单商品数量
foreach ($order_goods as $og){
if($og['single_refundtime']>0){
$refund_num++;
}
if($og['single_refundstate']==1 || $og['single_refundstate']==2){
$apply_refund_num++;
}
}
if(empty($apply_refund_num) && !empty($refund_num)){
pdo_update('ewei_shop_order', array('refundtime'=>time()), array('id' => $order['id'], 'uniacid' => $uniacid));
}
if(empty($apply_refund_num) && empty($refund_num)){
pdo_update('ewei_shop_order', array('refundstate' => 0,'refundtime'=>0), array('id' => $order['id'], 'uniacid' => $uniacid));
}
show_json(1);
}
//填写快递单号
function express() {
global $_W, $_GPC;
extract($this->globalData());
if (empty($single_refundid)) {
show_json(0, '参数错误!');
}
if (empty($_GPC['expresssn'])) {
show_json(0, '请填写快递单号');
}
$refund = array(
'status'=>4,
'express'=>trim($_GPC['express']),
'expresscom'=>trim($_GPC['expresscom']),
'expresssn'=>trim($_GPC['expresssn']),
'sendtime'=>time()
);
pdo_update('ewei_shop_order_single_refund', $refund, array('id' => $single_refundid, 'uniacid' => $uniacid));
show_json(1);
}
//收到换货商品
function receive(){
global $_W, $_GPC;
extract($this->globalData());
$single_refundid = intval($_GPC['single_refundid']);
$refund = pdo_fetch("select * from " . tablename('ewei_shop_order_single_refund') . ' where id=:id and ordergoodsid=:ordergoodsid and uniacid=:uniacid limit 1'
, array(':id' => $single_refundid,':ordergoodsid' => $order_goodsid,':uniacid' => $uniacid,));
if (empty($refund)) {
show_json(0, '换货申请未找到!');
}
$time = time();
$refund_data = array();
$refund_data['status'] = 1;
$refund_data['refundtime'] = $time;
pdo_update('ewei_shop_order_single_refund', $refund_data, array('id'=>$single_refundid, 'uniacid' => $uniacid));
$order_data = array();
$order_data['single_refundstate'] = 9;
pdo_update('ewei_shop_order_goods', $order_data, array('id'=>$order_goodsid, 'uniacid' => $uniacid));
//查询其它 订单商品 是否有正在维权中的
$is_single_refund=pdo_fetchcolumn('select count(id) from '.tablename('ewei_shop_order_goods').'where orderid=:orderid and (single_refundstate=1 or single_refundstate=2)',array(':orderid'=>$order['id']));
//如果其它 订单商品 没有正在维权中
if(empty($is_single_refund)){
//更新订单维权时间
pdo_update('ewei_shop_order', array('refundtime' => $time), array('id' => $order['id'], 'uniacid' => $uniacid));
}
show_json(1);
}
//查询商家重新发货快递
function refundexpress() {
global $_W, $_GPC;
extract($this->globalData());
$express = trim($_GPC['express']);
$expresssn = trim($_GPC['expresssn']);
$expresscom = trim($_GPC['expresscom']);
$expresslist = m('util')->getExpressList($express, $expresssn);
include $this->template('order/refundexpress');
}
}

View File

@@ -1,426 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Detail_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$id = intval($_GPC['id']);
$coupon = pdo_fetch('select * from ' . tablename('ewei_shop_coupon') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($coupon)) {
header('location: ' . mobileUrl('sale/coupon'));
exit();
}
$coupon = com('coupon')->setCoupon($coupon, time());
$title2 = '';
$title3 = '';
if ($coupon['coupontype'] == '0') {
if (0 < $coupon['enough']) {
$title2 = '满' . (double) $coupon['enough'] . '元可用';
}
else {
$title2 = '无金额门槛';
}
}
else {
if ($coupon['coupontype'] == '1') {
if (0 < $coupon['enough']) {
$title2 = '充值满' . (double) $coupon['enough'] . '元可用';
}
else {
$title2 = '无金额门槛';
}
}
}
if ($coupon['coupontype'] == '2') {
if (0 < $coupon['enough']) {
$title2 = '满' . (double) $coupon['enough'] . '元可用';
}
else {
$title2 = '无金额门槛';
}
}
if ($coupon['backtype'] == 0) {
if ($coupon['enough'] == '0') {
$coupon['color'] = 'orange';
}
else {
$coupon['color'] = 'blue';
}
$title3 = '<span class="subtitle nopadding">¥</span>' . (double) $coupon['deduct'];
}
if ($coupon['backtype'] == 1) {
$coupon['color'] = 'red ';
$title3 = (double) $coupon['discount'] . '折 ';
}
if ($coupon['backtype'] == 2) {
if ($coupon['coupontype'] == '0') {
$coupon['color'] = 'red ';
}
else {
$coupon['color'] = 'pink ';
}
if (!empty($coupon['backmoney']) && (0 < $coupon['backmoney'])) {
$backmoneytext = $coupon['backmoney'] . '元余额 ';
}
if (!empty($coupon['backcredit']) && (0 < $coupon['backcredit'])) {
$backcredittext = $coupon['backcredit'] . '积分 ';
}
if (!empty($coupon['backredpack']) && (0 < $coupon['backredpack'])) {
$backredpacktext = $coupon['backredpack'] . '元红包';
}
}
$coupon['title2'] = $title2;
$coupon['title3'] = $title3;
$goods = array();
$category = array();
if ($coupon['limitgoodtype'] != 0) {
if (!empty($coupon['limitgoodids'])) {
$where = 'and id in(' . $coupon['limitgoodids'] . ')';
}
$goods = pdo_fetchall('select `title` from ' . tablename('ewei_shop_goods') . ' where uniacid=:uniacid ' . $where, array(':uniacid' => $_W['uniacid']), 'id');
}
if ($coupon['limitgoodcatetype'] != 0) {
if (!empty($coupon['limitgoodcateids'])) {
$where = 'and id in(' . $coupon['limitgoodcateids'] . ')';
}
$category = pdo_fetchall('select `name` from ' . tablename('ewei_shop_category') . ' where uniacid=:uniacid ' . $where, array(':uniacid' => $_W['uniacid']), 'id');
}
$limitmemberlevels = explode(',', $coupon['limitmemberlevels']);
$limitagentlevels = explode(',', $coupon['limitagentlevels']);
$limitpartnerlevels = explode(',', $coupon['limitpartnerlevels']);
$limitaagentlevels = explode(',', $coupon['limitaagentlevels']);
$hascommission = false;
$plugin_com = p('commission');
if ($plugin_com) {
$plugin_com_set = $plugin_com->getSet();
$leveltitle2 = $plugin_com_set['texts']['agent'];
$hascommission = !empty($plugin_com_set['level']);
if (in_array('0', $limitagentlevels)) {
$commissionname = (empty($plugin_com_set['levelname']) ? '普通等级' : $plugin_com_set['levelname']);
}
}
$hasglobonus = false;
$plugin_globonus = p('globonus');
if ($plugin_globonus) {
$plugin_globonus_set = $plugin_globonus->getSet();
$leveltitle3 = $plugin_globonus_set['texts']['partner'];
$hasglobonus = !empty($plugin_globonus_set['open']);
if (in_array('0', $limitpartnerlevels)) {
$globonuname = (empty($plugin_globonus_set['levelname']) ? '普通等级' : $plugin_globonus_set['levelname']);
}
}
$hasabonus = false;
$abonu = '';
$plugin_abonus = p('abonus');
if ($plugin_abonus) {
$plugin_abonus_set = $plugin_abonus->getSet();
$leveltitle4 = $plugin_abonus_set['texts']['aagent'];
$hasabonus = !empty($plugin_abonus_set['open']);
if (in_array('0', $limitaagentlevels)) {
$abonuname = (empty($plugin_abonus_set['levelname']) ? '普通等级' : $plugin_abonus_set['levelname']);
}
}
$pass = false;
if ($coupon['islimitlevel'] == 1) {
$openid = trim($_W['openid']);
$member = m('member')->getMember($openid);
if (!empty($coupon['limitmemberlevels']) || ($coupon['limitmemberlevels'] == '0')) {
$shop = $_W['shopset']['shop'];
if (in_array('0', $limitmemberlevels)) {
$meblvname = (empty($shop['levelname']) ? '普通等级' : $shop['levelname']);
}
$level1 = pdo_fetchall('select * from ' . tablename('ewei_shop_member_level') . ' where uniacid=:uniacid and id in (' . $coupon['limitmemberlevels'] . ') ', array(':uniacid' => $_W['uniacid']));
if (in_array($member['level'], $limitmemberlevels)) {
$pass = true;
}
}
if ((!empty($coupon['limitagentlevels']) || ($coupon['limitagentlevels'] == '0')) && $hascommission) {
$level2 = pdo_fetchall('select * from ' . tablename('ewei_shop_commission_level') . ' where uniacid=:uniacid and id in (' . $coupon['limitagentlevels'] . ') ', array(':uniacid' => $_W['uniacid']));
if (($member['isagent'] == '1') && ($member['status'] == '1')) {
if (in_array($member['agentlevel'], $limitagentlevels)) {
$pass = true;
}
}
}
if ((!empty($coupon['limitpartnerlevels']) || ($coupon['limitpartnerlevels'] == '0')) && $hasglobonus) {
$level3 = pdo_fetchall('select * from ' . tablename('ewei_shop_globonus_level') . ' where uniacid=:uniacid and id in(' . $coupon['limitpartnerlevels'] . ') ', array(':uniacid' => $_W['uniacid']));
if (($member['ispartner'] == '1') && ($member['partnerstatus'] == '1')) {
if (in_array($member['partnerlevel'], $limitpartnerlevels)) {
$pass = true;
}
}
}
if ((!empty($coupon['limitaagentlevels']) || ($coupon['limitaagentlevels'] == '0')) && $hasabonus) {
$level4 = pdo_fetchall('select * from ' . tablename('ewei_shop_abonus_level') . ' where uniacid=:uniacid and id in (' . $coupon['limitaagentlevels'] . ') ', array(':uniacid' => $_W['uniacid']));
if (($member['isaagent'] == '1') && ($member['aagentstatus'] == '1')) {
if (in_array($member['aagentlevel'], $limitaagentlevels)) {
$pass = true;
}
}
}
}
else {
$pass = true;
}
$set = m('common')->getPluginset('coupon');
if (is_h5app()) {
$sec = m('common')->getSec();
$sec = iunserializer($sec['sec']);
$shopset = m('common')->getSysset();
$payinfo = array('wechat' => !empty($sec['app_wechat']['merchname']) && !empty($shopset['pay']['app_wechat']) && !empty($sec['app_wechat']['appid']) && !empty($sec['app_wechat']['appsecret']) && !empty($sec['app_wechat']['merchid']) && !empty($sec['app_wechat']['apikey']) ? true : false, 'alipay' => false, 'mcname' => $sec['app_wechat']['merchname'], 'logno' => NULL, 'money' => NULL, 'attach' => $_W['uniacid'] . ':4', 'type' => 4);
}
list(, $payment) = m('common')->public_build();
if (!empty($payment['is_new'])) {
if (($payment['type'] == 2) || ($payment['type'] == 3)) {
if (!empty($payment['sub_appsecret'])) {
m('member')->wxuser($payment['sub_appid'], $payment['sub_appsecret']);
}
}
}
include $this->template();
}
public function pay($a = array(), $b = array())
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$id = intval($_GPC['id']);
$coupon = pdo_fetch('select * from ' . tablename('ewei_shop_coupon') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
$coupon = com('coupon')->setCoupon($coupon, time());
if (empty($coupon['gettype'])) {
show_json(-1, '无法' . $coupon['gettypestr']);
}
if ($coupon['total'] != -1) {
if ($coupon['total'] <= 0) {
show_json(-1, '优惠券数量不足');
}
}
if (!$coupon['canget']) {
show_json(-1, '您已超出' . $coupon['gettypestr'] . '次数限制');
}
if (0 < $coupon['credit']) {
$credit = m('member')->getCredit($openid, 'credit1');
if ($credit < intval($coupon['credit'])) {
show_json(-1, '您的积分不足,无法' . $coupon['gettypestr'] . '!');
}
}
$needpay = false;
if (0 < $coupon['money']) {
pdo_delete('ewei_shop_coupon_log', array('couponid' => $id, 'openid' => $openid, 'status' => 0, 'paystatus' => 0));
$needpay = true;
$lastlog = pdo_fetch('select * from ' . tablename('ewei_shop_coupon_log') . ' where couponid=:couponid and openid=:openid and status=0 and paystatus=1 and uniacid=:uniacid limit 1', array(':couponid' => $id, ':openid' => $openid, ':uniacid' => $_W['uniacid']));
if (!empty($lastlog)) {
show_json(1, array('logid' => $lastlog['id']));
}
}
else {
pdo_delete('ewei_shop_coupon_log', array('couponid' => $id, 'openid' => $openid, 'status' => 0));
}
$logno = m('common')->createNO('coupon_log', 'logno', 'CC');
$log = array('uniacid' => $_W['uniacid'], 'merchid' => $coupon['merchid'], 'openid' => $openid, 'logno' => $logno, 'couponid' => $id, 'status' => 0, 'paystatus' => 0 < $coupon['money'] ? 0 : -1, 'creditstatus' => 0 < $coupon['credit'] ? 0 : -1, 'createtime' => time(), 'getfrom' => 1);
pdo_insert('ewei_shop_coupon_log', $log);
$logid = pdo_insertid();
if ($needpay) {
$useweixin = true;
if (!empty($coupon['usecredit2'])) {
$money = m('member')->getCredit($openid, 'credit2');
if ($coupon['money'] <= $money) {
$useweixin = false;
}
}
pdo_update('ewei_shop_coupon_log', array('paytype' => $useweixin ? 1 : 0), array('id' => $logid));
$set = m('common')->getSysset();
$sec = m('common')->getSec();
$sec = iunserializer($sec['sec']);
if ($useweixin && is_h5app()) {
if (empty($sec['app_wechat']['merchname']) || empty($set['pay']['app_wechat']) || empty($sec['app_wechat']['appid']) || empty($sec['app_wechat']['appsecret']) || empty($sec['app_wechat']['merchid']) || empty($sec['app_wechat']['apikey']) || empty($coupon['money'])) {
$useweixin = false;
}
}
if ($useweixin) {
if (is_h5app()) {
show_json(1, array('needpay' => true, 'logid' => $logid, 'logno' => $logno, 'money' => $coupon['money']));
}
$set['pay']['weixin'] = !empty($set['pay']['weixin_sub']) ? 1 : $set['pay']['weixin'];
$set['pay']['weixin_jie'] = !empty($set['pay']['weixin_jie_sub']) ? 1 : $set['pay']['weixin_jie'];
if (!is_weixin()) {
show_json(-1, '非微信环境!');
}
if (empty($set['pay']['weixin']) && empty($set['pay']['weixin_jie'])) {
show_json(0, '未开启微信支付!');
}
$wechat = array('success' => false);
$jie = intval($_GPC['jie']);
$params = array();
$params['tid'] = $log['logno'];
$params['user'] = $openid;
$params['fee'] = $coupon['money'];
$params['title'] = $set['shop']['name'] . '优惠券领取单号:' . $log['logno'];
if (isset($set['pay']) && ($set['pay']['weixin'] == 1) && ($jie !== 1)) {
load()->model('payment');
$setting = uni_setting($_W['uniacid'], array('payment'));
$options = array();
if (is_array($setting['payment'])) {
$options = $setting['payment']['wechat'];
$options['appid'] = $_W['account']['key'];
$options['secret'] = $_W['account']['secret'];
}
$wechat = m('common')->wechat_build($params, $options, 4);
if (!is_error($wechat)) {
$wechat['success'] = true;
if (!empty($wechat['code_url'])) {
$wechat['weixin_jie'] = true;
}
else {
$wechat['weixin'] = true;
}
}
}
if ((isset($set['pay']) && ($set['pay']['weixin_jie'] == 1) && !$wechat['success']) || ($jie === 1)) {
$params['tid'] = $params['tid'] . '_borrow';
$options = array();
$options['appid'] = $sec['appid'];
$options['mchid'] = $sec['mchid'];
$options['apikey'] = $sec['apikey'];
if (!empty($set['pay']['weixin_jie_sub']) && !empty($sec['sub_secret_jie_sub'])) {
$wxuser = m('member')->wxuser($sec['sub_appid_jie_sub'], $sec['sub_secret_jie_sub']);
$params['openid'] = $wxuser['openid'];
}
else {
if (!empty($sec['secret'])) {
$wxuser = m('member')->wxuser($sec['appid'], $sec['secret']);
$params['openid'] = $wxuser['openid'];
}
}
$wechat = m('common')->wechat_native_build($params, $options, 4);
if (!is_error($wechat)) {
$wechat['success'] = true;
if (!empty($params['openid'])) {
$wechat['weixin'] = true;
}
else {
$wechat['weixin_jie'] = true;
}
}
}
$wechat['jie'] = $jie;
if (!$wechat['success']) {
show_json(0, '微信支付参数错误!');
}
show_json(1, array('logid' => $logid, 'wechat' => $wechat));
}
}
show_json(1, array('logid' => $logid));
}
public function payresult($a = array())
{
global $_W;
global $_GPC;
$logid = intval($_GPC['logid']);
$log = pdo_fetch('select id,logno,status,paystatus,couponid from ' . tablename('ewei_shop_coupon_log') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $logid, ':uniacid' => $_W['uniacid']));
if (empty($log)) {
show_json(-1, '订单未找到');
}
$coupon = com('coupon')->getCoupon($log['couponid']);
if (!empty($coupon['usecredit2']) || ($coupon['money'] <= 0)) {
$result = com('coupon')->payResult($log['logno']);
if (is_error($result)) {
show_json($result['errno'], $result['message']);
}
}
else {
if (empty($log['paystatus'])) {
show_json(0, '支付未成功!');
}
}
show_json(1, array('url' => $result['url'], 'dataid' => $result['dataid'], 'coupontype' => $result['coupontype']));
}
public function recommand()
{
$goods = m('goods')->getList(array('pagesize' => 4, 'isrecommand' => true, 'random' => true));
show_json(1, array('list' => $goods));
}
}
?>

View File

@@ -1,651 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobileLoginPage {
//多商户
protected function merchData() {
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if ($merch_plugin && $merch_data['is_openmerch']) {
$is_openmerch = 1;
} else {
$is_openmerch = 0;
}
return array(
'is_openmerch' => $is_openmerch,
'merch_plugin' => $merch_plugin,
'merch_data' => $merch_data
);
}
function main() {
global $_W, $_GPC;
$openid = $_W['openid'];
$cateid = trim($_GPC['catid']);
$timestamp=time();
$set = m('common')->getPluginset('coupon');
if(!empty($set['closecenter'])){
header('location: '.mobileUrl('member'));
exit;
}
//多商户
$merchdata = $this->merchData();
extract($merchdata);
// 读取幻灯片
$advs = is_array($set['advs']) ? $set['advs'] : array();
$shop = m('common')->getSysset('shop');
// 读取分类
$param = array();
$param[':uniacid'] = $_W['uniacid'];
$sql = 'select * from ' . tablename('ewei_shop_coupon_category') . ' where uniacid=:uniacid';
if ($is_openmerch == 0) {
$sql .= ' and merchid=0';
} else {
if (!empty($_GPC['merchid'])) {
$sql .= ' and merchid=:merchid';
$param[':merchid'] = intval($_GPC['merchid']);
}
}
$sql .= ' and status=1 order by displayorder desc';
$category = pdo_fetchall($sql, $param);
include $this->template();
}
function getcoupon($cateid){
global $_W;
//多商户
$merchdata = $this->merchData();
extract($merchdata);
$time = time();
$param = array();
$param[':uniacid'] = $_W['uniacid'];
$sql = "select id,timelimit,coupontype,timedays,timestart,timeend,couponname,enough,backtype,deduct,discount,backmoney,backcredit,backredpack,bgcolor,thumb,credit,money,getmax,merchid,total as t,tagtitle,settitlecolor,titlecolor from " . tablename('ewei_shop_coupon');
$sql.=" where uniacid=:uniacid";
if ($is_openmerch == 0) {
$sql .= ' and merchid=0';
}else {
if (!empty($_GPC['merchid'])) {
$sql .= ' and merchid=:merchid';
$param[':merchid'] = intval($_GPC['merchid']);
}
}
//分销商限制
$plugin_com = p('commission');
if ($plugin_com) {
$plugin_com_set = $plugin_com->getSet();
if(empty($plugin_com_set['level']))
{
$sql .= ' and ( limitagentlevels = "" or limitagentlevels is null )';
}
}
else
{
$sql .= ' and ( limitagentlevels = "" or limitagentlevels is null )';
}
//股东限制
$plugin_globonus = p('globonus');
if ($plugin_globonus) {
$plugin_globonus_set = $plugin_globonus->getSet();
if(empty($plugin_globonus_set['open']))
{
$sql .= ' and ( limitpartnerlevels = "" or limitpartnerlevels is null )';
}
}
else
{
$sql .= ' and ( limitpartnerlevels = "" or limitpartnerlevels is null )';
}
//区域代理限制
$plugin_abonus = p('abonus');
if ($plugin_abonus) {
$plugin_abonus_set = $plugin_abonus->getSet();
if(empty($plugin_abonus_set['open']))
{
$sql .= ' and ( limitaagentlevels = "" or limitaagentlevels is null )';
}
}
else
{
$sql .= ' and ( limitaagentlevels = "" or limitaagentlevels is null )';
}
$sql.=" and gettype=1 and (total=-1 or total>0) and ( timelimit = 0 or (timelimit=1 and timeend>unix_timestamp()))";
if (!empty($cateid)) {
$sql.=" and catid=" . $cateid;
}
$sql.=" order by displayorder desc, id desc ";
$coupons = set_medias(pdo_fetchall($sql, $param), 'thumb');
if(empty($coupons))
{
$coupons=array();
}
foreach ($coupons as $i=>&$row) {
$row = com('coupon')->setCoupon($row, $time);
$last= com('coupon')->get_last_count($row['id']);
$row['contype'] =2;
if($row['t']!=-1)
{
if($last <=0)
{
$row['last']= 0;
$row['isdisa']='1';
}
else
{
$totle = $row['t'];
$row['last']= $last;
$row['lastratio']= intval($last/$totle*100);
}
}else
{
$row['last']= 1;
$row['lastratio']= 100;
}
$title2='';
$title3='';
$title4='';
$tagtitle = '';
if($row['coupontype']=='0')
{
if($row['enough']>0)
{
$title2 ='满'.((float)$row['enough']).'元可用';
}
else
{
$title2 = '无金额门槛';
}
}
elseif($row['coupontype']=='1')
{
if($row['enough']>0)
{
$title2 ='充值满'.((float)$row['enough']).'元可用';
}else
{
$title2 = '无金额门槛';
}
} if($row['coupontype']=='2')
{
if($row['enough']>0)
{
$title2 ='满'.((float)$row['enough']).'元可用';
}
else
{
$title2 = '无金额门槛';
}
}
if($row['backtype']==0)
{
$title3='<span class="subtitle">¥</span>'.((float)$row['deduct']);
if($row['enough']=='0')
{
$title5='消费任意金额立减'.((float)$row['deduct']);
$row['color']='orange ';
$tagtitle = '代金券';
}
else
{
$title5='消费满'.(float)$row['enough'].'立减'.((float)$row['deduct']);
$row['color']='blue';
$tagtitle = '满减券';
}
}else if($row['backtype']==1)
{
$row['color']='red ';
$title3=((float)$row['discount']).'<span class="subtitle"> 折</span> ';
$tagtitle = '打折券';
if($row['enough']=='0')
{
$title5='消费任意金额'.'打'.((float)$row['discount']).'折';
}
else
{
$title5='消费满'.(float)$row['enough'].'打'.((float)$row['discount']).'折';
}
}else if($row['backtype']==2)
{
if($row['coupontype']=='0')
{
$row['color']='red ';
$tagtitle = '购物返现券';
}
else if($row['coupontype']=='1')
{
$row['color']='pink ';
$tagtitle = '充值返现券';
}
else if($row['coupontype']=='2')
{
$row['color']='red ';
$tagtitle = '购物返现券';
}
if($row['enough']=='0') {
$title5 = '消费任意金额';
}else
{
$title5 = '消费满' . (float)$row['enough'];
}
if (!empty($row['backmoney']) && $row['backmoney'] > 0) {
// $title3 = '送<span>'.$row['backmoney'].'</span>元余额 ';
$title3="立返";
$title5=$title5."立返余额";
}
elseif (!empty($row['backcredit']) && $row['backcredit'] > 0) {
//$title3 = '送<span>'.$row['backcredit'].'</span>积分 ';
$title3="立返";
$title5=$title5."立返积分";
}
elseif (!empty($row['backredpack']) && $row['backredpack'] > 0) {
//$title3 = '送<span>'.$row['backredpack'].'</span>元红包 ';
$title5=$title5."立返红包";
}
}
if($row['tagtitle']=='')
{
$row['tagtitle'] = $tagtitle;
}
if ($row['timestr']=='0')
{
$title4='永久有效';
}
else if($row['timestr']=='1')
{
$title4 ='即'.$row['gettypestr'].'日内'. $row['timedays'].'天有效';
}else
{
$title4 =$row['timestr'];
}
$row['title2']= $title2;
$row['title3']= $title3;
$row['title4']= $title4;
$row['title5']= $title5;
}
unset($row);
return $coupons;
}
function getwxcard(){
global $_W;
//多商户
$merchdata = $this->merchData();
extract($merchdata);
$time = time();
$param = array();
$param[':uniacid'] = $_W['uniacid'];
$sql = "select id,card_id,0 as coupontype,card_type, least_cost,reduce_cost,discount,datetype,begin_timestamp,end_timestamp,fixed_term,fixed_begin_term, merchid,title as couponname,logo_url as thumb ,total_quantity as t,quantity as `last`,tagtitle,settitlecolor,titlecolor,islimitlevel, limitmemberlevels,limitagentlevels,limitpartnerlevels,limitaagentlevels from " . tablename('ewei_shop_wxcard');
$sql.=" where uniacid=:uniacid";
if ($is_openmerch == 0) {
$sql .= ' and merchid=0';
}else {
if (!empty($_GPC['merchid'])) {
$sql .= ' and merchid=:merchid';
$param[':merchid'] = intval($_GPC['merchid']);
}
}
//分销商限制
$plugin_com = p('commission');
if ($plugin_com) {
$plugin_com_set = $plugin_com->getSet();
if(empty($plugin_com_set['level']))
{
$sql .= ' and ( limitagentlevels = "" or limitagentlevels is null )';
}
}
else
{
$sql .= ' and ( limitagentlevels = "" or limitagentlevels is null )';
}
//股东限制
$plugin_globonus = p('globonus');
if ($plugin_globonus) {
$plugin_globonus_set = $plugin_globonus->getSet();
if(empty($plugin_globonus_set['open']))
{
$sql .= ' and ( limitpartnerlevels = "" or limitpartnerlevels is null )';
}
}
else
{
$sql .= ' and ( limitpartnerlevels = "" or limitpartnerlevels is null )';
}
//区域代理限制
$plugin_abonus = p('abonus');
if ($plugin_abonus) {
$plugin_abonus_set = $plugin_abonus->getSet();
if(empty($plugin_abonus_set['open']))
{
$sql .= ' and ( limitaagentlevels = "" or limitaagentlevels is null )';
}
}
else
{
$sql .= ' and ( limitaagentlevels = "" or limitaagentlevels is null )';
}
$sql.=" and gettype=1 and quantity>0 and ( datetype = 'DATE_TYPE_FIX_TERM' or (datetype='DATE_TYPE_FIX_TIME_RANGE' and end_timestamp>unix_timestamp()))";
if (!empty($cateid)) {
$sql.=" and catid=" . $cateid;
}
$sql.=" order by displayorder desc, id desc ";
$wxcard = pdo_fetchall($sql, $param);
if(empty($wxcard))
{
$wxcard=array();
}
//分销商限制
$hascommission = false;
$plugin_com = p('commission');
if ($plugin_com) {
$plugin_com_set = $plugin_com->getSet();
$hascommission = !empty($plugin_com_set['level']);
}
//股东限制
$hasglobonus = false;
$plugin_globonus = p('globonus');
if ($plugin_globonus) {
$plugin_globonus_set = $plugin_globonus->getSet();
$hasglobonus = !empty($plugin_globonus_set['open']);
}
//区域代理限制
$hasabonus = false;
$plugin_abonus = p('abonus');
if ($plugin_abonus) {
$plugin_abonus_set = $plugin_abonus->getSet();
$hasabonus = !empty($plugin_abonus_set['open']);
}
foreach ($wxcard as $i=>&$row) {
//分类限制
$limitmemberlevels =explode(",", $row['limitmemberlevels']);
$limitagentlevels =explode(",", $row['limitagentlevels']);
$limitpartnerlevels=explode(",", $row['limitpartnerlevels']);
$limitaagentlevels=explode(",", $row['limitaagentlevels']);
$pass = false;
if($row['islimitlevel'] ==1) {
$openid = trim($_W['openid']);
$member = m('member')->getMember($openid);
if(!empty($row['limitmemberlevels'])||$row['limitmemberlevels']=='0')
{
//会员等级
$shop = $_W['shopset']['shop'];
if (in_array($member['level'],$limitmemberlevels)){
$pass = true;
}
};
if((!empty($row['limitagentlevels'])||$row['limitagentlevels']=='0')&&$hascommission) {
if($member['isagent']=='1'&&$member['status']=='1')
{
if (in_array($member['agentlevel'],$limitagentlevels)){
$pass = true;
}
}
}
if((!empty($row['limitpartnerlevels'])||$row['limitpartnerlevels']=='0')&&$hasglobonus) {
if($member['ispartner']=='1'&&$member['partnerstatus']=='1')
{
if (in_array($member['partnerlevel'],$limitpartnerlevels)){
$pass = true;
}
}
}
if((!empty($row['limitaagentlevels'])||$row['limitaagentlevels']=='0')&&$hasabonus) {
if($member['isaagent']=='1'&&$member['aagentstatus']=='1')
{
if (in_array($member['aagentlevel'],$limitaagentlevels)){
$pass = true;
}
}
}
}else
{
$pass = true;
}
$row['pass'] =$pass;
$row['contype'] =1;
$totle = $row['t'];
$last = $row['last'];
$row['lastratio']= intval($last/$totle*100);
$title2='';
$title3='';
$title4='';
$tagtitle = '';
if($row['coupontype']=='0')
{
if($row['least_cost']>0)
{
$title2 ='满'.(((float)$row['least_cost'])/100).'元可用';
}
else
{
$title2 = '无金额门槛';
}
}
if($row['card_type']=="CASH")
{
$title3='<span class="subtitle">¥</span>'.((float)$row['reduce_cost']/100);
if(empty($row['least_cost']))
{
$title5='消费任意金额立减'.((float)$row['deduct']);
$row['color']='orange ';
$tagtitle = '代金券';
}
else
{
$title5='消费满'.((float)$row['least_cost']/100).'立减'.((float)$row['reduce_cost']/100);
$row['color']='blue';
$tagtitle = '满减券';
}
}
if($row['card_type']=="DISCOUNT")
{
$discount = (float)(100 -intval($row['discount']))/10;
$row['color']='red ';
$title3=$discount.'<span class="subtitle"> 折</span> ';
$tagtitle = '打折券';
$title5='消费任意金额'.'打'.$discount.'折';
}
if($row['tagtitle']=='')
{
$row['tagtitle'] = $tagtitle;
}
if ($row['datetype']=='DATE_TYPE_FIX_TIME_RANGE')
{
$title4 =date('Y.m.d', $row['begin_timestamp']).'-'.date('Y.m.d', $row['end_timestamp']);
}
else if($row['datetype']=='DATE_TYPE_FIX_TERM')
{
if(empty($row['fixed_begin_term']))
{
$begin="当日生效";
}else
{
$begin ='内'. $row['fixed_begin_term'].'生效,';
}
$title4 ='即领取日'.$begin. $row['fixed_term'].'天有效';
}
$row['title2']= $title2;
$row['title3']= $title3;
$row['title4']= $title4;
$row['title5']= $title5;
}
unset($row);
$wxcardlist = array();
foreach ($wxcard as $row) {
if(!empty($row["pass"]))
{
$wxcardlist[]=$row;
}
}
return $wxcardlist;
}
function getlist(){
global $_W, $_GPC;
// 读取 优惠券
$cateid = trim($_GPC['cateid']);
$coupons =$this->getcoupon($cateid);
foreach ($coupons as $k=>&$v){
$v = com('coupon')->setCoupon($v, time());
}
unset($v);
$wxcard =$this->getwxcard($cateid);
$cards= array_merge ($wxcard,$coupons);
$pindex = max(1, intval($_GPC['page']));
$psize = 10;
$cardslist =array();
for($i=0;$i<count($cards);$i++)
{
if($i>=($pindex-1)*$psize&&$i<$pindex*$psize)
{
$cardslist[] =$cards[$i];
}
}
show_json(1, array('list' => $cardslist, 'pagesize' => $psize, 'total'=>count($cards)));
}
function getsignature(){
global $_W, $_GPC;
$timestamp =time()+"";
$nonce_str = random(16)+"";
$card_id =$_GPC['card_id'];
$openid=$_GPC['openid'];
$code=empty($_GPC['code'])?"":$_GPC['code'];
$signature =com("wxcard")->getsignature($card_id,$timestamp,$nonce_str,$openid,$code);
$arr = array(
'code'=>$code,
'openid'=>$openid,
'timestamp'=>$timestamp,
'nonce_str'=>$nonce_str,
'signature'=>$signature
);
//'{"code":"", "openid": "{$openid}","timestamp": "' + data.result.timestamp + '", "nonce_str":"' + data.result.nonce_str + '", "signature":"' + data.result.signature + '"}'
show_json(1, array('cardExt'=>json_encode($arr)));
}
function updateQuantity(){
global $_W, $_GPC;
$cardList =$_GPC['cardList'];
if($cardList && !is_array($cardList)){
$cardList = json_decode($cardList,true);
}
sleep(5);
foreach($cardList as $card)
{
if($card && !is_array($card)){
$card = json_decode($card,true);
}
if(com("wxcard")) {
com("wxcard")->wxCardUpdateQuantity($card['cardId']);
}
}
show_json(1);
}
/*
function updateQuantity(){
global $_W, $_GPC;
$id = intval($_GPC['id']);
if(!empty($id))
{
com("wxcard")->wxCardUpdateQuantity($id);
}
show_json(1, array('url' => referer()));
}*/
}

View File

@@ -1,793 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class My_EweiShopV2Page extends MobileLoginPage
{
public function main()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$set = m('common')->getPluginset('coupon');
com('coupon')->setShare();
include $this->template();
}
public function detail()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$data = pdo_fetch('select * from ' . tablename('ewei_shop_coupon_data') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($data)) {
if (empty($coupon)) {
header('location: ' . mobileUrl('sale/coupon/my'));
exit();
}
}
$coupon = pdo_fetch('select * from ' . tablename('ewei_shop_coupon') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $data['couponid'], ':uniacid' => $_W['uniacid']));
if (empty($coupon)) {
header('location: ' . mobileUrl('sale/coupon/my'));
exit();
}
$coupon['gettime'] = $data['gettime'];
$coupon['back'] = $data['back'];
$coupon['backtime'] = $data['backtime'];
$coupon['used'] = $data['used'];
$coupon['usetime'] = $data['usetime'];
$time = time();
$coupon = com('coupon')->setMyCoupon($coupon, $time);
$commonset = m('common')->getPluginset('coupon');
if ($coupon['descnoset'] == '0') {
if ($coupon['coupontype'] == '0') {
$coupon['desc'] = $commonset['consumedesc'];
}
else if ($coupon['coupontype'] == '1') {
$coupon['desc'] = $commonset['rechargedesc'];
}
else {
$coupon['desc'] = $commonset['consumedesc'];
}
}
$title2 = '';
$title3 = '';
if ($coupon['coupontype'] == '0') {
if (0 < $coupon['enough']) {
$title2 = '满' . (double) $coupon['enough'] . '元';
}
else {
$title2 = '购物任意金额';
}
}
else if ($coupon['coupontype'] == '1') {
if (0 < $coupon['enough']) {
$title2 = '充值满' . (double) $coupon['enough'] . '元';
}
else {
$title2 = '充值任意金额';
}
}
else {
if ($coupon['coupontype'] == '2') {
if (0 < $coupon['enough']) {
$title2 = '满' . (double) $coupon['enough'] . '元';
}
else {
$title2 = '购物任意金额';
}
}
}
if ($coupon['backtype'] == 0) {
if ($coupon['enough'] == '0') {
$coupon['color'] = 'orange ';
}
else {
$coupon['color'] = 'blue';
}
$title3 = '减' . (double) $coupon['deduct'] . '元';
}
if ($coupon['backtype'] == 1) {
$coupon['color'] = 'red ';
$title3 = '打' . (double) $coupon['discount'] . '折 ';
}
if ($coupon['backtype'] == 2) {
if ($coupon['coupontype'] == '0' || $coupon['coupontype'] == '2') {
$coupon['color'] = 'red ';
}
else {
$coupon['color'] = 'pink ';
}
if (!empty($coupon['backmoney']) && 0 < $coupon['backmoney']) {
$title3 = $title3 . '送' . $coupon['backmoney'] . '元余额 ';
}
if (!empty($coupon['backcredit']) && 0 < $coupon['backcredit']) {
$title3 = $title3 . '送' . $coupon['backcredit'] . '积分 ';
}
if (!empty($coupon['backredpack']) && 0 < $coupon['backredpack']) {
$title3 = $title3 . '送' . $coupon['backredpack'] . '元红包 ';
}
}
if ($coupon['past'] || !empty($data['used'])) {
$coupon['color'] = 'disa';
}
$coupon['title2'] = $title2;
$coupon['title3'] = $title3;
$goods = array();
$category = array();
if ($coupon['limitgoodtype'] != 0) {
if (!empty($coupon['limitgoodids'])) {
$where = 'and id in(' . $coupon['limitgoodids'] . ')';
}
$goods = pdo_fetchall('select `title` from ' . tablename('ewei_shop_goods') . ' where uniacid=:uniacid ' . $where, array(':uniacid' => $_W['uniacid']), 'id');
}
if ($coupon['limitgoodcatetype'] != 0) {
if (!empty($coupon['limitgoodcateids'])) {
$where = 'and id in(' . $coupon['limitgoodcateids'] . ')';
}
$category = pdo_fetchall('select `name` from ' . tablename('ewei_shop_category') . ' where uniacid=:uniacid ' . $where, array(':uniacid' => $_W['uniacid']), 'id');
}
$num = pdo_fetchcolumn('select ifnull(count(*),0) from ' . tablename('ewei_shop_coupon_data') . ' where couponid=:couponid and openid=:openid and uniacid=:uniacid and used=0 ', array(':couponid' => $coupon['id'], ':openid' => $_W['openid'], ':uniacid' => $_W['uniacid']));
$canuse = !$coupon['past'] && empty($data['used']);
if ($coupon['coupontype'] == 0) {
$useurl = mobileUrl('sale/coupon/my/showcoupongoods', array('id' => $id));
}
else if ($coupon['coupontype'] == 1) {
$useurl = mobileUrl('member/recharge');
}
else {
if ($coupon['coupontype'] == 2) {
$useurl = mobileUrl('sale/coupon/my');
}
}
$set = $_W['shopset']['coupon'];
com('coupon')->setShare();
include $this->template();
}
public function getlist()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$cate = trim($_GPC['cate']);
$check = 0;
if (!empty($cate)) {
if ($cate == 'used') {
$used = 1;
$check = 1;
}
else {
$past = 1;
$check = 2;
}
}
$pindex = max(1, intval($_GPC['page']));
$psize = 10;
$time = time();
$sql = 'select d.id,d.couponid,d.gettime,c.timelimit,c.coupontype,c.timedays,c.timestart,c.timeend,c.thumb,c.couponname,c.enough,c.backtype,c.deduct,c.discount,c.backmoney,c.backcredit,c.backredpack,c.bgcolor,c.thumb,c.merchid,c.tagtitle,c.settitlecolor,c.titlecolor from ' . tablename('ewei_shop_coupon_data') . ' d';
$sql .= ' inner join ' . tablename('ewei_shop_coupon') . ' c on d.couponid = c.id';
$sql .= ' where d.openid=:openid and d.uniacid=:uniacid ';
if (!empty($past)) {
$sql .= ' and ( (c.timelimit =0 and c.timedays<>0 and c.timedays*86400 + d.gettime <unix_timestamp()) or (c.timelimit=1 and c.timeend<unix_timestamp() ))';
}
else if (!empty($used)) {
$sql .= ' and d.used =1 ';
}
else {
if (empty($used)) {
$sql .= ' and ( (c.timelimit = 0 and ( c.timedays=0 or c.timedays*86400 + d.gettime >=unix_timestamp() ) ) or (c.timelimit =1 and c.timeend>=' . $time . ')) and d.used =0 ';
}
}
$total = pdo_fetchcolumn($sql, array(':openid' => $openid, ':uniacid' => $_W['uniacid']));
$sql .= ' order by d.gettime desc LIMIT ' . ($pindex - 1) * $psize . ',' . $psize;
$coupons = set_medias(pdo_fetchall($sql, array(':openid' => $openid, ':uniacid' => $_W['uniacid'])), 'thumb');
pdo_update('ewei_shop_coupon_data', array('isnew' => 0), array('uniacid' => $_W['uniacid'], 'openid' => $_W['openid']));
if (empty($coupons)) {
$coupons = array();
}
foreach ($coupons as $i => &$row) {
$row = com('coupon')->setMyCoupon($row, $time);
$title2 = '';
if ($row['coupontype'] == '0') {
if (0 < $row['enough']) {
$title2 = '满' . (double) $row['enough'] . '元可用';
$title5 = '消费满' . (double) $row['enough'];
}
else {
$title2 = '无金额门槛';
$title5 = '消费任意金额';
}
}
else if ($row['coupontype'] == '1') {
if (0 < $row['enough']) {
$title2 = '充值满' . (double) $row['enough'] . '元可用';
$title5 = '充值满' . (double) $row['enough'];
}
else {
$title2 = '无金额门槛';
$title5 = '充值任意金额';
}
}
else {
if ($row['coupontype'] == '2') {
if (0 < $row['enough']) {
$title2 = '满' . (double) $row['enough'] . '元可用';
$title5 = '消费满' . (double) $row['enough'];
}
else {
$title2 = '无金额门槛';
$title5 = '消费任意金额';
}
}
}
if ($row['backtype'] == 0) {
$title3 = '<span class="subtitle">¥</span>' . (double) $row['deduct'];
$title5 = $title5 . '立减' . (double) $row['deduct'];
if ($row['enough'] == '0') {
$row['color'] = 'orange ';
$tagtitle = '代金券';
}
else {
$row['color'] = 'blue';
$tagtitle = '满减券';
}
}
if ($row['backtype'] == 1) {
$row['color'] = 'red ';
$title3 = (double) $row['discount'] . '折 ';
$title5 = $title5 . '打' . (double) $row['discount'] . '折 ';
$tagtitle = '打折券';
}
if ($row['backtype'] == 2) {
if ($row['coupontype'] == '0') {
$row['color'] = 'red ';
$tagtitle = '购物返现券';
}
else if ($row['coupontype'] == '1') {
$row['color'] = 'pink ';
$tagtitle = '充值返现券';
}
else {
if ($row['coupontype'] == '2') {
$row['color'] = 'red ';
$tagtitle = '购物返现券';
}
}
if (!empty($row['backmoney']) && 0 < $row['backmoney']) {
$title3 = '立返';
$title5 = '立返余额';
}
if (!empty($row['backcredit']) && 0 < $row['backcredit']) {
$title3 = '立返';
$title5 = '立返积分';
}
if (!empty($row['backredpack']) && 0 < $row['backredpack']) {
$title3 = '立返';
$title5 = '立返红包';
}
}
if ($row['tagtitle'] == '') {
$row['tagtitle'] = $tagtitle;
}
if ($past == 1) {
$row['color'] = 'disa';
}
$row['check'] = $check;
$row['title2'] = $title2;
$row['title3'] = $title3;
$row['title5'] = $title5;
}
unset($row);
show_json(1, array('list' => $coupons, 'pagesize' => $psize, 'total' => $total));
}
public function showcoupons()
{
global $_W;
global $_GPC;
$key = $_GPC['key'];
$openid = $_W['openid'];
$time = time();
$sql = 'select d.id,d.couponid,d.gettime,c.timelimit,c.coupontype,c.timedays,c.timestart,c.timeend,c.thumb,c.couponname,c.enough,c.backtype,c.deduct,c.discount,c.backmoney,c.backcredit,c.backredpack,c.bgcolor,c.thumb,c.merchid,c.tagtitle,c.settitlecolor,c.titlecolor from ' . tablename('ewei_shop_coupon_sendshow') . ' cs';
$sql .= ' inner join ' . tablename('ewei_shop_coupon_data') . ' d on d.id=cs.coupondataid';
$sql .= ' inner join ' . tablename('ewei_shop_coupon') . ' c on d.couponid = c.id ';
$sql .= ' where cs.openid=:openid and cs.uniacid=:uniacid and showkey=:key ';
$sql .= ' order by d.gettime desc ';
$coupons = set_medias(pdo_fetchall($sql, array(':openid' => $openid, ':uniacid' => $_W['uniacid'], ':key' => $key)), 'thumb');
if (empty($coupons)) {
$coupons = array();
}
foreach ($coupons as $i => &$row) {
$imgname = 'ling';
$row = com('coupon')->setMyCoupon($row, $time);
$title2 = '';
if ($row['coupontype'] == '0') {
if (0 < $row['enough']) {
$title2 = '消费满' . (double) $row['enough'] . '元';
}
else {
$title2 = '消费';
}
}
else if ($row['coupontype'] == '1') {
if (0 < $row['enough']) {
$title2 = '充值满' . (double) $row['enough'] . '元';
}
else {
$title2 = '充值';
}
}
else {
if ($row['coupontype'] == '2') {
if (0 < $row['enough']) {
$title2 = '消费满' . (double) $row['enough'] . '元';
}
else {
$title2 = '消费';
}
}
}
if ($row['backtype'] == 0) {
$title2 = $title2 . '立减' . (double) $row['deduct'] . '元';
if ($row['enough'] == '0') {
$row['color'] = 'orange ';
$tagtitle = '代金券';
}
else {
$row['color'] = 'blue';
$tagtitle = '满减券';
}
}
if ($row['backtype'] == 1) {
$row['color'] = 'red ';
$title2 = $title2 . '打' . (double) $row['discount'] . '折';
$tagtitle = '打折券';
}
if ($row['backtype'] == 2) {
if ($row['coupontype'] == '0') {
$row['color'] = 'red ';
$tagtitle = '购物返现券';
}
else if ($row['coupontype'] == '1') {
$row['color'] = 'pink ';
$tagtitle = '充值返现券';
}
else {
if ($row['coupontype'] == '2') {
$row['color'] = 'red ';
$tagtitle = '购物返现券';
}
}
if (!empty($row['backmoney']) && 0 < $row['backmoney']) {
$title2 = $title2 . '送' . $row['discount'] . '元余额';
}
if (!empty($row['backcredit']) && 0 < $row['backcredit']) {
$title2 = $title2 . '送' . $row['discount'] . '积分';
}
if (!empty($row['backredpack']) && 0 < $row['backredpack']) {
$title2 = $title2 . '送' . $row['discount'] . '元红包';
}
}
if ($row['tagtitle'] == '') {
$row['tagtitle'] = $tagtitle;
}
$check = 0;
if ($row['used'] == 1) {
$check = 1;
$imgname = 'used';
}
else {
if ($row['timelimit'] == 0 && $row['timedays'] != 0 && $row['timedays'] * 86400 + $row['gettime'] < time() || $row['timelimit'] == 1 && $row['timeend'] < time()) {
$check = 2;
$row['color'] = 'disa';
$imgname = 'past';
}
}
$row['imgname'] = $imgname;
$row['check'] = $check;
$row['title2'] = $title2;
}
unset($row);
include $this->template();
}
public function showcoupons2()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$data = pdo_fetch('select c.* from ' . tablename('ewei_shop_coupon_data') . ' cd inner join ' . tablename('ewei_shop_coupon') . ' c on cd.couponid = c.id where cd.id=:id and cd.uniacid=:uniacid and coupontype =0 limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($data)) {
if (empty($coupon)) {
header('location: ' . mobileUrl('sale/coupon/my'));
exit();
}
}
if (7 < mb_strlen($data['couponname'], 'utf-8')) {
$data['couponname'] = mb_substr($data['couponname'], 0, 7, 'utf-8') . '...';
}
$title1 = '';
$title2 = '';
if ($data['backtype'] == 0) {
$title1 = '<span>¥</span>' . (double) $data['deduct'];
}
else if ($data['backtype'] == 1) {
$title1 = (double) $data['discount'] . '<span>折</span>';
}
else {
if ($data['backtype'] == 2) {
if (!empty($data['backmoney']) && 0 < $data['backmoney']) {
$title1 = '送' . $data['backmoney'] . '元余额';
}
if (!empty($data['backcredit']) && 0 < $data['backcredit']) {
$title1 .= '送' . $data['backcredit'] . '积分';
}
if (!empty($data['backredpack']) && 0 < $data['backredpack']) {
$title1 .= '送' . $data['backredpack'] . '元红包';
}
}
}
if (0 < $data['enough']) {
$title2 = '满' . (double) $data['enough'] . '元使用';
}
else {
$title2 = '无金额门槛';
}
$goods = array();
$params = array(':uniacid' => $_W['uniacid']);
$sql = 'select distinct g.* from ';
$table = '';
if ($data['limitgoodcatetype'] == 1 && !empty($data['limitgoodcateids'])) {
$limitcateids = explode(',', $data['limitgoodcateids']);
if (0 < count($limitcateids)) {
$table = '(';
$i = 0;
foreach ($limitcateids as $cateid) {
++$i;
if (1 < $i) {
$table .= ' union all ';
}
$table .= 'select * from ' . tablename('ewei_shop_goods') . ' where FIND_IN_SET(' . $cateid . ',cates) and deleted =0';
}
$table .= ') g';
}
else {
$table = tablename('ewei_shop_goods') . ' g';
}
}
else {
$table = tablename('ewei_shop_goods') . ' g';
}
$where = ' where g.uniacid=:uniacid and g.bargain =0 and g.status =1 and g.deleted = 0 ';
if ($data['limitgoodtype'] == 1 && !empty($data['limitgoodids'])) {
$where .= ' and g.id in (' . $data['limitgoodids'] . ') ';
}
if (!empty($data['merchid'])) {
$where .= ' and g.merchid = ' . $data['merchid'] . ' and g.checked=0';
}
$where .= ' ORDER BY RAND() LIMIT 5 ';
$sql = $sql . $table . $where;
$goods = pdo_fetchall($sql, $params);
foreach ($goods as $i => &$row) {
$couponprice = (double) $row['minprice'];
if ($data['backtype'] == 0) {
$couponprice = round($couponprice - (double) $data['deduct'], 2);
}
if ($data['backtype'] == 1) {
$couponprice = (double) $couponprice * (floatval($data['discount']) / 10);
}
if ($couponprice < 0) {
$couponprice = 0;
}
$row['couponprice'] = $couponprice;
}
unset($row);
$goods = set_medias($goods, 'thumb');
include $this->template();
}
public function showcoupons3()
{
global $_W;
global $_GPC;
$key = $_GPC['key'];
$openid = $_W['openid'];
$time = time();
$sql = 'select d.id,d.couponid,d.gettime,c.timelimit,c.limitgoodcatetype,c.limitgoodcateids,c.coupontype,c.limitgoodtype,c.limitgoodids,c.timedays,c.timestart,c.timeend,c.thumb,c.couponname,c.enough,c.backtype,c.deduct,c.discount,c.backmoney,c.backcredit,c.backredpack,c.bgcolor,c.thumb,c.merchid,c.tagtitle,c.settitlecolor,c.titlecolor from ' . tablename('ewei_shop_coupon_sendshow') . ' cs';
$sql .= ' inner join ' . tablename('ewei_shop_coupon_data') . ' d on d.id=cs.coupondataid';
$sql .= ' inner join ' . tablename('ewei_shop_coupon') . ' c on d.couponid = c.id ';
$sql .= ' where cs.openid=:openid and cs.uniacid=:uniacid and showkey=:key ';
$sql .= ' order by d.gettime desc ';
$coupons = set_medias(pdo_fetchall($sql, array(':openid' => $openid, ':uniacid' => $_W['uniacid'], ':key' => $key)), 'thumb');
if (empty($coupons)) {
$coupons = array();
}
foreach ($coupons as $i => &$row) {
if (0 < $row['enough']) {
$row['title2'] = '满' . (double) $row['enough'] . '元使用';
}
else {
$row['title2'] = '无金额门槛';
}
if ($row['coupontype'] == 0 || $row['coupontype'] == 2) {
$row['title3'] = '优惠券';
if ($row['backtype'] == 0) {
$row['title1'] = '<span>¥</span>' . (double) $row['deduct'];
}
else if ($row['backtype'] == 1) {
$row['title1'] = (double) $row['discount'] . '<span>折</span>';
}
else {
if ($row['backtype'] == 2) {
if (!empty($row['backmoney']) && 0 < $row['backmoney']) {
$row['title1'] = '送' . $row['backmoney'] . '元余额';
}
if (!empty($row['backcredit']) && 0 < $row['backcredit']) {
$row['title1'] .= '送' . $row['backcredit'] . '积分';
}
if (!empty($row['backredpack']) && 0 < $row['backredpack']) {
$row['title1'] .= '送' . $row['backredpack'] . '元红包';
}
}
}
$goods = array();
$params = array(':uniacid' => $_W['uniacid']);
$sql = 'select distinct g.* from ';
$table = '';
if ($row['limitgoodcatetype'] == 1 && !empty($row['limitgoodcateids'])) {
$limitcateids = explode(',', $row['limitgoodcateids']);
if (0 < count($limitcateids)) {
$table = '(';
$i = 0;
foreach ($limitcateids as $cateid) {
++$i;
if (1 < $i) {
$table .= ' union all ';
}
$table .= 'select * from ' . tablename('ewei_shop_goods') . ' where FIND_IN_SET(' . $cateid . ',cates) and deleted = 0';
}
$table .= ') g';
}
else {
$table = tablename('ewei_shop_goods') . ' g';
}
}
else {
$table = tablename('ewei_shop_goods') . ' g';
}
$where = ' where g.uniacid=:uniacid and g.bargain =0 and g.status =1 and g.deleted = 0';
if ($row['limitgoodtype'] == 1 && !empty($row['limitgoodids'])) {
$where .= ' and g.id in (' . $row['limitgoodids'] . ') ';
}
if (!empty($row['merchid'])) {
$where .= ' and g.merchid = ' . $row['merchid'] . ' and g.checked=0';
}
$where .= ' ORDER BY RAND() LIMIT 5 ';
$sql = $sql . $table . $where;
$goods = pdo_fetchall($sql, $params);
foreach ($goods as $i => &$row2) {
$couponprice = (double) $row2['minprice'];
if ($row['backtype'] == 0) {
$couponprice = round($couponprice - (double) $row['deduct'], 2);
}
if ($row['backtype'] == 1) {
$couponprice = (double) $couponprice * (floatval($row['discount']) / 10);
}
if ($couponprice < 0) {
$couponprice = 0;
}
$row2['couponprice'] = $couponprice;
}
unset($row2);
$goods = set_medias($goods, 'thumb');
$row['goods'] = $goods;
}
else {
$row['title3'] = '充值卷';
if ($row['backtype'] == 2) {
if (!empty($row['backmoney']) && 0 < $row['backmoney']) {
$row['title1'] = '送' . $row['backmoney'] . '元余额';
}
if (!empty($row['backcredit']) && 0 < $row['backcredit']) {
$row['title1'] .= '送' . $row['backcredit'] . '积分';
}
if (!empty($row['backredpack']) && 0 < $row['backredpack']) {
$row['title1'] .= '送' . $row['backredpack'] . '元红包';
}
}
}
}
include $this->template();
}
public function showcoupongoods()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$data = pdo_fetch('select c.* from ' . tablename('ewei_shop_coupon_data') . ' cd inner join ' . tablename('ewei_shop_coupon') . ' c on cd.couponid = c.id where cd.id=:id and cd.uniacid=:uniacid and coupontype =0 limit 1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
if (empty($data)) {
if (empty($coupon)) {
header('location: ' . mobileUrl('sale/coupon/my'));
exit();
}
}
$merchid = 0;
if (!empty($data['merchid'])) {
$merchid = $data['merchid'];
}
if (8 < mb_strlen($data['couponname'], 'utf-8')) {
$data['couponname'] = mb_substr($data['couponname'], 0, 8, 'utf-8') . '..';
}
$allcategory = m('shop')->getCategory();
$catlevel = intval($_W['shopset']['category']['level']);
$opencategory = true;
$plugin_commission = p('commission');
if ($plugin_commission && 0 < intval($_W['shopset']['commission']['level'])) {
$mid = intval($_GPC['mid']);
if (!empty($mid)) {
$shop = p('commission')->getShop($mid);
if (empty($shop['selectcategory'])) {
$opencategory = false;
}
}
}
include $this->template();
}
public function get_list()
{
global $_GPC;
global $_W;
$args = array('pagesize' => 10, 'page' => intval($_GPC['page']), 'isnew' => trim($_GPC['isnew']), 'ishot' => trim($_GPC['ishot']), 'isrecommand' => trim($_GPC['isrecommand']), 'isdiscount' => trim($_GPC['isdiscount']), 'istime' => trim($_GPC['istime']), 'issendfree' => trim($_GPC['issendfree']), 'keywords' => trim($_GPC['keywords']), 'cate' => trim($_GPC['cate']), 'order' => trim($_GPC['order']), 'by' => trim($_GPC['by']), 'couponid' => trim($_GPC['couponid']), 'merchid' => intval($_GPC['merchid']));
$plugin_commission = p('commission');
if ($plugin_commission && 0 < intval($_W['shopset']['commission']['level']) && empty($_W['shopset']['commission']['closemyshop']) && !empty($_W['shopset']['commission']['select_goods'])) {
$mid = intval($_GPC['mid']);
$frommyshop = intval($_GPC['frommyshop']);
$mid = intval($_GPC['mid']);
if (!empty($mid) && !empty($frommyshop)) {
$shop = p('commission')->getShop($mid);
if (!empty($shop['selectgoods'])) {
$args['ids'] = $shop['goodsids'];
}
}
}
$this->_condition($args);
}
private function _condition($args)
{
global $_GPC;
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if ($merch_plugin && $merch_data['is_openmerch']) {
$args['merchid'] = intval($_GPC['merchid']);
}
if (isset($_GPC['nocommission'])) {
$args['nocommission'] = intval($_GPC['nocommission']);
}
$goods = m('goods')->getListbyCoupon($args);
show_json(1, array('list' => $goods['list'], 'total' => $goods['total'], 'pagesize' => $args['pagesize']));
}
}
?>

View File

@@ -1,88 +0,0 @@
<?php
//20200615
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Quickget_EweiShopV2Page extends MobileLoginPage {
public function main(){
global $_W, $_GPC;
$id = intval($_GPC['id']);
$openid= $_W['openid'];
$member = m('member')->getMember($openid);
if(empty($member))
{
header('location: ' . mobileUrl());die;
}
$time = time();
$coupon = pdo_fetch('select * from ' . tablename('ewei_shop_coupon') . ' where 1 and uniacid=:uniacid and id=:id', array(':uniacid' => $_W['uniacid'],':id' => $id));
$gettotal = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_coupon_data') . ' where couponid=:couponid and uniacid=:uniacid limit 1', array(':couponid' => $id, ':uniacid' => $_W['uniacid']));
$utotal = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_coupon_data') . ' where couponid=:couponid and uniacid=:uniacid and openid = :openid limit 1', array(':couponid' => $id, ':uniacid' => $_W['uniacid'],':openid'=>$_W['openid']));
if ($utotal >= $coupon['url_limit'] && $coupon['url_limit'] != 0 )
{
$this->message('您已经超过最大领取限制!',mobileUrl(),'error');
return ;
}
$left_count = $coupon['total'] - $gettotal;
$left_count = intval($left_count);
if (empty($coupon))
{
$msg = '优惠券不存在!';
}
if (empty($coupon['quickget']))
{
$msg = '此优惠券不可快速领取!';
}
if ($left_count<=0 && $coupon['total'] != -1)
{
$msg = '优惠券余量不足!';
}
if ($msg)
{
$this->message($msg ? $msg: '优惠券不存在或已经售罄',mobileUrl(),'error');
return;
}
// header('location: ' . mobileUrl());die;
//增加优惠券日志
$couponlog = array(
'uniacid' => $_W['uniacid'],
'openid' => $member['openid'],
'logno' => m('common')->createNO('coupon_log', 'logno', 'CC'),
'couponid' => $id,
'status' => 1,
'paystatus' => -1,
'creditstatus' => -1,
'createtime' => time(),
'getfrom' => 8
);
pdo_insert('ewei_shop_coupon_log', $couponlog);
//增加用户优惠券
$data = array(
'uniacid' => $_W['uniacid'],
'openid' => $member['openid'],
'couponid' => $id,
'gettype' => 8,
'gettime' => time()
);
pdo_insert('ewei_shop_coupon_data', $data);
$id = pdo_insertid();
header('location: ' . mobileUrl('sale/coupon/my/showcoupons2',array("id"=>$id)));
}
}

View File

@@ -1,19 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Show_EweiShopV2Page extends MobileLoginPage
{
public function main()
{
include $this->template('sale/coupon/my/showcoupons');
}
public function main2()
{
include $this->template('sale/coupon/my/showcoupons2');
}
}
?>

View File

@@ -1,37 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Util_EweiShopV2Page extends MobilePage
{
public function query()
{
global $_W;
global $_GPC;
$type = intval($_GPC['type']);
$money = floatval($_GPC['money']);
$merchs = $_GPC['merchs'];
$goods = $_GPC['goods'];
if ($type == 0) {
$list = com_run('coupon::getAvailableCoupons', $type, 0, $merchs, $goods);
$list2 = com_run('wxcard::getAvailableWxcards', $type, 0, $merchs, $goods);
}
else {
if ($type == 1) {
$list = com_run('coupon::getAvailableCoupons', $type, $money, $merchs);
$list2 = array();
}
}
show_json(1, array('coupons' => $list, 'wxcards' => $list2));
}
public function picker()
{
include $this->template();
}
}
?>

View File

@@ -1,441 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Share_EweiShopV2Page extends MobileLoginPage {
function getStatus(){
global $_W,$_GPC;
$money = str_replace(',','',$_GPC['money']);
$activity = $this -> activity($money);
if (!empty($activity)) {
$arr['status'] = 'success';
$arr['did'] = $activity['id'];
$arr['orderid'] = $_GPC['orderid'];
echo json_encode($arr);
exit;
}else{
$arr['status'] = 'error';
$arr['msg'] = '领取失败,请前往订单详情领取!';
echo json_encode($arr);
exit;
}
}
function enjoy(){
global $_W,$_GPC;
$openid = $_W['openid'];
if (!empty($_GPC['sid'])) {
$asql = 'SELECT * FROM '.tablename('ewei_shop_sendticket_share').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.intval($_GPC['sid']).' AND status = 1 AND (expiration = 0 OR (expiration = 1 AND endtime >= '.TIMESTAMP.'))';
$active = pdo_fetch($asql);
}else{
$active = $this -> activity($_GPC['money']);
if (empty($active)) {
$this -> message('活动已经结束!',mobileUrl('member'));
}
$_GPC['sid'] = $active['id'];
}
$csql = 'SELECT * FROM '.tablename('ewei_shop_coupon_data').' WHERE uniacid = '.intval($_W['uniacid']).' AND shareident = "'.trim($_GPC['ident']).'" AND openid = "'.$openid.'"';
$clist = pdo_fetchall($csql);
if (!empty($clist)) {
$newCoupon = array();
}else{
$insertData = $this -> shareSuccess();
$cpid = array();
$nums = array();
if (!empty($active['paycpid1'])) {
$cpid[] = $active['paycpid1'];
$nums[] = $active['paycpnum1'];
}
if (!empty($active['paycpid2'])) {
$cpid[] = $active['paycpid2'];
$nums[] = $active['paycpnum2'];
}
if (!empty($active['paycpid3'])) {
$cpid[] = $active['paycpid3'];
$nums[] = $active['paycpnum3'];
}
if(!empty($cpid)){
$newCoupon = array();
foreach ($cpid as $ck => $cv) {
$couponsql = 'SELECT * FROM '.tablename('ewei_shop_coupon').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.$cv;
$newCoupon[$ck] = pdo_fetch($couponsql);
$newCoupon[$ck]['cpnum'] = $nums[$ck];
}
}
$num = intval(array_sum($nums));
}
$storesql = 'SELECT * FROM '.tablename('ewei_shop_sysset').' WHERE uniacid = '.intval($_W['uniacid']);
$store = pdo_fetch($storesql);
$storeInfo = iunserializer($store['sets']);
$_W['shopshare'] = array(
'title' => $active['sharetitle'],
'imgUrl' => !empty($active['shareicon']) ? tomedia($active['shareicon']) : tomedia($storeInfo['shop']['logo']),
'desc' => !empty($active['sharedesc']) ? $active['sharedesc'] : $storeInfo['shop']['name'],
'link' => mobileUrl('sale/sendticket/share/shareCoupon', array('openid'=>$openid,'sid'=>intval($_GPC['sid']),'ident'=>$_GPC['ident']),true),
'way' => 'shareticket()',
);
$firendsql = 'SELECT c.backtype,c.deduct,c.backmoney,c.backredpack,c.discount,c.backcredit,d.id as did,d.couponid,d.openid,d.gettime,d.textkey,d.shareident FROM '.tablename('ewei_shop_coupon_data').' d,'.tablename('ewei_shop_coupon').' c WHERE c.id = d.couponid AND d.uniacid = '.intval($_W['uniacid']).' AND d.gettype = 15 AND d.shareident = "'.trim($_GPC['ident']).'" GROUP BY d.openid ORDER BY d.id ASC limit 20';
$firendlist = pdo_fetchall($firendsql);
foreach ($firendlist as $fk => $fv) {
$member = m('member')->getMember($fv['openid']);
$firendlist[$fk]['headimg'] = $member['avatar'];
$firendlist[$fk]['nickname'] = $member['nickname'];
$firendlist[$fk]['text'] = $this -> textClause($fv['textkey']);
}
$firendlist = array_reverse($firendlist);
include $this->template();
}
function activity($money){
global $_W;
$sql = 'SELECT * FROM '.tablename('ewei_shop_sendticket_share').' WHERE uniacid = '.intval($_W['uniacid']).' AND status = 1 AND (enough = '.$money.' OR enough <= '.$money.') AND (expiration = 0 OR (expiration = 1 AND endtime >= '.TIMESTAMP.')) ORDER BY enough DESC,createtime DESC LIMIT 1';
$activity = pdo_fetch($sql);
return $activity;
}
function getCoupon($cpids){
global $_W;
$sql = 'SELECT * FROM '.tablename('ewei_shop_coupon').' WHERE uniacid = '.intval($_W['uniacid']).' AND id IN ('.$cpids.')';
$coupon = pdo_fetchall($sql);
return $coupon;
}
function sendTicket($openid, $couponid,$gettype=0,$num,$ident='') {
global $_W, $_GPC;
$couponlog = array(
'uniacid' => $_W['uniacid'],
'openid' => $openid,
'logno' => m('common')->createNO('coupon_log', 'logno', 'CC'),
'couponid' => $couponid,
'status' => 1,
'paystatus' => -1,
'creditstatus' => -1,
'createtime' => time(),
'getfrom' => 3,
);
for($i = 0;$i<$num;$i++){
$log = pdo_insert('ewei_shop_coupon_log', $couponlog);
}
$tmp = range(0,20);
$data = array(
'uniacid' => $_W['uniacid'],
'openid' => $openid,
'couponid' => $couponid,
'gettype' => $gettype,
'gettime' => time(),
'shareident' => $ident,
);
for($i = 0;$i<$num;$i++){
$data['textkey'] = array_rand($tmp,1);
$datas = pdo_insert('ewei_shop_coupon_data', $data);
}
if ($log && $datas) {
return true;
} else {
return false;
}
}
function shareCoupon(){
global $_W,$_GPC;
$shareurl = $this -> curPageURL();
$shareOpenid = $_GPC['openid'];
$openid = $_W['openid'];
if($shareOpenid == $openid){
$data = array(
'isshare' => 1,
);
pdo_update('ewei_shop_order',$data,array('id'=>intval($_GPC['orderid'])));
header("location:".mobileUrl('sale/sendticket/share/sharePage',array('shareident'=>$_GPC['ident'],'shareurl' => $shareurl)));
exit;
}
$csql = 'SELECT * FROM '.tablename('ewei_shop_coupon_data').' WHERE uniacid = '.intval($_W['uniacid']).' AND shareident = "'.trim($_GPC['ident']).'" AND openid = "'.$openid.'"';
$clist = pdo_fetchall($csql);
if (!empty($clist)) {
header("location:".mobileUrl('sale/sendticket/share/sharePage',array('shareident'=>$_GPC['ident'])));
exit;
}
$asql = 'SELECT * FROM '.tablename('ewei_shop_sendticket_share').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.intval($_GPC['sid']).' AND status = 1 AND (expiration = 0 OR (expiration = 1 AND endtime >= '.TIMESTAMP.'))';
$activity = pdo_fetch($asql);
if (!empty($activity)) {
$cpid = array();
$nums = array();
if (!empty($activity['sharecpid1'])) {
$cpid[] = $activity['sharecpid1'];
$nums[] = $activity['sharecpnum1'];
}
if (!empty($activity['sharecpid2'])) {
$cpid[] = $activity['sharecpid2'];
$nums[] = $activity['sharecpnum2'];
}
if (!empty($activity['sharecpid3'])) {
$cpid[] = $activity['sharecpid3'];
$nums[] = $activity['sharecpnum3'];
}
foreach($cpid as $cpks => $cpvs){
$insertid = $this -> sendTicket($openid,$cpvs,15,$nums[$cpks],trim($_GPC['ident']));
}
header("location:".mobileUrl('sale/sendticket/share/sharePage',array('shareident' => $_GPC['ident'],'sid'=>$_GPC['sid'],'shareurl' => $shareurl)));
exit;
}else{
header("location:".mobileUrl('sale/sendticket/share/sharePage',array('shareident' => $_GPC['ident'],'close' => 1)));
exit;
}
}
function sharePage(){
global $_W,$_GPC;
$openid = $_W['openid'];
if($_GPC['close'] == 1){
$close = 1;
}else{
$close = 0;
if (!empty($_GPC['sid'])) {
$asql = 'SELECT * FROM '.tablename('ewei_shop_sendticket_share').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.intval($_GPC['sid']).' AND status = 1 AND (expiration = 0 OR (expiration = 1 AND endtime >= '.TIMESTAMP.'))';
$activity = pdo_fetch($asql);
$cpid = array();
$nums = array();
if (!empty($activity['sharecpid1'])) {
$cpid[] = $activity['sharecpid1'];
$nums[] = $activity['sharecpnum1'];
}
if (!empty($activity['sharecpid2'])) {
$cpid[] = $activity['sharecpid2'];
$nums[] = $activity['sharecpnum2'];
}
if (!empty($activity['sharecpid3'])) {
$cpid[] = $activity['sharecpid3'];
$nums[] = $activity['sharecpnum3'];
}
if(!empty($cpid)){
$newCoupon = array();
foreach ($cpid as $ck => $cv) {
$couponsql = 'SELECT * FROM '.tablename('ewei_shop_coupon').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.$cv;
$newCoupon[$ck] = pdo_fetch($couponsql);
$newCoupon[$ck]['cpnum'] = $nums[$ck];
}
}
$num = intval(array_sum($nums));
$storesql = 'SELECT * FROM '.tablename('ewei_shop_sysset').' WHERE uniacid = '.intval($_W['uniacid']);
$store = pdo_fetch($storesql);
$storeInfo = iunserializer($store['sets']);
$_W['shopshare'] = array(
'title' => $activity['sharetitle'],
'imgUrl' => !empty($activity['shareicon']) ? tomedia($activity['shareicon']) : tomedia($storeInfo['shop']['logo']),
'desc' => !empty($activity['sharedesc']) ? $activity['sharedesc'] : $storeInfo['shop']['name'],
'link' => $_GPC['shareurl'],
);
}
}
$firendsql = 'SELECT c.backtype,c.deduct,c.backmoney,c.backredpack,c.discount,c.backcredit,d.id as did,d.couponid,d.openid,d.gettime,d.textkey,d.shareident FROM '.tablename('ewei_shop_coupon_data').' d,'.tablename('ewei_shop_coupon').' c WHERE c.id = d.couponid AND d.uniacid = '.intval($_W['uniacid']).' AND d.gettype = 15 AND d.shareident = "'.trim($_GPC['shareident']).'" GROUP BY d.openid ORDER BY d.id ASC limit 20';
$firendlist = pdo_fetchall($firendsql);
foreach ($firendlist as $fk => $fv) {
$member = m('member')->getMember($fv['openid']);
$firendlist[$fk]['headimg'] = $member['avatar'];
$firendlist[$fk]['nickname'] = $member['nickname'];
$firendlist[$fk]['text'] = $this -> textClause($fv['textkey']);
}
$firendlist = array_reverse($firendlist);
include $this -> template('sale/sendticket/share/share');
}
function shareSuccess(){
global $_W,$_GPC;
$openid = $_W['openid'];
$orderSql = 'SELECT isshare FROM '.tablename('ewei_shop_order').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.intval($_GPC['orderid']);
$orderData = pdo_fetch($orderSql);
if ($orderData['isshare'] == 1) {
return false;
}
$couponDataSql = 'SELECT * FROM '.tablename('ewei_shop_coupon_data').' WHERE uniacid = '.intval($_W['uniacid']).' AND shareident = "'.$_GPC['ident'].'"';
$couponData = pdo_fetchall($couponDataSql);
if($couponData){
return false;
}
$asql = 'SELECT * FROM '.tablename('ewei_shop_sendticket_share').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.intval($_GPC['sid']).' AND status = 1 AND (expiration = 0 OR (expiration = 1 AND endtime >= '.TIMESTAMP.'))';
$activity = pdo_fetch($asql);
$cpid = array();
$nums = array();
if (!empty($activity['paycpid1'])) {
$cpid[] = $activity['paycpid1'];
$nums[] = $activity['paycpnum1'];
}
if (!empty($activity['paycpid2'])) {
$cpid[] = $activity['paycpid2'];
$nums[] = $activity['paycpnum2'];
}
if (!empty($activity['paycpid3'])) {
$cpid[] = $activity['paycpid3'];
$nums[] = $activity['paycpnum3'];
}
$insertid = array();
foreach($cpid as $cpks => $cpvs){
$insertid[] = $this -> sendTicket($openid,$cpvs,15,$nums[$cpks],$_GPC['ident']);
}
$data = array(
'isshare' => 1,
);
pdo_update('ewei_shop_order',$data,array('id'=>intval($_GPC['orderid'])));
if($insertid){
return true;
}else{
return false;
}
}
function unclaimed(){
global $_W,$_GPC;
$openid = $_W['openid'];
if (!empty($_GPC['sid'])) {
$asql = 'SELECT * FROM '.tablename('ewei_shop_sendticket_share').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.intval($_GPC['sid']).' AND status = 1 AND (expiration = 0 OR (expiration = 1 AND endtime >= '.TIMESTAMP.'))';
$active = pdo_fetch($asql);
}else{
$active = $this -> activity($_GPC['money']);
if (empty($active)) {
header("location:".mobileUrl('sale/sendticket/share/sharePage',array('shareident' => $_GPC['ident'],'close' => 1)));
exit;
}
$_GPC['sid'] = $active['id'];
}
$cpid = array();
$nums = array();
if (!empty($active['paycpid1'])) {
$cpid[] = $active['paycpid1'];
$nums[] = $active['paycpnum1'];
}
if (!empty($active['paycpid2'])) {
$cpid[] = $active['paycpid2'];
$nums[] = $active['paycpnum2'];
}
if (!empty($active['paycpid3'])) {
$cpid[] = $active['paycpid3'];
$nums[] = $active['paycpnum3'];
}
if(!empty($cpid)){
$newCoupon = array();
foreach ($cpid as $ck => $cv) {
$couponsql = 'SELECT * FROM '.tablename('ewei_shop_coupon').' WHERE uniacid = '.intval($_W['uniacid']).' AND id = '.$cv;
$newCoupon[$ck] = pdo_fetch($couponsql);
$newCoupon[$ck]['cpnum'] = $nums[$ck];
}
}
$num = intval(array_sum($nums));
$storesql = 'SELECT * FROM '.tablename('ewei_shop_sysset').' WHERE uniacid = '.intval($_W['uniacid']);
$store = pdo_fetch($storesql);
$storeInfo = iunserializer($store['sets']);
$ident = 'rrsc'.date('Ymd',time()).intval($_GPC['orderid']);
$_W['shopshare'] = array(
'title' => $active['sharetitle'],
'imgUrl' => !empty($active['shareicon']) ? tomedia($active['shareicon']) : tomedia($storeInfo['shop']['logo']),
'desc' => !empty($active['sharedesc']) ? $active['sharedesc'] : $storeInfo['shop']['name'],
'link' => mobileUrl('sale/sendticket/share/shareCoupon', array('openid'=>$openid,'sid'=>intval($_GPC['sid']),'ident'=>$ident),true),
'way' => 'shareticket()',
);
include $this -> template();
}
function textClause($key){
$text = array();
$text[0] = '我是购物狂,我为自己代言!';
$text[1] = '花钱如尿裤子一般,痛快!';
$text[2] = '不肯花大钱就买不来贵重东西!';
$text[3] = '不花钱是造不成宫殿的!';
$text[4] = '我是购物狂,我在振兴经济!';
$text[5] = '现在就买,否则晚点会哭!';
$text[6] = '没有什么比没买的东西叫人念念不忘的!';
$text[7] = '消费拉动内需,活跃市场!';
$text[8] = '购物让人心情愉悦!';
$text[9] = '懂得花钱和懂得挣钱是幸福的!';
$text[10] = '爱是个银行,不怕花钱,就怕不存钱!';
$text[11] = '和朋友在一起消费可以促进感情!';
$text[12] = '向钱看,向厚赚';
$text[13] = '挣钱是本事,花钱是美德。';
$text[14] = '会花钱才更会赚钱。';
$text[15] = '花钱的速度,决定你赚钱的动力。';
$text[16] = '花了的钱,才是自己的钱。';
$text[17] = '挣钱、赚钱只有一个目的,就是花!';
$text[18] = '一个人,富不富,不在于你存了多少,而在于你使用了多少!';
return $text[$key];
}
function curPageURL()
{
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on")
{
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80")
{
$pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
}
else
{
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
}
return $pageURL;
}
}

View File

@@ -1,100 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Category_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
global $_GPC;
$merchid = intval($_GPC['merchid']);
$category_set = $_W['shopset']['category'];
$category_set['advimg'] = tomedia($category_set['advimg']);
if ($category_set['level'] == -1) {
$this->message('暂时未开启分类', '', 'error');
}
$category = $this->getCategory($category_set['level'], $merchid);
$set = m('common')->getSysset('category');
include $this->template();
}
protected function getCategory($level, $merchid = 0)
{
$level = intval($level);
$category = m('shop')->getCategory();
$category_parent = array();
$category_children = array();
$category_grandchildren = array();
if (0 < $merchid) {
$merch_plugin = p('merch');
$merch_data = m('common')->getPluginset('merch');
if ($merch_plugin && $merch_data['is_openmerch']) {
$is_openmerch = 1;
}
else {
$is_openmerch = 0;
}
if ($is_openmerch) {
$merch_category = $merch_plugin->getSet('merch_category', $merchid);
if (!empty($merch_category)) {
if (!empty($category['parent'])) {
foreach ($category['parent'] as $key => $value) {
if (array_key_exists($value['id'], $merch_category)) {
$category['parent'][$key]['enabled'] = $merch_category[$value['id']];
}
}
}
if (!empty($category['children'])) {
foreach ($category['children'] as $key => $value) {
if (!empty($value)) {
foreach ($value as $k => $v) {
if (array_key_exists($v['id'], $merch_category)) {
$category['children'][$key][$k]['enabled'] = $merch_category[$v['id']];
}
}
}
}
}
}
}
}
foreach ($category['parent'] as $value) {
if ($value['enabled'] == 1) {
$value['thumb'] = tomedia($value['thumb']);
$value['advimg'] = tomedia($value['advimg']);
$category_parent[$value['parentid']][] = $value;
if (!empty($category['children'][$value['id']]) && (2 <= $level)) {
foreach ($category['children'][$value['id']] as $val) {
if ($val['enabled'] == 1) {
$val['thumb'] = tomedia($val['thumb']);
$val['advimg'] = tomedia($val['advimg']);
$category_children[$val['parentid']][] = $val;
if (!empty($category['children'][$val['id']]) && (3 <= $level)) {
foreach ($category['children'][$val['id']] as $v) {
if ($v['enabled'] == 1) {
$v['thumb'] = tomedia($v['thumb']);
$v['advimg'] = tomedia($v['advimg']);
$category_grandchildren[$v['parentid']][] = $v;
}
}
}
}
}
}
}
}
return array('parent' => $category_parent, 'children' => $category_children, 'grandchildren' => $category_grandchildren);
}
}
?>

View File

@@ -1,30 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Cityexpress_EweiShopV2Page extends MobilePage
{
public function map()
{
global $_W;
global $_GPC;
$cityexpress = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_city_express') . ' WHERE uniacid=:uniacid AND merchid=:merchid', array(':uniacid' => $_W['uniacid'], ':merchid' => 0));
$address = m('common')->getSysset('contact');
$shop = m('common')->getSysset('shop');
if (!empty($address)) {
$cityexpress['address'] = $address['province'] . $address['city'] . $address['address'];
}
if (!empty($shop)) {
$cityexpress['name'] = $shop['name'];
$cityexpress['logo'] = $shop['logo'];
}
include $this->template();
}
}
?>

View File

@@ -1,55 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Notice_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
include $this->template();
}
public function get_list()
{
global $_W;
global $_GPC;
$pindex = max(1, intval($_GPC['page']));
$psize = 10;
$condition = ' and `uniacid` = :uniacid and status=1 and iswxapp=0';
$params = array(':uniacid' => $_W['uniacid']);
$sql = 'SELECT COUNT(*) FROM ' . tablename('ewei_shop_notice') . ' where 1 ' . $condition;
$total = pdo_fetchcolumn($sql, $params);
$sql = 'SELECT * FROM ' . tablename('ewei_shop_notice') . ' where 1 ' . $condition . ' ORDER BY displayorder desc,id desc LIMIT ' . (($pindex - 1) * $psize) . ',' . $psize;
$list = pdo_fetchall($sql, $params);
foreach ($list as $key => &$row) {
$row['createtime'] = date('Y-m-d H:i', $row['createtime']);
}
unset($row);
$list = set_medias($list, 'thumb');
show_json(1, array('list' => $list, 'pagesize' => $psize, 'total' => $total));
}
public function detail()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$merchid = intval($_GPC['merchid']);
$merch_plugin = p('merch');
if ($merch_plugin && !empty($merchid)) {
$notice = pdo_fetch('select * from ' . tablename('ewei_shop_merch_notice') . ' where id=:id and uniacid=:uniacid and merchid=:merchid and status=1', array(':id' => $id, ':uniacid' => $_W['uniacid'], ':merchid' => $merchid));
}
else {
$notice = pdo_fetch('select * from ' . tablename('ewei_shop_notice') . ' where id=:id and iswxapp=0 and uniacid=:uniacid and status=1', array(':id' => $id, ':uniacid' => $_W['uniacid']));
}
$notice['detail'] = m('ui')->lazy($notice['detail']);
include $this->template();
}
}
?>

View File

@@ -1,68 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobilePage
{
public function detail()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$merchid = intval($_GPC['merchid']);
if ($merchid) {
$item = pdo_fetch('select * from ' . tablename('ewei_shop_merch_store') . ' where id =:id and uniacid=:uniacid and merchid=:merchid', array(':id' => $id, ':uniacid' => $_W['uniacid'], 'merchid' => $merchid));
}
else {
$item = pdo_fetch('select * from ' . tablename('ewei_shop_store') . ' where id =:id and uniacid=:uniacid', array(':id' => $id, ':uniacid' => $_W['uniacid']));
}
$item['logo'] = tomedia($item['logo']);
if (!empty($item['tag'])) {
$tags = explode(',', $item['tag']);
if (!empty($tags)) {
foreach ($tags as &$tag) {
if (2 < mb_strlen($tag, 'UTF-8')) {
$lable = mb_substr($tag, 0, 2, 'UTF-8');
}
}
unset($tag);
}
$item['taglist'] = $tags;
$item['hastag'] = 1;
}
else {
$item['hastag'] = 0;
}
if (!empty($item['label'])) {
$lables = explode(',', $item['label']);
if (!empty($lables)) {
foreach ($lables as &$lable) {
if (4 < mb_strlen($lable, 'UTF-8')) {
$lable = mb_substr($lable, 0, 4, 'UTF-8');
}
}
unset($lable);
}
$item['labellist'] = $lables;
$item['haslabel'] = 1;
}
else {
$item['haslabel'] = 0;
}
include $this->template();
}
}
?>

View File

@@ -1,27 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Map_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
global $_GPC;
$id = intval($_GPC['id']);
$merchid = intval($_GPC['merchid']);
if (0 < $merchid) {
$store = pdo_fetch('select * from ' . tablename('ewei_shop_merch_store') . ' where id=:id and uniacid=:uniacid and merchid=:merchid', array(':id' => $id, ':uniacid' => $_W['uniacid'], ':merchid' => $merchid));
}
else {
$store = pdo_fetch('select * from ' . tablename('ewei_shop_store') . ' where id=:id and uniacid=:uniacid', array(':id' => $id, ':uniacid' => $_W['uniacid']));
}
$store['logo'] = empty($store['logo']) ? $_W['shopset']['shop']['logo'] : $store['logo'];
include $this->template();
}
}
?>

View File

@@ -1,87 +0,0 @@
<?php
/*珍贵资源 请勿转卖*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Selector_EweiShopV2Page extends MobilePage {
function main() {
global $_W, $_GPC;
include $this->template();
}
function get_list() {
global $_W, $_GPC;
$psize = 20;
$pindex = max(1, intval($_GPC['page']));
$ids = trim($_GPC['ids']);
$type = intval($_GPC['type']);
$merchid = intval($_GPC['merchid']);
$neer = intval($_GPC['isneer']);
$lat = $_GPC['lat'];
$lng = $_GPC['lng'];
$keyword = $_GPC['keyword'];
$condition = '';
$params = array();
if(!empty($ids)){
$condition = " and id in({$ids})";
}
if($type==1){
$condition .= " and type in(1,3) ";
}
elseif ($type==2){
$condition .= " and type in(2,3) ";
}
if (!empty($keyword)){
$condition .= " and `storename` like :keyword ";
$params[':keyword'] = "%{$keyword}%";
}
if (!$neer) {
$isneer = 0;
if ($merchid > 0) {
$list = pdo_fetchall('select * from ' . tablename('ewei_shop_merch_store') . ' where uniacid=:uniacid and merchid=:merchid and status=1 '. $condition .' order by displayorder desc,id desc LIMIT ' . ($pindex - 1) * $psize . ',' . $psize, array_merge(array(':uniacid' => $_W['uniacid'], ':merchid' => $merchid),$params));
$total = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_merch_store') . ' where uniacid=:uniacid and merchid=:merchid and status=1 '. $condition, array_merge(array(':uniacid' => $_W['uniacid'], ':merchid' => $merchid),$params));
} else {
$list = pdo_fetchall('select * from ' . tablename('ewei_shop_store') . ' where uniacid=:uniacid and status=1 '. $condition .' order by displayorder desc,id desc LIMIT ' . ($pindex - 1) * $psize . ',' . $psize, array_merge(array(':uniacid' => $_W['uniacid']),$params));
$total = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_store') . ' where uniacid=:uniacid and status=1 '. $condition, array_merge(array(':uniacid' => $_W['uniacid']),$params));
}
} else {
$isneer =1;
if ($merchid > 0) {
$list = pdo_fetchall('select *, ROUND(6378.138 * 2 * ASIN( SQRT(POW(SIN((:lat * PI() / 180 - lat * PI() / 180) / 2),2) + COS(:lat * PI() / 180) * COS(lat * PI() / 180) * POW(SIN((:lng * PI() / 180 - lng * PI() / 180) / 2),2))) * 1000) AS juli
from ' . tablename('ewei_shop_merch_store')
. ' where uniacid=:uniacid and merchid=:merchid and status=1 '
. $condition .' order by juli asc LIMIT ' . ($pindex - 1) * $psize . ',' . $psize,
array_merge(array(':uniacid' => $_W['uniacid'], ':merchid' => $merchid, ':lat' => $lat, ':lng' => $lng),$params));
$total = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_merch_store')
. ' where uniacid=:uniacid and merchid=:merchid and status=1 '
. $condition ,
array_merge(array(':uniacid' => $_W['uniacid'], ':merchid' => $merchid),$params));
} else {
$list = pdo_fetchall('select *,ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN((:lat * PI() / 180 - lat * PI() / 180) / 2),2) + COS(:lat * PI() / 180) * COS(lat * PI() / 180) * POW(SIN((:lng * PI() / 180 - lng * PI() / 180) / 2),2))) * 1000) AS juli
from ' . tablename('ewei_shop_store') . ' where uniacid=:uniacid and status=1 '
. $condition .' order by juli asc LIMIT ' . ($pindex - 1) * $psize . ',' . $psize,
array_merge(array(':uniacid' => $_W['uniacid'],':lat' => $lat, ':lng' => $lng),$params));
$total = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_store') . ' where uniacid=:uniacid and status=1 '
. $condition,
array_merge(array(':uniacid' => $_W['uniacid']),$params));
}
}
show_json(1, array('list'=>$list,'total'=>$total,'pagesize'=>$psize));
}
}

View File

@@ -1,13 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Empty_EweiShopV2Page extends MobilePage
{
public function main()
{
}
}
?>

View File

@@ -1,14 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Task_EweiShopV2Page extends MobilePage
{
public function main()
{
$this->runTasks();
}
}
?>

View File

@@ -1,104 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Uploader_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
global $_GPC;
load()->func('file');
$field = $_GPC['file'];
if (!empty($_FILES[$field]['name'])) {
if (is_array($_FILES[$field]['name'])) {
$files = array();
foreach ($_FILES[$field]['name'] as $key => $name) {
if (strrchr($name, '.') === false) {
$name = $name . '.jpg';
}
$file = array('name' => $name, 'type' => $_FILES[$field]['type'][$key], 'tmp_name' => $_FILES[$field]['tmp_name'][$key], 'error' => $_FILES[$field]['error'][$key], 'size' => $_FILES[$field]['size'][$key]);
$files[] = $this->upload($file);
}
$ret = array('status' => 'success', 'files' => $files);
exit(json_encode($ret));
}
else {
if (strrchr($_FILES[$field]['name'], '.') === false) {
$_FILES[$field]['name'] = $_FILES[$field]['name'] . '.jpg';
}
$result = $this->upload($_FILES[$field]);
exit(json_encode($result));
}
}
else {
$result['message'] = '请选择要上传的图片!';
exit(json_encode($result));
}
}
protected function upload($uploadfile)
{
global $_W;
global $_GPC;
$result['status'] = 'error';
if ($uploadfile['error'] != 0) {
$result['message'] = '上传失败,请重试!';
return $result;
}
load()->func('file');
$path = '/images/ewei_shop/' . $_W['uniacid'];
if (!is_dir(ATTACHMENT_ROOT . $path)) {
mkdirs(ATTACHMENT_ROOT . $path);
}
$_W['uploadsetting'] = array();
$_W['uploadsetting']['image']['folder'] = $path;
$_W['uploadsetting']['image']['extentions'] = $_W['config']['upload']['image']['extentions'];
$_W['uploadsetting']['image']['limit'] = $_W['config']['upload']['image']['limit'];
$file = file_upload($uploadfile, 'image');
if (is_error($file)) {
$result['message'] = $file['message'];
return $result;
}
if (function_exists('file_remote_upload')) {
$remote = file_remote_upload($file['path']);
if (is_error($remote)) {
$result['message'] = $remote['message'];
return $result;
}
}
$result['status'] = 'success';
$result['url'] = $file['url'];
$result['error'] = 0;
$result['filename'] = $file['path'];
$result['url'] = trim($_W['attachurl'] . $result['filename']);
pdo_insert('core_attachment', array('uniacid' => $_W['uniacid'], 'uid' => $_W['member']['uid'], 'filename' => $uploadfile['name'], 'attachment' => $result['filename'], 'type' => 1, 'createtime' => TIMESTAMP));
return $result;
}
public function remove()
{
global $_W;
global $_GPC;
load()->func('file');
$file = $_GPC['file'];
file_delete($file);
exit(json_encode(array('status' => 'success')));
}
}
?>

View File

@@ -1,164 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
if (!pdo_tableexists('ewei_shop_saler_verify_log'))
{
pdo_query("CREATE TABLE " . tablename('ewei_shop_saler_verify_log') ." (
`id` int(11) NOT NULL AUTO_INCREMENT,
`storeid` int(11) DEFAULT '0' COMMENT '店铺id',
`uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
`openid` varchar(255) DEFAULT '' COMMENT '核销员openid',
`saler_id` int(11) NOT NULL DEFAULT '0' COMMENT '核销员id',
`order_id` int(11) NOT NULL DEFAULT '0' COMMENT '订单id',
`verify_time` int(11) NOT NULL DEFAULT '0' COMMENT '核销时间',
`type` tinyint(2) DEFAULT '0' COMMENT '0是常规1是计时计次',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_uniacid` (`uniacid`) USING BTREE,
KEY `index_openid` (`openid`) USING HASH,
KEY `index_type` (`type`) USING HASH
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
}
class Index_EweiShopV2Page extends MobilePage {
function qrcode() {
global $_W, $_GPC;
$orderid = intval($_GPC['id']);
$verifycode = $_GPC['verifycode'];
$query = array('id' => $orderid, 'verifycode' => $verifycode);
$order = pdo_fetch("select istrade from " . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid limit 1'
, array(':id' => $orderid, ':uniacid' => $_W['uniacid']));
if(empty($order['istrade'])) {
$url = mobileUrl('verify/detail', $query, true);
} else {
$url = mobileUrl('verify/tradedetail', $query, true);
}
show_json(1, array('url' => m('qrcode')->createQrcode($url)));
}
function select() {
global $_W, $_GPC;
$orderid = intval($_GPC['id']);
$verifycode = trim($_GPC['verifycode']);
if (empty($verifycode) || empty($orderid)) {
show_json(0);
}
$order = pdo_fetch("select id,verifyinfo from " . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid limit 1'
, array(':id' => $orderid, ':uniacid' => $_W['uniacid']));
if (empty($order)) {
show_json(0);
}
$verifyinfo = iunserializer($order['verifyinfo']);
foreach ($verifyinfo as &$v) {
if ($v['verifycode'] == $verifycode) {
if (!empty($v['select'])) {
$v['select'] = 0;
} else {
$v['select'] = 1;
}
}
}
unset($v);
$res = pdo_update('ewei_shop_order', array('verifyinfo' => iserializer($verifyinfo)), array('id' => $orderid));
if (empty($res)) {
show_json(0);
}
show_json(1);
}
function check() {
global $_W, $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$orderid = intval($_GPC['id']);
$order = pdo_fetch("select id,status,isverify,verified from " . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid and openid=:openid limit 1'
, array(':id' => $orderid, ':uniacid' => $uniacid, ':openid' => $openid));
if (empty($order)) {
show_json(0);
}
if (empty($order['isverify'])) {
show_json(0);
}
if ($order['verifytype'] == 0 || $order['verifytype'] == 3) {
if (empty($order['verified'])) {
show_json(0);
}
}
show_json(1);
}
function detail() {
global $_W, $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$orderid = intval($_GPC['id']);
$data = com('verify')->allow($orderid);
if(is_error($data)){
$this->message($data['message']);
}
extract($data);
include $this->template();
}
function tradedetail() {
global $_W, $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$orderid = intval($_GPC['id']);
$data = com('verify')->allow($orderid);
if(is_error($data)){
$this->message($data['message']);
}
extract($data);
$createInfo = array();
$createInfo['tradestatus'] = $order['tradestatus'];
$createInfo['betweenprice'] = $order['betweenprice'];
$newstore_plugin = p('newstore');
$temp_type = $newstore_plugin->getTempType();
$tempinfo = $newstore_plugin->getTempInfo($goods['tempid']);
if (!empty($goods['peopleid'])) {
$goods['peopleinfo'] = $newstore_plugin->getPeopleInfo($goods['peopleid']);
}
// print_r($goods);exit;
include $this->template();
}
function complete() {
global $_W, $_GPC;
$orderid = intval($_GPC['id']);
$times = intval($_GPC['times']);
// $verifycode = trim($_GPC['verifycode']);
$data = com('verify')->verify($orderid,$times);
if($data['errno'] == -1){
show_json(0,$data['message']);
}else{
show_json(1);
}
}
function success(){
global $_W,$_GPC;
$id =intval($_GPC['orderid']);
$times = intval($_GPC['times']);
$this->message(array('title'=>'操作完成','message'=>'您可以退出浏览器了'),"javascript:WeixinJSBridge.call(\"closeWindow\");",'success');
}
}

View File

@@ -1,112 +0,0 @@
<?php
if (!(defined('IN_IA')))
{
exit('Access Denied');
}
class Page_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$uniacd = $_W['uniacid'];
$merchid = 0;
$merch_plugin = p('merch');
$saler = pdo_fetch('select * from ' . tablename('ewei_shop_saler') . ' where openid=:openid and uniacid=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':openid' => $openid));
if (empty($saler) && $merch_plugin)
{
$saler = pdo_fetch('select * from ' . tablename('ewei_shop_merch_saler') . ' where openid=:openid and uniacid=:uniacid limit 1', array(':uniacid' => $_W['uniacid'], ':openid' => $openid));
}
if (empty($saler))
{
$this->message('您无核销权限!', 'close');
}
else
{
$merchid = $saler['merchid'];
}
if (empty($saler['storeid']))
{
$this->message('您不属于任何门店,无法进行核销!', 'close');
}
$member = m('member')->getMember($saler['openid']);
$store = false;
if (!(empty($saler['storeid'])))
{
if (0 < $merchid)
{
$store = pdo_fetch('select * from ' . tablename('ewei_shop_merch_store') . ' where id=:id and uniacid=:uniacid and merchid = :merchid limit 1', array(':id' => $saler['storeid'], ':uniacid' => $_W['uniacid'], ':merchid' => $merchid));
}
else
{
$store = pdo_fetch('select * from ' . tablename('ewei_shop_store') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $saler['storeid'], ':uniacid' => $_W['uniacid']));
}
}
include $this->template();
}
public function search()
{
global $_W;
global $_GPC;
$verifycode = trim($_GPC['verifycode']);
if (empty($verifycode))
{
show_json(0, '请填写核销码或自提码');
}
if ((strlen($verifycode) == 9) && (substr($verifycode, 0, 1) == '8'))
{
$verifygood = m('verifygoods')->search($verifycode);
if (is_error($verifygood))
{
show_json(0, $verifygood['message']);
}
show_json(1, array('verifygoodid' => $verifygood['id'], 'verifycode' => $verifycode, 'isverifygoods' => 1));
}
else
{
$orderid = pdo_fetchcolumn('select id from ' . tablename('ewei_shop_order') . ' where uniacid=:uniacid and ( verifycode=:verifycode or verifycodes like :verifycodes ) limit 1 ', array(':uniacid' => $_W['uniacid'], ':verifycode' => $verifycode, ':verifycodes' => '%|' . $verifycode . '|%'));
if (empty($orderid))
{
show_json(0, '未查询到订单,请核对');
}
$allow = com('verify')->allow($orderid);
if (is_error($allow))
{
show_json(0, $allow['message']);
}
extract($allow);
$verifyinfo = iunserializer($order['verifyinfo']);
if ($order['verifytype'] == 2)
{
foreach ($verifyinfo as &$v )
{
unset($v['select']);
if ($v['verifycode'] == $verifycode)
{
if ($v['verified'])
{
show_json(0, '此消费码已经使用!');
}
$v['select'] = 1;
}
}
unset($v);
pdo_update('ewei_shop_order', array('verifyinfo' => iserializer($verifyinfo)), array('id' => $orderid));
}
show_json(1, array('orderid' => $orderid, 'istrade' => intval($order['istrade']), 'isverifygoods' => 0));
}
}
public function complete()
{
global $_W;
global $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$orderid = intval($_GPC['id']);
$times = intval($_GPC['times']);
com('verify')->verify($orderid, $times);
show_json(1);
}
}
?>

View File

@@ -1,174 +0,0 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
if (!pdo_tableexists('ewei_shop_saler_verify_log'))
{
pdo_query("CREATE TABLE " . tablename('ewei_shop_saler_verify_log') ." (
`id` int(11) NOT NULL AUTO_INCREMENT,
`storeid` int(11) DEFAULT '0' COMMENT '店铺id',
`uniacid` int(11) DEFAULT '0' COMMENT '公众号id',
`openid` varchar(255) DEFAULT '' COMMENT '核销员openid',
`saler_id` int(11) NOT NULL DEFAULT '0' COMMENT '核销员id',
`order_id` int(11) NOT NULL DEFAULT '0' COMMENT '订单id',
`verify_time` int(11) NOT NULL DEFAULT '0' COMMENT '核销时间',
`type` tinyint(2) DEFAULT '0' COMMENT '0是常规1是计时计次',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_uniacid` (`uniacid`) USING BTREE,
KEY `index_openid` (`openid`) USING HASH,
KEY `index_type` (`type`) USING HASH
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
}
class Verifygoods_EweiShopV2Page extends MobilePage {
/**
* 会员核销卡核销页面
*/
function detail() {
global $_W, $_GPC;
$openid = $_W['openid'];
$verifycode = trim($_GPC['verifycode']);
$id = trim($_GPC['id']);
if (empty($verifycode)) {
$this->message('未查询到记次时商品或核销码已失效,请核对核销码!', '', 'error');
}
$item = pdo_fetch('select vg.*,g.id as goodsid ,g.title,g.subtitle,g.thumb,vg.storeid from ' . tablename('ewei_shop_verifygoods') . ' vg
inner join ' . tablename('ewei_shop_order_goods') . ' og on vg.ordergoodsid = og.id
inner join ' . tablename('ewei_shop_goods') . ' g on og.goodsid = g.id
where vg.id =:id and vg.verifycode=:verifycode and vg.uniacid=:uniacid and vg.invalid =0 limit 1', array(':id' => $id,':uniacid' => $_W['uniacid'],':verifycode' => $verifycode));
if (empty($item)) {
$this->message('未查询到记次时商品或核销码已失效,请核对核销码!', '', 'error');
}
if(intval($item['codeinvalidtime'])<time())
{
$this->message('核销码已失效,请联系用户刷新页面获取最新核销码!', '', 'error');
}
$saler = pdo_fetch('select * from ' . tablename('ewei_shop_saler') . ' where status=1 and openid=:openid and uniacid=:uniacid limit 1', array(
':uniacid' => $_W['uniacid'], ':openid' => $openid
));
if (empty($saler)) {
$this->message('您不是核销员,无权核销', '', 'error');
}
$store = pdo_fetch('select * from ' . tablename('ewei_shop_store') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $saler['storeid'], ':uniacid' => $_W['uniacid']));
/*if (empty($saler['storeid'])) {
$this->message('您无核销权限! 错误码:02', '', 'error');
}*/
if(!empty($item['storeid'])&&!empty($store)&&$item['storeid']!=$store['id'])
{
$this->message('该商品无法在您所属门店核销!请重新确认!', '', 'error');
}
if(!empty($item['limitnum']))
{
$verifygoodlogs = pdo_fetchall('select * from ' . tablename('ewei_shop_verifygoods_log') . ' where verifygoodsid =:id ', array(':id' => $item['id']));
$verifynum = 0;
foreach($verifygoodlogs as $verifygoodlog)
{
$verifynum +=intval($verifygoodlog['verifynum']);
}
$lastverifys = intval($item['limitnum']) - $verifynum;
}
//判断时间是否过期
if(empty($item['limittype']))
{
$limitdate = intval($item['starttime']) + intval($item['limitdays'])*86400;
}else
{
$limitdate = intval($item['limitdate']);
}
if($limitdate<time())
{
$this->message('该商品已过期!', '', 'error');
}
$termofvalidity = date('Y-m-d H:i', $limitdate);
include $this->template();
}
/**
* 记计核销台
*/
function main() {
global $_W, $_GPC;
$openid = $_W['openid'];
$saler = pdo_fetch('select * from ' . tablename('ewei_shop_saler') . ' where status=1 and openid=:openid and uniacid=:uniacid limit 1', array(
':uniacid' => $_W['uniacid'], ':openid' => $openid
));
if (empty($saler)) {
$this->message('您无核销权限!',"close");
}
$member = m('member')->getMember($saler['openid']);
$store = false;
if (!empty($saler['storeid'])) {
$store = pdo_fetch('select * from ' . tablename('ewei_shop_store') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $saler['storeid'], ':uniacid' => $_W['uniacid']));
}
include $this->template();
}
/**
* 查看核销
*/
function search() {
global $_W, $_GPC;
$openid = $_W['openid'];
$verifycode = trim($_GPC['verifycode']);
if (empty($verifycode)) {
show_json(0, '请填写核销码');
}
$verifygood = m('verifygoods')->search($verifycode);
if(is_error($verifygood)){
show_json(0, $verifygood['message']);
}
show_json(1, array('verifygoodid' =>$verifygood['id']));
}
/**
* 完成核销
*/
function complete() {
global $_W, $_GPC;
$times = intval($_GPC['times']);
$verifycode = trim($_GPC['verifycode']);
$remarks = trim($_GPC['remarks']);
$result = m('verifygoods')->complete($verifycode,$times,$remarks);
if(is_error($result)){
show_json(0,$result['message']);
}
show_json(1, array('verifygoodid' => $result['verifygoodid'],'orderid'=>$result['orderid']));
}
/**
* 核销成功页面
*/
function success(){
global $_W,$_GPC;
$this->message(array('title'=>'操作完成','message'=>'您可以退出浏览器了'),"javascript:WeixinJSBridge.call(\"closeWindow\");",'success');
}
}

Some files were not shown because too many files have changed in this diff Show More