96 行
2.2 KiB
PHP
可执行文件
96 行
2.2 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace Common\Business;
|
|
|
|
use Common\Model\SSupplierModel;
|
|
//[1.7.14]
|
|
/**
|
|
* 供货商类
|
|
* Class Supplier
|
|
* [
|
|
* 指定字段供货商列表 getList
|
|
* ]
|
|
* @package Common\Business
|
|
*/
|
|
class Supplier
|
|
{
|
|
|
|
/**
|
|
* 指定字段供货商列表
|
|
* @param $param
|
|
* [
|
|
* user_type 3商户 4门店
|
|
* merchant_id
|
|
* store_id
|
|
* fields 查询的字段
|
|
* ]
|
|
* @return mixed
|
|
*/
|
|
public function getList($param)
|
|
{
|
|
$verifyResult = $this->verifyParam($param); //参数验证
|
|
if ($verifyResult['status'] != 1) {
|
|
return $verifyResult;
|
|
}
|
|
switch ($param['user_type']) {
|
|
case 3:
|
|
//商户
|
|
break;
|
|
case 4:
|
|
//门店
|
|
$SupplierModel = new SSupplierModel();
|
|
break;
|
|
}
|
|
$where = $this->Term($param);
|
|
$fields = $param['fields'] ? $param['fields'] : '*';
|
|
try {
|
|
$list = $SupplierModel->getSelect($where, '', '', $fields); //供货商
|
|
return $list ? $list : [];
|
|
} catch (\Exception $e) {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 查询条件
|
|
* @param $param
|
|
* [
|
|
* user_type 3商户 4门店
|
|
* merchant_id
|
|
* store_id
|
|
* ]
|
|
* @return mixed
|
|
*/
|
|
public function Term($param)
|
|
{
|
|
$where = [
|
|
'merchant_id' => $param['merchant_id'],
|
|
'status' => 1
|
|
];
|
|
if ($param['user_type'] == 4) {
|
|
$where['store_id'] = $param['store_id'];
|
|
}
|
|
return $where;
|
|
}
|
|
|
|
|
|
/**
|
|
* 参数验证
|
|
* @param $param
|
|
* [
|
|
* user_type 3商户 4门店
|
|
* merchant_id
|
|
* store_id
|
|
* fields
|
|
* ]
|
|
* @return mixed
|
|
*/
|
|
public function verifyParam($param)
|
|
{
|
|
if (!in_array($param['user_type'], ['3', '4']) || empty($param['merchant_id']) || ($param['user_type'] == 4 && empty($param['store_id']))) {
|
|
return callBack(statusCode()['error'], "登录超时");
|
|
}
|
|
return callBack(statusCode()['success'], "验证成功");
|
|
}
|
|
} |