253 lines
9.9 KiB
PHP
253 lines
9.9 KiB
PHP
<?php
|
|
|
|
namespace addon\saas\shop\controller;
|
|
|
|
use addon\ali1688\model\Template as TemplateModel;
|
|
use addon\saas\model\Config as ConfigModel;
|
|
use app\model\system\Address as AddressModel;
|
|
use addon\supply\model\Supplier;
|
|
use addon\supply\model\SupplyApply;
|
|
use app\model\system\SiteGroup;
|
|
use app\model\system\User;
|
|
|
|
class Supply extends SaasBase
|
|
{
|
|
public function lists()
|
|
{
|
|
if (request()->isAjax()) {
|
|
$Supplier = new Supplier();
|
|
$page = input('page', 1);
|
|
$page_size = input('page_size', PAGE_LIST_ROWS);
|
|
$search_text = input('search_text', '');
|
|
$status = input('status', '');
|
|
$start_time = input("start_time", '');
|
|
$end_time = input("end_time", '');
|
|
$condition = [
|
|
['ag_site_id', '=', $this->site_id]
|
|
];
|
|
if ($search_text != '') {
|
|
$condition[] = ['title', 'like', '%' . $search_text . '%'];
|
|
}
|
|
if ($status != '') {
|
|
$condition[] = ['status', '=', $status];
|
|
}
|
|
if (!empty($start_time) && empty($end_time)) {
|
|
$condition[] = ['expire_time', '>=', strtotime($start_time)];
|
|
} elseif (empty($start_time) && !empty($end_time)) {
|
|
$condition[] = ["expire_time", "<=", strtotime($end_time)];
|
|
} elseif (!empty($start_time) && !empty($end_time)) {
|
|
$condition[] = ["expire_time", ">=", strtotime($start_time)];
|
|
$condition[] = ["expire_time", "<=", strtotime($end_time)];
|
|
}
|
|
$res = $Supplier->getSupplierPageList($condition, $page, $page_size);
|
|
return $res;
|
|
}
|
|
$this->forthMenu();
|
|
return $this->fetch("supply/lists");
|
|
}
|
|
|
|
/***
|
|
* 添加供应商
|
|
* @return array|mixed
|
|
*/
|
|
public function addSupply()
|
|
{
|
|
if (request()->isAjax()) {
|
|
$post = request()->post();
|
|
$supplier = new Supplier();
|
|
$data = array(
|
|
"app_module" => 'supply',
|
|
"username" => input('username', ''),
|
|
"title" => input("supplier_name", ''),
|
|
"fee_commission" => input("fee_commission", 0),
|
|
'supplier_address' => input("full_address", ''),//公司完整地址
|
|
'supplier_phone' => input("contacts_mobile", ''),//公司完整地址
|
|
"manage_id" => $post['manage_id'] ?? 0,
|
|
"manage_name" => $post['manage_name'] ?? '',
|
|
"year" => 1,
|
|
"ag_site_id" => $this->site_id,
|
|
'province_id' => input('province_id', 0),//所在省份
|
|
'city_id' => input('city_id', 0),//所在城市
|
|
'district_id' => input('district_id', 0),//所在地区
|
|
'address' => input('address'), //具体地址
|
|
'full_address' => input('full_address'), //具体地址
|
|
);
|
|
$user_info = [
|
|
'username' => input('username', ''),
|
|
'password' => data_md5(input('password', '')),
|
|
];
|
|
$cert_data = [
|
|
'company_province_id' => input("province_id", ''),//公司所在市
|
|
'company_city_id' => input("city_id", ''),//公司所在市
|
|
'company_district_id' => input("district_id", ''),//公司所在区/县
|
|
'company_address' => input("address", ''),//公司地址
|
|
'company_full_address' => input("full_address", ''),//公司完整地址
|
|
'contacts_name' => input("contacts_name", ''),//联系人姓名
|
|
'contacts_mobile' => input("contacts_mobile", ''),//联系人手机
|
|
];
|
|
$result = $supplier->addSupplier($data, $cert_data, $user_info);
|
|
return $result;
|
|
}
|
|
//查询省级数据列表
|
|
$address_model = new AddressModel();
|
|
$list = $address_model->getAreaList([["pid", "=", 0], ["level", "=", 1]]);
|
|
$this->assign("province_list", $list["data"]);
|
|
return $this->fetch("supply/addSupply");
|
|
}
|
|
|
|
/***
|
|
* 编辑供应
|
|
* @return mixed
|
|
*/
|
|
public function editSupply()
|
|
{
|
|
$shop_model = new \app\model\system\Site();
|
|
$supplier = new Supplier();
|
|
$supplier_id = input("supplier_id", 0);
|
|
if (request()->isAjax()) {
|
|
$condition=[
|
|
['supplier_id', '=', $supplier_id]
|
|
];
|
|
$data=[
|
|
"fee_commission" => input("fee_commission", 0),
|
|
'supplier_address' => input("full_address", ''),//公司完整地址
|
|
'supplier_phone' => input("contacts_mobile", ''),//公司完整地址
|
|
"manage_id" => $post['manage_id'] ?? 0,
|
|
"manage_name" => $post['manage_name'] ?? '',
|
|
'province_id' => input('province_id', 0),//所在省份
|
|
'city_id' => input('city_id', 0),//所在城市
|
|
'district_id' => input('district_id', 0),//所在地区
|
|
'address' => input('address'), //具体地址
|
|
'full_address' => input('full_address'), //具体地址
|
|
];
|
|
$site_data=[
|
|
'contacts_name'=>input("contacts_name", ""),
|
|
'contacts_mobile'=>input("contacts_mobile", ""),
|
|
];
|
|
$result = $supplier->editSupplier($condition, $data,$site_data);
|
|
return $result;
|
|
}
|
|
//查询省级数据列表
|
|
$where=[
|
|
'supplier_id'=>$supplier_id
|
|
];
|
|
$supInfo=$supplier->getSupplierInfo($where)['data'];
|
|
$shop_info = $shop_model->getSiteInfo(['site_id' => $supInfo['supplier_site_id']], '*')['data'];
|
|
$address_model = new AddressModel();
|
|
$list = $address_model->getAreaList([["pid", "=", 0], ["level", "=", 1]]);
|
|
$this->assign("province_list", $list["data"]);
|
|
$this->assign("userinfo", $shop_info);
|
|
$this->assign("supInfo", $supInfo);
|
|
$this->assign("supplier_id", $supplier_id);
|
|
return $this->fetch("supply/editSupply");
|
|
}
|
|
|
|
/***
|
|
* 供应商入驻申请
|
|
* @return mixed
|
|
*/
|
|
public function applylists()
|
|
{
|
|
if(request()->isAjax()){
|
|
|
|
$Supplier = new SupplyApply();
|
|
$page = input('page', 1);
|
|
$page_size = input('page_size', PAGE_LIST_ROWS);
|
|
$search_text = input('search_text', '');
|
|
$status = input('status', '');
|
|
$start_time = input("start_time", '');
|
|
$end_time = input("end_time", '');
|
|
$condition = [
|
|
['ag_site_id', '=', $this->site_id]
|
|
];
|
|
if ($search_text != '') {
|
|
$condition[] = ['title', 'like', '%' . $search_text . '%'];
|
|
}
|
|
if ($status != '') {
|
|
$condition[] = ['status', '=', $status];
|
|
}
|
|
// if (!empty($start_time) && empty($end_time)) {
|
|
// $condition[] = ['expire_time', '>=', strtotime($start_time)];
|
|
// } elseif (empty($start_time) && !empty($end_time)) {
|
|
// $condition[] = ["expire_time", "<=", strtotime($end_time)];
|
|
// } elseif (!empty($start_time) && !empty($end_time)) {
|
|
// $condition[] = ["expire_time", ">=", strtotime($start_time)];
|
|
// $condition[] = ["expire_time", "<=", strtotime($end_time)];
|
|
// }
|
|
$res = $Supplier->getApplyPageList($condition, $page, $page_size);
|
|
return $res;
|
|
}
|
|
$this->forthMenu();
|
|
return $this->fetch("supply/apply_lists");
|
|
}
|
|
|
|
|
|
/***
|
|
* 供应商配置
|
|
* @return mixed
|
|
*/
|
|
public function config()
|
|
{
|
|
$model = new ConfigModel();
|
|
if (request()->isAjax()) {
|
|
$data = request()->post();
|
|
$res = $model->setSupplierConfig($data, $this->site_id);
|
|
return $res;
|
|
}
|
|
$basics = $model->getSupplierConfig($this->site_id);
|
|
$supplierInfo=[];
|
|
if($basics['data']['value']['supplier_id'] > 0){
|
|
$supplier = new Supplier();
|
|
$condition = array(
|
|
['supplier_id', '=', $basics['data']['value']['supplier_id']],
|
|
);
|
|
$supplierInfo = $supplier->getSupplierInfo($condition)['data'];
|
|
}
|
|
$template_list = (new TemplateModel($this->site_id))->getTemplateList(['site_id' => $this->site_id]);
|
|
$upload_config_model = new \app\model\web\Config();
|
|
$upload_config_result = $upload_config_model->getDefaultImg($this->site_id, $this->app_module)['data']['value'];
|
|
$this->assign("supplier", $supplierInfo);
|
|
$this->assign('template_list', $template_list['data']['list']);
|
|
$this->assign("default_headimg", $upload_config_result['head']);
|
|
$this->assign("basics_info", $basics['data']['value']);
|
|
$this->forthMenu();
|
|
return $this->fetch('supply/supply');
|
|
}
|
|
|
|
|
|
public function searchSupply()
|
|
{
|
|
$supplier = new Supplier();
|
|
$search_text = input('search_text', '');
|
|
$condition = array(
|
|
['ag_site_id', '=', $this->site_id],
|
|
['title', 'like', '%' . $search_text . '%']
|
|
);
|
|
$res = $supplier->getSupplierInfo($condition);
|
|
return $res;
|
|
}
|
|
|
|
|
|
public function remarks(){
|
|
if (request()->isAjax()) {
|
|
$data = request()->post();
|
|
$supplier = new Supplier();
|
|
$res = $supplier->remarks($data,['supplier_id'=>input('supplier_id')]);
|
|
return $res;
|
|
}
|
|
}
|
|
|
|
/***
|
|
* 修改密码
|
|
* @param $site_id
|
|
*/
|
|
public function repass($site_id)
|
|
{
|
|
if (request()->isAjax() && $site_id) {
|
|
$password = trim(input('password', '123456'));
|
|
$shop_model = new User();
|
|
return $shop_model->modifyAdminUserPassword([['site_id', '=', $site_id], ['ag_site_id', '=', $this->site_id],['app_module', '=', 'supply']], $password);
|
|
}
|
|
}
|
|
}
|