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

178 行
4.8 KiB
PHP
可执行文件

<?php
namespace Common\Business;
use Common\Model\RetailCashierModel;
//[1.7.90]
/**
* 收银员
* Class Cashier
* [
* 线上订单推送 pushCashier
* 获取收银员openid getCashierOpenid
* 收银员授权微信 bindingWx
* 获取收银员列表信息的查询条件 getCashierListInfoTerm
* 获取收银员列表信息 getCashierListInfo
* 获取门店的收银员列表共选择 getChooseCashierList
* ]
* @package Common\Business
*/
class Cashier
{
/**
* 收银员线上订单推送
* @param $param
* [
* merchant_id
* store_id
* data 推送的信息
* ]
* @return mixed
*/
public function pushCashier($param)
{
if (empty($param['store_id'])) {
return callBack(statusCode()['error'], "缺少唯一标识");
}
if (empty($param['data'])) {
return callBack(statusCode()['error'], "缺少推送信息");
}
$openid_arr = $this->getCashierOpenid($param);
if (!empty($openid_arr)) {
foreach ($openid_arr as $value) {
A('Vip/Mark')->onlineOrderPush($param['merchant_id'], 9, $param['data'], $value);//小程序模板通知
}
}
}
/**
* 获取收银员openid
* @param $param
* [
* store_id
* merchant_id
* ]
* @return mixed
*/
public function getCashierOpenid($param)
{
$where = [
'merchantid' => $param['merchant_id'],
'storeid' => $param['store_id'],
'status' => 1,
'push_state' => 1,
'openid' => ['neq', '']
];
$CashierModel = new RetailCashierModel();
$openid = $CashierModel->getFindField($where, 'openid', true);
return $openid;
}
/**
* 授权微信
* @param $param
* [
* merchant_id
* store_id
* cashier_id
* openid
* ]
* @return mixed
*/
public function bindingWx($param)
{
if (empty($param['openid']) || empty($param['cashier_id'])) {
return callBack(statusCode()['error'], "请求超时");
}
$cashierModel = new RetailCashierModel();
$info = $cashierModel->getFind([
'id' => $param['cashier_id']
]);
if (empty($info)) {
return callBack(statusCode()['error'], "请先成为收银员");
}
$upData = $cashierModel->updateOrder([
'id' => $param['cashier_id']
], [
'openid' => $param['openid']
]);
if (!$upData) {
return callBack(statusCode()['error'], "已绑定");
} else {
return callBack(statusCode()['error'], "绑定成功");
}
}
/**
* 获取收银员列表信息
* @param $param
* [
* store_id
* keyword 姓名与手机号
* ]
* @return mixed
*/
public function getCashierListInfo($param)
{
if (empty($param['store_id'])) {
return callBack(statusCode()['error'], "缺少门店参数");
}
$where = $this->getCashierListInfoTerm($param);
$page = $param['page'] ? $param['page'] : '';
$limit = $param['limit'] ? $param['limit'] : '';
$CashierModel = new RetailCashierModel();
$list = $CashierModel->getSelect($where, '*', 'id desc', $page . ',' . $limit);
if (!empty($list)) {
$count = $CashierModel->getCount($where);
foreach ($list as $key => &$val) {
$val['index'] = $key + 1;
$val['add_time'] = date("Y-m-d H:i:s", $val['addtime']);
}
}
return callBack(statusCode()['success'], "查询成功", ['list' => $list, 'count' => $count ? $count : 0]);
}
/**
* 获取收银员列表信息的查询条件
* @param $param
* [
* store_id
* keyword 姓名与手机号
* ]
* @return mixed
*/
public function getCashierListInfoTerm($param)
{
if (!empty($param['keyword'])) {
$where['mobile|name'] = ['like', '%' . $param['keyword'] . '%'];
}
$where['storeid'] = $param['store_id'];
$where['status'] = 1;
return $where;
}
/**
* 获取门店的收银员列表共选择
* @param $param
* $param['store_id'] 门店ID
* @return mixed
*/
public function getChooseCashierList($param)
{
if (empty($param['store_id'])) {
return callBack(statusCode()['error'], "缺少门店参数");
}
$CashierModel = new RetailCashierModel();
$where = [
'storeid' => $param['store_id'],
'status' => 1,
];
$list = $CashierModel->getSelect($where, 'id,name', 'id asc');
return callBack(statusCode()['success'], empty($list) ? '暂无数据' : '获取成功', $list);
}
}