admin/addon/saasagent/shop/controller/Agent.php

144 lines
5.6 KiB
PHP

<?php
namespace addon\saasagent\shop\controller;
use addon\aliapp\model\AliPaySubLedger;
use addon\saasagent\model\AgentLevel;
use addon\saasagent\model\OrderCreate;
use app\model\shop\Shop as ShopModel;
use app\model\system\Address as AddressModel;
use app\model\web\Config as ConfigModel;
use app\model\web\WebSite as WebsiteModel;
use think\facade\Cache;
use think\facade\Db;
class Agent extends SaasBsae{
/***
* 代理商列表
* @return array|mixed
*/
public function lists(){
if(request()->isAjax()) return (new WebsiteModel())->newGetWebsiteList();
$this->forthMenu();
$this->assign('site_id',$this->site_id);
return $this->fetch('agent/list');
}
/***
* 添加代理商
* @return array|mixed
*/
public function adduser(){
$website_model = new WebsiteModel();
if(request()->isAjax()){
if($this->site_id == 1){
$data = [
'title' => input('title',''),
'status' => 1,
'is_agent' => 1,
'is_apply' => 1,
'member_id' => input('member_id',0),
'agent_level_id' => input('agent_level_id',0),
'role_ids' => input('role_ids'),
'website_pid' => $this->site_id,
'logo' => input('logo',''),
'desc' => input('desc',''),
'keywords' => input('keywords',''),
'alipay_account' => input('alipay_account',''),
'web_contacts' => input('web_contacts',''),
'web_address' => input('web_address',''),
'web_qrcode' => input('web_qrcode',''),
'web_email' => input('web_email',''),
'web_phone' => input('web_phone',''),
'web_qq' => input('web_qq',''),
'web_weixin' => input('web_weixin',''),
'wap_status' => input('wap_status',''),
'wap_domain' => input('wap_domain',''),
'site_area_id' => input('site_area_id',''),
'site_area_name' => input('site_area_name',''),
'settlement_bank_account_name' => input('settlement_bank_account_name',''),
'settlement_bank_account_number' => input('settlement_bank_account_number',''),
'settlement_bank_name' => input('settlement_bank_name',''),
'settlement_bank_address' => input('settlement_bank_address',''),
];
if($data['role_ids']){
$data['role_ids'] = implode(',',$data['role_ids']);
}
$res = $website_model->addWebsite($data);
return $res;
}
else{
return error(-1,'您不是代理商');
}
}
$this->assign("default_headimg",'');
$level_agent = new AgentLevel();
$level_info = $level_agent->getLevelList(['site_id' => $this->site_id])['data'];
//查询省级数据列表
$address_model = new AddressModel();
$list = $address_model->getAreaList([["pid","=",0],["level","=",1]]);
$this->assign("apply_info",$this->agent_info);
$this->assign("level_agent",$level_info);
$this->assign("province_list",$list["data"]);
return $this->fetch('agent/add_agent');
}
/**
* 编辑代理商
*/
public function edituser()
{
$id = input('id');
$website_model = new WebsiteModel();
if (request()->isAjax()) {
if ($this->site_id) {
$data = [
'web_contacts' => input('web_contacts', ''),
'web_phone' => input('web_phone', ''),
'web_email' => input('web_email', ''),
'web_qq' => input('web_qq', ''),
'web_weixin' => input('web_weixin', ''),
'role_ids' => input('role_ids'),
];
if ($data['role_ids']) {
$data['role_ids'] = implode(',', $data['role_ids']);
}
$res = $website_model->setWebSite($data, ['id' => $id]);
return $res;
}
return error(-1, '你还不是代理商');
}
$agent_Info = $website_model->getWebSite(['id' => $id]);
$level_agent = new AgentLevel();
$level_info = $level_agent->getLevelList(['site_id' => $this->site_id])['data'];
$this->assign("apply_info", $agent_Info['data']);
$this->assign("level_agent", $level_info);
return $this->fetch('agent/edit_user');
}
/**
* Common: 删除合伙人
* Author: wu-hui
* Time: 2023/01/29 11:47
* @return array|void
*/
public function deluser(){
if (request()->isAjax()) {
$id = input('id');
return (new WebsiteModel())->delWebsiteinfo($id);
}
}
public function demo(){
//(new AliPaySubLedger(5))->settleConfirm(163);
//(new AliPaySubLedger(5))->orderSettle(184);
debug("结束");
}
}