文件
mashangyoujiu/Application/Common/Business/StoreAuthority.class.php

103 行
2.6 KiB
PHP
可执行文件

<?php
namespace Common\Business;
use Common\Model\RetailStoreAuthModel;
use Common\Model\StoreConfigModel;
//[1.7.90]
/**
* 门店权限类
* Class StoreAuthority
* [
* 获取门店设置权限 getStoreConfig
* 价格按条码秤价格权限 codePriceState
* 查询单个权限 checkSingleAuth
* ]
* @package Common\Business
*/
class StoreAuthority
{
/**
* 获取门店设置权限
* @param $param
* [
* store_id
* fields
* ]
* @return mixed
*/
public function getStoreConfig($param)
{
try {
$StoreConfigModel = new StoreConfigModel();
$info = $StoreConfigModel->getFind([
'store_id' => $param['store_id']
], $param['fields']);
return callBack(statusCode()['success'], '查询成功', $info);
} catch (\Exception $e) {
return callBack(statusCode()['success'], '查询成功', []);
}
}
/**
* 价格按条码秤价格权限
* @param $param
* [
* store_id
* code_price_state 0关闭 1开启
* ]
* @return mixed
*/
public function codePriceState($param)
{
if (empty($param['store_id'])) {
return callBack(statusCode()['error'], '缺少门店唯一标识');
}
$where = [
'store_id' => $param['store_id']
];
$data = [
'store_id' => $param['store_id'],
'code_price_state' => $param['code_price_state']
];
$configModel = new StoreConfigModel();
$id = $configModel->getFindField($where, 'id');
if (!empty($id)) {
//修改
unset($data['store_id']);
$result = $configModel->updateOrder($where, $data);
} else {
//添加
$result = $configModel->addOrder($data);
}
if ($result) {
return callBack(statusCode()['success'], '修改成功');
} else {
return callBack(statusCode()['error'], '暂无修改');
}
}
/**
* 查询权限
* @param $param
* [
* store_id
* field 查询的权限字段
* ]
* @return int
*/
public function checkSingleAuth($param)
{
try {
$StoreAuthModel = new RetailStoreAuthModel();
$field_name = $StoreAuthModel->getFindField(['storeid' => $param['store_id']], $param['field']);
return $field_name;
} catch (\Exception $e) {
return '';
}
}
}