48 changed files with 30750 additions and 0 deletions
@ -0,0 +1,244 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
class CertifiedModuleUniapp extends Uniapp |
|||
{ |
|||
|
|||
public function initApplyCertified() |
|||
{ |
|||
global $_W , $_GPC; |
|||
|
|||
$validate = Member::validateMemberIdentity($_W['mid'],false); |
|||
if (!$validate['status']) $this->renderError($validate['msg']); |
|||
|
|||
$this->renderSuccess('成功'); |
|||
} |
|||
|
|||
/** |
|||
* 企业商户认证申请(商务合作) |
|||
* @return void |
|||
*/ |
|||
public function applyMerchantCertified() { |
|||
global $_W , $_GPC; |
|||
|
|||
$type = $_GPC['type'] ?: 'get'; // get 获取数据 | set 创建申请 |
|||
$storeid = $_GPC['storeid']; // 商户id |
|||
|
|||
# 验证是否有申请条件 |
|||
$validate = Member::validateMemberIdentity($_W['mid'],false); |
|||
if (!$validate['status']) $this->renderError($validate['msg']); |
|||
|
|||
$identity_id = pdo_getcolumn(PDO_NAME . 'member',['id' => $_W['mid']],'identity_id'); |
|||
if ($identity_id != 5) $this->renderError('非企业身份,禁止申请商户合作'); |
|||
|
|||
# 创建申请 |
|||
if ($type == 'set') { |
|||
$mobile = $_GPC['mobile']; // 手机号 |
|||
$position = $_GPC['position']; // 职务 |
|||
$name = $_GPC['name']; // 姓名 |
|||
$code = $_GPC['code']; // 短信验证码 |
|||
|
|||
if (empty($storeid) || !is_numeric($storeid)) $this->renderError('缺少商户id'); |
|||
if (empty($name)) $this->renderError('请输入姓名'); |
|||
if (empty($position)) $this->renderError('请输入职务'); |
|||
if (empty($mobile)) $this->renderError('请输入手机号'); |
|||
if (!preg_match("/^1[3-9]\d{9}$/",$mobile)) $this->renderError('请输入正确的手机号'); |
|||
|
|||
$nameRes = Filter::init($name,$_W['source'],1); |
|||
if ($nameRes['errno'] == 0) $this->renderError('姓名'.$nameRes['message']); |
|||
$positionRes = Filter::init($position,$_W['source'],1); |
|||
if ($positionRes['errno'] == 0) $this->renderError('职务'.$positionRes['message']); |
|||
|
|||
|
|||
$this->checkCode($mobile,$code); |
|||
|
|||
$queryRes = pdo_get(PDO_NAME . 'merchant_certified',['storeid'=>$storeid,'status' => [0,1]],'status'); |
|||
if ($queryRes) { |
|||
$this->renderError($queryRes['status'] == 1 ? '商务合作认证申请已通过,请勿重复申请' : '商户合作认证申请信息已提交,请勿重复申请'); |
|||
} |
|||
|
|||
$data = [ |
|||
'uniacid' => $_W['uniacid'], |
|||
'storeid' => $storeid, |
|||
'name' => trim($name), |
|||
'position' => trim($position), |
|||
'mobile' => $mobile, |
|||
'create_time' => time() |
|||
]; |
|||
|
|||
$insertRes = pdo_insert(PDO_NAME . 'merchant_certified',$data); |
|||
if (!$insertRes) $this->renderError('认证申请失败'); |
|||
$this->renderSuccess('已提交申请'); |
|||
} else { |
|||
if (empty($storeid)) $storeid = pdo_getcolumn(PDO_NAME . 'merchantuser',['mid' => $_W['mid']],'storeid'); |
|||
|
|||
$list = ['name' => '', 'position' => '', 'mobile' => '', 'remark' => '', 'status' => 0]; |
|||
# 获取上次审核数据 |
|||
$lastRes = pdo_getall(PDO_NAME . 'merchant_certified',['storeid' => $storeid],array_keys($list),'',' check_time desc',1); |
|||
foreach ($lastRes as $lastRow) { |
|||
$list = $lastRow; |
|||
} |
|||
|
|||
$list['reject'] = $list['remark']; |
|||
unset($list['remark']); |
|||
|
|||
$this->renderSuccess('数据返回成功',$list); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 教师认证申请 |
|||
* @return void |
|||
*/ |
|||
public function applyTeacherCertified() { |
|||
|
|||
global $_W , $_GPC; |
|||
|
|||
$type = $_GPC['type'] ?: 'get'; // get 获取上次申请数据 set 创建申请 |
|||
|
|||
$validate = Member::validateMemberIdentity($_W['mid']); |
|||
if (!$validate['status']) $this->renderError($validate['msg']); |
|||
|
|||
if ($type == 'set') { |
|||
$name = $_GPC['name']; // 姓名 |
|||
$mobile = $_GPC['mobile']; // 手机号 |
|||
$code = $_GPC['code']; // 短信验证码 |
|||
$school_name = $_GPC['school_name']; // 学校名称 |
|||
$faculty = $_GPC['faculty']; // 院系 |
|||
$documents = $_GPC['documents']; // 教师工作证件 |
|||
|
|||
if (empty($name)) $this->renderError('请输入姓名'); |
|||
if (empty($mobile)) $this->renderError('请输入手机号'); |
|||
if (!preg_match("/^1[3-9]\d{9}$/",$mobile)) $this->renderError('请输入正确的手机号'); |
|||
if (empty($school_name)) $this->renderError('请输入学校名称'); |
|||
if (empty($faculty)) $this->renderError('请输入院系'); |
|||
if (empty($documents)) $this->renderError('请上传教师工作证件'); |
|||
|
|||
|
|||
$nameRes = Filter::init($name,$_W['source'],1); |
|||
if ($nameRes['errno'] == 0) $this->renderError('姓名'.$nameRes['message']); |
|||
$school_nameRes = Filter::init($school_name,$_W['source'],1); |
|||
if ($school_nameRes['errno'] == 0) $this->renderError('学校名称'.$school_nameRes['message']); |
|||
$facultyRes = Filter::init($faculty,$_W['source'],1); |
|||
if ($facultyRes['errno'] == 0) $this->renderError('院系'.$facultyRes['message']); |
|||
$documentsRes = Filter::init($documents,$_W['source'],2); |
|||
if($documentsRes['errno'] == 0) $this->renderError('教师工作证件'.$documentsRes['message']); |
|||
|
|||
$this->checkCode($mobile,$code); |
|||
|
|||
$queryRes = pdo_get(PDO_NAME . 'member_teacher_certified',['mid'=>$_W['mid'],'status' => [0,1]],'status'); |
|||
if ($queryRes) { |
|||
$this->renderError($queryRes['status'] == 1 ? '教师认证申请已通过,请勿重复申请' : '教师认证申请信息已提交,请勿重复申请'); |
|||
} |
|||
|
|||
$data = [ |
|||
'uniacid' => $_W['uniacid'], |
|||
'mid' => $_W['mid'], |
|||
'name' => trim($name), |
|||
'mobile' => trim($mobile), |
|||
'school_name' => trim($school_name), |
|||
'faculty' => trim($faculty), |
|||
'documents' => trim($documents), |
|||
'create_time' => time() |
|||
]; |
|||
|
|||
$insertRes = pdo_insert(PDO_NAME . 'member_teacher_certified',$data); |
|||
if (!$insertRes) $this->renderError('认证申请失败'); |
|||
$this->renderSuccess('已提交申请'); |
|||
} else { |
|||
|
|||
$list = ['name' => '', 'mobile' => '', 'school_name' => '', 'faculty' => '', 'documents' => '', 'remark' => '', 'status' => 0]; |
|||
# 获取上次审核数据 |
|||
$lastRes = pdo_getall(PDO_NAME . 'member_teacher_certified',['mid' => $_W['mid']],array_keys($list),'',' certified_time desc',1); |
|||
foreach ($lastRes as $lastRow) { |
|||
$lastRow['documents'] = tomedia($lastRow['documents']); |
|||
$list = $lastRow; |
|||
} |
|||
$list['reject'] = $list['remark']; |
|||
unset($list['remark']); |
|||
|
|||
$this->renderSuccess('数据返回成功',$list); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 达人认证申请 |
|||
* @return void |
|||
*/ |
|||
public function applyBloggerCertified() { |
|||
|
|||
global $_W , $_GPC; |
|||
|
|||
$type = $_GPC['type'] ?: 'get'; // get 获取上次申请数据 set 创建申请 |
|||
|
|||
$validate = Member::validateMemberIdentity($_W['mid']); |
|||
if (!$validate['status']) $this->renderError($validate['msg']); |
|||
|
|||
if ($type == 'set') { |
|||
$name = $_GPC['name']; // 姓名/昵称 |
|||
$mobile = $_GPC['mobile']; // 联系电话 |
|||
$code = $_GPC['code']; // 短信验证码 |
|||
$screenshot = $_GPC['screenshot']; // 请上传其他平台粉丝截图 |
|||
|
|||
if (empty($name)) $this->renderError('请输入姓名'); |
|||
if (empty($mobile)) $this->renderError('请输入手机号'); |
|||
if (!preg_match("/^1[3-9]\d{9}$/",$mobile)) $this->renderError('请输入正确的手机号'); |
|||
if (empty($screenshot)) $this->renderError('请上传其他平台粉丝截图'); |
|||
|
|||
$nameRes = Filter::init($name,$_W['source'],1); |
|||
if ($nameRes['errno'] == 0) $this->renderError('姓名'.$nameRes['message']); |
|||
$screenshotRes = Filter::init($screenshot,$_W['source'],2); |
|||
if($screenshotRes['errno'] == 0) $this->renderError('其他平台粉丝截图'.$screenshotRes['message']); |
|||
|
|||
$this->checkCode($mobile,$code); |
|||
|
|||
$queryRes = pdo_get(PDO_NAME . 'member_daren_certified',['mid'=>$_W['mid'],'status' => [0,1]],'status'); |
|||
if ($queryRes) { |
|||
$this->renderError($queryRes['status'] == 1 ? '达人认证申请已通过,请勿重复申请' : '达人认证申请信息已提交,请勿重复申请'); |
|||
} |
|||
|
|||
$data = [ |
|||
'uniacid' => $_W['uniacid'], |
|||
'mid' => $_W['mid'], |
|||
'name' => trim($name), |
|||
'mobile' => $mobile, |
|||
'screenshot' => $screenshot, |
|||
'create_time' => time() |
|||
]; |
|||
|
|||
$insertRes = pdo_insert(PDO_NAME . 'member_daren_certified',$data); |
|||
if (!$insertRes) $this->renderError('认证申请失败'); |
|||
$this->renderSuccess('已提交申请'); |
|||
} else { |
|||
|
|||
$list = ['name' => '', 'mobile' => '', 'screenshot' => '', 'remark' => '', 'status' => 0]; |
|||
# 获取上次审核数据 |
|||
$lastRes = pdo_getall(PDO_NAME . 'member_daren_certified',['mid' => $_W['mid']],array_keys($list),'',' certified_time desc',1); |
|||
foreach ($lastRes as $lastRow) { |
|||
$lastRow['screenshot'] = tomedia($lastRow['screenshot']); |
|||
$list = $lastRow; |
|||
} |
|||
$list['reject'] = $list['remark']; |
|||
unset($list['remark']); |
|||
|
|||
$this->renderSuccess('数据返回成功',$list); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 短信验证码验证 |
|||
* @param $mobile |
|||
* @param $code |
|||
* @return void |
|||
*/ |
|||
private function checkCode($mobile,$code) { |
|||
$pin_info = pdo_get('wlmerchant_pincode' , ['mobile' => $mobile]); |
|||
if (empty($pin_info)) { |
|||
$this->renderError('验证码错误'); |
|||
} |
|||
if ($pin_info['time'] < time() - 300) { |
|||
$this->renderError('验证码已过期,请重新获取'); |
|||
} |
|||
if ($code != $pin_info['code']) $this->renderError('验证码错误'); |
|||
} |
|||
} |
|||
@ -0,0 +1,316 @@ |
|||
<?php |
|||
|
|||
defined('IN_IA') or exit('Access Denied'); |
|||
class CultivateClassModuleUniapp extends Uniapp |
|||
{ |
|||
/** |
|||
* 获取子页面全部自己分类 |
|||
*/ |
|||
public function getCultivateClassChildList() |
|||
{ |
|||
global $_W, $_GPC; |
|||
|
|||
$cc_id = $_GPC['cc_id']; |
|||
$storeid = $_GPC['storeid']; |
|||
|
|||
if (!empty($storeid)) { |
|||
$list = Category::getStoreCategoryAll($storeid, $cc_id); |
|||
} else { |
|||
$list = Category::getChildCategoryAll($cc_id, ['id', 'name']); |
|||
} |
|||
|
|||
$this->renderSuccess('数据返回成功', $list); |
|||
} |
|||
|
|||
/** |
|||
* 获取子级分类数据 |
|||
*/ |
|||
public function getCultivateClassInfo() |
|||
{ |
|||
global $_W, $_GPC; |
|||
|
|||
$cc_id = $_GPC['cc_id']; |
|||
|
|||
$list = Category::getSingleCategory($cc_id, ['id', 'name', 'advs']); |
|||
|
|||
if ($list['advs']) { |
|||
$list['advs'] = unserialize($list['advs']); |
|||
foreach ($list['advs'] as &$val) $val['thumb'] = tomedia($val['thumb']); |
|||
} |
|||
|
|||
$field = ['video_link', 'id', 'title', 'likeids', 'likenum', 'share','video_cover']; |
|||
$videoRes = Category::categoryVideoAll($list['id'], $field, true, $_W['mid']); |
|||
$list['video'] = $videoRes['list']; |
|||
|
|||
$this->renderSuccess('数据返回成功', $list); |
|||
} |
|||
|
|||
/** |
|||
* 获取招聘工作分类 |
|||
*/ |
|||
public function cultivateClassList() |
|||
{ |
|||
global $_GPC; |
|||
if ($_GPC['job_type']) { |
|||
$list = Category::getCategoryRecruit($_GPC['job_type']); |
|||
$this->renderSuccess('数据返回成功', $list); |
|||
} |
|||
$this->renderError('分类参数不存在'); |
|||
} |
|||
|
|||
/** |
|||
* 获取商品类型分类 |
|||
*/ |
|||
public function getStoreCategory() |
|||
{ |
|||
$list = Category::getStoreCategory(); |
|||
$this->renderSuccess('数据返回成功', $list); |
|||
} |
|||
|
|||
/** |
|||
* 获取商品类型子集分类 |
|||
*/ |
|||
public function getStoreCategoryChild() |
|||
{ |
|||
global $_W, $_GPC; |
|||
$cc_id = $_GPC['cc_id']; |
|||
if (empty($cc_id) || !is_numeric($cc_id)) $this->renderError('缺少分类id'); |
|||
$list = Category::getChildCategoryAll($cc_id, ['id', 'name']); |
|||
if ($list) $this->renderSuccess('数据返回成功', $list); |
|||
else $this->renderSuccess(2, '数据为空'); |
|||
} |
|||
|
|||
/** |
|||
* Comment: 分类视频点赞操作 |
|||
* Author: whj |
|||
* Date: 2023/6/30 10:12 |
|||
*/ |
|||
public function fabulous() |
|||
{ |
|||
global $_W, $_GPC; |
|||
#1、参数接收 |
|||
$id = $_GPC['id']; |
|||
if (empty($id) || !is_numeric($id)) $this->renderError('缺少参数:id');//视频id |
|||
#2、获取帖子的点赞信息 |
|||
$info = pdo_get(PDO_NAME . "cultivate_class_video", ['id' => $id], ['likeids', 'likenum']); |
|||
$ids = unserialize($info['likeids']); |
|||
$num = count($ids); |
|||
#3、判断是否为重复操作 |
|||
if (is_array($ids) && $num > 0) { |
|||
if (in_array($_W['mid'], $ids)) { |
|||
#4、取消点赞的操作 |
|||
$ids = array_flip($ids); |
|||
unset($ids[$_W['mid']]); |
|||
$ids = array_flip($ids); |
|||
$likenum = $info['likenum'] - 1; |
|||
} else { |
|||
$ids = array_values($ids);//初始化数组 重新生成键值 从0开始 |
|||
$ids[$num] = $_W['mid']; |
|||
$likenum = $info['likenum'] + 1; |
|||
} |
|||
} else { |
|||
$ids[$num] = $_W['mid']; |
|||
$likenum = $info['likenum'] + 1; |
|||
} |
|||
#5、点赞成功的操作 |
|||
$res = pdo_update(PDO_NAME . "cultivate_class_video", ['likeids' => serialize($ids), 'likenum' => $likenum], ['id' => $id]); |
|||
if ($res) $this->renderSuccess(); |
|||
$this->renderError(); |
|||
} |
|||
|
|||
/** |
|||
* Comment: 分享时记录分享数量 |
|||
* Author: zzw |
|||
* Date: 2023/6/30 10:30 |
|||
*/ |
|||
public function shareNum() |
|||
{ |
|||
global $_W, $_GPC; |
|||
#1、参数获取 |
|||
$id = $_GPC['id'] or $this->renderError('缺少参数:id'); |
|||
#2、获取当前分享数量 |
|||
$shareNum = pdo_getcolumn(PDO_NAME . "cultivate_class_video", ['id' => $id], 'share'); |
|||
$totalNum = intval($shareNum) + 1; |
|||
#2、修改分享数量 |
|||
pdo_update(PDO_NAME . "cultivate_class_video", ['share' => $totalNum], ['id' => $id]); |
|||
|
|||
$this->renderSuccess('记录成功'); |
|||
} |
|||
|
|||
/** |
|||
* Comment: 评论接口 |
|||
* Author: whj |
|||
* Date: 2023/6/30 10:30 |
|||
*/ |
|||
public function comment() |
|||
{ |
|||
global $_W,$_GPC; |
|||
//判断是否绑定手机 |
|||
$mastmobile = unserialize($_W['wlsetting']['userset']['plugin']); |
|||
if (empty($_W['wlmember']['mobile']) && in_array('private',$mastmobile)){ |
|||
$this->renderError('未绑定手机号'); |
|||
} |
|||
#1、参数接收 |
|||
$video_id = $_GPC['video_id'] OR $this->renderError('缺少参数:video_id') ;//视频id |
|||
$text = $_GPC['text'] OR $this->renderError('请输入评论内容!') ;//评论内容 |
|||
$pid = $_GPC['pid'] ?: 0;//父id |
|||
$oneid = $_GPC['oneid'] ?: 0;//第1级评论id |
|||
//判断文本内容是否非法 |
|||
$textRes = Filter::init($text,$_W['source'],1); |
|||
if ($textRes['errno'] == 0) $this->renderError($textRes['message']); |
|||
#2、判断用户是否为黑名单用户 |
|||
$this->checkBlack(); |
|||
#3、评论信息拼装 |
|||
$data['uniacid'] = $_W['uniacid']; |
|||
$data['aid'] = $_W['aid']; |
|||
$data['video_id'] = $video_id; |
|||
$data['content'] = base64_encode($text); |
|||
$data['mid'] = $_W['mid']; |
|||
$data['pid'] = $pid; |
|||
$data['oneid'] = $oneid; |
|||
$data['createtime'] = time(); |
|||
//判断是否需要审核 |
|||
$settings = Setting::wlsetting_read('comment_set'); |
|||
if($settings['videoComment'] == 1) $data['status'] = 1; |
|||
#4、保存评论内容 |
|||
$res = pdo_insert(PDO_NAME."cultivate_class_comment",$data); |
|||
if($res){ |
|||
$cid = pdo_insertid(); |
|||
# 回复帖子消息推送 |
|||
if (!empty($pid)) { |
|||
$parentRes = pdo_get(PDO_NAME .'cultivate_class_comment',['id' => $pid],'mid'); |
|||
Category::setReplyModelInfo($video_id,$cid,$_W['mid'],$parentRes['mid']); |
|||
} |
|||
$this->renderSuccess('评论成功',['cid' => $cid,'amid' => $data['mid']]); |
|||
} else { |
|||
$this->renderError('评论失败,请稍后重试'); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* Comment: 编辑或删除评论信息 |
|||
* Author: wlf |
|||
* Date: 2022/02/09 11:25 |
|||
*/ |
|||
public function changeComment(){ |
|||
global $_W,$_GPC; |
|||
$this->checkBlack(); |
|||
$id = $_GPC['id'] OR $this->renderError('缺少参数:id');//评论id |
|||
$type = $_GPC['type'] ? : 0; // 1修改 0删除 |
|||
if($type > 0){ |
|||
$text = $_GPC['text'] OR $this->renderError('请输入修改内容!');//评论内容 |
|||
//判断文本内容是否非法 |
|||
$textRes = Filter::init($text,$_W['source'],1); |
|||
if($textRes['errno'] == 0){ |
|||
$this->renderError($textRes['message']); |
|||
} |
|||
$data['content'] = base64_encode($text); |
|||
//判断是否需要审核 |
|||
$set = Setting::agentsetting_read('pocket');// <-- replace --> // |
|||
if($set['comment_reply'] == 1) $data['status'] = 0; |
|||
$res = pdo_update(PDO_NAME .'cultivate_class_comment',$data,['id' => $id]); |
|||
|
|||
}else{ |
|||
$res = $this->treeDeleteComment($id); |
|||
} |
|||
if($res > 0){ |
|||
$this->renderSuccess('操作成功'); |
|||
}else{ |
|||
$this->renderError('操作失败,请稍后重试'); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 递归删除评论 |
|||
* @param $id |
|||
* @return false|mixed |
|||
*/ |
|||
protected function treeDeleteComment($id) |
|||
{ |
|||
global $_W; |
|||
if (empty($id)) return false; |
|||
$arr = pdo_getall(PDO_NAME . 'cultivate_class_comment' , ['uniacid' => $_W['uniacid'] , 'pid' => $id]); |
|||
if (empty($arr)) return pdo_delete(PDO_NAME . 'cultivate_class_comment' , ['uniacid' => $_W['uniacid'] , 'id' => $id]); |
|||
foreach ($arr as $key => $value) { |
|||
if (!$this->treeDeleteComment($value['id'])) return false; |
|||
} |
|||
return pdo_delete(PDO_NAME . 'cultivate_class_comment' , ['uniacid' => $_W['uniacid'] , 'id' => $id]); |
|||
} |
|||
|
|||
/** |
|||
* Comment: 判断用户是否被加入黑名单 |
|||
* Author: wlf |
|||
* Date: 2020/06/28 16:28 |
|||
*/ |
|||
public function checkBlack(){ |
|||
global $_W; |
|||
$flag = pdo_getcolumn(PDO_NAME.'pocket_blacklist',array('uniacid'=>$_W['uniacid'],'mid'=>$_W['mid'],'aid'=>$_W['aid']),'id'); |
|||
if(!empty($flag)){ |
|||
$tips = $_W['wlsetting']['userset']['black_desc'] ? : '您被禁止评论,请联系客服'; |
|||
$this->renderError($tips); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 获取视频评论 |
|||
* @return void |
|||
*/ |
|||
public function getVideoComment() |
|||
{ |
|||
global $_W,$_GPC; |
|||
|
|||
$mid = $_W['mid']; |
|||
$oneid = $_GPC['oneid'] ?: 0; |
|||
$pindex = $_GPC['pindex'] ?: 1; |
|||
$psize = $_GPC['psize'] ?: 10; |
|||
$video_id = $_GPC['video_id']; |
|||
if (empty($video_id) || !is_numeric($video_id)) $this->renderError('缺少参数:video_id'); |
|||
|
|||
// 第一级评论 |
|||
$commentWhere = ['aid' => $_W['aid'],'video_id' => $video_id,'oneid' => $oneid, 'status' => 1]; |
|||
|
|||
$commentData = Category::getVideoComment($commentWhere,$mid,$pindex,$psize); |
|||
$list = $commentData['list']; |
|||
$total = $commentData['total']; |
|||
$this->renderSuccess('数据返回成功',['list' => $list,'total' => $total]); |
|||
} |
|||
|
|||
/** |
|||
* Comment: 分类视频点赞操作 |
|||
* Author: whj |
|||
* Date: 2023/6/30 10:12 |
|||
*/ |
|||
public function commentFabulous() |
|||
{ |
|||
global $_W, $_GPC; |
|||
#1、参数接收 |
|||
$id = $_GPC['id']; |
|||
if (empty($id) || !is_numeric($id)) $this->renderError('缺少参数:id');//视频id |
|||
#2、获取帖子的点赞信息 |
|||
$info = pdo_get(PDO_NAME . "cultivate_class_comment", ['id' => $id], ['likeids', 'likenum']); |
|||
$ids = unserialize($info['likeids']); |
|||
$num = count($ids); |
|||
#3、判断是否为重复操作 |
|||
if (is_array($ids) && $num > 0) { |
|||
if (in_array($_W['mid'], $ids)) { |
|||
#4、取消点赞的操作 |
|||
$ids = array_flip($ids); |
|||
unset($ids[$_W['mid']]); |
|||
$ids = array_flip($ids); |
|||
$likenum = $info['likenum'] - 1; |
|||
} else { |
|||
$ids = array_values($ids);//初始化数组 重新生成键值 从0开始 |
|||
$ids[$num] = $_W['mid']; |
|||
$likenum = $info['likenum'] + 1; |
|||
} |
|||
} else { |
|||
$ids[$num] = $_W['mid']; |
|||
$likenum = $info['likenum'] + 1; |
|||
} |
|||
#5、点赞成功的操作 |
|||
$res = pdo_update(PDO_NAME . "cultivate_class_comment", ['likeids' => serialize($ids), 'likenum' => $likenum], ['id' => $id]); |
|||
if ($res) $this->renderSuccess(); |
|||
$this->renderError(); |
|||
} |
|||
} |
|||
@ -0,0 +1,711 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class GoodsModuleUniapp extends Uniapp { |
|||
/** |
|||
* Comment: 获取商品详细信息 |
|||
* Author: zzw |
|||
* Date: 2019/8/13 18:34 |
|||
*/ |
|||
public function getGoodsDetail(){ |
|||
global $_W,$_GPC; |
|||
#1、参数获取 |
|||
$id = $_GPC['id'];//商品id |
|||
$type = $_GPC['type'];//商品类型:1=抢购 2=团购 3=拼团 4=大礼包 5=优惠券 6=折扣卡 7=砍价商品 8=积分商品 9活动 |
|||
$mid = $_W['mid'] ? : 0;//用户id |
|||
if(empty($id)) $this->renderError('缺少参数:商品id'); |
|||
if(empty($type)) $this->renderError('缺少参数:商品类型'); |
|||
#2、调用方法获取公共商品数据信息 |
|||
WeliamWeChat::browseRecord($type, $id);//记录当前商品的浏览记录 |
|||
$info = WeliamWeChat::getHomeGoods($type, $id); |
|||
if(empty($info['id'])){ |
|||
$this->renderError('商品不存在或已被删除',['url'=>h5_url('pages/mainPages/index/index')]); |
|||
} |
|||
#unset($info['address']); |
|||
#unset($info['storename']); |
|||
#3、获取商品补充数据信息 |
|||
switch ($type) { |
|||
case 1: |
|||
$tableName = "rush_activity"; |
|||
$table = tablename(PDO_NAME."rush_activity"); |
|||
$field = 'paidid,drawid,thumbs,detail,`describe`,pv,creditmoney,threestatus,pftotherinfo,alldaylimit,daylimit,monthlimit,usedatestatus,week,day,tag,isdistri,retainage,share_title,share_image,share_desc,lp_status,lp_set,unit,is_describe_tip,bgmusic,videourl'; |
|||
$commentPlugin = 'rush'; |
|||
$saletype = 1; |
|||
break;//抢购商品 |
|||
case 2: |
|||
$tableName = "groupon_activity"; |
|||
$table = tablename(PDO_NAME."groupon_activity"); |
|||
$field = 'paidid,drawid,thumbs,detail,`describe`,pv,creditmoney,threestatus,pftotherinfo,alldaylimit,daylimit,usedatestatus,week,day,tag,isdistri,retainage,share_title,share_image,share_desc,unit,is_describe_tip,bgmusic,videourl'; |
|||
$commentPlugin = 'groupon'; |
|||
$saletype = 2; |
|||
break;//团购商品 |
|||
case 3: |
|||
$tableName = "fightgroup_goods"; |
|||
$table = tablename(PDO_NAME."fightgroup_goods"); |
|||
$field = 'paidid,drawid,adv as thumbs,detail,pv,alldaylimit,creditmoney,daylimit,usedatestatus,week,day,tag,aloneprice,limitstarttime as starttime,limitendtime as endtime,isdistri,share_title,share_image,share_desc,`describe`,unit,is_describe_tip,bgmusic,videourl'; |
|||
$commentPlugin = 'wlfightgroup'; |
|||
$saletype = 3; |
|||
break;//拼团商品 |
|||
case 4: |
|||
$tableName = "package"; |
|||
$table = tablename(PDO_NAME."package"); |
|||
$field = '`describe`,pv,usedatestatus,week,day'; |
|||
$commentPlugin = 'package'; |
|||
$saletype = 0; |
|||
break;//大礼包 |
|||
case 5: |
|||
$tableName = "couponlist"; |
|||
$table = tablename(PDO_NAME."couponlist"); |
|||
$field = 'paidid,drawid,goodsdetail as detail,description as `describe`,pv,creditmoney,alldaylimit,daylimit,usedatestatus,week,day,is_charge,isdistri,starttime,is_describe_tip,endtime,time_type,adv as thumbs'; |
|||
$commentPlugin = 'coupon'; |
|||
$saletype = 4; |
|||
break;//优惠券 |
|||
case 6: |
|||
$tableName = "halfcardlist"; |
|||
$table = tablename(PDO_NAME."halfcardlist"); |
|||
$field = 'detail,`limit` as `describe`,pv'; |
|||
$commentPlugin = 'halfcard'; |
|||
$saletype = 0; |
|||
break;//折扣卡 |
|||
case 7: |
|||
$tableName = "bargain_activity"; |
|||
$table = tablename(PDO_NAME."bargain_activity"); |
|||
$field = 'paidid,drawid,thumbs,`describe`,detail,pv,creditmoney,usedatestatus,week,day,isdistri,share_title,share_image,share_desc,unit,is_describe_tip,bgmusic,videourl'; |
|||
$commentPlugin = 'bargain'; |
|||
$info['vipprice'] = $info['price'] - $info['discount_price']; |
|||
$saletype = 5; |
|||
break;//砍价商品 |
|||
case 8: |
|||
$tableName = "consumption_goods"; |
|||
$table = tablename(PDO_NAME."consumption_goods"); |
|||
$field = 'usedatestatus,week,day,chance'; |
|||
$commentPlugin = 'consumption'; |
|||
$info['logo'] = $info['thumb']; |
|||
$saletype = 0; |
|||
break;//积分商品 |
|||
} |
|||
if(!empty($field)) { |
|||
$where = " WHERE uniacid = {$_W['uniacid']} AND id = {$id}"; |
|||
$goods = pdo_fetch("SELECT {$field} FROM " . $table . $where); |
|||
$info = array_merge($info , $goods); |
|||
//修改商品人气(浏览量)信息 |
|||
$pv = intval($info['pv']) + 1; |
|||
pdo_update(PDO_NAME.$tableName,['pv'=>$pv],['id'=>$id]); |
|||
} |
|||
#4、处理商品数据信息 |
|||
//分享信息的处理 |
|||
$info['share_title'] = $info['share_title'] ? : $info['goods_name']; |
|||
$info['share_image'] = tomedia($info['share_image']) ? : $info['logo']; |
|||
$info['share_desc'] = $info['share_desc'] ? : ''; |
|||
//处理轮播图信息 |
|||
$info['thumbs'] = is_array(unserialize($info['thumbs'])) ? unserialize($info['thumbs']) : []; |
|||
if(is_array($info['thumbs']) && count($info['thumbs']) > 0){ |
|||
foreach ($info['thumbs'] as $thumbKey => &$thumbVal) { |
|||
$thumbVal = tomedia($thumbVal); |
|||
} |
|||
} |
|||
//视频信息 |
|||
if(!empty($info['videourl'])){ |
|||
$info['videourl'] = tomedia($info['videourl']); |
|||
} |
|||
//处理商品标签信息 |
|||
if($info['tag']){ |
|||
$tag = unserialize($info['tag']); |
|||
if(is_array($tag) && count($tag) > 0){ |
|||
if(count($tag) > 1){ |
|||
$tagIds = implode(',',$tag); |
|||
$tagWhere = " WHERE id IN ({$tagIds}) "; |
|||
}else{ |
|||
$tagWhere = " WHERE id = {$tag[0]} "; |
|||
} |
|||
$tagList = pdo_fetchall("SELECT title,content FROM ".tablename(PDO_NAME."tags").$tagWhere); |
|||
if(is_array($tagList) && count($tagList) > 0){ |
|||
$info['tag_list'] = array_column($tagList,'title'); |
|||
$info['tagslist'] = $tagList; |
|||
} |
|||
} |
|||
unset($info['tag']); |
|||
} |
|||
if($info['appointstatus']>0){ |
|||
$stagt = '需提前预约'; |
|||
$info['tag_list'][] = $stagt; |
|||
if($info['appointment'] > 0){ |
|||
$info['tagslist'][] = array( 'title'=> $stagt,'content'=> '消费本商品请至少提前'.$info['appointment'].'小时联系商家预约'); |
|||
}else{ |
|||
$info['tagslist'][] = array( 'title'=> $stagt,'content'=> '消费本商品请提前联系商家预约'); |
|||
} |
|||
} |
|||
if($info['allowapplyre']>0){ |
|||
$stagt = '不退款商品'; |
|||
$info['tag_list'][] = $stagt; |
|||
$info['tagslist'][] = array( 'title'=> $stagt,'content'=> '本商品是特殊商品,不支持购买后退款操作'); |
|||
} |
|||
if($info['creditmoney']>0){ |
|||
$jifen = $_W['wlsetting']['trade']['credittext'] ? : '积分'; |
|||
$stagt = $jifen.'抵扣'; |
|||
$info['tag_list'][] = $stagt; |
|||
$info['tagslist'][] = array('title'=> $stagt,'content'=> '每份商品最多可以使用'.$jifen.'抵扣'.$info['creditmoney'].'元'); |
|||
} |
|||
if($info['drawid'] > 0){ |
|||
$draw = pdo_get('wlmerchant_luckydraw',array('id' => $info['drawid'],'status' => 1),array('title','status')); |
|||
if(!empty($draw)){ |
|||
$info['tag_list'][] = '抽奖活动'; |
|||
$info['tagslist'][] = array('title'=> '抽奖活动','content'=> '购买商品核销或收货以后可以参与【'.$draw['title'].'】抽奖活动'); |
|||
} |
|||
} |
|||
if($info['paidid'] > 0){ |
|||
$paid = pdo_get('wlmerchant_payactive',array('id' => $info['paidid'],'status' => 1),array('title')); |
|||
if(!empty($paid)){ |
|||
$info['tag_list'][] = '支付有礼'; |
|||
$info['tagslist'][] = array('title'=> '支付有礼','content'=> '购买商品支付以后可以参与【'.$paid['title'].'】活动奖励'); |
|||
} |
|||
} |
|||
//处理商品详情/购买须知 |
|||
if(!empty($info['detail']) && is_base64($info['detail'])) $info['detail'] = htmlspecialchars_decode(base64_decode($info['detail'])); |
|||
else if(!empty($info['detail'])) $info['detail'] = htmlspecialchars_decode($info['detail']); |
|||
|
|||
if(!empty($info['describe']) && is_base64($info['describe'])) $info['describe'] = htmlspecialchars_decode(base64_decode($info['describe'])); |
|||
else if(!empty($info['describe'])) $info['describe'] = htmlspecialchars_decode($info['describe']); |
|||
//处理音乐信息 |
|||
if($info['bgmusic']) $info['bgmusic'] = tomedia($info['bgmusic']); |
|||
#5、获取商户信息 |
|||
if($info['sid'] > 0){ |
|||
$shop = pdo_fetch("SELECT id as sid,logo,address,mobile,storename,storehours,location FROM ". |
|||
tablename(PDO_NAME."merchantdata")." WHERE id = {$info['sid']} "); |
|||
$shop['logo'] = tomedia($shop['logo']); |
|||
$storehours = unserialize($shop['storehours']); |
|||
$shop['storehours'] = $storehours['startTime'].' - '.$storehours['endTime']; |
|||
if(!empty($storehours['startTime'])){ |
|||
$shop['storehours'] = $storehours['startTime'] . ' - ' . $storehours['endTime']; |
|||
}else{ |
|||
$shop['storehours'] = ''; |
|||
foreach($storehours as $hk => $hour){ |
|||
if($hk > 0){ |
|||
$shop['storehours'] .= ','.$hour['startTime'] . ' - ' . $hour['endTime']; |
|||
}else{ |
|||
$shop['storehours'] .= $hour['startTime'] . ' - ' . $hour['endTime']; |
|||
} |
|||
} |
|||
} |
|||
$shop['location'] = unserialize($shop['location']); |
|||
$info['shop'] = $shop; |
|||
}else{ |
|||
$info['sid'] = 0; |
|||
} |
|||
//认证 |
|||
if(p('attestation')){ |
|||
$info['attestation'] = Attestation::checkAttestation(2,$info['sid']); |
|||
}else{ |
|||
$info['attestation'] = 0; |
|||
} |
|||
#6、获取商品评价信息 |
|||
$comment = pdo_fetchall("SELECT headimg,nickname,createtime,star,pic,text,replytextone,replypicone FROM ".tablename(PDO_NAME.'comment')."WHERE gid = {$id} AND plugin = '{$commentPlugin}' AND status = 1 AND (checkone = 2 OR mid = {$mid}) ORDER BY createtime DESC LIMIT 5 "); |
|||
//处理评论信息 |
|||
foreach($comment as $commentKey => &$commentVal){ |
|||
//用户评论图片的处理 |
|||
$commentPic = unserialize($commentVal['pic']); |
|||
if(is_array($commentPic) && count($commentPic) > 0){ |
|||
foreach($commentPic as $picKey => &$picVal){ |
|||
if($picVal) $picVal = tomedia($picVal); |
|||
else unset($commentPic[$picKey]); |
|||
} |
|||
}else{ |
|||
$commentPic = []; |
|||
} |
|||
$commentVal['pic'] = array_values($commentPic); |
|||
//商家回复信息图片的处理 |
|||
$replyPic = unserialize($commentVal['replypicone']); |
|||
if(is_array($replyPic) && count($replyPic) > 0){ |
|||
foreach($replyPic as $replyPicKey => &$replyPicVal){ |
|||
$replyPicVal = tomedia($replyPicVal); |
|||
} |
|||
}else{ |
|||
$replyPic = []; |
|||
} |
|||
$commentVal['replypicone'] = array_values($replyPic); |
|||
} |
|||
$info['comment'] = $comment; |
|||
#7、获取拼团商品详情时 获取拼团已开团但未成团的信息列表 |
|||
if($type == 3){ |
|||
$info['group_list'] = pdo_fetchall("SELECT a.id,a.failtime,a.neednum,a.lacknum,m.nickname,m.avatar FROM " .tablename(PDO_NAME."fightgroup_group") |
|||
." as a RIGHT JOIN " .tablename(PDO_NAME."order") |
|||
." as b ON a.id = b.fightgroupid RIGHT JOIN ".tablename(PDO_NAME."member") |
|||
." as m ON b.mid = m.id " |
|||
." WHERE a.goodsid = {$id} AND a.uniacid = {$_W['uniacid']} AND a.status = 1 " |
|||
." GROUP BY b.fightgroupid ORDER BY a.starttime ASC LIMIT 5 "); |
|||
} |
|||
#8、分销助手,获取当前用户分享最高可以获得的佣金 |
|||
if(empty($info['isdistri'])){ |
|||
$info['dis_assistant'] = WeliamWeChat::getDisInfo($type,$id); |
|||
}else{ |
|||
$info['dis_assistant'] = []; |
|||
} |
|||
#10、社群信息获取 |
|||
if ($info['communityid'] > 0) { |
|||
$community = Commons::getCommunity($info['communityid']); |
|||
$info['community'] = is_array($community) ? $community : []; |
|||
} |
|||
#11、判断用户是否已经参与砍价 |
|||
if($type == 7){ |
|||
$info['is_participate'] = pdo_getcolumn(PDO_NAME."bargain_userlist" |
|||
,['activityid'=>$id,'mid'=>$_W['mid']] ,'id'); |
|||
} |
|||
#12、判断当前商品的状态:1=未开始,2=已开始,3=已结束 |
|||
if(in_array($type,[1,2,3,5,7])){ |
|||
//基本判断 |
|||
if($info['starttime'] > time()){ |
|||
//开始时间大于当前时间 未开始 |
|||
$info['sales_status'] = 1; |
|||
}else if($info['endtime'] > time()){ |
|||
//结束时间大于当前时间 已开始未结束 |
|||
$info['sales_status'] = 2; |
|||
}else if($info['endtime'] < time()){ |
|||
//结束时间小于当前时间 已结束 |
|||
$info['sales_status'] = 3; |
|||
} |
|||
//卡券补丁判断 时间段为领取后限制则固定为 已开始未结束 |
|||
if($type == 5 && $info['time_type'] == 2){ |
|||
$info['sales_status'] = 2; |
|||
} |
|||
if($info['usedatestatus'] > 0 ){ |
|||
$stagt = '定时发售'; |
|||
if($info['usedatestatus'] == 1){ |
|||
$content = '此商品每周'; |
|||
$week = unserialize($info['week']); |
|||
foreach($week as $key => $we){ |
|||
switch ($we){ |
|||
case '1': |
|||
$content .= '星期一'; |
|||
break; |
|||
case '2': |
|||
if($key == 0){ |
|||
$content .= '星期二'; |
|||
}else{ |
|||
$content .= ',星期二'; |
|||
} |
|||
break; |
|||
case '3': |
|||
if($key == 0){ |
|||
$content .= '星期三'; |
|||
}else{ |
|||
$content .= ',星期三'; |
|||
} |
|||
break; |
|||
case '4': |
|||
if($key == 0){ |
|||
$content .= '星期四'; |
|||
}else{ |
|||
$content .= ',星期四'; |
|||
} |
|||
break; |
|||
case '5': |
|||
if($key == 0){ |
|||
$content .= '星期五'; |
|||
}else{ |
|||
$content .= ',星期五'; |
|||
} |
|||
break; |
|||
case '6': |
|||
if($key == 0){ |
|||
$content .= '星期六'; |
|||
}else{ |
|||
$content .= ',星期六'; |
|||
} |
|||
break; |
|||
case '7': |
|||
if($key == 0){ |
|||
$content .= '星期天'; |
|||
}else{ |
|||
$content .= ',星期天'; |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
}else{ |
|||
$content = '此商品每月'; |
|||
$day = unserialize($info['day']); |
|||
foreach($day as $key => $dd){ |
|||
if($key == 0){ |
|||
$content .= $dd.'号'; |
|||
}else{ |
|||
$content .= ','.$dd.'号'; |
|||
} |
|||
} |
|||
} |
|||
$content .= '开放购买'; |
|||
$info['tag_list'][] = $stagt; |
|||
$info['tagslist'][] = array( 'title'=> $stagt,'content'=> $content); |
|||
if($info['sales_status'] == 2){ |
|||
$check = WeliamWeChat::checkUseDateStatus($info['usedatestatus'],$info['week'],$info['day']); |
|||
if(empty($check)){ |
|||
$info['sales_status'] = 3; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
$supar = []; |
|||
$supar[] = $info['stk']; |
|||
#6、判断用户购买限制 |
|||
//亿企达数量处理 |
|||
if($info['threestatus'] == 1){ |
|||
$pftotherinfo = unserialize($info['pftotherinfo']); |
|||
if($pftotherinfo['limitCountMax'] > 0){ |
|||
$supar[] = $pftotherinfo['limitCountMax']; |
|||
} |
|||
} |
|||
if ($info['buy_limit'] > 0 && $saletype > 0) { |
|||
$userBuyNum = WeliamWeChat::getSalesNum($saletype,$id,0,1,$_W['mid']); |
|||
$supar[] = $info['buy_limit'] - intval($userBuyNum);//当前用户还能购买的数量 |
|||
} |
|||
//每日限量 |
|||
if($info['daylimit']>0 || $info['alldaylimit']>0){ |
|||
$stagt = '每日限量'; |
|||
$info['tag_list'][] = $stagt; |
|||
$daylimittips = '此商品'; |
|||
if($info['alldaylimit']>0){ |
|||
$daylimittips .= '每天限量供应'.$info['alldaylimit'].'份.'; |
|||
} |
|||
if($info['daylimit']>0){ |
|||
$daylimittips .= '每天每人只能购买'.$info['daylimit'].'份.'; |
|||
} |
|||
$info['tagslist'][] = array( 'title'=> $stagt,'content'=> $daylimittips); |
|||
if($info['sales_status'] == 2){ |
|||
$today = strtotime(date('Y-m-d')); |
|||
if($info['alldaylimit']>0 ){ |
|||
$daysalenum = WeliamWeChat::getSalesNum($saletype,$id,0,1,0,$today); |
|||
$sup = $info['alldaylimit'] - intval($daysalenum); |
|||
$supar[] = $sup; |
|||
if($daysalenum >= $info['alldaylimit']){ |
|||
$info['sales_status'] = 4; |
|||
} |
|||
$info['todayselenum'] = $daysalenum; |
|||
} |
|||
if($info['daylimit']>0 && $_W['mid'] > 0 ){ |
|||
$daysalenum = WeliamWeChat::getSalesNum($saletype,$id,0,1,$_W['mid'],$today); |
|||
$sup = $info['daylimit'] - intval($daysalenum); |
|||
$supar[] = $sup; |
|||
if($daysalenum >= $info['daylimit']){ |
|||
$info['sales_status'] = 4; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
//每月限量 |
|||
if($info['monthlimit']>0 && $_W['mid'] > 0){ |
|||
$stagt = '每月限量'; |
|||
$info['tag_list'][] = $stagt; |
|||
$monthlimittips = '此商品每月每人只能购买'.$info['monthlimit'].'份.'; |
|||
$info['tagslist'][] = array( 'title'=> $stagt,'content'=> $monthlimittips); |
|||
if($info['sales_status'] == 2) { |
|||
$tomonth = strtotime(date('Y-m')); |
|||
$monthsalenum = WeliamWeChat::getSalesNum($saletype,$id,0,1,$_W['mid'],$tomonth); |
|||
$sup = $info['monthlimit'] - intval($monthsalenum); |
|||
$supar[] = $sup; |
|||
if($monthsalenum >= $info['monthlimit']){ |
|||
$info['sales_status'] = 4; |
|||
} |
|||
} |
|||
} |
|||
|
|||
//积分商品判断 |
|||
if($type == 8){ |
|||
$supar = []; |
|||
if ($info['chance'] > 0) { |
|||
$times = pdo_fetchcolumn('SELECT SUM(num) FROM ' . tablename('wlmerchant_consumption_record') . " WHERE uniacid = {$_W['uniacid']} AND goodsid = {$id} AND mid = {$_W['mid']} "); |
|||
$sup = $info['chance'] - $times; |
|||
$supar[] = $sup; |
|||
} |
|||
//判断库存 |
|||
$cctotal = pdo_fetchcolumn("SELECT SUM(num) FROM " . tablename(PDO_NAME . "order") . " WHERE plugin = 'consumption' AND fkid = {$id} AND status != 5 AND status != 7"); |
|||
$sup = $info['stock'] - $cctotal; |
|||
$supar[] = $sup; |
|||
} |
|||
$info['user_limit_num'] = min($supar); |
|||
if($info['user_limit_num'] < 0){ |
|||
$info['user_limit_num'] = 0; |
|||
} |
|||
//尾款 |
|||
if($info['retainage'] > 0){ |
|||
$stagt = '核销付尾款'; |
|||
$info['tag_list'][] = $stagt; |
|||
$info['tagslist'][] = array( 'title'=> $stagt,'content'=> '此商品使用时必须再向商户支付尾款:'.$info['retainage'].'元'); |
|||
} |
|||
#13、是否开启一卡通 |
|||
if($_W['wlsetting']['halfcard']['status'] > 0 && $info['vipstatus'] > 0){ |
|||
$info['is_open_vip'] = 1; |
|||
}else{ |
|||
$info['is_open_vip'] = 0; |
|||
} |
|||
#14、获取当前商品的浏览记录 |
|||
$browseRecord = array_column(WeliamWeChat::getBrowseRecord($type,$id), 'avatar'); |
|||
$info['user_list'] = is_array($browseRecord) ? $browseRecord :[]; |
|||
#15、判断是否开启阶梯价(目前仅抢购存在) 是否开启阶梯价(0=关闭 1=开启) |
|||
if($type == 1){ |
|||
if($info['lp_status'] == 1){ |
|||
$info['lp_set'] = is_array(unserialize($info['lp_set'])) ? unserialize($info['lp_set']) :[]; |
|||
if(count($info['lp_set']) > 0){ |
|||
$updateStatus = 0; |
|||
$nowStatus = 0; |
|||
$newArr = []; |
|||
$buyNum = $info['buy_num']; |
|||
$allsalenum = intval($info['allsalenum']); |
|||
foreach ($info['lp_set'] as $lpKey => &$lpVal){ |
|||
$lpVal['max'] = intval($lpVal['max']) + $allsalenum; |
|||
//修改当前商品价格、会员价格、会员优惠 |
|||
if($info['buy_num'] < $lpVal['max'] && $updateStatus == 0){ |
|||
$info['price'] = $lpVal['price']; |
|||
//$info['vipprice'] = $lpVal['vip_price']; |
|||
//$info['discount_price'] = sprintf("%.2f", ($lpVal['price'] - $lpVal['vip_price'])); |
|||
$updateStatus = 1; |
|||
} |
|||
//获取最小值 第一个的最小值为0 之后的最小值为前一个区间上限 +1 |
|||
$thisMin = intval($lpKey == 0 ? 0 : ($info['lp_set'][$lpKey - 1]['max'])) + 1; |
|||
//获取当前区间总共的可销售数量 第一个的可销售总数为其最大区间 之后的可销售总数为当前区间上限 - 前一个区间的上限 |
|||
$thisTotal = $lpKey == 0 ? $lpVal['max'] :($lpVal['max'] - $info['lp_set'][$lpKey - 1]['max']); |
|||
//获取当前区间的剩余数量 剩余数量为当前区间上限 减去销量 |
|||
$surplusTotalStk = ((($lpVal['max'] - $buyNum) >= 0) ? ($lpVal['max'] - $buyNum) : 0); |
|||
$thisStk = $surplusTotalStk > $thisTotal ? $thisTotal : $surplusTotalStk ; |
|||
//获取当前区间的已售数量 总共的可销售数量 - 剩余数量 |
|||
$thisBuyNum = $thisTotal - $thisStk; |
|||
//获取当前区间已售百分比 已售数量 / 总共可售数量 |
|||
$proportion = sprintf("%.2f",$thisBuyNum/$thisTotal * 100); |
|||
//新数组建立 方便移动端循环 |
|||
$newArr[$lpKey] = [ |
|||
'this_total' => $thisTotal , |
|||
'price' => sprintf("%.2f" , $lpVal['price']) ,//当前区间的销售价格 |
|||
'min' => intval($thisMin) ,//当前区间的最小值 |
|||
'max' => intval($lpVal['max']) ,//当前区间的最大值 |
|||
'surplus' => intval($thisStk) < 0 ? intval(0) : intval($thisStk) ,//当前区间剩余数量 |
|||
'buy_num' => intval($thisBuyNum) ,//当前区间已售数量 |
|||
'proportion' => $proportion |
|||
]; |
|||
//获取当前销售阶段的库存信息 |
|||
if($newArr[$lpKey]['surplus'] > 0 && $nowStatus == 0){ |
|||
$info['lp_now_stk'] = intval($newArr[$lpKey]['surplus']); |
|||
$nowStatus = 1; |
|||
} |
|||
} |
|||
//重新复制 lp_set |
|||
$info['lp_set'] = $newArr; |
|||
} |
|||
}else{ |
|||
$info['lp_set'] = []; |
|||
} |
|||
} |
|||
#16、获取使用流程和价格说明 |
|||
$settings = Setting::wlsetting_read('orderset'); |
|||
$info['info_set'] = [ |
|||
'use_info' => $settings['use_info'] ? htmlspecialchars_decode($settings['use_info']) : '', |
|||
'price_info' => $settings['price_info'] ? htmlspecialchars_decode($settings['price_info']) : '' |
|||
]; |
|||
#17、获取图片高度 |
|||
$info['imgstyle']['width'] = !empty(trim($_W['wlsetting']['base']['width'])) ? trim($_W['wlsetting']['base']['width']) : 750; |
|||
$info['imgstyle']['height'] = !empty(trim($_W['wlsetting']['base']['height'])) ? trim($_W['wlsetting']['base']['height']) : 560; |
|||
//删除不需要的多余信息 |
|||
unset($info['communityid']); |
|||
unset($info['allsalenum']); |
|||
unset($info['plugin']); |
|||
unset($info['usedatestatus']); |
|||
unset($info['week']); |
|||
unset($info['day']); |
|||
unset($info['daylimit']); |
|||
unset($info['monthlimit']); |
|||
unset($info['viparray']); |
|||
//881定制内容 |
|||
$isAuth = Customized::init('diy_userInfo'); |
|||
if($isAuth){ |
|||
$info['diy_userInfo']['credit'] = $_W['wlmember']['credit2']?$_W['wlmember']['credit2']:'0.00'; |
|||
$info['diy_userInfo']['dhurl'] = $_W['wlsetting']['recharge']['dhurl']; |
|||
$info['diy_userInfo']['dhtip1'] = $_W['wlsetting']['recharge']['dhtip1']?$_W['wlsetting']['recharge']['dhtip1']:'1乐豆抵用1元'; |
|||
$info['diy_userInfo']['dhtip2'] = $_W['wlsetting']['recharge']['dhtip2']?$_W['wlsetting']['recharge']['dhtip2']:'中国移动/中国银行积分可兑换乐豆'; |
|||
} |
|||
//砍价设置详情 |
|||
if($type == 7){ |
|||
$barset = Setting::agentsetting_read('bargainset'); |
|||
$info['barset']['playtitle'] = $barset['playtitle'] ? : ''; |
|||
$info['barset']['playdesc'] = $barset['playdesc'] ? : ''; |
|||
$info['barset']['playdetail'] = $barset['playdetail'] ? : ''; |
|||
}else{ |
|||
$info['barset']['playtitle'] = ''; |
|||
$info['barset']['playdesc'] = ''; |
|||
$info['barset']['playdetail'] = ''; |
|||
} |
|||
$this->renderSuccess('商品详细信息',$info); |
|||
} |
|||
/** |
|||
* Comment: 获取在线买单评价表 |
|||
* Author: wlf |
|||
* Date: 2019/11/25 18:29 |
|||
*/ |
|||
public function getPayOnlieOrder(){ |
|||
global $_W,$_GPC; |
|||
$id = $_GPC['orderid']; |
|||
$order = pdo_get('wlmerchant_order',array('id' => $id),array('sid','price')); |
|||
$data['price'] = $order['price']; |
|||
$store = pdo_get('wlmerchant_merchantdata',array('id' => $order['sid']),array('storename','logo')); |
|||
$data['goods_name'] = $store['storename'].'在线买单'; |
|||
$data['logo'] = tomedia($store['logo']); |
|||
$this->renderSuccess('订单信息',$data); |
|||
} |
|||
/** |
|||
* Comment: 获取商品推广图文设置信息 |
|||
* Author: zzw |
|||
* Date: 2019/12/26 10:21 |
|||
*/ |
|||
public function getGoodsExtensionInfo(){ |
|||
global $_W,$_GPC; |
|||
#1、参数获取 |
|||
$id = $_GPC['id'] OR $this->renderError('缺少参数:商品id');//商品id |
|||
$type = $_GPC['type'] OR $this->renderError('缺少参数:商品类型');//商品类型:1=抢购 2=团购 3=拼团 4=大礼包 5=优惠券 6=折扣卡 7=砍价商品 8=积分商品 |
|||
#2、根据商品类型获取推广文案设置信息 |
|||
switch ($type) { |
|||
case 1: |
|||
$table = tablename(PDO_NAME."rush_activity"); |
|||
$field = 'name,thumbs,extension_text,extension_img,oldprice,price,vipprice,vipstatus,viparray'; |
|||
break;//抢购商品 |
|||
case 2: |
|||
$table = tablename(PDO_NAME."groupon_activity"); |
|||
$field = 'name,thumbs,extension_text,extension_img,oldprice,price,vipprice,vipstatus,viparray'; |
|||
break;//团购商品 |
|||
case 3: |
|||
$table = tablename(PDO_NAME."fightgroup_goods"); |
|||
$field = 'name,adv as thumbs,extension_text,extension_img,price,aloneprice,oldprice,vipstatus,vipdiscount,peoplenum,vipdiscount'; |
|||
break;//拼团商品 |
|||
case 7: |
|||
$table = tablename(PDO_NAME."bargain_activity"); |
|||
$field = 'name,thumbs,extension_text,extension_img,oldprice,price,vipprice,vipstatus,viparray'; |
|||
break;//砍价商品 |
|||
} |
|||
$info = pdo_fetch("SELECT {$field} FROM ".$table." WHERE id = {$id} "); |
|||
#3、数据处理 |
|||
$thumbs = unserialize($info['thumbs']); |
|||
$extensionImg = unserialize($info['extension_img']); |
|||
//判断推广图片是否存在 不存在使用商品图集 |
|||
if (count($extensionImg) > 0 && is_array($extensionImg)) { |
|||
$info['extension_img'] = $extensionImg; |
|||
} else { |
|||
$info['extension_img'] = $thumbs; |
|||
} |
|||
//循环处理图片 |
|||
foreach($info['extension_img'] as &$img){ |
|||
$img = tomedia($img); |
|||
} |
|||
$info['extension_img'] = is_array($info['extension_img']) ? $info['extension_img'] : []; |
|||
//判断推广文案是否存在 不存在使用商品名称 |
|||
if($info['extension_text']){ |
|||
//[昵称] [时间] [商品名称] [原价] [特权类型] [拼团价] [单购价] [会员减免金额] [开团人数] [会员底价] [底价] [活动价] [会员价] |
|||
if($type != 3){ |
|||
$info['vipdiscount'] = WeliamWeChat::getVipDiscount($info['viparray'],-1); |
|||
$info['vipprice'] = sprintf("%.2f",$info['price'] - $info['vipdiscount']); |
|||
} |
|||
$nickname = $_W['wlmember']['nickname']; |
|||
$time = date("Y-m-d H:i:s" , time()); |
|||
if ($info['vipstatus'] == 1) $vipstatus = '会员特价'; |
|||
else if ($info['vipstatus'] == 2) $vipstatus = '会员特供'; |
|||
else $vipstatus = ''; |
|||
$info['extension_text'] = str_replace('[昵称]' , $nickname , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[时间]' , $time , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[商品名称]' , $info['name'] , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[原价]' , $info['oldprice'] , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[特权类型]' , $vipstatus , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[活动价]' , $info['price'] , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[会员价]' , $info['vipprice'] , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[拼团价]' , $info['price'] , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[单购价]' , $info['aloneprice'] , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[市场价]' , $info['oldprice'] , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[会员减免金额]' , $info['vipdiscount'] , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[开团人数]' , $info['peoplenum'] , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[会员底价]' , $info['vipprice'] , $info['extension_text']); |
|||
$info['extension_text'] = str_replace('[底价]' , $info['price'] , $info['extension_text']); |
|||
}else{ |
|||
$info['extension_text'] = $info['name'] ? : ''; |
|||
} |
|||
#4、删除多余的数据 |
|||
unset($info['name']); |
|||
unset($info['thumbs']); |
|||
|
|||
$this->renderSuccess('推广信息',$info,1); |
|||
} |
|||
/** |
|||
* Comment: 获取商品评价信息 |
|||
* Author: wlf |
|||
* Date: 2020/04/10 15:19 |
|||
*/ |
|||
public function getComment(){ |
|||
global $_W,$_GPC; |
|||
#1、参数获取 |
|||
$sid = $_GPC['sid']; //商户id |
|||
if(empty($sid)){ |
|||
$this->renderError('缺少商户参数,请返回重试'); |
|||
} |
|||
$plugin = $_GPC['plugin']; //商品插件 |
|||
$gid = $_GPC['goodsid']; //商品id |
|||
$page = $_GPC['page'] ? $_GPC['page'] : 1; //页码 |
|||
$page_start = $page * 10 - 10; |
|||
//查询 |
|||
$where = " sid = {$sid} AND status = 1 AND (checkone = 2 OR mid = {$_W['mid']})"; |
|||
if(!empty($plugin) && !empty($gid)){ |
|||
$where .= " AND plugin = '{$plugin}' AND gid = {$gid}"; |
|||
} |
|||
$data['totalnum'] = pdo_fetchcolumn('SELECT count(id) FROM '.tablename('wlmerchant_comment')." WHERE {$where}"); |
|||
$data['totalpage'] = ceil($data['totalnum'] / 10); |
|||
$comments = pdo_fetchall("SELECT headimg,nickname,createtime,star,pic,text,replytextone,replypicone,mid FROM ".tablename('wlmerchant_comment')."WHERE {$where} ORDER BY createtime DESC LIMIT {$page_start},10"); |
|||
if(!empty($comments)){ |
|||
foreach($comments as $commentKey => &$commentVal){ |
|||
//用户评论图片的处理 |
|||
$commentPic = unserialize($commentVal['pic']); |
|||
if(is_array($commentPic) && count($commentPic) > 0){ |
|||
foreach($commentPic as $picKey => &$picVal){ |
|||
if($picVal) $picVal = tomedia($picVal); |
|||
else unset($commentPic[$picKey]); |
|||
} |
|||
}else{ |
|||
$commentPic = []; |
|||
} |
|||
$commentVal['pic'] = $commentPic; |
|||
//商家回复信息图片的处理 |
|||
$replyPic = unserialize($commentVal['replypicone']); |
|||
if(is_array($replyPic) && count($replyPic) > 0){ |
|||
foreach($replyPic as $replyPicKey => &$replyPicVal){ |
|||
$replyPicVal = tomedia($replyPicVal); |
|||
} |
|||
}else{ |
|||
$replyPic = []; |
|||
} |
|||
$commentVal['replypicone'] = $replyPic; |
|||
//用户信息处理 |
|||
if(!empty($commentVal['mid'])){ |
|||
$member = pdo_get('wlmerchant_member',array('id' => $commentVal['mid']),array('nickname','avatar')); |
|||
} |
|||
if(!empty($member['nickname'])){ |
|||
$commentVal['nickname'] = $member['nickname']; |
|||
} |
|||
if(!empty($member['avatar'])){ |
|||
$commentVal['headimg'] = tomedia($member['avatar']) ; |
|||
}else{ |
|||
$commentVal['headimg'] = tomedia($commentVal['headimg']) ; |
|||
} |
|||
//处理时间 |
|||
$commentVal['createtime'] = date('Y-m-d H:i:s',$commentVal['createtime']); |
|||
} |
|||
} |
|||
$data['commentinfo'] = $comments; |
|||
$this->renderSuccess('评论列表',$data); |
|||
} |
|||
/** |
|||
* Comment: 商品分类页面 - 顶部排序分类信息 |
|||
* Author: zzw |
|||
* Date: 2020/12/7 10:24 |
|||
*/ |
|||
public function getGoodsCateList(){ |
|||
global $_W,$_GPC; |
|||
//参数信息获取 |
|||
$type = $_GPC['type'] ? : 3;//页面类型:3=抢购首页;4=团购首页;6=拼团首页;7=砍价首页;14=活动首页 |
|||
//信息获取 |
|||
$info = DiyPage::defaultInfo('options2',['type'=>$type]); |
|||
|
|||
$this->renderSuccess('评论列表',$info); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,138 @@ |
|||
<?php |
|||
/** |
|||
* 通讯系统 |
|||
*/ |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class ImModuleUniapp extends Uniapp { |
|||
//TODO:由于多功能通信大部分用户配置失败 如果删除多功能通信后需要保留发送图片和视频等功能 需要重新优化这里的通讯功能 目前普通通信仅支持发送文本信息 |
|||
/** |
|||
* Comment: 通讯信息列表(用户) |
|||
* Author: zzw |
|||
* Date: 2019/8/27 9:04 |
|||
*/ |
|||
public function infoList(){ |
|||
global $_W,$_GPC; |
|||
#1、参数获取 |
|||
$page = $_GPC['page'] ? : 1; |
|||
$pageIndex = $_GPC['page_index'] ? : 10; |
|||
$plugin = $_GPC['plugin'] ? : ''; |
|||
#2、获取列表信息 (1=用户;2=商户) |
|||
$data = Im::myList($_W['mid'],1,$page,$pageIndex,$plugin,true); |
|||
|
|||
$this->renderSuccess('通讯列表',$data); |
|||
} |
|||
/** |
|||
* Comment: 获取通讯记录 |
|||
* Author: zzw |
|||
* Date: 2019/8/26 17:42 |
|||
*/ |
|||
public function get(){ |
|||
global $_W,$_GPC; |
|||
#1、参数接收 |
|||
$page = $_GPC['page'] ? : 1; |
|||
$pageIndex = $_GPC['page_index'] ? : 10; |
|||
$thisId = $_GPC['id'] ? : $_W['mid'];//当前使用者的id:用户id(默认)|商户id |
|||
$thisType = $_GPC['type'] ? : 1;// 当前使用者的类型;1=用户(默认);2=商户 |
|||
$otherPartyType = $_GPC['other_party_type'] ? : 1;//通讯对象类型;1=用户;2=商户 |
|||
$otherPartyId = $_GPC['other_party_id'] or $this->renderError('缺少参数:other_party_id');//通讯对象id |
|||
#1、类型一致,id一致 则是给自己发送消息 |
|||
if($thisId == $otherPartyId && $thisType == $otherPartyType) $this->renderError("不能给自己发送信息哦",['url'=>h5_url('pages/mainPages/userCenter/userCenter')]); |
|||
$sendInfo['send_id'] = $thisId;//发送方id |
|||
$sendInfo['send_type'] = $thisType;//发送方类型(1=用户;2=商户) |
|||
$sendInfo['receive_id'] = $otherPartyId;//接收人id |
|||
$sendInfo['receive_type'] = $otherPartyType;//接收人类型(1=用户;2=商户) |
|||
|
|||
$data = Im::imRecord($page,$pageIndex,$sendInfo); |
|||
#3、修改信息为已读 |
|||
//if(is_array($data['list']) && count($data['list']) > 0) Im::is_read(array_column($data['list'],'id'),$thisId); |
|||
//修改所有对方发送的通讯信息为已读 |
|||
$where = " send_id = {$otherPartyId} AND send_type = {$otherPartyType} AND receive_id = {$thisId} AND receive_type = {$thisType} AND is_read = 0 "; |
|||
$sql = " UPDATE ".tablename(PDO_NAME."im")." SET is_read = 1 WHERE {$where} "; |
|||
pdo_query($sql); |
|||
#4、信息排序 |
|||
$sortArr = array_column($data['list'], 'create_time'); |
|||
array_multisort($sortArr, SORT_ASC, $data['list']); |
|||
#4、获取聊天对象的昵称 1=用户;2=商户 |
|||
if($otherPartyType == 1){ |
|||
$data['receive_name'] = pdo_getcolumn(PDO_NAME."member",['id'=>$otherPartyId],'nickname'); |
|||
}else{ |
|||
$data['receive_name'] = pdo_getcolumn(PDO_NAME."merchantdata",['id'=>$otherPartyId],'storename'); |
|||
} |
|||
|
|||
$this->renderSuccess('通讯记录',$data); |
|||
} |
|||
/** |
|||
* Comment: 发送通讯信息 |
|||
* Author: zzw |
|||
* Date: 2019/8/26 15:48 |
|||
*/ |
|||
public function send (){ |
|||
global $_W , $_GPC; |
|||
//判断是否绑定手机 |
|||
$mastmobile = unserialize($_W['wlsetting']['userset']['plugin']); |
|||
if (empty($_W['wlmember']['mobile']) && in_array('private',$mastmobile)){ |
|||
$this->renderError('未绑定手机号'); |
|||
} |
|||
$freeChat = Rights::freeChatRights($_W['mid'],$_GPC['send_type']); |
|||
if (!$freeChat) { |
|||
$memberIsChat = Rights::memberIsChat($_W['mid']); |
|||
if (!$memberIsChat['status']) $this->renderError($memberIsChat['msg'],['is_jump' => 1]); |
|||
} |
|||
#1、参数接收 |
|||
$sendId = $_GPC['send_id'] ? : $_W['mid'];//发送方id |
|||
$sendType = $_GPC['send_type'] ? : 1;//发送方类型(1=用户;2=商户) |
|||
$type = $_GPC['type'] ? : 0;//内容类型(0=文本信息(默认),1=图片地址,2=视频信息 3=名片 4=简历) |
|||
$plugin = $_GPC['plugin'] ? : '';// |
|||
!empty($_GPC['receive_id']) ? $receiveId = $_GPC['receive_id'] : $this->renderError('缺少参数:receive_id');//接收人id |
|||
!empty($_GPC['receive_type']) ? $receiveType = $_GPC['receive_type'] : $this->renderError('缺少参数:receive_type');//接收人类型(1=用户;2=商户) |
|||
!empty($_GPC['content']) ? $content = $_GPC['content'] : $this->renderError('缺少参数:content');//发送内容 |
|||
if($sendId == $receiveId && $sendType == $receiveType) $this->renderError("不能给自己发送信息哦"); |
|||
#2、信息拼装 |
|||
$data['uniacid'] = $_W['uniacid'];// |
|||
$data['send_id'] = $sendId;//发送方id |
|||
$data['send_type'] = $sendType;//发送方类型(1=用户;2=商户) |
|||
$data['receive_id'] = $receiveId;//接收人id |
|||
$data['receive_type'] = $receiveType;//接收人类型(1=用户;2=商户) |
|||
$data['create_time'] = time();//发送时间(建立时间) |
|||
$data['type'] = $type;//内容类型(0=文本信息(默认),1=图片地址,2=视频信息) |
|||
$data['plugin'] = $plugin;//通讯插件 |
|||
if(empty($data['type'])){ |
|||
$data['content'] = htmlspecialchars_decode($content);//发送内容 |
|||
}else{ |
|||
$data['content'] = $content;//发送内容 |
|||
} |
|||
|
|||
#2、信息记录 |
|||
$res = Im::insert($data); |
|||
if ($res) $this->renderSuccess('发送成功'); |
|||
else $this->renderError('发送失败'); |
|||
} |
|||
/** |
|||
* Comment: 通讯设置 |
|||
* Author: zzw |
|||
* Date: 2021/3/8 11:57 |
|||
*/ |
|||
public function getSetInfo(){ |
|||
global $_W,$_GPC; |
|||
//获取基本设置 |
|||
//$set = Setting::wlsetting_read('im_set'); |
|||
//判断用户是否存在简历信息 |
|||
$isResume = pdo_get(PDO_NAME."recruit_resume",['mid' => $_W['mid']]); |
|||
//信息拼接 |
|||
$data = [ |
|||
'type' => 1, |
|||
'port' => '', |
|||
'mid' => $_W['mid'], |
|||
'is_card' => p('citycard') ? 1 : 0,//是否存在名片插件 0=不存在,1=存在 |
|||
'is_recruit' => p('recruit') ? 1 : 0,//是否存在求职招聘插件 0=不存在,1=存在 |
|||
'is_resume' => $isResume ? 1 : 0,//是否存在简历信息 0=不存在,1=存在 |
|||
'resume_id' => $isResume['id'],//简历id |
|||
]; |
|||
|
|||
$this->renderSuccess('通讯设置信息',$data); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,282 @@ |
|||
<?php |
|||
|
|||
defined('IN_IA') or exit('Access Denied'); |
|||
class RightsModuleUniapp extends Uniapp |
|||
{ |
|||
|
|||
protected $typeArray = [ |
|||
1 => ['plugin' => 'rights', 'payfor' => 'rights'], |
|||
2 => ['plugin' => 'rights', 'payfor' => 'rightsBag'] |
|||
]; |
|||
|
|||
/** |
|||
* 我的权益首页展示数据 |
|||
* @return void |
|||
*/ |
|||
public function getRightsList() { |
|||
global $_W, $_GPC; |
|||
|
|||
$rights = Rights::getRightsList(); |
|||
$contentList = []; |
|||
foreach ($rights as $rightsKey => $rightsValue) { |
|||
$contentList[] = ($rightsKey + 1) . '.' . $rightsValue['content']; |
|||
} |
|||
|
|||
$rightsBag = pdo_get(PDO_NAME . 'rights_bag',['id' => 2],['id','title','price']); |
|||
|
|||
$this->renderSuccess('数据获取成功',[ |
|||
'table_list' => Rights::getRightsMergeList(), |
|||
'content_list' => $contentList, |
|||
'member_rights_list' => Rights::getMemberRightsUsageInfo($_W['mid']), |
|||
'rights_bag_data' => $rightsBag?:[] |
|||
]); |
|||
} |
|||
|
|||
/** |
|||
* 权益详情页面展示数据 |
|||
* @return void |
|||
*/ |
|||
public function getRightsTypeInfo() { |
|||
global $_W, $_GPC; |
|||
|
|||
$rightsid = $_GPC['rights_id']; |
|||
$mid = $_W['mid']; |
|||
if (empty($rightsid) || !is_numeric($rightsid)) $this->renderError('缺少权益id'); |
|||
|
|||
$rights = pdo_get(PDO_NAME . 'rights',['id' => $rightsid],['rights_type','calculate_method','price']); |
|||
if (!$rights) $this->renderError('权益信息不存在'); |
|||
|
|||
$rights_type = $rights['rights_type']; |
|||
|
|||
$data = [ |
|||
'rights_type' => $rights_type, // 权益类型 |
|||
'remaining_amount' => 0, // 剩余数量 |
|||
'price' => $rights['price'] // 单价 |
|||
]; |
|||
|
|||
$memberRights = pdo_get(PDO_NAME . 'member_rights',['rightsid' => $rightsid,'mid' => $mid,'status' => 1]); |
|||
if ($memberRights) { |
|||
$use_amount = $memberRights['use_amount']; |
|||
// 现有数量 |
|||
$data['remaining_amount'] = Rights::getUseAmount($rightsid,$memberRights['id'],$use_amount,$memberRights['total_amount']); |
|||
} |
|||
|
|||
// 获取权益提交数据信息 |
|||
switch ($rightsid) { |
|||
case 1: |
|||
|
|||
break; |
|||
case 2: |
|||
$data['amount_unit'] = Rights::$unit[4]; // 数量单位 |
|||
$data['num_data'] = Rights::$dayData; // 数量选择 |
|||
$data['filter_data'] = [ |
|||
'recruit' => Rights::getStoreRecruitInfo($mid) // 商户招聘职位信息 |
|||
]; |
|||
break; |
|||
case 3: |
|||
$data['amount_unit'] = Rights::$unit[4]; |
|||
$data['num_data'] = Rights::$monthData; |
|||
break; |
|||
case 4: |
|||
$data['amount_unit'] = Rights::$unit[3]; |
|||
$data['num_data'] = Rights::$numData; |
|||
break; |
|||
case 5: |
|||
$data['amount_unit'] = Rights::$unit[2]; |
|||
$data['num_data'] = Rights::$copyData; |
|||
$data['filter_data'] = [ |
|||
'recruit' => Rights::getStoreRecruitInfo($mid), |
|||
'graduated_school' => Rights::$graduatedSchool, // 毕业院校 |
|||
'experience' => Rights::$experience // 经历 |
|||
]; |
|||
break; |
|||
} |
|||
|
|||
$this->renderSuccess('数据返回成功',$data); |
|||
} |
|||
|
|||
/** |
|||
* 创建权益支付接口 |
|||
* @return void |
|||
*/ |
|||
public function createRightsPay() { |
|||
global $_W, $_GPC; |
|||
|
|||
$rightsid = $_GPC['rights_id']; // 权益ID |
|||
$type = $_GPC['type']; // 权益支付类型 |
|||
$num = $_GPC['num']; // 购买数量 |
|||
$contacts = $_GPC['contacts']; // 联系人名称 |
|||
$contact_phone = $_GPC['contact_phone'] ?: ''; // 联系电话 |
|||
|
|||
if (empty($rightsid) || !is_numeric($rightsid)) $this->renderError('缺少权益id'); |
|||
if (empty($type) || !in_array($type,array_keys($this->typeArray))) $this->renderError('权益支付类型数据有误'); |
|||
if (!empty($contact_phone) && $contact_phone != 'undefined') { |
|||
if (!preg_match("/^1[3-9]\d{9}$/",$contact_phone)) $this->renderError('请输入正确的手机号'); |
|||
} |
|||
|
|||
if ($type == 2) { |
|||
$num = 1; |
|||
} else { |
|||
if (empty($num)) $this->renderError('请输入购买数量'); |
|||
if (!preg_match("/^\d+$/",$num)) $this->renderError('购买数量必须是数字整数'); |
|||
if ($num <= 0 || $num > 500) $this->renderError('购买数量最低不能小于0,最高不能大于500'); |
|||
} |
|||
if (!empty($contacts)) { |
|||
$contactsRes = Filter::init($contacts,$_W['source'],1); |
|||
if ($contactsRes['errno'] == 0) $this->renderError('联系人名称'.$contactsRes['message']); |
|||
} |
|||
|
|||
$typeData = $this->typeArray[$type]; |
|||
|
|||
// 获取权益价格 |
|||
$oprice = 0; |
|||
if ($typeData['payfor'] == 'rights') { |
|||
$rights = pdo_get(PDO_NAME . 'rights',['id' => $rightsid],['price']); |
|||
$oprice = $rights['price']; |
|||
} elseif ($typeData['payfor'] == 'rightsBag') { |
|||
$rightsBag = pdo_get(PDO_NAME . 'rights_bag',['id' => $rightsid],['price']); |
|||
$oprice = $rightsBag['price']; |
|||
} |
|||
$price = bcmul($oprice,$num,2); |
|||
|
|||
//生成订单 |
|||
$orderdata = [ |
|||
'uniacid' => $_W['uniacid'], |
|||
'mid' => $_W['mid'], |
|||
'aid' => $_W['aid'], |
|||
'fkid' => $rightsid, |
|||
'createtime' => time(), |
|||
'orderno' => createUniontid(), |
|||
'oprice' => $oprice, |
|||
'price' => $price, |
|||
'num' => $num, |
|||
'plugin' => $typeData['plugin'], |
|||
'payfor' => $typeData['payfor'], |
|||
'goodsprice' => $price, |
|||
'fightstatus' => 1, |
|||
'name' => $contacts, |
|||
'mobile' => $contact_phone |
|||
]; |
|||
pdo_insert(PDO_NAME.'order',$orderdata); |
|||
$orderid = pdo_insertid(); |
|||
if (empty($orderid)) { |
|||
$this->renderError('生成订单失败,请刷新重试'); |
|||
|
|||
} else { |
|||
$this->renderSuccess('发布成功',['status' => 1,'type' => $typeData['plugin'],'orderid' => $orderid]); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 用户使用权益 |
|||
* @return void |
|||
*/ |
|||
public function memberUseRights() { |
|||
global $_W, $_GPC; |
|||
|
|||
$mid = $_W['mid']; |
|||
$rightsid = $_GPC['rights_id']; // 权益id |
|||
$position = json_decode(html_entity_decode($_GPC['position']),true); // 使用权益 关联信息 |
|||
if (empty($rightsid) || !is_numeric($rightsid)) $this->renderError('缺少权益id'); |
|||
if (empty($position)) $this->renderError('position参数不能为空'); |
|||
if (!is_array($position)) $this->renderError('position参数数据有误'); |
|||
|
|||
$sumNum = 0; // 总使用数量 |
|||
// 验证请求数据 |
|||
foreach($position as $value) { |
|||
|
|||
$num = $value['num']; // 使用数量 |
|||
$recruit_id = $value['recruit_id']; // 商户招聘信息ID |
|||
if (empty($num)) $this->renderError('请填写使用数量'); |
|||
if ($num <= 0) $this->renderError('使用数量不能小于等于0'); |
|||
if (empty($recruit_id) || !is_numeric($recruit_id)) $this->renderError('请选择要置顶的岗位'); |
|||
|
|||
$sumNum += $num; |
|||
} |
|||
|
|||
// 获取用户是否购买权益 |
|||
$memberRights = Rights::getMemberRights($mid,$rightsid); |
|||
if (!$memberRights) $this->renderError('您没有该权益,请先购买权益'); |
|||
|
|||
#$remaining_amount = $memberRights['total_amount'] - $memberRights['use_amount']; // 剩余权益数量 |
|||
$remaining_amount = Rights::getUseAmount($rightsid,$memberRights['id'],$memberRights['use_amount'],$memberRights['total_amount']); |
|||
// 判断权益是否使用完 |
|||
if ($memberRights['status'] == 0) $this->renderError('该权益的使用已到期,请重新购买使用'); |
|||
if ($remaining_amount <= 0) $this->renderError('该权益的使用数量为零,请重新购买使用'); |
|||
|
|||
if ($sumNum > $remaining_amount) $this->renderError('填写数量不能大于剩余数量'); |
|||
|
|||
try { |
|||
pdo_begin(); |
|||
|
|||
switch ($rightsid) { |
|||
case 2: |
|||
// 生成使用信息 |
|||
foreach ($position as $value) { |
|||
// 生成子权益使用 |
|||
$saveMemberRightsUse = Rights::saveMemberRightsUse($rightsid,$memberRights['id'],$value['num'],$value['recruit_id']); |
|||
if (!$saveMemberRightsUse['status']) throw new Exception($saveMemberRightsUse['msg']); |
|||
|
|||
// 判断是否可以置顶 可以及开始置顶 |
|||
$isTopRes = Rights::recruitIsTop($value['recruit_id'],$memberRights['id'],$memberRights,$value['num']); |
|||
$num = 1; |
|||
if ($isTopRes == 2) $num = 0; |
|||
if ($isTopRes) Rights::useMemberRights($rightsid,$mid,$value['recruit_id'],'recruit_bout',$num); |
|||
} |
|||
break; |
|||
case 5: |
|||
$graduated_school = $_GPC['graduated_school']; // 毕业院校(待确认) |
|||
$experience = $_GPC['experience']; // 优先选项 - 经历(待确认) |
|||
$data = []; |
|||
if (!empty($graduated_school) && is_numeric($graduated_school)) $data['graduated_school'] = $graduated_school; |
|||
if (!empty($experience) && is_numeric($experience)) $data['experience'] = $experience; |
|||
foreach ($position as $value) { |
|||
$saveMemberRightsUse = Rights::saveMemberRightsUse($rightsid,$memberRights['id'],$value['num'],$value['recruit_id'],'recruit_resume',$data); |
|||
if (!$saveMemberRightsUse['status']) throw new Exception($saveMemberRightsUse['msg']); |
|||
} |
|||
break; |
|||
} |
|||
|
|||
// $memberRightsUpdateArr = ['use_amount' => $memberRights['use_amount'] + $sumNum]; |
|||
// $memberRightsUpdate = pdo_update(PDO_NAME . 'member_rights',$memberRightsUpdateArr,['id' => $memberRights['id']]); |
|||
// if (!$memberRightsUpdate) throw new Exception('使用失败'); |
|||
|
|||
} catch (Exception $e) { |
|||
pdo_rollback(); |
|||
$this->renderError($e->getMessage()); |
|||
} |
|||
|
|||
pdo_commit(); |
|||
|
|||
$this->renderSuccess('使用成功'); |
|||
} |
|||
|
|||
public function getRightsOrderList() |
|||
{ |
|||
global $_W, $_GPC; |
|||
|
|||
$page = $_GPC['page'] ? : 1; |
|||
$pageIndex = $_GPC['page_index'] ? : 10; |
|||
|
|||
$where = ['uniacid' => $_W['uniacid'], 'aid' => $_W['aid'], 'plugin' => 'rights','mid' => $_W['mid']?:4]; |
|||
$field = "id,orderno,status,paytype,payfor,paytime,price,fkid,mid,num"; |
|||
$orderData = Util::getNumData($field, PDO_NAME . 'order', $where, 'id desc', $page, $pageIndex, 1); |
|||
|
|||
$list = $orderData[0]; |
|||
|
|||
foreach($list as &$item){ |
|||
if ($item['payfor'] == 'rightsBag') { |
|||
|
|||
$rightsBag = pdo_get(PDO_NAME . 'rights_bag',['id' => $item['fkid']]); |
|||
$item['storename'] = $rightsBag['title']; |
|||
} else { |
|||
$rights = pdo_get(PDO_NAME . 'rights',['id' => $item['fkid']]); |
|||
$item['storename'] = $rights['rights_type']; |
|||
} |
|||
|
|||
Member::getMemberInfo($item,$item['mid']); |
|||
} |
|||
$this->renderSuccess('数据获取成功',$list); |
|||
} |
|||
|
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,495 @@ |
|||
<?php |
|||
|
|||
defined('IN_IA') or exit('Access Denied'); |
|||
class StudentModuleUniapp extends Uniapp |
|||
{ |
|||
/* |
|||
* 学生认证申请初始数据 |
|||
*/ |
|||
public function studentIdentityIndex() |
|||
{ |
|||
global $_W, $_GPC; |
|||
|
|||
$mid = $_W['mid']; |
|||
|
|||
if (empty($mid) || !is_numeric($mid)) $this->renderError('缺少参数'); |
|||
|
|||
$fields_arr = [ |
|||
'id','mid','name','code','school_name','department_name','start_date','certificate_img','check_cause','check_status' |
|||
]; |
|||
$data = pdo_get(PDO_NAME . 'member_student_info',['mid' => $mid],$fields_arr); |
|||
if (is_numeric($data['check_status']) && $data['check_status'] == 0) $this->renderError('待审核中,请勿重复申请认证'); |
|||
if ($data['check_status'] == 1) $this->renderError('认证已成功,请勿重复申请认证',['is_jump' => true]); |
|||
|
|||
$user = pdo_get(PDO_NAME . 'member',['id' => $mid],['identity_id']); |
|||
if ($user && !in_array($user['identity_id'],[1,3])) { |
|||
$identity = pdo_get(PDO_NAME . 'member_identity',['id' => $user['identity_id']],['name']); |
|||
$this->renderError('您已经是' . $identity['name'] . '身份,无法申请学生认证'); |
|||
} |
|||
|
|||
if ($data) { |
|||
$data['certificate_img'] = tomedia($data['certificate_img']); |
|||
$data['reject'] = $data['check_cause']; |
|||
$data['status'] = $data['check_status']; |
|||
unset($data['check_cause'],$data['check_status']); |
|||
$this->renderSuccess('数据获取成功',$data); |
|||
} |
|||
$this->renderSuccess('数据为空',[ |
|||
'id' => '', |
|||
'mid' => $mid, |
|||
'name' => '', |
|||
'code' => '', |
|||
'school_name' => '', |
|||
'department_name' => '', |
|||
'start_date' => '', |
|||
'certificate_img' => '', |
|||
'reject' => '', |
|||
'status' => 0 |
|||
]); |
|||
} |
|||
/* |
|||
* 学生认证申请 |
|||
*/ |
|||
public function studentIdentityAttestation() |
|||
{ |
|||
global $_W, $_GPC; |
|||
|
|||
$data = []; |
|||
$id = $_GPC['id']; |
|||
$mid = $_W['mid']; |
|||
$uniacid = $_W['uniacid']; |
|||
$sms_code = $_GPC['sms_code']; |
|||
|
|||
// 验证信息 |
|||
if (empty($_GPC['name'])) $this->renderError('请输入姓名'); |
|||
if (empty($_GPC['mobile'])) $this->renderError('请输入手机号'); |
|||
if (!preg_match("/^1[3-9]\d{9}$/",$_GPC['mobile'])) $this->renderError('请输入正确的手机号'); |
|||
if (empty($_GPC['code'])) $this->renderError('请输入学号'); |
|||
if (empty($_GPC['school_name'])) $this->renderError('请输入学校名称'); |
|||
if (empty($_GPC['department_name'])) $this->renderError('请输入院系'); |
|||
if (empty($_GPC['start_date'])) $this->renderError('请选择入学时间'); |
|||
if (empty($_GPC['certificate_img'])) $this->renderError('请上传证件'); |
|||
|
|||
if (strtotime($_GPC['start_date']) > time()) $this->renderError('入学时间不能超出未来时间'); |
|||
|
|||
$this->checkCode($_GPC['mobile'],$sms_code); |
|||
|
|||
$validate = Member::validateMemberIdentity($_W['mid']); |
|||
if (!$validate['status']) $this->renderError($validate['msg'],['is_jump' => true]); |
|||
|
|||
$where = ['mid' => $mid]; |
|||
$student_res = pdo_get(PDO_NAME . 'member_student_info',$where); |
|||
if ($student_res) { |
|||
if (is_numeric($student_res['check_status']) && $student_res['check_status'] == 0) $this->renderError('待审核中,请勿重复申请'); |
|||
if ($student_res['check_status'] == 1) $this->renderError('已审核通过,请勿重复申请'); |
|||
} |
|||
|
|||
$name_res = Filter::init(trim($_GPC['name']),$_W['source'],1); |
|||
if ($name_res['errno'] == 0) $this->renderError($name_res['message']); |
|||
$school_name_res = Filter::init(trim($_GPC['school_name']),$_W['source'],1); |
|||
if ($school_name_res['errno'] == 0) $this->renderError($school_name_res['message']); |
|||
$department_name_res = Filter::init(trim($_GPC['department_name']),$_W['source'],1); |
|||
if ($department_name_res['errno'] == 0) $this->renderError($department_name_res['message']); |
|||
$certificate_img_res = Filter::init(trim($_GPC['certificate_img']),$_W['source'],2); |
|||
if ($certificate_img_res['errno'] == 0) $this->renderError($certificate_img_res['message']); |
|||
|
|||
// 创建认证申请 |
|||
$data['mid'] = $mid; |
|||
$data['uniacid'] = $uniacid; |
|||
$data['name'] = trim($_GPC['name']); |
|||
$data['mobile'] = trim($_GPC['mobile']); |
|||
$data['code'] = trim($_GPC['code']); |
|||
$data['school_name'] = trim($_GPC['school_name']); |
|||
$data['department_name'] = trim($_GPC['department_name']); |
|||
$data['certificate_img'] = trim($_GPC['certificate_img']); |
|||
$data['start_date'] = trim($_GPC['start_date']); |
|||
|
|||
if (empty($id)) { |
|||
$data['create_time'] = time(); |
|||
$result = pdo_insert(PDO_NAME . 'member_student_info',$data); |
|||
} elseif (is_numeric($id)) { |
|||
$data['update_time'] = time(); |
|||
$data['check_status'] = 0; |
|||
$result = pdo_update(PDO_NAME . 'member_student_info',$data,['id' => $id]); |
|||
} else { |
|||
$result = false; |
|||
} |
|||
if (!$result) $this->renderError('认证申请失败'); |
|||
|
|||
$this->renderSuccess('认证申请已提交'); |
|||
} |
|||
/** |
|||
* Comment: 文件上传 |
|||
* Author: zzw |
|||
* Date: 2023/3/24 14:32 |
|||
*/ |
|||
public function uploadFiles(){ |
|||
global $_W , $_GPC; |
|||
#1、判断上传方式 |
|||
$uploadType = $_GPC['upload_type'] ? $_GPC['upload_type'] : 1;//1=普通上传;2=微信端上传 |
|||
#2、调用方法进行处理 |
|||
UploadFile::uploadIndex($_FILES ,$uploadType, $_GPC['id'], [], 'student_info'); |
|||
} |
|||
/* |
|||
* 校园活动信息列表 |
|||
*/ |
|||
public function campusActivitiesList() { |
|||
global $_W, $_GPC; |
|||
|
|||
$mid = $_W['mid']; |
|||
$collect = $_GPC['collect'] ?: 0; # 收藏数据查询 |
|||
$sub = $_GPC['sub'] ?: 0; # 发布记录查询 |
|||
$pindex = max(1, intval($_GPC['page'])); |
|||
$psize = $_GPC['size'] ?: 5; |
|||
|
|||
$where = ''; |
|||
if (empty($sub)) { |
|||
$where .= ' status = 1 '; |
|||
} else { |
|||
$where .= " create_place = 2 and create_user_id = {$mid}"; |
|||
} |
|||
|
|||
# 查询用户收藏数据 |
|||
if (!empty($collect) && $collect == 1) { |
|||
$collect_list = pdo_getall(PDO_NAME . 'member_collect_activities',['mid' => $mid],['campus_activities_id']); |
|||
|
|||
if ($collect_list) { |
|||
$caid_arr = []; |
|||
foreach ($collect_list as $collect_value) $caid_arr[] = $collect_value['campus_activities_id']; |
|||
$where .= " and id in('" . implode("','",$caid_arr) . "')"; |
|||
} else { |
|||
$where .= ' and id = 0 '; |
|||
} |
|||
} |
|||
|
|||
|
|||
if (!empty($_GPC['cc_id'])) $where .= " and cc_id = '{$_GPC['cc_id']}'"; |
|||
if (!empty($_GPC['recommend'])) $where .= " and recommend = '{$_GPC['recommend']}'"; |
|||
if (!empty($_GPC['title'])) $where .= " and title like '%{$_GPC['title']}%'"; |
|||
$statusArr = ['审核中' , '已发布', '已驳回']; |
|||
$field = ['id','title','describe','promotional_img','publish_time','create_place','create_user_id','cc_id','status','reject']; |
|||
$total = pdo_count(PDO_NAME . 'member_campus_activities',$where); |
|||
$list = pdo_getall(PDO_NAME . 'member_campus_activities',$where,$field,'','publish_time desc',[$pindex,$psize]); |
|||
foreach ($list as &$val) { |
|||
$val['promotional_img'] = tomedia($val['promotional_img']); |
|||
$val['publish_time'] = $val['publish_time'] ? date("Y-m-d H:i:s",$val['publish_time']) : ''; |
|||
#发布人 |
|||
$val['nickname'] = '小粤'; |
|||
$val['avatar'] = $_W['wlsetting']['base']['logo'] ? tomedia($_W['wlsetting']['base']['logo']) : tomedia('headimg_'.$_W['account']['acid'].'.jpg'); |
|||
#分类名称 |
|||
if ($val['create_place'] == 2) Member::getMemberInfo($val,$val['create_user_id']); |
|||
$cc_name = pdo_getcolumn(PDO_NAME . 'cultivate_class',['id' => $val['cc_id']],'name'); |
|||
$val['cc_name'] = $cc_name ?: ''; |
|||
$val['status_str'] = $statusArr[$val['status']]; |
|||
// 活动点赞数 |
|||
$thumbs_up_count = pdo_count(PDO_NAME . 'member_thumbs_up_activities',['campus_activities_id' => $val['id']]); |
|||
$val['thumbs_up_count'] = $thumbs_up_count ?: 0; |
|||
$is_thumbs_up = pdo_get(PDO_NAME . 'member_thumbs_up_activities',['campus_activities_id' => $val['id'], 'mid' => $_W['mid']]); |
|||
// 是否点赞该活动 |
|||
$val['is_thumbs_up'] = $is_thumbs_up ? true : false; |
|||
if ($val['status'] == 1) $val['reject'] = ''; |
|||
unset($val['create_place'],$val['create_user_id'],$val['status']); |
|||
} |
|||
|
|||
$this->renderSuccess($list?'数据获取成功':'数据为空',['data' => $list, 'pager' => $pindex, 'total' => $total]); |
|||
} |
|||
/* |
|||
* 获取校园活动信息详情 |
|||
*/ |
|||
public function campusActivitiesFind() { |
|||
global $_W, $_GPC; |
|||
|
|||
$id = $_GPC['id']; |
|||
if (empty($id)) $this->renderError('请求失败'); |
|||
$fields = ['id','title','describe','promotional_img','publish_time','create_place','create_user_id']; |
|||
$data = pdo_get(PDO_NAME . 'member_campus_activities',['id' => $id],$fields); |
|||
#发布人 |
|||
$data['nickname'] = '小粤'; |
|||
$data['avatar'] = $_W['wlsetting']['base']['logo'] ? tomedia($_W['wlsetting']['base']['logo']) : tomedia('headimg_'.$_W['account']['acid'].'.jpg'); |
|||
if ($data['create_place'] == 2) Member::getMemberInfo($data,$data['create_user_id']); |
|||
#分类名称 |
|||
$cc_name = pdo_getcolumn(PDO_NAME . 'cultivate_class',['id' => $data['cc_id']],'name'); |
|||
$data['cc_name'] = $cc_name ?: ''; |
|||
$where = ['campus_activities_id' => $data['id']]; // 活动评价内容 |
|||
$where2 = ['campus_activities_id' => $data['id'], 'mid' => $_W['mid']]; |
|||
|
|||
$data['promotional_img'] = tomedia($data['promotional_img']); |
|||
$thumbs_up_count = pdo_count(PDO_NAME . 'member_thumbs_up_activities',$where); // 活动点赞数 |
|||
$data['thumbs_up_count'] = $thumbs_up_count ?: 0; |
|||
$is_thumbs_up = pdo_get(PDO_NAME . 'member_thumbs_up_activities',$where2); |
|||
$data['is_thumbs_up'] = $is_thumbs_up ? true : false; // 是否点赞该活动 |
|||
|
|||
$collect_count = pdo_count(PDO_NAME . 'member_collect_activities',$where); // 活动收藏数 |
|||
$data['collect_count'] = $collect_count ?: 0; |
|||
$is_collect = pdo_get(PDO_NAME . 'member_collect_activities',$where2); |
|||
$data['is_collect'] = $is_collect ? true : false; // 是否收藏 |
|||
$data['publish_time'] = date("Y-m-d H:i:s",$data['publish_time']); |
|||
|
|||
unset($data['create_place'],$data['create_user_id']); |
|||
$this->renderSuccess('数据获取成功',['data' => $data]); |
|||
} |
|||
/* |
|||
* 校园活动添加评价 |
|||
*/ |
|||
public function addEvaluation() { |
|||
global $_W, $_GPC; |
|||
|
|||
$mid = $_W['mid']; |
|||
$caid = $_GPC['caid']; |
|||
$oneid = $_GPC['oneid']; |
|||
$pid = $_GPC['pid']; |
|||
$content = $_GPC['content']; |
|||
|
|||
if (empty($mid) || !is_numeric($mid)) $this->renderError('请求失败'); |
|||
if (empty($caid) || !is_numeric($caid)) $this->renderError('请求失败'); |
|||
if (empty($content)) $this->renderError('请填写评价内容'); |
|||
$contentRes = Filter::init(trim($content)); |
|||
if ($contentRes['errno'] == 0) $this->renderError($contentRes['message']); |
|||
|
|||
$data = [ |
|||
'mid' => $mid, |
|||
'uniacid' => $_W['uniacid'], |
|||
'campus_activities_id' => $caid, |
|||
'content' => base64_encode(trim($content)), |
|||
'create_time' => time() |
|||
]; |
|||
if (!empty($pid) && is_numeric($pid)) { |
|||
$pQuery = pdo_get(PDO_NAME . 'member_evaluation_activities',['id' => $pid],['id']); |
|||
if (!$pQuery) $this->renderError('回复评价信息不存在!'); |
|||
$data['pid'] = $pQuery['id']; |
|||
} |
|||
if (!empty($oneid) && is_numeric($pid)) $data['oneid'] = $oneid; |
|||
|
|||
//判断是否需要审核 |
|||
$settings = Setting::wlsetting_read('comment_set'); |
|||
if($settings['campusActivities'] == 1) $data['status'] = 1; |
|||
|
|||
$result = pdo_insert(PDO_NAME . 'member_evaluation_activities',$data); |
|||
if (!$result) $this->renderError('评价失败'); |
|||
$this->renderSuccess('评价成功'); |
|||
} |
|||
|
|||
/** |
|||
* 获取评价数据 |
|||
* @return void |
|||
*/ |
|||
public function getEvaluationList() |
|||
{ |
|||
global $_W, $_GPC; |
|||
|
|||
$caid = $_GPC['caid']; |
|||
$oneid = $_GPC['oneid'] ?: 0; |
|||
$pindex = $_GPC['pindex'] ?: 1; |
|||
$psize = $_GPC['psize'] ?: 10; |
|||
|
|||
if (empty($caid) || !is_numeric($caid)) $this->renderError('缺少参数:caid'); |
|||
|
|||
$where = ['campus_activities_id' => $caid, 'oneid' => $oneid, 'status' => 1]; |
|||
|
|||
$fields = 'id,mid,content,create_time,pid,oneid'; |
|||
|
|||
$commentRes = Util::getNumData($fields, PDO_NAME . 'member_evaluation_activities', $where, 'create_time asc', $pindex, $psize, 1); |
|||
$appraise_list = (array)$commentRes[0]; |
|||
$pager = $commentRes[1]; |
|||
$total = $commentRes[2]; |
|||
foreach ($appraise_list as &$row) { |
|||
# 评价人信息 |
|||
Member::getMemberInfo($row,$row['mid']); |
|||
# 回复信息 |
|||
if (is_base64($row['content'])) $row['content'] = base64_decode($row['content']); |
|||
# 评价时间 |
|||
$row['create_time'] = date("Y.m.d H:i",$row['create_time']); |
|||
# 是否显示查看回复 |
|||
$row['is_query'] = false; |
|||
# 回复数量 |
|||
$row['reply_count'] = 0; |
|||
if (!$row['oneid']) { |
|||
$count = pdo_count(PDO_NAME . 'member_evaluation_activities',['oneid' => $row['id'],'status' => 1]); |
|||
if ($count > 0) $row['is_query'] = true; |
|||
$row['reply_count'] = $count; |
|||
} |
|||
# 被回复人信息 |
|||
if (!empty($row['pid'])) { |
|||
$pComment = pdo_get(PDO_NAME . 'member_evaluation_activities',['id' => $row['pid']],['mid']); |
|||
$quiltArr = []; |
|||
Member::getMemberInfo($quiltArr,$pComment['mid']); |
|||
$row['quilt_nickname'] = $quiltArr['nickname']; |
|||
$row['quilt_avatar'] = $quiltArr['avatar']; |
|||
$row['quilt_mid'] = $pComment['mid']; |
|||
} |
|||
} |
|||
|
|||
$this->renderSuccess('数据获取成功',['list' => $appraise_list, 'pager' => $pager, 'total' => $total]); |
|||
} |
|||
|
|||
/* |
|||
* 立即收藏活动 |
|||
*/ |
|||
public function immediatelyCollectActivities() { |
|||
global $_W, $_GPC; |
|||
|
|||
$mid = $_W['mid']; |
|||
$caid = $_GPC['caid']; |
|||
if (empty($mid) || !is_numeric($mid)) $this->renderError('请求失败'); |
|||
if (empty($caid) || !is_numeric($caid)) $this->renderError('请求失败'); |
|||
$collect_data = pdo_get(PDO_NAME . 'member_collect_activities',['campus_activities_id' => $caid,'mid' => $mid]); |
|||
if ($collect_data) $this->renderError('请勿重复收藏'); |
|||
$data = [ |
|||
'mid' => $mid, |
|||
'campus_activities_id' => $caid, |
|||
'create_time' => time() |
|||
]; |
|||
$result = pdo_insert(PDO_NAME . 'member_collect_activities', $data); |
|||
if (!$result) $this->renderError('收藏失败'); |
|||
$this->renderSuccess('收藏成功'); |
|||
} |
|||
/* |
|||
* 取消收藏活动 |
|||
*/ |
|||
public function cancelCollectActivities() { |
|||
global $_W, $_GPC; |
|||
|
|||
$mid = $_W['mid']; |
|||
$caid = $_GPC['caid']; |
|||
if (empty($mid) || !is_numeric($mid)) $this->renderError('请求失败'); |
|||
if (empty($caid) || !is_numeric($caid)) $this->renderError('请求失败'); |
|||
|
|||
$result = pdo_delete(PDO_NAME . 'member_collect_activities',['mid' => $mid, 'campus_activities_id' => $caid]); |
|||
if (!$result) $this->renderError('取消收藏失败'); |
|||
$this->renderSuccess('取消成功'); |
|||
} |
|||
/* |
|||
* 校园活动点赞(点赞/取消点赞) |
|||
*/ |
|||
public function thumbsUpActivities() { |
|||
global $_W, $_GPC; |
|||
|
|||
$mid = $_W['mid']; |
|||
$caid = $_GPC['caid']; |
|||
if (empty($mid) || !is_numeric($mid)) $this->renderError('请求失败'); |
|||
if (empty($caid) || !is_numeric($caid)) $this->renderError('请求失败'); |
|||
|
|||
$query_res = pdo_get(PDO_NAME . 'member_thumbs_up_activities', ['mid' => $mid, 'campus_activities_id' => $caid]); |
|||
if ($query_res) { |
|||
$del_res = pdo_delete(PDO_NAME . 'member_thumbs_up_activities',['id' => $query_res['id']]); |
|||
if (!$del_res) $this->renderError('取消点赞失败'); |
|||
$this->renderSuccess('已取消'); |
|||
} |
|||
$data = [ |
|||
'mid' => $mid, |
|||
'campus_activities_id' => $caid, |
|||
'create_time' => time() |
|||
]; |
|||
$result = pdo_insert(PDO_NAME . 'member_thumbs_up_activities', $data); |
|||
if (!$result) $this->renderError('点赞失败'); |
|||
$this->renderSuccess('点赞成功'); |
|||
} |
|||
/** |
|||
* 短信验证码验证 |
|||
* @param $mobile |
|||
* @param $code |
|||
* @return void |
|||
*/ |
|||
private function checkCode($mobile,$code) { |
|||
$pin_info = pdo_get('wlmerchant_pincode' , ['mobile' => $mobile]); |
|||
if (empty($pin_info)) { |
|||
$this->renderError('验证码错误'); |
|||
} |
|||
if ($pin_info['time'] < time() - 300) { |
|||
$this->renderError('验证码已过期,请重新获取'); |
|||
} |
|||
if ($code != $pin_info['code']) $this->renderError('验证码错误'); |
|||
} |
|||
|
|||
/** |
|||
* 编辑-发布校园活动 |
|||
* @return void |
|||
*/ |
|||
public function getCampusActivities() |
|||
{ |
|||
global $_W, $_GPC; |
|||
|
|||
$id = $_GPC['id']; |
|||
$mid = $_W['mid']; |
|||
$member = pdo_get(PDO_NAME . 'member',['id' => $mid],['identity_id','rights']); |
|||
$identity_id = $member['identity_id']; |
|||
if ($identity_id != 7) $this->renderError('非达人身份,无法访问'); |
|||
# 验证用户权限 |
|||
$validateRights = Member::validateMemberRights($mid,'campus_activities',$member); |
|||
if (!$validateRights['status']) $this->renderError($validateRights['msg']); |
|||
$categoryList = Category::getChildCategoryAll(6,['id','name'],true); |
|||
$data = [ |
|||
'id' => '', |
|||
'title' => '', |
|||
'cc_id' => '', |
|||
'describe' => '', |
|||
'promotional_img' => '', |
|||
'status' => 0, |
|||
'reject' => '' |
|||
]; |
|||
if (!empty($id)) { |
|||
$queryRes = pdo_get(PDO_NAME . 'member_campus_activities',['id' => $id],array_keys($data)); |
|||
if (!empty($queryRes)) { |
|||
$data = $queryRes; |
|||
if ($data['status'] != 2) $data['reject'] = ''; |
|||
} |
|||
} |
|||
#unset($data['status']); |
|||
|
|||
$this->renderSuccess('成功',['list' => $data, 'category_list' => $categoryList]); |
|||
} |
|||
|
|||
/** |
|||
* 保存-发布校园活动 |
|||
* @return void |
|||
*/ |
|||
public function publishCampusActivities() |
|||
{ |
|||
global $_W, $_GPC; |
|||
|
|||
$mid = $_W['mid']; |
|||
$id = $_GPC['id']; |
|||
$cc_id = $_GPC['cc_id']; |
|||
$title = trim($_GPC['title']); |
|||
$describe = $_GPC['describe']; |
|||
$promotional_img = trim($_GPC['promotional_img']); |
|||
// 验证必填数据 |
|||
if (empty($title)) $this->renderError('请填写活动标题'); |
|||
if (empty($describe)) $this->renderError('请填写活动内容'); |
|||
if (empty($promotional_img)) $this->renderError('请上传活动宣传图'); |
|||
// 验证数据是否违规 |
|||
$textRes = Filter::init($title,$_W['source'],1); |
|||
if($textRes['errno'] == 0) $this->renderError('活动标题'.$textRes['message']); |
|||
$textRes = Filter::init($describe,$_W['source'],1); |
|||
if($textRes['errno'] == 0) $this->renderError('活动内容'.$textRes['message']); |
|||
$textRes = Filter::init($promotional_img,$_W['source'],2); |
|||
if($textRes['errno'] == 0) $this->renderError('活动宣传图'.$textRes['message']); |
|||
// 验证活动标题是否存在 |
|||
$queryWhere = " title = '{$title}'"; |
|||
$queryWhere .= $id ? " and id != {$id} " : ''; |
|||
$queryRes = pdo_get(PDO_NAME . 'member_campus_activities',$queryWhere,'id'); |
|||
if ($queryRes) $this->renderError('活动标题:'.$title.',已存在'); |
|||
// 新增|修改数据 |
|||
$data = [ |
|||
'uniacid' => $_W['uniacid'], |
|||
'title' => $title, |
|||
'cc_id' => $cc_id, |
|||
'describe' => htmlspecialchars_decode($describe), |
|||
'promotional_img' => $promotional_img |
|||
]; |
|||
if ($id) { |
|||
$data['status'] = 0; |
|||
$data['update_time'] = time(); |
|||
$updateRes = pdo_update(PDO_NAME . 'member_campus_activities',$data,['id' => $id]); |
|||
if (!$updateRes) $this->renderError('提交失败'); |
|||
} else { |
|||
$data['create_place'] = 2; |
|||
$data['create_user_id'] = $mid; |
|||
$data['create_time'] = time(); |
|||
$insertRes = pdo_insert(PDO_NAME . 'member_campus_activities',$data); |
|||
if (!$insertRes) $this->renderError('提交失败'); |
|||
} |
|||
|
|||
$this->renderSuccess('提交成功'); |
|||
} |
|||
} |
|||
@ -0,0 +1,112 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class Cache { |
|||
/** |
|||
* 使用缓存前先查询缓存数据 |
|||
* |
|||
* @access static public |
|||
* @name getDateByCacheFirst |
|||
* @param $key 缓存键 |
|||
* @param $name 缓存名 |
|||
* @param $funcname 方法名 |
|||
* @param $valuearray 方法参数 |
|||
* @return array |
|||
*/ |
|||
static function getDateByCacheFirst($key, $name, $funcname, $valuearray) { |
|||
$data = self::getCache($key, $name); |
|||
if (empty($data)) { |
|||
$data = call_user_func_array($funcname, $valuearray); |
|||
self::setCache($key, $name, $data); |
|||
} |
|||
return $data; |
|||
} |
|||
|
|||
/** |
|||
* @param $key int|string |
|||
* @param $name int|string |
|||
* @return array|bool|false|Memcache|mixed|Redis|string |
|||
*/ |
|||
static function getCache($key, $name) { |
|||
global $_W; |
|||
if (empty($key) || empty($name)) return false; |
|||
|
|||
return cache_read(MODULE_NAME . ':' . $_W['uniacid'] . ':' . $key . ':' . $name); |
|||
} |
|||
|
|||
/** |
|||
* @param $key int|string |
|||
* @param $name int|string |
|||
* @param $value int|string |
|||
* @return array|bool|Memcache|Redis |
|||
*/ |
|||
static function setCache($key, $name, $value) { |
|||
global $_W; |
|||
if (empty($key) || empty($name)) return false; |
|||
|
|||
return cache_write(MODULE_NAME . ':' . $_W['uniacid'] . ':' . $key . ':' . $name, $value); |
|||
} |
|||
|
|||
/** |
|||
* 删除缓存 |
|||
* |
|||
* @access static public |
|||
* @name deleteCache |
|||
* @param $key 缓存键 |
|||
* @param $name 缓存名 |
|||
* @return true|false |
|||
*/ |
|||
static function deleteCache($key, $name) { |
|||
global $_W; |
|||
if (empty($key) || empty($name)) return false; |
|||
|
|||
return cache_delete(MODULE_NAME . ':' . $_W['uniacid'] . ':' . $key . ':' . $name); |
|||
} |
|||
|
|||
/** |
|||
* 删除本模块所有缓存 |
|||
* |
|||
* @access static public |
|||
* @name deleteThisModuleCache |
|||
* @return true|false |
|||
*/ |
|||
static function deleteThisModuleCache() { |
|||
return cache_clean(MODULE_NAME); |
|||
} |
|||
|
|||
/** |
|||
* 写入数据cache锁 |
|||
* |
|||
* @access static public |
|||
* @name setSingleLockByCache |
|||
* @param $arr [tablename][single] |
|||
* @param $time 加锁时间 |
|||
* @return false|true |
|||
*/ |
|||
static function setSingleLockByCache($arr, $time = 15) { |
|||
if ($arr == '' || empty($arr) || $arr['single'] == 'table') return false; |
|||
$tableCache = self::getCache($arr['tablename'], 'table'); |
|||
if (!empty($tableCache) && $tableCache > time()) return false; |
|||
$singleCache = self::getCache($arr['tablename'], $arr['single']); |
|||
if (!empty($singleCache) && $singleCache > time()) return false; |
|||
|
|||
return self::setCache($arr['tablename'], $arr['single'], time() + $time); |
|||
} |
|||
|
|||
/** |
|||
* 写入表cache锁 |
|||
* |
|||
* @access static public |
|||
* @name setTableLockByCache |
|||
* @param $arr [tablename] |
|||
* @param $time 加锁时间 |
|||
* @return false|true |
|||
*/ |
|||
static function setTableLockByCache($arr, $time = 15) { |
|||
if ($arr == '' || empty($arr) || $arr['single'] == 'table') return false; |
|||
$tableCache = self::getCache($arr['tablename'], 'table'); |
|||
if (!empty($tableCache) && $tableCache > time()) return false; |
|||
|
|||
return self::setCache($arr['tablename'], 'table', time() + $time); |
|||
} |
|||
} |
|||
@ -0,0 +1,138 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class FilesHandle { |
|||
|
|||
static function file_copy($fromFile, $toFile) { |
|||
self::file_create_folder($toFile); |
|||
$folder1 = opendir($fromFile); |
|||
while ($f1 = readdir($folder1)) { |
|||
if ($f1 != "." && $f1 != "..") { |
|||
$path2 = "{$fromFile}/{$f1}"; |
|||
if (is_file($path2)) { |
|||
$file = $path2; |
|||
$newfile = "{$toFile}/{$f1}"; |
|||
copy($file, $newfile); |
|||
} elseif (is_dir($path2)) { |
|||
$toFiles = $toFile . '/' . $f1; |
|||
self::file_copy($path2, $toFiles); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
/* |
|||
* 递归创建文件夹 |
|||
*/ |
|||
static function file_create_folder($dir, $mode = 0777) { |
|||
if (is_dir($dir) || @mkdir($dir, $mode)) { |
|||
return true; |
|||
} |
|||
if (!self::file_create_folder(dirname($dir), $mode)) { |
|||
return false; |
|||
} |
|||
return @mkdir($dir, $mode); |
|||
} |
|||
|
|||
//遍历打包文件目录 |
|||
static function file_list_dir($dir) { |
|||
$result = array(); |
|||
if (is_dir($dir)) { |
|||
$file_dir = scandir($dir); |
|||
foreach ($file_dir as $file) { |
|||
if ($file == '.' || $file == '..') { |
|||
continue; |
|||
} elseif (is_dir($dir . $file)) { |
|||
$result = array_merge($result, self::file_list_dir($dir . $file . '/')); |
|||
} else { |
|||
array_push($result, $dir . $file); |
|||
} |
|||
} |
|||
} |
|||
return $result; |
|||
} |
|||
|
|||
//遍历文件目录 |
|||
static function file_tree($path) { |
|||
$files = array(); |
|||
$ds = glob($path . '/*'); |
|||
if (is_array($ds)) { |
|||
foreach ($ds as $entry) { |
|||
if (is_file($entry)) { |
|||
$files[] = $entry; |
|||
} |
|||
if (is_dir($entry)) { |
|||
$rs = self::file_tree($entry); |
|||
foreach ($rs as $f) { |
|||
$files[] = $f; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return $files; |
|||
} |
|||
|
|||
//创建目录 |
|||
static function file_mkdirs($path) { |
|||
if (!is_dir($path)) { |
|||
self::file_mkdirs(dirname($path)); |
|||
mkdir($path); |
|||
} |
|||
return is_dir($path); |
|||
} |
|||
|
|||
//删除文件夹下所有文件 |
|||
static function file_delete_all($path, $delall = '') { |
|||
$op = dir($path); |
|||
while (false != ($item = $op->read())) { |
|||
if ($item == '.' || $item == '..') { |
|||
continue; |
|||
} |
|||
if (is_dir($op->path . '/' . $item)) { |
|||
self::file_delete_all($op->path . '/' . $item); |
|||
rmdir($op->path . '/' . $item); |
|||
} else { |
|||
unlink($op->path . '/' . $item); |
|||
} |
|||
} |
|||
if ($delall == 1) { |
|||
rmdir($path); |
|||
} |
|||
} |
|||
|
|||
//查找目录下所有php文件 |
|||
static function file_findphp($path) { |
|||
$up_filestree = self::file_tree($path); |
|||
|
|||
$upgrade = array(); |
|||
foreach ($up_filestree as $sf) { |
|||
$file_bs = substr($sf, -3); |
|||
if ($file_bs == 'php') { |
|||
$upgrade[] = array('path' => str_replace($path . '/', "", $sf), 'fullpath' => $sf); |
|||
} |
|||
} |
|||
|
|||
return $upgrade; |
|||
} |
|||
|
|||
//删除所有空目录 |
|||
static function file_rm_empty_dir($path) { |
|||
if (is_dir($path) && ($handle = opendir($path)) !== false) { |
|||
while (($file = readdir($handle)) !== false) {// 遍历文件夹 |
|||
if ($file != '.' && $file != '..') { |
|||
$curfile = $path . '/' . $file; |
|||
// 当前目录 |
|||
if (is_dir($curfile)) {// 目录 |
|||
self::file_rm_empty_dir($curfile); |
|||
// 如果是目录则继续遍历 |
|||
if (count(scandir($curfile)) == 2) {//目录为空,=2是因为.和..存在 |
|||
rmdir($curfile); |
|||
// 删除空目录 |
|||
} |
|||
} |
|||
} |
|||
} |
|||
closedir($handle); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,101 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class Func_loader { |
|||
/** |
|||
* static function函数应用 |
|||
* |
|||
* @access public |
|||
* @name core |
|||
* @param $name 函数名称 |
|||
* @return true|false |
|||
*/ |
|||
static function core($name) { |
|||
global $_W; |
|||
if (isset($_W['wlfunc'][$name])) { |
|||
return true; |
|||
} |
|||
$file = PATH_CORE . 'function/' . $name . '.func.php'; |
|||
if (file_exists($file)) { |
|||
include_once $file; |
|||
$_W['wlfunc'][$name] = true; |
|||
return true; |
|||
} else { |
|||
trigger_error('Invalid Helper Function ' . PATH_CORE . 'function/' . $name . '.func.php', E_USER_ERROR); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* static function函数应用 |
|||
* |
|||
* @access public |
|||
* @name web |
|||
* @param $name 函数名称 |
|||
* @return true|false |
|||
*/ |
|||
static function sys($name) { |
|||
global $_W; |
|||
if (isset($_W['wlsys'][$name])) { |
|||
return true; |
|||
} |
|||
$file = PATH_SYS . 'common/' . $name . '.func.php'; |
|||
if (file_exists($file)) { |
|||
include_once $file; |
|||
$_W['wlsys'][$name] = true; |
|||
return true; |
|||
} else { |
|||
trigger_error('Invalid Sys Helper ' . PATH_SYS . 'common/' . $name . '.func.php', E_USER_ERROR); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* static function函数应用 |
|||
* |
|||
* @access public |
|||
* @name web |
|||
* @param $name 函数名称 |
|||
* @return true|false |
|||
*/ |
|||
static function web($name) { |
|||
global $_W; |
|||
if (isset($_W['wlweb'][$name])) { |
|||
return true; |
|||
} |
|||
$file = PATH_WEB . 'common/' . $name . '.func.php'; |
|||
if (file_exists($file)) { |
|||
include_once $file; |
|||
$_W['wlweb'][$name] = true; |
|||
return true; |
|||
} else { |
|||
trigger_error('Invalid Web Helper ' . PATH_WEB . 'common/' . $name . '.func.php', E_USER_ERROR); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* function函数应用 |
|||
* |
|||
* @access public |
|||
* @name app |
|||
* @param $name 函数名称 |
|||
* @return true|false |
|||
*/ |
|||
static function app($name) { |
|||
global $_W; |
|||
if (isset($_W['wlapp'][$name])) { |
|||
return true; |
|||
} |
|||
$file = PATH_APP . 'common/' . $name . '.func.php'; |
|||
if (file_exists($file)) { |
|||
include_once $file; |
|||
$_W['wlapp'][$name] = true; |
|||
return true; |
|||
} else { |
|||
trigger_error('Invalid App Function ' . PATH_APP . 'common/' . $name . '.func.php', E_USER_ERROR); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,97 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
require_once PATH_CORE . "library/querylist/QueryList.class.php"; |
|||
use QL\QueryList; |
|||
|
|||
class GatherArticle { |
|||
|
|||
function get_caiji($url) { |
|||
global $_W; |
|||
load()->func('file'); |
|||
load()->func('communication'); |
|||
//采集规则 |
|||
$html = ihttp_request($url, '', array('CURLOPT_REFERER' => 'http://www.qq.com')); |
|||
// $html = file_get_contents($url); |
|||
$html = str_replace("<!--headTrap<body></body><head></head><html></html>-->", "", $html['content']); |
|||
$reg = array( |
|||
//采集文章标题 |
|||
'title' => array('#activity-name', 'text'), |
|||
//采集文章发布日期,这里用到了QueryList的过滤功能,过滤掉span标签和a标签 |
|||
//采集文章正文内容,利用过滤功能去掉文章中的超链接,但保留超链接的文字,并去掉版权、JS代码等无用信息 |
|||
'content' => array('#js_content', 'html'), |
|||
'nickname' => array('.profile_nickname', 'text'), |
|||
'video' => array('.video_iframe', 'data-src', '', function ($video) { |
|||
$video = explode('vid=', $video); |
|||
$video = explode('&', $video['1']); |
|||
return $video['0']; |
|||
}), |
|||
'logo' => array(':contains(msg_cdn_url)', 'text', '', function ($logo) { |
|||
$logo = explode('var msg_cdn_url = "', $logo); |
|||
$logo = explode('";', $logo['1']); |
|||
$logo = 'web/index.php?c=utility&a=wxcode&do=image&attach=' . $logo['0']; |
|||
return $logo; |
|||
}), |
|||
'desc' => array(':contains(msg_cdn_url)', 'text', '', function ($desc) { |
|||
$desc = explode('var msg_desc = "', $desc); |
|||
$desc = explode('";', $desc['1']); |
|||
return $desc['0']; |
|||
}), |
|||
); |
|||
|
|||
$rang = 'body'; |
|||
$ql = QueryList::Query($html, $reg, $rang, 'UTF-8'); |
|||
|
|||
$con = $ql->getData(); |
|||
$contents = $con['0']['content']; |
|||
//如果出现中文乱码使用下面代码 |
|||
//$getcontent = iconv("gb2312", "utf-8",$contents); |
|||
preg_match_all('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $contents, $match); |
|||
$pic1 = $match['0']; |
|||
$img = $match['2']; |
|||
|
|||
foreach ($pic1 as $key => $value) { |
|||
$url = $value; |
|||
$path = $_W['siteroot'] . 'web/index.php?c=utility&a=wxcode&do=image&attach=' . $img[$key]; |
|||
|
|||
// $imgarr = getimagesize($path); |
|||
// if ($imgarr['0'] > 300 && $imgarr['1'] > 10) { |
|||
// $fileurl = '<img src="' . tomedia($path) . '" width="100%"/>'; |
|||
// } else { |
|||
// $fileurl = '<img src="' . tomedia($path) . '" width="' . $imgarr[0] . '" />'; |
|||
// } |
|||
// if ($imgarr['0'] > 300 && $imgarr['1'] > 200) { |
|||
// if ($key < 4) { |
|||
// $pic .= tomedia($path) . ','; |
|||
// } |
|||
// } |
|||
$fileurl = '<img src="' . tomedia($path) . '" width="' . $imgarr[0] . '" />'; |
|||
$pic .= tomedia($path) . ','; |
|||
$contents = str_replace("{$url}", $fileurl, $contents); |
|||
} |
|||
preg_match_all('/<\s*iframe\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $contents, $match); |
|||
$fs = $match['0']; |
|||
$fskey = $match['2']; |
|||
foreach ($fs as $key => $value) { |
|||
$fileurl = "<iframe border='0' width='100%' height='250' src='http://v.qq.com/iframe/player.html?vid={$con['0']['video']}&tiny=0&auto=0' allowfullscreen></iframe>"; |
|||
$contents = str_replace("$value", $fileurl, $contents); |
|||
} |
|||
$pic = rtrim($pic, ","); |
|||
$pic = explode(",", $pic); |
|||
if (count($pic) == 3) { |
|||
$pic = iserializer($pic); |
|||
} else { |
|||
$pic = null; |
|||
} |
|||
$data = array( |
|||
'title' => $con['0']['title'], |
|||
'contents' => $contents, |
|||
'desc' => $con['0']['desc'], |
|||
'pic' => $pic, |
|||
'vid' => $con['0']['video'], |
|||
'thumb' => $_W['siteroot'] . $con['0']['logo'], |
|||
'nickname' => $con['0']['nickname'] |
|||
); |
|||
|
|||
return $data; |
|||
} |
|||
} |
|||
@ -0,0 +1,271 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class Jurisdiction { |
|||
/** |
|||
* Comment: 需要进行权限管理的菜单的列表 |
|||
* Author: zzw |
|||
* @return array |
|||
*/ |
|||
static public function menuList(){ |
|||
global $_W; |
|||
//列出基本权限 |
|||
$list = [ |
|||
//首页管理 |
|||
'dashboard' => [ |
|||
'title' => '首页管理', |
|||
'list' => [ |
|||
['name' => '运营概况','url' => 'dashboard/dashboard','home'=>'index'], |
|||
['name' => '公告','url' => 'dashboard/notice','home'=>'index'], |
|||
['name' => '幻灯片','url' => 'dashboard/adv','home'=>'index'], |
|||
['name' => '导航栏','url' => 'dashboard/nav','home'=>'index'], |
|||
['name' => '广告栏','url' => 'dashboard/banner','home'=>'index'], |
|||
['name' => '商品魔方','url' => 'dashboard/cube','home'=>'index'], |
|||
['name' => '选项卡管理','url' => 'dashboard/plugin','home'=>'index'], |
|||
['name' => '底部菜单','url' => 'dashboard/foot','home'=>'index'], |
|||
['name' => '页面链接','url' => 'dashboard/pagelinks','home'=>'index'], |
|||
] |
|||
], |
|||
//商户管理 |
|||
'store' => [ |
|||
'title' => '商户管理', |
|||
'list' => [ |
|||
['name' => '商户列表','url' => 'store/merchant','home'=>'index'], |
|||
['name' => '商户分类','url' => 'store/category','home'=>'index'], |
|||
['name' => '入驻申请','url' => 'store/storeApply','home'=>'index'], |
|||
['name' => '付费记录','url' => 'store/register','home'=>'chargerecode'], |
|||
['name' => '入驻套餐','url' => 'store/storeSetMeal','home'=>'chargelist'], |
|||
['name' => '全部评论','url' => 'store/storeComment','home'=>'index'], |
|||
['name' => '商户动态','url' => 'store/storeDynamic','home'=>'dynamic'], |
|||
] |
|||
], |
|||
//订单管理 |
|||
'order' => [ |
|||
'title' => '订单管理', |
|||
'list' => [ |
|||
['name' => '商品订单','url' => 'order/wlOrder','home'=>'orderlist'], |
|||
['name' => '在线买单','url' => 'order/orderPayOnline','home'=>'payonlinelist'], |
|||
['name' => '运费模板','url' => 'order/orderFreightTemplate','home'=>'freightlist'], |
|||
['name' => '售后记录','url' => 'order/orderAfterSales','home'=>'afterlist'], |
|||
] |
|||
], |
|||
//财务管理 |
|||
'finace' => [ |
|||
'title' => '财务管理', |
|||
'list' => [ |
|||
['name' => '账单明细','url' => 'finace/finaceBill','home'=>'cashrecord'], |
|||
['name' => '退款记录','url' => 'finace/finaceRefundRecord','home'=>'refundrecord'], |
|||
['name' => '账户管理','url' => 'finace/newCash','home'=>'currentlist','params'=>['type'=>'store']], |
|||
] |
|||
], |
|||
//数据管理 |
|||
'datacenter' => [ |
|||
'title' => '数据管理', |
|||
'list' => [ |
|||
['name' => '统计管理','url' => 'datacenter/datacenter','home'=>'stat_operate'], |
|||
] |
|||
], |
|||
//应用管理 |
|||
'app' => [ |
|||
'title' => '应用管理', |
|||
'list' => '', |
|||
], |
|||
//设置管理 |
|||
'agentset' => [ |
|||
'title' => '设置管理', |
|||
'list' => [ |
|||
['name' => '员工管理','url' => 'agentset/agentSetStaff','home'=>'adminset'], |
|||
['name' => '社群设置','url' => 'agentset/agentSetCommunity','home'=>'communityList'], |
|||
['name' => '标签设置','url' => 'agentset/agentSetTags','home'=>'tags'], |
|||
['name' => '自定义表单','url' => 'agentset/diyForm','home'=>'index'], |
|||
] |
|||
], |
|||
]; |
|||
//只显示该平台拥有的应用(插件) |
|||
if (agent_p('groupon')) $appList[] = ['name' => '团购活动','url' => 'groupon/active','home'=>'activelist','keyword' => 'groupon']; |
|||
if (agent_p('rush')) $appList[] = ['name' => '抢购活动','url' => 'rush/active','home'=>'activelist','keyword' => 'rush']; |
|||
if (agent_p('wlfightgroup')) $appList[] = ['name' => '拼团商城','url' => 'wlfightgroup/fightgoods','home'=>'ptgoodslist','keyword' => 'wlfightgroup']; |
|||
if (agent_p('bargain')) $appList[] = ['name' => '砍价活动','url' => 'bargain/bargain_web','home'=>'activitylist','keyword' => 'bargain']; |
|||
if (agent_p('paidpromotion')) $appList[] = ['name' => '支付有礼','url' => 'paidpromotion/payactive','home'=>'activelist','keyword' => 'paidpromotion']; |
|||
if (agent_p('pocket')) $appList[] = ['name' => '掌上信息','url' => 'pocket/Tiezi','home'=>'lists','keyword' => 'pocket']; |
|||
if (agent_p('diypage')) $appList[] = ['name' => '平台装修','url' => 'diypage/diy','home'=>'pagelist','keyword' => 'diypage']; |
|||
if (agent_p('wlcoupon')) $appList[] = ['name' => '超级券','url' => 'wlcoupon/couponlist','home'=>'couponsList','keyword' => 'wlcoupon']; |
|||
if (agent_p('call')) $appList[] = ['name' => '集Call','url' => 'call/call','home'=>'callList','keyword' => 'call']; |
|||
if (agent_p('headline')) $appList[] = ['name' => '头条','url' => 'headline/headline','home'=>'infoList','keyword' => 'headline']; |
|||
if (agent_p('citycard')) $appList[] = ['name' => '同城名片','url' => 'citycard/citycard','home'=>'card_lists','keyword' => 'citycard']; |
|||
if (agent_p('salesman')) $appList[] = ['name' => '业务员','url' => 'salesman/salesman','home'=>'lists','keyword' => 'salesman']; |
|||
if (agent_p('yellowpage')) $appList[] = ['name' => '黄页114','url' => 'yellowpage/yellowpage','home'=>'page_lists','keyword' => 'yellowpage']; |
|||
if (agent_p('citydelivery')) $appList[] = ['name' => '同城配送','url' => 'citydelivery/active','home'=>'activelist','keyword' => 'citydelivery']; |
|||
if (agent_p('activity')) $appList[] = ['name' => '同城活动','url' => 'activity/activity_web','home'=>'activitylist','keyword' => 'activity']; |
|||
if (agent_p('redpack')) $appList[] = ['name' => '线上红包','url' => 'redpack/redpack','home'=>'pack_lists','keyword' => 'redpack']; |
|||
if (agent_p('recruit')) $appList[] = ['name' => '求职招聘','url' => 'recruit/industryPosition','home'=>'industryList','keyword' => 'recruit']; |
|||
if (agent_p('dating')) $appList[] = ['name' => '相亲交友','url' => 'dating/member','home'=>'memberList','keyword' => 'dating']; |
|||
if (agent_p('attestation')) $appList[] = ['name' => '认证中心','url' => 'attestation/attestation','home'=>'attestationList','keyword' => 'attestation']; |
|||
if (agent_p('vehicle')) $appList[] = ['name' => '顺风车','url' => 'vehicle/route','home'=>'routeList','keyword' => 'vehicle']; |
|||
if (agent_p('housekeep')) $appList[] = ['name' => '家政服务','url' => 'housekeep/KeepWeb','home'=>'serviceList','keyword' => 'housekeep']; |
|||
if (uniacid_p('housekeep')) $appList[] = ['name' => '票付通','url' => 'pftapimod/basicSetting','home'=>'basicSetting','keyword' => 'pftapimod']; |
|||
//平台管理员信息补充 |
|||
if($_W['aid'] <= 0){ |
|||
//插件权限补充 |
|||
if (uniacid_p('ydbapp')) $appList[] = ['name' => 'APP','url' => 'ydbapp/appset','home'=>'setting']; |
|||
if (uniacid_p('wxplatform')) $appList[] = ['name' => '微信公众号','url' => 'wxplatform/wechat','home'=>'info']; |
|||
if (uniacid_p('wxapp')) $appList[] = ['name' => '微信小程序','url' => 'wxapp/wxappset','home'=>'wxapp_info']; |
|||
if (uniacid_p('payback')) $appList[] = ['name' => 'NEW支付返现','url' => 'payback/payback','home'=>'cashBackRecord']; |
|||
if (uniacid_p('halfcard')) $appList[] = ['name' => '一卡通','url' => 'halfcard/halftype','home'=>'memberlist']; |
|||
if (uniacid_p('cashback')) $appList[] = ['name' => '支付返现','url' => 'cashback/cashback','home'=>'cashBackRecord']; |
|||
if (uniacid_p('subposter')) $appList[] = ['name' => '倡议关注海报','url' => 'subposter/subposter','home'=>'setting']; |
|||
if (uniacid_p('sharegift')) $appList[] = ['name' => '分享有礼','url' => 'sharegift/sharebase','home'=>'sharerecord']; |
|||
if (uniacid_p('ranklist')) $appList[] = ['name' => '排行榜','url' => 'ranklist/rank','home'=>'rank_list']; |
|||
if (uniacid_p('fullreduce')) $appList[] = ['name' => '满减活动','url' => 'fullreduce/fullreduce','home'=>'activelist']; |
|||
if (uniacid_p('consumption')) $appList[] = ['name' => '积分商城','url' => 'consumption/consumptionset','home'=>'consumptionapi']; |
|||
if (uniacid_p('wlsign')) $appList[] = ['name' => '积分签到','url' => 'wlsign/signset','home'=>'signrule']; |
|||
if (uniacid_p('taxipay')) $appList[] = ['name' => '出租车买单','url' => 'taxipay/taxipay','home'=>'master_lists']; |
|||
if (uniacid_p('distribution')) $appList[] = ['name' => '分销合伙人','url' => 'distribution/dissysbase','home'=>'distributorlist']; |
|||
if (uniacid_p('draw')) $appList[] = ['name' => '幸运抽奖','url' => 'draw/draw','home'=>'index']; |
|||
if (uniacid_p('openapi')) $appList[] = ['name' => '开放接口','url' => 'openapi/apilist','home'=>'apimanage']; |
|||
if (uniacid_p('weliam_house')) $appList[] = ['name' => '智慧房产','url' => 'weliam_house/house','home'=>'home']; |
|||
if (uniacid_p('live')) $appList[] = ['name' => '直播管理','url' => 'live/live','home'=>'liveList']; |
|||
if (uniacid_p('helper')) $appList[] = ['name' => '帮助中心','url' => 'helper/helperquestion','home'=>'lists']; |
|||
if (uniacid_p('news')) $appList[] = ['name' => '消息管理','url' => 'news/template','home'=>'index']; |
|||
if (uniacid_p('diyposter')) $appList[] = ['name' => '自定义海报','url' => 'diyposter/poster','home'=>'lists']; |
|||
if (uniacid_p('mobilerecharge')) $appList[] = ['name' => '话费充值','url' => 'mobilerecharge/mrecharge','home'=>'orderList','keyword' => 'mobilerecharge']; |
|||
//商户权限补充 |
|||
$list['store']['list'][] = ['name' => '入驻设置','url' => 'store/settled','home'=>'baseset']; |
|||
$list['store']['list'][] = ['name' => '基本设置','url' => 'store/comment','home'=>'storeSet']; |
|||
//订单权限补充 |
|||
$list['order']['list'][] = ['name' => '订单设置','url' => 'order/orderSet','home'=>'orderset']; |
|||
//财务权限补充 |
|||
$list['finace']['list'][] = ['name' => '提现申请','url' => 'finace/finaceWithdrawalApply','home'=>'cashApply']; |
|||
$list['finace']['list'][] = ['name' => '财务设置','url' => 'finace/wlCash','home'=>'cashset']; |
|||
//设置权限补充 |
|||
$list['agentset']['list'][] = ['name' => '基本设置管理','url' => 'setting/shopset','home'=>'base'];//包括基础设置、客服设置、分享关注、接口设置、文字设置 |
|||
$list['agentset']['list'][] = ['name' => '交易管理','url' => 'setting/settingTransaction','home'=>'recharge']; |
|||
$list['agentset']['list'][] = ['name' => '个人中心','url' => 'agentset/userset','home'=>'userindex']; |
|||
$list['agentset']['list'][] = ['name' => '支付管理','url' => 'setting/pay','home'=>'index']; |
|||
//用户权限补充 |
|||
$list['member'] = [ |
|||
'title' => '客户', |
|||
'list' => [ |
|||
['name' => '客户管理与设置','url' => 'member/wlMember','home'=>'index'], |
|||
['name' => '通信管理','url' => 'member/userIm','home'=>'index'], |
|||
['name' => '客户标签','url' => 'member/userlabel','home'=>'labellist'], |
|||
['name' => '用户财务明细','url' => 'member/memberFinancialDetails','home'=>'recharge'], |
|||
] |
|||
]; |
|||
//代理权限补充 |
|||
if (p('area')) { |
|||
$list['area'] = [ |
|||
'title' => '代理', |
|||
'list' => [ |
|||
['name' => '代理列表&分组','url' => 'area/areaagent','home'=>'agentIndex'], |
|||
['name' => '地区列表&分组','url' => 'area/hotarea','home'=>'oparealist'], |
|||
['name' => '自定义地区','url' => 'area/custom','home'=>'index'], |
|||
['name' => '复制数据','url' => 'area/areadb','home'=>'copydata'], |
|||
['name' => '代理设置','url' => 'area/areaset','home'=>'setting'], |
|||
] |
|||
]; |
|||
} |
|||
}else{ |
|||
//代理商独有权限 |
|||
//财务 |
|||
$list['finace']['list'][] = ['name' => '提现管理','url' => 'finace/finaceWithdrawal','home'=>'cashApply'];//代理商余额提现、提现账户、提现记录 |
|||
//设置 |
|||
$list['agentset']['list'][] = ['name' => '账号信息','url' => 'agentset/agentSetAccount','home'=>'profile']; |
|||
$list['agentset']['list'][] = ['name' => '客服设置','url' => 'agentset/userset','home'=>'agentcustomer']; |
|||
//应用 |
|||
if (p('halfcard')) $appList[] = ['name' => '一卡通','url' => 'halfcard/halfcard_web','home'=>'halfcardList','keyword' => 'halfcard']; |
|||
|
|||
//判断代理是否有插件权限 |
|||
$category = App::get_cate_plugins('agent'); |
|||
$newlist = []; |
|||
foreach ($category as $car){ |
|||
if(!empty($car['plugins'])){ |
|||
foreach ($car['plugins'] as $plu){ |
|||
$newlist[] = $plu['ident']; |
|||
} |
|||
} |
|||
} |
|||
foreach($appList as $ak => $app){ |
|||
if(!in_array($app['keyword'],$newlist)){ |
|||
unset($appList[$ak]); |
|||
} |
|||
} |
|||
} |
|||
|
|||
$list['app']['list'] = $appList; |
|||
return $list; |
|||
} |
|||
/** |
|||
* Comment: 判断代理商员工拥有的主要功能菜单的权限 |
|||
* Author: zzw |
|||
* Date: 2020/12/31 16:23 |
|||
* @param $list |
|||
* @return array|null |
|||
*/ |
|||
static public function judgeMainMenu($list){ |
|||
//获取全部的权限菜单列表 |
|||
$menuList = self::menuList();//获取当前端口需要判断权限的所有菜单 |
|||
$menuListKeys = array_keys($menuList);//需要判断权限的菜单的别名列表 |
|||
$top_menus = is_store() ? Menus_store::topmenus() : (is_agent() ? Menus::topmenus() : Menus_sys::topmenus());//获取当前端口菜单列表 |
|||
$jurisdiction = array_column($top_menus,'jurisdiction');//获取权限别名列表 |
|||
//判断权限 |
|||
foreach($jurisdiction as $index => $item){ |
|||
$pathList = array_column($menuList[$item]['list'], 'url'); |
|||
#当前菜单需要判断权限 并且不存在拥有权限的子菜单 删除当前菜单 |
|||
if(in_array($item,$menuListKeys) && count(array_intersect($pathList,$list)) <= 0){ |
|||
unset($jurisdiction[$index]); |
|||
} |
|||
} |
|||
|
|||
|
|||
return array_values($jurisdiction); |
|||
} |
|||
/** |
|||
* Comment: 员工权限判断 |
|||
* Author: zzw |
|||
* Date: 2021/1/8 15:21 |
|||
*/ |
|||
static public function judge(){ |
|||
global $_W,$_GPC; |
|||
//基本参数信息获取 |
|||
$jurisdiction = $_W['jurisdiction'];//当前员工的权限 |
|||
$pAc = $_GPC['p'].'/'.$_GPC['ac'];//前往页面的路径 |
|||
$permissionList = Jurisdiction::menuList();//所有加入权限控制的控制器列表 |
|||
$infoList = array_column($permissionList,'list');//权限列表 |
|||
$isJurisdiction = $_GPC['is_jurisdiction'] ? : 0;//是否判断权限,用于某些跨控制器跳转使用。1则不判断权限,强制通过 |
|||
//循环获取全部的url信息 |
|||
$urlInfoList = [];//需要权限的全部信息列表 |
|||
foreach($infoList as $listKey => $ListVal){ |
|||
$urlInfoList = array_merge($urlInfoList,$ListVal); |
|||
} |
|||
$_W['JUrlList'] = $urlList = array_column($urlInfoList,'url');//需要权限的全部路径列表 |
|||
//进行员工权限的判断 当:当前gotopath需要权限并且员工拥有该权限才会进入 否则返回上一页面 |
|||
if(in_array($pAc, $urlList) && !in_array($pAc, $jurisdiction) && $isJurisdiction != 1){ |
|||
//没有当前访问方法的权限 进行顺推,查看拥有哪一个的方法进行访问 |
|||
$groupList = $permissionList[$_GPC['p']]['list']; |
|||
$sortList = array_column($groupList,'url'); |
|||
foreach ($sortList as $VisitKey => $VisitVal){ |
|||
if(in_array($VisitVal, $jurisdiction)) { |
|||
//获取以当前路径作为键的新数组 |
|||
$rewardList = array_combine($sortList,$groupList); |
|||
$goToPath = $rewardList[$VisitVal]['url'] . '/' . $rewardList[$VisitVal]['home']; |
|||
header('Location: '.web_url($goToPath,$rewardList[$VisitVal]['params'])); |
|||
die; |
|||
} |
|||
} |
|||
//没有当前访问控制器/模块中任何方法的访问权限 获取第一个拥有权限的页面 |
|||
foreach($urlList as $urlListKey => $urlListVal){ |
|||
if($urlListVal == $jurisdiction[0]){ |
|||
$rewardList = array_combine($urlList,$urlInfoList); |
|||
$goToPath = $rewardList[$urlListVal]['url'] . '/' . $rewardList[$urlListVal]['home']; |
|||
|
|||
header('Location: '.web_url($goToPath,$rewardList[$urlListVal]['params'])); |
|||
die; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class MapService { |
|||
|
|||
/** |
|||
* 获取腾讯地图KEY |
|||
* @return string |
|||
*/ |
|||
private static function get_key() { |
|||
global $_W; |
|||
return empty($_W['wlsetting']['api']['txmapkey']) ? '4PUBZ-I2QCU-5OHV7-2JX2J-4JERZ-UTBQG' : $_W['wlsetting']['api']['txmapkey']; |
|||
} |
|||
|
|||
/** |
|||
* 统一请求函数 |
|||
* @return JSON |
|||
*/ |
|||
private static function get_content($apiurl) { |
|||
$result = ihttp_get($apiurl); |
|||
if ($result['code'] != 200) { |
|||
return error(-1, $result['content']); |
|||
} |
|||
$content = @json_decode($result['content'], true); |
|||
if (!is_array($content)) { |
|||
return error(-1, $result['content']); |
|||
} |
|||
if ($content['status'] != 0) { |
|||
return error($content['status'], $content['message']); |
|||
} |
|||
return $content; |
|||
} |
|||
|
|||
/** |
|||
* 逆地址解析(坐标位置描述)https://lbs.qq.com/webservice_v1/guide-gcoder.html |
|||
* @param $location 位置坐标,格式:location=lat<纬度>,lng<经度> |
|||
* @param $get_poi 是否返回周边POI列表:1.返回;0不返回(默认) |
|||
* @return JSON |
|||
*/ |
|||
static function guide_gcoder($location, $get_poi = 0) { |
|||
if (empty($location)) { |
|||
return error(1, '位置坐标不得为空'); |
|||
} |
|||
$apiurl = 'https://apis.map.qq.com/ws/geocoder/v1/?location=' . $location . '&key=' . self::get_key() . '&get_poi=' . $get_poi; |
|||
return self::get_content($apiurl); |
|||
} |
|||
|
|||
/** |
|||
* 地址搜索https://lbs.qq.com/webservice_v1/guide-search.html |
|||
* @param $keyword POI搜索关键字,用于全文检索字段 |
|||
* @param $boundary 搜索地理范围 |
|||
* @return JSON |
|||
*/ |
|||
static function guide_search($keyword, $boundary) { |
|||
if (empty($keyword)) { |
|||
return error(1, '搜索关键字不得为空'); |
|||
} |
|||
if (empty($boundary)) { |
|||
return error(1, '搜索地理范围不得为空'); |
|||
} |
|||
$apiurl = 'https://apis.map.qq.com/ws/place/v1/search?keyword=' . urlencode($keyword) . '&key=' . self::get_key() . '&boundary=' . $boundary; |
|||
return self::get_content($apiurl); |
|||
} |
|||
|
|||
/** |
|||
* IP定位https://lbs.qq.com/webservice_v1/guide-ip.html |
|||
* @param $ip IP地址,缺省时会使用请求端的IP |
|||
* @return JSON |
|||
*/ |
|||
static function guide_ip($ip) { |
|||
if (empty($ip)) { |
|||
return error(1, 'IP地址不得为空'); |
|||
} |
|||
$apiurl = 'https://apis.map.qq.com/ws/location/v1/ip?ip=' . $ip . '&key=' . self::get_key(); |
|||
return self::get_content($apiurl); |
|||
} |
|||
} |
|||
@ -0,0 +1,574 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class Menus { |
|||
|
|||
public static function __callStatic($method, $arg) { |
|||
global $_W, $_GPC; |
|||
$method = substr($method, 3, -6); |
|||
$config = App::ext_plugin_config($method); |
|||
if (empty($config['menus']) || $config['setting']['agent'] != 'true') { |
|||
wl_message('您访问的应用不存在,请重试!'); |
|||
} |
|||
return $config['menus']; |
|||
} |
|||
|
|||
/** |
|||
* static function函数应用 |
|||
* |
|||
* @access static |
|||
* @name _calc_current_frames2 函数名称 |
|||
* @param $frames |
|||
* @return array |
|||
*/ |
|||
static function _calc_current_frames2(&$frames) { |
|||
global $_W, $_GPC; |
|||
if (!empty($frames) && is_array($frames)) { |
|||
foreach ($frames as &$frame) { |
|||
foreach ($frame['items'] as &$fr) { |
|||
if (count($fr['actions']) == 2) { |
|||
if (is_array($fr['actions']['1'])) { |
|||
$fr['active'] = in_array($_GPC[$fr['actions']['0']], $fr['actions']['1']) ? 'active' : ''; |
|||
} else { |
|||
if ($fr['actions']['1'] == $_GPC[$fr['actions']['0']]) { |
|||
$fr['active'] = 'active'; |
|||
} |
|||
} |
|||
} elseif (count($fr['actions']) == 3) { |
|||
if (($fr['actions']['1'] == $_GPC[$fr['actions']['0']] || @in_array($_GPC[$fr['actions']['0']], $fr['actions']['1'])) && ($fr['actions']['2'] == $_GPC['do'] || @in_array($_GPC['do'], $fr['actions']['2']))) { |
|||
$fr['active'] = 'active'; |
|||
} |
|||
} elseif (count($fr['actions']) == 4) { |
|||
if (($fr['actions']['1'] == $_GPC[$fr['actions']['0']] || @in_array($_GPC[$fr['actions']['0']], $fr['actions']['1'])) && ($fr['actions']['3'] == $_GPC[$fr['actions']['2']] || @in_array($_GPC[$fr['actions']['2']], $fr['actions']['3']))) { |
|||
$fr['active'] = 'active'; |
|||
} |
|||
} elseif (count($fr['actions']) == 5) { |
|||
if ($fr['actions']['1'] == $_GPC[$fr['actions']['0']] && $fr['actions']['3'] == $_GPC[$fr['actions']['2']] && $fr['actions']['4'] == $_GPC['status']) { |
|||
$fr['active'] = 'active'; |
|||
} |
|||
} else { |
|||
$query = parse_url($fr['url'], PHP_URL_QUERY); |
|||
parse_str($query, $urls); |
|||
if (defined('ACTIVE_FRAME_URL')) { |
|||
$query = parse_url(ACTIVE_FRAME_URL, PHP_URL_QUERY); |
|||
parse_str($query, $get); |
|||
} else { |
|||
$get = $_GET; |
|||
} |
|||
if (!empty($_GPC['a'])) { |
|||
$get['a'] = $_GPC['a']; |
|||
} |
|||
if (!empty($_GPC['c'])) { |
|||
$get['c'] = $_GPC['c']; |
|||
} |
|||
if (!empty($_GPC['do'])) { |
|||
$get['do'] = $_GPC['do']; |
|||
} |
|||
if (!empty($_GPC['ac'])) { |
|||
$get['ac'] = $_GPC['ac']; |
|||
} |
|||
if (!empty($_GPC['status'])) { |
|||
$get['status'] = $_GPC['status']; |
|||
} |
|||
if (!empty($_GPC['p'])) { |
|||
$get['p'] = $_GPC['p']; |
|||
} |
|||
if (!empty($_GPC['op'])) { |
|||
$get['op'] = $_GPC['op']; |
|||
} |
|||
if (!empty($_GPC['m'])) { |
|||
$get['m'] = $_GPC['m']; |
|||
} |
|||
$diff = array_diff_assoc($urls, $get); |
|||
|
|||
if (empty($diff)) { |
|||
$fr['active'] = 'active'; |
|||
} else { |
|||
$fr['active'] = ''; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* static function 顶部列表 |
|||
* |
|||
* @access static |
|||
* @name topmenus |
|||
* @param |
|||
* @return array |
|||
*/ |
|||
static function topmenus() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$appact = Util::traversingFiles(PATH_PLUGIN); |
|||
$appact[] = 'app'; |
|||
$appact[] = 'goodshouse'; |
|||
|
|||
$frames['dashboard']['title'] = '<i class="fa fa-desktop"></i> 平台'; |
|||
$frames['dashboard']['url'] = web_url('dashboard/dashboard'); |
|||
$frames['dashboard']['active'] = 'dashboard'; |
|||
$frames['dashboard']['jurisdiction'] = 'dashboard'; |
|||
|
|||
if (file_exists(PATH_MODULE . 'jimaiwang.log')) { |
|||
$frames['member']['title'] = '<i class="fa fa-user"></i> 客户'; |
|||
$frames['member']['url'] = web_url('member/wlMember/index'); |
|||
$frames['member']['active'] = 'member'; |
|||
} |
|||
|
|||
$frames['store']['title'] = '<i class="fa fa-users"></i> 商户'; |
|||
$frames['store']['url'] = web_url('store/merchant/index', array('enabled' => '')); |
|||
$frames['store']['active'] = 'store'; |
|||
$frames['store']['jurisdiction'] = 'store'; |
|||
|
|||
// $frames['goods']['title'] = '<i class="fa fa-users"></i> 商品'; |
|||
// $frames['goods']['url'] = web_url('goods/Goods/index'); |
|||
// $frames['goods']['active'] = 'goods'; |
|||
// $frames['goods']['jurisdiction'] = 'goods'; |
|||
|
|||
$frames['order']['title'] = '<i class="fa fa-list"></i> 订单'; |
|||
$frames['order']['url'] = web_url('order/wlOrder/orderlist'); |
|||
$frames['order']['active'] = 'order'; |
|||
$frames['order']['jurisdiction'] = 'order'; |
|||
|
|||
$frames['finance']['title'] = '<i class="fa fa-money"></i> 财务'; |
|||
$frames['finance']['url'] = web_url('finace/finaceBill/cashrecord'); |
|||
$frames['finance']['active'] = 'finace'; |
|||
$frames['finance']['jurisdiction'] = 'finace'; |
|||
|
|||
$frames['data']['title'] = '<i class="fa fa-bar-chart"></i> 数据'; |
|||
$frames['data']['url'] = web_url('datacenter/datacenter/stat_operate'); |
|||
$frames['data']['active'] = 'datacenter'; |
|||
$frames['data']['jurisdiction'] = 'datacenter'; |
|||
|
|||
$frames['app']['title'] = '<i class="fa fa-cubes"></i> 应用'; |
|||
$frames['app']['url'] = web_url('app/plugins'); |
|||
$frames['app']['active'] = $appact; |
|||
$frames['app']['jurisdiction'] = 'app'; |
|||
|
|||
$frames['setting']['title'] = '<i class="fa fa-gear"></i> 设置'; |
|||
$frames['setting']['url'] = web_url('agentset/agentSetAccount/profile'); |
|||
$frames['setting']['active'] = 'agentset'; |
|||
$frames['setting']['jurisdiction'] = 'agentset'; |
|||
|
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
/** |
|||
* static function 首页左侧列表 |
|||
* |
|||
* @access static |
|||
* @name getdashboardFrames |
|||
* @param |
|||
* @return array |
|||
*/ |
|||
static function getdashboardFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$frames['member']['title'] = '<i class="fa fa-dashboard"></i> 概况'; |
|||
$frames['member']['items'] = array(); |
|||
|
|||
$frames['member']['items']['setting']['url'] = web_url('dashboard/dashboard/index'); |
|||
$frames['member']['items']['setting']['title'] = '运营概况'; |
|||
$frames['member']['items']['setting']['actions'] = array('ac', 'dashboard'); |
|||
$frames['member']['items']['setting']['active'] = ''; |
|||
|
|||
$frames['page']['title'] = '<i class="fa fa-inbox"></i> 主页管理'; |
|||
$frames['page']['items'] = array(); |
|||
$frames['page']['items']['notice']['url'] = web_url('dashboard/notice/index'); |
|||
$frames['page']['items']['notice']['title'] = '公告'; |
|||
$frames['page']['items']['notice']['actions'] = array('ac', 'notice'); |
|||
$frames['page']['items']['notice']['active'] = ''; |
|||
|
|||
$frames['page']['items']['adv']['url'] = web_url('dashboard/adv/index'); |
|||
$frames['page']['items']['adv']['title'] = '幻灯片'; |
|||
$frames['page']['items']['adv']['actions'] = array('ac', 'adv'); |
|||
$frames['page']['items']['adv']['active'] = ''; |
|||
|
|||
$frames['page']['items']['nav']['url'] = web_url('dashboard/nav/index'); |
|||
$frames['page']['items']['nav']['title'] = '导航栏'; |
|||
$frames['page']['items']['nav']['actions'] = array('ac', 'nav'); |
|||
$frames['page']['items']['nav']['active'] = ''; |
|||
|
|||
$frames['page']['items']['banner']['url'] = web_url('dashboard/banner/index'); |
|||
$frames['page']['items']['banner']['title'] = '广告栏'; |
|||
$frames['page']['items']['banner']['actions'] = array('ac', 'banner'); |
|||
$frames['page']['items']['banner']['active'] = ''; |
|||
|
|||
$frames['page']['items']['cube']['url'] = web_url('dashboard/cube/index'); |
|||
$frames['page']['items']['cube']['title'] = '商品魔方'; |
|||
$frames['page']['items']['cube']['actions'] = array('ac', 'cube'); |
|||
$frames['page']['items']['cube']['active'] = ''; |
|||
|
|||
// $frames['page']['items']['sort']['url'] = web_url('dashboard/sort/index'); |
|||
// $frames['page']['items']['sort']['title'] = '主页排版'; |
|||
// $frames['page']['items']['sort']['actions'] = array(); |
|||
// $frames['page']['items']['sort']['active'] = ''; |
|||
|
|||
$frames['page']['items']['plugin']['url'] = web_url('dashboard/plugin/index'); |
|||
$frames['page']['items']['plugin']['title'] = '选项卡管理'; |
|||
$frames['page']['items']['plugin']['actions'] = array('ac', 'plugin'); |
|||
$frames['page']['items']['plugin']['active'] = ''; |
|||
|
|||
$frames['page']['items']['foot']['url'] = web_url('dashboard/foot/index'); |
|||
$frames['page']['items']['foot']['title'] = '底部菜单'; |
|||
$frames['page']['items']['foot']['actions'] = array('ac', 'foot'); |
|||
$frames['page']['items']['foot']['active'] = ''; |
|||
|
|||
$frames['other']['title'] = '<i class="fa fa-inbox"></i> 其他信息'; |
|||
$frames['other']['items'] = array(); |
|||
$frames['other']['items']['notice']['url'] = web_url('dashboard/pagelinks/index'); |
|||
$frames['other']['items']['notice']['title'] = '页面链接'; |
|||
$frames['other']['items']['notice']['actions'] = array('ac', 'pagelinks'); |
|||
$frames['other']['items']['notice']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getmemberFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$frames['user']['title'] = '<i class="fa fa-inbox"></i> 客户'; |
|||
$frames['user']['items'] = array(); |
|||
|
|||
$frames['user']['items']['register']['url'] = web_url('member/wlMember/index'); |
|||
$frames['user']['items']['register']['title'] = '客户概况'; |
|||
$frames['user']['items']['register']['actions'] = array('ac', 'wlMember', 'do', 'index'); |
|||
$frames['user']['items']['register']['active'] = ''; |
|||
|
|||
$frames['user']['items']['notice']['url'] = web_url('member/wlMember/memberIndex'); |
|||
$frames['user']['items']['notice']['title'] = '客户列表'; |
|||
$frames['user']['items']['notice']['actions'] = array('ac', 'wlMember', 'do', array('memberIndex', 'memberDetail')); |
|||
$frames['user']['items']['notice']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getfinaceFrames() { |
|||
global $_W, $_GPC; |
|||
$frames = array(); |
|||
|
|||
$frames['cashSurvey']['title'] = '<i class="fa fa-database"></i> 财务'; |
|||
$frames['cashSurvey']['items'] = array(); |
|||
|
|||
// $frames['cashSurvey']['items']['datemana']['url'] = web_url('finace/wlCash/cashSurvey'); |
|||
// $frames['cashSurvey']['items']['datemana']['title'] = '财务概况'; |
|||
// $frames['cashSurvey']['items']['datemana']['actions'] = array(); |
|||
// $frames['cashSurvey']['items']['datemana']['active'] = ''; |
|||
|
|||
$frames['cashSurvey']['items']['cashrecord']['url'] = web_url('finace/finaceBill/cashrecord'); |
|||
$frames['cashSurvey']['items']['cashrecord']['title'] = '账单明细'; |
|||
$frames['cashSurvey']['items']['cashrecord']['actions'] = array(); |
|||
$frames['cashSurvey']['items']['cashrecord']['active'] = ''; |
|||
|
|||
$frames['cashSurvey']['items']['refundrecord']['url'] = web_url('finace/finaceRefundRecord/refundrecord'); |
|||
$frames['cashSurvey']['items']['refundrecord']['title'] = '退款记录'; |
|||
$frames['cashSurvey']['items']['refundrecord']['actions'] = array(); |
|||
$frames['cashSurvey']['items']['refundrecord']['active'] = ''; |
|||
|
|||
$frames['cashApplyAgent']['title'] = '<i class="fa fa-globe"></i> 提现'; |
|||
$frames['cashApplyAgent']['items'] = array(); |
|||
|
|||
$frames['cashApplyAgent']['items']['display1']['url'] = web_url('finace/finaceWithdrawal/cashApplyAgent', array('status' => '1')); |
|||
$frames['cashApplyAgent']['items']['display1']['title'] = '余额提现'; |
|||
$frames['cashApplyAgent']['items']['display1']['actions'] = array('do', 'cashApplyAgent', 'status', '1'); |
|||
$frames['cashApplyAgent']['items']['display1']['active'] = ''; |
|||
|
|||
$frames['cashApplyAgent']['items']['account']['url'] = web_url('finace/finaceWithdrawal/account'); |
|||
$frames['cashApplyAgent']['items']['account']['title'] = '提现账户'; |
|||
$frames['cashApplyAgent']['items']['account']['actions'] = array(); |
|||
$frames['cashApplyAgent']['items']['account']['active'] = ''; |
|||
|
|||
$frames['cashApplyAgent']['items']['display2']['url'] = web_url('finace/finaceWithdrawal/cashApplyAgentRecord'); |
|||
$frames['cashApplyAgent']['items']['display2']['title'] = '提现记录'; |
|||
$frames['cashApplyAgent']['items']['display2']['actions'] = array('do', 'cashApplyAgentRecord'); |
|||
$frames['cashApplyAgent']['items']['display2']['active'] = ''; |
|||
|
|||
if($_W['wlsetting']['cashset']['allocationtype']>0) { |
|||
$frames['cashAll']['title'] = '<i class="fa fa-globe"></i> 分账'; |
|||
$frames['cashAll']['items'] = array(); |
|||
|
|||
$frames['cashAll']['items']['allidset']['url'] = web_url('finace/wlCash/allidset'); |
|||
$frames['cashAll']['items']['allidset']['title'] = '账户设置'; |
|||
$frames['cashAll']['items']['allidset']['actions'] = array('do', 'allidset'); |
|||
$frames['cashAll']['items']['allidset']['active'] = ''; |
|||
|
|||
} |
|||
|
|||
$frames['current']['title'] = '<i class="fa fa-globe"></i> 账户'; |
|||
$frames['current']['items'] = array(); |
|||
|
|||
$frames['current']['items']['currentstore']['url'] = web_url('finace/newCash/currentlist', array('type' => 'store')); |
|||
$frames['current']['items']['currentstore']['title'] = '商家账户'; |
|||
$frames['current']['items']['currentstore']['actions'] = array('type', 'store'); |
|||
$frames['current']['items']['currentstore']['active'] = ''; |
|||
|
|||
$frames['current']['items']['currentmy']['url'] = web_url('finace/newCash/currentlist', array('type' => 'agent')); |
|||
$frames['current']['items']['currentmy']['title'] = '我的账户'; |
|||
$frames['current']['items']['currentmy']['actions'] = array('type', 'agent'); |
|||
$frames['current']['items']['currentmy']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
/** |
|||
* static function 商户左侧列表 |
|||
* |
|||
* @access static |
|||
* @name getstoreFrames |
|||
* @param |
|||
* @return array |
|||
*/ |
|||
static function getstoreFrames() { |
|||
global $_W, $_GPC; |
|||
$frames = array(); |
|||
|
|||
$frames['user']['title'] = '<i class="fa fa-inbox"></i> 商户管理'; |
|||
$frames['user']['items'] = array(); |
|||
$frames['user']['items']['index']['url'] = web_url('store/merchant/index', array('enabled' => '')); |
|||
$frames['user']['items']['index']['title'] = '商户列表'; |
|||
$frames['user']['items']['index']['actions'] = array('ac', 'merchant'); |
|||
$frames['user']['items']['index']['active'] = ''; |
|||
|
|||
$frames['user']['items']['category']['url'] = web_url('store/category/index'); |
|||
$frames['user']['items']['category']['title'] = '商户分类'; |
|||
$frames['user']['items']['category']['actions'] = array('ac', 'category'); |
|||
$frames['user']['items']['category']['active'] = ''; |
|||
|
|||
$frames['register']['title'] = '<i class="fa fa-globe"></i> 入驻管理'; |
|||
$frames['register']['items'] = array(); |
|||
$frames['register']['items']['register']['url'] = web_url('store/storeApply/index'); |
|||
$frames['register']['items']['register']['title'] = '入驻申请'; |
|||
$frames['register']['items']['register']['actions'] = array('ac', 'storeApply', 'do', 'index'); |
|||
$frames['register']['items']['register']['active'] = ''; |
|||
|
|||
if ($_W['wlsetting']['register']['chargestatus']) { |
|||
$frames['register']['items']['chargerecode']['url'] = web_url('store/register/chargerecode'); |
|||
$frames['register']['items']['chargerecode']['title'] = '付费记录'; |
|||
$frames['register']['items']['chargerecode']['actions'] = array('ac', 'storeApply', 'do', 'chargerecode'); |
|||
$frames['register']['items']['chargerecode']['active'] = ''; |
|||
} |
|||
|
|||
if ($_W['wlsetting']['register']['agentright']) { |
|||
$frames['register']['items']['agentcharge']['url'] = web_url('store/storeSetMeal/chargelist'); |
|||
$frames['register']['items']['agentcharge']['title'] = '入驻套餐'; |
|||
$frames['register']['items']['agentcharge']['actions'] = array('ac', 'storeSetMeal', 'do', array('chargelist', 'add')); |
|||
$frames['register']['items']['agentcharge']['active'] = ''; |
|||
} |
|||
|
|||
$frames['comment']['title'] = '<i class="fa fa-inbox"></i> 评论与动态'; |
|||
$frames['comment']['items'] = array(); |
|||
$frames['comment']['items']['comment']['url'] = web_url('store/storeComment/index'); |
|||
$frames['comment']['items']['comment']['title'] = '全部评论'; |
|||
$frames['comment']['items']['comment']['actions'] = array('ac', 'storeComment', 'do', 'index'); |
|||
$frames['comment']['items']['comment']['active'] = ''; |
|||
|
|||
$frames['comment']['items']['dynamic']['url'] = web_url('store/storeDynamic/dynamic'); |
|||
$frames['comment']['items']['dynamic']['title'] = '商户动态'; |
|||
$frames['comment']['items']['dynamic']['actions'] = array('ac', 'storeDynamic', 'do', 'dynamic'); |
|||
$frames['comment']['items']['dynamic']['active'] = ''; |
|||
|
|||
// $frames['setting']['title'] = '<i class="fa fa-inbox"></i> 商户设置'; |
|||
// $frames['setting']['items'] = array(); |
|||
// $frames['setting']['items']['setting']['url'] = web_url('store/comment/storeSet'); |
|||
// $frames['setting']['items']['setting']['title'] = '基本设置'; |
|||
// $frames['setting']['items']['setting']['actions'] = array('ac', 'comment', 'do', 'index'); |
|||
// $frames['setting']['items']['setting']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
/** |
|||
* static function 订单左侧列表 |
|||
* |
|||
* @access static |
|||
* @name getorderFrames |
|||
* @param |
|||
* @return array |
|||
*/ |
|||
static function getorderFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$frames['order']['title'] = '<i class="fa fa-inbox"></i> 订单'; |
|||
$frames['order']['items'] = array(); |
|||
|
|||
$frames['order']['items']['orderlist']['url'] = web_url('order/wlOrder/orderlist'); |
|||
$frames['order']['items']['orderlist']['title'] = '商品订单'; |
|||
$frames['order']['items']['orderlist']['actions'] = array('ac', 'wlOrder', 'do', array('orderlist', 'orderdetail')); |
|||
$frames['order']['items']['orderlist']['active'] = ''; |
|||
|
|||
$frames['order']['items']['payonlinelist']['url'] = web_url('order/orderPayOnline/payonlinelist'); |
|||
$frames['order']['items']['payonlinelist']['title'] = '在线买单'; |
|||
$frames['order']['items']['payonlinelist']['actions'] = array('ac', 'orderPayOnline', 'do', 'payonlinelist'); |
|||
$frames['order']['items']['payonlinelist']['active'] = ''; |
|||
|
|||
$frames['freight']['title'] = '<i class="fa fa-inbox"></i> 运费'; |
|||
$frames['freight']['items'] = array(); |
|||
|
|||
$frames['freight']['items']['freightlist']['url'] = web_url('order/orderFreightTemplate/freightlist'); |
|||
$frames['freight']['items']['freightlist']['title'] = '运费模板'; |
|||
$frames['freight']['items']['freightlist']['actions'] = array('ac', 'orderFreightTemplate', 'do', 'freightlist'); |
|||
$frames['freight']['items']['freightlist']['active'] = ''; |
|||
|
|||
$frames['saleafter']['title'] = '<i class="fa fa-inbox"></i> 预约售后'; |
|||
$frames['saleafter']['items'] = array(); |
|||
|
|||
$frames['saleafter']['items']['afterlist']['url'] = web_url('order/orderAfterSales/afterlist'); |
|||
$frames['saleafter']['items']['afterlist']['title'] = '售后记录'; |
|||
$frames['saleafter']['items']['afterlist']['actions'] = array('ac', 'orderAfterSales', 'do', 'afterlist'); |
|||
$frames['saleafter']['items']['afterlist']['active'] = ''; |
|||
|
|||
$frames['saleafter']['items']['appointlist']['url'] = web_url('order/wlOrder/appointlist'); |
|||
$frames['saleafter']['items']['appointlist']['title'] = '预约记录'; |
|||
$frames['saleafter']['items']['appointlist']['actions'] = array('ac', 'wlOrder', 'do', 'appointlist'); |
|||
$frames['saleafter']['items']['appointlist']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getdatacenterFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
|
|||
$frames['datacenter']['title'] = '<i class="fa fa-inbox"></i> 统计分析'; |
|||
$frames['datacenter']['items'] = array(); |
|||
$frames['datacenter']['items']['stat_operate']['url'] = web_url('datacenter/datacenter/stat_operate'); |
|||
$frames['datacenter']['items']['stat_operate']['title'] = '运营统计'; |
|||
$frames['datacenter']['items']['stat_operate']['actions'] = array(); |
|||
$frames['datacenter']['items']['stat_operate']['active'] = ''; |
|||
|
|||
$frames['datacenter']['items']['stat_store']['url'] = web_url('datacenter/datacenter/stat_store'); |
|||
$frames['datacenter']['items']['stat_store']['title'] = '店铺统计'; |
|||
$frames['datacenter']['items']['stat_store']['actions'] = array(); |
|||
$frames['datacenter']['items']['stat_store']['active'] = ''; |
|||
|
|||
if (file_exists(PATH_MODULE . 'TnSrtWDJ.log')) { |
|||
$frames['datacenter']['items']['stat_store_card']['url'] = web_url('datacenter/datacenter/stat_store_card'); |
|||
$frames['datacenter']['items']['stat_store_card']['title'] = '商户会员'; |
|||
$frames['datacenter']['items']['stat_store_card']['actions'] = array(); |
|||
$frames['datacenter']['items']['stat_store_card']['active'] = ''; |
|||
} |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
/** |
|||
* static function 应用左侧列表 |
|||
* |
|||
* @access static |
|||
* @name getappFrames |
|||
* @param |
|||
* @return array |
|||
*/ |
|||
static function getappFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
|
|||
$category = App::get_cate_plugins('agent'); |
|||
foreach ($category as $key => $value) { |
|||
if (!empty($value['plugins'])) { |
|||
$frames[$key]['title'] = '<i class="fa fa-inbox"></i> ' . $value['name']; |
|||
$frames[$key]['items'] = array(); |
|||
foreach ($value['plugins'] as $pk => $plug) { |
|||
$frames[$key]['items'][$plug['ident']]['url'] = $plug['cover']; |
|||
$frames[$key]['items'][$plug['ident']]['title'] = $plug['name']; |
|||
$frames[$key]['items'][$plug['ident']]['actions'] = array('ac', $plug['ident']); |
|||
$frames[$key]['items'][$plug['ident']]['active'] = ''; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
/** |
|||
* static function 应用左侧列表 |
|||
* |
|||
* @access static |
|||
* @name getappFrames |
|||
* @param |
|||
* @return array |
|||
*/ |
|||
static function getgoodshouseFrames() { |
|||
global $_W, $_GPC; |
|||
$method = $_GPC['plugin'] ?: 'rush'; |
|||
$method = ($method != 'fightgroup') ? $method : 'wlfightgroup'; |
|||
$config = App::ext_plugin_config($method); |
|||
|
|||
return $config['menus']; |
|||
} |
|||
|
|||
static function getagentsetFrames() { |
|||
global $_W, $_GPC; |
|||
$frames = array(); |
|||
$frames['setting']['title'] = '<i class="fa fa-globe"></i> 设置'; |
|||
$frames['setting']['items'] = array(); |
|||
$frames['setting']['items']['base']['url'] = web_url('agentset/agentSetAccount/profile'); |
|||
$frames['setting']['items']['base']['title'] = '账号信息'; |
|||
$frames['setting']['items']['base']['actions'] = array('ac', 'agentSetAccount', 'do', 'profile'); |
|||
$frames['setting']['items']['base']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['share']['url'] = web_url('agentset/agentSetAccount/shareSet'); |
|||
$frames['setting']['items']['share']['title'] = '分享设置'; |
|||
$frames['setting']['items']['share']['actions'] = array('ac', 'agentSetAccount', 'do', 'shareSet'); |
|||
$frames['setting']['items']['share']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['adminset']['url'] = web_url('agentset/agentSetStaff/adminset'); |
|||
$frames['setting']['items']['adminset']['title'] = '员工管理'; |
|||
$frames['setting']['items']['adminset']['actions'] = array('ac', 'agentSetStaff', 'do', 'adminset'); |
|||
$frames['setting']['items']['adminset']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['community']['url'] = web_url('agentset/agentSetCommunity/communityList'); |
|||
$frames['setting']['items']['community']['title'] = '社群设置'; |
|||
$frames['setting']['items']['community']['actions'] = array('ac', 'agentSetCommunity', 'do', 'communityList'); |
|||
$frames['setting']['items']['community']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['tags']['url'] = web_url('agentset/agentSetTags/tags'); |
|||
$frames['setting']['items']['tags']['title'] = '标签设置'; |
|||
$frames['setting']['items']['tags']['actions'] = array('ac', 'agentSetTags', 'do', 'tags'); |
|||
$frames['setting']['items']['tags']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['customer']['url'] = web_url('agentset/userset/agentcustomer'); |
|||
$frames['setting']['items']['customer']['title'] = '客服设置'; |
|||
$frames['setting']['items']['customer']['actions'] = array('ac', 'userset', 'do', 'agentcustomer'); |
|||
$frames['setting']['items']['customer']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['divform']['url'] = web_url('agentset/diyForm/index'); |
|||
$frames['setting']['items']['divform']['title'] = '自定义表单'; |
|||
$frames['setting']['items']['divform']['actions'] = ['ac' , 'diyForm' , 'do' , ['index' ,'add', 'edit']]; |
|||
$frames['setting']['items']['divform']['active'] = ''; |
|||
|
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 商品左侧菜单列表 |
|||
* Author: zzw |
|||
* Date: 2019/7/3 18:30 |
|||
*/ |
|||
static function getgoodsFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$frames['goods']['title'] = '<i class="fa fa-dashboard"></i> 商品管理'; |
|||
$frames['goods']['items'] = array(); |
|||
|
|||
$frames['goods']['items']['list']['url'] = web_url('goods/Goods/index'); |
|||
$frames['goods']['items']['list']['title'] = '商品列表'; |
|||
$frames['goods']['items']['list']['actions'] = array('ac', 'Goods', 'do', 'index'); |
|||
$frames['goods']['items']['list']['active'] = ''; |
|||
|
|||
$frames['goods']['items']['cate']['url'] = web_url('goods/Goods/category'); |
|||
$frames['goods']['items']['cate']['title'] = '商品分类'; |
|||
$frames['goods']['items']['cate']['actions'] = array('ac', 'Goods', 'do', 'category'); |
|||
$frames['goods']['items']['cate']['active'] = ''; |
|||
|
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,274 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class Menus_store extends Menus { |
|||
|
|||
public static function __callStatic($method, $arg) { |
|||
global $_W, $_GPC; |
|||
$method = substr($method, 3, -6); |
|||
$config = App::ext_plugin_config($method); |
|||
if (empty($config['menus']) || $config['setting']['agent'] != 'true') { |
|||
wl_message('您访问的应用不存在,请重试!'); |
|||
} |
|||
$perms = $_W['authority']; |
|||
if(!empty($perms)){ |
|||
if(!in_array('halfcard',$perms)){ |
|||
unset($config['menus']['halfcard0']['items']['halfcard_webeditHalfcard']); |
|||
} |
|||
if(!in_array('package',$perms)){ |
|||
unset($config['menus']['halfcard0']['items']['halfcard_webpackagelist']); |
|||
} |
|||
} |
|||
return $config['menus']; |
|||
} |
|||
|
|||
static function topmenus() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$appact = Util::traversingFiles(PATH_PLUGIN); |
|||
$appact[] = 'app'; |
|||
$appact[] = 'goodshouse'; |
|||
|
|||
$frames['dashboard']['title'] = '<i class="fa fa-desktop"></i> 概况'; |
|||
$frames['dashboard']['url'] = web_url('dashboard/dashboard'); |
|||
$frames['dashboard']['active'] = 'dashboard'; |
|||
$frames['dashboard']['jurisdiction'] = 'dashboard'; |
|||
|
|||
$frames['order']['title'] = '<i class="fa fa-list"></i> 订单'; |
|||
$frames['order']['url'] = web_url('order/wlOrder/orderlist'); |
|||
$frames['order']['active'] = 'order'; |
|||
$frames['order']['jurisdiction'] = 'order'; |
|||
|
|||
$frames['finance']['title'] = '<i class="fa fa-money"></i> 财务'; |
|||
$frames['finance']['url'] = web_url('finace/newCash/currentlist',array('type'=>'store')); |
|||
$frames['finance']['active'] = 'finace'; |
|||
$frames['finance']['jurisdiction'] = 'finace'; |
|||
|
|||
$frames['data']['title'] = '<i class="fa fa-bar-chart"></i> 数据'; |
|||
$frames['data']['url'] = web_url('datacenter/datacenter/stat_operate'); |
|||
$frames['data']['active'] = 'datacenter'; |
|||
$frames['data']['jurisdiction'] = 'datacenter'; |
|||
|
|||
$frames['app']['title'] = '<i class="fa fa-cubes"></i> 营销'; |
|||
$frames['app']['url'] = web_url('app/plugins'); |
|||
$frames['app']['active'] = $appact; |
|||
$frames['app']['jurisdiction'] = 'app'; |
|||
|
|||
$frames['store']['title'] = '<i class="fa fa-gear"></i> 设置'; |
|||
$frames['store']['url'] = web_url('store/merchant/edit'); |
|||
$frames['store']['active'] = 'store'; |
|||
$frames['store']['jurisdiction'] = 'store'; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getdashboardFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
return $frames; |
|||
} |
|||
|
|||
static function getfinaceFrames() { |
|||
global $_W, $_GPC; |
|||
$frames = array(); |
|||
|
|||
$frames['cashSurvey']['title'] = '<i class="fa fa-database"></i> 财务'; |
|||
$frames['cashSurvey']['items'] = array(); |
|||
|
|||
$frames['cashSurvey']['items']['cashrecord']['url'] = web_url('finace/newCash/currentlist',array('type'=>'store')); |
|||
$frames['cashSurvey']['items']['cashrecord']['title'] = '结算记录'; |
|||
$frames['cashSurvey']['items']['cashrecord']['actions'] = array(); |
|||
$frames['cashSurvey']['items']['cashrecord']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
|
|||
static function getstoreFrames() { |
|||
global $_W, $_GPC; |
|||
$frames = array(); |
|||
|
|||
$frames['user']['title'] = '<i class="fa fa-inbox"></i> 商户管理'; |
|||
$frames['user']['items'] = array(); |
|||
$frames['user']['items']['edit']['url'] = web_url('store/merchant/edit'); |
|||
$frames['user']['items']['edit']['title'] = '商户详情'; |
|||
$frames['user']['items']['edit']['actions'] = array('ac', 'merchant', 'do', 'edit'); |
|||
$frames['user']['items']['edit']['active'] = ''; |
|||
|
|||
if($_W['storeismain'] == 1){ |
|||
$frames['user']['items']['clerk']['url'] = web_url('store/merchant/clerkindex'); |
|||
$frames['user']['items']['clerk']['title'] = '店员管理'; |
|||
$frames['user']['items']['clerk']['actions'] = array('ac','merchant','do','clerkindex'); |
|||
$frames['user']['items']['clerk']['active'] = ''; |
|||
} |
|||
|
|||
if(empty($_W['authority']) || in_array('comment',$_W['authority']) || in_array('dynamic',$_W['authority'])){ |
|||
$frames['comment']['title'] = '<i class="fa fa-inbox"></i> 评论与动态'; |
|||
$frames['comment']['items'] = array(); |
|||
if(empty($_W['authority']) || in_array('comment',$_W['authority'])){ |
|||
$frames['comment']['items']['comment']['url'] = web_url('store/storeComment/index'); |
|||
$frames['comment']['items']['comment']['title'] = '全部评论'; |
|||
$frames['comment']['items']['comment']['actions'] = array('ac', 'storeComment', 'do', 'index'); |
|||
$frames['comment']['items']['comment']['active'] = ''; |
|||
} |
|||
if(empty($_W['authority']) || in_array('dynamic',$_W['authority'])) { |
|||
$frames['comment']['items']['dynamic']['url'] = web_url('store/storeDynamic/dynamic'); |
|||
$frames['comment']['items']['dynamic']['title'] = '商户动态'; |
|||
$frames['comment']['items']['dynamic']['actions'] = array('ac', 'storeDynamic', 'do', 'dynamic'); |
|||
$frames['comment']['items']['dynamic']['active'] = ''; |
|||
} |
|||
} |
|||
|
|||
$frames['setting']['title'] = '<i class="fa fa-globe"></i> 设置'; |
|||
$frames['setting']['items'] = array(); |
|||
$frames['setting']['items']['divform']['url'] = web_url('agentset/diyForm/index'); |
|||
$frames['setting']['items']['divform']['title'] = '自定义表单'; |
|||
$frames['setting']['items']['divform']['actions'] = ['ac' , 'diyForm' , 'do' , ['index' ,'add', 'edit']]; |
|||
$frames['setting']['items']['divform']['active'] = ''; |
|||
|
|||
|
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getorderFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$frames['order']['title'] = '<i class="fa fa-inbox"></i> 订单'; |
|||
$frames['order']['items'] = array(); |
|||
|
|||
$frames['order']['items']['orderlist']['url'] = web_url('order/wlOrder/orderlist'); |
|||
$frames['order']['items']['orderlist']['title'] = '商品订单'; |
|||
$frames['order']['items']['orderlist']['actions'] = array('ac', 'wlOrder', 'do', array('orderlist', 'orderdetail')); |
|||
$frames['order']['items']['orderlist']['active'] = ''; |
|||
|
|||
$frames['order']['items']['payonlinelist']['url'] = web_url('order/orderPayOnline/payonlinelist'); |
|||
$frames['order']['items']['payonlinelist']['title'] = '在线买单'; |
|||
$frames['order']['items']['payonlinelist']['actions'] = array('ac', 'orderPayOnline', 'do', 'payonlinelist'); |
|||
$frames['order']['items']['payonlinelist']['active'] = ''; |
|||
|
|||
$frames['freight']['title'] = '<i class="fa fa-inbox"></i> 运费'; |
|||
$frames['freight']['items'] = array(); |
|||
|
|||
$frames['freight']['items']['freightlist']['url'] = web_url('order/orderFreightTemplate/freightlist'); |
|||
$frames['freight']['items']['freightlist']['title'] = '运费模板'; |
|||
$frames['freight']['items']['freightlist']['actions'] = array('ac', 'orderFreightTemplate', 'do', 'freightlist'); |
|||
$frames['freight']['items']['freightlist']['active'] = ''; |
|||
|
|||
$frames['saleafter']['title'] = '<i class="fa fa-inbox"></i> 预约售后'; |
|||
$frames['saleafter']['items'] = array(); |
|||
|
|||
$frames['saleafter']['items']['afterlist']['url'] = web_url('order/orderAfterSales/afterlist'); |
|||
$frames['saleafter']['items']['afterlist']['title'] = '售后记录'; |
|||
$frames['saleafter']['items']['afterlist']['actions'] = array('ac', 'orderAfterSales', 'do', 'afterlist'); |
|||
$frames['saleafter']['items']['afterlist']['active'] = ''; |
|||
|
|||
$frames['saleafter']['items']['appointlist']['url'] = web_url('order/wlOrder/appointlist'); |
|||
$frames['saleafter']['items']['appointlist']['title'] = '预约记录'; |
|||
$frames['saleafter']['items']['appointlist']['actions'] = array('ac', 'wlOrder', 'do', 'appointlist'); |
|||
$frames['saleafter']['items']['appointlist']['active'] = ''; |
|||
|
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getdatacenterFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
|
|||
$frames['datacenter']['title'] = '<i class="fa fa-inbox"></i> 统计分析'; |
|||
$frames['datacenter']['items'] = array(); |
|||
$frames['datacenter']['items']['stat_operate']['url'] = web_url('datacenter/datacenter/stat_operate'); |
|||
$frames['datacenter']['items']['stat_operate']['title'] = '运营分析'; |
|||
$frames['datacenter']['items']['stat_operate']['actions'] = array(); |
|||
$frames['datacenter']['items']['stat_operate']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getappFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
|
|||
$category = App::get_cate_plugins('store'); |
|||
foreach ($category as $key => $value) { |
|||
if (!empty($value['plugins'])) { |
|||
$frames[$key]['title'] = '<i class="fa fa-inbox"></i> ' . $value['name']; |
|||
$frames[$key]['items'] = array(); |
|||
foreach ($value['plugins'] as $pk => $plug) { |
|||
$frames[$key]['items'][$plug['ident']]['url'] = $plug['cover']; |
|||
$frames[$key]['items'][$plug['ident']]['title'] = $plug['name']; |
|||
$frames[$key]['items'][$plug['ident']]['actions'] = array('ac', $plug['ident']); |
|||
$frames[$key]['items'][$plug['ident']]['active'] = ''; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getagentsetFrames() { |
|||
global $_W, $_GPC; |
|||
|
|||
|
|||
return self::getstoreFrames(); |
|||
|
|||
|
|||
$frames = array(); |
|||
$frames['setting']['title'] = '<i class="fa fa-globe"></i> 设置'; |
|||
$frames['setting']['items'] = array(); |
|||
$frames['setting']['items']['base']['url'] = web_url('agentset/agentSetAccount/profile'); |
|||
$frames['setting']['items']['base']['title'] = '账号信息'; |
|||
$frames['setting']['items']['base']['actions'] = array('ac', 'agentSetAccount', 'do', 'profile'); |
|||
$frames['setting']['items']['base']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['adminset']['url'] = web_url('agentset/agentSetStaff/adminset'); |
|||
$frames['setting']['items']['adminset']['title'] = '管理设置'; |
|||
$frames['setting']['items']['adminset']['actions'] = array('ac', 'agentSetStaff', 'do', 'adminset'); |
|||
$frames['setting']['items']['adminset']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['customer']['url'] = web_url('agentset/userset/customer'); |
|||
$frames['setting']['items']['customer']['title'] = '客服设置'; |
|||
$frames['setting']['items']['customer']['actions'] = array('ac', 'userset', 'do', 'customer'); |
|||
$frames['setting']['items']['customer']['active'] = ''; |
|||
|
|||
|
|||
$frames['setting']['items']['community']['url'] = web_url('agentset/agentSetCommunity/communityList'); |
|||
$frames['setting']['items']['community']['title'] = '社群设置'; |
|||
$frames['setting']['items']['community']['actions'] = array('ac', 'agentSetCommunity', 'do', 'communityList'); |
|||
$frames['setting']['items']['community']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['tags']['url'] = web_url('agentset/agentSetTags/tags'); |
|||
$frames['setting']['items']['tags']['title'] = '标签设置'; |
|||
$frames['setting']['items']['tags']['actions'] = array('ac', 'agentSetTags', 'do', 'tags'); |
|||
$frames['setting']['items']['tags']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['userindex']['url'] = web_url('agentset/userset/userindex'); |
|||
$frames['setting']['items']['userindex']['title'] = '个人中心'; |
|||
$frames['setting']['items']['userindex']['actions'] = array('ac', 'userset', 'do', 'userindex'); |
|||
$frames['setting']['items']['userindex']['active'] = ''; |
|||
|
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
|
|||
static function getgoodsFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$frames['goods']['title'] = '<i class="fa fa-dashboard"></i> 商品管理'; |
|||
$frames['goods']['items'] = array(); |
|||
|
|||
$frames['goods']['items']['list']['url'] = web_url('goods/Goods/index'); |
|||
$frames['goods']['items']['list']['title'] = '商品列表'; |
|||
$frames['goods']['items']['list']['actions'] = array('ac', 'Goods', 'do', 'index'); |
|||
$frames['goods']['items']['list']['active'] = ''; |
|||
|
|||
$frames['goods']['items']['cate']['url'] = web_url('goods/Goods/category'); |
|||
$frames['goods']['items']['cate']['title'] = '商品分类'; |
|||
$frames['goods']['items']['cate']['actions'] = array('ac', 'Goods', 'do', 'category'); |
|||
$frames['goods']['items']['cate']['active'] = ''; |
|||
return $frames; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,723 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class Menus_sys extends Menus { |
|||
|
|||
public static function __callStatic($method, $arg) { |
|||
global $_W, $_GPC; |
|||
$config = App::ext_plugin_config($_W['plugin']); |
|||
if (empty($config['menus']) || $config['setting']['system'] != 'true') { |
|||
wl_message('您访问的应用不存在,请重试!'); |
|||
} |
|||
//没有公众号,则不显示实卡功能 |
|||
if ($_W['plugin'] == 'halfcard' && !p('wxplatform')) { |
|||
unset($config['menus']['halfcard1']['items']['realcardcardlist']); |
|||
} |
|||
//非独立版隐藏自定义菜单 |
|||
if(IMS_FAMILY != 'wl'){ |
|||
unset($config['menus']['wxplatform0']['items']['wechatdiymenu']); |
|||
unset($config['menus']['wxplatform0']['items']['wechatautoreply']); |
|||
} |
|||
if(Customized::init('distributionText') > 0 && $_W['plugin'] == 'distribution'){ |
|||
$config['menus']['distribution0']['title'] = '共享股东'; |
|||
$config['menus']['distribution0']['items']['dissysbasedistributorlist']['title'] = '股东列表'; |
|||
$config['menus']['distribution0']['items']['dissysbasedislevel']['title'] = '股东等级'; |
|||
$config['menus']['distribution2']['items']['dissysbasedisbaseset']['title'] = '应用设置'; |
|||
} |
|||
|
|||
|
|||
return $config['menus']; |
|||
} |
|||
|
|||
/** |
|||
* static function 顶部列表 |
|||
* |
|||
* @access static |
|||
* @name topmenus |
|||
* @param |
|||
* @return array |
|||
*/ |
|||
static function topmenus() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$appact = Util::traversingFiles(PATH_PLUGIN); |
|||
$appact[] = 'app'; |
|||
$appact[] = 'goodshouse'; |
|||
|
|||
$frames['dashboard']['title'] = '<i class="fa fa-desktop"></i> 平台'; |
|||
$frames['dashboard']['url'] = web_url('dashboard/dashboard'); |
|||
$frames['dashboard']['active'] = 'dashboard'; |
|||
$frames['dashboard']['jurisdiction'] = 'dashboard'; |
|||
|
|||
$frames['member']['title'] = '<i class="fa fa-user"></i> 客户'; |
|||
$frames['member']['url'] = web_url('member/wlMember/index'); |
|||
$frames['member']['active'] = 'member'; |
|||
$frames['member']['jurisdiction'] = 'member'; |
|||
|
|||
$frames['store']['title'] = '<i class="fa fa-users"></i> 商户'; |
|||
$frames['store']['url'] = web_url('store/merchant/index', array('enabled' => '')); |
|||
$frames['store']['active'] = 'store'; |
|||
$frames['store']['jurisdiction'] = 'store'; |
|||
|
|||
$frames['order']['title'] = '<i class="fa fa-list"></i> 订单'; |
|||
$frames['order']['url'] = web_url('order/wlOrder/orderlist'); |
|||
$frames['order']['active'] = 'order'; |
|||
$frames['order']['jurisdiction'] = 'order'; |
|||
|
|||
// $perms = App::get_account_perm("plugins", $_W['uniacid']); |
|||
// if (p('area') && ((in_array('area',$perms) && $perms) || !$perms )) { |
|||
// $frames['area']['title'] = '<i class="fa fa-map"></i> 代理'; |
|||
// $frames['area']['url'] = web_url('area/areaagent/agentIndex'); |
|||
// $frames['area']['active'] = 'area'; |
|||
// $frames['area']['jurisdiction'] = 'area'; |
|||
// } |
|||
|
|||
$frames['finance']['title'] = '<i class="fa fa-money"></i> 财务'; |
|||
$frames['finance']['url'] = web_url('finace/finaceBill/cashrecord'); |
|||
$frames['finance']['active'] = 'finace'; |
|||
$frames['finance']['jurisdiction'] = 'finace'; |
|||
|
|||
$frames['data']['title'] = '<i class="fa fa-bar-chart"></i> 数据'; |
|||
$frames['data']['url'] = web_url('datacenter/datacenter/stat_operate'); |
|||
$frames['data']['active'] = 'datacenter'; |
|||
$frames['data']['jurisdiction'] = 'datacenter'; |
|||
|
|||
$frames['app']['title'] = '<i class="fa fa-cubes"></i> 应用'; |
|||
$frames['app']['url'] = web_url('app/plugins'); |
|||
$frames['app']['active'] = array_merge(array_diff($appact, array('area'))); |
|||
$frames['app']['jurisdiction'] = 'app'; |
|||
|
|||
$frames['setting']['title'] = '<i class="fa fa-gear"></i> 设置'; |
|||
$frames['setting']['url'] = web_url('setting/shopset/base'); |
|||
$frames['setting']['active'] = ['setting', 'agentset']; |
|||
$frames['setting']['jurisdiction'] = 'agentset'; |
|||
|
|||
if ($_W['highest_role'] == 'founder' && IMS_FAMILY != 'wl') { |
|||
$frames['cloud']['title'] = '<i class="fa fa-cloud"></i> 云服务'; |
|||
$frames['cloud']['url'] = web_url('cloud/auth/auth'); |
|||
$frames['cloud']['active'] = 'cloud'; |
|||
$frames['cloud']['jurisdiction'] = 'cloud'; |
|||
} |
|||
return $frames; |
|||
} |
|||
|
|||
static function getdashboardFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$frames['member']['title'] = '<i class="fa fa-dashboard"></i> 概况'; |
|||
$frames['member']['items'] = array(); |
|||
|
|||
$frames['member']['items']['setting']['url'] = web_url('dashboard/dashboard/index'); |
|||
$frames['member']['items']['setting']['title'] = '运营概况'; |
|||
$frames['member']['items']['setting']['actions'] = array('ac', 'dashboard'); |
|||
$frames['member']['items']['setting']['active'] = ''; |
|||
|
|||
$frames['page']['title'] = '<i class="fa fa-inbox"></i> 主页管理'; |
|||
$frames['page']['items'] = array(); |
|||
$frames['page']['items']['notice']['url'] = web_url('dashboard/notice/index'); |
|||
$frames['page']['items']['notice']['title'] = '公告'; |
|||
$frames['page']['items']['notice']['actions'] = array('ac', 'notice'); |
|||
$frames['page']['items']['notice']['active'] = ''; |
|||
|
|||
$frames['page']['items']['adv']['url'] = web_url('dashboard/adv/index'); |
|||
$frames['page']['items']['adv']['title'] = '幻灯片'; |
|||
$frames['page']['items']['adv']['actions'] = array('ac', 'adv'); |
|||
$frames['page']['items']['adv']['active'] = ''; |
|||
|
|||
$frames['page']['items']['nav']['url'] = web_url('dashboard/nav/index'); |
|||
$frames['page']['items']['nav']['title'] = '导航栏'; |
|||
$frames['page']['items']['nav']['actions'] = array('ac', 'nav'); |
|||
$frames['page']['items']['nav']['active'] = ''; |
|||
|
|||
$frames['page']['items']['banner']['url'] = web_url('dashboard/banner/index'); |
|||
$frames['page']['items']['banner']['title'] = '广告栏'; |
|||
$frames['page']['items']['banner']['actions'] = array('ac', 'banner'); |
|||
$frames['page']['items']['banner']['active'] = ''; |
|||
|
|||
$frames['page']['items']['cube']['url'] = web_url('dashboard/cube/index'); |
|||
$frames['page']['items']['cube']['title'] = '商品魔方'; |
|||
$frames['page']['items']['cube']['actions'] = array('ac', 'cube'); |
|||
$frames['page']['items']['cube']['active'] = ''; |
|||
|
|||
// $frames['page']['items']['sort']['url'] = web_url('dashboard/sort/index'); |
|||
// $frames['page']['items']['sort']['title'] = '主页排版'; |
|||
// $frames['page']['items']['sort']['actions'] = array(); |
|||
// $frames['page']['items']['sort']['active'] = ''; |
|||
|
|||
$frames['page']['items']['plugin']['url'] = web_url('dashboard/plugin/index'); |
|||
$frames['page']['items']['plugin']['title'] = '选项卡管理'; |
|||
$frames['page']['items']['plugin']['actions'] = array('ac', 'plugin'); |
|||
$frames['page']['items']['plugin']['active'] = ''; |
|||
|
|||
$frames['page']['items']['foot']['url'] = web_url('dashboard/foot/index'); |
|||
$frames['page']['items']['foot']['title'] = '底部菜单'; |
|||
$frames['page']['items']['foot']['actions'] = array('ac', 'foot'); |
|||
$frames['page']['items']['foot']['active'] = ''; |
|||
|
|||
$frames['page']['items']['category']['url'] = web_url('dashboard/category/index',array('active'=>1)); |
|||
$frames['page']['items']['category']['title'] = '分类管理'; |
|||
$frames['page']['items']['category']['actions'] = array('ac', 'category'); |
|||
$frames['page']['items']['category']['active'] = ''; |
|||
|
|||
$frames['page']['items']['rule_center']['url'] = web_url('dashboard/ruleCenter/index'); |
|||
$frames['page']['items']['rule_center']['title'] = '规则中心'; |
|||
$frames['page']['items']['rule_center']['actions'] = array('ac', 'ruleCenter'); |
|||
$frames['page']['items']['rule_center']['active'] = ''; |
|||
|
|||
$frames['other']['title'] = '<i class="fa fa-inbox"></i> 其他信息'; |
|||
$frames['other']['items'] = array(); |
|||
$frames['other']['items']['notice']['url'] = web_url('dashboard/pagelinks/index'); |
|||
$frames['other']['items']['notice']['title'] = '页面链接'; |
|||
$frames['other']['items']['notice']['actions'] = array('ac', 'pagelinks'); |
|||
$frames['other']['items']['notice']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
/** |
|||
* static function 客户左侧列表 |
|||
* |
|||
* @access static |
|||
* @name getmemberFrames |
|||
* @param |
|||
* @return array |
|||
*/ |
|||
static function getmemberFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$frames['user']['title'] = '<i class="fa fa-inbox"></i> 客户'; |
|||
$frames['user']['items'] = array(); |
|||
|
|||
$frames['user']['items']['register']['url'] = web_url('member/wlMember/index'); |
|||
$frames['user']['items']['register']['title'] = '客户概况'; |
|||
$frames['user']['items']['register']['actions'] = array('ac', 'wlMember', 'do', 'index'); |
|||
$frames['user']['items']['register']['active'] = ''; |
|||
|
|||
$frames['user']['items']['notice']['url'] = web_url('member/wlMember/memberIndex'); |
|||
$frames['user']['items']['notice']['title'] = '客户列表'; |
|||
$frames['user']['items']['notice']['actions'] = array('ac', 'wlMember', 'do', array('memberIndex', 'memberDetail')); |
|||
$frames['user']['items']['notice']['active'] = ''; |
|||
|
|||
$frames['user']['items']['publish']['url'] = web_url('member/campusActivities/index',array('active' => 1)); |
|||
$frames['user']['items']['publish']['title'] = '校园活动'; |
|||
$frames['user']['items']['publish']['actions'] = array('ac', 'campusActivities', 'do', 'index'); |
|||
$frames['user']['items']['publish']['active'] = ''; |
|||
|
|||
$frames['check']['title'] = '<i class="fa fa-inbox"></i> 审核'; |
|||
$frames['check']['items'] = array(); |
|||
|
|||
$frames['check']['items']['notice']['url'] = web_url('member/checkMember/checkStudentIndex'); |
|||
$frames['check']['items']['notice']['title'] = '学生认证'; |
|||
$frames['check']['items']['notice']['actions'] = array('ac', 'checkMember', 'do', 'checkStudentIndex'); |
|||
$frames['check']['items']['notice']['active'] = ''; |
|||
|
|||
$frames['check']['items']['teacher']['url'] = web_url('member/checkMember/checkTeacherIndex'); |
|||
$frames['check']['items']['teacher']['title'] = '教师认证'; |
|||
$frames['check']['items']['teacher']['actions'] = array('ac', 'checkMember', 'do', 'checkTeacherIndex'); |
|||
$frames['check']['items']['teacher']['active'] = ''; |
|||
|
|||
$frames['check']['items']['blogger']['url'] = web_url('member/checkMember/checkBloggerIndex'); |
|||
$frames['check']['items']['blogger']['title'] = '达人认证'; |
|||
$frames['check']['items']['blogger']['actions'] = array('ac', 'checkMember', 'do', 'checkBloggerIndex'); |
|||
$frames['check']['items']['blogger']['active'] = ''; |
|||
|
|||
$frames['im']['title'] = '<i class="fa fa-inbox"></i> 通信管理'; |
|||
$frames['im']['items'] = array(); |
|||
|
|||
$frames['im']['items']['im']['url'] = web_url('member/userIm/index'); |
|||
$frames['im']['items']['im']['title'] = '通信管理'; |
|||
$frames['im']['items']['im']['actions'] = ['ac' , 'userIm' , 'do' , ['index']]; |
|||
$frames['im']['items']['im']['active'] = ''; |
|||
|
|||
// $frames['im']['items']['im_set']['url'] = web_url('member/userIm/imSet'); |
|||
// $frames['im']['items']['im_set']['title'] = '通信设置'; |
|||
// $frames['im']['items']['im_set']['actions'] = ['ac' , 'userIm' , 'do' , ['imSet']]; |
|||
// $frames['im']['items']['im_set']['active'] = ''; |
|||
|
|||
$frames['userlabel']['title'] = '<i class="fa fa-inbox"></i> 标签'; |
|||
$frames['userlabel']['items'] = array(); |
|||
|
|||
$frames['userlabel']['items']['labellist']['url'] = web_url('member/userlabel/labellist'); |
|||
$frames['userlabel']['items']['labellist']['title'] = '客户标签'; |
|||
$frames['userlabel']['items']['labellist']['actions'] = array(); |
|||
$frames['userlabel']['items']['labellist']['active'] = ''; |
|||
|
|||
$frames['current']['title'] = '<i class="fa fa-inbox"></i> 财务'; |
|||
$frames['current']['items'] = array(); |
|||
|
|||
$frames['current']['items']['recharge']['url'] = web_url('member/memberFinancialDetails/recharge'); |
|||
$frames['current']['items']['recharge']['title'] = '充值明细'; |
|||
$frames['current']['items']['recharge']['actions'] = array('ac', 'memberFinancialDetails', 'do', 'recharge'); |
|||
$frames['current']['items']['recharge']['active'] = ''; |
|||
|
|||
$frames['current']['items']['integral']['url'] = web_url('member/memberFinancialDetails/integral'); |
|||
$frames['current']['items']['integral']['title'] = '积分明细'; |
|||
$frames['current']['items']['integral']['actions'] = array('ac', 'memberFinancialDetails', 'do', 'integral'); |
|||
$frames['current']['items']['integral']['active'] = ''; |
|||
|
|||
$frames['current']['items']['balance']['url'] = web_url('member/memberFinancialDetails/balance'); |
|||
$frames['current']['items']['balance']['title'] = '余额明细'; |
|||
$frames['current']['items']['balance']['actions'] = array('ac', 'memberFinancialDetails', 'do', 'balance'); |
|||
$frames['current']['items']['balance']['active'] = ''; |
|||
|
|||
$frames['memberset']['title'] = '<i class="fa fa-inbox"></i> 设置'; |
|||
$frames['memberset']['items'] = array(); |
|||
|
|||
$frames['memberset']['items']['userset']['url'] = web_url('member/wlMember/userset'); |
|||
$frames['memberset']['items']['userset']['title'] = '用户设置'; |
|||
$frames['memberset']['items']['userset']['actions'] = array('ac', 'wlMember', 'do', 'userset'); |
|||
$frames['memberset']['items']['userset']['active'] = ''; |
|||
|
|||
if (file_exists(PATH_MODULE . 'N561.log')) { |
|||
$frames['transfer']['title'] = '<i class="fa fa-inbox"></i> 余额转赠'; |
|||
$frames['transfer']['items'] = array(); |
|||
|
|||
$frames['transfer']['items']['transferlist']['url'] = web_url('member/wlMember/transferlist'); |
|||
$frames['transfer']['items']['transferlist']['title'] = '转赠活动'; |
|||
$frames['transfer']['items']['transferlist']['actions'] = array('ac', 'wlMember', 'do', 'transferlist'); |
|||
$frames['transfer']['items']['transferlist']['active'] = ''; |
|||
|
|||
$frames['transfer']['items']['transferrecord']['url'] = web_url('member/wlMember/transferrecord'); |
|||
$frames['transfer']['items']['transferrecord']['title'] = '转赠记录'; |
|||
$frames['transfer']['items']['transferrecord']['actions'] = array('ac', 'wlMember', 'do', 'transferrecord'); |
|||
$frames['transfer']['items']['transferrecord']['active'] = ''; |
|||
} |
|||
|
|||
|
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getstoreFrames() { |
|||
global $_W, $_GPC; |
|||
$frames = array(); |
|||
|
|||
$frames['user']['title'] = '<i class="fa fa-inbox"></i> 商户管理'; |
|||
$frames['user']['items'] = array(); |
|||
$frames['user']['items']['index']['url'] = web_url('store/merchant/index', array('enabled' => '')); |
|||
$frames['user']['items']['index']['title'] = '商户列表'; |
|||
$frames['user']['items']['index']['actions'] = array('ac', 'merchant'); |
|||
$frames['user']['items']['index']['active'] = ''; |
|||
|
|||
$frames['user']['items']['category']['url'] = web_url('store/category/index'); |
|||
$frames['user']['items']['category']['title'] = '商户分类'; |
|||
$frames['user']['items']['category']['actions'] = array('ac', 'category'); |
|||
$frames['user']['items']['category']['active'] = ''; |
|||
|
|||
$frames['register']['title'] = '<i class="fa fa-globe"></i> 入驻管理'; |
|||
$frames['register']['items'] = array(); |
|||
$frames['register']['items']['register']['url'] = web_url('store/storeApply/index'); |
|||
$frames['register']['items']['register']['title'] = '入驻申请'; |
|||
$frames['register']['items']['register']['actions'] = array('ac', 'storeApply', 'do', 'index'); |
|||
$frames['register']['items']['register']['active'] = ''; |
|||
|
|||
$frames['register']['items']['settled']['url'] = web_url('store/settled/baseset'); |
|||
$frames['register']['items']['settled']['title'] = '入驻设置'; |
|||
$frames['register']['items']['settled']['actions'] = array('ac', 'settled', 'do', 'baseset'); |
|||
$frames['register']['items']['settled']['active'] = ''; |
|||
|
|||
$frames['register']['items']['chargerecode']['url'] = web_url('store/register/chargerecode'); |
|||
$frames['register']['items']['chargerecode']['title'] = '付费记录'; |
|||
$frames['register']['items']['chargerecode']['actions'] = array('ac', 'register', 'do', 'chargerecode'); |
|||
$frames['register']['items']['chargerecode']['active'] = ''; |
|||
|
|||
$frames['register']['items']['chargelist']['url'] = web_url('store/storeSetMeal/chargelist'); |
|||
$frames['register']['items']['chargelist']['title'] = '入驻套餐'; |
|||
$frames['register']['items']['chargelist']['actions'] = array('ac', 'storeSetMeal', 'do', array('chargelist', 'add')); |
|||
$frames['register']['items']['chargelist']['active'] = ''; |
|||
|
|||
$frames['certified']['title'] = '<i class="fa fa-globe"></i> 认证管理'; |
|||
$frames['certified']['items'] = array(); |
|||
$frames['certified']['items']['certified']['url'] = web_url('store/storeCertified/index'); |
|||
$frames['certified']['items']['certified']['title'] = '商务认证'; |
|||
$frames['certified']['items']['certified']['actions'] = array('ac', 'storeCertified', 'do', 'index'); |
|||
$frames['certified']['items']['certified']['active'] = ''; |
|||
|
|||
$frames['comment']['title'] = '<i class="fa fa-inbox"></i> 评论与动态'; |
|||
$frames['comment']['items'] = array(); |
|||
$frames['comment']['items']['comment']['url'] = web_url('store/storeComment/index'); |
|||
$frames['comment']['items']['comment']['title'] = '全部评论'; |
|||
$frames['comment']['items']['comment']['actions'] = array('ac', 'storeComment', 'do', 'index'); |
|||
$frames['comment']['items']['comment']['active'] = ''; |
|||
|
|||
$frames['comment']['items']['dynamic']['url'] = web_url('store/storeDynamic/dynamic'); |
|||
$frames['comment']['items']['dynamic']['title'] = '商户动态'; |
|||
$frames['comment']['items']['dynamic']['actions'] = array('ac', 'storeDynamic', 'do', 'dynamic'); |
|||
$frames['comment']['items']['dynamic']['active'] = ''; |
|||
|
|||
$frames['setting']['title'] = '<i class="fa fa-inbox"></i> 商户设置'; |
|||
$frames['setting']['items'] = array(); |
|||
$frames['setting']['items']['setting']['url'] = web_url('store/comment/storeSet'); |
|||
$frames['setting']['items']['setting']['title'] = '基本设置'; |
|||
$frames['setting']['items']['setting']['actions'] = array('ac', 'comment', 'do', 'storeSet'); |
|||
$frames['setting']['items']['setting']['active'] = ''; |
|||
|
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
/** |
|||
* static function 订单左侧列表 |
|||
* |
|||
* @access static |
|||
* @name getorderFrames |
|||
* @param |
|||
* @return array |
|||
*/ |
|||
static function getorderFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
$frames['order']['title'] = '<i class="fa fa-inbox"></i> 订单'; |
|||
$frames['order']['items'] = array(); |
|||
|
|||
$frames['order']['items']['orderlist']['url'] = web_url('order/wlOrder/orderlist'); |
|||
$frames['order']['items']['orderlist']['title'] = '商品订单'; |
|||
$frames['order']['items']['orderlist']['actions'] = array('ac', 'wlOrder', 'do', array('orderlist', 'orderdetail')); |
|||
$frames['order']['items']['orderlist']['active'] = ''; |
|||
|
|||
$frames['order']['items']['payonlinelist']['url'] = web_url('order/orderPayOnline/payonlinelist'); |
|||
$frames['order']['items']['payonlinelist']['title'] = '在线买单'; |
|||
$frames['order']['items']['payonlinelist']['actions'] = array('ac', 'orderPayOnline', 'do', 'payonlinelist'); |
|||
$frames['order']['items']['payonlinelist']['active'] = ''; |
|||
|
|||
$frames['order']['items']['orderset']['url'] = web_url('order/orderSet/orderset'); |
|||
$frames['order']['items']['orderset']['title'] = '订单设置'; |
|||
$frames['order']['items']['orderset']['actions'] = array('ac', 'orderSet', 'do', 'orderset'); |
|||
$frames['order']['items']['orderset']['active'] = ''; |
|||
|
|||
$frames['freight']['title'] = '<i class="fa fa-inbox"></i> 运费'; |
|||
$frames['freight']['items'] = array(); |
|||
|
|||
$frames['freight']['items']['freightlist']['url'] = web_url('order/orderFreightTemplate/freightlist'); |
|||
$frames['freight']['items']['freightlist']['title'] = '运费模板'; |
|||
$frames['freight']['items']['freightlist']['actions'] = array('ac', 'orderFreightTemplate', 'do', 'freightlist'); |
|||
$frames['freight']['items']['freightlist']['active'] = ''; |
|||
|
|||
$frames['saleafter']['title'] = '<i class="fa fa-inbox"></i> 预约售后'; |
|||
$frames['saleafter']['items'] = array(); |
|||
|
|||
$frames['saleafter']['items']['afterlist']['url'] = web_url('order/orderAfterSales/afterlist'); |
|||
$frames['saleafter']['items']['afterlist']['title'] = '售后记录'; |
|||
$frames['saleafter']['items']['afterlist']['actions'] = array('ac', 'orderAfterSales', 'do', 'afterlist'); |
|||
$frames['saleafter']['items']['afterlist']['active'] = ''; |
|||
|
|||
$frames['saleafter']['items']['appointlist']['url'] = web_url('order/wlOrder/appointlist'); |
|||
$frames['saleafter']['items']['appointlist']['title'] = '预约记录'; |
|||
$frames['saleafter']['items']['appointlist']['actions'] = array('ac', 'wlOrder', 'do', 'appointlist'); |
|||
$frames['saleafter']['items']['appointlist']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
|
|||
static function getfinaceFrames() { |
|||
global $_W, $_GPC; |
|||
$frames = array(); |
|||
$frames['cashSurvey']['title'] = '<i class="fa fa-database"></i> 财务概况'; |
|||
$frames['cashSurvey']['items'] = array(); |
|||
|
|||
// $frames['cashSurvey']['items']['datemana']['url'] = web_url('finace/wlCash/cashSurvey'); |
|||
// $frames['cashSurvey']['items']['datemana']['title'] = '财务概况'; |
|||
// $frames['cashSurvey']['items']['datemana']['actions'] = array(); |
|||
// $frames['cashSurvey']['items']['datemana']['active'] = ''; |
|||
|
|||
$frames['cashSurvey']['items']['cashrecord']['url'] = web_url('finace/finaceBill/cashrecord'); |
|||
$frames['cashSurvey']['items']['cashrecord']['title'] = '账单明细'; |
|||
$frames['cashSurvey']['items']['cashrecord']['actions'] = array(); |
|||
$frames['cashSurvey']['items']['cashrecord']['active'] = ''; |
|||
|
|||
$frames['cashSurvey']['items']['refundrecord']['url'] = web_url('finace/finaceRefundRecord/refundrecord'); |
|||
$frames['cashSurvey']['items']['refundrecord']['title'] = '退款记录'; |
|||
$frames['cashSurvey']['items']['refundrecord']['actions'] = array(); |
|||
$frames['cashSurvey']['items']['refundrecord']['active'] = ''; |
|||
|
|||
$frames['current']['title'] = '<i class="fa fa-globe"></i> 账户'; |
|||
$frames['current']['items'] = array(); |
|||
|
|||
$frames['current']['items']['currentstore']['url'] = web_url('finace/newCash/currentlist', array('type' => 'store')); |
|||
$frames['current']['items']['currentstore']['title'] = '商家账户'; |
|||
$frames['current']['items']['currentstore']['actions'] = array('type', 'store'); |
|||
$frames['current']['items']['currentstore']['active'] = ''; |
|||
|
|||
$frames['current']['items']['currentmy']['url'] = web_url('finace/newCash/currentlist', array('type' => 'agent')); |
|||
$frames['current']['items']['currentmy']['title'] = '代理账户'; |
|||
$frames['current']['items']['currentmy']['actions'] = array('type', 'agent'); |
|||
$frames['current']['items']['currentmy']['active'] = ''; |
|||
|
|||
$frames['cashApply']['title'] = '<i class="fa fa-globe"></i> 提现'; |
|||
$frames['cashApply']['items'] = array(); |
|||
|
|||
$frames['cashApply']['items']['display1']['url'] = web_url('finace/finaceWithdrawalApply/cashApply'); |
|||
$frames['cashApply']['items']['display1']['title'] = '提现申请'; |
|||
$frames['cashApply']['items']['display1']['actions'] = array(); |
|||
$frames['cashApply']['items']['display1']['active'] = ''; |
|||
|
|||
$frames['cashApply']['items']['cashset']['url'] = web_url('finace/wlCash/cashset'); |
|||
$frames['cashApply']['items']['cashset']['title'] = '财务设置'; |
|||
$frames['cashApply']['items']['cashset']['actions'] = array(); |
|||
$frames['cashApply']['items']['cashset']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getdatacenterFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
|
|||
$frames['datacenter']['title'] = '<i class="fa fa-inbox"></i> 统计分析'; |
|||
$frames['datacenter']['items'] = array(); |
|||
|
|||
$frames['datacenter']['items']['stat_operate']['url'] = web_url('datacenter/datacenter/stat_operate'); |
|||
$frames['datacenter']['items']['stat_operate']['title'] = '运营分析'; |
|||
$frames['datacenter']['items']['stat_operate']['actions'] = array(); |
|||
$frames['datacenter']['items']['stat_operate']['active'] = ''; |
|||
|
|||
$frames['datacenter']['items']['stat_store']['url'] = web_url('datacenter/datacenter/stat_store'); |
|||
$frames['datacenter']['items']['stat_store']['title'] = '店铺统计'; |
|||
$frames['datacenter']['items']['stat_store']['actions'] = array(); |
|||
$frames['datacenter']['items']['stat_store']['active'] = ''; |
|||
|
|||
if (file_exists(PATH_MODULE . 'TnSrtWDJ.log')) { |
|||
$frames['datacenter']['items']['stat_store_card']['url'] = web_url('datacenter/datacenter/stat_store_card'); |
|||
$frames['datacenter']['items']['stat_store_card']['title'] = '商户会员'; |
|||
$frames['datacenter']['items']['stat_store_card']['actions'] = array(); |
|||
$frames['datacenter']['items']['stat_store_card']['active'] = ''; |
|||
} |
|||
|
|||
// $frames['datacenter']['items']['stat_agent']['url'] = web_url('datacenter/datacenter/stat_agent'); |
|||
// $frames['datacenter']['items']['stat_agent']['title'] = '代理统计'; |
|||
// $frames['datacenter']['items']['stat_agent']['actions'] = array(); |
|||
// $frames['datacenter']['items']['stat_agent']['active'] = ''; |
|||
|
|||
if (p('distribution')) { |
|||
if(Customized::init('distributionText') > 0){ |
|||
$frames['distri']['title'] = '<i class="fa fa-inbox"></i> 共享股东分析'; |
|||
}else{ |
|||
$frames['distri']['title'] = '<i class="fa fa-inbox"></i> 分销分析'; |
|||
} |
|||
$frames['distri']['items'] = array(); |
|||
|
|||
$frames['distri']['items']['stat_distri']['url'] = web_url('datacenter/datacenter/stat_distri'); |
|||
if(Customized::init('distributionText') > 0){ |
|||
$frames['distri']['items']['stat_distri']['title'] = '共享股东统计'; |
|||
}else{ |
|||
$frames['distri']['items']['stat_distri']['title'] = '分销统计'; |
|||
} |
|||
$frames['distri']['items']['stat_distri']['actions'] = array(); |
|||
$frames['distri']['items']['stat_distri']['active'] = ''; |
|||
} |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
/** |
|||
* static function 设置左侧列表 |
|||
* |
|||
* @access static |
|||
* @name getsettingFrames |
|||
* @param |
|||
* @return array |
|||
*/ |
|||
static function getsettingFrames() { |
|||
global $_W, $_GPC; |
|||
$frames = array(); |
|||
$frames['setting']['title'] = '<i class="fa fa-globe"></i> 设置'; |
|||
$frames['setting']['items'] = array(); |
|||
$frames['setting']['items']['base']['url'] = web_url('setting/shopset/base'); |
|||
$frames['setting']['items']['base']['title'] = '基础设置'; |
|||
$frames['setting']['items']['base']['actions'] = array('ac', 'shopset', 'do', 'base'); |
|||
$frames['setting']['items']['base']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['share']['url'] = web_url('setting/shopset/share'); |
|||
$frames['setting']['items']['share']['title'] = '分享关注'; |
|||
$frames['setting']['items']['share']['actions'] = array('ac', 'shopset', 'do', 'share'); |
|||
$frames['setting']['items']['share']['active'] = ''; |
|||
|
|||
// $frames['setting']['items']['api']['url'] = web_url('setting/shopset/api'); |
|||
// $frames['setting']['items']['api']['title'] = '接口设置'; |
|||
// $frames['setting']['items']['api']['actions'] = array('ac', 'shopset', 'do', 'api'); |
|||
// $frames['setting']['items']['api']['active'] = ''; |
|||
|
|||
// $frames['setting']['items']['community']['url'] = web_url('agentset/agentSetCommunity/communityList'); |
|||
// $frames['setting']['items']['community']['title'] = '社群设置'; |
|||
// $frames['setting']['items']['community']['actions'] = array('ac', 'agentSetCommunity', 'do', 'communityList'); |
|||
// $frames['setting']['items']['community']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['userindex']['url'] = web_url('agentset/userset/userindex'); |
|||
$frames['setting']['items']['userindex']['title'] = '个人中心'; |
|||
$frames['setting']['items']['userindex']['actions'] = array('ac', 'userset', 'do', 'userindex'); |
|||
$frames['setting']['items']['userindex']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['adminset']['url'] = web_url('agentset/agentSetStaff/adminset'); |
|||
$frames['setting']['items']['adminset']['title'] = '员工管理'; |
|||
$frames['setting']['items']['adminset']['actions'] = array('ac', 'agentSetStaff', 'do', 'adminset'); |
|||
$frames['setting']['items']['adminset']['active'] = ''; |
|||
|
|||
// $frames['setting']['items']['trade']['url'] = web_url('setting/shopset/trade'); |
|||
// $frames['setting']['items']['trade']['title'] = '文字设置'; |
|||
// $frames['setting']['items']['trade']['actions'] = array('ac', 'shopset', 'do', 'trade'); |
|||
// $frames['setting']['items']['trade']['active'] = ''; |
|||
|
|||
$frames['setting']['items']['customer']['url'] = web_url('setting/shopset/customer'); |
|||
$frames['setting']['items']['customer']['title'] = '客服设置'; |
|||
$frames['setting']['items']['customer']['actions'] = array('ac', 'shopset', 'do', 'customer'); |
|||
$frames['setting']['items']['customer']['active'] = ''; |
|||
|
|||
// $frames['setting']['items']['tags']['url'] = web_url('agentset/agentSetTags/tags'); |
|||
// $frames['setting']['items']['tags']['title'] = '标签设置'; |
|||
// $frames['setting']['items']['tags']['actions'] = array('ac', 'agentSetTags', 'do', 'tags'); |
|||
// $frames['setting']['items']['tags']['active'] = ''; |
|||
|
|||
// $frames['setting']['items']['divform']['url'] = web_url('agentset/diyForm/index'); |
|||
// $frames['setting']['items']['divform']['title'] = '自定义表单'; |
|||
// $frames['setting']['items']['divform']['actions'] = ['ac' , 'diyForm' , 'do' , ['index' ,'add', 'edit']]; |
|||
// $frames['setting']['items']['divform']['active'] = ''; |
|||
|
|||
// if(IMS_FAMILY == 'wl'){ |
|||
// $frames['setting']['items']['enclosure']['url'] = web_url('setting/shopset/enclosure'); |
|||
// $frames['setting']['items']['enclosure']['title'] = '附件设置'; |
|||
// $frames['setting']['items']['enclosure']['actions'] = ['ac' , 'shopset' , 'do' ,'enclosure']; |
|||
// $frames['setting']['items']['enclosure']['active'] = ''; |
|||
// } |
|||
|
|||
$frames['payset']['title'] = '<i class="fa fa-inbox"></i> 交易'; |
|||
$frames['payset']['items'] = array(); |
|||
$frames['payset']['items']['recharge']['url'] = web_url('setting/settingTransaction/recharge'); |
|||
$frames['payset']['items']['recharge']['title'] = '充值设置'; |
|||
$frames['payset']['items']['recharge']['actions'] = array('ac', 'settingTransaction', 'do', 'recharge'); |
|||
$frames['payset']['items']['recharge']['active'] = ''; |
|||
|
|||
$frames['payset']['items']['creditset']['url'] = web_url('setting/settingTransaction/creditset'); |
|||
$frames['payset']['items']['creditset']['title'] = '积分设置'; |
|||
$frames['payset']['items']['creditset']['actions'] = array('ac', 'settingTransaction', 'do', 'creditset'); |
|||
$frames['payset']['items']['creditset']['active'] = ''; |
|||
|
|||
|
|||
$frames['pay']['title'] = '<i class="fa fa-inbox"></i> 支付'; |
|||
$frames['pay']['items'] = array(); |
|||
$frames['pay']['items']['recharge']['url'] = web_url('setting/pay/index'); |
|||
$frames['pay']['items']['recharge']['title'] = '支付设置'; |
|||
$frames['pay']['items']['recharge']['actions'] = array('ac', 'pay', 'do', 'index'); |
|||
$frames['pay']['items']['recharge']['active'] = ''; |
|||
|
|||
$frames['pay']['items']['administration']['url'] = web_url('setting/pay/administration'); |
|||
$frames['pay']['items']['administration']['title'] = '支付管理'; |
|||
$frames['pay']['items']['administration']['actions'] = array('ac', 'pay', 'do', 'administration'); |
|||
$frames['pay']['items']['administration']['active'] = ''; |
|||
|
|||
$frames['rights']['title'] = '<i class="fa fa-inbox"></i> 权益'; |
|||
$frames['rights']['items'] = array(); |
|||
|
|||
$frames['rights']['items']['config']['url'] = web_url('setting/rights/index'); |
|||
$frames['rights']['items']['config']['title'] = '权益配置'; |
|||
$frames['rights']['items']['config']['actions'] = array('ac', 'rights', 'do', 'index'); |
|||
$frames['rights']['items']['config']['active'] = ''; |
|||
|
|||
$frames['rights']['items']['use']['url'] = web_url('setting/rights/useRightsIndex'); |
|||
$frames['rights']['items']['use']['title'] = '权益使用'; |
|||
$frames['rights']['items']['use']['actions'] = array('ac', 'rights', 'do', 'useRightsIndex'); |
|||
$frames['rights']['items']['use']['active'] = ''; |
|||
|
|||
$frames['rights']['items']['order']['url'] = web_url('setting/rights/rightsOrderIndex'); |
|||
$frames['rights']['items']['order']['title'] = '订单管理'; |
|||
$frames['rights']['items']['order']['actions'] = array('ac', 'rights', 'do', 'rightsOrderIndex'); |
|||
$frames['rights']['items']['order']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getagentsetFrames() { |
|||
return self::getsettingFrames(); |
|||
} |
|||
|
|||
static function getappFrames() { |
|||
global $_W; |
|||
$frames = array(); |
|||
|
|||
$category = App::get_cate_plugins('sys'); |
|||
foreach ($category as $key => $value) { |
|||
if (!empty($value['plugins'])) { |
|||
$frames[$key]['title'] = '<i class="fa fa-inbox"></i> ' . $value['name']; |
|||
$frames[$key]['items'] = array(); |
|||
foreach ($value['plugins'] as $pk => $plug) { |
|||
$frames[$key]['items'][$plug['ident']]['url'] = $plug['cover']; |
|||
$frames[$key]['items'][$plug['ident']]['title'] = $plug['name']; |
|||
$frames[$key]['items'][$plug['ident']]['actions'] = array('ac', $plug['ident']); |
|||
$frames[$key]['items'][$plug['ident']]['active'] = ''; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return $frames; |
|||
} |
|||
|
|||
static function getcloudFrames() { |
|||
global $_W, $_GPC; |
|||
$frames = array(); |
|||
$frames['member']['title'] = '<i class="fa fa-globe"></i> 云服务'; |
|||
$frames['member']['items'] = array(); |
|||
|
|||
$frames['member']['items']['setting']['url'] = web_url('cloud/auth/auth'); |
|||
$frames['member']['items']['setting']['title'] = '系统授权'; |
|||
$frames['member']['items']['setting']['actions'] = array(); |
|||
$frames['member']['items']['setting']['active'] = ''; |
|||
|
|||
if ($_W['wlcloud']['authinfo']['status'] == 0 && $_W['wlcloud']['authinfo']['endtime'] > time()) { |
|||
$frames['member']['items']['display']['url'] = web_url('cloud/auth/upgrade'); |
|||
$frames['member']['items']['display']['title'] = '系统升级'; |
|||
$frames['member']['items']['display']['actions'] = array(); |
|||
$frames['member']['items']['display']['active'] = ''; |
|||
|
|||
$frames['member']['items']['log']['url'] = web_url('cloud/auth/upgrade_log'); |
|||
$frames['member']['items']['log']['title'] = '更新日志'; |
|||
$frames['member']['items']['log']['actions'] = array(); |
|||
$frames['member']['items']['log']['active'] = ''; |
|||
} |
|||
|
|||
$frames['plugin']['title'] = '<i class="fa fa-database"></i> 应用管理'; |
|||
$frames['plugin']['items'] = array(); |
|||
|
|||
$frames['plugin']['items']['index']['url'] = web_url('cloud/plugin/index'); |
|||
$frames['plugin']['items']['index']['title'] = '应用信息'; |
|||
$frames['plugin']['items']['index']['actions'] = array(); |
|||
$frames['plugin']['items']['index']['active'] = ''; |
|||
|
|||
$frames['plugin']['items']['perm']['url'] = web_url('cloud/plugin/account_list'); |
|||
$frames['plugin']['items']['perm']['title'] = '公众号权限'; |
|||
$frames['plugin']['items']['perm']['actions'] = array('do', array('account_list', 'account_post')); |
|||
$frames['plugin']['items']['perm']['active'] = ''; |
|||
|
|||
$frames['database']['title'] = '<i class="fa fa-database"></i> 数据管理'; |
|||
$frames['database']['items'] = array(); |
|||
|
|||
$frames['database']['items']['datemana']['url'] = web_url('cloud/database/datemana'); |
|||
$frames['database']['items']['datemana']['title'] = '数据管理'; |
|||
$frames['database']['items']['datemana']['actions'] = array(); |
|||
$frames['database']['items']['datemana']['active'] = ''; |
|||
|
|||
$frames['database']['items']['run']['url'] = web_url('cloud/database/run'); |
|||
$frames['database']['items']['run']['title'] = '运行SQL'; |
|||
$frames['database']['items']['run']['actions'] = array(); |
|||
$frames['database']['items']['run']['active'] = ''; |
|||
|
|||
$frames['sysset']['title'] = '<i class="fa fa-database"></i> 系统设置'; |
|||
$frames['sysset']['items'] = array(); |
|||
|
|||
$frames['sysset']['items']['base']['url'] = web_url('cloud/wlsysset/base'); |
|||
$frames['sysset']['items']['base']['title'] = '系统信息'; |
|||
$frames['sysset']['items']['base']['actions'] = array(); |
|||
$frames['sysset']['items']['base']['active'] = ''; |
|||
|
|||
$frames['sysset']['items']['datemana']['url'] = web_url('cloud/wlsysset/taskcover'); |
|||
$frames['sysset']['items']['datemana']['title'] = '计划任务'; |
|||
$frames['sysset']['items']['datemana']['actions'] = array(); |
|||
$frames['sysset']['items']['datemana']['active'] = ''; |
|||
|
|||
$frames['sysset']['items']['jumpadmin']['url'] = web_url('cloud/wlsysset/jumpadmin'); |
|||
$frames['sysset']['items']['jumpadmin']['title'] = '跳转域名'; |
|||
$frames['sysset']['items']['jumpadmin']['actions'] = array(); |
|||
$frames['sysset']['items']['jumpadmin']['active'] = ''; |
|||
|
|||
return $frames; |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,161 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class PayBuild { |
|||
static function wechat_proxy_build($params, $wechat) { |
|||
global $_W; |
|||
$uniacid = !empty($wechat['service']) ? $wechat['service'] : $wechat['borrow']; |
|||
$oauth_account = uni_setting($uniacid, array('payment')); |
|||
if (intval($wechat['switch']) == '2') { |
|||
$_W['uniacid'] = $uniacid; |
|||
$wechat['signkey'] = $oauth_account['payment']['wechat']['signkey']; |
|||
$wechat['mchid'] = $oauth_account['payment']['wechat']['mchid']; |
|||
unset($wechat['sub_mch_id']); |
|||
} else { |
|||
$wechat['signkey'] = $oauth_account['payment']['wechat_facilitator']['signkey']; |
|||
$wechat['mchid'] = $oauth_account['payment']['wechat_facilitator']['mchid']; |
|||
} |
|||
$acid = pdo_getcolumn('uni_account', array('uniacid' => $uniacid), 'default_acid'); |
|||
$wechat['appid'] = pdo_getcolumn('account_wechats', array('acid' => $acid), 'key'); |
|||
$wechat['version'] = 2; |
|||
return wechat_build($params, $wechat); |
|||
} |
|||
|
|||
static function wechat_build($params, $wechat) { |
|||
global $_W; |
|||
load()->func('communication'); |
|||
if (empty($wechat['version']) && !empty($wechat['signkey'])) { |
|||
$wechat['version'] = 1; |
|||
} |
|||
$wOpt = array(); |
|||
if ($wechat['version'] == 1) { |
|||
$wOpt['appId'] = $wechat['appid']; |
|||
$wOpt['timeStamp'] = strval(TIMESTAMP); |
|||
$wOpt['nonceStr'] = random(8); |
|||
$package = array(); |
|||
$package['bank_type'] = 'WX'; |
|||
$package['body'] = $params['title']; |
|||
$package['attach'] = $_W['uniacid']; |
|||
$package['partner'] = $wechat['partner']; |
|||
$package['out_trade_no'] = $params['uniontid']; |
|||
$package['total_fee'] = $params['fee'] * 100; |
|||
$package['fee_type'] = '1'; |
|||
$package['notify_url'] = MODULE_URL . 'payment/wechat/weixin_notify.php'; |
|||
$package['spbill_create_ip'] = CLIENT_IP; |
|||
$package['time_start'] = date('YmdHis', TIMESTAMP); |
|||
$package['time_expire'] = date('YmdHis', TIMESTAMP + 600); |
|||
$package['input_charset'] = 'UTF-8'; |
|||
if (!empty($wechat['sub_appid'])) { |
|||
$package['sub_appid'] = $wechat['sub_appid']; |
|||
} |
|||
if (!empty($wechat['sub_mch_id'])) { |
|||
$package['sub_mch_id'] = $wechat['sub_mch_id']; |
|||
} |
|||
ksort($package); |
|||
$string1 = ''; |
|||
foreach ($package as $key => $v) { |
|||
if (empty($v)) { |
|||
continue; |
|||
} |
|||
$string1 .= "{$key}={$v}&"; |
|||
} |
|||
$string1 .= "key={$wechat['key']}"; |
|||
$sign = strtoupper(md5($string1)); |
|||
|
|||
$string2 = ''; |
|||
foreach ($package as $key => $v) { |
|||
$v = urlencode($v); |
|||
$string2 .= "{$key}={$v}&"; |
|||
} |
|||
$string2 .= "sign={$sign}"; |
|||
$wOpt['package'] = $string2; |
|||
|
|||
$string = ''; |
|||
$keys = array('appId', 'timeStamp', 'nonceStr', 'package', 'appKey'); |
|||
sort($keys); |
|||
foreach ($keys as $key) { |
|||
$v = $wOpt[$key]; |
|||
if ($key == 'appKey') { |
|||
$v = $wechat['signkey']; |
|||
} |
|||
$key = strtolower($key); |
|||
$string .= "{$key}={$v}&"; |
|||
} |
|||
$string = rtrim($string, '&'); |
|||
$wOpt['signType'] = 'SHA1'; |
|||
$wOpt['paySign'] = sha1($string); |
|||
return $wOpt; |
|||
} else { |
|||
$package = array(); |
|||
$package['appid'] = $wechat['appid']; |
|||
$package['mch_id'] = $wechat['mchid']; |
|||
$package['nonce_str'] = random(8); |
|||
$package['body'] = cutstr($params['title'], 26); |
|||
$package['attach'] = $_W['uniacid']; |
|||
$package['out_trade_no'] = $params['uniontid']; |
|||
$package['total_fee'] = $params['fee'] * 100; |
|||
$package['spbill_create_ip'] = CLIENT_IP; |
|||
$package['time_start'] = date('YmdHis', TIMESTAMP); |
|||
$package['time_expire'] = date('YmdHis', TIMESTAMP + 600); |
|||
$package['notify_url'] = MODULE_URL . 'payment/wechat/weixin_notify.php'; |
|||
$package['trade_type'] = 'JSAPI'; |
|||
$package['openid'] = empty($wechat['openid']) ? $_W['fans']['from_user'] : $wechat['openid']; |
|||
if (!empty($wechat['sub_appid'])) { |
|||
$package['sub_appid'] = $wechat['sub_appid']; |
|||
} |
|||
if (!empty($wechat['sub_mch_id'])) { |
|||
$package['sub_mch_id'] = $wechat['sub_mch_id']; |
|||
} |
|||
ksort($package, SORT_STRING); |
|||
$string1 = ''; |
|||
foreach ($package as $key => $v) { |
|||
if (empty($v)) { |
|||
continue; |
|||
} |
|||
$string1 .= "{$key}={$v}&"; |
|||
} |
|||
$string1 .= "key={$wechat['signkey']}"; |
|||
$package['sign'] = strtoupper(md5($string1)); |
|||
$dat = array2xml($package); |
|||
$response = ihttp_request('https://api.mch.weixin.qq.com/pay/unifiedorder', $dat); |
|||
if (is_error($response)) { |
|||
return $response; |
|||
} |
|||
$xml = @isimplexml_load_string($response['content'], 'SimpleXMLElement', LIBXML_NOCDATA); |
|||
if (strval($xml->return_code) == 'FAIL') { |
|||
return error(-1, strval($xml->return_msg)); |
|||
} |
|||
if (strval($xml->result_code) == 'FAIL') { |
|||
return error(-1, strval($xml->err_code) . ': ' . strval($xml->err_code_des)); |
|||
} |
|||
$prepayid = $xml->prepay_id; |
|||
$wOpt['appId'] = $wechat['appid']; |
|||
$wOpt['timeStamp'] = strval(TIMESTAMP); |
|||
$wOpt['nonceStr'] = random(8); |
|||
$wOpt['package'] = 'prepay_id=' . $prepayid; |
|||
$wOpt['signType'] = 'MD5'; |
|||
ksort($wOpt, SORT_STRING); |
|||
foreach ($wOpt as $key => $v) { |
|||
$string .= "{$key}={$v}&"; |
|||
} |
|||
$string .= "key={$wechat['signkey']}"; |
|||
$wOpt['paySign'] = strtoupper(md5($string)); |
|||
return $wOpt; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Comment: 生成支付信息时判断当前订单是否存在开通会员卡的操作,并进行相关操作 |
|||
* Author: zzw |
|||
* @param $data 订单信息,必须存在vip_card_id & price字段 |
|||
* @return mixed |
|||
*/ |
|||
static function isOpenCard($data, $field = 'price') { |
|||
if ($data['vip_card_id'] > 0) { |
|||
//会员卡id存在 代表用户在购买商品时开通了vip卡 |
|||
$cardPrice = pdo_getcolumn(PDO_NAME . "halfcard_type", array('id' => $data['vip_card_id']), 'price'); |
|||
$data[$field] = sprintf("%.2f", $data[$field] + $cardPrice); |
|||
} |
|||
return $data; |
|||
} |
|||
} |
|||
@ -0,0 +1,131 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class PayResult { |
|||
/** |
|||
* Comment: 支付回调公共处理 |
|||
* Author: zzw |
|||
* Date: 2019/9/27 15:23 |
|||
* @param $params |
|||
*/ |
|||
public static function main($params){ |
|||
global $_W; |
|||
$log = pdo_get(PDO_NAME . 'paylogvfour' , array( 'tid' => $params['tid'])); |
|||
$_W['uniacid'] = $params['uniacid'] ? $params['uniacid'] : $log['uniacid']; |
|||
$_W['acid'] = pdo_getcolumn('account_wechats' , array( 'uniacid' => $_W['uniacid'] ) , 'acid'); |
|||
$_W['source'] = $log['source']; |
|||
$member = pdo_get(PDO_NAME."member",['id'=>$log['mid']],['openid']); |
|||
$className = $log['plugin']; |
|||
$ret = [ |
|||
'weid' => $log['uniacid'] , |
|||
'uniacid' => $log['uniacid'] , |
|||
'result' => 'success' , |
|||
'type' => $params['type'] , |
|||
'tid' => $log['tid'] , |
|||
'uniontid' => $log['uniacid'] , |
|||
'user' => $member['openid'] , |
|||
'fee' => $log['fee'] , |
|||
'tag' => $log['tag'] , |
|||
'is_usecard' => $log['is_usecard'] , |
|||
'card_type' => $log['card_type'] , |
|||
'card_fee' => $log['card_fee'] , |
|||
'card_id' => $log['card_id'] , |
|||
'blendcredit'=> $log['blendcredit'] |
|||
]; |
|||
Util::wl_log('rush_notify2' , PATH_DATA . "rush/data/" , $ret); //写入异步日志记录 |
|||
//混合支付扣除余额 |
|||
if($ret['blendcredit'] > 0){ |
|||
Member::credit_update_credit2($log['mid'],-$ret['blendcredit'],'混合支付['.$log['tid'].']订单支付余额'); |
|||
} |
|||
//当订单中存在开卡信息时的操作 |
|||
$tid = $params['tid']; |
|||
#1、获取订单信息 |
|||
if ($log['plugin'] == 'Rush') { |
|||
$orderInfo = pdo_get(PDO_NAME . "rush_order" , array( 'orderno' => $tid ) , array( 'mid','orderno','uniacid','aid','id','vip_card_id' )); |
|||
}else if($log['payfor'] == 'Halfcard'){ |
|||
$orderInfo = pdo_get(PDO_NAME . "halfcard_record" , array( 'orderno' => $tid ) , array( 'mid','orderno','uniacid','aid')); |
|||
} else { |
|||
$orderInfo = pdo_get(PDO_NAME . "order" , array( 'orderno' => $tid ) , array( 'mid','orderno','uniacid','aid', 'id','vip_card_id')); |
|||
} |
|||
if(empty($member['aid'])){ //给会员添加aid 修改用户所属代理 |
|||
pdo_update(PDO_NAME."member",array('aid' => $orderInfo['aid']),array('id' => $log['mid'])); |
|||
} |
|||
if ($orderInfo['vip_card_id'] > 0 && !empty($orderInfo['vip_card_id'])) { |
|||
$halftype = pdo_get(PDO_NAME . 'halfcard_type' , array( 'id' => $orderInfo['vip_card_id'] )); |
|||
#2、获取用户信息 |
|||
$userInfo = pdo_get(PDO_NAME . "member" , array( 'id' => $orderInfo['mid'] ) , array( 'nickname' , 'mobile' )); |
|||
$cardid = $orderInfo['vip_card_id']; |
|||
$username = $userInfo['nickname']; |
|||
$mobile = $userInfo['mobile']; |
|||
#3、到期时间计算 |
|||
if ($cardid) { |
|||
$mdata = array( 'uniacid' => $_W['uniacid'] , 'mid' => $orderInfo['mid'] , 'id' => $cardid ); |
|||
$vipInfo = Util::getSingelData('*' , PDO_NAME . "halfcardmember" , $mdata); |
|||
$lastviptime = $vipInfo['expiretime']; |
|||
if ($lastviptime && $lastviptime > time()) { |
|||
$limittime = $lastviptime + $halftype['days'] * 24 * 60 * 60; |
|||
} else { |
|||
$limittime = time() + $halftype['days'] * 24 * 60 * 60; |
|||
} |
|||
} else { |
|||
$limittime = time() + $halftype['days'] * 24 * 60 * 60; |
|||
} |
|||
#4、开卡信息记录 支付方式:1=余额;2=微信;3=支付宝;4=货到付款 |
|||
$data = array( |
|||
'aid' => $orderInfo['aid'] , |
|||
'uniacid' => $_W['uniacid'] , |
|||
'mid' => $orderInfo['mid'] , |
|||
'orderno' => createUniontid() , |
|||
'status' => 1 ,//订单状态:0未支,1支付,2待发货,3已发货,4已签收,5已取消,6待退款,7已退款 |
|||
'createtime' => TIMESTAMP , |
|||
'price' => $halftype['price'] , |
|||
'limittime' => $limittime , |
|||
'typeid' => $halftype['id'] , |
|||
'howlong' => $halftype['days'] , |
|||
'todistributor' => $halftype['todistributor'] , |
|||
'cardid' => $cardid , |
|||
'username' => $username , |
|||
'mobile' => $mobile |
|||
); |
|||
$data['paytype'] = $params['type']; |
|||
$data['paytime'] = time(); |
|||
pdo_insert(PDO_NAME . 'halfcard_record' , $data); |
|||
$recordid = pdo_insertid(); |
|||
//分销 |
|||
if (p('distribution') && empty($halftype['isdistri'])) { |
|||
$_W['aid'] = $orderInfo['aid']; |
|||
$disorderid = Distribution::disCore($orderInfo['mid'] , $data['price'] , $halftype['onedismoney'] , $halftype['twodismoney'] , $halftype['threedismoney'] , $recordid , 'halfcard' , 1); |
|||
pdo_update(PDO_NAME . 'halfcard_record' , array( 'disorderid' => $disorderid ) , array( 'id' => $recordid )); |
|||
} |
|||
#5、成功开通会员卡 |
|||
$halfcarddata = array( |
|||
'uniacid' => $_W['uniacid'] , |
|||
'aid' => $data['aid'] , |
|||
'mid' => $data['mid'] , |
|||
'expiretime' => $data['limittime'] , |
|||
'username' => $data['username'] , |
|||
'levelid' => $halftype['levelid'] , |
|||
'createtime' => time() |
|||
); |
|||
pdo_insert(PDO_NAME . 'halfcardmember' , $halfcarddata); |
|||
} |
|||
if ($params['type'] == 2 && $params['bank_type'] != 'OTHERS'){ //银行卡返现 |
|||
$set = Setting::wlsetting_read('payback'); |
|||
if($set['status'] > 0){ |
|||
$rate = pdo_getcolumn(PDO_NAME.'payback_bank',array('uniacid'=>$_W['uniacid'],'bank'=>$params['bank_type']),'rate'); |
|||
if($rate > 0){ |
|||
$price = sprintf("%.2f",$ret['fee'] * $rate / 100); |
|||
if($price>0){ |
|||
Payback::payCore(0,$orderInfo['mid'],-2,'sys',$price,$orderInfo['orderno'],$orderInfo['id'],$orderInfo['uniacid'],$orderInfo['aid'],0,$params['bank_type']); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
//开卡操作的结束 |
|||
pdo_update(PDO_NAME . 'paylogvfour' , [ 'status' => 1 , 'type' => $params['type'] ,'transaction_id'=>$params['transaction_id'],'pay_order_no'=>$params['pay_order_no']] |
|||
, ['tid' => $params['tid'] , 'uniacid' => $_W['uniacid'] ]); |
|||
$ret['from'] = 'notify'; |
|||
$functionName = 'pay' . $log['payfor'] . 'Notify'; |
|||
$className::$functionName($ret); |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,94 @@ |
|||
<?php |
|||
if (!defined('IN_IA')) { |
|||
exit('Access Denied'); |
|||
} |
|||
|
|||
class Sms { |
|||
static function sendSms($smstpl, $param, $mobile) { |
|||
global $_W; |
|||
if ($smstpl['type'] == 'aliyun') { |
|||
include PATH_CORE . 'library/aliyun/Config.php'; |
|||
$profile = DefaultProfile::getProfile("cn-hangzhou", $_W['wlsetting']['sms']['note_appkey'], $_W['wlsetting']['sms']['note_secretKey']); |
|||
DefaultProfile::addEndpoint("cn-hangzhou", "cn-hangzhou", "Dysmsapi", "dysmsapi.aliyuncs.com"); |
|||
$acsClient = new DefaultAcsClient($profile); |
|||
m('aliyun/sendsmsrequest')->setSignName($_W['wlsetting']['sms']['note_sign']); |
|||
m('aliyun/sendsmsrequest')->setTemplateParam(json_encode($param)); |
|||
m('aliyun/sendsmsrequest')->setTemplateCode($smstpl['smstplid']); |
|||
m('aliyun/sendsmsrequest')->setPhoneNumbers($mobile); |
|||
$resp = $acsClient->getAcsResponse(m('aliyun/sendsmsrequest')); |
|||
$res = Util::object_array($resp); |
|||
if ($res['Code'] == 'OK') { |
|||
self::create_apirecord(-1, '', $_W['mid'], $mobile, 1, '阿里云身份验证'); |
|||
$recode = array("result" => 1); |
|||
} else { |
|||
$recode = array("result" => 2, "msg" => $res['Message']); |
|||
} |
|||
} else { |
|||
m('alidayu/topclient')->appkey = $_W['wlsetting']['sms']['note_appkey']; |
|||
m('alidayu/topclient')->secretKey = $_W['wlsetting']['sms']['note_secretKey']; |
|||
m('alidayu/smsnum')->setSmsType("normal"); |
|||
m('alidayu/smsnum')->setSmsFreeSignName($_W['wlsetting']['sms']['note_sign']); |
|||
m('alidayu/smsnum')->setSmsParam(json_encode($param)); |
|||
m('alidayu/smsnum')->setRecNum($mobile); |
|||
m('alidayu/smsnum')->setSmsTemplateCode($smstpl['smstplid']); |
|||
$resp = m('alidayu/topclient')->execute(m('alidayu/smsnum'), '6100e23657fb0b2d0c78568e55a3031134be9a3a5d4b3a365753805'); |
|||
$res = Util::object_array($resp); |
|||
if ($res['result']['success'] == 1) { |
|||
self::create_apirecord(-1, '', $_W['mid'], $mobile, 1, '阿里大于身份验证'); |
|||
$recode = array("result" => 1); |
|||
} else { |
|||
$recode = array("result" => 2, "msg" => $res['sub_msg']); |
|||
} |
|||
} |
|||
|
|||
return $recode; |
|||
} |
|||
|
|||
//替换默认变量 |
|||
static function replaceTemplate($str, $datas = array()) { |
|||
foreach ($datas as $d) { |
|||
$str = str_replace('【' . $d['name'] . '】', $d['value'], $str); |
|||
} |
|||
return $str; |
|||
} |
|||
|
|||
//记录短信发送记录 |
|||
static function create_apirecord($sendmid, $sendmobile = '', $takemid, $takemobile, $type, $remark) { |
|||
global $_W; |
|||
$data = array( |
|||
'uniacid' => $_W['uniacid'], |
|||
'sendmid' => $sendmid, |
|||
'sendmobile' => $sendmobile, |
|||
'takemid' => $takemid, |
|||
'takemobile' => $takemobile, |
|||
'type' => $type, |
|||
'remark' => $remark, |
|||
'createtime' => time() |
|||
); |
|||
pdo_insert(PDO_NAME . 'apirecord', $data); |
|||
} |
|||
|
|||
//发送身份验证信息 |
|||
static function smsSF($code, $mobile) { |
|||
global $_W; |
|||
//发送海外短信时进行不同处理 |
|||
if (strlen($mobile) > 11) { |
|||
if (substr($mobile, 0, 2) == 86) { |
|||
$mobile = substr($mobile, -11); |
|||
} else { |
|||
$_W['wlsetting']['smsset']['dy_sf'] = $_W['wlsetting']['smsset']['dy_sfhw']; |
|||
} |
|||
} |
|||
$smses = pdo_fetch("select * from" . tablename(PDO_NAME . 'smstpl') . "where uniacid=:uniacid and id=:id", array(':uniacid' => $_W['uniacid'], ':id' => $_W['wlsetting']['smsset']['dy_sf'])); |
|||
$param = unserialize($smses['data']); |
|||
$datas = array( |
|||
array('name' => '系统名称', 'value' => $_W['wlsetting']['base']['name']), |
|||
array('name' => '版权信息', 'value' => $_W['wlsetting']['base']['copyright']), |
|||
array('name' => '验证码', 'value' => $code) |
|||
); |
|||
foreach ($param as $d) { |
|||
$params[$d['data_temp']] = self::replaceTemplate($d['data_shop'], $datas); |
|||
} |
|||
return self::sendSms($smses, $params, $mobile); |
|||
} |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class Template { |
|||
/** |
|||
* html转化tpl |
|||
* |
|||
* @access static public |
|||
* @name wl_template_compile |
|||
*/ |
|||
static function wl_template_compile($from, $to, $inmodule = false) { |
|||
global $_W; |
|||
$path = dirname($to); |
|||
if (!is_dir($path)) { |
|||
load()->func('file'); |
|||
Util::mkDirs($path); |
|||
} |
|||
$content = self::wl_template_parse(file_get_contents($from), $inmodule); |
|||
if (defined('IN_APP')) { |
|||
if (!empty($_W['wlsetting']['halfcard']['text']['halfcardtext'])) { |
|||
$content = str_replace('一卡通', $_W['wlsetting']['halfcard']['text']['halfcardtext'], $content); |
|||
} |
|||
if (!empty($_W['wlsetting']['halfcard']['text']['privilege'])) { |
|||
$content = str_replace('特权', $_W['wlsetting']['halfcard']['text']['privilege'], $content); |
|||
} |
|||
if (!empty($_W['wlsetting']['trade']['credittext'])) { |
|||
$content = str_replace('积分', $_W['wlsetting']['trade']['credittext'], $content); |
|||
} |
|||
if (!empty($_W['wlsetting']['trade']['moneytext'])) { |
|||
$content = str_replace('余额', $_W['wlsetting']['trade']['moneytext'], $content); |
|||
} |
|||
} |
|||
file_put_contents($to, $content); |
|||
} |
|||
|
|||
/** |
|||
* 转译模板 |
|||
* |
|||
* @access static public |
|||
* @name wl_template_parse |
|||
*/ |
|||
static function wl_template_parse($str, $inmodule = false) { |
|||
$str = preg_replace('/<!--{(.+?)}-->/s', '{$1}', $str); |
|||
$str = preg_replace('/{template\s+(.+?)}/', '<?php include wl_template($1, TEMPLATE_INCLUDEPATH);?>', $str); |
|||
$str = preg_replace('/{php\s+(.+?)}/', '<?php $1?>', $str); |
|||
$str = preg_replace('/{if\s+(.+?)}/', '<?php if($1) { ?>', $str); |
|||
$str = preg_replace('/{else}/', '<?php } else { ?>', $str); |
|||
$str = preg_replace('/{else ?if\s+(.+?)}/', '<?php } else if($1) { ?>', $str); |
|||
$str = preg_replace('/{\/if}/', '<?php } ?>', $str); |
|||
$str = preg_replace('/{loop\s+(\S+)\s+(\S+)}/', '<?php if(is_array($1)) { foreach($1 as $2) { ?>', $str); |
|||
$str = preg_replace('/{loop\s+(\S+)\s+(\S+)\s+(\S+)}/', '<?php if(is_array($1)) { foreach($1 as $2 => $3) { ?>', $str); |
|||
$str = preg_replace('/{\/loop}/', '<?php } } ?>', $str); |
|||
$str = preg_replace('/{(\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)}/', '<?php echo $1;?>', $str); |
|||
$str = preg_replace('/{(\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff\[\]\'\"\$]*)}/', '<?php echo $1;?>', $str); |
|||
$str = preg_replace('/{url\s+(\S+)}/', '<?php echo url($1);?>', $str); |
|||
$str = preg_replace('/{url\s+(\S+)\s+(array\(.+?\))}/', '<?php echo url($1, $2);?>', $str); |
|||
$str = @preg_replace_callback('/<\?php([^\?]+)\?>/s', "template_addquote", $str); |
|||
$str = preg_replace('/{([A-Z_\x7f-\xff][A-Z0-9_\x7f-\xff]*)}/s', '<?php echo $1;?>', $str); |
|||
$str = str_replace('{##', '{', $str); |
|||
$str = str_replace('##}', '}', $str); |
|||
$str = "<?php defined('IN_IA') or exit('Access Denied');?>" . $str; |
|||
return $str; |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,190 @@ |
|||
<?php |
|||
/** |
|||
* Comment: 小程序独立方法类 |
|||
* Author: zzw |
|||
* Date: 2019/11/7 15:29 |
|||
*/ |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
use EasyWeChat\Factory; |
|||
use EasyWeChat\Kernel\Messages\Raw; |
|||
|
|||
class WeApp { |
|||
/** |
|||
* Comment: 小程序二维码生成 |
|||
* Author: zzw |
|||
* Date: 2019/11/7 16:13 |
|||
* @param string $path |
|||
* @param string $name |
|||
* @param array $optional |
|||
* @return array|string |
|||
*/ |
|||
public static function getQrCode($path, $name = '', $optional = []) { |
|||
global $_W; |
|||
#1、获取小程序配置信息 |
|||
$app = self::getFactoryConfig(); |
|||
#2、生成小程序太阳码 |
|||
try { |
|||
//其中 $optional 为以下可选参数: |
|||
//width Int - 默认 430 二维码的宽度 |
|||
//auto_color 默认 false 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 |
|||
//line_color 数组,auto_color 为 false 时生效,使用 rgb 设置颜色 例如 ,示例:["r" => 0,"g" => 0,"b" => 0]。 |
|||
$qrCode = $app->app_code->get($path, $optional); |
|||
//判断返回内容为数组 则为错误抛出 正常返回内容应该为对象 |
|||
if(is_array($qrCode)) throw new Exception($qrCode['message']); |
|||
//储存太阳码信息 |
|||
$filePath = 'addons/' . MODULE_NAME . '/data/qrcode/'.$_W['uniacid'].'/'.date("Y-m-d", time()) . '/';//保存路径 |
|||
$savePath = IA_ROOT . '/' . $filePath;//保存完整路径 |
|||
if (!file_exists($savePath . $name)) { |
|||
if (empty($name)) $name = md5(uniqid(microtime(true), true)); |
|||
$qrCode->saveAs($savePath, $name); |
|||
} |
|||
return $filePath . $name; |
|||
} catch (Exception $e) { |
|||
//错误抛出 |
|||
$error = $e->getMessage(); |
|||
return error(0, $error); |
|||
} |
|||
} |
|||
/** |
|||
* Comment: 发送客服信息 |
|||
* Author: zzw |
|||
* Date: 2019/11/18 18:55 |
|||
* @param $input |
|||
* @throws \GuzzleHttp\Exception\GuzzleException |
|||
*/ |
|||
public static function CustomerService($input) { |
|||
global $_W; |
|||
#1、获取参数信息 |
|||
$openid = $input['FromUserName'];//发送者的openid |
|||
$content = $input['Content'];//用户发送的内容 |
|||
#1、获取社群信息 |
|||
$communityInfo = pdo_get(PDO_NAME . "community", ['id' => $content,'uniacid' => $_W['uniacid']], ['communqrcode', 'media_id', 'reply', 'media_endtime']); |
|||
#1、获取小程序配置信息 |
|||
$app = self::getFactoryConfig(); |
|||
#2、小程序客服操作 |
|||
try { |
|||
#2、判断图片id是否存在 不存在则上传图片换取图片id |
|||
if (empty($communityInfo['media_id']) || ($communityInfo['media_endtime'] < time())) { |
|||
#1、保证图片存在本地 |
|||
$imgPath = PATH_ATTACHMENT.'/' . $communityInfo['communqrcode'];//文件在本地服务器暂存地址 |
|||
wl_uploadImages($imgPath, tomedia($communityInfo['communqrcode'])); |
|||
#1、保证图片存在本地 |
|||
$updateImg = $app->media->uploadImage($imgPath); // $path 为本地文件路径 |
|||
if ($updateImg['media_id']) { |
|||
$communityInfo['media_id'] = $updateImg['media_id']; |
|||
pdo_update(PDO_NAME . "community", ['media_id' => $updateImg['media_id'], 'media_endtime' => time() + 48*3600], ['id' => $content]); |
|||
} |
|||
} |
|||
#2、发送二维码图片 |
|||
$message = new Raw(self::dataEncoding([ |
|||
"touser" => $openid, |
|||
"msgtype" => 'image', |
|||
"image" => [ |
|||
"media_id" => $communityInfo['media_id'] |
|||
] |
|||
])); |
|||
$app->customer_service->message($message)->to($openid)->send(); |
|||
#2、发送回复内容 |
|||
$messagess = new Raw(self::dataEncoding([ |
|||
"touser" => $openid, |
|||
"msgtype" => 'text', |
|||
"text" => [ |
|||
"content" => $communityInfo['reply'] |
|||
] |
|||
])); |
|||
$app->customer_service->message($messagess)->to($openid)->send(); |
|||
} catch (Exception $e) { |
|||
//错误抛出 |
|||
$error = $e->getMessage(); |
|||
Util::wl_log('customerService', PATH_MODULE . "log/", ['error' => $error, 'input' => $input], '微信小程序客服 —— 错误信息', false); //写入日志记录 |
|||
} |
|||
} |
|||
/** |
|||
* Comment: 微信小程序客服接口请求验证(配置接口时微信官方验证接口是否可用) |
|||
* Author: zzw |
|||
* Date: 2019/11/18 11:01 |
|||
* @param $info |
|||
* @return bool|mixed |
|||
*/ |
|||
public static function pleaseVerification($info) { |
|||
$signature = $info["signature"]; |
|||
$timestamp = $info["timestamp"]; |
|||
$nonce = $info["nonce"]; |
|||
$echostr = $info["echostr"]; |
|||
if ($signature && $timestamp && $nonce && $echostr) { |
|||
$set = Setting::wlsetting_read('wxapp_config'); |
|||
$token = $set['token']; |
|||
$tmpArr = array($token, $timestamp, $nonce); |
|||
sort($tmpArr, SORT_STRING); |
|||
$tmpStr = implode($tmpArr); |
|||
$tmpStr = sha1($tmpStr); |
|||
if ($tmpStr == $signature) { |
|||
return $echostr; |
|||
} else { |
|||
return false; |
|||
} |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
/** |
|||
* Comment: 数据编码(json) |
|||
* Author: zzw |
|||
* Date: 2019/11/18 11:29 |
|||
* @param $array |
|||
* @return false|mixed|string|string[]|null |
|||
*/ |
|||
public static function dataEncoding($array) { |
|||
if (version_compare(PHP_VERSION, '5.4.0', '<')) { |
|||
$str = json_encode($array); |
|||
$str = preg_replace_callback("#\\\u([0-9a-f]{4})#i", function ($matchs) { |
|||
return iconv('UCS-2BE', 'UTF-8', pack('H4', $matchs[1])); |
|||
}, $str); |
|||
return $str; |
|||
} else { |
|||
return json_encode($array, JSON_UNESCAPED_UNICODE); |
|||
} |
|||
} |
|||
/** |
|||
* Comment: 获取 EasyWeChat 的配置信息 |
|||
* Author: zzw |
|||
* Date: 2019/11/7 15:41 |
|||
* @return \EasyWeChat\MiniProgram\Application |
|||
*/ |
|||
protected static function getFactoryConfig() { |
|||
#1、生成配置信息 |
|||
$set = Setting::wlsetting_read('wxapp_config'); |
|||
$config = [ |
|||
'app_id' => trim($set['appid']), |
|||
'secret' => trim($set['secret']), |
|||
'response_type' => 'array', |
|||
]; |
|||
$object = Factory::miniProgram($config); |
|||
return $object; |
|||
} |
|||
/** |
|||
* Comment: 小程序手机号解密 |
|||
* Author: zzw |
|||
* Date: 2020/9/8 9:22 |
|||
* @param $session_key |
|||
* @param $iv |
|||
* @param $data |
|||
* @return array |
|||
* @throws \EasyWeChat\Kernel\Exceptions\DecryptException |
|||
*/ |
|||
public static function decryptedMobile($session_key , $iv , $data){ |
|||
$app = self::getFactoryConfig(); |
|||
return $app->encryptor->decryptData($session_key, $iv, $data); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
@ -0,0 +1,249 @@ |
|||
<?php |
|||
/** |
|||
* Comment: 小程序微信支付功能 |
|||
* Author: ZZW |
|||
* Date: 2018/9/25 |
|||
* Time: 11:43 |
|||
*/ |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class WeChatPay { |
|||
protected $appid;//小程序appid |
|||
protected $openid;//用户openid |
|||
protected $mch_id;//商户id |
|||
protected $key;//商户支付key |
|||
protected $out_trade_no;//订单号 |
|||
protected $body;//商品简单描述 |
|||
protected $total_fee;//订单总金额(单位:分) |
|||
|
|||
/** |
|||
* Comment: 统一下单接口 |
|||
* Author: zzw |
|||
* @param $mid 用户id |
|||
* @param $orderNum 订单号 |
|||
* @param $goodDescribe 商品描述 |
|||
* @param $fee 实际支付金额 |
|||
* @return array |
|||
*/ |
|||
public static function pay($mid, $orderNum, $goodDescribe, $fee) { |
|||
$pay = new WeChatPay(); |
|||
//更新受保护的数据 |
|||
$pay->getCode($mid, $orderNum, $goodDescribe, $fee); |
|||
//开始支付数据的操作 |
|||
$return = $pay->weixinapp(); |
|||
|
|||
return $return; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 更新数据 |
|||
* Author: zzw |
|||
* @param $mid 用户id |
|||
* @param $orderNum 订单号 |
|||
* @param $goodDescribe 商品描述 |
|||
* @param $fee 实际支付金额 |
|||
*/ |
|||
private function getCode($mid, $orderNum, $goodDescribe, $fee) { |
|||
$set = unserialize(pdo_getcolumn(PDO_NAME . "setting", array('key' => 'city_selection_set'), 'value')); |
|||
$this->appid = $set['appid'];//appid |
|||
$this->openid = pdo_getcolumn(PDO_NAME . "member", array('id' => $mid), array('wechat_openid')); //openid |
|||
$this->mch_id = $set['mch_id'];//mch_id 商户id |
|||
$this->key = $set['pay_key'];//key 支付key |
|||
$this->out_trade_no = $orderNum; //out_trade_no 订单号 |
|||
$this->body = $goodDescribe; //body 商品描述 |
|||
$this->total_fee = $fee; //total_fee 实际支付总金额 |
|||
} |
|||
|
|||
/** |
|||
* Comment: 微信小程序接口 |
|||
* Author: zzw |
|||
* @return array |
|||
*/ |
|||
private function weixinapp() { |
|||
//统一下单接口 |
|||
$unifiedorder = $this->unifiedorder(); |
|||
$parameters = array( |
|||
'appId' => $this->appid, //小程序ID |
|||
'timeStamp' => '' . time() . '', //时间戳 |
|||
'nonceStr' => $this->createNoncestr(), //随机串 |
|||
'package' => 'prepay_id=' . $unifiedorder['prepay_id'], //数据包 |
|||
'signType' => 'MD5'//签名方式 |
|||
); |
|||
//签名 |
|||
$parameters['paySign'] = $this->getSign($parameters); |
|||
return $parameters; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 统一下单接口 |
|||
* Author: zzw |
|||
* @return mixed |
|||
*/ |
|||
private function unifiedorder() { |
|||
$url = 'https://api.mch.weixin.qq.com/pay/unifiedorder'; |
|||
$parameters = array( |
|||
'appid' => $this->appid, //小程序ID |
|||
'mch_id' => $this->mch_id, //商户号 |
|||
'nonce_str' => $this->createNoncestr(), //随机字符串 |
|||
'body' => $this->body,//商品描述 |
|||
'out_trade_no' => $this->out_trade_no,//商户订单号 |
|||
'total_fee' => $this->total_fee * 100,//总金额 单位 分 |
|||
'notify_url' => 'http://www.weixin.qq.com/wxpay/pay.php',//通知地址 确保外网能正常访问 |
|||
'openid' => $this->openid, //用户id |
|||
'trade_type' => 'JSAPI'//交易类型 |
|||
); |
|||
|
|||
//统一下单签名 |
|||
$parameters['sign'] = $this->getSign($parameters); |
|||
$xmlData = $this->arrayToXml($parameters); |
|||
$return = $this->xmlToArray($this->postXmlCurl($xmlData, $url, 60)); |
|||
|
|||
return $return; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 请求获取支付数据 |
|||
* Author: zzw |
|||
* @param $xml |
|||
* @param $url |
|||
* @param int $second |
|||
* @return mixed |
|||
*/ |
|||
private static function postXmlCurl($xml, $url, $second = 30) { |
|||
$ch = curl_init(); |
|||
//设置超时 |
|||
curl_setopt($ch, CURLOPT_TIMEOUT, $second); |
|||
curl_setopt($ch, CURLOPT_URL, $url); |
|||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
|||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); //严格校验 |
|||
//设置header |
|||
curl_setopt($ch, CURLOPT_HEADER, FALSE); |
|||
//要求结果为字符串且输出到屏幕上 |
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
|||
//post提交方式 |
|||
curl_setopt($ch, CURLOPT_POST, TRUE); |
|||
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); |
|||
|
|||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); |
|||
curl_setopt($ch, CURLOPT_TIMEOUT, 40); |
|||
set_time_limit(0); |
|||
|
|||
//运行curl |
|||
$data = curl_exec($ch); |
|||
//返回结果 |
|||
if ($data) { |
|||
curl_close($ch); |
|||
return $data; |
|||
} else { |
|||
$error = curl_errno($ch); |
|||
curl_close($ch); |
|||
return "curl出错,错误码:$error"; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Comment: 数组转换成xml |
|||
* Author: zzw |
|||
* @param $arr |
|||
* @return string |
|||
*/ |
|||
private function arrayToXml($arr) { |
|||
$xml = "<root>"; |
|||
foreach ($arr as $key => $val) { |
|||
if (is_array($val)) { |
|||
$xml .= "<" . $key . ">" . arrayToXml($val) . "</" . $key . ">"; |
|||
} else { |
|||
$xml .= "<" . $key . ">" . $val . "</" . $key . ">"; |
|||
} |
|||
} |
|||
$xml .= "</root>"; |
|||
return $xml; |
|||
} |
|||
|
|||
/** |
|||
* Comment: xml转换成数组 |
|||
* Author: zzw |
|||
* @param $xml |
|||
* @return mixed |
|||
*/ |
|||
private function xmlToArray($xml) { |
|||
|
|||
|
|||
//禁止引用外部xml实体 |
|||
|
|||
|
|||
libxml_disable_entity_loader(true); |
|||
|
|||
|
|||
$xmlstring = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); |
|||
|
|||
|
|||
$val = json_decode(json_encode($xmlstring), true); |
|||
|
|||
|
|||
return $val; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 产生随机字符串,不长于32位 |
|||
* Author: zzw |
|||
* @param int $length |
|||
* @return string |
|||
*/ |
|||
private function createNoncestr($length = 32) { |
|||
$chars = "abcdefghijklmnopqrstuvwxyz0123456789"; |
|||
$str = ""; |
|||
for ($i = 0; $i < $length; $i++) { |
|||
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); |
|||
} |
|||
return $str; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 生成签名 |
|||
* Author: zzw |
|||
* @param $Obj |
|||
* @return string |
|||
*/ |
|||
private function getSign($Obj) { |
|||
foreach ($Obj as $k => $v) { |
|||
$Parameters[$k] = $v; |
|||
} |
|||
//签名步骤一:按字典序排序参数 |
|||
ksort($Parameters); |
|||
$String = $this->formatBizQueryParaMap($Parameters, false); |
|||
//签名步骤二:在string后加入KEY |
|||
$String = $String . "&key=" . $this->key; |
|||
//签名步骤三:MD5加密 |
|||
$String = md5($String); |
|||
//签名步骤四:所有字符转为大写 |
|||
$result_ = strtoupper($String); |
|||
return $result_; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 格式化参数,签名过程需要使用 |
|||
* Author: zzw |
|||
* @param $paraMap |
|||
* @param $urlencode |
|||
* @return bool|string |
|||
*/ |
|||
private function formatBizQueryParaMap($paraMap, $urlencode) { |
|||
$buff = ""; |
|||
ksort($paraMap); |
|||
foreach ($paraMap as $k => $v) { |
|||
if ($urlencode) { |
|||
$v = urlencode($v); |
|||
} |
|||
$buff .= $k . "=" . $v . "&"; |
|||
} |
|||
if (strlen($buff) > 0) { |
|||
$reqPar = substr($buff, 0, strlen($buff) - 1); |
|||
} |
|||
return $reqPar; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
@ -0,0 +1,915 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class WeixinPay { |
|||
|
|||
//退款 |
|||
public function refund($arr) { |
|||
global $_W; |
|||
$setting = uni_setting($_W['uniacid'], array('payment')); |
|||
|
|||
$data['appid'] = $_W['account']['key']; |
|||
$data['mch_id'] = $setting['payment']['wechat']['mchid']; |
|||
|
|||
$data['transaction_id'] = $arr['transid']; |
|||
$data['out_refund_no'] = $arr['transid'] . rand(1000, 9999); |
|||
|
|||
$data['total_fee'] = $arr['totalmoney'] * 100; |
|||
$data['refund_fee'] = $arr['refundmoney'] * 100; |
|||
$data['op_user_id'] = $setting['payment']['wechat']['mchid']; |
|||
$data['nonce_str'] = $this->createNoncestr(); |
|||
|
|||
$data['sign'] = $this->getSign($data); |
|||
|
|||
if (empty($data['appid']) || empty($data['mch_id'])) { |
|||
$rearr['return_msg'] = '请先在微擎的功能选项-支付参数内设置微信商户号和秘钥'; |
|||
return $rearr; |
|||
} |
|||
if ($data['total_fee'] > $data['refund_fee']) { |
|||
$rearr['return_msg'] = '退款金额不能大于实际支付金额'; |
|||
return $rearr; |
|||
} |
|||
$xml = $this->arrayToXml($data); |
|||
$url = "https://api.mch.weixin.qq.com/secapi/pay/refund"; |
|||
$re = $this->wxHttpsRequestPem($xml, $url); |
|||
$rearr = $this->xmlToArray($re); |
|||
|
|||
return $rearr; |
|||
} |
|||
|
|||
//查询退款 |
|||
public function checkRefund($transid) { |
|||
global $_W; |
|||
$setting = uni_setting($_W['uniacid'], array('payment')); |
|||
$data['appid'] = $_W['account']['key']; |
|||
$data['mch_id'] = $setting['payment']['wechat']['mchid']; |
|||
$data['transaction_id'] = $transid; |
|||
$data['nonce_str'] = $this->createNoncestr(); |
|||
$data['sign'] = $this->getSign($data); |
|||
|
|||
if (empty($data['appid']) || empty($data['mch_id'])) { |
|||
$rearr['return_msg'] = '请先在微擎的功能选项-支付参数内设置微信商户号和秘钥'; |
|||
return $rearr; |
|||
} |
|||
$xml = $this->arrayToXml($data); |
|||
$url = "https://api.mch.weixin.qq.com/pay/refundquery"; |
|||
$re = $this->wxHttpsRequestPem($xml, $url); |
|||
$rearr = $this->xmlToArray($re); |
|||
|
|||
return $rearr; |
|||
} |
|||
|
|||
//企业付款 |
|||
public function finance($openid = '', $money = 0, $desc = '', $realname, $trade_no) { |
|||
global $_W; |
|||
$setting = uni_setting($_W['uniacid'], array('payment')); |
|||
|
|||
$refund_setting = $setting['payment']['wechat_refund']; |
|||
if ($refund_setting['switch'] != 1) { |
|||
return error(1, '未开启微信退款功能!'); |
|||
} |
|||
if (empty($refund_setting['key']) || empty($refund_setting['cert'])) { |
|||
return error(1, '缺少微信证书!'); |
|||
} |
|||
$cert = authcode($refund_setting['cert'], 'DECODE'); |
|||
$key = authcode($refund_setting['key'], 'DECODE'); |
|||
file_put_contents(ATTACHMENT_ROOT . $_W['uniacid'] . '_wechat_refund_all.pem', $cert . $key); |
|||
|
|||
$data = array(); |
|||
$data['mch_appid'] = $_W['account']['key']; |
|||
$data['mchid'] = $setting['payment']['wechat']['mchid']; |
|||
$data['nonce_str'] = $this->createNoncestr();; |
|||
$data['partner_trade_no'] = $trade_no; |
|||
$data['openid'] = $openid; |
|||
if (!empty($realname)) { |
|||
$data['re_user_name'] = $realname; |
|||
} |
|||
$data['check_name'] = 'NO_CHECK'; |
|||
$data['amount'] = $money * 100; |
|||
$data['desc'] = empty($desc) ? '商家佣金提现' : $desc; |
|||
$data['spbill_create_ip'] = gethostbyname($_SERVER["HTTP_HOST"]); |
|||
$data['sign'] = $this->getSign($data); |
|||
if (empty($data['mch_appid'])) { |
|||
$rearr['return_msg'] = '请先在微擎的功能选项-支付参数内设置微信商户号和秘钥'; |
|||
return $rearr; |
|||
} |
|||
$xml = $this->arrayToXml($data); |
|||
$url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"; |
|||
$re = $this->wxHttpsRequestPem($xml, $url); |
|||
$rearr = $this->xmlToArray($re); |
|||
return $rearr; |
|||
} |
|||
|
|||
public function createNoncestr($length = 32) { |
|||
$chars = "abcdefghijklmnopqrstuvwxyz0123456789"; |
|||
$str = ""; |
|||
for ($i = 0; $i < $length; $i++) { |
|||
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); |
|||
} |
|||
return $str; |
|||
} |
|||
|
|||
function formatBizQueryParaMap($paraMap, $urlencode) { |
|||
$buff = ""; |
|||
ksort($paraMap); |
|||
foreach ($paraMap as $k => $v) { |
|||
if ($urlencode) { |
|||
$v = urlencode($v); |
|||
} |
|||
$buff .= $k . "=" . $v . "&"; |
|||
} |
|||
$reqPar; |
|||
if (strlen($buff) > 0) { |
|||
$reqPar = substr($buff, 0, strlen($buff) - 1); |
|||
} |
|||
return $reqPar; |
|||
} |
|||
|
|||
public function getSign($Obj) { |
|||
global $_W; |
|||
$setting = uni_setting($_W['uniacid'], array('payment')); |
|||
foreach ($Obj as $k => $v) { |
|||
$Parameters[$k] = $v; |
|||
} |
|||
ksort($Parameters); |
|||
$String = $this->formatBizQueryParaMap($Parameters, false); |
|||
$String = $String . "&key=" . $setting['payment']['wechat']['apikey']; |
|||
$String = md5($String); |
|||
$result_ = strtoupper($String); |
|||
return $result_; |
|||
} |
|||
|
|||
public function arrayToXml($arr) { |
|||
$xml = "<xml>"; |
|||
foreach ($arr as $key => $val) { |
|||
if (is_numeric($val)) { |
|||
$xml .= "<" . $key . ">" . $val . "</" . $key . ">"; |
|||
} else { |
|||
$xml .= "<" . $key . "><![CDATA[" . $val . "]]></" . $key . ">"; |
|||
} |
|||
} |
|||
$xml .= "</xml>"; |
|||
return $xml; |
|||
} |
|||
|
|||
public function xmlToArray($xml) { |
|||
$array_data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); |
|||
return $array_data; |
|||
} |
|||
|
|||
|
|||
public function wxHttpsRequestPem($vars, $url, $second = 30, $aHeader = array()) { |
|||
global $_W; |
|||
$ch = curl_init(); |
|||
curl_setopt($ch, CURLOPT_TIMEOUT, $second); |
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|||
curl_setopt($ch, CURLOPT_URL, $url); |
|||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
|||
curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM'); |
|||
curl_setopt($ch, CURLOPT_SSLCERT, ATTACHMENT_ROOT . $_W['uniacid'] . '_wechat_refund_all.pem'); |
|||
// curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM'); |
|||
// curl_setopt($ch,CURLOPT_SSLKEY, PATH_DATA."cert/".$_W['uniacid']."/wechat/apiclient_key.pem"); |
|||
// curl_setopt($ch,CURLOPT_CAINFO,'PEM'); |
|||
// curl_setopt($ch,CURLOPT_CAINFO,IA_ROOT . '/attachment/feng_fightgroups/cert/' . $_W['uniacid'] . '/rootca.pem'); |
|||
if (count($aHeader) >= 1) { |
|||
curl_setopt($ch, CURLOPT_HTTPHEADER, $aHeader); |
|||
} |
|||
curl_setopt($ch, CURLOPT_POST, 1); |
|||
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars); |
|||
$data = curl_exec($ch); |
|||
unlink(ATTACHMENT_ROOT . $_W['uniacid'] . '_wechat_refund_all.pem'); |
|||
if ($data) { |
|||
curl_close($ch); |
|||
return $data; |
|||
} else { |
|||
$error = curl_errno($ch); |
|||
echo "call faild, errorCode:$error\n"; |
|||
curl_close($ch); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Comment: 发送微信红包 |
|||
* Author: zzw |
|||
*/ |
|||
static public function sendingRedPackets($info) { |
|||
global $_W; |
|||
#1、验证签名证书 |
|||
$setting = uni_setting($_W['uniacid'], array('payment')); |
|||
$refund_setting = $setting['payment']['wechat_refund']; |
|||
if ($refund_setting['switch'] != 1) { |
|||
return error(1, '未开启微信付款功能!'); |
|||
} |
|||
if (empty($refund_setting['key']) || empty($refund_setting['cert'])) { |
|||
return error(1, '缺少微信证书!'); |
|||
} |
|||
$cert = authcode($refund_setting['cert'], 'DECODE'); |
|||
$key = authcode($refund_setting['key'], 'DECODE'); |
|||
file_put_contents(ATTACHMENT_ROOT . $_W['uniacid'] . '_wechat_refund_all.pem', $cert . $key); |
|||
#2、基本信息 |
|||
$payment = $setting['payment']; |
|||
$cloud = Cloud::wl_syssetting_read('auth'); |
|||
$info = array( |
|||
'nonce_str' => random(32),//随机码 |
|||
'mch_billno' => $info['mch_billno'],//订单号 |
|||
'mch_id' => $payment['wechat']['mchid'],//商户id |
|||
'wxappid' => $_W['account']['key'],//appid |
|||
'send_name' => $_W['wlsetting']['base']['name'],//平台名称 |
|||
're_openid' => $info['re_openid'],//收款人openid |
|||
'total_amount' => $info['total_amount'],//发送金额 单位:分 |
|||
'total_num' => 1,//发送数量 |
|||
'wishing' => '恭喜发财,大吉大利',//留言 |
|||
'client_ip' => $cloud['ip'],//发送主机ip |
|||
'act_name' => '红包提现',//$info['act_name'],//活动名称/商品名称 |
|||
'remark' => $info['remark'],//备注信息 |
|||
'scene_id' => 'PRODUCT_5'//使用场景 这里是渠道分润 |
|||
); |
|||
#3、获取签名信息 |
|||
ksort($info); |
|||
$sign = ''; |
|||
foreach ($info as $k => $v) { |
|||
if (!empty($v)) { |
|||
$sign .= $k . '=' . $v . '&'; |
|||
} |
|||
} |
|||
$sign .= "key=" . $setting['payment']['wechat']['apikey']; |
|||
$info['sign'] = strtoupper(md5($sign)); |
|||
$pay = new WeixinPay(); |
|||
$xml = $pay->arrayToXml($info); |
|||
$url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack'; |
|||
$re = $pay->wxHttpsRequestPem($xml, $url); |
|||
$rearr = $pay->xmlToArray($re); |
|||
return $rearr; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 红包打款 查询接口 |
|||
* Author: zzw |
|||
* @return array|mixed |
|||
*/ |
|||
static public function getRedPacketsInfo($info) { |
|||
global $_W; |
|||
#1、验证签名证书 |
|||
$setting = uni_setting($_W['uniacid'], array('payment')); |
|||
$refund_setting = $setting['payment']['wechat_refund']; |
|||
if ($refund_setting['switch'] != 1) { |
|||
return error(1, '未开启微信付款功能!'); |
|||
} |
|||
if (empty($refund_setting['key']) || empty($refund_setting['cert'])) { |
|||
return error(1, '缺少微信证书!'); |
|||
} |
|||
$cert = authcode($refund_setting['cert'], 'DECODE'); |
|||
$key = authcode($refund_setting['key'], 'DECODE'); |
|||
file_put_contents(ATTACHMENT_ROOT . $_W['uniacid'] . '_wechat_refund_all.pem', $cert . $key); |
|||
#2、基本信息 |
|||
$payment = $setting['payment']; |
|||
$info = array( |
|||
'nonce_str' => random(32), |
|||
'mch_billno' => $info['mch_billno'], |
|||
'mch_id' => $payment['wechat']['mchid'], |
|||
'appid' => $_W['account']['key'], |
|||
'bill_type' => 'MCHT', |
|||
); |
|||
#3、获取签名信息 |
|||
ksort($info); |
|||
$sign = ''; |
|||
foreach ($info as $k => $v) { |
|||
if (!empty($v)) { |
|||
$sign .= $k . '=' . $v . '&'; |
|||
} |
|||
} |
|||
$sign .= "key=" . $setting['payment']['wechat']['apikey']; |
|||
$info['sign'] = strtoupper(md5($sign)); |
|||
$pay = new WeixinPay(); |
|||
$xml = $pay->arrayToXml($info); |
|||
$url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/gethbinfo'; |
|||
$re = $pay->wxHttpsRequestPem($xml, $url); |
|||
$rearr = $pay->xmlToArray($re); |
|||
return $rearr; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 获取平台分账信息 |
|||
* Author: wlf |
|||
* Date: 2020/09/04 11:24 |
|||
*/ |
|||
public function getSysAllInfo($price,$source,$set,$uniacid){ |
|||
global $_W; |
|||
$_W['uniacid'] = $uniacid; |
|||
$cashset = Setting::wlsetting_read('cashset'); |
|||
$payment_set = Setting::wlsetting_read('payment_set'); |
|||
if($source != 3 && $cashset['wxsyspercent'] > 0){ |
|||
$sysmoney = $price * $cashset['wxsyspercent']; |
|||
if($sysmoney > 0){ |
|||
$paysetid = $payment_set['wechat']['wechat']; |
|||
// if($_W['wlsetting']['cashset']['wxsysalltype'] == 1){ |
|||
// //添加关系 |
|||
// $res = self::addReceiver('MERCHANT_ID',$_W['wlsetting']['cashset']['wxmerchantid'],'SERVICE_PROVIDER',$_W['wlsetting']['cashset']['wxmerchantname'],$set); |
|||
// if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS'){ |
|||
// $data = [ |
|||
// 'type' => 'MERCHANT_ID', |
|||
// 'account' => $_W['wlsetting']['cashset']['wxmerchantid'], |
|||
// 'amount' => $sysmoney, |
|||
// 'description' => '平台抽佣', |
|||
// ]; |
|||
// }else{ |
|||
// file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
// } |
|||
// }else if($_W['wlsetting']['cashset']['wxsysalltype'] == 2){ |
|||
// $cashopenid = pdo_getcolumn(PDO_NAME.'member',array('id'=>$_W['wlsetting']['cashset']['wxallmid']),'openid'); |
|||
// $res = self::addReceiver('PERSONAL_OPENID',$cashopenid,'SERVICE_PROVIDER','',$set); |
|||
// if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS') { |
|||
// $data = [ |
|||
// 'type' => 'PERSONAL_OPENID', |
|||
// 'account' => $cashopenid, |
|||
// 'amount' => $sysmoney, |
|||
// 'description' => '平台抽佣', |
|||
// ]; |
|||
// }else{ |
|||
// file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
// } |
|||
// } |
|||
} |
|||
}else if($source == 3 && $cashset['appsyspercent'] > 0){ |
|||
$sysmoney = $price * $cashset['appsyspercent']; |
|||
if($sysmoney > 0){ |
|||
$paysetid = $payment_set['wxapp']['wechat']; |
|||
// if($_W['wlsetting']['cashset']['appsysalltype'] == 1){ |
|||
// $res = self::addReceiver('MERCHANT_ID',$_W['wlsetting']['cashset']['appmerchantid'],'SERVICE_PROVIDER',$_W['wlsetting']['cashset']['appmerchantname'],$set); |
|||
// if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS') { |
|||
// $data = [ |
|||
// 'type' => 'MERCHANT_ID', |
|||
// 'account' => $_W['wlsetting']['cashset']['appmerchantid'], |
|||
// 'amount' => $sysmoney, |
|||
// 'description' => '平台抽佣', |
|||
// ]; |
|||
// }else{ |
|||
// file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
// } |
|||
// }else if($_W['wlsetting']['cashset']['appsysalltype'] == 2){ |
|||
// $cashopenid = pdo_getcolumn(PDO_NAME.'member',array('id'=>$_W['wlsetting']['cashset']['appallmid']),'wechat_openid'); |
|||
// $res = self::addReceiver('PERSONAL_OPENID',$cashopenid,'SERVICE_PROVIDER','',$set); |
|||
// if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS') { |
|||
// $data = [ |
|||
// 'type' => 'PERSONAL_OPENID', |
|||
// 'account' => $cashopenid, |
|||
// 'amount' => $sysmoney, |
|||
// 'description' => '平台抽佣', |
|||
// ]; |
|||
// }else{ |
|||
// file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
// } |
|||
// } |
|||
} |
|||
} |
|||
if($paysetid > 0){ |
|||
$info = pdo_get(PDO_NAME."payment",['id'=>$paysetid]); |
|||
$Setinfo = json_decode($info['param'],true); |
|||
$res = self::addReceiver('MERCHANT_ID',$Setinfo['sub_shop_number'],'SERVICE_PROVIDER',$Setinfo['merchantname'],$set); |
|||
if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS'){ |
|||
$data = [ |
|||
'type' => 'MERCHANT_ID', |
|||
'account' => $Setinfo['sub_shop_number'], |
|||
'amount' => $sysmoney, |
|||
'description' => '平台抽佣', |
|||
]; |
|||
}else{ |
|||
file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
} |
|||
} |
|||
return !empty($data) ? $data : 0; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 获取分销分账信息 |
|||
* Author: wlf |
|||
* Date: 2020/09/04 14:15 |
|||
*/ |
|||
public function getDisAllInfo($disid,$disprice,$source,$set){ |
|||
global $_W; |
|||
if($source == 1){ |
|||
$openid = pdo_getcolumn(PDO_NAME.'member',array('distributorid'=>$disid),'openid'); |
|||
}else{ |
|||
$openid = pdo_getcolumn(PDO_NAME.'member',array('distributorid'=>$disid),'wechat_openid'); |
|||
} |
|||
if(!empty($openid)){ |
|||
$res = self::addReceiver('PERSONAL_OPENID',$openid,'DISTRIBUTOR','',$set); |
|||
if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS') { |
|||
$data = [ |
|||
'type' => 'PERSONAL_OPENID', |
|||
'account' => $openid, |
|||
'amount' => $disprice * 100, |
|||
'description' => '分佣', |
|||
]; |
|||
}else{ |
|||
file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
} |
|||
} |
|||
return !empty($data) ? $data : 0; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 获取业务员分账信息 |
|||
* Author: wlf |
|||
* Date: 2020/09/04 15:53 |
|||
*/ |
|||
public function getSaleAllInfo($mid,$salesprice,$source,$set){ |
|||
global $_W; |
|||
if($source == 1){ |
|||
$openid = pdo_getcolumn(PDO_NAME.'member',array('mid'=>$mid),'openid'); |
|||
}else{ |
|||
$openid = pdo_getcolumn(PDO_NAME.'member',array('mid'=>$mid),'wechat_openid'); |
|||
} |
|||
if(!empty($openid)){ |
|||
$res = self::addReceiver('PERSONAL_OPENID',$openid,'STAFF','',$set); |
|||
if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS') { |
|||
$data = [ |
|||
'type' => 'PERSONAL_OPENID', |
|||
'account' => $openid, |
|||
'amount' => $salesprice * 100, |
|||
'description' => '业务员', |
|||
]; |
|||
}else{ |
|||
file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
} |
|||
} |
|||
return !empty($data) ? $data : 0; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 获取代理分账信息 |
|||
* Author: wlf |
|||
* Date: 2020/09/04 16:09 |
|||
*/ |
|||
public function getAgentAllInfo($aid,$agentprice,$source,$set){ |
|||
global $_W; |
|||
$agentset = pdo_get('wlmerchant_agentusers',array('id' => $aid),array('wxpaysetid','apppaysetid')); |
|||
if($source == 1 || $source == 2){ |
|||
$paysetid = $agentset['wxpaysetid']; |
|||
// if($agentset['wxsysalltype'] == 1){ |
|||
// //添加关系 |
|||
// $res = self::addReceiver('MERCHANT_ID',$agentset['wxmerchantid'],'PARTNER',$agentset['wxmerchantname'],$set); |
|||
// if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS'){ |
|||
// $data = [ |
|||
// 'type' => 'MERCHANT_ID', |
|||
// 'account' => $agentset['wxmerchantid'], |
|||
// 'amount' => $agentprice * 100, |
|||
// 'description' => '代理抽佣', |
|||
// ]; |
|||
// }else{ |
|||
// file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
// } |
|||
// }else{ |
|||
// //添加关系 |
|||
// $cashopenid = pdo_getcolumn(PDO_NAME.'member',array('id'=>$agentset['wxallmid']),'openid'); |
|||
// $res = self::addReceiver('PERSONAL_OPENID',$cashopenid,'PARTNER','',$set); |
|||
// if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS'){ |
|||
// $data = [ |
|||
// 'type' => 'PERSONAL_OPENID', |
|||
// 'account' => $cashopenid, |
|||
// 'amount' => $agentprice * 100, |
|||
// 'description' => '代理抽佣', |
|||
// ]; |
|||
// }else{ |
|||
// file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
// } |
|||
// } |
|||
}else if($source == 3){ |
|||
$paysetid = $agentset['apppaysetid']; |
|||
// if($agentset['appsysalltype'] == 1){ |
|||
// //添加关系 |
|||
// $res = self::addReceiver('MERCHANT_ID',$agentset['appmerchantid'],'PARTNER',$agentset['appmerchantname'],$set); |
|||
// if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS'){ |
|||
// $data = [ |
|||
// 'type' => 'MERCHANT_ID', |
|||
// 'account' => $agentset['appmerchantid'], |
|||
// 'amount' => $agentprice * 100, |
|||
// 'description' => '代理抽佣', |
|||
// ]; |
|||
// }else{ |
|||
// file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
// } |
|||
// }else{ |
|||
// //添加关系 |
|||
// $cashopenid = pdo_getcolumn(PDO_NAME.'member',array('id'=>$agentset['appallmid']),'wechat_openid'); |
|||
// $res = self::addReceiver('PERSONAL_OPENID',$cashopenid,'PARTNER','',$set); |
|||
// if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS'){ |
|||
// $data = [ |
|||
// 'type' => 'PERSONAL_OPENID', |
|||
// 'account' => $cashopenid, |
|||
// 'amount' => $agentprice * 100, |
|||
// 'description' => '代理抽佣', |
|||
// ]; |
|||
// }else{ |
|||
// file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
// } |
|||
// } |
|||
} |
|||
if($paysetid > 0){ |
|||
$info = pdo_get(PDO_NAME."payment",['id'=>$paysetid]); |
|||
$Setinfo = json_decode($info['param'],true); |
|||
$res = self::addReceiver('MERCHANT_ID',$Setinfo['sub_shop_number'],'SERVICE_PROVIDER',$Setinfo['merchantname'],$set); |
|||
if($res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS'){ |
|||
$data = [ |
|||
'type' => 'MERCHANT_ID', |
|||
'account' => $Setinfo['sub_shop_number'], |
|||
'amount' => $agentprice * 100, |
|||
'description' => '代理抽佣', |
|||
]; |
|||
}else{ |
|||
file_put_contents(PATH_DATA . "allocation_error.log", var_export($res, true) . PHP_EOL, FILE_APPEND); |
|||
} |
|||
} |
|||
return !empty($data) ? $data : 0; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 服务商订单结算分账借口 |
|||
* Author: wlf |
|||
* Date: 2020/09/08 14:10 |
|||
*/ |
|||
public function allocationPro($orderid,$type,$source,$salesinfo = [],$salesmoney = 0){ |
|||
global $_W; |
|||
$receivers = []; |
|||
$sysmoney = $disonemoney = $distwomoney = $storemoney = 0; |
|||
//获取订单数据 |
|||
switch ($type){ |
|||
case '1': |
|||
$order = pdo_get(PDO_NAME.'rush_order',array('id'=>$orderid),array('sid','uniacid','settlementmoney','transid','aid','paysetid','orderno','actualprice','disorderid')); |
|||
$price = $order['actualprice']; |
|||
$storemoney = $order['settlementmoney']; |
|||
break; |
|||
case '4': |
|||
$order = pdo_get(PDO_NAME.'halfcard_record',array('id'=>$orderid),array('transid','uniacid','aid','paysetid','orderno','price','disorderid')); |
|||
$price = $order['price']; |
|||
break; |
|||
default : |
|||
$order = pdo_get(PDO_NAME.'order',array('id'=>$orderid),array('sid','settlementmoney','transid','uniacid','plugin','aid','paysetid','orderno','price','disorderid')); |
|||
$price = $order['price']; |
|||
$plugin = $order['plugin']; |
|||
$storemoney = $order['settlementmoney']; |
|||
break; |
|||
} |
|||
if(empty($order['transid'])) { |
|||
$order['transid'] = pdo_getcolumn(PDO_NAME . 'paylogvfour', array('tid' => $order['orderno']), 'transaction_id'); |
|||
} |
|||
//基础信息 |
|||
$getUrl = "https://api.mch.weixin.qq.com/secapi/pay/profitsharing"; |
|||
$filePath = PATH_ATTACHMENT . "public_file/" . MODULE_NAME . "/"; |
|||
$id = $order['paysetid']; |
|||
$info = pdo_get(PDO_NAME."payment",['id'=>$id]); |
|||
$setting = json_decode($info['param'],true); |
|||
//获取平台分账信息 |
|||
$sysinfo = self::getSysAllInfo($price,$source,$setting,$order['uniacid']); |
|||
if(!empty($sysinfo)){ |
|||
$receivers[] = $sysinfo; |
|||
$sysmoney = sprintf("%.2f",$sysinfo['amount'] / 100); |
|||
} |
|||
//获取分销分账信息 |
|||
if($order['disorderid'] > 0){ |
|||
$disorder = pdo_get('wlmerchant_disorder',array('id' => $order['disorderid']),array('oneleadid','twoleadid','leadmoney')); |
|||
$leadmoney = unserialize($disorder['leadmoney']); |
|||
if($disorder['oneleadid'] > 0 && $leadmoney['one'] > 0){ |
|||
$onedisinfo = self::getDisAllInfo($disorder['oneleadid'],$leadmoney['one'],$source,$setting); |
|||
if(!empty($sysinfo)){ |
|||
$receivers[] = $onedisinfo; |
|||
} |
|||
$disonemoney = $leadmoney['one']; |
|||
} |
|||
if($disorder['twoleadid'] > 0 && $leadmoney['two'] > 0){ |
|||
$onedisinfo = self::getDisAllInfo($disorder['twoleadid'],$leadmoney['two'],$source,$setting); |
|||
if(!empty($sysinfo)){ |
|||
$receivers[] = $onedisinfo; |
|||
} |
|||
$distwomoney = $leadmoney['two']; |
|||
} |
|||
} |
|||
//获取业务员信息 |
|||
if(!empty($salesinfo) && $salesmoney > 0){ |
|||
foreach($salesinfo as $sinfo){ |
|||
$saleallinfo = self::getSaleAllInfo($sinfo['mid'],$sinfo['reportmoney'],$source,$setting); |
|||
if(!empty($saleallinfo)){ |
|||
$receivers[] = $saleallinfo; |
|||
} |
|||
} |
|||
} |
|||
//获取代理分账信息 |
|||
if(!empty($order['sid']) || $plugin == 'store'){ |
|||
$agentmoney = sprintf("%.2f",$price - $sysmoney - $disonemoney - $storemoney - $distwomoney - $salesmoney); |
|||
if($agentmoney > 0 && $order['aid'] > 0){ |
|||
$agentallinfo = self::getAgentAllInfo($order['aid'],$agentmoney,$source,$setting); |
|||
if(!empty($agentallinfo)){ |
|||
$receivers[] = $agentallinfo; |
|||
} |
|||
} |
|||
} |
|||
|
|||
//生成分账方面 |
|||
if(count($receivers)>0){ |
|||
$receivers = json_encode($receivers); |
|||
$data = [ |
|||
'mch_id' => $setting['shop_number'], |
|||
'sub_mch_id' => $setting['sub_shop_number'], |
|||
'appid' => $setting['sub_up_app_id'], |
|||
'nonce_str' => $this -> createNoncestr(), |
|||
'transaction_id' => $order['transid'], |
|||
'out_order_no' => 'PP'.date('YmdHis').random(4,1), |
|||
'receivers' => $receivers, |
|||
]; |
|||
$data['sign'] = $this->getWlfSign($data,$setting['secret_key']); |
|||
|
|||
$cert = trim($filePath . $setting['cert_certificate']); |
|||
$key = trim($filePath . $setting['key_certificate']); |
|||
|
|||
$xml = $this->arrayToXml($data); |
|||
$re = $this->wxWlfHttpsRequestPem($xml,$getUrl,30,[],$cert,$key); |
|||
$rearr = $this->xmlToArray($re); |
|||
if($rearr['return_code'] == 'SUCCESS' && $rearr['result_code'] == 'SUCCESS'){ |
|||
$result = [ |
|||
'status' => 1, |
|||
'agentmoney' => $agentmoney > 0 ? $agentmoney : 0, |
|||
'sysmoney' => $sysmoney |
|||
]; |
|||
return $result; |
|||
}else{ |
|||
file_put_contents(PATH_DATA . "allocation_error.log", var_export($rearr, true) . PHP_EOL, FILE_APPEND); |
|||
return 0; |
|||
} |
|||
}else{ |
|||
//完成结算 |
|||
$data = [ |
|||
'mch_id' => $setting['shop_number'], |
|||
'sub_mch_id' => $setting['sub_shop_number'], |
|||
'appid' => $setting['sub_up_app_id'], |
|||
'nonce_str' => $this -> createNoncestr(), |
|||
'transaction_id' => $order['transid'], |
|||
'out_order_no' => 'PP'.date('YmdHis').random(4,1), |
|||
'description' => '分账已完成', |
|||
]; |
|||
$data['sign'] = $this->getWlfSign($data,$setting['secret_key']); |
|||
$cert = trim($filePath . $setting['cert_certificate']); |
|||
$key = trim($filePath . $setting['key_certificate']); |
|||
|
|||
$getUrl = 'https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish'; |
|||
$xml = $this->arrayToXml($data); |
|||
$re = $this->wxWlfHttpsRequestPem($xml,$getUrl,30,[],$cert,$key); |
|||
$rearr = $this->xmlToArray($re); |
|||
if($rearr['return_code'] == 'SUCCESS' && $rearr['result_code'] == 'SUCCESS'){ |
|||
$result = [ |
|||
'status' => 1, |
|||
'agentmoney' => $agentmoney > 0 ? $agentmoney : 0, |
|||
'sysmoney' => $sysmoney > 0 ? : 0 |
|||
]; |
|||
return $result; |
|||
}else{ |
|||
file_put_contents(PATH_DATA . "allocation_error.log", var_export($rearr, true) . PHP_EOL, FILE_APPEND); |
|||
return 0; |
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Comment: 服务商核销码分账借口 |
|||
* Author: wlf |
|||
* Date: 2020/08/31 10:46 |
|||
*/ |
|||
public function allocationMulti($orderid,$source,$salesinfo = [],$salesmoney = 0){ // $source = 1公众号 3小程序 |
|||
global $_W; |
|||
//获取订单数据 |
|||
$receivers = []; |
|||
$sysmoney = 0; |
|||
$smallorder = pdo_get('wlmerchant_smallorder',array('id' => $orderid),array('aid','orderprice','plugin','orderid','settlemoney','sid','oneleadid','twoleadid','onedismoney','twodismoney')); |
|||
$price = $smallorder['orderprice']; |
|||
if($smallorder['plugin'] == 'rush'){ |
|||
$order = pdo_get('wlmerchant_rush_order',array('id' => $smallorder['orderid']),array('transid','uniacid','paysetid','orderno','allocationtype')); |
|||
}else{ |
|||
$order = pdo_get('wlmerchant_order',array('id' => $smallorder['orderid']),array('transid','uniacid','paysetid','orderno','allocationtype')); |
|||
} |
|||
if(empty($order['transid'])) { |
|||
$order['transid'] = pdo_getcolumn(PDO_NAME . 'paylogvfour', array('tid' => $order['orderno']), 'transaction_id'); |
|||
} |
|||
//基础信息 |
|||
$getUrl = "https://api.mch.weixin.qq.com/secapi/pay/multiprofitsharing"; |
|||
$filePath = PATH_ATTACHMENT . "public_file/" . MODULE_NAME . "/"; |
|||
$id = $order['paysetid']; |
|||
$info = pdo_get(PDO_NAME."payment",['id'=>$id]); |
|||
$setting = json_decode($info['param'],true); |
|||
|
|||
//获取平台分账信息 |
|||
$sysinfo = self::getSysAllInfo($price,$source,$setting,$order['uniacid']); |
|||
|
|||
if(!empty($sysinfo)){ |
|||
$receivers[] = $sysinfo; |
|||
$sysmoney = sprintf("%.2f",$sysinfo['amount'] / 100); |
|||
} |
|||
//获取分销分账信息 |
|||
if($smallorder['oneleadid'] > 0 && $smallorder['onedismoney'] > 0){ |
|||
$onedisinfo = self::getDisAllInfo($smallorder['oneleadid'],$smallorder['onedismoney'],$source,$setting); |
|||
if(!empty($sysinfo)){ |
|||
$receivers[] = $onedisinfo; |
|||
} |
|||
} |
|||
if($smallorder['twoleadid'] > 0 && $smallorder['twodismoney'] > 0){ |
|||
$onedisinfo = self::getDisAllInfo($smallorder['twoleadid'],$smallorder['twodismoney'],$source,$setting); |
|||
if(!empty($sysinfo)){ |
|||
$receivers[] = $onedisinfo; |
|||
} |
|||
} |
|||
//获取业务员信息 |
|||
if(!empty($salesinfo) && $salesmoney > 0){ |
|||
foreach($salesinfo as $sinfo){ |
|||
$saleallinfo = self::getSaleAllInfo($sinfo['mid'],$sinfo['reportmoney'],$source,$setting); |
|||
if(!empty($saleallinfo)){ |
|||
$receivers[] = $saleallinfo; |
|||
} |
|||
} |
|||
} |
|||
//获取代理分账信息 |
|||
$agentmoney = sprintf("%.2f",$price - $sysmoney - $smallorder['settlemoney'] - $smallorder['onedismoney'] - $smallorder['twodismoney'] - $salesmoney); |
|||
if($agentmoney > 0 && $smallorder['aid'] > 0){ |
|||
$agentallinfo = self::getAgentAllInfo($smallorder['aid'],$agentmoney,$source,$setting); |
|||
if(!empty($agentallinfo)){ |
|||
$receivers[] = $agentallinfo; |
|||
} |
|||
} |
|||
//生成分账方面 |
|||
if(count($receivers)>0){ |
|||
$receivers = json_encode($receivers); |
|||
$data = [ |
|||
'mch_id' => $setting['shop_number'], |
|||
'sub_mch_id' => $setting['sub_shop_number'], |
|||
'appid' => $setting['sub_up_app_id'], |
|||
'nonce_str' => $this -> createNoncestr(), |
|||
'transaction_id' => $order['transid'], |
|||
'out_order_no' => 'PP'.date('YmdHis').random(4,1), |
|||
'receivers' => $receivers, |
|||
]; |
|||
$data['sign'] = $this->getWlfSign($data,$setting['secret_key']); |
|||
|
|||
$cert = trim($filePath . $setting['cert_certificate']); |
|||
$key = trim($filePath . $setting['key_certificate']); |
|||
|
|||
$xml = $this->arrayToXml($data); |
|||
$re = $this->wxWlfHttpsRequestPem($xml,$getUrl,30,[],$cert,$key); |
|||
$rearr = $this->xmlToArray($re); |
|||
if($rearr['return_code'] == 'SUCCESS' && $rearr['result_code'] == 'SUCCESS'){ |
|||
$result = [ |
|||
'status' => 1, |
|||
'agentmoney' => $agentmoney > 0 ? $agentmoney : 0, |
|||
'sysmoney' => $sysmoney |
|||
]; |
|||
return $result; |
|||
}else{ |
|||
file_put_contents(PATH_DATA . "allocation_error.log", var_export($rearr, true) . PHP_EOL, FILE_APPEND); |
|||
return 0; |
|||
} |
|||
}else{ |
|||
$result = [ |
|||
'status' => 1, |
|||
'agentmoney' => $agentmoney > 0 ? $agentmoney : 0, |
|||
'sysmoney' => $sysmoney > 0 ? : 0 |
|||
]; |
|||
return $result; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Comment: 添加分账方接口 |
|||
* Author: wlf |
|||
* Date: 2020/08/31 15:27 |
|||
*/ |
|||
public function addReceiver($type,$account,$relation_type,$name = '',$setting){ |
|||
global $_W; |
|||
$getUrl = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver"; |
|||
//生成分账方面 |
|||
$receiver = [ |
|||
'type' => $type, |
|||
'account' => $account, |
|||
'relation_type' => $relation_type, |
|||
]; |
|||
if($type == 'MERCHANT_ID'){ |
|||
$receiver['name'] = $name; |
|||
} |
|||
$receiver = json_encode($receiver); |
|||
$data = [ |
|||
'mch_id' => $setting['shop_number'], |
|||
'sub_mch_id' => $setting['sub_shop_number'], |
|||
'appid' => $setting['sub_up_app_id'], |
|||
'nonce_str' => $this -> createNoncestr(), |
|||
'receiver' => $receiver, |
|||
]; |
|||
$data['sign'] = $this->getWlfSign($data,$setting['secret_key']); |
|||
$xml = $this->arrayToXml($data); |
|||
$re = $this->wxWlfHttpsRequestPem($xml,$getUrl); |
|||
$rearr = $this->xmlToArray($re); |
|||
|
|||
return $rearr; |
|||
} |
|||
|
|||
/** |
|||
* Comment: 完结分账接口 |
|||
* Author: wlf |
|||
* Date: 2020/09/04 18:10 |
|||
*/ |
|||
public function allocationFinish($orderid){ |
|||
global $_W; |
|||
$smallorder = pdo_get('wlmerchant_smallorder',array('id' => $orderid),array('aid','orderprice','plugin','orderid','settlemoney','sid','oneleadid','twoleadid','onedismoney','twodismoney')); |
|||
$price = $smallorder['orderprice']; |
|||
if($smallorder['plugin'] == 'rush'){ |
|||
$order = pdo_get('wlmerchant_rush_order',array('id' => $smallorder['orderid']),array('transid','paysetid','orderno','allocationtype')); |
|||
}else{ |
|||
$order = pdo_get('wlmerchant_order',array('id' => $smallorder['orderid']),array('transid','paysetid','orderno','allocationtype')); |
|||
} |
|||
if(empty($order['transid'])) { |
|||
$order['transid'] = pdo_getcolumn(PDO_NAME . 'paylogvfour', array('tid' => $order['orderno']), 'transaction_id'); |
|||
} |
|||
//基础信息 |
|||
$getUrl = "https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish"; |
|||
$filePath = PATH_ATTACHMENT . "public_file/" . MODULE_NAME . "/"; |
|||
$id = $order['paysetid']; |
|||
$info = pdo_get(PDO_NAME."payment",['id'=>$id]); |
|||
$setting = json_decode($info['param'],true); |
|||
|
|||
$data = [ |
|||
'mch_id' => $setting['shop_number'], |
|||
'sub_mch_id' => $setting['sub_shop_number'], |
|||
'appid' => $setting['sub_up_app_id'], |
|||
'nonce_str' => $this -> createNoncestr(), |
|||
'transaction_id' => $order['transid'], |
|||
'out_order_no' => 'PP'.date('YmdHis').random(4,1), |
|||
'description' => '订单已完成', |
|||
]; |
|||
$data['sign'] = $this->getWlfSign($data,$setting['secret_key']); |
|||
|
|||
$cert = trim($filePath . $setting['cert_certificate']); |
|||
$key = trim($filePath . $setting['key_certificate']); |
|||
|
|||
$xml = $this->arrayToXml($data); |
|||
$re = $this->wxWlfHttpsRequestPem($xml,$getUrl,30,[],$cert,$key); |
|||
$rearr = $this->xmlToArray($re); |
|||
if($rearr['return_code'] == 'SUCCESS' && $rearr['result_code'] == 'SUCCESS'){ |
|||
return 1; |
|||
}else{ |
|||
file_put_contents(PATH_DATA . "allocation_error.log", var_export($rearr, true) . PHP_EOL, FILE_APPEND); |
|||
return 0; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
public function wxWlfHttpsRequestPem($vars, $url, $second = 30, $aHeader = array(),$cert = '',$key = '') { |
|||
global $_W; |
|||
$ch = curl_init(); |
|||
curl_setopt($ch, CURLOPT_TIMEOUT, $second); |
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|||
curl_setopt($ch, CURLOPT_URL, $url); |
|||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
|||
if(!empty($cert)){ |
|||
curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM'); |
|||
curl_setopt($ch, CURLOPT_SSLCERT,$cert); |
|||
} |
|||
if(!empty($key)){ |
|||
curl_setopt($ch, CURLOPT_SSLKEYTYPE, 'PEM'); |
|||
curl_setopt($ch, CURLOPT_SSLKEY,$key); |
|||
} |
|||
// curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM'); |
|||
// curl_setopt($ch,CURLOPT_SSLKEY, PATH_DATA."cert/".$_W['uniacid']."/wechat/apiclient_key.pem"); |
|||
// curl_setopt($ch,CURLOPT_CAINFO,'PEM'); |
|||
// curl_setopt($ch,CURLOPT_CAINFO,IA_ROOT . '/attachment/feng_fightgroups/cert/' . $_W['uniacid'] . '/rootca.pem'); |
|||
if (count($aHeader) >= 1) { |
|||
curl_setopt($ch, CURLOPT_HTTPHEADER, $aHeader); |
|||
} |
|||
curl_setopt($ch, CURLOPT_POST, 1); |
|||
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars); |
|||
$data = curl_exec($ch); |
|||
if ($data) { |
|||
curl_close($ch); |
|||
return $data; |
|||
} else { |
|||
$error = curl_errno($ch); |
|||
echo "call faild, errorCode:$error\n"; |
|||
curl_close($ch); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public function getWlfSign($Obj,$key) { |
|||
global $_W; |
|||
foreach ($Obj as $k => $v) { |
|||
$Parameters[$k] = $v; |
|||
} |
|||
ksort($Parameters); |
|||
$String = $this->formatBizQueryParaMap($Parameters, false); |
|||
$String = $String . "&key=" . $key; |
|||
$String = hash_hmac("sha256",$String,$key); |
|||
$result_ = strtoupper($String); |
|||
return $result_; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
?> |
|||
@ -0,0 +1,328 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class Weixinqrcode |
|||
{ |
|||
|
|||
/** |
|||
* 生成关注二维码 |
|||
* @param $name |
|||
* @param $keyword |
|||
* @param int $ptype 0商户1分销2商品 |
|||
* @param int $qrctype |
|||
* @param int $agentid |
|||
* @param string $remark |
|||
* @return array |
|||
*/ |
|||
static function createqrcode($name, $keyword, $ptype = 0, $qrctype = 2, $agentid = -1, $remark = '自动获取') |
|||
{ |
|||
global $_W, $_GPC; |
|||
if (empty($name) || empty($keyword)) { |
|||
return error('-1', '二维码关键字和名称不能为空'); |
|||
} |
|||
load()->func('communication'); |
|||
$barcode = array( |
|||
'expire_seconds' => '', |
|||
'action_name' => '', |
|||
'action_info' => array( |
|||
'scene' => array(), |
|||
), |
|||
); |
|||
|
|||
$scene_str = date('YmdHis') . rand(1000, 9999); |
|||
$uniacccount = WeAccount::create($_W['acid']); |
|||
|
|||
if ($qrctype == 1) { |
|||
$qrcid = pdo_fetchcolumn("SELECT qrcid FROM " . tablename('qrcode') . " WHERE acid = :acid AND model = '1' AND type = 'scene' ORDER BY qrcid DESC LIMIT 1", array(':acid' => $_W['acid'])); |
|||
$barcode['action_info']['scene']['scene_id'] = !empty($qrcid) ? ($qrcid + 1) : 100001; |
|||
$barcode['expire_seconds'] = 2592000; |
|||
$barcode['action_name'] = 'QR_SCENE'; |
|||
$result = $uniacccount->barCodeCreateDisposable($barcode); |
|||
} else if ($qrctype == 2) { |
|||
$is_exist = pdo_fetchcolumn('SELECT id FROM ' . tablename('qrcode') . ' WHERE uniacid = :uniacid AND scene_str = :scene_str AND model = 2', array(':uniacid' => $_W['uniacid'], ':scene_str' => $scene_str)); |
|||
if (!empty($is_exist)) { |
|||
$scene_str = date('YmdHis') . rand(1000, 9999); |
|||
} |
|||
$barcode['action_info']['scene']['scene_str'] = $scene_str; |
|||
$barcode['action_name'] = 'QR_LIMIT_STR_SCENE'; |
|||
$result = $uniacccount->barCodeCreateFixed($barcode); |
|||
} |
|||
|
|||
if (!is_error($result)) { |
|||
$insert = array( |
|||
'uniacid' => $_W['uniacid'], |
|||
'acid' => $_W['acid'], |
|||
'qrcid' => $barcode['action_info']['scene']['scene_id'], |
|||
'scene_str' => $barcode['action_info']['scene']['scene_str'], |
|||
'keyword' => $keyword, |
|||
'name' => $name, |
|||
'model' => $qrctype, |
|||
'ticket' => $result['ticket'], |
|||
'url' => $result['url'], |
|||
'expire' => $result['expire_seconds'], |
|||
'createtime' => TIMESTAMP, |
|||
'status' => '1', |
|||
'type' => 'scene', |
|||
); |
|||
pdo_insert('qrcode', $insert); |
|||
$qrid = pdo_insertid(); |
|||
$qrinsert = array( |
|||
'uniacid' => $_W['uniacid'], |
|||
'aid' => $agentid, |
|||
'qrid' => $qrid, |
|||
'type' => $ptype, |
|||
'model' => $qrctype, |
|||
'cardsn' => $scene_str, |
|||
'salt' => random(8), |
|||
'createtime' => TIMESTAMP, |
|||
'status' => '1', |
|||
'remark' => $remark |
|||
); |
|||
pdo_insert(PDO_NAME . 'qrcode', $qrinsert); |
|||
return $qrid; |
|||
} |
|||
return $result; |
|||
} |
|||
|
|||
static function get_qrid($message) |
|||
{ |
|||
global $_W; |
|||
if (!empty($message['ticket'])) { |
|||
if (is_numeric($message['scene']) && mb_strlen($message['scene']) != 18) { |
|||
$qrid = pdo_fetchcolumn('select id from ' . tablename('qrcode') . ' where uniacid=:uniacid and qrcid=:qrcid', array(':uniacid' => $_W['uniacid'], ':qrcid' => $message['scene'])); |
|||
} else { |
|||
$qrid = pdo_fetchcolumn('select id from ' . tablename('qrcode') . ' where uniacid=:uniacid and scene_str=:scene_str', array(':uniacid' => $_W['uniacid'], ':scene_str' => $message['scene'])); |
|||
} |
|||
if ($message['event'] == 'subscribe') { |
|||
self::qr_log($qrid, $message['from'], 1); |
|||
} else { |
|||
self::qr_log($qrid, $message['from'], 2); |
|||
} |
|||
} else { |
|||
self::send_text('欢迎关注我们!', $message); |
|||
} |
|||
return $qrid; |
|||
} |
|||
|
|||
static function qr_log($qrid, $openid, $type) |
|||
{ |
|||
global $_W; |
|||
if (empty($qrid) || empty($openid)) { |
|||
return; |
|||
} |
|||
$qrcode = pdo_get('qrcode', array('id' => $qrid), array('scene_str', 'name')); |
|||
$log = array('uniacid' => $_W['uniacid'], 'acid' => $_W['acid'], 'qid' => $qrid, 'openid' => $openid, 'type' => $type, 'scene_str' => $qrcode['scene_str'], 'name' => $qrcode['name'], 'createtime' => time()); |
|||
pdo_insert('qrcode_stat', $log); |
|||
} |
|||
|
|||
static function createkeywords($name, $keyword) |
|||
{ |
|||
global $_W; |
|||
if (empty($name) || empty($keyword)) { |
|||
return error('-1', '二维码关键字和名称不能为空'); |
|||
} |
|||
$rid = pdo_fetchcolumn("select id from " . tablename('rule') . 'where uniacid=:uniacid and module=:module and name=:name', array( |
|||
':uniacid' => $_W['uniacid'], |
|||
':module' => 'weliam_smartcity', |
|||
':name' => $name |
|||
)); |
|||
if (empty($rid)) { |
|||
$rule_data = array( |
|||
'uniacid' => $_W['uniacid'], |
|||
'name' => $name, |
|||
'module' => 'weliam_smartcity', |
|||
'displayorder' => 0, |
|||
'status' => 1 |
|||
); |
|||
pdo_insert('rule', $rule_data); |
|||
$rid = pdo_insertid(); |
|||
} |
|||
|
|||
$content = pdo_getcolumn('rule_keyword', array('rid' => $rid, 'module' => 'weliam_smartcity', 'content' => $keyword), 'content'); |
|||
if (empty($content)) { |
|||
$keyword_data = array( |
|||
'uniacid' => $_W['uniacid'], |
|||
'rid' => $rid, |
|||
'module' => 'weliam_smartcity', |
|||
'content' => $keyword, |
|||
'type' => 1, |
|||
'displayorder' => 0, |
|||
'status' => 1 |
|||
); |
|||
pdo_insert('rule_keyword', $keyword_data); |
|||
} |
|||
|
|||
return $rid; |
|||
} |
|||
|
|||
static function send_news($returnmess, $message, $end = 1) |
|||
{ |
|||
global $_W; |
|||
if (count($returnmess) > 1) { |
|||
$returnmess = array_slice($returnmess, 0, 1); |
|||
} |
|||
$send['touser'] = $message['from']; |
|||
$send['msgtype'] = 'news'; |
|||
$send['news']['articles'] = $returnmess; |
|||
$acc = WeAccount::create($_W['acid']); |
|||
$data = $acc->sendCustomNotice($send); |
|||
if (is_error($data)) { |
|||
self::salerEmpty(); |
|||
} else { |
|||
if ($end == 1) { |
|||
self::salerEmpty(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
static function send_image($image, $message, $end = 1) |
|||
{ |
|||
global $_W; |
|||
$media = self::image_to_media($image, $message); |
|||
$send['touser'] = $message['from']; |
|||
$send['msgtype'] = 'image'; |
|||
$send['image'] = array('media_id' => $media['media_id']); |
|||
|
|||
$acc = WeAccount::create($_W['acid']); |
|||
$data = $acc->sendCustomNotice($send); |
|||
if (is_error($data)) { |
|||
self::salerEmpty(); |
|||
} else { |
|||
if ($end == 1) { |
|||
self::salerEmpty(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
static function send_text($mess, $message, $end = 1) |
|||
{ |
|||
global $_W; |
|||
$send['touser'] = $message['from']; |
|||
$send['msgtype'] = 'text'; |
|||
$send['text'] = array('content' => urlencode($mess)); |
|||
$acc = WeAccount::create($_W['acid']); |
|||
$data = $acc->sendCustomNotice($send); |
|||
if (is_error($data)) { |
|||
self::salerEmpty(); |
|||
} else { |
|||
if ($end == 1) { |
|||
self::salerEmpty(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
static function send_wxapp($mess, $message, $end = 1) |
|||
{ |
|||
global $_W; |
|||
if(empty($mess['path'])){ |
|||
$mess['path'] = tomedia($_W['wlsetting']['base']['logo']); |
|||
} |
|||
if(!empty($mess['path'])){ |
|||
$acc = WeAccount::create($_W['acid']); |
|||
$media = self::image_to_media($mess['path'], $message); |
|||
$mess['thumb_media_id'] = $media['media_id']; |
|||
unset($mess['path']); |
|||
$send['touser'] = $message['from']; |
|||
$send['msgtype'] = 'miniprogrampage'; |
|||
$send['miniprogrampage'] = $mess; |
|||
$data = $acc->sendCustomNotice($send); |
|||
if (is_error($data)) { |
|||
self::salerEmpty(); |
|||
} else { |
|||
if ($end == 1) { |
|||
self::salerEmpty(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
private static function image_to_media($image, $message) |
|||
{ |
|||
global $_W; |
|||
$caCheName = md5($image);//当前图片缓存信息 防止同一张图片多次提交 |
|||
//获取缓存信息 |
|||
$media = Cache::getCache('wxappSend',$caCheName); |
|||
if(empty($media)){ |
|||
$acc = WeAccount::create($_W['acid']); |
|||
//文件在远程需要下载到本地 |
|||
$path = "images" . DIRECTORY_SEPARATOR . $_W['uniacid'] . DIRECTORY_SEPARATOR . "media.upload" . DIRECTORY_SEPARATOR . md5($image) . substr($image, -4); |
|||
$allpath = ATTACHMENT_ROOT . $path; |
|||
if (!file_exists($allpath)) { |
|||
$imgcontent = self::getImage($image); |
|||
$res = FilesHandle::file_mkdirs(dirname($allpath)); |
|||
if($res){ |
|||
//保存图片信息 |
|||
$res = file_put_contents($allpath, $imgcontent); |
|||
if(!$res){ |
|||
//获取图片类型 |
|||
$imageInfo = getimagesize($image); |
|||
$mime = explode('/',$imageInfo['mime'])['1']; |
|||
$imageType = $mime ? '.'.$mime : '.jpg'; |
|||
//再次写入图片信息 |
|||
ob_start();//打开输出 |
|||
readfile($image);//输出图片文件 |
|||
$img = ob_get_contents();//得到浏览器输出 |
|||
ob_end_clean();//清除输出并关闭 |
|||
$fp2 = @fopen($allpath.$imageType, "a"); |
|||
$res = fwrite($fp2, $img);//向当前目录写入图片文件,并重新命名 |
|||
fclose($fp2); |
|||
//从新定义path |
|||
$path = $path.$imageType; |
|||
} |
|||
}else{ |
|||
self::send_text('目录创建失败', $message); |
|||
return false; |
|||
} |
|||
} |
|||
$media = $acc->uploadMedia($path); |
|||
if (is_error($media)) { |
|||
self::send_text($media['message'], $message); |
|||
} else { |
|||
Cache::setCache('wxappSend',$caCheName,$media); |
|||
return $media; |
|||
} |
|||
} |
|||
return $media; |
|||
} |
|||
|
|||
private static function salerEmpty() |
|||
{ |
|||
// ob_clean(); |
|||
// ob_start(); |
|||
// echo ''; |
|||
// ob_flush(); |
|||
// ob_end_flush(); |
|||
// exit(0); |
|||
return true; |
|||
} |
|||
|
|||
|
|||
protected static function getImage($imgurl){ |
|||
load()->func('communication'); |
|||
$resp = ihttp_request($imgurl); |
|||
|
|||
if ($resp['code'] == 200 && !empty($resp['content'])) { |
|||
return imagecreatefromstring($resp['content']); |
|||
} |
|||
if ($resp['errno'] == 35) { |
|||
$imgurl = str_replace(array('https://'), 'http://', $imgurl); |
|||
} |
|||
|
|||
$i = 0; |
|||
while ($i < 3) { |
|||
$resp = ihttp_request($imgurl); |
|||
if ($resp['code'] == 200 && !empty($resp['content'])) { |
|||
return imagecreatefromstring($resp['content']); |
|||
} |
|||
++$i; |
|||
} |
|||
|
|||
//以上方法都未获取图片资源 |
|||
$resp = file_get_contents($imgurl); |
|||
return imagecreatefromstring($resp); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,270 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class WeliamDb { |
|||
|
|||
/** |
|||
* 生成表差异SQL |
|||
* @param $table |
|||
* @return array |
|||
*/ |
|||
static function table_upgrade($table) { |
|||
$sqlarr = []; |
|||
if (!empty($table['table'])) { |
|||
$oldtable = self::get_table_schema($table['table']); |
|||
if (empty($oldtable)) { |
|||
//创建表 |
|||
$sqlarr[] = self::create_table($table); |
|||
} else { |
|||
//对比字段 |
|||
foreach ($table['fields'] as $fk => $field) { |
|||
if (empty($oldtable['fields'][$fk])) { |
|||
//字段不存在,增加字段 |
|||
$sqlarr[] = ($field['increment'] == 1) ? self::table_field_edit($table['table'], $field, 1, $table['indexes']['PRIMARY']) : self::table_field_edit($table['table'], $field, 1); |
|||
} elseif (array_diff_assoc($table['fields'][$fk], $oldtable['fields'][$fk]) || array_diff_assoc($oldtable['fields'][$fk], $table['fields'][$fk])) { |
|||
//字段有变化,修改字段 |
|||
$sqlarr[] = self::table_field_edit($table['table'], $field, 2); |
|||
} |
|||
} |
|||
//对比索引 |
|||
foreach ($table['indexes'] as $idx => $index) { |
|||
if ($idx == 'PRIMARY') { |
|||
continue; |
|||
} |
|||
if (empty($oldtable['indexes'][$idx])) { |
|||
//索引不存在,增加索引 |
|||
$sqlarr[] = self::table_index_edit($table['table'], $index, 1); |
|||
} elseif (array_diff_assoc($table['indexes'][$idx], $oldtable['indexes'][$idx]) || array_diff_assoc($oldtable['indexes'][$idx]['fields'], $table['indexes'][$idx]['fields']) || array_diff_assoc($table['indexes'][$idx]['fields'], $oldtable['indexes'][$idx]['fields'])) { |
|||
//索引有变化,删除索引,新建索引 |
|||
$sqlarr[] = self::table_index_edit($table['table'], $index, 2); |
|||
$sqlarr[] = self::table_index_edit($table['table'], $index, 1); |
|||
} |
|||
} |
|||
//多余索引,需要删除 |
|||
foreach ($oldtable['indexes'] as $oidx => $oindex) { |
|||
if (empty($table['indexes'][$oidx])) { |
|||
$sqlarr[] = self::table_index_edit($table['table'], $oindex, 2); |
|||
} |
|||
} |
|||
//对比存储引擎 |
|||
if ($table['engine'] != $oldtable['engine']) { |
|||
$sqlarr[] = "ALTER TABLE " . self::tablename($table['table']) . " ENGINE=" . $table['engine'] . ", ROW_FORMAT=DEFAULT;"; |
|||
} |
|||
} |
|||
} |
|||
return $sqlarr; |
|||
} |
|||
|
|||
/** |
|||
* 根据条件查找表名 |
|||
* @param $table |
|||
* @param string $tablepre |
|||
* @param bool $haspre |
|||
* @return array |
|||
*/ |
|||
static function get_tables_name($table, $tablepre = 'ims_', $haspre = false) { |
|||
$tablenames = pdo_fetchall("SHOW TABLES LIKE :tablename", array(":tablename" => "%" . $table . "%")); |
|||
if (!empty($tablenames)) { |
|||
$tables = []; |
|||
foreach ($tablenames as $item) { |
|||
$table = end($item); |
|||
$tables[] = $haspre ? $table : substr($table, strlen($tablepre)); |
|||
} |
|||
return $tables; |
|||
} |
|||
return []; |
|||
} |
|||
|
|||
/** |
|||
* 根据表名生成数据库插入语句 |
|||
* @param $tablename |
|||
* @param $uniacid |
|||
* @param $start |
|||
* @param $size |
|||
* @return array|bool |
|||
*/ |
|||
static function get_table_insert_sql($tablename, $uniacid, $start, $size) { |
|||
$data = ''; |
|||
$tmp = ''; |
|||
$sql = "SELECT * FROM {$tablename} WHERE `uniacid` = {$uniacid} LIMIT {$start}, {$size}"; |
|||
$result = pdo_fetchall($sql); |
|||
if (!empty($result)) { |
|||
foreach ($result as $row) { |
|||
$tmp .= '('; |
|||
foreach ($row as $k => $v) { |
|||
$value = str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $v); |
|||
$tmp .= "'" . $value . "',"; |
|||
} |
|||
$tmp = rtrim($tmp, ','); |
|||
$tmp .= "),\n"; |
|||
} |
|||
$tmp = rtrim($tmp, ",\n"); |
|||
$data .= "INSERT INTO {$tablename} VALUES \n{$tmp};\n"; |
|||
$datas = array( |
|||
'data' => $data, |
|||
'result' => $result, |
|||
); |
|||
|
|||
return $datas; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 根据表名返回表的数据 |
|||
* @param string $tablename |
|||
* @return array |
|||
*/ |
|||
static function get_table_schema($tablename = '') { |
|||
$result = self::pdo()->fetch("SHOW TABLE STATUS LIKE '" . trim(self::tablename($tablename), "`") . "'"); |
|||
if (empty($result) || empty($result['Create_time'])) { |
|||
return array(); |
|||
} |
|||
$ret["table"] = $tablename; |
|||
$ret["tablename"] = $result["Name"]; |
|||
$ret["charset"] = $result["Collation"]; |
|||
$ret["engine"] = $result["Engine"]; |
|||
$ret["increment"] = $result["Auto_increment"]; |
|||
$result = self::pdo()->fetchall("SHOW FULL COLUMNS FROM " . self::tablename($tablename)); |
|||
foreach ($result as $value) { |
|||
$temp = array(); |
|||
$type = explode(" ", $value["Type"], 2); |
|||
$temp["name"] = $value["Field"]; |
|||
$pieces = explode("(", $type[0], 2); |
|||
$temp["type"] = $pieces[0]; |
|||
$temp["length"] = rtrim($pieces[1], ")"); |
|||
$temp["null"] = !($value["Null"] == "NO"); |
|||
$temp["signed"] = empty($type[1]); |
|||
$temp["increment"] = $value["Extra"] == "auto_increment"; |
|||
if (!empty($value['Comment'])) { |
|||
$temp["comment"] = $value["Comment"]; |
|||
} |
|||
if ($value["Default"] != NULL) { |
|||
$temp["default"] = $value["Default"]; |
|||
} |
|||
$ret["fields"][$value["Field"]] = $temp; |
|||
} |
|||
$result = self::pdo()->fetchall("SHOW INDEX FROM " . self::tablename($tablename)); |
|||
foreach ($result as $value) { |
|||
$ret["indexes"][$value["Key_name"]]["name"] = $value["Key_name"]; |
|||
$ret["indexes"][$value["Key_name"]]["type"] = $value["Key_name"] == "PRIMARY" ? "primary" : ($value["Non_unique"] == 0 ? "unique" : "index"); |
|||
$ret["indexes"][$value["Key_name"]]["fields"][] = $value["Column_name"]; |
|||
} |
|||
return $ret; |
|||
} |
|||
|
|||
/** |
|||
* 返回完整表名 |
|||
* @param $table |
|||
* @return string |
|||
*/ |
|||
private static function tablename($table) { |
|||
return self::pdo()->tablename($table); |
|||
} |
|||
|
|||
/** |
|||
* 数据库操作类 |
|||
* @return DB|SlaveDb |
|||
*/ |
|||
private static function pdo() { |
|||
return pdo(); |
|||
} |
|||
|
|||
/** |
|||
* 生成创建表的SQL |
|||
* @param $schema |
|||
* @return string |
|||
*/ |
|||
private static function create_table($schema) { |
|||
if (empty($schema)) { |
|||
return ''; |
|||
} |
|||
$sql = "CREATE TABLE IF NOT EXISTS " . self::tablename($schema['table']) . " ("; |
|||
//生成表的字段 |
|||
foreach ($schema['fields'] as $field) { |
|||
$sql .= self::create_table_field($field); |
|||
$sql .= ","; |
|||
} |
|||
//生成表的索引 |
|||
foreach ($schema['indexes'] as $index) { |
|||
$sql .= self::create_table_index($index); |
|||
$sql .= ","; |
|||
} |
|||
$sql = rtrim($sql, ","); |
|||
|
|||
$charset = substr($schema['charset'], 0, stripos($schema['charset'], "_")); |
|||
$sql .= ") ENGINE={$schema['engine']} DEFAULT CHARSET={$charset};"; |
|||
|
|||
return $sql; |
|||
} |
|||
|
|||
/** |
|||
* 生成操作字段的SQL段 |
|||
* @param $field |
|||
* @return string |
|||
*/ |
|||
private static function create_table_field($field) { |
|||
if (empty($field)) { |
|||
return ""; |
|||
} |
|||
$sql = ""; |
|||
$sql .= " `{$field['name']}` {$field['type']}"; |
|||
$sql .= !empty($field['length']) ? "({$field['length']})" : ""; |
|||
$sql .= !empty($field['signed']) ? "" : " UNSIGNED"; |
|||
$sql .= !empty($field['null']) ? (array_key_exists("default", $field) ? "" : " DEFAULT NULL") : " NOT NULL"; |
|||
$sql .= array_key_exists("default", $field) ? " DEFAULT '{$field['default']}'" : ""; |
|||
$sql .= !empty($field['increment']) ? " AUTO_INCREMENT" : ""; |
|||
$sql .= !empty($field['comment']) ? " COMMENT '{$field['comment']}'" : ""; |
|||
return $sql; |
|||
} |
|||
|
|||
/** |
|||
* 生成操作索引的SQL段 |
|||
* @param $index |
|||
* @param string $type |
|||
* @return string |
|||
*/ |
|||
private static function create_table_index($index, $type = 'ADD') { |
|||
if (empty($index)) { |
|||
return ""; |
|||
} |
|||
$sql = ""; |
|||
$sql .= $index['type'] == 'primary' ? "PRIMARY KEY" : "KEY `{$index['name']}`"; |
|||
if ($type == 'ADD') { |
|||
$sql .= " (`" . implode("`,`", $index['fields']) . "`)"; |
|||
} |
|||
return $sql; |
|||
} |
|||
|
|||
/** |
|||
* 生成操作字段的SQL |
|||
* @param string $tablename |
|||
* @param $field |
|||
* @param int $type |
|||
* @return string |
|||
*/ |
|||
private static function table_field_edit($tablename = '', $field, $type = 1, $idx_field = []) { |
|||
$sqlstr = ($type == 1) ? " ADD " : " MODIFY COLUMN "; |
|||
$sql = "ALTER TABLE " . self::tablename($tablename) . $sqlstr . self::create_table_field($field); |
|||
//特殊情况,增加主键字段时 |
|||
if ($type == 1 && $field['increment'] == 1) { |
|||
$sql .= ", ADD " . self::create_table_index($idx_field, 'ADD'); |
|||
} |
|||
$sql .= ";"; |
|||
return $sql; |
|||
} |
|||
|
|||
/** |
|||
* 生成操作索引的SQL |
|||
* @param string $tablename |
|||
* @param $field |
|||
* @param int $type |
|||
* @return string |
|||
*/ |
|||
private static function table_index_edit($tablename = '', $field, $type = 1) { |
|||
$sqlstr = ($type == 1) ? " ADD " : " DROP "; |
|||
$sql = "ALTER TABLE " . self::tablename($tablename) . $sqlstr . self::create_table_index($field, trim($sqlstr)) . ";"; |
|||
return $sql; |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,137 @@ |
|||
<?php |
|||
|
|||
class util_csv { |
|||
|
|||
/** |
|||
* 读取CSV文件 |
|||
* @param string $csv_file csv文件路径 |
|||
* @param int $lines 读取行数 |
|||
* @param int $offset 起始行数 |
|||
* @return array|bool |
|||
*/ |
|||
static function read_csv_lines($csv_file = '', $lines = 0, $offset = 0) { |
|||
if (!$fp = fopen($csv_file, 'r')) { |
|||
return false; |
|||
} |
|||
$i = $j = 0; |
|||
while (false !== ($line = fgets($fp))) { |
|||
if ($i++ < $offset) { |
|||
continue; |
|||
} |
|||
break; |
|||
} |
|||
$data = array(); |
|||
while (($j++ < $lines) && !feof($fp)) { |
|||
$data[] = fgetcsv($fp); |
|||
} |
|||
fclose($fp); |
|||
return $data; |
|||
} |
|||
|
|||
/** |
|||
* 导出CSV文件 |
|||
* @param array $data 数据 |
|||
* @param array $header_data 首行数据 |
|||
* @param string $file_name 文件名称 |
|||
* @return string |
|||
*/ |
|||
static function export_csv_1($data = array(), $header_data = array(), $file_name = '') { |
|||
header('Content-Type: application/octet-stream'); |
|||
header('Content-Disposition: attachment; filename=' . $file_name); |
|||
if (!empty($header_data)) { |
|||
echo iconv('utf-8', 'gbk//TRANSLIT', '"' . implode('","', $header_data) . '"' . "\n"); |
|||
} |
|||
foreach ($data as $key => $value) { |
|||
$output = array(); |
|||
$output[] = $value['id']; |
|||
$output[] = $value['name']; |
|||
echo iconv('utf-8', 'gbk//TRANSLIT', '"' . implode('","', $output) . "\"\n"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 导出CSV文件 |
|||
* @param array $data 数据 |
|||
* @param array $header_data 首行数据 |
|||
* @param string $file_name 文件名称 |
|||
* @return string |
|||
*/ |
|||
static function export_csv_2($data = array(), $header_data = array(), $file_name = '') { |
|||
header('Content-Type: application/vnd.ms-excel'); |
|||
header('Content-Disposition: attachment;filename=' . $file_name); |
|||
header('Cache-Control: max-age=0'); |
|||
$fp = fopen('php://output', 'a'); |
|||
if (!empty($header_data)) { |
|||
foreach ($header_data as $key => $value) { |
|||
$header_data[$key] = iconv('utf-8', 'gbk', $value); |
|||
} |
|||
fputcsv($fp, $header_data); |
|||
} |
|||
$num = 0; |
|||
//每隔$limit行,刷新一下输出buffer,不要太大,也不要太小 |
|||
$limit = 100000; |
|||
//逐行取出数据,不浪费内存 |
|||
$count = count($data); |
|||
if ($count > 0) { |
|||
for ($i = 0; $i < $count; $i++) { |
|||
$num++; |
|||
//刷新一下输出buffer,防止由于数据过多造成问题 |
|||
if ($limit == $num) { |
|||
ob_flush(); |
|||
flush(); |
|||
$num = 0; |
|||
} |
|||
$row = $data[$i]; |
|||
foreach ($row as $key => $value) { |
|||
$row[$key] = iconv('utf-8', 'gbk', $value); |
|||
} |
|||
fputcsv($fp, $row); |
|||
} |
|||
} |
|||
fclose($fp); |
|||
} |
|||
|
|||
/** |
|||
* 保存CSV文件 |
|||
* @param array $data 数据 |
|||
* @param array $header_data 首行数据 |
|||
* @param string $file_name 文件名称 |
|||
* @return string |
|||
*/ |
|||
static function save_csv($data = array(), $header_data = array(), $file_name = '') { |
|||
header('Content-Type: application/vnd.ms-excel'); |
|||
header('Content-Disposition: attachment;filename=' . $file_name); |
|||
header('Cache-Control: max-age=0'); |
|||
$csv_filename = PATH_ATTACHMENT . "public_file/" . MODULE_NAME . "/".$file_name; |
|||
$fp = fopen($csv_filename, "w"); |
|||
if (!empty($header_data)) { |
|||
foreach ($header_data as $key => $value) { |
|||
$header_data[$key] = iconv('utf-8', 'gbk', $value); |
|||
} |
|||
fputcsv($fp, $header_data); |
|||
} |
|||
$num = 0; |
|||
//每隔$limit行,刷新一下输出buffer,不要太大,也不要太小 |
|||
$limit = 100000; |
|||
//逐行取出数据,不浪费内存 |
|||
$count = count($data); |
|||
if ($count > 0) { |
|||
for ($i = 0; $i < $count; $i++) { |
|||
$num++; |
|||
//刷新一下输出buffer,防止由于数据过多造成问题 |
|||
if ($limit == $num) { |
|||
ob_flush(); |
|||
flush(); |
|||
$num = 0; |
|||
} |
|||
$row = $data[$i]; |
|||
foreach ($row as $key => $value) { |
|||
$row[$key] = iconv('utf-8', 'gbk', $value); |
|||
} |
|||
fputcsv($fp, $row); |
|||
} |
|||
} |
|||
fclose($fp); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,168 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
|
|||
class wlPay extends WeModuleSite { |
|||
|
|||
static function finance($openid = '', $money = 0, $desc = '', $realname = '', $trade_no) { |
|||
global $_W; |
|||
$pay = new WeixinPay; |
|||
$arr = $pay->finance($openid, $money, $desc, $realname, $trade_no); |
|||
return $arr; |
|||
} |
|||
/** |
|||
* Comment: 退款操作 |
|||
* Author: zzw |
|||
* Date: 2019/9/29 10:55 |
|||
* @param $id int 订单ID |
|||
* @param $money float 退款金额 |
|||
* @param $remark string 退款原因 |
|||
* @param $plugin string 模块信息 |
|||
* @param int $type int 1微信端2web端3计划任务退款 |
|||
* @param $blendcredit float 退款到余额 |
|||
* @return mixed |
|||
* @throws \Yansongda\Pay\Exceptions\GatewayException |
|||
* @throws \Yansongda\Pay\Exceptions\InvalidArgumentException |
|||
* @throws \Yansongda\Pay\Exceptions\InvalidConfigException |
|||
* @throws \Yansongda\Pay\Exceptions\InvalidSignException |
|||
*/ |
|||
static function refundMoney ($id , $money , $remark , $plugin , $type = 3,$blendcredit = 0){ |
|||
global $_W; |
|||
#1、初始申明 |
|||
$refund = false;//默认退款失败 |
|||
#2、基本订单信息获取 |
|||
switch ($plugin) { |
|||
case 'rush' : |
|||
$order = pdo_get(PDO_NAME.'rush_order' ,[ 'id' => $id] ,['paytype','orderno','aid','sid']); |
|||
break; |
|||
case 'attestation' : |
|||
$order = pdo_get(PDO_NAME.'attestation_money' ,[ 'id' => $id] ,['paytype','orderno']); |
|||
break; |
|||
case 'mobilerecharge' : |
|||
$order = pdo_get(PDO_NAME.'mrecharge_order' ,[ 'id' => $id] ,['paytype','orderno']); |
|||
break; |
|||
default : |
|||
$order = pdo_get(PDO_NAME.'order' , [ 'id' => $id] ,['paytype','orderno','aid','sid','paylogid']); |
|||
break; |
|||
} |
|||
#3、获取支付信息 |
|||
if(empty($order['orderno'])){ |
|||
$res['status'] = false; |
|||
$res['message'] = '订单不存在'; |
|||
} |
|||
if($plugin == 'citydelivery'){ |
|||
$payInfo = pdo_get(PDO_NAME."paylogvfour",['tid'=>$order['orderno']] ,['tid','transaction_id','fee','blendcredit','mid','module','uniacid','type']); |
|||
if(empty($payInfo)){ |
|||
$payInfo = pdo_get(PDO_NAME."paylogvfour",['plid'=>$order['paylogid']] ,['tid','transaction_id','fee','blendcredit','mid','module','uniacid','type']); |
|||
} |
|||
$order['orderno'] = $payInfo['tid']; |
|||
}else{ |
|||
$payInfo = pdo_get(PDO_NAME."paylogvfour",['tid'=>$order['orderno']] ,['transaction_id','fee','mid','blendcredit','module','uniacid','type']); |
|||
if(empty($payInfo)){ |
|||
$payInfo = pdo_get(PDO_NAME."paylog",['tid'=>$order['orderno']] ,['transaction_id','fee','mid','module','uniacid','type']); |
|||
} |
|||
} |
|||
if(empty($payInfo)){ |
|||
$payInfo = ['fee' => 0]; |
|||
} |
|||
$orderInfo = array_merge($order,$payInfo);//合并两个数组的信息 |
|||
#4、退款金额判断 |
|||
if ($money > $orderInfo['fee']) { |
|||
$errMsg = '退款金额大于实际支付金额,无法退款'; |
|||
} else if ($money > 0) { |
|||
$orderInfo['refund_money'] = $money;//记录退款金额 |
|||
} else if ($blendcredit < 0.01){ |
|||
$money = $orderInfo['fee'];//退款金额为支付金额(全额退款) |
|||
if($orderInfo['blendcredit'] > 0){ |
|||
$money = sprintf("%.2f",$money - $orderInfo['blendcredit']); |
|||
$blendcredit = $orderInfo['blendcredit']; |
|||
} |
|||
} |
|||
//支付返现判断 |
|||
if(p('cashback')){ |
|||
//判断当前订单是否存在返现订单 |
|||
$cashOrderInfo = pdo_get(PDO_NAME."cashback",['order_id'=>$id,'plugin'=>$plugin,'status'=>1]); |
|||
if($cashOrderInfo){ |
|||
//退款比例计算 |
|||
$proportion = sprintf("%.2f",$money / $orderInfo['fee']);//比例 |
|||
$cashRefund = sprintf("%.2f",$cashOrderInfo['money'] * $proportion);//取消的返现金额 |
|||
//数据判断 余额是否大于当前取消返现金额 |
|||
$member = Member::wl_member_get($cashOrderInfo['mid'],['id','uid','cash_back_money']);//用户当前余额获取 |
|||
if($member['credit2'] < $cashRefund) return ['status'=>false,'message'=>'退款失败;余额不足,不能取消返现金额!']; |
|||
} |
|||
} |
|||
#5、插入退款记录信息 |
|||
$refundRecord = [ |
|||
'sid' => $orderInfo['sid'] , |
|||
'orderno' => $orderInfo['orderno'] , |
|||
'mid' => $orderInfo['mid'] , |
|||
'aid' => $orderInfo['aid'] , |
|||
'paytype' => $orderInfo['type'] , |
|||
'transid' => $orderInfo['transaction_id'] , |
|||
'type' => $type , |
|||
'orderid' => $id , |
|||
'payfee' => $orderInfo['fee'] , |
|||
'refundfee' => sprintf("%.2f",$money + $blendcredit), |
|||
'uniacid' => $orderInfo['uniacid'] , |
|||
'remark' => $remark , |
|||
'plugin' => $plugin |
|||
]; |
|||
$refundid = pdo_getcolumn(PDO_NAME.'refund_record',$refundRecord,'id'); |
|||
if(empty($refundid)){ |
|||
$refundRecord['createtime'] = TIMESTAMP; |
|||
$refundRecord['status'] = 0; |
|||
pdo_insert(PDO_NAME . 'refund_record' , $refundRecord); |
|||
$refundid = pdo_insertid(); |
|||
} |
|||
#6、判断退款成功失败信息 |
|||
$pluginArray = [ 'rush','housekeep' , 'vip' ,'mobilerecharge', 'citydelivery','yellowpage','coupon' ,'attestation','merchant' , 'wlfightgroup' , 'activity' , 'groupon' , 'bargain' ]; |
|||
if (!in_array($plugin , $pluginArray)) { |
|||
pdo_update(PDO_NAME . 'refund_record' , [ 'errmsg' => '退款订单插件' . $plugin . '错误' ] , [ 'id' => $refundid]); |
|||
$errMsg = '退款订单插件' . $plugin . '错误'; |
|||
} |
|||
if ($money <= 0 && $blendcredit <= 0 && $orderInfo['paytype'] != 6 ) { |
|||
pdo_update(PDO_NAME . 'refund_record' , ['errmsg' => '退款金额小于0'] , ['id' => $refundid]); |
|||
$errMsg = '退款金额小于0'; |
|||
} |
|||
if (empty($orderInfo['transaction_id']) && $orderInfo['type'] == 'wechat') { |
|||
pdo_update(PDO_NAME . 'refund_record' ,['errmsg' => '无微信订单号'] , ['id' => $refundid]); |
|||
$errMsg = '微信订单无微信订单号'; |
|||
} |
|||
if($orderInfo['module'] == 'weliam_merchant'){ |
|||
$errMsg = '此订单为旧版系统支付订单,无法在V4版本进行退款,请前往旧版系统退款'; |
|||
pdo_update(PDO_NAME . 'refund_record' ,['errmsg' => $errMsg] , ['id' => $refundid]); |
|||
} |
|||
#7、符合退款要求,开始退款操作 |
|||
if (empty($errMsg)){ |
|||
if($orderInfo['paytype'] == 6){ |
|||
$result = ['error' => 1]; |
|||
}else{ |
|||
$result = Refund::refundInit($orderInfo['orderno'],$money,$blendcredit); //调用方法进行退款操作 |
|||
} |
|||
} |
|||
#8、返回退款结果 |
|||
if ($result['error']) { |
|||
pdo_update(PDO_NAME . 'refund_record' , [ 'status' => 1 ] , [ 'id' => $refundid ]); |
|||
$res['status'] = true; |
|||
$res['message'] = '退款成功'; |
|||
//支付返现退款操作 |
|||
if(p('cashback') && $cashOrderInfo){ |
|||
//修改用户返现金额 |
|||
pdo_update(PDO_NAME."member",['cash_back_money'=>sprintf("%.2f",$member['cash_back_money'] - $cashRefund)],['id'=>$cashOrderInfo['mid']]); |
|||
//修改用户余额信息 |
|||
Member::credit_update_credit2($cashOrderInfo['mid'],-$cashRefund,'订单['.$order['orderno'].']退款取消返现金额'); |
|||
//修改返现记录信息 |
|||
pdo_update(PDO_NAME."cashback",['refund_money'=>sprintf("%.2f",$cashOrderInfo['refund_money'] + $cashRefund)],['id'=>$cashOrderInfo['id']]); |
|||
} |
|||
} else { |
|||
$errMsg = $result['msg'] ? : $errMsg; |
|||
if (empty($errMsg)) $errMsg = '未知错误,请联系管理员'; |
|||
pdo_update(PDO_NAME . 'refund_record' ,['errmsg' => $errMsg] , ['id' => $refundid]); |
|||
$res['status'] = false; |
|||
$res['message'] = $errMsg; |
|||
} |
|||
return $res; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,292 @@ |
|||
<?php |
|||
define('IN_UNIAPP',true); |
|||
error_reporting(0); |
|||
header('Access-Control-Allow-Origin:*'); |
|||
require '../../../../framework/bootstrap.inc.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/common/defines.php'; |
|||
require PATH_MODULE."/vendor/autoload.php"; |
|||
require PATH_CORE."common/autoload.php"; |
|||
Func_loader::core('global'); |
|||
global $_W,$_GPC,$db,$socket; |
|||
load()->model('attachment'); |
|||
//获取基本设置信息 |
|||
$set = pdo_get(PDO_NAME.'setting',['key' => 'im_set'],['value']); |
|||
if (is_array($set)) $set = iunserializer($set['value']); |
|||
$port = $set['port']; |
|||
$cert = $set['pem_path']; |
|||
$key = $set['key_path']; |
|||
//$cert = 'D:/Software/phpstudy_pro/Extensions/Nginx1.15.11/conf/ssl/www.locatiom.smartcity.com.pem'; |
|||
//$key = 'D:/Software/phpstudy_pro/Extensions/Nginx1.15.11/conf/ssl/www.locatiom.smartcity.com.key'; |
|||
|
|||
//开始进行通讯处理 |
|||
use Workerman\Worker; |
|||
require_once PATH_VENDOR.'workerman/workerman/Autoloader.php'; |
|||
//创建一个Worker监听端口,使用websocket协议通讯 |
|||
$context = [ |
|||
// 更多ssl选项请参考手册 http://php.net/manual/zh/context.ssl.php |
|||
'ssl' => [ |
|||
'local_cert' => $cert, |
|||
'local_pk' => $key, |
|||
'verify_peer' => false, |
|||
// 'allow_self_signed' => true, //如果是自签名证书需要开启此选项 |
|||
] |
|||
]; |
|||
$socket = new Worker("websocket://0.0.0.0:{$port}",$context); |
|||
$socket->transport = 'ssl'; |
|||
//$socket->count = 4;//启动x个进程对外提供服务 |
|||
$socket->onWorkerStart = function($worker) { |
|||
// 将db实例存储在全局变量中(也可以存储在某类的静态成员中) |
|||
global $db; |
|||
require '../../../../data/config.php'; |
|||
$master = $config['db']['master']; |
|||
$db = new \Workerman\MySQL\Connection($master['host'],$master['port'], $master['username'], $master['password'],$master['database']); |
|||
}; |
|||
//接收数据并且进行对应的处理 |
|||
$socket->onMessage = function ($connection,$data) { |
|||
//处理信息 |
|||
(new handle($data,$connection))->handleData(); |
|||
}; |
|||
//当某个链接断开时触发 |
|||
$socket->onClose = function ($connection) { |
|||
|
|||
|
|||
}; |
|||
//方法类 |
|||
class handle{ |
|||
private $data,//当前接收的消息 |
|||
$sendId,//发送方唯一id |
|||
$receiveId,//接收方唯一id |
|||
$idsFile = PATH_CORE."common/im_ids.php"; |
|||
|
|||
public function __construct($data,$connection){ |
|||
global $_W; |
|||
//data信息处理 |
|||
$data = json_decode($data,true); |
|||
$_W['uniacid'] = $data['i'] ? : $data['uniacid'];//公众号id |
|||
$_W['aid'] = $data['aid'];//代理商id |
|||
$_W['source'] = $data['source'];//渠道 |
|||
//通讯信息获取 |
|||
$data['send_id'] = intval($data['send_id']) ? : $_W['mid'];//当前发送信息的用户的id(商户id) |
|||
$data['receive_id'] = intval($data['receive_id']);//接受消息的用户id(商户id) |
|||
$data['page'] = intval($data['page']) ? : 1;//页码 |
|||
$data['page_index'] = intval($data['page_index']) ? : 10;//每页的数量 |
|||
$this->sendId = $data['send_id'].'_'.$data['receive_id']; |
|||
$this->receiveId = $data['receive_id'].'_'.$data['send_id']; |
|||
$this->data = $data; |
|||
//通讯节点处理 |
|||
$this->setIds($this->sendId,$connection->id); |
|||
} |
|||
/** |
|||
* Comment: 处理接收的data信息 |
|||
* Author: zzw |
|||
* Date: 2021/3/8 11:44 |
|||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException |
|||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|||
*/ |
|||
public function handleData(){ |
|||
global $_W,$db; |
|||
//接受信息 |
|||
$data = $this->data; |
|||
//判断是否给自己发送消息 |
|||
if($data['send_id'] == $data['receive_id'] && $data['send_type'] == $data['receive_type']) $this->socketSend($this->sendId,"不能给自己发送信息哦",5); |
|||
//判断通讯类型,进行对应的操作。信息类型:1=系统信息,2=通信信息,3=断开链接,4=通讯记录,5=错误抛出 |
|||
if($data['im_type'] == 2){ |
|||
//记录信息到表 |
|||
$newData['uniacid'] = $_W['uniacid']; |
|||
$newData['send_id'] = $data['send_id'];//发送方id |
|||
$newData['send_type'] = $data['send_type'];//发送方类型(1=用户;2=商户) |
|||
$newData['receive_id'] = $data['receive_id'];//接收人id |
|||
$newData['receive_type'] = $data['receive_type'];//接收人类型(1=用户;2=商户) |
|||
$newData['create_time'] = time();//发送时间(建立时间) |
|||
$newData['type'] = $data['type'];//内容类型:0=文本内容(可带表情),1=图片信息(不可带表情),2=视频信息(不可带表情),3=名片信息(不可带表情),4=简历信息(不可带表情),5=其他信息(不可带表情) |
|||
$newData['content'] = base64_encode($data['content']);//发送内容 |
|||
$newData['plugin'] = $data['plugin'];//发送内容 |
|||
$table = trim(tablename(PDO_NAME."im"),'`'); |
|||
$db->insert($table)->cols($newData)->query(); |
|||
//判断接收方是否在线 在线进行推送 |
|||
$memberInfo = $db->select('nickname,avatar') |
|||
->from(trim(tablename(PDO_NAME."member"),'`')) |
|||
->where("id={$newData['send_id']}") |
|||
->row(); |
|||
$sendInfo = [ |
|||
'avatar' => tomedia($memberInfo['avatar']), |
|||
'content' => $data['content'], |
|||
'create_time' => $newData['create_time'], |
|||
'date_time' => date('Y-m-d H:i:s',$newData['create_time']), |
|||
'is_my' => 1,//0=自己发送的消息,1=对方发送的消息 |
|||
'nickname' => $memberInfo['nickname'], |
|||
'receive_id' => $newData['receive_id'], |
|||
'send_id' => $newData['send_id'], |
|||
'type' => $newData['type'] |
|||
]; |
|||
|
|||
$this->socketSend($this->receiveId,'即时通讯信息',2,$data['type'],['list'=>[$sendInfo]]); |
|||
}else if ($data['im_type'] == 3){ |
|||
//断开链接 |
|||
//$this->log(['断开',$data]); |
|||
$this->deleteIds($this->sendId); |
|||
}else if($data['im_type'] == 4){ |
|||
//获取通讯记录信息 |
|||
$sendInfo['send_id'] = $data['send_id'] ;//发送方id |
|||
$sendInfo['send_type'] = $data['send_type'] ;//发送方类型(1=用户;2=商户) |
|||
$sendInfo['receive_id'] = $data['receive_id'] ;//接收人id |
|||
$sendInfo['receive_type'] = $data['receive_type'] ;//接收人类型(1=用户;2=商户) |
|||
//$list = Im::imRecord($data['page'],$data['page_index'],$sendInfo); |
|||
$pageStart = $data['page'] * $data['page_index'] - $data['page_index']; |
|||
//条件生成 |
|||
$where = " as a WHERE a.uniacid = {$_W['uniacid']} AND |
|||
( |
|||
(a.send_id = {$sendInfo['send_id']} AND a.send_type = {$sendInfo['send_type']} AND a.receive_id = {$sendInfo['receive_id']} AND a.receive_type = {$sendInfo['receive_type']}) |
|||
OR |
|||
(a.send_id = {$sendInfo['receive_id']} AND a.send_type = {$sendInfo['receive_type']} AND a.receive_id = {$sendInfo['send_id']} AND a.receive_type = {$sendInfo['send_type']}) |
|||
)"; |
|||
if($data['plugin']) $where .= " AND a.plugin = {$data['plugin']} "; |
|||
else $where .= " AND (a.plugin = '' OR a.plugin IS NULL)"; |
|||
//要查询的字段生成 |
|||
$field = " a.id,a.send_id,a.`receive_id`,a.content,a.create_time,a.type,FROM_UNIXTIME(create_time,'%Y-%m-%d %H:%i:%S') as date_time, |
|||
CASE {$sendInfo['receive_id']} WHEN a.send_id THEN 1 |
|||
ELSE 0 |
|||
END as is_my, |
|||
CASE a.`send_type` |
|||
WHEN 1 THEN (SELECT `nickname` FROM ".tablename(PDO_NAME."member")." WHERE `id` = a.`send_id`) |
|||
ELSE (SELECT storename FROM ".tablename(PDO_NAME."merchantdata")." WHERE `id` = a.`send_id` ) |
|||
END as nickname, |
|||
CASE a.`send_type` |
|||
WHEN 1 THEN (SELECT `avatar` FROM ".tablename(PDO_NAME."member")." WHERE `id` = a.`send_id`) |
|||
ELSE (SELECT logo FROM ".tablename(PDO_NAME."merchantdata")." WHERE `id` = a.`send_id` ) |
|||
END as avatar"; |
|||
#4、获取总页数 |
|||
$totalSql = "SELECT COUNT(*) as total FROM ".tablename(PDO_NAME."im").$where; |
|||
$total = $db->single($totalSql); |
|||
$list['total'] = ceil($total / $data['page_index']); |
|||
#5、获取当前页列表信息 |
|||
$listSql = "SELECT {$field} FROM ".tablename(PDO_NAME."im").$where |
|||
." ORDER BY a.create_time DESC LIMIT {$pageStart},{$data['page_index']} "; |
|||
$list['list'] = $db->query($listSql); |
|||
foreach($list['list'] as $key => &$val) { |
|||
$val['avatar'] = tomedia($val['avatar']); |
|||
if(is_base64($val['content'])) $val['content'] = base64_decode($val['content'],true); |
|||
} |
|||
//修改信息为已读 |
|||
/*if(is_array($list['list']) && count($list['list']) > 0) { |
|||
//条件生成 |
|||
$ids = array_column($list['list'],'id'); |
|||
if(!empty($sendInfo['send_id'])) $where = " receive_id = {$sendInfo['send_id']} "; |
|||
else $where = " receive_id = {$_W['mid']} "; |
|||
if(count($ids) > 1){ |
|||
$idStr = implode(',',$ids); |
|||
$where .= " AND id IN ({$idStr}) "; |
|||
}else{ |
|||
$where .= " AND id = {$ids[0]} "; |
|||
} |
|||
#2、修改内容 |
|||
$updateSql = "UPDATE ".tablename(PDO_NAME."im")." SET is_read = 1 WHERE ".$where; |
|||
$db->query($updateSql); |
|||
}*/ |
|||
$where = " send_id = {$sendInfo['receive_id']} AND send_type = {$sendInfo['receive_type']} AND receive_id = {$sendInfo['send_id']} AND receive_type = {$sendInfo['send_type']} AND is_read = 0 "; |
|||
$sql = " UPDATE ".tablename(PDO_NAME."im")." SET is_read = 1 WHERE {$where} "; |
|||
$db->query($sql); |
|||
//信息排序 |
|||
$sortArr = array_column($list['list'], 'create_time'); |
|||
array_multisort($sortArr, SORT_ASC, $list['list']); |
|||
//获取聊天对象的昵称 1=用户;2=商户 |
|||
if($sendInfo['receive_type'] == 1) { |
|||
$nicknameSql = "SELECT nickname FROM ".tablename(PDO_NAME."member")." WHERE id = {$sendInfo['receive_id']} "; |
|||
$list['receive_name'] = $db->single($nicknameSql); |
|||
} else { |
|||
$nicknameSql = "SELECT storename FROM ".tablename(PDO_NAME."merchantdata")." WHERE id = {$sendInfo['receive_id']} "; |
|||
$list['receive_name'] = $db->single($nicknameSql); |
|||
} |
|||
$this->socketSend($this->sendId,'通讯记录',4,5,$list); |
|||
} |
|||
} |
|||
/** |
|||
* Comment: 发送数据给移动端 |
|||
* Author: zzw |
|||
* Date: 2021/3/8 11:44 |
|||
* @param $id |
|||
* @param $content |
|||
* @param int $imType |
|||
* @param int $type |
|||
* @param array $other |
|||
*/ |
|||
public function socketSend($id,$content,$imType = 2,$type = 0,$other = []){ |
|||
global $socket; |
|||
//生成需要发送的信息 |
|||
$data = [ |
|||
'im_type' => $imType,//信息类型:1=系统信息,2=通信信息,3=断开链接,4=通讯记录,5=错误抛出 |
|||
//具体通讯信息 |
|||
'type' => $type,//内容类型:0=文本内容(可带表情),1=图片信息(不可带表情),2=视频信息(不可带表情),3=名片信息(不可带表情),4=简历信息(不可带表情),5=其他信息(数组) |
|||
'content' => $content,//文本内容 |
|||
'other' => $other,//其他信息(名片信息|简历信息) |
|||
]; |
|||
//发送信息 |
|||
$connectionId = $this->getIds($id); |
|||
if($connectionId > 0){ |
|||
$connection = $socket->connections[$connectionId]; |
|||
|
|||
if(is_object($connection)) $connection->send(json_encode($data,JSON_UNESCAPED_UNICODE)); |
|||
} |
|||
} |
|||
/** |
|||
* Comment: 日志记录 |
|||
* Author: zzw |
|||
* Date: 2021/3/8 11:44 |
|||
* @param $content |
|||
* @param string $title |
|||
*/ |
|||
public function log($content,$title = '日志'){ |
|||
Util::wl_log('socket',PATH_MODULE . "log/",$content,$title,false); |
|||
} |
|||
/** |
|||
* Comment: 获取ids数组信息 |
|||
* Author: zzw |
|||
* Date: 2021/3/12 10:21 |
|||
* @param int $key 发送者id |
|||
* @return array|bool|Memcache|mixed|Redis|string |
|||
*/ |
|||
public function getIds($id = 0){ |
|||
//获取文件读写权限 |
|||
if(!is_readable($this->idsFile)) chmod($this->idsFile,0755); |
|||
//获取文件内容 |
|||
$data = file_get_contents($this->idsFile); |
|||
$data = json_decode($data,true); |
|||
if($id > 0) return $data[$id]; |
|||
else return $data; |
|||
} |
|||
/** |
|||
* Comment: 设置id缓存 |
|||
* Author: zzw |
|||
* Date: 2021/3/12 10:21 |
|||
* @param int $key 发送者id |
|||
* @param int $val 通讯节点id |
|||
*/ |
|||
public function setIds($key,$val){ |
|||
header('Content-Type:text/html;charset=utf-8'); |
|||
//数组转字符串 |
|||
$data = $this->getIds(); |
|||
$data[$key] = $val; |
|||
$idStr = json_encode($data,JSON_UNESCAPED_UNICODE); |
|||
file_put_contents($this->idsFile, print_r($idStr, true)); |
|||
} |
|||
/** |
|||
* Comment: 删除id缓存 |
|||
* Author: zzw |
|||
* Date: 2021/3/18 11:13 |
|||
* @param $id |
|||
*/ |
|||
public function deleteIds($id){ |
|||
header('Content-Type:text/html;charset=utf-8'); |
|||
//数组转字符串 |
|||
$data = $this->getIds(); |
|||
unset($data[$id]); |
|||
$idStr = json_encode($data,JSON_UNESCAPED_UNICODE); |
|||
file_put_contents($this->idsFile, print_r($idStr, true)); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
//运行 |
|||
Worker::runAll(); |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
require '../../../../framework/bootstrap.inc.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/common/defines.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/common/autoload.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/function/global.func.php'; |
|||
global $_W,$_GPC; |
|||
ignore_user_abort(); |
|||
set_time_limit(0); |
|||
$flag = $_GPC['flag']; |
|||
$_W['uniacid'] = $_GPC['uniacid']; |
|||
if($flag == 'consumption'){ |
|||
Consumption::consumptions(); |
|||
} |
|||
if($flag == 'notice'){ |
|||
Consumption::notice(); |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* 自动加载类方法 |
|||
* |
|||
* @access public |
|||
* @name Wlmore_AutoLoad() |
|||
* @param $class_name 方法名; |
|||
* @since 1.0 |
|||
* @return $file 引入方法 |
|||
*/ |
|||
function Weliam_AutoLoad($class_name) { |
|||
if (strexists($class_name, 'Table')) { |
|||
$file = PATH_CORE . 'table/' . lcfirst(str_replace("Table", "", $class_name)) . '.table.php'; |
|||
} else { |
|||
$file = PATH_CORE . 'model/' . $class_name . '.mod.php'; |
|||
if (!file_exists($file)) { |
|||
$file = PATH_CORE . 'class/' . $class_name . '.class.php'; |
|||
} |
|||
if (!file_exists($file)) { |
|||
$file = PATH_PLUGIN . strtolower($class_name) . '/' . $class_name . '.mod.php'; |
|||
} |
|||
} |
|||
if (file_exists($file)) { |
|||
require_once $file; |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
spl_autoload_register('Weliam_AutoLoad'); |
|||
@ -0,0 +1,56 @@ |
|||
<?php |
|||
defined("IN_IA") or exit("访问非法"); |
|||
|
|||
$_W['current_module']['name'] = $_W['current_module']['name'] ? : 'weliam_smartcity'; |
|||
!defined("MODULE_NAME") && define("MODULE_NAME", $_W['current_module']['name']); |
|||
if(!is_file('../../../../wlversion.txt')){ |
|||
$version = file_put_contents('../../../../wlversion.txt',MODULE_NAME); |
|||
define("MODULE_NAME",$version); |
|||
} |
|||
$_W['siteroot'] = str_replace(array('/addons/' . MODULE_NAME,'/addons/weliam_smartcity', '/core/common', '/addons/bm_payms'), '', $_W['siteroot']); |
|||
!defined("PATH_MODULE") && define("PATH_MODULE", IA_ROOT . '/addons/' . MODULE_NAME . '/'); |
|||
!defined("IS_DEV") && define("IS_DEV", file_exists(IA_ROOT . '/check.php') ? true : false); |
|||
!defined("FILES_UP_PATH") && define("FILES_UP_PATH", PATH_MODULE . 'upfiles.json'); |
|||
!defined("VERSION_PATH") && define("VERSION_PATH", PATH_MODULE . 'version.php'); |
|||
!defined("URL_MODULE") && define("URL_MODULE", $_W['siteroot'] . 'addons/' . MODULE_NAME . '/'); |
|||
!defined('WL_URL_AUTH') && define('WL_URL_AUTH', 'http://citydev.weliam.com.cn/api/api.php'); |
|||
!defined('WELIAM_API') && define('WELIAM_API', 'https://auth.weliam.com.cn/api.php'); |
|||
!defined('PATH_ATTACHMENT') && define('PATH_ATTACHMENT', IA_ROOT . '/attachment/'); |
|||
!defined('PAY_PATH') && define('PAY_PATH', $_W['siteroot'] . 'addons/' . MODULE_NAME . '/payment/'); |
|||
|
|||
/* |
|||
* 表前缀定义 |
|||
*/ |
|||
!defined("PDO_NAME") && define("PDO_NAME", "wlmerchant_"); |
|||
|
|||
!defined("PATH_APP") && define("PATH_APP", PATH_MODULE . 'app/'); |
|||
!defined("PATH_WEB") && define("PATH_WEB", PATH_MODULE . 'web/'); |
|||
!defined("PATH_SYS") && define("PATH_SYS", PATH_MODULE . 'sys/'); |
|||
!defined("PATH_CORE") && define("PATH_CORE", PATH_MODULE . 'core/'); |
|||
!defined("PATH_DATA") && define("PATH_DATA", PATH_MODULE . 'data/'); |
|||
!defined("PATH_PAYMENT") && define("PATH_PAYMENT", PATH_MODULE . 'payment/'); |
|||
!defined("PATH_PLUGIN") && define("PATH_PLUGIN", PATH_MODULE . 'plugin/'); |
|||
!defined("PATH_VENDOR") && define("PATH_VENDOR", PATH_MODULE . 'vendor/'); |
|||
/* |
|||
* app resource路径 |
|||
*/ |
|||
!defined("URL_APP_RESOURCE") && define("URL_APP_RESOURCE", URL_MODULE . 'app/resource/'); |
|||
!defined("URL_APP_CSS") && define("URL_APP_CSS", URL_APP_RESOURCE . 'css/'); |
|||
!defined("URL_APP_JS") && define("URL_APP_JS", URL_APP_RESOURCE . 'js/'); |
|||
!defined("URL_APP_IMAGE") && define("URL_APP_IMAGE", URL_APP_RESOURCE . 'image/'); |
|||
!defined("URL_APP_COMP") && define("URL_APP_COMP", URL_APP_RESOURCE . 'components/'); |
|||
/* |
|||
* web resource路径 |
|||
*/ |
|||
!defined("URL_WEB_RESOURCE") && define("URL_WEB_RESOURCE", URL_MODULE . 'web/resource/'); |
|||
!defined("URL_WEB_CSS") && define("URL_WEB_CSS", URL_WEB_RESOURCE . 'css/'); |
|||
!defined("URL_WEB_JS") && define("URL_WEB_JS", URL_WEB_RESOURCE . 'js/'); |
|||
!defined("URL_WEB_IMAGE") && define("URL_WEB_IMAGE", URL_WEB_RESOURCE . 'image/'); |
|||
!defined("URL_WEB_COMP") && define("URL_WEB_COPM", URL_WEB_RESOURCE . 'components/'); |
|||
!defined("URL_WEB_COMP") && define("URL_WEB_DIY", URL_WEB_RESOURCE . 'diy/'); |
|||
|
|||
!defined('IMAGE_PIXEL') && define('IMAGE_PIXEL', URL_MODULE . 'web/resource/images/pixel.gif'); |
|||
!defined('IMAGE_NOPIC_SMALL') && define('IMAGE_NOPIC_SMALL', URL_MODULE . 'web/resource/images/nopic-small.jpg'); |
|||
!defined('IMAGE_LOADING') && define('IMAGE_LOADING', URL_MODULE . 'web/resource/images/loading.gif'); |
|||
|
|||
!defined("URL_H5_RESOURCE") && define("URL_H5_RESOURCE", URL_MODULE . 'h5/resource/'); |
|||
@ -0,0 +1,62 @@ |
|||
<?php |
|||
define('IN_OPENAPI', true); |
|||
require '../../../../framework/bootstrap.inc.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/common/defines.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/common/autoload.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/function/global.func.php'; |
|||
global $_W,$_GPC; |
|||
load()->model('attachment'); |
|||
|
|||
//判断公众号相关 |
|||
$_W['siteroot'] = str_replace(array('/addons/'.MODULE_NAME.'/core/common','/addons/weliam_smartcity/core/common'), '', $_W['siteroot']); |
|||
$_W['method'] = $method = !empty($_GPC['do']) ? $_GPC['do'] : 'index'; |
|||
$_W['aid'] = intval($_GPC['aid']); |
|||
$_W['uniacid'] = intval($_GPC['i']); |
|||
$_W['apitoken'] = trim($_GPC['token']); |
|||
if(empty($_W['uniacid'])) { |
|||
$_W['uniacid'] = intval($_GPC['weid']); |
|||
} |
|||
$_W['uniaccount'] = $_W['account'] = uni_fetch($_W['uniacid']); |
|||
if(empty($_W['uniaccount'])) { |
|||
header('HTTP/1.1 404 Not Found'); |
|||
header("status: 404 Not Found"); |
|||
exit; |
|||
} |
|||
if (!empty($_W['uniaccount']['endtime']) && TIMESTAMP > $_W['uniaccount']['endtime']) { |
|||
exit('抱歉,您的公众号服务已过期,请及时联系管理员'); |
|||
} |
|||
$_W['acid'] = $_W['uniaccount']['acid']; |
|||
$isdel_account = pdo_get('account', array('isdeleted' => 1, 'acid' => $_W['acid'])); |
|||
if (!empty($isdel_account)) { |
|||
exit('指定公众号已被删除'); |
|||
} |
|||
$_W['attachurl'] = attachment_set_attach_url(); |
|||
|
|||
//寻找对应方法 |
|||
require IA_ROOT . "/addons/'.MODULE_NAME.'/plugin/openapi/openapi.php"; |
|||
$instance = new Weliam_smartcityModuleOpenapi(); |
|||
if (!method_exists($instance, $method)) { |
|||
$method = 'doPage' . ucfirst($method); |
|||
} |
|||
$instance -> $method(); |
|||
|
|||
|
|||
class Openapi { |
|||
|
|||
public function __construct(){ |
|||
global $_W; |
|||
$settings = Setting::wlsetting_read('apiset'); |
|||
if ($_W['apitoken'] != $settings['token']) { |
|||
$this->result(-1, '无效Token'); |
|||
} |
|||
} |
|||
|
|||
public function result($errno, $message, $data = '') { |
|||
exit(json_encode(array( |
|||
'errno' => $errno, |
|||
'message' => $message, |
|||
'data' => $data, |
|||
))); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
<?php |
|||
if(is_file('../../../../wlversion.txt')){ |
|||
$version = file_get_contents('../../../../wlversion.txt'); |
|||
define("MODULE_NAME",$version); |
|||
}else{ |
|||
define("MODULE_NAME",'weliam_smartcity'); |
|||
} |
|||
require '../../../../framework/bootstrap.inc.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/common/defines.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/common/autoload.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/vendor/autoload.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/function/global.func.php'; |
|||
global $_W,$_GPC; |
|||
ignore_user_abort(); |
|||
set_time_limit(0); |
|||
|
|||
$input['time'] = date('Y-m-d H:i:s',time()); |
|||
$input['siteroot'] = $_W['siteroot']; |
|||
Util::wl_log('sinaTask',PATH_DATA."tasklog", $input); |
|||
$on = $_GPC['on'] ? intval($_GPC['on']) : 0; |
|||
|
|||
$queue = new Queue; |
|||
$queue -> queueMain($on); |
|||
File diff suppressed because one or more lines are too long
@ -0,0 +1,31 @@ |
|||
<?php |
|||
if(is_file('../../../../wlversion.txt')){ |
|||
$version = file_get_contents('../../../../wlversion.txt'); |
|||
define("MODULE_NAME",$version); |
|||
}else{ |
|||
define("MODULE_NAME",'weliam_smartcity'); |
|||
} |
|||
require '../../../../framework/bootstrap.inc.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/common/defines.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/common/autoload.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/vendor/autoload.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/function/global.func.php'; |
|||
global $_W,$_GPC; |
|||
$yunorderinfo = json_decode(html_entity_decode($_GPC['order']),true); |
|||
Util::wl_log('yun_notify', PATH_DATA . "merchant/data/", $yunorderinfo); //写入异步日志记录 |
|||
$transaction_id = $yunorderinfo['itpOrderId']; |
|||
$paylog = pdo_get('wlmerchant_paylogvfour' , ['transaction_id' => $transaction_id] , ['status','tid','uniacid','plugin' ,'plid','fee','payfor']); |
|||
$_W['uniacid'] = $paylog['uniacid']; |
|||
$tid = $paylog['tid']; |
|||
if($paylog['status'] == 0){ |
|||
$successInfo = [ |
|||
'type' => 2 ,//支付方式 |
|||
'tid' => $paylog['tid'],//订单号 |
|||
'transaction_id' => $transaction_id, |
|||
'time' => $yunorderinfo['paidTime'], |
|||
]; |
|||
PayResult::main($successInfo);//调用方法处理订单 |
|||
exit('SUCCESS'); |
|||
}else{ |
|||
exit('SUCCESS'); |
|||
} |
|||
@ -0,0 +1,113 @@ |
|||
<?php |
|||
if(is_file('../../../../wlversion.txt')){ |
|||
$version = file_get_contents('../../../../wlversion.txt'); |
|||
define("MODULE_NAME",$version); |
|||
}else{ |
|||
define("MODULE_NAME",'weliam_smartcity'); |
|||
} |
|||
require '../../../../framework/bootstrap.inc.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/common/defines.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/common/autoload.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/vendor/autoload.php'; |
|||
require '../../../../addons/'.MODULE_NAME.'/core/function/global.func.php'; |
|||
require '../../../../framework/model/attachment.mod.php'; |
|||
global $_W,$_GPC; |
|||
$transaction_id = $_GPC['out_trade_no']; |
|||
$paylog = pdo_get('wlmerchant_paylogvfour' , ['transaction_id' => $transaction_id] , ['status','tid','uniacid','plugin' ,'plid','fee','payfor']); |
|||
$_W['uniacid'] = $paylog['uniacid']; |
|||
$tid = $paylog['tid']; |
|||
//订单信息查询 |
|||
$type = strtolower($paylog['plugin']); |
|||
$payfor = strtolower($paylog['payfor']); |
|||
$data = []; |
|||
$data['plugin'] = $type; |
|||
if ($type == 'rush') { |
|||
$order = pdo_get('wlmerchant_rush_order' , ['orderno' => $tid] , ['id' ,'aid', 'num' , 'activityid' , 'actualprice']); |
|||
$data['price'] = $order['actualprice']; |
|||
$data['goodsname'] = pdo_getcolumn(PDO_NAME.'rush_activity',array('id'=>$order['activityid']),'name'); |
|||
$detail_url = h5_url('pages/subPages/orderList/orderDetails/orderDetails',['orderid'=>$order['id'],'plugin'=>'rush']); |
|||
} |
|||
else if ($type == 'merchant' && $payfor == 'halfcard') { |
|||
$order = pdo_get('wlmerchant_halfcard_record' , ['orderno' => $tid] , ['id','aid', 'num' , 'price']); |
|||
$data['price'] = $order['price']; |
|||
$data['goodsname'] = '会员开通/续费'; |
|||
} |
|||
else if ($type == 'attestation') { |
|||
$order = pdo_get('wlmerchant_attestation_money' , ['orderno' => $tid] , ['id' , 'num' , 'money' , 'type']); |
|||
$data['price'] = $order['money']; |
|||
$data['type'] = $order['type']; |
|||
$data['goodsname'] = '认证保证金缴纳'; |
|||
}else { |
|||
$order = pdo_get('wlmerchant_order' , ['orderno' => $tid] , ['id','aid' , 'recordid' , 'num' , 'fkid' , 'plugin' , 'fightstatus' , 'paidprid' , 'price' , 'vip_card_id' , 'expressid']); |
|||
$data['price'] = $order['price']; |
|||
if ($order['plugin'] == 'wlfightgroup') { |
|||
$data['goodsname'] = pdo_getcolumn(PDO_NAME.'fightgroup_goods',array('id'=>$order['fkid']),'name'); |
|||
$detail_url = h5_url('pages/subPages/orderList/orderDetails/orderDetails',['orderid'=>$order['id'],'plugin'=>'wlfightgroup']); |
|||
}else if ($order['plugin'] == 'coupon') { |
|||
$data['goodsname'] = pdo_getcolumn(PDO_NAME.'couponlist',array('id'=>$order['fkid']),'title'); |
|||
$detail_url = h5_url('pages/subPages/orderList/orderDetails/orderDetails',['orderid'=>$order['id'],'plugin'=>'coupon']); |
|||
}else if($data['plugin'] == 'citydelivery'){ |
|||
$data['price'] = $paylog['fee']; |
|||
$order = pdo_get('wlmerchant_order' , ['paylogid' => $paylog['plid']] , ['id' , 'recordid' , 'num' , 'fkid' , 'plugin' , 'fightstatus' , 'paidprid' , 'price' , 'vip_card_id' , 'expressid']); |
|||
$detail_url = h5_url('pages/subPages/orderList/orderDetails/orderDetails',['orderid'=>$order['id'],'plugin'=>'citydelivery']); |
|||
$data['goodsname'] = '同城配送商品'; |
|||
}else if ($order['plugin'] == 'groupon') { |
|||
$data['goodsname'] = pdo_getcolumn(PDO_NAME.'groupon_activity',array('id'=>$order['fkid']),'name'); |
|||
$detail_url = h5_url('pages/subPages/orderList/orderDetails/orderDetails',['orderid'=>$order['id'],'plugin'=>'groupon']); |
|||
}else if ($order['plugin'] == 'bargain') { |
|||
$data['goodsname'] = pdo_getcolumn(PDO_NAME.'bargain_activity',array('id'=>$order['fkid']),'name'); |
|||
$detail_url = h5_url('pages/subPages/orderList/orderDetails/orderDetails',['orderid'=>$order['id'],'plugin'=>'bargain']); |
|||
}else if ($order['plugin'] == 'pocket') { |
|||
$data['goodsname'] = '掌上信息付费'; |
|||
}else if ($order['plugin'] == 'store') { |
|||
$data['goodsname'] = '商户入驻'; |
|||
}else if ($order['plugin'] == 'distribution') { |
|||
$data['goodsname'] = '分销商申请'; |
|||
}else if ($order['plugin'] == 'consumption') { |
|||
$data['goodsname'] = pdo_getcolumn(PDO_NAME.'consumption_goods',array('id'=>$order['fkid']),'title'); |
|||
}else if ($order['plugin'] == 'member') { |
|||
$data['goodsname'] = '余额充值'; |
|||
}else if ($order['plugin'] == 'halfcard') { |
|||
$data['goodsname'] = '在线买单'; |
|||
}else if ($order['plugin'] == 'halfcard') { |
|||
$data['goodsname'] = '在线买单'; |
|||
}else if ($order['plugin'] == 'citycard') { |
|||
$data['goodsname'] = '同城名片付费'; |
|||
}else if ($order['plugin'] == 'yellowpage') { |
|||
$data['goodsname'] = '黄页114付费'; |
|||
}else if ($order['plugin'] == 'recruit') { |
|||
$data['goodsname'] = '招聘求职付费'; |
|||
}else if ($order['plugin'] == 'dating') { |
|||
$data['goodsname'] = '相亲交友付费'; |
|||
}else if ($order['plugin'] == 'vehicle') { |
|||
$data['goodsname'] = '顺风车付费'; |
|||
}else if ($order['plugin'] == 'housekeep') { |
|||
$data['goodsname'] = '家政服务付费'; |
|||
} |
|||
} |
|||
$data['num'] = $order['num'] ? : 1; |
|||
if(empty($data['goodsname'])){ |
|||
$data['goodsname'] = '其他付费项目'; |
|||
} |
|||
$_W['aid'] = $order['aid'] ? : 0; |
|||
//系统信息查询 |
|||
$_W['attachurl_remote'] = attachment_set_attach_url(); |
|||
$base = Setting::wlsetting_read('base'); |
|||
$base['logo'] = tomedia($base['logo']); |
|||
$home_url = h5_url('pages/mainPages/index/index'); |
|||
if(empty($detail_url)){ |
|||
$detail_url = h5_url('pages/subPages/orderList/orderList',['type'=>10]); |
|||
} |
|||
//处理订单回调 |
|||
if($paylog['status'] == 0){ |
|||
$successInfo = [ |
|||
'type' => 2 ,//支付方式 |
|||
'tid' => $paylog['tid'],//订单号 |
|||
'transaction_id' => $transaction_id, |
|||
'time' => $_GPC['t'], |
|||
]; |
|||
PayResult::main($successInfo);//调用方法处理订单 |
|||
} |
|||
|
|||
|
|||
include wl_template('utility/ahrcu'); |
|||
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,38 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
load()->classs('table'); |
|||
|
|||
class AgentareaTable extends We7Table { |
|||
|
|||
protected $tableName = 'wlmerchant_oparea'; |
|||
|
|||
public function getAreaList() { |
|||
return $this->query->from($this->tableName)->orderby('sort', 'DESC')->getall(); |
|||
} |
|||
|
|||
public function selectFields($select) { |
|||
$this->query->select($select); |
|||
return $this; |
|||
} |
|||
|
|||
public function searchWithLevel($level) { |
|||
$this->query->where('level', $level); |
|||
return $this; |
|||
} |
|||
|
|||
public function searchWithHot() { |
|||
$this->query->where('ishot', 1); |
|||
return $this; |
|||
} |
|||
|
|||
public function searchWithOpen() { |
|||
$this->query->where('status', 1); |
|||
return $this; |
|||
} |
|||
|
|||
public function searchWithUniacid($uniacid) { |
|||
$this->query->where('uniacid', $uniacid); |
|||
return $this; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
load()->classs('table'); |
|||
|
|||
class AreaTable extends We7Table { |
|||
|
|||
protected $area_table = 'wlmerchant_area'; |
|||
protected $oparea_table = 'wlmerchant_oparea'; |
|||
|
|||
public function getAreaList() { |
|||
return $this->query->from($this->area_table)->getall(); |
|||
} |
|||
|
|||
public function getAreaById($id) { |
|||
return $this->query->from($this->area_table)->where('id', $id)->get(); |
|||
} |
|||
|
|||
public function selectFields($select) { |
|||
$this->query->select($select); |
|||
return $this; |
|||
} |
|||
|
|||
public function searchWithLevel($level) { |
|||
$this->query->where('level', $level); |
|||
return $this; |
|||
} |
|||
|
|||
public function searchWithOpen() { |
|||
$this->query->where('visible', 2); |
|||
return $this; |
|||
} |
|||
|
|||
public function searchWithUniacid($uniacid) { |
|||
$value = !empty($uniacid) ? [0, $uniacid] : 0; |
|||
$this->query->where('displayorder', $value); |
|||
return $this; |
|||
} |
|||
|
|||
public function searchWithKeyword($keyword) { |
|||
if (!empty($keyword)) { |
|||
$this->query->where('name LIKE', "%{$keyword}%")->whereor('pinyin LIKE', "%{$keyword}%"); |
|||
return $this; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
<?php |
|||
defined('IN_IA') or exit('Access Denied'); |
|||
load()->classs('table'); |
|||
|
|||
class DistributionTable extends We7Table { |
|||
|
|||
protected $distributor_table = 'wlmerchant_distributor'; |
|||
|
|||
public function getDisNumById($id, $level = 1) { |
|||
if ($level == 1) { |
|||
|
|||
} |
|||
$onenum = pdo_fetchcolumn('SELECT count(id) FROM ' . tablename('wlmerchant_distributor') . " WHERE leadid = {$_W['wlmember']['id']}"); |
|||
$twonum = pdo_fetchcolumn('SELECT count(id) FROM ' . tablename('wlmerchant_distributor') . " WHERE leadid in (select mid from " . tablename('wlmerchant_distributor') . " where `leadid` = {$_W['wlmember']['id']})"); |
|||
return $this->query->from($this->area_table)->where('id', $id)->get(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue