文件
mashangyoujiu/Application/Retail/Controller/StoreController.class.php

786 行
31 KiB
PHP
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace Retail\Controller;
use Api\Controller\AlidayuController;
use Common\Business\SerialNumberGoods;
use Common\Business\Store;
use Common\Model\CitysModel;
use Common\Model\ImageGalleryModel;
use Common\Model\RetailDaMerchantModel;
use Common\Model\RetailDeliveryConfigModel;
use Common\Model\RetailFranchiseeModel;
use Common\Model\RetailManagerModel;
use Common\Model\RetailMerchantModel;
use Common\Model\RetailStoreModel;
use Common\Order\Statistics;
use Retail\Model\StoreIndustryModel;
use Think\Controller;
//[1.8.50]
/**
* 门店
* Class StoreController
* @package Retail\Controller
*/
class StoreController extends BaseController
{
public function index()
{
$this->display();
}
/*门店列表*/
public function store()
{
$this->display();
}
/*获取门店列表*/
public function getStoreList()
{
$store_name = I('post.store_name');
$store_class = I('post.store_class');
$industry_id = I('post.industry_id');
$map = [
'merchantid' => $this->merchant_id,
'store_status' => 0,
];
if (!empty($store_class)) {
$map['store_class'] = $store_class;
}
if (!empty($store_name)) {
$map['storetag'] = ['like', '%' . $store_name . '%'];
}
if ($industry_id != '') {
$map['industry_id'] = $industry_id;
}
$StoreModel = new RetailStoreModel();
$StoreIndustryModel = new StoreIndustryModel();
$ImageGalleryModel = new ImageGalleryModel();
$count = $StoreModel->getCount($map);
$storeList = $StoreModel->getSelect($map, '*', 'id asc', $_POST['page'] . ',' . $_POST['limit']);
foreach ($storeList as $key => &$val) {
if ($val['store_type'] == 0 && $val['store_class'] == 1) {
$val['store_type'] = "直营店-主店";
} else if ($val['store_type'] == 1 && $val['store_class'] == 1) {
$val['store_type'] = "直营店-分店";
} else if ($val['store_class'] == 2) {
$val['store_type'] = "加盟店";
}
if ($val['industry_id']) {
$val['industry_name'] = $StoreIndustryModel->getFindField(['id' => $val['industry_id']], 'name');
} else {
$val['industry_name'] = '-';
}
if ($val['shopimg_id']) {
$val['shopimg_url'] = $ImageGalleryModel->getOneField(['id' => $val['shopimg_id']], 'path');
} else {
$val['shopimg_url'] = '';
}
$val['store_name'] = $val['storetag'];
unset($val['storetag']);
unset($val['shopimg_id']);
$ManagerModel = new RetailManagerModel();
$manager = $ManagerModel->getFind(array('storeid' => $val['id'], 'status' => 1));
$val['shop_manager'] = $manager ? $manager['name'] : '未设置店长';
$val['tel'] = $manager ? $manager['mobile'] : '未设置店长';
}
$res['status'] = 1;
$res['message'] = empty($storeList) ? '暂无数据' : '获取成功';
$res['count'] = $count;
$res['data'] = $storeList;
$this->ajaxReturn($res);
}
/**
* 添加门店
*/
public function addstore()
{
$this->display();
}
/**
* 编辑门店
*/
public function editstore()
{
$this->display('addstore');
}
/**
* 门店新增/修改封装
* 2021年1月19日10:26:49
* @author GuYunQinFeng
*/
public function operateStoreInfo()
{
$param = I('post.');
$param['merchant_id'] = $this->merchant_id;
$param['platform_type'] = $this->role_info['platform_type'];
$Store = new Store();
$result = $Store->operateStoreInfo($param);
$this->ajaxReturn($result);
}
/**
* 行业门店开启/关闭
*/
public function manageSet()
{
if (IS_POST) {
$storeIds = I('post.storeIds');
$neq = M('retail_store')->where(array('merchantid' => $this->merchant_id))->save(array('store_status' => 1));
if ($storeIds) {
$neq = M('retail_store')->where(array('merchantid' => $this->merchant_id, 'id' => array('in', $storeIds)))->save(array('store_status' => 0));
}
if ($neq) {
$res['status'] = 1;
$res['msg'] = '操作成功';
//操作日志记录
$source = 0; //请求来源: 0pc系统 1小助手
$type = 3; //平台: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);
} else {
$where['state'] = 0; //状态正常的门店
$where['merchantid'] = $this->merchant_id; //商户id
$stores = M('retail_store')->field('id,storetag')->where(array('merchantid' => $this->merchant_id, 'state' => 0))->select();
$stores = $stores ? $stores : array();
$this->assign('stores', json_encode($stores));
//查询行业门店表已经存在的门店
$haveStore = M('retail_store')->field('id')->where(array('merchantid' => $this->merchant_id, 'store_status' => 0, 'state' => 0))->select();
$store_id = $this->_array_column($haveStore, 'id');
$this->assign('store_id', json_encode($store_id));
$this->display();
}
}
public function _array_column($input, $columnKey, $indexKey = null)
{
if (!function_exists('array_column')) {
$columnKeyIsNumber = (is_numeric($columnKey)) ? true : false;
$indexKeyIsNull = (is_null($indexKey)) ? true : false;
$indexKeyIsNumber = (is_numeric($indexKey)) ? true : false;
$result = array();
foreach ((array)$input as $key => $row) {
if ($columnKeyIsNumber) {
$tmp = array_slice($row, $columnKey, 1);
$tmp = (is_array($tmp) && !empty($tmp)) ? current($tmp) : null;
} else {
$tmp = isset($row[$columnKey]) ? $row[$columnKey] : null;
}
if (!$indexKeyIsNull) {
if ($indexKeyIsNumber) {
$key = array_slice($row, $indexKey, 1);
$key = (is_array($key) && !empty($key)) ? current($key) : null;
$key = is_null($key) ? 0 : $key;
} else {
$key = isset($row[$indexKey]) ? $row[$indexKey] : 0;
}
}
$result[$key] = $tmp;
}
return $result;
} else {
return array_column($input, $columnKey, $indexKey);
}
}
/**
* 删除门店发送短信
*/
public function sendDelPhoneMessage()
{
$RetailMerchantModel = new RetailMerchantModel();
$AlidayuController = new AlidayuController();
$merchant_id = $this->merchant_id;
$merchantNum = $RetailMerchantModel->getFindField(['id' => $merchant_id], 'mobile');
$sendRes = $AlidayuController->Send($merchantNum, $merchant_id);
$this->ajaxReturn($sendRes);
}
/**
* 删除门店
*/
public function delstore()
{
$storeIds = I('post.storeIds');
if (IS_POST && !empty($storeIds)) {
$verifyCode = I('post.code');
$verifyPhone = session('identifying_codes');
if (!$verifyPhone) {
$this->ajaxReturn(['status' => 0, 'msg' => '验证码已过期,请重新获取']);
} elseif ($verifyPhone != $verifyCode) {
$this->ajaxReturn(['status' => 0, 'msg' => '请输入正确的验证码']);
}
$sMap = array(
'merchantid' => $this->merchant_id,
'id' => array('in', $storeIds),
'store_status' => 1
);
$neq = M('retail_store')->where($sMap)->save(array('state' => 1));
if ($neq) {
$mMap = array(
'merchantid' => $this->merchant_id,
'storeid' => array('in', $storeIds),
);
$delete = M('retail_manager')->where($mMap)->save(array('status' => 2)); //删除店长
$cMap = array(
'storeid' => array('in', $storeIds),
'status' => 1,
);
$delete = M('retail_cashier')->where($cMap)->save(array('status' => 2)); //删除收银员
$gMap = array(
'storeid' => array('in', $storeIds),
'status' => 1,
);
$delete = M('retail_guide')->where($gMap)->save(array('status' => 2)); //删除导购员
}
if ($neq) {
$res['status'] = 1;
$res['msg'] = '操作成功';
//操作日志记录
$source = 0; //请求来源: 0pc系统 1小助手
$type = 3; //平台: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);
} else {
$where['state'] = 0;
$where['store_status'] = 1; //状态关闭的门店
$where['merchantid'] = $this->merchant_id; //商户id
$stores = M('retail_store')->field('id,storetag')->where($where)->select();
if (!$stores) {
echo '<h3 style="text-align: center;"> - - 暂无关闭门店 - - </h3>';
} else {
$this->assign('stores', json_encode($stores));
$this->display();
}
}
}
//达达配送
public function dadadelivery()
{
$merchant_id = $this->merchant_id;
$store_id = I('post.storeid');
if (!$store_id) {
$this->ajaxReturn(['status' => 0, 'msg' => '请指定门店']);
}
$DeliveryConfigModel = new RetailDeliveryConfigModel();
$developer = $DeliveryConfigModel->getFind();
if (!$developer) {
$this->ajaxReturn(['status' => 0, 'msg' => '请先联系合伙人完善达达开发者信息']);
}
//先找到商户号
$DaMerchantModel = new RetailDaMerchantModel();
$da_merchant = $DaMerchantModel->getFind(['merchantid' => $merchant_id]);
if (empty($da_merchant)) {
$this->ajaxReturn(['status' => 0, 'msg' => '请先在达达配送注册达达商户']);
}
//再判断门店资料是否齐全
$StoreModel = new RetailStoreModel();
$store = $StoreModel->getFind(['id' => $store_id, 'merchantid' => $this->merchant_id]);
if (($store['store_status'] == 1)) {
$this->ajaxReturn(['status' => 0, 'msg' => '该门店不存在请创建新门店']);
} else if ($store['dadastatus'] == 1) {
$this->ajaxReturn(['status' => 0, 'msg' => '该门店未开启达达配送']);
} else if (empty($store['storetag'])) {
$this->ajaxReturn(['status' => 0, 'msg' => '该门店未设置门店名称']);
} else if (empty($store['attribute'])) {
$this->ajaxReturn(['status' => 0, 'msg' => '该门店未设置门店类型']);
} else if (empty($store['city'])) {
$this->ajaxReturn(['status' => 0, 'msg' => '该门店未设置城市名称']);
} else if (empty($store['area'])) {
$this->ajaxReturn(['status' => 0, 'msg' => '该门店未设置城市区域']);
} else if (empty($store['address'])) {
$this->ajaxReturn(['status' => 0, 'msg' => '该门店未设置门店地址']);
} else if (empty($store['longitude']) || empty($store['latitude'])) {
$this->ajaxReturn(['status' => 0, 'msg' => '该门店未设置门店经纬度']);
} else if (empty($store['origin_shop_id'])) {
$this->ajaxReturn(['status' => 0, 'msg' => '该门店未设置门店编码']);
}
$data = array(
'station_name' => $store['storetag'],
'origin_shop_id' => $store['origin_shop_id'],
'area_name' => $store['area'],
'station_address' => $store['address'],
'contact_name' => $da_merchant['contact_name'],
'city_name' => $store['city'],
'business' => intval($store['attribute']),
'lng' => floatval($store['longitude']),
'phone' => $da_merchant['contact_phone'],
'lat' => floatval($store['latitude']),
);
if (!empty($store['username'])) {
$data['username'] = $store['username'];
$data['password'] = $store['password'];
}
if ($store['synchronization'] == 2) {
$success = A('Retail/DadaCeshi')->updatestore($developer['app_key'], $developer['app_secret'], $da_merchant['resultid'], $data);
$success = json_decode($success, true);
if ($success['status'] == 'success') {
$res['status'] = 1;
$res['msg'] = '同步成功';
//操作日志记录
$source = 0; //请求来源: 0pc系统 1小助手
$type = 3; //平台: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'] = $success['msg'] . "失败原因:" . $success['result']['failedList'][0]['msg'];
}
} else {
$success = A('Retail/DadaCeshi')->establishstore($developer['app_key'], $developer['app_secret'], $da_merchant['resultid'], array($data));
$success = json_decode($success, true);
if ($success['status'] == 'success') {
$save = M('retail_store')->where(array('id' => $store_id))->save(array('synchronization' => 2));
if ($save) {
$res['status'] = 1;
$res['msg'] = '同步成功';
//操作日志记录
$source = 0; //请求来源: 0pc系统 1小助手
$type = 3; //平台:1合伙人端 2代理商端 3商户端 4门店端
$request_data = json_encode($_POST); //请求参数 json数据
$desc = '门店信息同步到达达配送'; //操作行为描述
action_log($source, $type, $request_data, $desc);
//end
} else {
$res['status'] = 1;
$res['msg'] = '同步成功,后台数据更新失败';
}
} else {
$res['status'] = 0;
$res['msg'] = $success['msg'] . "失败原因:" . $success['result']['failedList'][0]['msg'];
}
}
$this->ajaxReturn($res);
}
// 主店分店 加载模板
public function store_type_set()
{
$store_id = I('post.id');
$merchant_id = $this->merchant_id;
$StoreModel = new RetailStoreModel();
if (IS_POST) {
if (empty($store_id)) {
$res['status'] = 0;
$res['msg'] = '必须设置一个门店为主店';
$this->ajaxReturn($res);
}
$store = $StoreModel->getFind(array('id' => $store_id, 'merchantid' => $merchant_id, 'store_type' => 0, 'state' => 0));
if (empty($store)) {
// 修改旧主店
$find_old = $StoreModel->getFind(array('merchantid' => $merchant_id, 'store_type' => 0, 'state' => 0));
if (!empty($find_old)) {
$save_old = $StoreModel->updateOrder(array('id' => $find_old['id']), array('store_type' => 1));
if (!empty($save_old)) {
$save_new = $StoreModel->updateOrder(array('id' => $store_id, 'merchantid' => $merchant_id, 'store_type' => 1, 'state' => 0), array('store_type' => 0));
if (!empty($save_new)) {
$res['status'] = 1;
$res['msg'] = '设置成功';
//操作日志记录
$source = 0; //请求来源: 0pc系统 1小助手
$type = 3; //平台: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'] = '设置失败,请重新提交';
}
} else {
$res['status'] = 0;
$res['msg'] = '设置失败,请重新提交';
}
} else {
$save_new = $StoreModel->updateOrder(array('id' => $store_id, 'merchantid' => $merchant_id, 'store_type' => 1, 'state' => 0), array('store_type' => 0));
if (!empty($save_new)) {
$res['status'] = 1;
$res['msg'] = '设置成功';
//操作日志记录
$source = 0; //请求来源: 0pc系统 1小助手
$type = 3; //平台: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'] = '设置失败,请重新提交';
}
}
} else {
$res['status'] = 0;
$res['msg'] = '该门店已是主店,无需设置';
}
$this->ajaxReturn($res);
} else {
$where['state'] = 0; //状态正常的门店
$where['store_status'] = 0; //状态正常的门店
$where['store_class'] = 1; //直营店->xc添加
$where['merchantid'] = $merchant_id; //商户id
$stores = M('retail_store')->field('id,storetag,store_type')->where($where)->select();
$stores = $stores ? $stores : array();
$this->assign('stores', json_encode($stores));
$store_id = $StoreModel->getFindField(array('merchantid' => $merchant_id, 'store_status' => 0, 'store_type' => 0), 'id');
$this->assign('store_id', $store_id);
$this->display();
}
}
/**
* 销售统计页面
*/
public function statistics()
{
$this->display();
}
/**
* 商户销售统计获取数据接口
*/
public function getStoreSaleDataList()
{
$Statistics = new Statistics();
$this->ajaxReturn($Statistics->getStoreSaleDataList([
'merchant_id' => $this->merchant_id,
'date' => I('post.date'),
'page' => I('post.page'),
'type' => 1,
]));
}
/**
* 生成小程序二维码
*/
public function qrcode()
{
$merchant_id = $this->merchant_id;
$store_id = I('post.store_id');
$stime = time();
$store_name = M('retail_store')->where(array('id' => $store_id))->getField('storetag'); //查询门店名称用来拼接下载二维码后的名称
$app_id = M('appinfo')->where(array('merchant_id' => $merchant_id))->getField('id'); //根据商户id查询该商户的授权小程序
if (empty($app_id)) {
$res['status'] = 0;
$res['msg'] = '请先去授权您的小程序再进行此操作';
$this->ajaxReturn($res);
}
$file_merchant = "./Uploads/Merchant";
if (!is_dir($file_merchant)) {
mkdir('./Uploads/Merchant', 0777);
}
$path = "./Uploads/Merchant/Xcx";
if (!is_dir($path)) { //创建目录
mkdir('./Uploads/Merchant/Xcx', 0777);
}
$file_name = $path . '/' . $stime . $merchant_id . $store_id . '.jpg';
if (is_file($file_name)) {
//没有文件微信接口调用下载文件
$urlpath = "/pages/store/store?store_id=" . $store_id;
$width = 430;
$post_data = '{"path":"' . $urlpath . '","width":' . $width . '}';
$access_token = get_authorizer_access_token($merchant_id);
$url = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" . $access_token;
$result = $this->api_notice_increment($url, $post_data);
$re['status'] = 1;
$re['pic_url'] = $path . '/' . $stime . $merchant_id . $store_id . '.jpg';
$re['pic_name'] = $store_name;
$this->ajaxReturn($re);
} else {
//没有文件微信接口调用下载文件
$urlpath = "pages/store/store?store_id=" . $store_id;
$width = 430;
$post_data = '{"path":"' . $urlpath . '","width":' . $width . '}';
$access_token = get_authorizer_access_tokens($merchant_id);
$url = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" . $access_token;
$result = $this->api_notice_increment($url, $post_data);
file_put_contents($file_name, $result);
$re['status'] = 1;
$re['pic_url'] = $path . '/' . $stime . $merchant_id . $store_id . '.jpg';
$re['pic_name'] = $store_name;
$this->ajaxReturn($re);
}
}
public function api_notice_increment($url, $data)
{
$ch = curl_init();
$header = "Accept-Charset: utf-8";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$tmpInfo = curl_exec($ch);
// var_dump($tmpInfo);
// exit;
if (curl_errno($ch)) {
return false;
} else {
// var_dump($tmpInfo);
return $tmpInfo;
}
}
/**
* 下载门店小程序二维码
*/
public function downloadImg()
{
$imgUrl = $_GET['url'];
$arr = pathinfo($imgUrl);
$imgName = $_GET['pic_name'] . '.' . $arr['extension'];
if (!file_exists($imgUrl)) { //判断文件是否存在
echo "文件不存在";
exit();
}
$file = fopen($imgUrl, "r");
Header("Content-type:application/octet-stream");
header("Accept-Ranges: bytes");
header("Accept-Length: " . filesize($imgUrl));
header("Content-Disposition: attachment; filename=" . $imgName);
echo fread($file, filesize($imgUrl));
fclose($file);
}
/**
* 跳转到门店
*/
public function toStore()
{
$store_id = I('post.store_id');
if (empty($store_id)) {
$res['status'] = 0;
$res['msg'] = '请求有误';
$this->ajaxReturn($res);
}
$StoreModel = new RetailStoreModel();
$map = array(
$StoreModel::MERCHANT_ID => $this->merchant_id,
$StoreModel::STORE_STATUS => 0,
$StoreModel::STATE => 0
);
$store = $StoreModel->getFind($map);
if (empty($store)) {
$res['status'] = 0;
$res['msg'] = '您跳转的门店不存在';
} else {
session('storeid', $store_id);
session('store_id', $store_id);
$platform_type = $this->role_info['platform_type'] ? $this->role_info['platform_type'] : 1;
$supplier_type = $StoreModel->getFindField(array('id' => $store_id), "supplier_type");
$info = session("ls_userinfo");
$info['supplier_type'] = $supplier_type;
$info['platform_type'] = $platform_type;
session("ls_userinfo", $info);
$res['status'] = 1;
$res['msg'] = '跳转成功';
}
$this->ajaxReturn($res);
}
/**
* 获取门店列表接口,仅获取ID和名称
*/
public function getStoreLimitList()
{
$Store = new Store();
$this->ajaxReturn($Store->getStoreLimitList([
'merchant_id' => $this->merchant_id,
'page' => I('post.page'),
'industry_id' => I('post.industry_id'),
'strict_industry' => I('post.strict_industry'),
'limit' => I('post.limit'),
'store_name' => I('post.store_name'),
'store_status' => I('post.store_status'),
]));
}
/**
* 获取门店所有信息
*/
public function getStoreInfo()
{
$id = I('post.id');
if (!$id) {
$this->ajaxReturn(['status' => 0, 'msg' => '缺少必要参数']);
}
$RetailStoreModel = new RetailStoreModel();
$CitysModel = new CitysModel();
$ImageGalleryModel = new ImageGalleryModel();
$FranchiseeModel = new RetailFranchiseeModel();
$field = [
'id',
'industry_id',
'store_class',
'supplier_type',
'storetag',
'shopimg_id',
'province',
'city',
'area',
'address',
'longitude',
'latitude',
'detail_address',
'dadastatus',
'attribute',
'origin_shop_id',
'username',
'password',
'third_code'
];
$store = $RetailStoreModel->getFind(['id' => $id, 'merchantid' => $this->merchant_id], $field);
if (empty($store)) {
$this->ajaxReturn(['status' => 0, 'msg' => '请求有误']);
}
$store['industry_id'] = empty($store['industry_id']) ? '' : $store['industry_id'];
$store['longitude'] = $store['longitude'] * 1;
$store['latitude'] = $store['latitude'] * 1;
if ($store['shopimg_id']) {
$store['shopimg_url'] = $ImageGalleryModel->getOneField(['id' => $store['shopimg_id']], 'path');
}
// 省市区id
if ($store['province']) {
$store['province_id'] = $CitysModel->getFindField(['city_name' => $store['province'], 'state' => 0, 'parentid' => 0], 'cityid');
} else {
$store['province_id'] = '';
}
if ($store['city']) {
$store['city_id'] = $CitysModel->getFindField(['city_name' => $store['city'], 'state' => 0, 'parentid' => $store['province_id']], 'cityid');
} else {
$store['city_id'] = '';
}
if ($store['area']) {
$store['area_id'] = $CitysModel->getFindField(['city_name' => $store['area'], 'state' => 0, 'parentid' => $store['city_id']], 'cityid');
} else {
$store['area_id'] = '';
}
if ($store['store_class'] == 2) {
$field = [
'clearing_form',
'account_number',
'opening_bank',
'name',
'type as period_radio',
'rate',
];
$franchisee = $FranchiseeModel->getFind(['store_id' => $id], $field);
if ($franchisee) {
$store = array_merge($store, $franchisee);
}
}
$result = [
'status' => 1,
'msg' => '获取数据成功',
'data' => $store,
];
$this->ajaxReturn($result);
}
/**
* 获取已使用门店数
*/
public function getUseStoreNum()
{
$StoreModel = new RetailStoreModel();
$MerchantModel = new RetailMerchantModel();
$merchant_id = $this->merchant_id;
// 门店已用数
$hasUseNum = $StoreModel->getCount(['merchantid' => $merchant_id, 'state' => 0]);
// 可创建门店数
$canAddNum = $MerchantModel->getFindField(['id' => $merchant_id], 'storenum');
// 剩余数量
$canUseNum = bcsub($canAddNum, $hasUseNum);
$this->ajaxReturn(
[
'status' => 1,
'msg' => '获取成功',
'data' => [
'canAddNum' => $canAddNum,
'canUseNum' => $canUseNum,
],
]
);
}
//串号搜索
public function serial_number()
{
$this->display();
}
//串号搜索
public function serial_number_search()
{
$data = I('post.');
$data['merchant_id'] = $this->merchant_id;
$SerialNumberClass = new SerialNumberGoods();
$result = $SerialNumberClass->serialPosition($data);
$this->ajaxReturn($result);
}
/**
* 获取腾讯地图API密钥
* @return void
*/
public function getTencentMapKey()
{
// 从 sms_config 表获取腾讯地图API密钥,与 getAddress 函数保持一致
$config = M('sms_config')->find();
$key = isset($config['tencent_key']) ? $config['tencent_key'] : '';
if (empty($key)) {
$this->ajaxReturn(array(
'status' => 0,
'key' => '',
'msg' => '腾讯地图API密钥未配置'
));
} else {
$this->ajaxReturn(array(
'status' => 1,
'key' => $key,
'msg' => '获取成功'
));
}
}
}