132 lines
4.7 KiB
PHP
132 lines
4.7 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
namespace addon\saasagent\shop\controller;
|
|
use addon\aliapp\model\CloudPay;
|
|
use addon\saasagent\model\PayShop;
|
|
use addon\saasagent\model\AlipayCategory;
|
|
use think\facade\Db;
|
|
use app\model\system\Address as AddressModel;
|
|
class Alipay extends SaasBsae
|
|
{
|
|
|
|
|
|
public function list()
|
|
{
|
|
if (request()->isAjax()) {
|
|
$page = input('page', 1);
|
|
$pay = new PayShop();
|
|
$condition = [
|
|
['a.ag_site_id', '=', $this->site_id],
|
|
['a.is_zmpay', '=', 1],
|
|
];
|
|
$search_text = input('search_text', '');
|
|
if ($search_text) {
|
|
$condition[] = ['a.merchant_name|a.contacts_name|a.contacts_phone', 'like', '%' . $search_text . '%'];
|
|
}
|
|
$res = $pay->getPageList($condition, $page);
|
|
return $res;
|
|
}
|
|
$this->forthMenu();
|
|
return $this->fetch('alipay/list');
|
|
}
|
|
|
|
|
|
/***
|
|
* 添加芝麻商户
|
|
* @return mixed
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function add()
|
|
{
|
|
$payShop = new PayShop();
|
|
$shop_id = input('shop_id', 0);
|
|
if (request()->isAjax()) {
|
|
$data = request()->post();
|
|
$settleAccountList = [];
|
|
if (isset($data['settleAccountList'])) {
|
|
$user = Db::name('website')
|
|
->where('id', 'in', $data['settleAccountList'])
|
|
->column('id,alipay_account,web_contacts,web_phone,role_ids', 'id');
|
|
$web_ids = $data['settleAccountList'];
|
|
foreach ($user as $key => $item) {
|
|
$role_ids = explode(',', $item['role_ids']);
|
|
$rate = Db::name('agent_level')->where('level_id', 'in', $role_ids)->value('sum(rate)');
|
|
if ($rate && $item['alipay_account']) {
|
|
$settleAccountList[$key]['settleAccount'] = $item['alipay_account'];
|
|
$settleAccountList[$key]['separateLedgerRate'] = $rate;
|
|
$settleAccountList[$key]['payeeRealName'] = $item['web_contacts'];
|
|
}
|
|
}
|
|
$data['website_ids'] = $web_ids;
|
|
unset($data['settleAccountList']);
|
|
}
|
|
$pay = new CloudPay();
|
|
$res = $pay->upAlipayUser($data, $settleAccountList);
|
|
$updata = [
|
|
'zmalipay_value' => $data
|
|
];
|
|
if ($res['code'] == '10000') {
|
|
$updata['is_zmpay'] = 1;
|
|
}
|
|
$Info = $payShop->where('shop_id', $shop_id)->save($updata);
|
|
return $res;
|
|
}
|
|
if ($shop_id) {
|
|
$where = [
|
|
'a.shop_id' => $shop_id,
|
|
'u.app_type' => 'aliapp',
|
|
];
|
|
$regInfo = $payShop
|
|
->where($where)
|
|
->alias('a')
|
|
->field('a.*,u.appid')
|
|
->join('uni_account u', 'a.site_id=u.site_id', 'left')
|
|
->find();
|
|
if(empty($regInfo)){
|
|
$this->error('请绑定小程序');
|
|
}
|
|
$agentUser = Db::name('website')->where('website_pid', '=', $this->site_id)->field('id,alipay_account,web_contacts,web_phone')->select();
|
|
$payInfo = $regInfo['alipay_value'];
|
|
$zmalipay_value = $regInfo['zmalipay_value'];
|
|
$this->assign('zmalipay', $zmalipay_value);
|
|
$this->assign('shop_id', $shop_id);
|
|
$this->assign('info', $regInfo);
|
|
$this->assign('payInfo', $payInfo);
|
|
$this->assign('userList', $agentUser);
|
|
} else {
|
|
$this->error('直通商户无效');
|
|
}
|
|
return $this->fetch('alipay/add_user');
|
|
}
|
|
|
|
|
|
public function edit()
|
|
{
|
|
if (request()->isAjax()) {
|
|
|
|
|
|
}
|
|
return $this->fetch('alipay/edit_user');
|
|
}
|
|
|
|
public function getalicategory()
|
|
{
|
|
$AlipayCategory = new AlipayCategory();
|
|
$name = input('name');
|
|
$res = $AlipayCategory->getCategory($name);
|
|
return $res;
|
|
}
|
|
|
|
} |