234 行
7.8 KiB
PHP
可执行文件
234 行
7.8 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Retail\Controller;
|
||
|
||
use Common\Model\StoreConfigModel;
|
||
|
||
//[1.5.46]
|
||
|
||
/**
|
||
* 打印设置
|
||
* Class ReceiptController
|
||
* @package Retail\Controller
|
||
*/
|
||
class ReceiptController extends BaseController
|
||
{
|
||
public function _initialize()
|
||
{
|
||
parent::_initialize(); // TODO: Change the autogenerated stub
|
||
|
||
$store_id = $this->store_id;
|
||
if (!$store_id) {
|
||
if(IS_POST){
|
||
$res['status'] = 0;
|
||
$res['msg'] = '登录超时,请重新登录';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
}
|
||
}
|
||
|
||
public function index()
|
||
{
|
||
$arr = array(
|
||
'receiptSet' => '/index.php/Retail/Receipt/receiptSet',
|
||
'delreceipt' => '/index.php/Retail/Receipt/delreceipt',
|
||
);
|
||
$authArr = checkFunction($arr);
|
||
$this->assign('authArr', $authArr);
|
||
$this->display();
|
||
}
|
||
|
||
public function receiptList()
|
||
{
|
||
$count = M('retail_receipt')
|
||
->where(array('storeid' => $this->store_id, 'status' => array('in', array(1, 2))))
|
||
->count();
|
||
$page = I('post.page');
|
||
$limit = I('post.limit');
|
||
$list = M('retail_receipt')
|
||
->where(array('storeid' => $this->store_id, 'status' => array('in', array(1, 2))))
|
||
->page($page, $limit)
|
||
->select();
|
||
foreach ($list as &$v) {
|
||
$v['addtime'] = date('Y-m-d H:i', $v['addtime']);
|
||
$v['set'] = json_decode($v['set'], true);
|
||
switch ($v['status']) {
|
||
case 1:
|
||
$v['status_name'] = '正常';
|
||
break;
|
||
case 2:
|
||
$v['status_name'] = '已关闭';
|
||
break;
|
||
case 3:
|
||
$v['status_name'] = '已删除';
|
||
break;
|
||
default:
|
||
$v['status_name'] = '不是正常的状态';
|
||
break;
|
||
}
|
||
switch ($v['type']) {
|
||
case 1:
|
||
$v['type_name'] = '收银小票';
|
||
break;
|
||
case 2:
|
||
$v['type_name'] = '充值小票';
|
||
break;
|
||
default:
|
||
$v['type_name'] = '不是正常小票类型';
|
||
break;
|
||
}
|
||
}
|
||
$result['status'] = 1;
|
||
$result['msg'] = '获取成功';
|
||
$result['count'] = intval($count);
|
||
$result['data'] = $list;
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
// 小票设置
|
||
public function receiptSet()
|
||
{
|
||
$id = I('post.id');
|
||
$name = I('post.name');
|
||
$set = htmlspecialchars_decode(I('post.set'));
|
||
$data['name'] = $name;
|
||
$data['width'] = I('post.width');
|
||
$data['paperwidth'] = I('post.paperwidth');
|
||
$data['set'] = $set;
|
||
if ($id) {
|
||
$res = M('retail_receipt')->where(array('storeid' => $this->store_id, 'id' => $id))->save($data);
|
||
if ($res) {
|
||
//操作日志记录
|
||
$source = 0;//请求来源: 0pc系统 1小助手
|
||
$type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端
|
||
$request_data = json_encode($_POST);//请求参数 json数据
|
||
$desc = '小票设置-编辑';//操作行为描述
|
||
action_log($source, $type, $request_data, $desc);
|
||
|
||
$rt['status'] = 1;
|
||
$rt['msg'] = '设置成功';
|
||
} else {
|
||
$rt['status'] = 0;
|
||
$rt['msg'] = '设置失败';
|
||
}
|
||
} else {
|
||
$data['storeid'] = $this->store_id;
|
||
$data['addtime'] = time();
|
||
$data['status'] = 2;
|
||
$data['type'] = I('post.type');
|
||
$res = M('retail_receipt')->add($data);
|
||
if ($res) {
|
||
//操作日志记录
|
||
$source = 0;//请求来源: 0pc系统 1小助手
|
||
$type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端
|
||
$request_data = json_encode($_POST);//请求参数 json数据
|
||
if ($data['type'] == 1) {
|
||
$desc = '小票设置-添加收银小票';//操作行为描述
|
||
} elseif ($data['type'] == 2) {
|
||
$desc = '小票设置-添加充值小票';//操作行为描述
|
||
}
|
||
action_log($source, $type, $request_data, $desc);
|
||
|
||
$rt['status'] = 1;
|
||
$rt['msg'] = '设置成功';
|
||
} else {
|
||
$rt['status'] = 0;
|
||
$rt['msg'] = '设置失败';
|
||
}
|
||
}
|
||
$this->ajaxReturn($rt);
|
||
}
|
||
|
||
// 小票删除
|
||
public function delreceipt()
|
||
{
|
||
$id = I('post.id');
|
||
$data = array(
|
||
'status' => 3
|
||
);
|
||
$res = M('retail_receipt')->where(array('storeid' => $this->store_id, 'id' => $id))->save($data);
|
||
if ($res) {
|
||
//操作日志记录
|
||
$source = 0;//请求来源: 0pc系统 1小助手
|
||
$type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端
|
||
$request_data = json_encode($_POST);//请求参数 json数据
|
||
$desc = '小票设置-删除';//操作行为描述
|
||
action_log($source, $type, $request_data, $desc);
|
||
|
||
$rt['status'] = 1;
|
||
$rt['msg'] = '删除成功';
|
||
} else {
|
||
$rt['status'] = 0;
|
||
$rt['msg'] = '删除失败';
|
||
}
|
||
$this->ajaxReturn($rt);
|
||
}
|
||
|
||
// 小票开启关闭
|
||
public function editReceiptStatus()
|
||
{
|
||
$id = I('post.id');
|
||
$status = I('post.status');
|
||
|
||
if ($status == 1) {
|
||
$type = M('retail_receipt')->where(array('storeid' => $this->store_id, 'id' => $id))->getField('type');
|
||
$datas = array(
|
||
'status' => 2
|
||
);
|
||
M('retail_receipt')->where(array('storeid' => $this->store_id, 'type' => $type, 'status' => 1))->save($datas);
|
||
}
|
||
$data = array(
|
||
'status' => $status
|
||
);
|
||
$res = M('retail_receipt')->where(array('storeid' => $this->store_id, 'id' => $id))->save($data);
|
||
if ($res) {
|
||
//操作日志记录
|
||
$source = 0;//请求来源: 0pc系统 1小助手
|
||
$type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端
|
||
$request_data = json_encode($_POST);//请求参数 json数据
|
||
if ($status == 1) {
|
||
$desc = '小票设置-开启小票';//操作行为描述
|
||
} elseif ($status == 2) {
|
||
$desc = '小票设置-关闭小票';//操作行为描述
|
||
}
|
||
action_log($source, $type, $request_data, $desc);
|
||
|
||
$rt['status'] = 1;
|
||
$rt['msg'] = '设置成功';
|
||
} else {
|
||
$rt['status'] = 0;
|
||
$rt['msg'] = '设置失败';
|
||
}
|
||
$this->ajaxReturn($rt);
|
||
}
|
||
|
||
// 获取手小票手机号
|
||
public function getMobileShow()
|
||
{
|
||
$StoreConfig = new StoreConfigModel();
|
||
|
||
// 获取当前的状态
|
||
$mobile_set = $StoreConfig->getFind(['store_id' => $this->store_id], 'mobile_set');
|
||
|
||
$res['status'] = 1;
|
||
$res['data'] = $mobile_set;
|
||
$res['msg'] = '数据获取成功!';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
// 设置小票手机号-隐藏/显示
|
||
public function setMobileShow()
|
||
{
|
||
$mobile_set = I('post.mobile_set');
|
||
$StoreConfig = new StoreConfigModel();
|
||
$res = $StoreConfig->updateOrder(['store_id' => $this->store_id], ['mobile_set' => $mobile_set]);
|
||
if ($res) {
|
||
$result['status'] = 1;
|
||
$result['msg'] = '修改成功';
|
||
} else {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '修改失败';
|
||
}
|
||
$this->ajaxReturn($result);
|
||
}
|
||
} |