187 lines
5.7 KiB
PHP
187 lines
5.7 KiB
PHP
<?php
|
|
/**
|
|
* @copyright Copyright (c) 2021 勾股工作室
|
|
* @license https://opensource.org/licenses/Apache-2.0
|
|
* @link https://www.gougucms.com
|
|
*/
|
|
namespace app\admin\controller\supplychain;
|
|
|
|
use app\admin\BaseController;
|
|
use think\facade\Db;
|
|
use think\facade\View;
|
|
use app\admin\model\Merchant as MerchantModel; // 商户模型
|
|
use app\admin\model\StoreOrder as StoreOrderModel; // 商户订单模型
|
|
use app\admin\model\GeoCity; // 省市模型
|
|
use app\admin\model\GeoArea; // 区域模型
|
|
use app\admin\model\GeoStreet; // 街道模型
|
|
use app\admin\model\SupplyChain; // 供应链模型
|
|
use app\admin\model\SupplyChainLinkMerchant; // 供应链关联商户模型
|
|
use app\api\model\Area as AreaModel; // 市场区域模型
|
|
use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型
|
|
|
|
class Merchant extends BaseController
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->adminInfo = get_login_admin();
|
|
$this->category_id=354;
|
|
$this->url=[
|
|
'/admin/supplychain.index/index?category_id='.$this->category_id,
|
|
'/admin/supplychain.index/add',
|
|
'/admin/supplychain.index/edit',
|
|
'/admin/supplychain.index/delete',
|
|
'/admin/supplychain.merchant/index',
|
|
'/admin/supplychain.merchant/bill',
|
|
];
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 供应链团队列表
|
|
*
|
|
*/
|
|
public function index()
|
|
{
|
|
if (request()->isAjax()) {
|
|
|
|
$params= get_params();
|
|
|
|
$where = [];
|
|
|
|
if (isset($params['keywords']) && !empty($params['keywords'])){
|
|
$where[]= ['name','like','%'.$params['keywords'].'%'];
|
|
}
|
|
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
|
|
$www['admin_id'] = $this->adminInfo['id'];
|
|
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
|
|
if ($user_address){
|
|
if($user_address['auth_range'] == 1){
|
|
$where[] = ['village_id','=',$user_address['village_id']];
|
|
}elseif ($user_address['auth_range'] == 2){
|
|
$where[] = ['street_id','=',$user_address['street_id']];
|
|
}elseif ($user_address['auth_range'] == 3){
|
|
$where[] = ['area_id','=',$user_address['area_id']];
|
|
}else{
|
|
$where[] = ['village_id','=',$user_address['village_id']];
|
|
}
|
|
}else{
|
|
$where[] = ['village_id','=',''];
|
|
}
|
|
}
|
|
|
|
$total = SupplyChainLinkMerchant::where($where)->count();
|
|
|
|
$list = SupplyChainLinkMerchant::with(['supplyChain', 'merchant'])->order('id desc')->select();
|
|
|
|
View::assign('url', $this->url);
|
|
View::assign('list', $list);
|
|
|
|
$result = ['total' => $total, 'data' => $list];
|
|
|
|
return table_assign(0, '', $result);
|
|
|
|
}else{
|
|
|
|
$total = SupplyChainLinkMerchant::count();
|
|
$list = SupplyChainLinkMerchant::with(['merchant', 'supplyChain'])->select();
|
|
|
|
View::assign('url', $this->url);
|
|
View::assign('list', $list);
|
|
|
|
$result = ['total' => $total, 'data' => $list];
|
|
return view();
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 交易订单
|
|
*
|
|
*/
|
|
public function bill()
|
|
{
|
|
if (request()->isAjax()) {
|
|
|
|
$params= get_params();
|
|
|
|
$where = [];
|
|
|
|
if (isset($params['keywords']) && !empty($params['keywords'])){
|
|
$where[]= ['name','like','%'.$params['keywords'].'%'];
|
|
}
|
|
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
|
|
$www['admin_id'] = $this->adminInfo['id'];
|
|
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
|
|
if ($user_address){
|
|
if($user_address['auth_range'] == 1){
|
|
$where[] = ['village_id','=',$user_address['village_id']];
|
|
}elseif ($user_address['auth_range'] == 2){
|
|
$where[] = ['street_id','=',$user_address['street_id']];
|
|
}elseif ($user_address['auth_range'] == 3){
|
|
$where[] = ['area_id','=',$user_address['area_id']];
|
|
}else{
|
|
$where[] = ['village_id','=',$user_address['village_id']];
|
|
}
|
|
}else{
|
|
$where[] = ['village_id','=',''];
|
|
}
|
|
}
|
|
|
|
$total = StoreOrderModel::where($where)->count();
|
|
|
|
$list = StoreOrderModel::with(['merchant'])->order('order_id desc')->select();
|
|
|
|
View::assign('url', $this->url);
|
|
View::assign('list', $list);
|
|
|
|
$result = ['total' => $total, 'data' => $list];
|
|
|
|
return table_assign(0, '', $result);
|
|
|
|
}else{
|
|
|
|
$total = StoreOrderModel::count();
|
|
$list = StoreOrderModel::with(['merchant', 'user'])
|
|
->where('source', 1) // 只读取来源为供应链小组的订单
|
|
->select();
|
|
|
|
View::assign('url', $this->url);
|
|
View::assign('list', $list);
|
|
|
|
$result = ['total' => $total, 'data' => $list];
|
|
return view();
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 新增
|
|
*
|
|
*/
|
|
public function add()
|
|
{
|
|
return view();
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 编辑
|
|
*
|
|
*/
|
|
public function edit()
|
|
{
|
|
return view();
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 删除
|
|
*
|
|
*/
|
|
public function delete()
|
|
{
|
|
return view();
|
|
}
|
|
|
|
} |