604 行
18 KiB
PHP
可执行文件
604 行
18 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Admin\Controller;
|
||
|
||
use Common\Business\Plug;
|
||
use Common\Model\WxappinfoModel;
|
||
use Think\Controller;
|
||
|
||
//[1.9.13]
|
||
|
||
/**
|
||
* 商户设置
|
||
* Class MerchantController
|
||
* @package Admin\Controller
|
||
*/
|
||
class MerchantController extends BaseController
|
||
{
|
||
/**
|
||
* 商户信息展示管理
|
||
*/
|
||
public function index()
|
||
{
|
||
$user = session('admin_userinfo');
|
||
$agentname = M('retail_agent')->where(array('partnerid' => $user['pid']))->order('id desc')->select();
|
||
$map['partnerid'] = $user['pid'];
|
||
//所有商户
|
||
$allMerchant = M('retail_merchant')->where($map)->count();
|
||
$map['status'] = 1;
|
||
$map['end_time'] = array('gt', time());
|
||
//正常商户
|
||
$normalMerchant = M('retail_merchant')->where($map)->count();
|
||
$map['end_time'] = array('lt', time());
|
||
//过期商户
|
||
$overdueMerchant = M('retail_merchant')->where($map)->count();
|
||
$this->assign('allMerchant', $allMerchant);
|
||
$this->assign('normalMerchant', $normalMerchant);
|
||
$this->assign('overdueMerchant', $overdueMerchant);
|
||
$this->assign('agentname', json_encode($agentname));
|
||
$arr = array(
|
||
'getMerchantSms' => '/index.php/Admin/Merchant/getMerchantSms', //商户短信功能设置
|
||
'paySet' => '/index.php/Admin/Payset/paySet', //商户支付配置
|
||
'xcxConfig' => '/index.php/Admin/Merchant/xcxConfig', //商户小程序配置
|
||
);
|
||
$authArr = checkFunction($arr);
|
||
$this->assign('authArr', $authArr);
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 商户信息
|
||
*/
|
||
public function getMerchant()
|
||
{
|
||
$agent_id = I('post.agent_id');
|
||
if ($agent_id) {
|
||
$where['agentid'] = $agent_id;
|
||
}
|
||
$keyword = I('post.keyword');
|
||
if ($keyword) {
|
||
$where['mobile|name'] = ['like', '%' . $keyword . '%'];
|
||
}
|
||
$page = I('post.page');
|
||
$limit = I('post.limit');
|
||
$where['status'] = ['in', '1,2'];
|
||
$time = time();
|
||
$count = M('retail_merchant')->where($where)->count();
|
||
$merchantList = M('retail_merchant')->where($where)->order('addtime desc')->page($page, $limit)->select();
|
||
if ($merchantList) {
|
||
foreach ($merchantList as $key => &$val) {
|
||
if ($val['status'] = 1) {
|
||
if ($val['end_time'] < $time) {
|
||
$val['status_name'] = '过期';
|
||
} else {
|
||
$val['status_name'] = '正常';
|
||
}
|
||
} else if ($val['status'] = 2) {
|
||
$val['status_name'] = '禁用';
|
||
}
|
||
$val['index'] = $key + 1;
|
||
$curFormat = 'Y-m-d';
|
||
$val['add_time'] = newDate($curFormat, $val['addtime']);
|
||
$val['begin_time'] = newDate($curFormat, $val['begin_time']);
|
||
$val['end_time'] = newDate($curFormat, $val['end_time']);
|
||
$val['meal_name'] = M('retail_meal')->where(array('id' => $val['mealid']))->getField('name');
|
||
$val['agent_name'] = M('retail_agent')->where(array('id' => $val['agentid']))->getField('name');
|
||
}
|
||
} else {
|
||
$merchantList = array();
|
||
}
|
||
$res['status'] = 1;
|
||
$res['msg'] = '';
|
||
$res['data'] = $merchantList;
|
||
$res['count'] = intval($count);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 商户短信设置
|
||
*/
|
||
public function getMerchantSms()
|
||
{
|
||
$merchantid = I('post.id');
|
||
$sms_merchant = M('sms_merchant')->where(array('merchantid' => $merchantid))->find();
|
||
// 初始化 商户系统短信设置
|
||
if (empty($sms_merchant)) {
|
||
$smsconfig = M("sms_config")->find();
|
||
if (empty($smsconfig)) {
|
||
$rt['status'] = 0;
|
||
$rt['msg'] = '请先设置系统短信配置';
|
||
$this->ajaxReturn($rt);
|
||
} else {
|
||
$defaultnum = $smsconfig['defaultnum'];
|
||
$Ad['merchantid'] = $merchantid;
|
||
$Ad['allnum'] = $defaultnum; // 系统合伙人设置的默认商户可用条数
|
||
$Ad['status'] = $smsconfig['defaultstatus']; // 系统合伙人设置的默认商户使用短信权限。
|
||
$id = M('sms_merchant')->add($Ad);
|
||
$sms_merchant = M('sms_merchant')->where(array('id' => $id))->find();
|
||
}
|
||
}
|
||
if (empty($sms_merchant)) {
|
||
$rt['status'] = 0;
|
||
$rt['msg'] = '抱歉,好像出错了,请稍后再试';
|
||
} else {
|
||
$rt['status'] = 1;
|
||
$rt['msg'] = '设置成功';
|
||
$rt['data'] = $sms_merchant;
|
||
}
|
||
$this->ajaxReturn($rt);
|
||
}
|
||
|
||
/**
|
||
* 商户短信设置权限
|
||
*/
|
||
public function merchantSmsStatusSet()
|
||
{
|
||
$status = I('post.status');
|
||
$id = I('post.id');
|
||
$up = M('sms_merchant')->where(array('id' => $id))->save(array('status' => $status));
|
||
if ($up) {
|
||
$rt['status'] = 1;
|
||
$rt['msg'] = '设置成功';
|
||
} else {
|
||
$rt['status'] = 0;
|
||
$rt['msg'] = '设置失败';
|
||
}
|
||
$this->ajaxReturn($rt);
|
||
}
|
||
|
||
/**
|
||
* 商户短信设置权限
|
||
*/
|
||
public function doAddSmsAllNum()
|
||
{
|
||
$num = I('post.num');
|
||
$id = I('post.id');
|
||
$up = M('sms_merchant')->where(array('id' => $id))->setInc('allnum', $num);
|
||
if ($up) {
|
||
$rt['status'] = 1;
|
||
$rt['msg'] = '设置成功';
|
||
} else {
|
||
$rt['status'] = 0;
|
||
$rt['msg'] = '设置失败';
|
||
}
|
||
$this->ajaxReturn($rt);
|
||
}
|
||
|
||
/******************************商户小程序配置*****************************/
|
||
|
||
/**
|
||
* 商户小程序配置
|
||
*/
|
||
public function xcxConfig()
|
||
{
|
||
$merchant_id = I('get.merchant_id');
|
||
if (empty($merchant_id)) {
|
||
echo '您的操作有误';
|
||
exit;
|
||
}
|
||
$this->assign('merchant_id', $merchant_id);
|
||
$this->assign('type', 1);//1合伙人 2代理商 3商户
|
||
$authArr = array(
|
||
'submitAudit' => true,
|
||
);
|
||
$this->assign('authArr', $authArr);
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 小程序获取基本信息
|
||
*/
|
||
public function getBaseData()
|
||
{
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf(I('post.merchant_id'));
|
||
$res = $MerXcxConf->getBaseData();//获取小程序当前信息
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 修改充值入口显示状态
|
||
*/
|
||
public function changeOnlineStatus()
|
||
{
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf(I('post.merchant_id'));
|
||
$res = $MerXcxConf->changeOnlineStatus();//修改充值入口是否显示
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 小程序获取预览码
|
||
*/
|
||
public function getPreviewQrImg()
|
||
{
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf(I('post.merchant_id'));
|
||
$res = $MerXcxConf->getPreviewQrImg();//获取小程序当前信息
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 小程序的授权功能
|
||
*/
|
||
public function authIndex()
|
||
{
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf(I('get.merchant_id'));
|
||
$url = $MerXcxConf->authIndex('Admin/Merchant/authSuccess');
|
||
header('location:' . $url);
|
||
}
|
||
|
||
/**
|
||
* 小程序授权回调
|
||
*/
|
||
public function authSuccess()
|
||
{
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf(I('get.merchant_id'));
|
||
$res = $MerXcxConf->authSuccess();
|
||
$this->assign('status', $res ? 1 : 0);
|
||
if (!$res) {
|
||
$this->assign('msg', $MerXcxConf->errMsg);
|
||
}
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 小程序提交审核
|
||
*/
|
||
public function submitAudit()
|
||
{
|
||
$urgent_state = I('post.urgent_state') ? I('post.urgent_state') : 0;
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf(I('post.merchant_id'));
|
||
$res = $MerXcxConf->submitAudit($urgent_state);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 绑定开发体验用户
|
||
*/
|
||
public function bindUser()
|
||
{
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf(I('post.merchant_id'));
|
||
$res = $MerXcxConf->bindUser();
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 小程序审核撤回
|
||
*/
|
||
public function undoCodeAudit()
|
||
{
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf(I('post.merchant_id'));
|
||
$res = $MerXcxConf->undoCodeAudit();
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 发布小程序版本
|
||
*/
|
||
public function release()
|
||
{
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf(I('post.merchant_id'));
|
||
$res = $MerXcxConf->release();
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 回退小程序版本
|
||
*/
|
||
public function reBack()
|
||
{
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf(I('post.merchant_id'));
|
||
$res = $MerXcxConf->reBack();
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 回退小程序版本
|
||
*/
|
||
public function clearAuthInfo()
|
||
{
|
||
$MerXcxConf = new \Addons\Api\MerXcxConf(I('post.merchant_id'));
|
||
$res = $MerXcxConf->clearAuthInfo();
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
|
||
|
||
/*******************************商户支付设置*******************************/
|
||
|
||
/**
|
||
* 支付页面
|
||
*/
|
||
public function paySet()
|
||
{
|
||
$merchant_id = I('get.merchant_id');
|
||
if (empty($merchant_id)) {
|
||
$this->error("请求有误");
|
||
exit;
|
||
}
|
||
// 查询商户设置
|
||
$result = A('Api/RetailPaySet')->getPaySet($merchant_id);
|
||
$this->assign('merchant_id', $merchant_id);
|
||
$this->assign('entry_status', $result['entry_status']);
|
||
$this->assign("merchantInfo", json_encode($result['merchantInfo']));
|
||
$this->assign('entry', json_encode($result['entry']));
|
||
$this->assign('pay', json_encode($result['paySet']));
|
||
$this->assign('open_user', 3);
|
||
// 节点
|
||
$arr = array(
|
||
'doSetPaySet' => '/index.php/Admin/Merchant/doSetPaySet',
|
||
);
|
||
$authArr = checkFunction($arr);
|
||
$this->assign('authArr', $authArr);
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 获取该代理商支付模式权限
|
||
*/
|
||
public function get_pay_pattern()
|
||
{
|
||
$merchant_id = I('post.merchant_id');
|
||
$pay_list = M('retail_merchant as m')
|
||
->join('ls_retail_pay_pattern as p on p.agent_id=m.agentid')
|
||
->field('p.*')
|
||
->where(array('m.id' => $merchant_id))
|
||
->find();
|
||
$res['general_pay'] = $pay_list['general_pay'] ? $pay_list['general_pay'] : 0;
|
||
$res['service_pay'] = $pay_list['service_pay'] ? $pay_list['service_pay'] : 0;
|
||
$res['new_continent_pay'] = $pay_list['new_continent_pay'] ? $pay_list['new_continent_pay'] : 0;
|
||
$res['cloud_pay'] = $pay_list['cloud_pay'] ? $pay_list['cloud_pay'] : 0;
|
||
|
||
$Plug = new Plug();
|
||
$merPlug = $Plug->merPlugState([
|
||
'merchant_id' => $merchant_id,
|
||
'identification_arr' => ['moneyguestpay', 'lakalapay', 'happypay']
|
||
]);
|
||
|
||
$res['happy_pay'] = $pay_list['happy_pay'] && $merPlug['happypay'] ? $pay_list['happy_pay'] : 0;//乐返支付模式状态:0:关闭,1:开启
|
||
$res['lakala_pay'] = $pay_list['lakala_pay'] && $merPlug['lakalapay'] ? $pay_list['lakala_pay'] : 0;//拉卡拉支付模式状态:0:关闭,1:开启
|
||
$res['qian_ke_pay'] = $pay_list['qian_ke_pay'] && $merPlug['moneyguestpay'] ? $pay_list['qian_ke_pay'] : 0;//钱客云支付模式状态:0关闭,1开启
|
||
$res['close_pay_type'] = 1;
|
||
$res['status'] = 1;
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 上传证书
|
||
*/
|
||
public function upload()
|
||
{
|
||
$res = A('Api/RetailPaySet')->upload();
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 图片上传
|
||
*/
|
||
public function uploads()
|
||
{
|
||
// 判断登录
|
||
$merchant_id = I('post.merchant_id');
|
||
if (!$merchant_id) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '请求有误';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$res = A('Api/RetailPaySet')->uploads($merchant_id);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 保存支付设置
|
||
*/
|
||
public function doSetPaySet()
|
||
{
|
||
if (IS_POST) {
|
||
$merchant_id = I('post.merchant_id');
|
||
if (empty($merchant_id)) {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '请求有误';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$res = A('Api/RetailPaySet')->doSetPaySet($merchant_id);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 加载申请新大陆商户页面
|
||
*/
|
||
public function merchantEntry()
|
||
{
|
||
$merchant_id = I('get.merchant_id');
|
||
$open_type = I('get.open_type');
|
||
$this->assign('merchant_id', $merchant_id);
|
||
$this->assign('open_type', $open_type);
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 获取初始新大陆进件信息
|
||
*/
|
||
public function initialNewPaySet()
|
||
{
|
||
// 判断登录
|
||
$merchant_id = I('post.merchant_id');
|
||
if (!$merchant_id) {
|
||
$res = array('status' => 0, 'msg' => '请求有误');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$res = A('Api/RetailPaySet')->initialNewPaySet($merchant_id);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 已有新大陆商户,直接配置 Configurexdl
|
||
*/
|
||
public function customSettings()
|
||
{
|
||
$merchant_id = I('post.merchant_id');
|
||
if (!$merchant_id) {
|
||
$res = array('status' => 0, 'msg' => '请求有误');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$result = A('Api/RetailPaySet')->customSettings($merchant_id);
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 获取经营类目
|
||
*/
|
||
public function getMccArr()
|
||
{
|
||
$res = A('Api/RetailPaySet')->getMccArr();
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 获取省列表
|
||
*/
|
||
public function getProvince()
|
||
{
|
||
$res = A('Api/RetailPaySet')->getProvince();
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 获取市列表
|
||
*/
|
||
public function getSubordinate()
|
||
{
|
||
// 接收参数
|
||
$p_id = I('post.p_id');
|
||
if (!$p_id) {
|
||
$res = array('status' => 0, 'msg' => '参数缺失');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$res = A('Api/RetailPaySet')->getSubordinate($p_id);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 获取区列表
|
||
*/
|
||
public function getArea()
|
||
{
|
||
// 接收参数
|
||
$province = I('post.province');
|
||
$city = I('post.city');
|
||
if (!$province || !$city) {
|
||
$res = array(
|
||
'status' => 0,
|
||
'msg' => '参数缺失'
|
||
);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$res = A('Api/RetailPaySet')->getArea();
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 获取银行信息
|
||
*/
|
||
public function getBank()
|
||
{
|
||
$res = A('Api/RetailPaySet')->getBank();
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 获取联行信息
|
||
*/
|
||
public function getWcLbnkNo()
|
||
{
|
||
$keyword = I('post.keyword');
|
||
$res = A('Api/RetailPaySet')->getWcLbnkNo($keyword);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 保存新大陆进件信息
|
||
*/
|
||
public function updateNewPaySet()
|
||
{
|
||
$merchant_id = I('post.merchant_id');
|
||
if (!$merchant_id) {
|
||
$res = array('status' => 0, 'msg' => '请求有误');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
// 接收参数
|
||
$data = I('post.data');
|
||
$step = I('post.step');
|
||
$res = A('Api/RetailPaySet')->updateNewPaySet($data, $step, $merchant_id);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 第一次提交进件信息
|
||
*/
|
||
public function toIncomingParts()
|
||
{
|
||
$merchant_id = I('post.merchant_id');
|
||
if (!$merchant_id) {
|
||
$res = array('status' => 0, 'msg' => '请求有误');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$res = A('Api/RetailPaySet')->toIncomingParts($merchant_id);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 提交信息
|
||
*/
|
||
public function submitApply()
|
||
{
|
||
$merchant_id = I('post.merchant_id');
|
||
if (!$merchant_id) {
|
||
$res = array('status' => 0, 'msg' => '请求有误');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$res = A('Api/RetailPaySet')->submitApply($merchant_id);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 商户提交查询状态
|
||
*/
|
||
public function searchEntryApply()
|
||
{
|
||
$merchant_id = I('post.merchant_id');
|
||
if (!$merchant_id) {
|
||
$res = array('status' => 0, 'msg' => '请求有误');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$res = A('Api/RetailPaySet')->searchEntryApply($merchant_id);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 商户申请修改 商户通过时才能申请
|
||
*/
|
||
public function applyChange()
|
||
{
|
||
$merchant_id = I('post.merchant_id');
|
||
if (!$merchant_id) {
|
||
$res = array('status' => 0, 'msg' => '请求有误');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$res = A('Api/RetailPaySet')->applyChange($merchant_id);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 删除商户新大陆支付配置
|
||
*/
|
||
public function deleteEntry()
|
||
{
|
||
$merchant_id = I('post.merchant_id');
|
||
if (!$merchant_id) {
|
||
$res = array('status' => 0, 'msg' => '请求有误');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$res = A('Api/RetailPaySet')->deleteEntry($merchant_id);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
} |