初始化

This commit is contained in:
meng 2023-02-14 19:57:32 +08:00
commit c477860168
9630 changed files with 1440370 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/data

1
cert/readme.txt Normal file
View File

@ -0,0 +1 @@
#证书文件夹 请不要删除

0
core/com/cache.php Normal file
View File

2039
core/com/coupon.php Normal file

File diff suppressed because it is too large Load Diff

9
core/com/h5app.php Normal file
View File

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

4158
core/com/perm.php Normal file

File diff suppressed because it is too large Load Diff

1237
core/com/printer.php Normal file

File diff suppressed because it is too large Load Diff

179
core/com/qiniu.php Normal file
View File

@ -0,0 +1,179 @@
<?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_SHOP_V2_MODULE_NAME)) {
$url = str_replace("../addons/" . EWEI_SHOP_V2_MODULE_NAME, "addons/" . EWEI_SHOP_V2_MODULE_NAME, $url);
}
if (!strexists($url, "addons/" . EWEI_SHOP_V2_MODULE_NAME)) {
$url = tomedia($url);
}
if (!empty($_W["setting"]["remote"]["type"])) {
$enforce = true;
}
$outlinkEnforce = false;
if (!strexists($url, $_W["siteroot"]) && (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_SHOP_V2_MODULE_NAME)) {
$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_SHOP_V2_MODULE_NAME)) {
$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;
}
if (!function_exists("classLoader")) {
require_once IA_ROOT . "/framework/library/qiniu/autoload.php";
} else {
spl_autoload_register("qiniuClassLoader");
require_once IA_ROOT . "/framework/library/qiniu/src/Qiniu/functions.php";
}
$auth = new Auth($config["access_key"], $config["secret_key"]);
if (is_callable("\\\\Zone::zone0")) {
$zone = Zone::zone0();
if ($config["zone"] == "zone1") {
$zone = Zone::zone1();
}
$uploadmgr = new Storage\UploadManager(new Config($zone));
$putpolicy = base64_urlSafeEncode(json_encode(array("scope" => $config["bucket"] . ":" . $url)));
$uploadtoken = $auth->uploadToken($config["bucket"], $key, 3600, $putpolicy);
} else {
$uploadmgr = new 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_SHOP_V2_MODULE_NAME . "/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;
}
}
function qiniuClassLoader($class)
{
$path = str_replace("\\", DIRECTORY_SEPARATOR, $class);
$file = IA_ROOT . "/framework/library/qiniu/src/" . $path . ".php";
if (file_exists($file)) {
require_once $file;
}
}
?>

203
core/com/sale.php Normal file
View File

@ -0,0 +1,203 @@
<?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);
}
/**
* 传入金额,生成满立减优惠
* @param string $openid 用户openid
* @param int $price 传入金额
* @param int $paytype 支付类型 1 余额支付; 3 货到付款; 21 微信支付; 22 支付宝支付; 37 收银台付款;
* @param int $type 购物送积分 1 充值送积分 2
* @param int $refund 是否是退款
* @param string $desc 是否是退款
* @return float|int
*/
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;
}
}

194
core/com/sendticket.php Normal file
View File

@ -0,0 +1,194 @@
<?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;
}
}

370
core/com/sms.php Normal file
View File

@ -0,0 +1,370 @@
<?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 {
if ($template['type'] == 'smsbao') {
$request = array('30' => '密码错误', '40' => '账号不存在', '41' => '余额不足', '42' => '账号过期', '43' => 'IP地址限制', '50' => '内容含有敏感词', '51' => '手机号码不正确');
$url = 'http://api.smsbao.com/sms?u=' . $smsset['smsbao_key'] . '&p=' . md5($smsset['smsbao_secret']) . '&m=' . $mobile . '&c=【' . $smsset['smsbao_sign'] . '】' . $params;
$res = file_get_contents($url);
if ($res != 0) {
return array('status' => $res, 'message' => $request[$res]);
}
} 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'] == 'smsbao') {
if (empty($smsset['smsbao'])) {
return array('status' => 0, 'message' => '未开启短信宝!');
}
if (empty($smsset['smsbao_key'])) {
return array('status' => 0, 'message' => '未填写短信宝帐号!');
}
if (empty($smsset['smsbao_secret'])) {
return array('status' => 0, 'message' => '未填写短信宝密码!');
}
if (empty($smsset['smsbao_sign'])) {
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 ($type == 'smsbao') {
$template = $template['content'];
foreach ($data as $key => $value) {
$template = str_replace('{' . $key . '}', $value, $template);
}
$result = $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);
}
}
}

12
core/com/tmessage.php Normal file
View File

@ -0,0 +1,12 @@
<?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'));
}
}

575
core/com/verify.php Normal file
View File

@ -0,0 +1,575 @@
<?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_SHOP_V2_MODULE_NAME . "/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_SHOP_V2_MODULE_NAME . "/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, '核销失败,请检查数据');
}
}
}

400
core/com/virtual.php Normal file
View File

@ -0,0 +1,400 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Virtual_EweiShopV2ComModel extends ComModel {
public function updateGoodsStock($id = 0) {
global $_W, $_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;
}
$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, $_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']));
//如果redis可用则取最后一个使用过的卡密id 拼接 sql
$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));
//如果上一条不是被置顶的卡密数据 , 则下一条ID+1
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 (empty($virtual_data) ||count($virtual_data) < $goods['total']) {
return array('error' => -1, 'message' => '库存不足');
}
//将最后一个将要使用的卡密id存到redis
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();
$success_flag = true;
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);
//更新虚拟物品数据
$virtual_data = 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']));
if ($virtual_data) {
pdo_update('ewei_shop_virtual_type', 'usedata=usedata+1', array('id' => $vd['typeid']));
} else {
$success_flag = false;
}
}
if (!$success_flag || empty($virtual_info) || empty($virtual_str)) {
return array('error' => -1, 'message' => '数据出错请重试');
}
//更新库存
$this->updateStock($order['virtual']);
$virtual_str = implode("\n", $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']));
//将卡密内容存到redis里面
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, $_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']));
if ($order["is_sub_account"] == 1) {
$subAccountSet = m("common")->getPluginset("sub_account");
if (empty($subAccountSet["days"])) {
$change_data["sub_account_time"] = date("Y-m-d H:i:s", time() + 300);
} else {
$change_data["sub_account_time"] = date("Y-m-d H:i:s", strtotime("+" . $subAccountSet["days"] . " days"));
}
pdo_update("ewei_shop_order", $change_data, array("id" => $order["id"]));
}
//处理余额抵扣
/*if ($order['deductcredit2'] > 0) {
$shopset = m('common')->getSysset('shop');
m('member')->setCredit($order['openid'], 'credit2', -$order['deductcredit2'], array(0, $shopset['name'] . "余额抵扣: {$order['deductcredit2']} 订单号: " . $order['ordersn']));
}*/
//购物积分
//$credits = $goods['total'] * $g['credit'];
$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 ($credits > 0) {
$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'], (float)$order['price'], $order['paytype'], 1);
if ($money > 0) {
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 ($order['deductcredit2'] > 0) {
$order['price'] = floatval($order['price']) + floatval($order['deductcredit2']);
}
//积分抵扣加入金额计算
if ($order['deductcredit'] > 0) {
$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 ($order['deductcredit2'] > 0) {
$order['price'] = floatval($order['price']) + floatval($order['deductcredit2']);
}
//积分抵扣加入金额计算
if ($order['deductcredit'] > 0) {
$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 ($order['deductcredit2'] > 0) {
$order['price'] = floatval($order['price']) + floatval($order['deductcredit2']);
}
//积分抵扣加入金额计算
if ($order['deductcredit'] > 0) {
$order['price'] = floatval($order['price']) + floatval($order['deductprice']);
}
//type 1:消费 2:签到 3:任务 4:其他
$res = p('lottery')->getLottery($order['openid'], 1, array('money' => $order['price'], 'paytype' => 1));
if ($order['virtual']) {
$afterorder = p('lottery')->getLottery($order['openid'], 1, array('money' => $order['price'], 'paytype' => 2));
if ($afterorder) {
p('lottery')->getLotteryList($order['openid'], array('lottery_id' => $afterorder));
}
}
if ($res) {
//发送模版消息
p('lottery')->getLotteryList($order['openid'], array('lottery_id' => $res));
}
}
return true;
}
// public function pay($order) {
//
// global $_W, $_GPC;
//
// $orderid_cache = m("cache")->getString("orderid_".$order['id']);
// if(empty($orderid_cache))
// {
// m("cache")->set("orderid_".$order['id'],1);
// }else
// {
// return false;
// }
// //虚拟物品直接发货
// $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']));
// $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($vd['typeid']);
// }
// $virtual_str = implode("\n", $virtual_str);
// $virtual_info = "[" . implode(",", $virtual_info) . "]";
//
// //更新订单的状态
// $time = time();
// pdo_update('ewei_shop_order', array('virtual_info' => $virtual_info, 'virtual_str' => $virtual_str, 'status' => '3', 'paytime' => $time, 'sendtime' => $time, 'finishtime' => $time), array('id' => $order['id']));
//
// //处理余额抵扣
// /*if ($order['deductcredit2'] > 0) {
// $shopset = m('common')->getSysset('shop');
// m('member')->setCredit($order['openid'], 'credit2', -$order['deductcredit2'], array(0, $shopset['name'] . "余额抵扣: {$order['deductcredit2']} 订单号: " . $order['ordersn']));
// }*/
//
// //购物积分
// //$credits = $goods['total'] * $g['credit'];
// $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 ($credits > 0) {
// $shopset = m('common')->getSysset('shop');
// m('member')->setCredit($order['openid'], 'credit1', $credits, array(0, $shopset['name'] . '购物积分 订单号: ' . $order['ordersn']));
// }
//
// //实际销量
// $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);
//
// //发送赠送优惠券
// 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']);
// }
//
// return true;
// }
}

12
core/com/wap.php Normal file
View File

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

1680
core/com/wxcard.php Normal file

File diff suppressed because it is too large Load Diff

14
core/inc/com_model.php Normal file
View File

@ -0,0 +1,14 @@
<?php
/*
* 人人商城V2
*
* @author ewei 狸小狐 QQ:22185157
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class ComModel {
}

View File

@ -0,0 +1,40 @@
<?php
/*
* 人人商城V2
*
* @author ewei 狸小狐 QQ:22185157
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
require MODULE_ROOT . '/defines.php';
class ComProcessor extends WeModuleProcessor {
public $model;
public $modulename;
public $message;
public function __construct($name = '') {
$this->modulename = EWEI_SHOP_V2_MODULE_NAME;
$this->pluginname = $name;
//自动加载插件model.php
$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;
}
}

21
core/inc/data_model.php Normal file
View File

@ -0,0 +1,21 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
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);
}
}
?>

3626
core/inc/functions.php Normal file

File diff suppressed because it is too large Load Diff

566
core/inc/page.php Normal file
View File

@ -0,0 +1,566 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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_SHOP_V2_MODULE_NAME . "/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_SHOP_V2_MODULE_NAME . "/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_SHOP_V2_MODULE_NAME . "/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_SHOP_V2_MODULE_NAME . "/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_SHOP_V2_MODULE_NAME . "/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);
}
if (p("sub_account")) {
$lasttime = strtotime(m("cache")->getString("sub_account_lasttime", "global"));
$interval = 5 * 60;
$current = time();
if ($lasttime + $interval <= $current) {
m("cache")->set("sub_account_lasttime", date("Y-m-d H:i:s", $current), "global");
ihttp_request(EWEI_SHOPV2_TASK_URL . "order/autosubaccount.php", array("uniacid" => $_W["uniacid"]), 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_SHOP_V2_MODULE_NAME;
$moduleroot = IA_ROOT . "/addons/" . EWEI_SHOP_V2_MODULE_NAME;
// 管理端
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_SHOP_V2_MODULE_NAME;
$moduleroot = IA_ROOT . "/addons/" . EWEI_SHOP_V2_MODULE_NAME;
$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;
}
}

720
core/inc/page_mobile.php Normal file
View File

@ -0,0 +1,720 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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,$_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, $_GPC;
if(is_h5app() || !is_weixin()){
return;
}
$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']);
}
elseif ($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, $_GPC;
if(is_h5app() || !is_weixin()){
return;
}
$mid = intval($_GPC['mid']);
$cmember_plugin = p('cmember');
if (!$cmember_plugin) {
return;
}
$openid = $_W['openid'];
$followed = m('user')->followed($openid);
if (!$followed) {
return;
}
$check = $cmember_plugin->checkMember($openid);
if (!empty($check)) {
return;
}
$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;
}
$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, $_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($_W['shopset']['commission']['level']>0)){
$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');
}elseif($controller=='sign'){
include $this->template('sign/_menu');
}elseif($controller=='sns'){
include $this->template('sns/_menu');
}elseif($controller=='seckill'){
include $this->template('seckill/_menu');
}elseif($controller=='mmanage'){
include $this->template('mmanage/_menu');
}elseif($ismerch){
include $this->template('merch/_menu');
}
else{
include $this->template('_menu');
}
}
}
public function shopShare() {
global $_W,$_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, $_GPC,$_S;
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');
$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]);
}
elseif ($diyitem['id'] == 'topmenu') {
$diy_topmenu = $diyitem;
//unset($diyitems[$diyitemid]);
}
}
unset($diyitem);
}
//qwj 富文本中添加会员数显示变量
if(strexists($jsondiyitems, 'richtext')) {
foreach ($diyitems as $diyitemid => &$diyitem) {
if ($diyitem['id'] == 'richtext') {
$content = base64_decode($diyitem['params']['content']);
if (strpos($content, '#会员数#') !== false) {
$diypagedata = m('common')->getPluginset('diypage');
$bottombar = $diypagedata['member_num'];
if (empty($bottombar['isopen']) && $bottombar['isopen1'] == 1) {
$condition = " and dm.uniacid=:uniacid";
$params = array(':uniacid' => $_W['uniacid']);
$join = '';
$open_redis = function_exists('redis') && !is_error(redis());
if ($open_redis) {
$redis_key = "ewei_{$_W['uniacid']}_member_list";
$total = m('member')->memberRadisCount($redis_key);
if (!$total) {
$total = pdo_fetchcolumn("select count(*) from" . tablename('ewei_shop_member') . " dm {$join} where 1 {$condition} ", $params);
m('member')->memberRadisCount($redis_key, $total);
}
} else {
$total = pdo_fetchcolumn("select count(*) from" . tablename('ewei_shop_member') . " dm {$join} where 1 {$condition} ", $params);
}
$total = $bottombar['fakenum1'] ? $total + $bottombar['fakenum1'] : $total;
$content = str_replace("#会员数#", $total, $content);
$diyitem['params']['content'] = base64_encode($content);
} else {
unset($diyitems[$diyitemid]);
}
}
}
}
unset($diyitem);
}
//qwj end
}
$startadv = p('diypage')->getStartAdv($page['diyadv']);
/*if($type == 'commission' && (is_mobile() || is_weixin() || is_h5app())) {
foreach ($diyitems as $key => &$value) {
if($value['id'] == 'memberc')
{
$member = m('member')->getMember($_W['openid']);
$up = current(p('commission')->getAgentsByMember($_W['openid'],1));
if(!empty($up))
{
$upname = p('commission')->getLevel($up['openid']);
}
$upmember = $up['nickname'];
$level = p('commission')->getLevel($up['openid']);
if (empty($level))
{
$level = [
'id' => '0',
"levelname" => empty($_S['commission']['levelname']) ? '默认等级' : $_S['commission']['levelname'],
'commission1' => $_S['commission']['commission1'],
'commission2' => $_S['commission']['commission2'],
'commission3' => $_S['commission']['commission3'],
'withdraw' => (float)$_S['commission']['withdraw_default'],
'repurchase' => (float)$_S['commission']['repurchase_default']
];
}
$value['params']['upmember'] = $upmember;
$value['params']['levelname'] = $level['levelname'];
}
}
unset($value);
}
*/
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 && 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($days > 0) {
$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, $_GPC;
if(!p('diypage') || $diy) {
return;
}
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;
}
$matchCount = preg_match("/^((0\\d{2,3}-\\d{7,8})|(1[3584]\\d{9}))\$/", $diylayer["params"]["linkurl"]);
if (!empty($goods) && $matchCount) {
$diylayer['params']['linkurl'] .= '&goodsid=' . $goods['id'] . '&merch=' . $goods['merch'];
}
if (!empty($order) && $matchCount) {
$diylayer['params']['linkurl'] .= '&orderid=' . $order['id'];
}
include $this->template('diypage/layer');
}
return;
}
public function diyGotop($v=false, $diy=false, $merch=false){
global $_W, $_GPC;
if(!p('diypage') || $diy) {
return;
}
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;
}else{
if(!$diygotop['params']['isopen'] && $v) return;
}
include $this->template('diypage/gotop');
}
return;
}
public function diyDanmu($diy=false) {
global $_W,$_GPC;
if(!p('diypage')){
return;
}
$diypagedata = m('common')->getPluginset('diypage');
$danmu = $diypagedata['danmu'];
if(empty($danmu) || (!$diy && empty($danmu['params']['isopen']))){
return;
}
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);
}
}
elseif($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']));
}
elseif($danmu['params']['datatype']==2){
$danmu['data'] = set_medias($danmu['data'], 'imgurl');
}
if(empty($danmu['data']) || !is_array($danmu['data'])){
return;
}
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);
}
elseif($danmu['params']['datatype']==1){
$danmu['data'][$index]['time'] = p('diypage')->getDanmuTime(time()-$item['time']);
}elseif($danmu['params']['datatype']==2){
$danmu['data'][$index]['time'] = p('diypage')->getDanmuTime($danmu['data'][$index]['time']);
}
}
include $this->template('diypage/danmu');
}
//qwj添加功能
public function diyBottombar($diy=false) {
global $_W,$_GPC;
if(!p('diypage')){
return;
}
$diypagedata = m('common')->getPluginset('diypage');
$bottombar = $diypagedata['member_num'];
$condition = " and dm.uniacid=:uniacid";
$params = array(':uniacid' => $_W['uniacid']);
$join = '' ;
if(empty($bottombar) || (!$diy && empty($bottombar['isopen']))){
return;
}
$open_redis = function_exists('redis') && !is_error(redis());
if($open_redis) {
$redis_key = "ewei_{$_W['uniacid']}_member_list";
$total = m('member')->memberRadisCount($redis_key);
if(!$total){
$total = pdo_fetchcolumn("select count(*) from" . tablename('ewei_shop_member') . " dm {$join} where 1 {$condition} ", $params);
m('member') -> memberRadisCount($redis_key,$total);
}
}else{
$total = pdo_fetchcolumn("select count(*) from" . tablename('ewei_shop_member') . " dm {$join} where 1 {$condition} ", $params);
}
$total = $bottombar['fakenum'] ? $total + $bottombar['fakenum']:$total;
include $this->template('diypage/bottombar');
}
public function backliving() {
global $_W, $_GPC;
if(!p('live')){
return;
}
if(strexists($_W['routes'], 'live')){
return false;
}
$liveid = intval($_GPC['liveid']);
if(empty($liveid)){
return;
}
$living = p('live')->isLiving($liveid);
if(!$living){
return;
}
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

@ -0,0 +1,22 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class MobileLoginPage extends MobilePage {
public function __construct() {
global $_W,$_GPC;
parent::__construct();
}
}

View File

@ -0,0 +1,280 @@
<?php
/*
* 20200803
*
* FY
*/
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 Twig\Loader\FilesystemLoader($pluginTemplatePath);
$this->twig = new Twig\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

@ -0,0 +1,22 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class PluginMobileLoginPage extends PluginMobilePage {
public function __construct() {
global $_W,$_GPC;
parent::__construct();
}
}

View File

@ -0,0 +1,28 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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;
}
}

30
core/inc/page_system.php Normal file
View File

@ -0,0 +1,30 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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']|| $_W['role'] =='vice_founder'){
$this->message('您无权访问');
}
}
}

128
core/inc/page_web.php Normal file
View File

@ -0,0 +1,128 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class WebPage extends Page {
public function __construct($_init = true) {
if($_init){
$this->init();
}
// 设置版本
//m('system')->set_version();
$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) {
if (!is_array($is_xxx)) {
if (in_array($is_xxx, $perm_type_value)) {
$this->message('你没有相应的权限查看');
}
}
else {
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("你没有相应的权限查看");
} elseif (!$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();
}
function isOpenPlugin()
{
$name = com_run('perm::allPerms');
unset($name['shop']);
unset($name['goods']);
unset($name['member']);
unset($name['order']);
unset($name['finance']);
unset($name['statistics']);
unset($name['sysset']);
unset($name['sale']);
$name_keys = array_keys($name);
return implode('|',$name_keys);
}
function frame_menus() {
global $_GPC, $_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");
}
}
}
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');
}
}

27
core/inc/page_web_com.php Normal file
View File

@ -0,0 +1,27 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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

@ -0,0 +1,127 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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_SHOP_V2_MODULE_NAME;
$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_URL . '/grant', $data);
if (empty($resp['content'])) {
return array('errno' => -1, 'errmsg' => '访问失败');
}
$result = json_decode($resp['content'], true); */
//RubySn0w 修改
$result['errno'] = 0;
return $result;
}
}
?>

74
core/inc/plugin_model.php Normal file
View File

@ -0,0 +1,74 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
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));
}
function getName() {
return pdo_fetchcolumn('select name from ' . tablename('ewei_shop_plugin') . ' where identity=:identity limit 1', array(':identity' => $this->pluginname));
}
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

@ -0,0 +1,56 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
require MODULE_ROOT . '/defines.php';
class PluginProcessor extends WeModuleProcessor {
public $model;
public $modulename;
public $message;
public function __construct($name = '') {
global $_W;
$this->modulename = EWEI_SHOP_V2_MODULE_NAME;
$this->pluginname = $name;
$secure = $this->getIsSecureConnection();
$http = $secure ? 'https' : 'http';
$_W['siteroot'] = strexists($_W['siteroot'],'https://') ? $_W['siteroot'] : str_replace('http',$http,$_W['siteroot']);
//自动加载插件model.php
$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;
} elseif (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) {
return true;
}
return false;
}
}

58
core/inc/processor.php Normal file
View File

@ -0,0 +1,58 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Processor extends WeModuleProcessor {
public function respond() {
if ($this->message["msgtype"] == "event" && $this->message["event"] == "MASSSENDJOBFINISH") {
$processor_file = EWEI_SHOPV2_PLUGIN . "videoaccount/core/processor.php";
if (is_file($processor_file)) {
require $processor_file;
$processor_class = "VideoaccountProcessor";
$proc = new $processor_class("videoaccount");
if (method_exists($proc, "respond")) {
return $proc->respond($this);
}
}
}
$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);
}
}
}
}
}

121
core/inc/receiver.php Normal file
View File

@ -0,0 +1,121 @@
<?php
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);
}
}

103
core/job/sendPoster.php Normal file
View File

@ -0,0 +1,103 @@
<?php
namespace core\job;
class sendPoster
{
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;
}
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);
}
}
}

96
core/job/sendPostera.php Normal file
View File

@ -0,0 +1,96 @@
<?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

@ -0,0 +1,118 @@
<?php
/**
* ALIPAY API: alipay.trade.app.pay request
*
* @author auto create
* @since 1.0, 2017-10-20 10:54:52
*/
class AlipayTradeAppPayRequest
{
/**
* app支付接口2.0
**/
private $bizContent;
private $apiParas = array();
private $terminalType;
private $terminalInfo;
private $prodCode;
private $apiVersion="1.0";
private $notifyUrl;
private $returnUrl;
private $needEncrypt=false;
public function setBizContent($bizContent)
{
$this->bizContent = $bizContent;
$this->apiParas["biz_content"] = $bizContent;
}
public function getBizContent()
{
return $this->bizContent;
}
public function getApiMethodName()
{
return "alipay.trade.app.pay";
}
public function setNotifyUrl($notifyUrl)
{
$this->notifyUrl=$notifyUrl;
}
public function getNotifyUrl()
{
return $this->notifyUrl;
}
public function setReturnUrl($returnUrl)
{
$this->returnUrl=$returnUrl;
}
public function getReturnUrl()
{
return $this->returnUrl;
}
public function getApiParas()
{
return $this->apiParas;
}
public function getTerminalType()
{
return $this->terminalType;
}
public function setTerminalType($terminalType)
{
$this->terminalType = $terminalType;
}
public function getTerminalInfo()
{
return $this->terminalInfo;
}
public function setTerminalInfo($terminalInfo)
{
$this->terminalInfo = $terminalInfo;
}
public function getProdCode()
{
return $this->prodCode;
}
public function setProdCode($prodCode)
{
$this->prodCode = $prodCode;
}
public function setApiVersion($apiVersion)
{
$this->apiVersion=$apiVersion;
}
public function getApiVersion()
{
return $this->apiVersion;
}
public function setNeedEncrypt($needEncrypt)
{
$this->needEncrypt=$needEncrypt;
}
public function getNeedEncrypt()
{
return $this->needEncrypt;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
<?php
/**
* 加密工具类
*
* User: jiehua
* Date: 16/3/30
* Time: 下午3:25
*/
/**
* 加密方法
* @param string $str
* @return string
*/
function encrypt($str,$screct_key){
//AES, 128 模式加密数据 CBC
$screct_key = base64_decode($screct_key);
$str = trim($str);
$str = addPKCS7Padding($str);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);
$encrypt_str = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);
return base64_encode($encrypt_str);
}
/**
* 解密方法
* @param string $str
* @return string
*/
function decrypt($str,$screct_key){
//AES, 128 模式加密数据 CBC
$str = base64_decode($str);
$screct_key = base64_decode($screct_key);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);
$encrypt_str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);
$encrypt_str = trim($encrypt_str);
$encrypt_str = stripPKSC7Padding($encrypt_str);
return $encrypt_str;
}
/**
* 填充算法
* @param string $source
* @return string
*/
function addPKCS7Padding($source){
$source = trim($source);
$block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$pad = $block - (strlen($source) % $block);
if ($pad <= $block) {
$char = chr($pad);
$source .= str_repeat($char, $pad);
}
return $source;
}
/**
* 移去填充算法
* @param string $source
* @return string
*/
function stripPKSC7Padding($source){
$source = trim($source);
$char = substr($source, -1);
$num = ord($char);
if($num==62)return $source;
$source = substr($source,0,-$num);
return $source;
}

View File

@ -0,0 +1,499 @@
<?php
if (!(defined('IN_IA')))
{
exit('Access Denied');
}
include('wxpaydemo.php');
require_once('AopClient.php');
require_once('AlipayTradeAppPayRequest.php');
require_once('AopEncrypt.php');
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 login()
{
global $_W;
global $_GPC;
if (is_weixin() || !(empty($_GPC['__ewei_shopv2_member_session_' . $_W['uniacid']])))
{
header('location: ' . mobileUrl());
}
if ($_W['ispost'])
{
$sns = $_GPC['sns'];
if($sns =="web"||empty($_GPC['sns']))
{
$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, '登录成功');
}else if($sns =="wx")
{
$tmp = m('member')->checkMemberSNS($sns);
$code = trim($_GPC['code']);
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']);
show_json(1, '登录成功');
}else
{
show_json(0, '微信登录失败获取openid失败');
}
}
}
$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 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 get_pay_config()
{
global $_W;
$sec = m("common")->getSec();
$sec = iunserializer($sec["sec"]);
$sec['app_alipay']["ali_notify_url"] = $_W["siteroot"] . "addons/ewei_shopv2/payment/alipay/notify.php";
echo json_encode($sec) ;
}
public function orderstatus()
{
global $_W;
global $_GPC;
$paytype = $_GPC["paytype"];
$paytype = $paytype=="alipay"?22:21;
if(strpos($_GPC["ordersn"],'RC') !==false){
$log = pdo_fetch("SELECT * FROM " . tablename("ewei_shop_member_log") . " WHERE `logno`=:logno limit 1", array( ":logno" => $_GPC["ordersn"] ));
if($log['status']==0)
{
pdo_update("ewei_shop_member_log", array( "status" =>1 ), array( "logno" =>$_GPC["ordersn"] ));
$row = pdo_fetch("SELECT * FROM " . tablename("ewei_shop_member") . " WHERE `openid`=:openid limit 1", array( ":openid" => $log['openid'] ));
if($row['uid']==0)
{
pdo_update("ewei_shop_member", array( "credit2" =>$row['credit2']+$log["money"] ), array( "openid" => $log['openid'] ));
}else
{
$row2 = pdo_fetch("SELECT * FROM " . tablename("mc_members") . " WHERE `uid`=:uid limit 1", array( ":uid" => $row['uid'] ));
pdo_update("mc_members", array( "credit2" =>$row2['credit2']+$log["money"] ), array( "uid" => $row['uid'] ));
}
}
}else
{
//$orderid = intval($_GPC["globe_orderid_"]);
//$app_paytype= intval($_GPC["app_paytype"]);
$ordersn = $_GPC["ordersn"];
$tradeno = $_GPC["tradeno"];
$result=pdo_update("ewei_shop_order", array( "status" =>1,"paytime"=>time(),"paytype" =>$paytype ), array( "ordersn" => $ordersn, "uniacid" => $_W["uniacid"] ));
echo json_encode($result) ;
}
}
public function Pay_data()
{
if( isset($_POST['submit_wx'] )&& $_POST['submit_wx']=="true")
{
$fee=$_POST['fee'];
$app_wechat_appid=$_POST['wx_appid'];
$app_wechat_merchid=$_POST['wx_merchid'];
$app_wechat_apikey=$_POST['wx_apikey'];
$pay_attach=$_POST['pay_attach'];
$ordersn =$_POST['ordersn'];
$result_wx_pay=new wxpay($app_wechat_appid,$app_wechat_merchid,$app_wechat_apikey,$fee*100,$pay_attach,$ordersn);
$result_wx_pay_data=$result_wx_pay->result_paydata;
echo ($result_wx_pay_data) ;
}
if( isset($_POST['submit_ali'] )&& $_POST['submit_ali']=="true")
{
global $_W;
$fee=$_POST['fee'];
$rand = rand(10000, 99999);
$order=$_POST['ordersn'];
$set_ali_appid= $_POST['ali_appid'];
$set_ali_PrivateKey= $_POST['ali_private_key_rsa2'];
$set_ali_PublicKey= $_POST['ali_public_key_rsa2'];
$ali_notify_url= $_POST['ali_notify_url'];
$pay_attach=$_POST['pay_attach'];
$result_ali_pay_data =$this->Alipay($fee,$order,$pay_attach,$set_ali_appid,$set_ali_PrivateKey,$set_ali_PublicKey,$ali_notify_url);//==================================用户自定义参数
echo $result_ali_pay_data ;
}
}
public function Alipay($price,$id,$name,$appId,$PrivateKey,$PublicKey,$ali_notify_url){
$type = 0;
if(strpos($_POST['ordersn'],'RC') !==false){
$type = 1;
}
$params = array('out_trade_no' => $_POST['ordersn'], 'total_amount' => $price, 'subject' =>$name . '订单', 'body' => $_W['uniacid'] . ':'.$type.':NATIVEAPP');
$sec = m('common')->getSec();
$sec = iunserializer($sec['sec']);
$alipay_config = $sec['app_alipay'];
//print_r($alipay_config);
$res = $this->alipay_build($params, $alipay_config);
$aop = new AopClient;
$aop->gatewayUrl = "https://openapi.alipay.com/gateway.do";
$aop->appId = $appId;
$aop->rsaPrivateKey = $PrivateKey;
$aop->alipayrsaPublicKey = $PublicKey;
$aop->format = "json";
$aop->charset = "UTF-8";
$aop->signType = "RSA2";
$request = new AlipayTradeAppPayRequest();
$bizcontent = "{\"body\":\"test\","
. "\"subject\": \"$name\","
. "\"out_trade_no\": \"$id\","
. "\"timeout_express\": \"30m\","
. "\"total_amount\": \"$price\","
. "\"product_code\":\"QUICK_MSECURITY_PAY\""
. "}";
$request->setNotifyUrl($ali_notify_url);
$request->setBizContent($bizcontent);
$response = $aop->sdkExecute($request);
return $response;
}
public function alipay_build($params, $config = array())
{
global $_W;
$arr = array('app_id' => $config['appid'], 'method' => 'alipay.trade.app.pay', 'format' => 'JSON', 'charset' => 'utf-8', 'sign_type' => 'RSA2', 'timestamp' => date('Y-m-d H:i:s', time()), 'version' => '1.0', 'notify_url' => $_W['siteroot'] . 'addons/ewei_shopv2/payment/alipay/notify.php', 'biz_content' => json_encode(array('timeout_express' => '90m', 'product_code' => 'QUICK_MSECURITY_PAY', 'total_amount' => $params['total_amount'], 'subject' => $params['subject'], 'body' => $params['body'], 'out_trade_no' => $params['out_trade_no'])));
ksort($arr);
$string1 = '';
foreach ($arr as $key => $v )
{
if (empty($v))
{
continue;
}
$string1 .= $key . '=' . $v . '&';
}
$string1 = rtrim($string1, '&');
//print_r($config);
$prevateKeytmp = $this->chackKey($config['private_key_rsa2'], false);
//print_r($prevateKeytmp);
$pkeyid = openssl_pkey_get_private($prevateKeytmp);
if ($pkeyid === false)
{
return error(-1, '提供的私钥格式不对');
}
//print_r("1");
$signature = '';
openssl_sign($string1, $signature, $pkeyid, OPENSSL_ALGO_SHA256);
openssl_free_key($pkeyid);
//print_r("2");
$signature = base64_encode($signature);
//print_r($signature);
$arr['sign'] = $signature;
return http_build_query($arr);
}
public function chackKey($key, $public = true)
{
if( empty($key) )
{
return $key;
}
if( $public )
{
if( strexists($key, "-----BEGIN PUBLIC KEY-----") )
{
$key = str_replace(array( "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----" ), "", $key);
}
$head_end = "-----BEGIN PUBLIC KEY-----\n{key}\n-----END PUBLIC KEY-----";
}
else
{
if( strexists($key, "-----BEGIN RSA PRIVATE KEY-----") )
{
$key = str_replace(array( "-----BEGIN RSA PRIVATE KEY-----", "-----END RSA PRIVATE KEY-----" ), "", $key);
}
$head_end = "-----BEGIN RSA PRIVATE KEY-----\n{key}\n-----END RSA PRIVATE KEY-----";
}
$key = str_replace(array( "\r\n", "\r", "\n" ), "", trim($key));
$key = wordwrap($key, 64, "\n", true);
return str_replace("{key}", $key, $head_end);
}
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']);
}
public function agr()
{
global $_W;
$wapset = $_W['shopset']['wap'];
$agr = $wapset['agr'];
$agr_content = htmlspecialchars_decode($wapset['content']);
include $this->template('agr', NULL, true);
}
}
?>

View File

@ -0,0 +1,147 @@
<?php
//----------------------------
//变色龙在线制作App
//----------------------------
//变色龙版权所有
//----------------------------
class wxpay
{
private $appid='';
private $mc_id='';
private $wx_key='';
private $result_paydata='';
private $prepay_id='';
private $total_fee='';
private $pay_attach='';
private $out_trade_no='';
function __construct($appid1,$mc_id1,$wx_key1,$total_fee,$pay_attach,$ordersn)
{
$this->appid =$appid1 ;//开放平台appid-------------------------------------------------------------------必填
$this->mc_id = $mc_id1 ; //商户平台商户id---------------------------------------------------------------必填
$this->wx_key=$wx_key1; //商户平台支付秘钥key
$this->total_fee=$total_fee;
$this->pay_attach=$pay_attach;
$this->out_trade_no=$ordersn;
$url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
$postdata =$this-> mkPostData($this->appid, $this->mc_id,$this->total_fee);
$data =$this-> posturl($url,$postdata);
$this->prepay_id = $this-> getPrepayId($data);
$this->result_paydata= $paydata = $this-> mkPayData($this->prepay_id,$this->appid,$this->mc_id);
// echo $postdata;
// return $this->result;
}
//设置只能用来读取类里的变量,不能修改
public function __get($property_name)
{
if(isset($this->$property_name))
{
return $this->$property_name;
}
else
{
return NULL;
}
}
function mkPostData($appid,$mc_id,$fee){
$postarray=array(
"appid"=>$appid,
"body"=> $this->pay_attach,
"mch_id"=>$mc_id,
"nonce_str"=>md5(time()),
"notify_url"=>"http://127.0.0.1/addons/ewei_shopv2/payment/wechat/notify2.php", //自已的网址 修改
"out_trade_no"=>$this->out_trade_no,//'bsl_'.time(),
"spbill_create_ip"=>$_SERVER['REMOTE_ADDR'],
"total_fee"=>$fee,
"trade_type"=>"APP"
);
$sign =$this-> mkSign($postarray,$this->wx_key);
$postarray['sign'] = $sign;
$postdata = '<xml>';
foreach($postarray as $p => $v){
$postdata .= '<'.$p.'>'.$v.'</'.$p.'>';
}
$postdata .= '</xml>';
//$postdata = iconv('UTF-8','ISO8859-1',$postdata);
return $postdata;
}
function getPrepayId($data){
$ob = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA);
$prepayid = (array)$ob->prepay_id;
return $prepayid[0];
}
function mkPayData($prepay_id,$appid,$mc_id){
$data = array(
"appid"=>$appid,
"noncestr"=>md5(time()),
"package"=>"Sign=WXPay",
"partnerid"=>$mc_id,
"prepayid"=>$prepay_id,
"timestamp"=>time(),
);
$data['sign'] =$this-> mkSign($data,$this->wx_key);
return json_encode($data);
}
function mkSign($postarray,$wx_key){
//$wx_key = 'pHrHeeoxqG27tUf5Fgbl1pZjyHAcAuzt'; //商户平台支付秘钥key------------------------------------------------------------------必填
$poststr = '';
foreach($postarray as $k => $v)
{
$poststr .= $k."=".$v."&";
}
$poststr .= 'key=' . $wx_key;
$poststr = rtrim($poststr, '&');
/*
foreach($postarray as $p => $v){
$poststr .= '&'.$p.'='.$v;
}
$poststr .= '&key='.$wx_key;
*/
return strtoupper(md5($poststr));
return strtoupper(md5(substr($poststr,1)));
}
// function sendData($url,$data){
// $ch = curl_init();//初始化curl
// curl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页
// curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
// curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
// curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// curl_error($ch);
// $data = curl_exec($ch);//运行curl
// // curl_close($ch);
// return $data;
// }
function posturl($url,$data){
// $data = json_encode($data);
// $headerArray =array("Content-type:application/json;charset='utf-8'","Accept:application/json");
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
// curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
// return json_decode($outputtrue);
return $output;
}
}

View File

@ -0,0 +1,27 @@
<?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();
}
}

2029
core/mobile/goods/detail.php Normal file

File diff suppressed because it is too large Load Diff

124
core/mobile/goods/index.php Normal file
View File

@ -0,0 +1,124 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobilePage {
function main() {
global $_W, $_GPC;
$allcategory = m('shop')->getCategory();
$catlevel = intval($_W['shopset']['category']['level']);
$opencategory = true; //是否自己商品不同步分类
$plugin_commission = p('commission');
if ($plugin_commission && intval($_W['shopset']['commission']['level']) > 0) {
$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();
}
function gift(){
global $_W,$_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,total from ".tablename('ewei_shop_goods')." where uniacid = ".$uniacid." and deleted = 0 and id = ".$value." and status = 2 ");
}
$giftgoods = array_filter($giftgoods);
}
include $this->template();
}
function get_list() {
global $_GPC, $_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 && intval($_W['shopset']['commission']['level'])>0 && 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);
}
function query() {
global $_GPC, $_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

@ -0,0 +1,80 @@
<?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 pid = :pid and goodsid = :goodsid and uniacid = :uniacid ORDER BY id DESC", array(':pid' => $pid, ':goodsid' => $goodsid, ':uniacid' => $uniacid));
$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 pid = :pid and goodsid = :goodsid and uniacid = :uniacid and optionid = :optionid ORDER BY id DESC", array(':goodsid' => $goodsid, ':optionid' => intval($value), ':uniacid' => $uniacid, ':pid' => $pid));
}
show_json(1, $option);
}
}

View File

@ -0,0 +1,681 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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,buyagain,buyagain_sale,preselltimestart,buyagain_islong,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);
}
if (floatval($goods['buyagain']) > 0 && !empty($goods['buyagain_sale'])) {
//第一次后买东西享受优惠
$goods['goodsid'] = $goods['id'];
if (m('goods')->canBuyAgain($goods)) {
$goods['minprice'] *= $goods['buyagain']/10;
$goods['maxprice'] *= $goods['buyagain']/10;
}
}
$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

@ -0,0 +1,24 @@
<?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

@ -0,0 +1,187 @@
<?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,
isdiscount_time,isdiscount_time_start,isdiscount_discounts, needfollow, followtip, followurl, `type`,intervalfloor,intervalprice, isverify, maxprice, minprice, merchsale,ispresell,preselltimeend,unite_total,threen
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'];
$followqrcode = $_W['shopset']['share']['followqrcode'];
$followqrcode = tomedia($followqrcode);
show_json(2, array('followtip' => $followtip, 'followurl' => $followurl, 'followqrcode' => $followqrcode));
}
}
$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'];
}
}
$diyformhtml = '';
$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();
}
}
$goods['canAddCart'] = true;
show_json(1, array('goods' => $goods, 'spec1items' => $spec1items, 'spec2items' => $spec2items, 'options' => $options, 'diyformhtml' => $diyformhtml, 'hasoption' => $hasoption));
}
}
?>

291
core/mobile/index.php Normal file
View File

@ -0,0 +1,291 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobilePage {
function main() {
global $_W, $_GPC;
//定制
/*if(p('offic')){
header('location: ' . mobileUrl('offic'));
}*/
$_SESSION['newstoreid']=0;
$this->diypage('home');
$shopSetting = m('common')->getSysset(array('trade','shop'));
// //交易增强功能
$trade = $shopSetting['trade'];
$shop_data = $shopSetting['shop'];
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($days > 0) {
$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);
}
$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();
}
}
include $this->template();
}
function get_recommand(){
global $_W, $_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, $_GPC;
return m("common")->createStaticFile(mobileUrl('getpage',null,true));
}
function getpage(){
global $_W, $_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($value['ispresell']>0){
$indexrecommands[$key]['minprice'] = $value['presellprice'];
}
$indexrecommands[$key]['seecommission'] = $this->getCommission($value,$level,$set);
if($indexrecommands[$key]['seecommission'] >0){
$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();
}
function seckillinfo(){
$seckillinfo = plugin_run('seckill::getTaskSeckillInfo');
include $this->template('shop/index/seckill_tpl');
exit;
}
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);
}
function share_url()
{
global $_W,$_GPC;
$url = trim($_GPC['url']);
$account_api = WeAccount::create($_W['acid']);
$jssdkconfig = $account_api->getJssdkConfig($url);
show_json(1,$jssdkconfig);
}
//获取分销商等级
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;
}
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 = $set['level'] >= 1 ? ($goods['commission1_rate'] > 0 ? ($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 = $set['level'] >= 1 ? round($level['commission1'] * $goods['marketprice'] / 100, 2) : 0;
} else {
if( $goods['marketprice'] <= 0){
$goods['marketprice'] = $goods['maxprice'];
}
$commission = $set['level'] >= 1 ? round($set['commission1'] * $goods['marketprice'] / 100, 2) : 0;
}
}
return $commission;
}
}

View File

@ -0,0 +1,335 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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('wxcard')->wxCardCodeDecrypt($encrypt_code);
$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('wxcard')->ActivateMembercardbyopenid($_W['openid']);
$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('wxcard')->wxCardCodeDecrypt($encrypt_code);
$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('wxcard')->ActivateMembercardbyopenid($_W['openid']);
$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

@ -0,0 +1,345 @@
<?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']);
$intellectAddress = m("common")->getSysset("trade")["intellect_address"];
$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"])) {
$other = array("境外地区", "台湾", "澳门", "香港");
if (!in_array($data["province"], $other)) {
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 敷衍 QQ:278638500
* @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;
}
}

233
core/mobile/member/bind.php Normal file
View File

@ -0,0 +1,233 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Bind_EweiShopV2Page extends MobileLoginPage
{
protected $member;
function __construct()
{
global $_W, $_GPC;
parent::__construct();
}
/*
* ***用户绑定逻辑
*
* 1. GPC到新手机号
* 2. 查询此手机号是否存在用户
* 2.1. 如果不存在 则直接绑定
* 2.2. 如果已存在 得到member2 判断是否是自己
* 2.2.1. 如果是自己 则返回
* 2.2.2. 如果不是自己 则判断 member2 是否是微信用户
* 2.2.2.1. 如果 member2 不是微信用户 则进行合并
* 2.2.2.2. 如果 member2 是微信用户 则判断自己 member 是否是微信用户
* 2.2.2.2.1. 如果自己 member 也是微信用户 则执行解绑、绑定
* 2.2.2.2.2. 如果 自己 member 不是微信用户则合并
*
*/
public function main(){
global $_W, $_GPC;
@session_start();
$member = m('member')->getMember($_W['openid']);
if(empty($member['id'])){
$this->message("会员数据出错");
}
$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($bind == 0){
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)");
}
// member 不等于空 判断是否是自己
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>");
}
}
// 判断 member2 不是是微信用户
if(!m('bind')->iswxm($member2)){
if($confirm) {
// member 不是微信用户 则进行合并
$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>");
}
}
// 判断 member 不是微信用户
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
));
}
}

579
core/mobile/member/cart.php Normal file
View File

@ -0,0 +1,579 @@
<?php
/*
* @ PHP 5.6
* @ Decoder version : 1.0.0.1
* @ Release on : 24.03.2018
* @ Website : http://EasyToYou.eu
*/
echo "\r\n";
if (!defined("IN_IA")) {
exit("Access Denied");
}
class Cart_EweiShopV2Page extends MobileLoginPage
{
public function main()
{
global $_W;
global $_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();
}
public function get_list()
{
global $_W;
global $_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 (0 < $g["intervalfloor"]) {
$g["intervalprice1"] = $intervalprice[0]["intervalprice"];
$g["intervalnum1"] = $intervalprice[0]["intervalnum"];
}
if (1 < $g["intervalfloor"]) {
$g["intervalprice2"] = $intervalprice[1]["intervalprice"];
$g["intervalnum2"] = $intervalprice[1]["intervalnum"];
}
if (2 < $g["intervalfloor"]) {
$g["intervalprice3"] = $intervalprice[2]["intervalprice"];
$g["intervalnum3"] = $intervalprice[2]["intervalnum"];
}
}
if (0 < $g["ispresell"] && ($g["preselltimeend"] == 0 || time() < $g["preselltimeend"])) {
$g["marketprice"] = 0 < intval($g["hasoption"]) ? $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["ggprice"] = $prices["price"];
$g["marketprice"] = $g["ggprice"];
$g["discounttype"] = $prices["discounttype"];
if ($seckillinfo && $seckillinfo["status"] == 0) {
$seckilllast = 0;
if (0 < $seckillinfo["maxbuy"]) {
$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 ($g["seckilllast"] < $totalmaxbuy) {
$totalmaxbuy = $g["seckilllast"];
}
if ($totalmaxbuy < $g["total"]) {
$g["total"] = $totalmaxbuy;
}
$g["minbuy"] = 0;
} else {
if ($g["type"] == 4) {
} else {
if (0 < $g["maxbuy"]) {
if ($totalmaxbuy != -1) {
if ($g["maxbuy"] < $totalmaxbuy) {
$totalmaxbuy = $g["maxbuy"];
}
} else {
$totalmaxbuy = $g["maxbuy"];
}
}
if (0 < $g["usermaxbuy"]) {
$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 ($last < $totalmaxbuy) {
$totalmaxbuy = $last;
}
} else {
$totalmaxbuy = $last;
}
}
if (0 < $g["minbuy"] && $totalmaxbuy < $g["minbuy"]) {
$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));
}
public function select()
{
global $_W;
global $_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);
}
public function update()
{
global $_W;
global $_GPC;
$id = intval($_GPC["id"]);
$goodstotal = intval($_GPC["total"]);
$optionid = intval($_GPC["optionid"]);
$type = intval($_GPC["type"]);
if ($type == 0) {
return NULL;
}
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);
}
public function add()
{
global $_W;
global $_GPC;
$id = intval($_GPC["id"]);
$total = intval($_GPC["total"]);
$this->_validateCartOverLimit();
$total <= 0 and $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 (0 < $goods["hasoption"] && 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));
}
public function addwholesale()
{
global $_W;
global $_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;
global $_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 (50 < $listCount + $simpleGoodsCount + $wholesaleCount) {
show_json(0, "您的购物车宝贝超过50个了建议您先去结算或清理");
}
}
public function remove()
{
global $_W;
global $_GPC;
$ids = $_GPC["ids"];
if (empty($ids) || !is_array($ids)) {
show_json(0, "参数错误");
}
$ids = arrayForceType($ids, "int", true);
$sql = "update " . tablename("ewei_shop_member_cart") . " set deleted=1 where uniacid=:uniacid and openid=:openid and id in (" . $ids . ")";
pdo_query($sql, array(":uniacid" => $_W["uniacid"], ":openid" => $_W["openid"]));
show_json(1);
}
public function tofavorite()
{
global $_W;
global $_GPC;
$uniacid = $_W["uniacid"];
$openid = $_W["openid"];
$ids = $_GPC["ids"];
if (empty($ids) || !is_array($ids)) {
show_json(0, "参数错误");
}
foreach ($ids as &$id) {
$id = (int) $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);
}
}
}
$ids = implode(",", $ids);
$sql = "update " . tablename("ewei_shop_member_cart") . " set deleted=1 where uniacid=:uniacid and openid=:openid and id in (" . $ids . ")";
pdo_query($sql, array(":uniacid" => $uniacid, ":openid" => $openid));
show_json(1);
}
public function caculategoodsprice()
{
global $_W;
global $_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));
}
public function submit()
{
global $_W;
global $_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"] && $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 && 1 < count($list)) {
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 (0 < $g["minbuy"] && $g["total"] < $g["minbuy"]) {
show_json(0, $g["title"] . "<br/> " . $g["minbuy"] . $g["unit"] . "起售!");
}
if (0 < $g["maxbuy"] && $g["maxbuy"] < $g["total"]) {
show_json(0, $g["title"] . "<br/> 一次限购 " . $g["maxbuy"] . $g["unit"] . "!");
}
}
if (0 < $g["usermaxbuy"]) {
if ($g["usermaxbuy"] < $g["total"] || $g["usermaxbuy"] < $g["allt"]) {
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 ($g["usermaxbuy"] < $order_goodscount || $g["usermaxbuy"] < $order_goodscount + $g["allt"]) {
show_json(0, $g["title"] . "<br/> 最多限购 " . $g["usermaxbuy"] . $g["unit"] . "!");
}
$total_buy = $order_goodscount + $g["total"];
if ($g["usermaxbuy"] < $total_buy || $g["usermaxbuy"] < $order_goodscount + $g["allt"]) {
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) && $option["stock"] != -1 && empty($option["stock"])) {
show_json(-1, $g["title"] . "<br/>" . $option["title"] . " 库存不足!");
}
} else {
if ($g["stock"] != -1 && empty($g["stock"])) {
show_json(0, $g["title"] . "<br/>库存不足!");
}
}
}
}
show_json(1);
}
}
?>

View File

@ -0,0 +1,58 @@
<?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

@ -0,0 +1,61 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Credit_EweiShopV2Page extends MobileLoginPage
{
public function main()
{
global $_W;
global $_GPC;
$_GPC['type'] = intval($_GPC['type']);
$member = m('member')->getMember($_W['openid'], true);
$showTransfer = false;
if (p('transfer_account')) {
$set = p('transfer_account')->getSet();
if ($set['credit'] == 1) {
$showTransfer = true;
}
}
$credit2 = m('member')->getCredit($_W['openid'], 'credit2');
include $this->template();
}
public function get_list()
{
global $_W;
global $_GPC;
$type = intval($_GPC['type']);
$listType = $_GPC['list_type'];
$pindex = max(1, intval($_GPC['page']));
$psize = 10;
$uidinfo = M('member')->getInfo($_W['openid']);
$uid = $uidinfo['uid'];
$credit_condition = ' and r.uniacid=' . $_W['uniacid'] . (' and r.credittype=\'credit1\' and r.openid = \'' . $_W['openid'] . '\' ');
if ($listType == 1) {
$credit_condition .= ' and (r.num < 0) ';
}
else {
$credit_condition .= ' and (r.num > 0) ';
}
$list = 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.openid = r.openid where 1 ' . $credit_condition . ' order by r.createtime desc LIMIT ' . ($pindex - 1) * $psize . ',' . $psize);
$total = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_member_credit_record') . 'r left join ' . tablename('ewei_shop_member') . ' m on m.openid = r.openid where 1 ' . $credit_condition);
foreach ($list as &$item) {
$item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
$item['rechargetype'] = 'credit';
}
unset($item);
show_json(1, array('list' => $list, 'total' => $total, 'pagesize' => $psize));
}
}
?>

View File

@ -0,0 +1,155 @@
<?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, '参数错误');
}
$ids = implode(",", $ids);
$sql = "update " . tablename("ewei_shop_member_favorite") . " set deleted=1 where openid=:openid and id in (" . $ids . ")";
pdo_query($sql, array(":openid" => $_W["openid"]));
show_json(1);
}
}

View File

@ -0,0 +1,98 @@
<?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

@ -0,0 +1,75 @@
<?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

@ -0,0 +1,261 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobileLoginPage {
function main() {
global $_W, $_GPC;
//会员信息
$usermembercard=false;//默认不能使用会员卡
$member = m('member')->getMember($_W['openid'], true);
if(p('membercard') && m('plugin')->permission('membercard'))
{
$list_membercard= p('membercard')->get_Mycard('',0,100, "all");
$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']));
// $statics['newcoupon'] = pdo_fetchcolumn("SELECT 1 FROM ".tablename('ewei_shop_coupon_data')." where openid=:openid and uniacid=:uniacid and isnew=1", 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']);
$cardnum = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('ewei_shop_wxcard') . " where uniacid=:uniacid and gettype =1", array(':uniacid'=>$_W['uniacid']));
$cardnum += $cardnum;
}
}
//股东
$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'];
}
//3N倍增营销(定制)
$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'])){
if((empty($_W['shopset']['app']['isclose']) && !empty($_W['shopset']['app']['openbind'])) || !empty($_W['shopset']['wap']['open']) || $hasThreen){
// 判断 如果小程序开启绑定 或者 开启WAP 则需要绑定
$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();
}
}

130
core/mobile/member/info.php Normal file
View File

@ -0,0 +1,130 @@
<?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');
/* $oauth_account = WeAccount::create();
$AccessToken = $oauth_account->getAccessToken();
$userinfo = $oauth_account->fansQueryInfo($_W['openid']);
if (isset($userinfo['headimgurl']) && !empty($userinfo['headimgurl']) && !empty($this->member)) {
if ($this->member['avatar'] != $userinfo['headimgurl']) {
pdo_update('ewei_shop_member', array('avatar' => $userinfo['headimgurl']), array('id' => $this->member['id'], 'uniacid' => $this->member['uniacid']));
$this->member['avatar'] = $userinfo['headimgurl'];
}
}
*/
$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']);
if (!empty($memberdata['edit_avatar'])) {
$m_data['avatar'] = $memberdata['edit_avatar'];
}
$m_data['nickname'] = $memberdata['nickname'];
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

@ -0,0 +1,73 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Log_EweiShopV2Page extends MobileLoginPage {
function main() {
global $_W, $_GPC;
$_GPC['type'] = intval($_GPC['type']);
$showTransfer = false;
$member = m("member")->getMember($_W["openid"], true);
if( p("transfer_account") )
{
$set = p("transfer_account")->getSet();
if( $set["balance"] == 1 )
{
$showTransfer = true;
}
}
$credit2 = m("member")->getCredit($_W["openid"], "credit2");
include $this->template();
}
function get_list(){
global $_W, $_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 order by r.createtime desc LIMIT ";
$credit_condition = " and r.uniacid=" . $_W["uniacid"] . " and r.credittype='credit2' and r.uid = " . $uid . " and r.num > 0 and remark not like '%充值%' and remark not like '%转账%' order by r.createtime desc LIMIT ";
if($uid>0){
$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

@ -0,0 +1,37 @@
<?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();
}
}

220
core/mobile/member/rank.php Normal file
View File

@ -0,0 +1,220 @@
<?php
function ranksort($a, $b)
{
return $b['credit1'] < $a['credit1'] ? -1 : 1;
}
if (!defined('IN_IA')) {
exit('Access Denied');
}
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;
global $_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;
global $_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 ($num <= $pindex * $psize) {
$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_SHOP_V2_MODULE_NAME . "\" 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;
global $_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;
global $_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 ($num <= $pindex * $psize) {
$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

@ -0,0 +1,410 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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, '请填写充值金额!');
}
//pdo_delete('ewei_shop_member_log', array('openid' => $_W['openid'], 'status' => 0, 'type' => 0, 'uniacid' => $_W['uniacid']));
$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'));
}
}
/*
function alipay_complete() {
global $_W, $_GPC;
$logno = trim($_GPC['out_trade_no']);
$notify_id = trim($_GPC['notify_id']); //支付宝通知ID
$sign = trim($_GPC['sign']);
if(is_h5app()){
$set = m('common')->getSysset(array('shop', 'pay'));
$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'));
}
}else{
if (empty($logno)) {
die('[ERR1]充值出现错误,请重试!');
}
if(empty($set['pay']['alipay']) && is_weixin()){
$this->message('未开启支付宝支付!', mobileUrl('order'));
}
if (!m('finance')->isAlipayNotify($_GET)) {
die('[ERR2]充值出现错误,请重试!');
}
}
$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), 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']);
}
$url = mobileUrl('member', null, true);
die("<script>top.window.location.href='{$url}'</script>");
}*/
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

@ -0,0 +1,261 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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

@ -0,0 +1,84 @@
<?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);
}
}

5615
core/mobile/order/create.php Normal file

File diff suppressed because it is too large Load Diff

1003
core/mobile/order/index.php Normal file

File diff suppressed because it is too large Load Diff

412
core/mobile/order/list.php Normal file
View File

@ -0,0 +1,412 @@
<?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();
}
}

250
core/mobile/order/op.php Normal file
View File

@ -0,0 +1,250 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Op_EweiShopV2Page extends MobileLoginPage {
/**
* 取消订单
* @global type $_W
* @global type $_GPC
*/
function cancel() {
global $_W;
global $_GPC;
global $_S;
$orderid = intval($_GPC['id']);
$peerid = intval($_GPC['id']);
$uniacid = $_W['uniacid'];
$refundid = intval($_GPC['refundid']);
$order = pdo_fetch('select id,ordersn,openid,status,deductcredit,deductcredit2,deductprice,couponid,isparent,`virtual`,`virtual_info`,merchid 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($refundid)) {
$refundid = $order['refundid'];
}
if (!empty($refundid)) {
$refund = pdo_fetch('select * from ' . tablename('ewei_shop_order_refund') . ' where id=:id limit 1', array(':id' => $refundid));
}
$peerpay = pdo_fetch('select p.*,o.openid from ' . tablename('ewei_shop_order_peerpay') . ' p join ' . tablename('ewei_shop_order') . ' o on o.id=p.orderid where p.orderid=:id and p.uniacid=:uniacid limit 1', array(':id' => $peerid, ':uniacid' => $uniacid));
$peerpay_info = pdo_fetchall('select * from ' . tablename('ewei_shop_order_peerpay_payinfo') . ' where pid=:pid', array(':pid' => $peerpay['id']));
$peerpay_info1 = (double) pdo_fetchcolumn('select SUM(price) price from ' . tablename('ewei_shop_order_peerpay_payinfo') . ' where pid=:pid limit 1', array(':pid' => $peerpay['id']));
$rate_price = round($peerpay['peerpay_realprice'] - $peerpay_info1, 2);
if (0 < $rate_price) {
$shopset = $_S['shop'];
foreach ($peerpay_info as $v) {
if ($v['paytype'] == 1) {
m('member')->setCredit($v['openid'], 'credit2', $v['price'], array(0, $shopset['name'] . ('退款: ' . $v['price'] . '元 代付订单号: ') . $order['ordersn']));
} else {
if ($v['paytype'] == 21) {
m('finance')->refund($v['openid'], $v['tid'], $refund['refundno'] . $v['id'], $v['price'] * 100, $v['price'] * 100, !empty($order['apppay']) ? true : false);
}
}
}
}
if (empty($order)) {
show_json(0, '订单未找到');
}
if($order['status'] > 0){
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='.$order['merchid'].' where typeid=' . intval($typeid).' and orderid = '.$order["id"]);
//模板减少使用数据
pdo_query("update " . tablename('ewei_shop_virtual_type') . " set usedata=usedata-".$vkeynum." where id=" .intval($typeid));
}
//返还抵扣积分
if ($order['deductprice'] > 0) {
m('member')->setCredit($order['openid'], 'credit1', $order['deductcredit'], array('0', $_W['shopset']['shop']['name'] . "购物返还抵扣积分 积分: {$order['deductcredit']} 抵扣金额: {$order['deductprice']} 订单号: {$order['ordersn']}"));
}
//返还抵扣余额
if (0 < $order['deductcredit2']) {
m('member')->setCredit($order['openid'], 'credit2', $order['deductcredit2'], array('0', $_W['shopset']['shop']['name'] . ('购物返还抵扣余额 余额: ' . $order['deductcredit2'] . ' 订单号: ' . $order['ordersn'])));
}
// m('order')->setDeductCredit2($order);
//处理订单库存及用户积分情况(赠送积分)
m('order')->setStocksAndCredits($orderid, 2);
//退还优惠券 退还之前先检测
if (com('coupon') && !empty($order['couponid'])) {
//检测当前优惠券有没有使用过
$plugincoupon = com('coupon');
if ($plugincoupon) {
/* $coupondata= $plugincoupon->getCouponByDataID($order['couponid']);
if($coupondata['used']!=1){
com('coupon')->returnConsumeCoupon($orderid); //手机关闭订单
}*/
$plugincoupon->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
*/
function finish() {
global $_W, $_GPC;
$orderid = intval($_GPC['id']);
//单品退换货,确认收货后取消维权
pdo_update('ewei_shop_order_goods', array('single_refundstate' => 0), array('orderid' => $orderid, 'uniacid' => $_W['uniacid']));
$order = pdo_fetch("select id,status,openid,couponid,price,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 ($order['refundstate'] > 0 && !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,true);
//商品全返
m('order')->fullback($orderid);
//show_json(0, $res);
//会员升级
$memberSetting = m('common')->getSysset('member');
if ((int) $memberSetting['upgrade_condition'] === 1 || empty($memberSetting['upgrade_condition'])) {
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')){
//type 1:消费 2:签到 3:任务 4:其他
$res = p('lottery')->getLottery($_W['openid'],1,array('money'=>$order['price'],'paytype'=>2));
if($res){
p('lottery')->getLotteryList($_W['openid'],array('lottery_id'=>$res));
}
}
// 任务中心
if (p('task')){
p('task')->checkTaskProgress($order['price'],'order_full','',$order['openid']);
}
show_json(1,array('url'=>mobileUrl('order',array('status'=>3))));
}
/**
* 删除或恢复订单
* @global type $_W
* @global type $_GPC
*/
function delete() {
global $_W, $_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 ($order['refundstate'] > 0 && !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);
}
}

1853
core/mobile/order/pay.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,260 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Pay_Alipay_EweiShopV2Page extends MobilePage {
function main()
{
global $_W, $_GPC;
$url = urldecode($_GPC['url']);
if(!is_weixin()){
header('location: ' . $url);
exit;
}
include $this->template('order/alipay');
}
public function complete() {
global $_GPC, $_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']);
$alidata = base64_decode($_GET['alidata']);
$alidata = json_decode($alidata, true);
$sign_type = trim($alidata['sign_type'],'"');
if($sign_type == 'RSA'){
$public_key = $sec['app_alipay']['public_key'];
}else if($sign_type == 'RSA2'){
$public_key = $sec['app_alipay']['public_key_rsa2'];
}
if(empty($set['pay']['app_alipay']) || empty($public_key)){
$this->message('支付出现错误,请重试(1)!', mobileUrl('order'));
}
$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_SHOP_V2_MODULE_NAME, ':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_SHOP_V2_MODULE_NAME, ':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
$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);
die("<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');
}
}
}
function recharge_complete() {
global $_W, $_GPC;
$fromwechat = intval($_GPC['fromwechat']);
//$this->message("121212");
$logno = trim($_GPC['out_trade_no']);
$notify_id = trim($_GPC['notify_id']); //支付宝通知ID
$sign = trim($_GPC['sign']);
$set = m('common')->getSysset(array('shop', 'pay'));
if(is_h5app()){
$sec = m('common')->getSec();
$sec =iunserializer($sec['sec']);
if(empty($_GET['alidata'])){
$this->message('支付出现错误,请重试(1)!', mobileUrl('member'));
}
$alidata = base64_decode($_GET['alidata']);
$alidata = json_decode($alidata, true);
$sign_type = $alidata['sign_type'];
if($sign_type == 'RSA'){
$public_key = $sec['app_alipay']['public_key'];
}else if($sign_type == 'RSA2'){
$public_key = $sec['app_alipay']['public_key_rsa2'];
}
if(empty($set['pay']['app_alipay']) || empty($public_key)){
$this->message('支付出现错误,请重试(2)!', mobileUrl('order'));
}
$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']);
//
// //充值打印小票
// $member =m('member')->getMember($log['openid']);
// $params=array(
// 'nickname'=>empty($member['nickname'])?'未更新':$member['nickname'],
// 'price'=>$log['money'],
// 'paytype'=>'支付宝支付',
// 'paytime'=>date("Y-m-d H:i:s",time()),
// );
// com_run('printer::sendRechargeMessage',$params);
// }
if(is_h5app()){
$url = mobileUrl('member', null, true);
die("<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

@ -0,0 +1,372 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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']);
$singleRefund = pdo_fetch("select * from " . tablename("ewei_shop_order_single_refund") . " where orderid=:orderid and uniacid=:uniacid and status in (0,1) limit 1", array(":orderid" => $orderid, ":uniacid" => $uniacid));
if (!empty($singleRefund)) {
show_message("订单已单品维权");
}
$order = pdo_fetch("select id,status,price,refundid,goodsprice,dispatchprice,deductprice,deductcredit2,finishtime,isverify,`virtual`,refundstate,merchid,random_code,iscycelbuy,paytype,sub_account_status 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);
}
if ($order["sub_account_status"] == 1) {
$isSubAccount = false;
} else {
$isSubAccount = true;
}
$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

@ -0,0 +1,359 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
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 = '订单完成, 无法申请退款!';
}
}
}
$refund = pdo_fetch("select id,orderid from ".tablename('ewei_shop_order_refund')." where uniacid = :uniacid and orderid = :orderid and :goodsid in (ordergoodsids) and status > 0 limit 1 ",array(':uniacid'=>$uniacid,':orderid'=>$order['id'],':goodsid'=>$order_goodsid));
if(!empty($refund)){
$_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, NULL, $order_goodsid);
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,'single_refundid'=>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

@ -0,0 +1,73 @@
<?php
/*
* @ https://EasyToYou.eu - IonCube v10 Decoder Online
* @ PHP 5.6
* @ Decoder version: 1.0.4
* @ Release: 02/06/2020
*
* @ ZendGuard Decoder PHP 5.6
*/
if (!defined("IN_IA")) {
exit("Access Denied");
}
class Waitpay_EweiShopV2Page extends MobileLoginPage
{
public function main()
{
global $_W;
global $_GPC;
$trade = m("common")->getSysset("trade");
$orderid = $_GPC["id"];
$list = pdo_fetchall("select * from " . tablename("ewei_shop_order") . " where parentid=" . $orderid . " and uniacid=" . $_W["uniacid"]);
foreach ($list as &$row) {
$merchInfo = pdo_fetch("select * from " . tablename("ewei_shop_merch_user") . " where id=" . $row["merchid"]);
$row["merchname"] = $merchInfo["merchname"];
$param = array();
$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,\r\n og.sendtype,og.expresscom,og.expresssn,og.express,og.sendtime,og.finishtime,og.remarksend,og.single_refundid,og.single_refundstate\r\n 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;
}
}
if ($r["type"] == 5) {
$row["isonlyverifygoods"] = true;
}
if (empty($r["gtitle"]) != true) {
$r["title"] = $r["gtitle"];
}
}
unset($r);
$goods = set_medias($goods, "thumb");
if (empty($goods)) {
$goods = array();
}
$row["goods"] = $goods;
$row["goods_num"] = count($goods);
$cycelbuy_periodic = explode(",", $row["cycelbuy_periodic"]);
$row["phaseNum"] = $cycelbuy_periodic[2];
$row["statuscss"] = "text-cancel";
$row["statusstr"] = "待付款";
}
unset($row);
include $this->template();
}
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);
}
}
?>

View File

@ -0,0 +1,327 @@
<?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;
$coupon["desc"] = m("ui")->lazy($coupon["desc"]);
$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" && 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" && 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" && 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"]) && ($payment["type"] == 2 || $payment["type"] == 3) && !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 && $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() && (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

@ -0,0 +1,655 @@
<?php
/*
* 20200814
*
* FY
*/
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

@ -0,0 +1,824 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class My_EweiShopV2Page extends MobileLoginPage {
function main() {
global $_W, $_GPC;
$openid = $_W['openid'];
$set = m('common')->getPluginset('coupon');
com('coupon')->setShare();
include $this->template();
}
function detail() {
global $_W, $_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($coupon['enough']>0)
{
$title2 ='满'.((float)$coupon['enough']).'元';
}else
{
$title2 ='购物任意金额';
}
}
elseif($coupon['coupontype']=='1')
{
if($coupon['enough']>0)
{
$title2 ='充值满'.((float)$coupon['enough']).'元';
}else
{
$title2 ='充值任意金额';
}
}
elseif($coupon['coupontype']=='2')
{
if($coupon['enough']>0)
{
$title2 ='满'.((float)$coupon['enough']).'元';
}else
{
$title2 ='购物任意金额';
}
}
if($coupon['backtype']==0)
{
if($coupon['enough']=='0')
{
$coupon['color']='orange ';
}
else
{
$coupon['color']='blue';
}
$title3='减'.((float)$coupon['deduct']).'元';
}
if($coupon['backtype']==1)
{
$coupon['color']='red ';
$title3='打'.((float)$coupon['discount']).'折 ';
}
if($coupon['backtype']==2)
{
if($coupon['coupontype']=='0'||$coupon['coupontype']=='2')
{
$coupon['color']='red ';
}
else
{
$coupon['color']='pink ';
}
if (!empty($coupon['backmoney']) && $coupon['backmoney'] > 0) {
$title3 = $title3.'送'.$coupon['backmoney'].'元余额 ';
}
if (!empty($coupon['backcredit']) && $coupon['backcredit'] > 0) {
$title3 = $title3.'送'.$coupon['backcredit'].'积分 ';
}
if (!empty($coupon['backredpack']) && $coupon['backredpack'] > 0) {
$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();
}
function getlist(){
global $_W, $_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.friendcouponid,d.couponid,d.gettime,d.friendcouponid,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 ($row['enough'] > 0) {
$title2 ='满'.((float)$row['enough']).'元可用';
$title5="消费满".(float)$row['enough'];
} else {
$title2 = '无金额门槛';
$title5="消费任意金额";
}
} elseif ($row['coupontype'] == '1') {
if ($row['enough'] > 0) {
$title2 ='充值满'.((float)$row['enough']).'元可用';
$title5="充值满".(float)$row['enough'];
} else {
$title2 = '无金额门槛';
$title5="充值任意金额";
}
}elseif ($row['coupontype'] == '2') {
if ($row['enough'] > 0) {
$title2 ='满'.((float)$row['enough']).'元可用';
$title5="消费满".(float)$row['enough'];
} else {
$title2 = '无金额门槛';
$title5="消费任意金额";
}
}
if ($row['backtype'] == 0) {
$title3='<span class="subtitle">¥</span>'.((float)$row['deduct']);
$title5=$title5.'立减'.((float)$row['deduct']);
if($row['enough']=='0')
{
$row['color']='orange ';
$tagtitle = '代金券';
} else {
$row['color']='blue';
$tagtitle = '满减券';
}
}
if ($row['backtype'] == 1) {
$row['color'] = 'red ';
$title3=((float)$row['discount']).'折 ';
$title5=$title5.'打'.((float)$row['discount']).'折 ';
$tagtitle = '打折券';
}
if ($row['backtype'] == 2) {
if($row['coupontype']=='0')
{
$row['color']='red ';
$tagtitle = '购物返现券';
}
elseif($row['coupontype']=='1')
{
$row['color']='pink ';
$tagtitle = '充值返现券';
}
elseif($row['coupontype']=='2')
{
$row['color']='red ';
$tagtitle = '购物返现券';
}
if (!empty($row['backmoney']) && $row['backmoney'] > 0) {
//$title2 = $title2 . '送' . $row['backmoney'] . '元余额';
$title3="立返";
$title5="立返余额";
}
if (!empty($row['backcredit']) && $row['backcredit'] > 0) {
//$title2 = $title2 . '送' . $row['backcredit'] . '积分';
$title3="立返";
$title5="立返积分";
}
if (!empty($row['backredpack']) && $row['backredpack'] > 0) {
//$title2 = $title2 . '送' . $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));
}
function showcoupons() {
global $_W, $_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 ($row['enough'] > 0) {
$title2 = '消费满' . (float)$row['enough'] . '元';
} else {
$title2 = '消费';
}
} elseif ($row['coupontype'] == '1') {
if ($row['enough'] > 0) {
$title2 = '充值满' . (float)$row['enough'] . '元';
} else {
$title2 = '充值';
}
}
elseif ($row['coupontype'] == '2') {
if ($row['enough'] > 0) {
$title2 = '消费满' . (float)$row['enough'] . '元';
} else {
$title2 = '消费';
}
}
if ($row['backtype'] == 0) {
$title2 = $title2 . '立减' . ((float)$row['deduct']) . '元';
if($row['enough']=='0')
{
$row['color']='orange ';
$tagtitle = '代金券';
}
else
{
$row['color']='blue';
$tagtitle = '满减券';
}
}
if ($row['backtype'] == 1) {
$row['color'] = 'red ';
$title2 = $title2 . '打' . ((float)$row['discount']) . '折';
$tagtitle = '打折券';
}
if ($row['backtype'] == 2) {
if($row['coupontype']=='0')
{
$row['color']='red ';
$tagtitle = '购物返现券';
}
elseif($row['coupontype']=='1')
{
$row['color']='pink ';
$tagtitle = '充值返现券';
}
elseif($row['coupontype']=='2')
{
$row['color']='red ';
$tagtitle = '购物返现券';
}
if (!empty($row['backmoney']) && $row['backmoney'] > 0) {
$title2 = $title2 . '送' . $row['discount'] . '元余额';
}
if (!empty($row['backcredit']) && $row['backcredit'] > 0) {
$title2 = $title2 . '送' . $row['discount'] . '积分';
}
if (!empty($row['backredpack']) && $row['backredpack'] > 0) {
$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();
}
function showcoupons2() {
global $_W, $_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(mb_strlen($data['couponname'],'utf-8')>7)
{
$data['couponname']=mb_substr( $data['couponname'], 0, 7, 'utf-8' ).'...';
}
$title1='';
$title2='';
if ($data['backtype'] == 0)
{
$title1='<span>¥</span>'.(float)$data['deduct'];
}else if ($data['backtype'] == 1)
{
$title1=(float)$data['discount'].'<span>折</span>';
}else if($data['backtype'] == 2)
{
if (!empty($data['backmoney']) && $data['backmoney'] > 0) {
$title1 = '送' . $data['backmoney'] . '元余额';
}
if (!empty($data['backcredit']) && $data['backcredit'] > 0) {
$title1 .= '送' . $data['backcredit'] . '积分';
}
if (!empty($data['backredpack']) && $data['backredpack'] > 0) {
$title1 .= '送' . $data['backredpack'] . '元红包';
}
}
if($data['enough']>0)
{
$title2 ='满'.((float)$data['enough']).'元使用';
}
else
{
$title2 = '无金额门槛';
}
$goods = array();
$params = array(':uniacid'=>$_W['uniacid']);
$sql='select distinct g.* from ';
$table ='';
if($data['limitgoodcatetype']==1&&!empty($data['limitgoodcateids']))
{
$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["limitgoodcatetype"] == 1 && !empty($data["limitgoodcateids"])) {
$where .= " and g.cates in (" . $data["limitgoodcateids"] . ") ";
}
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 .=' LIMIT 5 ';
$sql =$sql.$table.$where;
$goods = pdo_fetchall($sql,$params );
foreach ($goods as $i=>&$row) {
$couponprice =(float)$row['minprice'];
if ($data['backtype'] == 0) {
$couponprice = round($couponprice - (float)$data['deduct'],2);
}
if ($data['backtype'] == 1) {
$couponprice = (float)$couponprice *(floatval($data['discount'])/10);
}
if($couponprice<0)
{
$couponprice=0;
}
$row['couponprice']=$couponprice;
}
unset($row);
$goods = set_medias($goods, 'thumb');
include $this->template();
}
function showcoupons3() {
global $_W, $_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($row['enough']>0)
{
$row['title2'] ='满'.((float)$row['enough']).'元使用';
}
else
{
$row['title2'] = '无金额门槛';
}
if($row['coupontype'] ==0 ||$row['coupontype'] ==2)
{
$row['title3'] ='优惠券';
if ($row['backtype'] == 0)
{
$row['title1'] ='<span>¥</span>'.(float)$row['deduct'];
}else if ($row['backtype'] == 1)
{
$row['title1']=(float)$row['discount'].'<span>折</span>';
}else if($row['backtype'] == 2)
{
if (!empty($row['backmoney']) && $row['backmoney'] > 0) {
$row['title1'] = '送' . $row['backmoney'] . '元余额';
}
if (!empty($row['backcredit']) && $row['backcredit'] > 0) {
$row['title1'] .= '送' . $row['backcredit'] . '积分';
}
if (!empty($row['backredpack']) && $row['backredpack'] > 0) {
$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(count($limitcateids)>0)
{
$table ='(';
$i=0;
foreach($limitcateids as $cateid)
{
$i++;
if($i>1)
{
$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 =(float)$row2['minprice'];
if ($row['backtype'] == 0) {
$couponprice = round($couponprice -(float)$row['deduct'],2);
}
if ($row['backtype'] == 1) {
$couponprice = (float)$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']) && $row['backmoney'] > 0) {
$row['title1'] = '送' . $row['backmoney'] . '元余额';
}
if (!empty($row['backcredit']) && $row['backcredit'] > 0) {
$row['title1'] .= '送' . $row['backcredit'] . '积分';
}
if (!empty($row['backredpack']) && $row['backredpack'] > 0) {
$row['title1'] .= '送' . $row['backredpack'] . '元红包';
}
}
}
}
include $this->template();
}
function showcoupongoods() {
global $_W, $_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(mb_strlen($data['couponname'],'utf-8')>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 && intval($_W['shopset']['commission']['level']) > 0) {
$mid = intval($_GPC['mid']);
if (!empty($mid)) {
$shop = p('commission')->getShop($mid);
if (empty($shop['selectcategory'])) {
$opencategory = false;
}
}
}
include $this->template();
}
function get_list() {
global $_GPC, $_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 && intval($_W['shopset']['commission']['level'])>0 && empty($_W['shopset']['commission']['closemyshop']) && !empty($_W['shopset']['commission']['select_goods'])) {
$mid = intval($_GPC['mid']);
if (!empty($mid)) {
$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

@ -0,0 +1,87 @@
<?php
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 and gettype <> 14 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

@ -0,0 +1,16 @@
<?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

@ -0,0 +1,31 @@
<?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

@ -0,0 +1,441 @@
<?php
//QQ278638500 敷衍 QQ维护群468773368 20200117
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

@ -0,0 +1,88 @@
<?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

@ -0,0 +1,24 @@
<?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

@ -0,0 +1,47 @@
<?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

@ -0,0 +1,52 @@
<?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();
}
}

36
core/mobile/store/map.php Normal file
View File

@ -0,0 +1,36 @@
<?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']));
}
$gcj02 = $this->Convert_BD09_To_GCJ02($store['lat'], $store['lng']);
$store['lat'] = $gcj02['lat'];
$store['lng'] = $gcj02['lng'];
$store['logo'] = empty($store['logo']) ? $_W['shopset']['shop']['logo'] : $store['logo'];
include $this->template();
}
public function Convert_BD09_To_GCJ02($lat, $lng)
{
$x_pi = 3.141592653589793 * 3000 / 180;
$x = $lng - 0.0065;
$y = $lat - 0.006;
$z = sqrt($x * $x + $y * $y) - 2.0E-5 * sin($y * $x_pi);
$theta = atan2($y, $x) - 3.0E-6 * cos($x * $x_pi);
$lng = $z * cos($theta);
$lat = $z * sin($theta);
return array('lat' => $lat, 'lng' => $lng);
}
}

View File

@ -0,0 +1,85 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Selector_EweiShopV2Page extends MobilePage
{
public function main()
{
global $_W;
global $_GPC;
include $this->template();
}
public function get_list()
{
global $_W;
global $_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)) {
if (is_string($ids)) {
$ids = explode(",", $ids);
}
$ids = arrayForceType($ids, "int", true);
$condition = ' and id in(' . $ids . ')';
}
if ($type == 1) {
$condition .= ' and type in(1,3) ';
}
else {
if ($type == 2) {
$condition .= ' and type in(2,3) ';
}
}
if (!empty($keyword)) {
$condition .= ' and `storename` like :keyword ';
$params[':keyword'] = '%' . $keyword . '%';
}
if (!$neer) {
$isneer = 0;
if (0 < $merchid) {
$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 (0 < $merchid) {
$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

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

12
core/mobile/util/task.php Normal file
View File

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

View File

@ -0,0 +1,105 @@
<?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]);
if (function_exists("exif_read_data")) {
$image = imagecreatefromstring(file_get_contents($file["tmp_name"]));
$exif = exif_read_data($file["tmp_name"]);
if (!empty($exif["Orientation"])) {
switch ($exif["Orientation"]) {
case 8:
$image = imagerotate($image, 90, 0);
break;
case 3:
$image = imagerotate($image, 180, 0);
break;
case 6:
$image = imagerotate($image, -90, 0);
break;
}
}
imagejpeg($image, $file["tmp_name"]);
}
$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 (!empty($_W["setting"]["remote"][$_W["uniacid"]]["type"])) {
$_W["setting"]["remote"] = $_W["setting"]["remote"][$_W["uniacid"]];
}
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"] = tomedia(trim($result["filename"]));
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

@ -0,0 +1,163 @@
<?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 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

@ -0,0 +1,91 @@
<?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

@ -0,0 +1,174 @@
<?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 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');
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,440 @@
<?php
/*
* 人人商城
*
* 青岛易联互动网络科技有限公司
* http://www.we7shop.cn
* TEL: 4000097827/18661772381/15865546761
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Index_EweiShopV2Page extends MobilePage {
function main() {
global $_W, $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
/*$verifygoods = pdo_fetchall('select vg.*,g.title,g.subtitle,g.thumb 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
left join ' . tablename('ewei_shop_order') . ' o on vg.orderid = o.id
left join ' . tablename('ewei_shop_order_refund') . ' orf on o.refundid = orf.id
where vg.uniacid=:uniacid and vg.openid=:openid and vg.invalid =0 and (orf.status is null or orf.status=0)', array(':uniacid' => $uniacid,':openid' => $openid));
*/
include $this->template();
}
function getlist(){
global $_W, $_GPC;
$openid = $_W['openid'];
$cate = trim($_GPC['cate']);
if(!empty($cate)){
if($cate=='used'){
$used = 1;
}else{
$past = 1;
}
}
$pindex = max(1, intval($_GPC['page']));
$psize = 10;
$time = time();
$sql='select vg.*,g.title,g.subtitle,g.thumb,c.card_id from ' . tablename('ewei_shop_verifygoods') . ' vg
inner join ' . tablename('ewei_shop_order_goods') . ' og on vg.ordergoodsid = og.id
left join ' . tablename('ewei_shop_order') . ' o on vg.orderid = o.id
left join ' . tablename('ewei_shop_order_refund') . ' orf on o.refundid = orf.id
inner join ' . tablename('ewei_shop_goods') . ' g on og.goodsid = g.id
left join ' . tablename('ewei_shop_goods_cards') . ' c on c.id = g.cardid
where vg.uniacid=:uniacid and vg.openid=:openid and vg.invalid =0 and (o.refundid=0 or orf.status<0) and o.status>0';
if(!empty($past)){
$sql.=" and ((vg.limittype=0 and vg.limitdays * 86400 + vg.starttime <{$time} )or ( vg.limittype=1 and vg.limitdate <{$time} )) and vg.used < 1";
}
else if(!empty($used)){
$sql.=" and vg.used =1";
}else if(empty($used)){
$sql.=" and ((vg.limittype=0 and vg.limitdays * 86400 + vg.starttime >={$time} )or ( vg.limittype=1 and vg.limitdate >={$time} )) and vg.used =0 ";
}
$total = pdo_fetchcolumn($sql, array(':uniacid' => $_W['uniacid'],':openid' => $openid));
$sql.=" order by vg.starttime desc LIMIT " . ($pindex - 1) * $psize . ',' . $psize; //类型+最低消费+示使用
$verifygoods = set_medias(pdo_fetchall($sql, array(':uniacid' => $_W['uniacid'],':openid' => $openid)), 'thumb');
if(empty($verifygoods))
{
$verifygoods=array();
}
foreach ($verifygoods as $i=>&$row) {
$verifygoodlogs = pdo_fetchall('select * from ' . tablename('ewei_shop_verifygoods_log') . ' where verifygoodsid =:id ', array(':id' => $row['id']));
$verifynum = 0;
foreach($verifygoodlogs as $verifygoodlog)
{
$verifynum +=intval($verifygoodlog['verifynum']);
}
$row['numlimit']=0;
if(empty($row['limitnum']))
{
if(empty($row['limittype']))
{
$surplusdays = (intval($row['starttime']) + $row['limitdays']*86400 -time())/86400;
}else
{
$surplusdays = (intval($row['limitdate'])-time())/86400;
}
if($surplusdays>0)
{
$row['surplusnum'] = intval($surplusdays);
}else
{
$row['surplusnum'] = "<span style='font-size: 1rem'>已过期</span>";
$row['expired'] = 1;
}
}else
{
$row['numlimit']=1;
$num = intval($row['limitnum']) - $verifynum;
if($num>0)
{
$row['surplusnum'] = $num;
}else
{
$row['surplusnum'] = "<span style='font-size: 1rem'>已使用</span>";
}
}
if(empty($row['limittype']))
{
$row['termofvalidity'] =date('Y-m-d H:i', intval($row['starttime']) + $row['limitdays']*86400 );
}else
{
$row['termofvalidity'] = date('Y-m-d H:i', $row['limitdate']);
}
if(empty($cate)){
$row['canuse']=1;
}
if(is_weixin())
{
if(!empty($row['card_id'])&&empty($row['activecard']))
{
$row['cangetcard']=1;
}
}
//如果是已过期的
if(!empty($past)){
$row['expired'] = 1;
}
}
unset($row);
show_json(1,array('list'=>$verifygoods,'pagesize'=>$psize, 'total'=>$total));
}
function detail() {
global $_W, $_GPC;
$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$cansee = 1;
if(!empty($_GPC['card_id'])&&!empty($_GPC['encrypt_code'])&&!empty($_GPC['openid']))
{
if($openid!=$_GPC['openid']){
header('location: ' . mobileUrl('verifygoods'));
}
$card_id = $_GPC['card_id'];
$encrypt_code = $_GPC['encrypt_code'];
//$data = com('wxcard')->wxCardCodeDecrypt($encrypt_code);
$data =com_run('wxcard::wxCardCodeDecrypt',$encrypt_code);
if(empty($data) || is_wxerror($data))
{
header('location: ' . mobileUrl('verifygoods'));
}
$code = $data['code'];
$item = pdo_fetch('select vg.*,g.title,g.subtitle,g.thumb from ' . tablename('ewei_shop_verifygoods') . ' vg
inner join ' . tablename('ewei_shop_order_goods') . ' og on vg.ordergoodsid = og.id
left join ' . tablename('ewei_shop_order') . ' o on vg.orderid = o.id
left join ' . tablename('ewei_shop_order_refund') . ' orf on o.refundid = orf.id
inner join ' . tablename('ewei_shop_goods') . ' g on og.goodsid = g.id
inner join ' . tablename('ewei_shop_goods_cards') . ' c on c.id = g.cardid
where vg.uniacid=:uniacid and vg.openid=:openid and vg.invalid =0 and c.card_id =:card_id and vg.cardcode=:cardcode and (o.refundid=0 or orf.status<0) and o.status>0 limit 1',
array(':uniacid' => $uniacid,':openid' => $openid,":card_id"=>$card_id,":cardcode"=>$code));
if(empty($item))
{
header('location: ' . mobileUrl('verifygoods'));
}
$id = $item['id'];
}
else
{
$id = $_GPC['id'];
$item = pdo_fetch('select vg.*,g.title,g.subtitle,g.thumb from ' . tablename('ewei_shop_verifygoods') . ' vg
inner join ' . tablename('ewei_shop_order_goods') . ' og on vg.ordergoodsid = og.id
left join ' . tablename('ewei_shop_order') . ' o on vg.orderid = o.id
left join ' . tablename('ewei_shop_order_refund') . ' orf on o.refundid = orf.id
inner join ' . tablename('ewei_shop_goods') . ' g on og.goodsid = g.id
where vg.id =:id and vg.uniacid=:uniacid and vg.openid=:openid and vg.invalid =0 and (o.refundid=0 or orf.status<0) and o.status>0 limit 1', array(':id' => $id,':uniacid' => $uniacid,':openid' => $openid));
}
if(empty($item))
{
header('location: ' . mobileUrl('verifygoods'));
}
//判断时间是否过期
if(empty($item['limittype']))
{
$limitdate = intval($item['starttime']) + intval($item['limitdays'])*86400;
}
else
{
$limitdate = intval($item['limitdate']);
}
if($limitdate<time())
{
// header('location: ' . mobileUrl('verifygoods'));
$cansee = 2;
}
$limitdatestr = date('Y-m-d H:i', $limitdate);
$verifygoodlogs = pdo_fetchall('select vgl.*,s.storename,sa.salername from ' . tablename('ewei_shop_verifygoods_log') . ' vgl
left join ' . tablename('ewei_shop_store') . ' s on s.id = vgl.storeid
left join ' . tablename('ewei_shop_saler') . ' sa on sa.id = vgl.salerid
where vgl.verifygoodsid =:id order by vgl.verifydate desc ', array(':id' => $id));
$verifynum = 0;
foreach($verifygoodlogs as &$verifygoodlog)
{
if(empty($verifygoodlog['storename'])){
$verifygoodlog['storename'] = $_W['shopset']['shop']['name'];
}
$verifynum +=intval($verifygoodlog['verifynum']);
}
unset($verifygoodlog);
if(!empty($item['limitnum']))
{
if($verifynum>=intval($item['limitnum']))
{
// header('location: ' . mobileUrl('verifygoods'));
$cansee = 3;
}
}
if($item['used'] ==1){
$cansee = 3;
}
$verifycode = $item['verifycode'];
if(empty($verifycode)||$item['codeinvalidtime']<time())
{
//记次时商品核销码8开头加8位随机数,共9位
$verifycode = "8".random(8, true);
while (1) {
$count = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_verifygoods') . ' where verifycode=:verifycode and uniacid=:uniacid limit 1', array(':verifycode' => $verifycode, ':uniacid' => $_W['uniacid']));
if ($count <= 0) {
break;
}
$verifycode = random(8, true);
}
$data = array(
"verifycode"=>$verifycode,
"codeinvalidtime"=>time()+1800
);
pdo_update("ewei_shop_verifygoods",$data,array("id"=>$item['id']));
}
$query = array('id' => $item['id'],'verifycode'=>$verifycode);
$url = mobileUrl('verify/verifygoods/detail', $query, true);
$qrurl = 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);
}
$goodsstore = pdo_fetch('select * from ' . tablename('ewei_shop_store') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $item['storeid'], ':uniacid' => $_W['uniacid']));
include $this->template();
}
function activecard()
{
global $_W, $_GPC;
$openid = $_W['openid'];
$card_id = $_GPC['card_id'];
$encrypt_code = $_GPC['encrypt_code'];
$code = "";
if(empty($card_id)||empty($encrypt_code))
{
}
//$data = com('wxcard')->wxCardCodeDecrypt($encrypt_code);
$data =com_run('wxcard::wxCardCodeDecrypt',$encrypt_code);
if(empty($data) || is_wxerror($data))
{
$this->message(array("message"=>"激活链接错误!", "title"=>"激活链接错误!", "buttondisplay"=>true), mobileUrl('verifygoods'), 'error');
}
$code = $data['code'];
$sql='select vg.*,g.title,g.subtitle,g.thumb,c.card_id 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
left join ' . tablename('ewei_shop_goods_cards') . ' c on c.id = g.cardid
where vg.uniacid=:uniacid and vg.openid=:openid and vg.invalid =0
and ((vg.limittype=0 and vg.limitdays * 86400 + vg.starttime >=unix_timestamp() )or ( vg.limittype=1 and vg.limitdate >=unix_timestamp() )) and vg.used =0 and (vg.activecard=0 or vg.activecard is null) and g.cardid>0 and c.card_id=:card_id';
$verifygoods = set_medias(pdo_fetchall($sql, array(':uniacid' => $_W['uniacid'],':openid' => $openid,':card_id'=>$card_id)), 'thumb');
if(empty($verifygoods))
{
//$good =com('wxcard')->getgoodidbycardid($card_id);
$good =com_run('wxcard::getgoodidbycardid',$card_id);
if(empty($good))
{
$this->message(array("message"=>"激活链接错误!", "title"=>"激活链接错误!", "buttondisplay"=>true), mobileUrl('verifygoods'), 'error');
}else
{
$this->message(array("message"=>"请先购买此商品!", "title"=>"请先购买此商品!", "buttondisplay"=>true),mobileUrl('goods/detail',array('id'=>$good['id'])), '');
//header('location: ' . mobileUrl('goods/detail',array('id'=>$good['id'])));
}
}
foreach ($verifygoods as $i=>&$row) {
$verifygoodlogs = pdo_fetchall('select * from ' . tablename('ewei_shop_verifygoods_log') . ' where verifygoodsid =:id ', array(':id' => $row['id']));
$verifynum = 0;
foreach($verifygoodlogs as $verifygoodlog)
{
$verifynum +=intval($verifygoodlog['verifynum']);
}
if(empty($row['limitnum']))
{
$row['surplusnum'] = "不限";
}else
{
$num = intval($row['limitnum']) - $verifynum;
$row['surplusnum'] = $num."";
}
if(empty($row['limittype']))
{
$row['termofvalidity'] =date('Y-m-d H:i', intval($row['starttime']) + $row['limitdays']*86400 );
}else
{
$row['termofvalidity'] = date('Y-m-d H:i', $row['limitdate']);
}
if(!empty($row['card_id'])&&empty($row['getcard']))
{
$row['cangetcard']=1;
}
}
unset($row);
include $this->template();
}
function active()
{
global $_W, $_GPC;
$openid = $_W['openid'];
$card_id = $_GPC['card_id'];
$encrypt_code = $_GPC['encrypt_code'];
$code = "";
$id = $_GPC['id'];
if(empty($card_id)||empty($encrypt_code)||empty($id))
{
$this->message(array("message"=>"激活链接错误!", "title"=>"激活链接错误!", "buttondisplay"=>true), mobileUrl('verifygoods'), 'error');
}
//$data = com('wxcard')->wxCardCodeDecrypt($encrypt_code);
$data =com_run('wxcard::wxCardCodeDecrypt',$encrypt_code);
if(empty($data) || is_wxerror($data))
{
$this->message(array("message"=>"激活链接错误!", "title"=>"激活链接错误!", "buttondisplay"=>true), mobileUrl('verifygoods'), 'error');
}
$code = $data['code'];
//$result =com('wxcard')->ActivateVerifygoodCard($id,$card_id,$code,$openid);
$result =com_run('wxcard::ActivateVerifygoodCard',$id,$card_id,$code,$openid);
if($result)
{
$redirect = mobileUrl('verifygoods/detail',array('id'=>$id));
$this->message(array("message"=>"您的核销卡已成功激活!", "title"=>"激活成功!", "buttondisplay"=>true), $redirect, 'success');
}else
{
$this->message(array("message"=>"激活链接错误!", "title"=>"激活链接错误!", "buttondisplay"=>true), mobileUrl('verifygoods'), 'error');
}
}
}

83
core/model/account.php Normal file
View File

@ -0,0 +1,83 @@
<?php
if (!defined("IN_IA")) {
exit("Access Denied");
}
class Account_EweiShopV2Model
{
public function checkLogin()
{
global $_W;
global $_GPC;
if (empty($_W["openid"])) {
$openid = $this->checkOpenid();
if (!empty($openid)) {
return $openid;
}
$url = urlencode(base64_encode($_SERVER["QUERY_STRING"]));
$loginurl = mobileUrl("account/login", array("mid" => $_GPC["mid"], "backurl" => $_W["isajax"] ? "" : $url));
if ($_W["isajax"]) {
show_json(0, array("url" => $loginurl, "message" => "请先登录!", "imgcode" => $_W["shopset"]["wap"]["smsimgcode"]));
}
header("location: " . $loginurl);
exit;
}
}
public function checkOpenid()
{
global $_W;
global $_GPC;
$key = "__ewei_shopv2_member_session_" . $_W["uniacid"];
if (isset($_GPC[$key])) {
$session = json_decode(base64_decode($_GPC[$key]), true);
if (is_array($session)) {
$member = m("member")->getMember($session["openid"]);
if (is_array($member) && $session["ewei_shopv2_member_hash"] == md5($member["pwd"] . $member["salt"])) {
$GLOBALS["_W"]["ewei_shopv2_member_hash"] = md5($member["pwd"] . $member["salt"]);
$GLOBALS["_W"]["ewei_shopv2_member"] = $member;
return $member["openid"];
}
isetcookie($key, false, -100);
}
}
}
public function setLogin($member)
{
global $_W;
if (!is_array($member)) {
$member = m("member")->getMember($member);
}
if (!empty($member)) {
$member["ewei_shopv2_member_hash"] = md5($member["pwd"] . $member["salt"]);
$key = "__ewei_shopv2_member_session_" . $_W["uniacid"];
$cookie = base64_encode(json_encode($member));
isetcookie($key, $cookie, 30 * 86400);
}
}
public function getSalt()
{
$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);
}
return $salt;
}
public function uni_accounts($uniacid = 0)
{
global $_W;
$uniacid = empty($uniacid) ? $_W["uniacid"] : intval($uniacid);
$account_info = pdo_get("account", array("uniacid" => $uniacid));
if (!empty($account_info)) {
$account_tablename = uni_account_type($account_info["type"]);
$account_tablename = $account_tablename["table_name"];
$accounts = pdo_fetchall("SELECT w.*, a.type, a.isconnect FROM " . tablename("account") . " a INNER JOIN " . tablename($account_tablename) . " w USING(acid) WHERE a.uniacid = :uniacid AND a.isdeleted <> 1 ORDER BY a.acid ASC", array(":uniacid" => $uniacid), "acid");
}
return !empty($accounts) ? $accounts : array();
}
}
?>

528
core/model/bind.php Normal file
View File

@ -0,0 +1,528 @@
<?php
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Bind_EweiShopV2Model
{
/**
* @param array $member
* @return bool
*/
public function iswxm($member = array())
{
if (empty($member) || !is_array($member)) {
return true;
}
if (strexists($member['openid'], 'sns_wx_') || strexists($member['openid'], 'sns_qq_') || strexists($member['openid'], 'sns_wa_') || strexists($member['openid'], 'wap_user_')) {
return false;
}
return true;
}
/**
* @param int $mid
* @param array $arr
*/
public function update($mid = 0, $arr = array())
{
global $_W;
if (empty($mid) || empty($arr) || !is_array($arr)) {
return NULL;
}
pdo_update('ewei_shop_member', $arr, array('id' => $mid, 'uniacid' => $_W['uniacid']));
}
/**
* @param array $a
* @param array $b
* @return array
*/
public function merge($a=array(), $b=array()){
global $_W;
if(empty($a) || empty($b) || $a['id']==$b['id']){
return error(0, "params error");
}
$createtime = $a['createtime'] > $b['createtime'] ? $b['createtime'] : $a['createtime'];
$childtime = $a['childtime'] > $b['childtime'] ? $b['childtime'] : $a['childtime'];
$comparelevel = m('member')->compareLevel(array($a['level'], $b['level']));
$level = $comparelevel ? $b['level'] : $a['level'];
$isblack = !empty($a['isblack']) || !empty($b['isblack']) ? 1 : 0;
$openid_qq = !empty($b['openid_qq']) && empty($a['openid_qq']) ? $b['openid_qq'] : $a['openid_qq'];
$openid_wx = !empty($b['openid_wx']) && empty($a['openid_wx']) ? $b['openid_wx'] : $a['openid_wx'];
$openid_wa = !empty($b['openid_wa']) && empty($a['openid_wa']) ? $b['openid_wa'] : $a['openid_wa'];
if(!empty($a['isagent']) && empty($b['isagent'])){
$isagent = 1;
$agentid = $a['agentid'];
$status = !empty($a['status']) ? 1 : 0;
$agenttime = $a['agenttime'];
$agentlevel = $a['agentlevel'];
$agentblack = $a['agentblack'];
$fixagentid = $a['fixagentid'];
}
elseif(!empty($b['isagent']) && empty($a['isagent'])){
$isagent = 1;
$agentid = $b['agentid'];
$status = !empty($b['status']) ? 1 : 0;
$agenttime = $b['agenttime'];
$agentlevel = $b['agentlevel'];
$agentblack = $b['agentblack'];
$fixagentid = $b['fixagentid'];
}
elseif(!empty($b['isagent']) && !empty($a['isagent'])){
$compare = p('commission')->compareLevel(array($a['agentlevel'], $b['agentlevel']));
$isagent = 1;
if($compare){
$agentid = $b['agentid'];
if(empty($b['agentid']) && !empty($a['agentid'])){
$agentid = $a['agentid'];
}
/*if ($agentid == $b['id'] || $agentid == $a['id']) {
$agentid = 0;
}*/
$status = !empty($b['status']) ? 1 : 0;
$agentblack = !empty($b['agentblack']) ? 1 : 0;
$fixagentid = !empty($b['fixagentid']) ? 1 : 0;
}else{
$agentid = $a['agentid'];
if(empty($a['agentid']) && !empty($b['agentid'])){
$agentid = $b['agentid'];
}
/*if ($agentid == $b['id'] || $agentid == $a['id']) {
$agentid = 0;
}*/
$status = !empty($a['status']) ? 1 : 0;
$agentblack = !empty($a['agentblack']) ? 1 : 0;
$fixagentid = !empty($a['fixagentid']) ? 1 : 0;
}
$agenttime = $compare ? $b['agenttime'] : $a['agenttime'];
$agentlevel = $compare ? $b['agentlevel'] : $a['agentlevel'];
}
elseif (empty($b['isagent']) && empty($a['isagent'])){
if(!empty($a['agentid']) && !empty($b['agentid'])){
$agentid = $a['agentid'];
}
elseif(empty($a['agentid']) && !empty($b['agentid'])){
$agentid = $b['agentid'];
}
elseif (!empty($a['agentid']) && empty($b['agentid'])){
$agentid = $a['agentid'];
}
if(!empty($a['inviter']) && !empty($b['inviter'])){
$inviter = $a['inviter'];
}
elseif(empty($a['inviter']) && !empty($b['inviter'])){
$inviter = $b['inviter'];
}
elseif (!empty($a['inviter']) && empty($b['inviter'])){
$inviter = $a['inviter'];
}
}
if(!empty($a['isauthor']) && empty($b['isauthor'])){
$isauthor = $a['isauthor'];
$authorstatus = !empty($a['authorstatus']) ? 1 : 0;
$authortime = $a['authortime'];
$authorlevel = $a['authorlevel'];
$authorblack = $a['authorblack'];
}
elseif(!empty($b['isauthor']) && empty($a['isauthor'])){
$isauthor = $b['isauthor'];
$authorstatus = !empty($b['authorstatus']) ? 1 : 0;
$authortime = $b['authortime'];
$authorlevel = $b['authorlevel'];
$authorblack = $b['authorblack'];
}
elseif(!empty($b['isauthor']) && !empty($a['isauthor'])){
return error(0, "此手机号已绑定另一用户(a1)<br>请联系管理员");
}
if(!empty($a['ispartner']) && empty($b['ispartner'])){
$ispartner = 1;
$partnerstatus = !empty($a['partnerstatus']) ? 1 : 0;
$partnertime = $a['partnertime'];
$partnerlevel = $a['partnerlevel'];
$partnerblack = $a['partnerblack'];
}
elseif(!empty($b['ispartner']) && empty($a['ispartner'])){
$ispartner = 1;
$partnerstatus = !empty($b['partnerstatus']) ? 1 : 0;
$partnertime = $b['partnertime'];
$partnerlevel = $b['partnerlevel'];
$partnerblack = $b['partnerblack'];
}
elseif(!empty($b['ispartner']) && !empty($a['ispartner'])){
return error(0, "此手机号已绑定另一用户(p)<br>请联系管理员");
}
if(!empty($a['isaagent']) && empty($b['isaagent'])){
$isaagent = $a['isaagent'];
$aagentstatus = !empty($a['aagentstatus']) ? 1 : 0;
$aagenttime = $a['aagenttime'];
$aagentlevel = $a['aagentlevel'];
$aagenttype = $a['aagenttype'];
$aagentprovinces = $a['aagentprovinces'];
$aagentcitys = $a['aagentcitys'];
$aagentareas = $a['aagentareas'];
}
elseif(!empty($b['isaagent']) && empty($a['isaagent'])){
$isaagent = $b['isaagent'];
$aagentstatus = !empty($b['aagentstatus']) ? 1 : 0;
$aagenttime = $b['aagenttime'];
$aagentlevel = $b['aagentlevel'];
$aagenttype = $b['aagenttype'];
$aagentprovinces = $b['aagentprovinces'];
$aagentcitys = $b['aagentcitys'];
$aagentareas = $b['aagentareas'];
}
elseif(!empty($b['isaagent']) && !empty($a['isaagent'])){
return error(0, "此手机号已绑定另一用户(a2)<br>请联系管理员");
}
$arr = array();
if(isset($createtime)){
$arr['createtime'] = $createtime;
}
if(isset($childtime)){
$arr['childtime'] = $childtime;
}
if(isset($level)){
$arr['level'] = $level;
}
if(isset($groupid)){
$arr['groupid'] = $groupid;
}
if(isset($isblack)){
$arr['isblack'] = $isblack;
}
if(isset($openid_qq)){
$arr['openid_qq'] = $openid_qq;
}
if(isset($openid_wx)){
$arr['openid_wx'] = $openid_wx;
}
if(isset($openid_wa)){
$arr['openid_wa'] = $openid_wa;
}
if(isset($status)){
$arr['status'] = $status;
}
if(isset($isagent)){
$arr['isagent'] = $isagent;
}
if(isset($agentid)){
$arr['agentid'] = $agentid;
}
if(isset($agenttime)){
$arr['agenttime'] = $agenttime;
}
if(isset($agentlevel)){
$arr['agentlevel'] = $agentlevel;
}
if(isset($agentblack)){
$arr['agentblack'] = $agentblack;
}
if(isset($fixagentid)){
$arr['fixagentid'] = $fixagentid;
}
if(isset($isauthor)){
$arr['isauthor'] = $isauthor;
}
if(isset($authorstatus)){
$arr['authorstatus'] = $authorstatus;
}
if(isset($authortime)){
$arr['authortime'] = $authortime;
}
if(isset($authorlevel)){
$arr['authorlevel'] = $authorlevel;
}
if(isset($authorblack)){
$arr['authorblack'] = $authorblack;
}
if(isset($ispartner)){
$arr['ispartner'] = $ispartner;
}
if(isset($partnerstatus)){
$arr['partnerstatus'] = $partnerstatus;
}
if(isset($partnertime)){
$arr['partnertime'] = $partnertime;
}
if(isset($partnerlevel)){
$arr['partnerlevel'] = $partnerlevel;
}
if(isset($partnerblack)){
$arr['partnerblack'] = $partnerblack;
}
if(isset($isaagent)){
$arr['isaagent'] = $isaagent;
}
if(isset($aagentstatus)){
$arr['aagentstatus'] = $aagentstatus;
}
if(isset($aagenttime)){
$arr['aagenttime'] = $aagenttime;
}
if(isset($aagentlevel)){
$arr['aagentlevel'] = $aagentlevel;
}
if(isset($aagenttype)){
$arr['aagenttype'] = $aagenttype;
}
if(isset($aagentprovinces)){
$arr['aagentprovinces'] = $aagentprovinces;
}
if(isset($aagentcitys)){
$arr['aagentcitys'] = $aagentcitys;
}
if(isset($aagentareas)){
$arr['aagentareas'] = $aagentareas;
}
if(isset($inviter)){
$arr['inviter'] = $inviter;
}
if(!empty($arr) && is_array($arr)){
pdo_update('ewei_shop_member', $arr, array('id'=>$b['id']));
}
pdo_update('ewei_shop_commission_apply', array('mid' => $b['id']), array('uniacid' => $_W['uniacid'], 'mid' => $a['id']));
pdo_update('ewei_shop_order',array('agentid'=>$b['id']),array('agentid'=>$a['id']));
pdo_update('ewei_shop_member',array('agentid'=>$b['id']),array('agentid'=>$a['id']));
$mergeinfo = ' 合并前用户: '.$a['nickname'].'('.$a['id'].') 合并后用户: '.$b['nickname'].'('.$b['id'].')';
if($a['credit1']>0){
m('member')->setCredit($b['openid'], 'credit1', abs($a['credit1']), '全网通会员数据合并增加积分 +' . $a['credit1']. $mergeinfo);
}
if($a['credit2']>0) {
m('member')->setCredit($b['openid'], 'credit2', abs($a['credit2']), '全网通会员数据合并增加余额 +' . $a['credit2']. $mergeinfo);
}
pdo_delete('ewei_shop_member', array('id' => $a['id'], 'uniacid' => $_W['uniacid']));
if(method_exists(m('member'),'memberRadisCountDelete')) {
m('member')->memberRadisCountDelete();
}
$tables = pdo_fetchall("SHOW TABLES like '%_ewei_shop_%'");
foreach ($tables as $k => $v) {
$v = array_values($v);
$tablename = str_replace($_W['config']['db']['tablepre'], '', $v[0]);
if (pdo_fieldexists($tablename, 'openid') && pdo_fieldexists($tablename, 'uniacid')) {
pdo_update($tablename, array('openid' => $b['openid']), array('uniacid' => $_W['uniacid'], 'openid' => $a['openid']));
}
if (pdo_fieldexists($tablename, 'openid') && pdo_fieldexists($tablename, 'acid')) {
pdo_update($tablename, array('openid' => $b['openid']), array('acid' => $_W['acid'], 'openid' => $a['openid']));
}
if (pdo_fieldexists($tablename, 'mid') && pdo_fieldexists($tablename, 'uniacid')) {
pdo_update($tablename, array('mid' => $b['id']), array('uniacid' => $_W['uniacid'], 'mid' => $a['id']));
}
}
$c = m('member')->getMember($b['openid']);
pdo_insert("ewei_shop_member_mergelog", array(
'uniacid'=>$_W['uniacid'],
'mergetime'=>time(),
'openid_a'=>$a['openid'],
'openid_b'=>$b['openid'],
'mid_a'=>$a['id'],
'mid_b'=>$b['id'],
'detail_a'=>iserializer($a),
'detail_b'=>iserializer($b),
'detail_c'=>iserializer($c)
));
return error(1);
}
/**
* 绑定送积分
* @param array $member
*/
public function sendCredit($member = array()) {
if(empty($member)){
return;
}
$data = m('common')->getPluginset('sale');
if(!empty($data['bindmobile']) && intval($data['bindmobilecredit'])>0){
m('member')->setCredit($member['openid'], 'credit1', abs($data['bindmobilecredit']), '绑定手机号送积分 +'. $data['bindmobilecredit']);
}
}
/**
* 数据迁移
* @param array $a
* @param array $b
* @return array
*/
public function mergeforuniacid($a=array(), $b=array()){
global $_W;
if(empty($a) || empty($b) || $a['id']==$b['id']){
return error(0, "params error");
}
if(!empty($b['mobileverify']))
{
return error(0, "params error");
}
$createtime = $a['createtime'] > $b['createtime'] ? $b['createtime'] : $a['createtime'];
$childtime = $a['childtime'] > $b['childtime'] ? $b['childtime'] : $a['childtime'];
$comparelevel = m('member')->compareLevel(array($a['level'], $b['level']));
$level = $comparelevel ? $b['level'] : $a['level'];
$isblack = !empty($a['isblack']) || !empty($b['isblack']) ? 1 : 0;
$openid_qq = !empty($b['openid_qq']) && empty($a['openid_qq']) ? $b['openid_qq'] : $a['openid_qq'];
$openid_wx = !empty($b['openid_wx']) && empty($a['openid_wx']) ? $b['openid_wx'] : $a['openid_wx'];
$openid_wa = !empty($b['openid_wa']) && empty($a['openid_wa']) ? $b['openid_wa'] : $a['openid_wa'];
if(!empty($a['isagent']) && empty($b['isagent'])){
$isagent = 1;
$agentid = $a['agentid'];
$status = !empty($a['status']) ? 1 : 0;
$agenttime = $a['agenttime'];
$agentlevel = $a['agentlevel'];
$agentblack = $a['agentblack'];
$fixagentid = $a['fixagentid'];
}
elseif(!empty($b['isagent']) && empty($a['isagent'])){
$isagent = 1;
$agentid = $b['agentid'];
$status = !empty($b['status']) ? 1 : 0;
$agenttime = $b['agenttime'];
$agentlevel = $b['agentlevel'];
$agentblack = $b['agentblack'];
$fixagentid = $b['fixagentid'];
}
elseif(!empty($b['isagent']) && !empty($a['isagent'])){
$compare = p('commission')->compareLevel(array($a['agentlevel'], $b['agentlevel']));
$isagent = 1;
if($compare){
$agentid = $b['agentid'];
if(empty($b['agentid']) && !empty($a['agentid'])){
$agentid = $a['agentid'];
}
$status = !empty($b['status']) ? 1 : 0;
$agentblack = !empty($b['agentblack']) ? 1 : 0;
$fixagentid = !empty($b['fixagentid']) ? 1 : 0;
}else{
$agentid = $a['agentid'];
if($a['agentid'] && !empty($b['agentid'])){
$agentid = $b['agentid'];
}
$status = !empty($a['status']) ? 1 : 0;
$agentblack = !empty($a['agentblack']) ? 1 : 0;
$fixagentid = !empty($a['fixagentid']) ? 1 : 0;
}
$agenttime = $compare ? $b['agenttime'] : $a['agenttime'];
$agentlevel = $compare ? $b['agentlevel'] : $a['agentlevel'];
}
$arr = array();
$arr['ishb'] = 1;
if(isset($createtime)){
$arr['createtime'] = $createtime;
}
if(isset($childtime)){
$arr['childtime'] = $childtime;
}
if(isset($level)){
$arr['level'] = $level;
}
if(isset($groupid)){
$arr['groupid'] = $groupid;
}
if(isset($isblack)){
$arr['isblack'] = $isblack;
}
if(isset($openid_qq)){
$arr['openid_qq'] = $openid_qq;
}
if(isset($openid_wx)){
$arr['openid_wx'] = $openid_wx;
}
if(isset($openid_wa)){
$arr['openid_wa'] = $openid_wa;
}
if(isset($status)){
$arr['status'] = $status;
}
if(isset($isagent)){
$arr['isagent'] = $isagent;
}
if(isset($agentid)){
$arr['agentid'] = $agentid;
}
if(isset($agenttime)){
$arr['agenttime'] = $agenttime;
}
if(isset($agentlevel)){
$arr['agentlevel'] = $agentlevel;
}
if(isset($agentblack)){
$arr['agentblack'] = $agentblack;
}
if(isset($fixagentid)){
$arr['fixagentid'] = $fixagentid;
}
if(!empty($arr) && is_array($arr)){
pdo_update('ewei_shop_member', $arr, array('id'=>$b['id']));
}
pdo_update('ewei_shop_commission_apply', array('mid' => $b['id']), array('mid' => $a['id']));
pdo_update('ewei_shop_order',array('agentid'=>$b['id']),array('agentid'=>$a['id']));
pdo_update('ewei_shop_member',array('agentid'=>$b['id']),array('agentid'=>$a['id']));
$mergeinfo = ' 合并前用户: '.$a['nickname'].'('.$a['id'].') 合并后用户: '.$b['nickname'].'('.$b['id'].')';
if($a['credit1']>0){
m('member')->setCredit($b['openid'], 'credit1', abs($a['credit1']), '数据迁移会员数据合并增加积分 +' . $a['credit1']. $mergeinfo);
}
if($a['credit2']>0) {
m('member')->setCredit($b['openid'], 'credit2', abs($a['credit2']), '数据迁移会员数据合并增加余额 +' . $a['credit2']. $mergeinfo);
}
$tables = pdo_fetchall("SHOW TABLES like '%_ewei_shop_%'");
foreach ($tables as $k => $v) {
$v = array_values($v);
$tablename = str_replace($_W['config']['db']['tablepre'], '', $v[0]);
if (pdo_fieldexists($tablename, 'openid') && pdo_fieldexists($tablename, 'uniacid')) {
if($tablename !='ewei_shop_member')
{
pdo_update($tablename, array('openid' => $b['openid']), array('uniacid' => $_W['uniacid'], 'openid' => $a['openid']));
}
}
if (pdo_fieldexists($tablename, 'openid') && pdo_fieldexists($tablename, 'acid')) {
pdo_update($tablename, array('openid' => $b['openid']), array('acid' => $_W['acid'], 'openid' => $a['openid']));
}
if (pdo_fieldexists($tablename, 'mid') && pdo_fieldexists($tablename, 'uniacid')) {
pdo_update($tablename, array('mid' => $b['id']), array('uniacid' => $_W['uniacid'], 'mid' => $a['id']));
}
}
$c = m('member')->getMember($b['openid']);
pdo_insert("ewei_shop_member_mergelog", array(
'uniacid'=>$_W['uniacid'],
'fromuniacid'=>$_W['uniacid'],
'mergetime'=>time(),
'openid_a'=>$a['openid'],
'openid_b'=>$b['openid'],
'mid_a'=>$a['id'],
'mid_b'=>$b['id'],
'detail_a'=>iserializer($a),
'detail_b'=>iserializer($b),
'detail_c'=>iserializer($c)
));
return error(1);
}
}

130
core/model/cache.php Normal file
View File

@ -0,0 +1,130 @@
<?php
/*
* 人人商城V2
*
* @author ewei 狸小狐 QQ:22185157
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
class Cache_EweiShopV2Model {
function get_key($key = '', $uniacid = '') {
global $_W;
static $APPID;
static $_uniacid;
$account_key = '';
$isme = $uniacid==$_W['uniacid'] || empty($uniacid);
if($isme){
$uniacid = $_W['uniacid'];
$account_key = $_W['account']['key'];
}
if (function_exists('redis')){
$redis = redis();
if(!is_error($redis)){
if (stripos($uniacid,'global') !== FALSE){
return "ewei_shopv2_syscache_{$_W['setting']['site']['key']}_global_{$key}";
}
if (empty($account_key)){
if($isme) {
if (is_null($APPID) || empty($APPID) || $_uniacid != $uniacid) {
$_uniacid = $uniacid;
$APPID = pdo_fetchcolumn('SELECT `key` FROM ' . tablename('account_wechats') . " WHERE uniacid=:uniacid", array(':uniacid' => $uniacid));
}
$account_key = $APPID;
} else{
$account_key = pdo_fetchcolumn('SELECT `key` FROM '.tablename('account_wechats')." WHERE uniacid=:uniacid",array(':uniacid'=>$uniacid));;
}
}
return "ewei_shopv2_syscache_{$_W['setting']['site']['key']}_{$uniacid}_{$account_key}_{$key}";
}
}
return EWEI_SHOPV2_PREFIX . md5($uniacid . '_new_' . $key );
}
function getArray($key = '', $uniacid = '') {
return $this->get($key, $uniacid);
}
function getString($key = '', $uniacid = '') {
return $this->get($key, $uniacid);
}
function get($key = '', $uniacid = '') {
global $_W;
if (function_exists('redis')){
$redis = redis();
if(!is_error($redis)){
$prefix = "__iserializer__format__::";
$value = $redis->get($this->get_key($key,$uniacid));
if(empty($value)){
return false;
}
if (stripos($value, $prefix) === 0) {
$ret = iunserializer(substr($value, strlen($prefix)));
foreach($ret as $k =>&$v){
if( is_serialized($v)){
$v = iunserializer($v);
}
if(is_array($v)){
foreach($v as $k1 =>&$v1){
if( is_serialized($v1)){
$v1 = iunserializer($v1);
}
}
unset($v1);
}
}
return $ret;
}
return $value;
}
}
return cache_read($this->get_key($key,$uniacid));
}
function set($key = '', $value = null, $uniacid = '') {
if (function_exists('redis')){
$redis = redis();
if(!is_error($redis)){
$prefix = "__iserializer__format__::";
if(is_array($value)){
foreach($value as $k =>&$v) {
if (is_serialized($v)) {
$v = iunserializer($v);
}
}
unset($v);
$value = $prefix. iserializer($value);
}
$redis->set($this->get_key($key,$uniacid), $value);
return;
}
}
cache_write($this->get_key($key,$uniacid),$value);
}
function del($key,$uniacid='') {
if (function_exists('redis')){
$redis = redis();
if(!is_error($redis)){
$redis->del($this->get_key($key,$uniacid));
return;
}
}
cache_delete($this->get_key($key,$uniacid));
}
}

1837
core/model/common.php Normal file

File diff suppressed because it is too large Load Diff

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