432 行
15 KiB
PHP
可执行文件
432 行
15 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Retail\Controller;
|
||
|
||
use Api\Controller\RechargeRefundController;
|
||
use Common\Business\VipEdit;
|
||
use Common\Order\VipChangeRecord;
|
||
use Retail\Business\GeneralUser;
|
||
use Retail\Business\Vip;
|
||
|
||
//[1.8.50]
|
||
|
||
/**
|
||
* 门店管理会员
|
||
* Class VipsController
|
||
* @package Retail\Controller
|
||
*/
|
||
class VipsController extends BaseController
|
||
{
|
||
//会员记录
|
||
public function integralRecord()
|
||
{
|
||
$storeid = session('storeid');
|
||
//今日赠送总积分
|
||
$time = time();
|
||
$where['storeid'] = $storeid;
|
||
$start = strtotime(date('Y-m-d 0:0:0', $time));
|
||
$end = strtotime(date('Y-m-d 23:59:59', $time));
|
||
$where['addtime'] = array('between', array($start, $end));
|
||
$where['type'] = 0;
|
||
$give_integral = M('retail_integral_order')->where($where)->sum('integral');
|
||
$give_integral = $give_integral ? $give_integral : 0;
|
||
$where['type'] = 1;
|
||
$user_integral = M('retail_integral_order')->where($where)->sum('integral');
|
||
$user_integral = $user_integral ? $user_integral : 0;
|
||
$where['type'] = 2;
|
||
$return_integral = M('retail_integral_order')->where($where)->sum('integral');
|
||
$return_integral = $return_integral ? $return_integral : 0;
|
||
$this->assign('give_integral', $give_integral);
|
||
$this->assign('user_integral', $user_integral);
|
||
$this->assign('return_integral', $return_integral);
|
||
$this->display();
|
||
}
|
||
|
||
public function integralList()
|
||
{
|
||
$storeid = session('storeid');
|
||
if (I('get.date01') != "") {
|
||
$time = I('get.date01');
|
||
$time = explode('至', $time);
|
||
$start_time = strtotime(date('Y-m-d 0:0:0', strtotime($time[0])));
|
||
$end_time = strtotime(date('Y-m-d 23:59:59', strtotime($time[1])));
|
||
$where['addtime'] = array('between', array($start_time, $end_time));
|
||
}
|
||
$where['storeid'] = $storeid;
|
||
$integral_info = M('retail_integral_order')->where($where)->order('addtime desc')->page((int)$_GET['page'], (int)$_GET['limit'])->select();
|
||
$count = M('retail_integral_order')->where(array('storeid' => $storeid))->count();
|
||
if ($integral_info) {
|
||
foreach ($integral_info as $key => &$val) {
|
||
$val['index'] = $key + 1;
|
||
if ($val['type'] == 0) {
|
||
$val['type'] = '获取';
|
||
} else if ($val['type'] == 1) {
|
||
$val['type'] = '使用';
|
||
} else if ($val['type'] == 2) {
|
||
$val['type'] = '退还';
|
||
}
|
||
$val['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
|
||
$vip = M('retail_vip')->where(array('id' => $val['vid']))->find();
|
||
$val['name'] = $vip['name'];
|
||
$val['mobile_phone'] = $vip['mobile_phone'];
|
||
}
|
||
$res['code'] = 0;
|
||
$res['msg'] = '';
|
||
$res['data'] = $integral_info;
|
||
$res['count'] = $count;
|
||
} else {
|
||
$res['code'] = 0;
|
||
$res['msg'] = '';
|
||
$res['data'] = array();
|
||
$res['count'] = $count;
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
|
||
//冻结会员
|
||
public function frozenVip()
|
||
{
|
||
$VipEditClass = new VipEdit();
|
||
|
||
$this->ajaxReturn($VipEditClass->operateVipStatus([
|
||
'merchant_id' => $this->merchant_id,
|
||
'vip_id' => I('post.vip_id'),
|
||
'status' => 3,//1恢复 3冻结 4挂失
|
||
'plus_type' => 3,
|
||
'scene' => 4,//3商户 4门店
|
||
]));
|
||
}
|
||
|
||
//解冻
|
||
public function thawVip()
|
||
{
|
||
$VipEditClass = new VipEdit();
|
||
|
||
$this->ajaxReturn($VipEditClass->operateVipStatus([
|
||
'merchant_id' => $this->merchant_id,
|
||
'vip_id' => I('post.vip_id'),
|
||
'status' => 1,//1恢复 3冻结 4挂失
|
||
'plus_type' => 3,
|
||
'scene' => 4,//3商户 4门店
|
||
]));
|
||
}
|
||
|
||
//挂失
|
||
public function lossVip()
|
||
{
|
||
$VipEditClass = new VipEdit();
|
||
|
||
$this->ajaxReturn($VipEditClass->operateVipStatus([
|
||
'merchant_id' => $this->merchant_id,
|
||
'vip_id' => I('post.vip_id'),
|
||
'status' => 4,//1恢复 3冻结 4挂失
|
||
'plus_type' => 3,
|
||
'scene' => 4,//3商户 4门店
|
||
]));
|
||
}
|
||
|
||
/**
|
||
* 会员列表页
|
||
*/
|
||
public function index()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 获取会员列表
|
||
*/
|
||
public function vipList()
|
||
{
|
||
$data = I('post.');
|
||
$data['merchant_id'] = $this->merchant_id;
|
||
$data['get_type'] = 2;
|
||
$data['label_store_id'] = $this->store_id;
|
||
if (self::$global_store_jurisdiction['store_show_vip_info'] != 1) {
|
||
//门店无显示所有会员权限时,限制门店ID
|
||
$data['store_id'] = $this->store_id;
|
||
}
|
||
$Vip = new Vip();
|
||
|
||
$this->ajaxReturn($Vip->getVipList($data));
|
||
}
|
||
|
||
/**
|
||
* 获取会员统计
|
||
*/
|
||
public function getSumData()
|
||
{
|
||
$data = I("post.");
|
||
$data['merchant_id'] = $this->merchant_id;
|
||
|
||
$Vip = new Vip();
|
||
$this->ajaxReturn($Vip->getVipSumData($data));
|
||
}
|
||
|
||
/**
|
||
* 导出会员
|
||
*/
|
||
public function exportVip()
|
||
{
|
||
$data = I('get.');
|
||
$data['merchant_id'] = $this->merchant_id;
|
||
$data['get_type'] = 2;
|
||
$data['label_store_id'] = $this->store_id;
|
||
if (self::$global_store_jurisdiction['store_show_vip_info'] != 1) {
|
||
//门店无显示所有会员权限时,限制门店ID
|
||
$data['store_id'] = $this->store_id;
|
||
}
|
||
$data['need_count'] = false;
|
||
$data['need_index'] = true;
|
||
$data['is_export'] = true;
|
||
|
||
$Vip = new Vip();
|
||
$vip_info = $Vip->getVipList($data)['data']['list'];
|
||
|
||
$filename = "会员信息统计";
|
||
$headArr = array(
|
||
array('index', '序号'),
|
||
array('name', '会员姓名'),
|
||
array('nickname', '会员昵称'),
|
||
array('mobile_phone', '手机号'),
|
||
array('user_label', '会员标签'),
|
||
array('card_key', '实体卡'),
|
||
array('birthday', '生日'),
|
||
array('grade_name', '等级'),
|
||
array('discount', '折扣'),
|
||
array('balance', '余额'),
|
||
array('integral', '积分'),
|
||
array('store_name', '所属门店'),
|
||
array('guide_name', '所属导购'),
|
||
array('add_time', '激活时间'),
|
||
array('status_name', '会员状态'),
|
||
);
|
||
$str = $filename . ',导出日期:' . date('Y-m-d H:i:s');
|
||
getExcel($filename, $headArr, $vip_info, $str);
|
||
}
|
||
|
||
/**
|
||
* 修改会员信息
|
||
*/
|
||
public function modifyVip()
|
||
{
|
||
$data = I('post.');
|
||
$data['operator_type'] = 1;
|
||
$data['user_type'] = 4;
|
||
$data['operator_id'] = $this->login_user['id'];
|
||
$data['merchant_id'] = $this->merchant_id;
|
||
$data['store_id'] = $this->store_id;
|
||
$data['platform_type'] = $this->role_info['platform_type']?$this->role_info['platform_type']:1;
|
||
$VipEditClass = new VipEdit();
|
||
$this->ajaxReturn($VipEditClass->editInfo($data));
|
||
}
|
||
|
||
/**
|
||
* 修改会员支付密码
|
||
*/
|
||
public function modifyPassword()
|
||
{
|
||
$data['operator_type'] = 1;
|
||
$data['user_type'] = 4;
|
||
$data['operator_id'] = $this->login_user['id'];
|
||
$data['merchant_id'] = $this->merchant_id;
|
||
$data['vip_id'] = I('post.vip_id');
|
||
$data['password'] = I('post.password');
|
||
$VipEditClass = new VipEdit();
|
||
$this->ajaxReturn($VipEditClass->editVipPassword($data));
|
||
}
|
||
|
||
//会员变更记录
|
||
public function editRecord()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
|
||
/**
|
||
* 门店获取会员变更记录列表
|
||
*/
|
||
public function recordList()
|
||
{
|
||
if (IS_POST) {
|
||
$data = I('post.');
|
||
$VipChangeRecordApi = new VipChangeRecord();
|
||
$res = $VipChangeRecordApi->getRecordList([
|
||
'merchant_id' => $this->merchant_id,
|
||
'store_id' => $this->store_id,
|
||
'get_vip_type' => $data['store_type'],
|
||
'start_time' => $data['time_slot'] ? $data['time_slot'][0] : '',
|
||
'end_time' => $data['time_slot'] ? $data['time_slot'][1] : '',
|
||
'keyword' => $data['keyword'],
|
||
'page' => I('post.page'),
|
||
'limit' => I('post.limit'),
|
||
'need_count' => 1,
|
||
]);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 门店会员变更记录导出
|
||
*/
|
||
public function change_export()
|
||
{
|
||
if (IS_GET) {
|
||
$seek_data = I('get.data');
|
||
$seek_data = json_decode($seek_data, true);
|
||
$VipChangeRecordApi = new VipChangeRecord();
|
||
$res = $VipChangeRecordApi->getRecordList([
|
||
'merchant_id' => $this->merchant_id,
|
||
'store_id' => $this->store_id,
|
||
'get_vip_type' => $seek_data['store_type'],
|
||
'start_time' => $seek_data['time_slot'] ? $seek_data['time_slot'][0] : '',
|
||
'end_time' => $seek_data['time_slot'] ? $seek_data['time_slot'][1] : '',
|
||
'keyword' => $seek_data['keyword'],
|
||
'page' => I('post.page'),
|
||
'limit' => I('post.limit'),
|
||
'need_count' => 0,
|
||
]);
|
||
$filename = "会员变更记录";
|
||
$headerArr = array(
|
||
array('index', '序号'),
|
||
array('name', '会员姓名'),
|
||
array('nickname', '会员昵称'),
|
||
array('store_name', '操作门店'),
|
||
array('operator_type', '操作人员类型'),
|
||
array('operator_name', '操作人员'),
|
||
array('add_time', '操作时间'),
|
||
array('before_phone', '变更前手机号'),
|
||
array('after_phone', '变更后手机号'),
|
||
array('before_card_key', '变更前实体卡'),
|
||
array('after_card_key', '变更后实体卡'),
|
||
array('before_balance', '变更前余额'),
|
||
array('after_balance', '变更后余额'),
|
||
array('before_grade', '变更前等级'),
|
||
array('after_grade', '变更后等级'),
|
||
array('before_integral', '变更前积分'),
|
||
array('after_integral', '变更后积分'),
|
||
array('password', '是否修改密码'),
|
||
);
|
||
if ($res['status'] == 1) {
|
||
$one_line_str = $filename . '导出日期' . date('Y-m-d H:i:s', time());
|
||
getExcel($filename, $headerArr, $res['data']['list'], $one_line_str);
|
||
} else {
|
||
$one_line_str = $res['message'];
|
||
getExcel($filename, $headerArr, [], $one_line_str);
|
||
}
|
||
}
|
||
}
|
||
|
||
/*
|
||
* ******************************************************普通成员***************************************************
|
||
*/
|
||
public function xcxvip()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
public function store_xcxvip_list()
|
||
{
|
||
$GeneralUser = new GeneralUser();
|
||
$param['merchant_id'] = $this->merchant_id;
|
||
$param['search_info'] = I('post.search_info');
|
||
$param['page'] = I('post.page');
|
||
$param['limit'] = I('post.limit');
|
||
|
||
$result = $GeneralUser->getGeneralUserList($param);
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
//导出
|
||
public function store_xcxvip_list_export()
|
||
{
|
||
$GeneralUser = new GeneralUser();
|
||
$param['merchant_id'] = $this->merchant_id;
|
||
$param['search_info'] = I('get.search_info');
|
||
|
||
$result = $GeneralUser->getGeneralUserList($param);
|
||
$info = $result['list'];
|
||
$filename = '普通成员';
|
||
$heararr = array(
|
||
array('index', '序号'),
|
||
array('nickname', '昵称'),
|
||
array('mobile_phone', '自提手机号'),
|
||
array('link_name', '自提姓名'),
|
||
array('add_time', '注册时间'),
|
||
);
|
||
$str = $filename . '导出时间' . date('Y-m-d', time());
|
||
getExcel($filename, $heararr, $info, $str);
|
||
}
|
||
|
||
/**
|
||
* 变更小程序用户
|
||
* @param [array] $edit_form 提交数据
|
||
* @return [array] $res
|
||
*/
|
||
public function changeRole()
|
||
{
|
||
$GeneralUser = new GeneralUser();
|
||
$edit_form = I('post.');
|
||
$edit_form['store_id'] = $this->store_id;
|
||
$param['merchant_id'] = $this->merchant_id;
|
||
$param['operator_id'] = $this->login_user['id'];
|
||
$param['platform_type'] = $this->role_info['platform_type']?$this->role_info['platform_type']:1;
|
||
$result = $GeneralUser->changeXcxInfo($edit_form, $param, 2);
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 充值列表
|
||
*/
|
||
public function rechargeIndex()
|
||
{
|
||
$vip_id = I('get.id');
|
||
$this->assign('vip_id', $vip_id);
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 点击会员退款获取该会员充值列表
|
||
*/
|
||
public function rechargeList()
|
||
{
|
||
if (IS_POST) {
|
||
$id = I('post.id');
|
||
$page = I('post.page');
|
||
$limit = I('post.limit');
|
||
$RechargeRefund = new RechargeRefundController();
|
||
$res = $RechargeRefund->rechargeList($id, $this->merchant_id, $this->store_id, 0, 2, $page, $limit);
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '数据出错';
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 会员余额退款
|
||
*/
|
||
public function refundMoney()
|
||
{
|
||
if (IS_POST) {
|
||
$id = I('post.id');
|
||
$RechargeRefund = new RechargeRefundController();
|
||
$res = $RechargeRefund->refundMoney($this->merchant_id, $id, 3);
|
||
if ($res['status'] == 1) { //退款成功,记录日志
|
||
//操作日志记录
|
||
$source = 0; //请求来源: 0pc系统 1小助手
|
||
$type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端
|
||
$request_data = json_encode($_POST); //请求参数 json数据
|
||
$desc = '会员余额退款'; //操作行为描述
|
||
action_log($source, $type, $request_data, $desc);
|
||
//end
|
||
}
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '数据出错';
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
}
|