152 lines
5.3 KiB
PHP
152 lines
5.3 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
namespace addon\saasagent\model;
|
|
use app\model\BaseModel;
|
|
use think\facade\Db;
|
|
use think\Model;
|
|
class PayShop extends Model
|
|
{
|
|
protected $autoWriteTimestamp = 'int';
|
|
protected $json = ['wechatpay_value','alipay_value','zmalipay_value'];
|
|
protected $jsonAssoc = true;
|
|
public function getStore() {}
|
|
/***
|
|
* 获取分页
|
|
* @param $condition
|
|
* @param int $page
|
|
* @param int $page_size
|
|
* @param string $field
|
|
* @param string $order
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function getPageList($condition, $page = 1, $page_size = PAGE_LIST_ROWS, $field = 'a.*,u.appid', $order = 'a.create_time desc')
|
|
{
|
|
$join=[
|
|
['uni_account u','a.site_id=u.site_id','left']
|
|
];
|
|
$res = model('pay_shop')->pageList($condition,$field,$order,$page,$page_size,'a',$join);
|
|
return success(0,'',$res);
|
|
}
|
|
/***
|
|
* 保存支付
|
|
* @param $data
|
|
* @param $payInfo
|
|
* @param $site_id
|
|
* @param $rate 费率
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function PaySave($data, $payInfo, $site_id,$member_id=0,$rate='0.6')
|
|
{
|
|
$merchant_name='';
|
|
if(isset($data['subject_info']['business_license_info']['merchant_name'])){
|
|
$merchant_name=$data['subject_info']['business_license_info']['merchant_name'];
|
|
}else if($data['subject_info']['certificate_info']['merchant_name']){
|
|
$merchant_name=$data['subject_info']['certificate_info']['merchant_name'];
|
|
}
|
|
$date = [
|
|
'merchant_name' =>$merchant_name,
|
|
'contacts_name' => $data['contact_info']['contact_name'],
|
|
'contacts_phone' => $data['contact_info']['mobile_phone'],
|
|
'site_id' => $site_id,
|
|
'ag_member_id' => $member_id,
|
|
'pay_type' => 'wechatpay',
|
|
'states' => 0,
|
|
'rate' => $rate,
|
|
'subject_type' => $data['subject_type'],
|
|
'wechatpay_value' => $payInfo,
|
|
'business_code' => $data['business_code'],
|
|
'isDrafts' => $data['isDrafts'],
|
|
'reg_money' => $data['reg_money'],
|
|
];
|
|
if($data['shop_id']>0){
|
|
$find=$this->where('shop_id',$data['shop_id'])->find();
|
|
}else{
|
|
$find=$this->where('business_code',$data['business_code'])->find();
|
|
}
|
|
if($find){
|
|
$find->save($date);
|
|
}else{
|
|
$this->save($date);
|
|
}
|
|
return success();
|
|
}
|
|
|
|
/***
|
|
* @param $data
|
|
* @param $payInfo
|
|
* @param $site_id
|
|
* @param int $member_id
|
|
* @param string $rate
|
|
* @return array
|
|
*/
|
|
public function AlipaySave($data, $payInfo, $ag_site_id,$member_id=0,$rate='0.6'){
|
|
$date = [
|
|
'merchant_name' =>$data['alias_name'],
|
|
'contacts_name' => $data['contact_infos']['name'],
|
|
'contacts_phone' => $data['contact_infos']['mobile'],
|
|
'site_id' => $data['bing_site_id'],
|
|
'ag_site_id' => $ag_site_id,
|
|
'ag_member_id' => $member_id,
|
|
'pay_type' => 'alipay',
|
|
'rate' => $rate,
|
|
'subject_type' => $data['subject_type'],
|
|
'alipay_value' => $payInfo,
|
|
'business_code' => $data['business_code'],
|
|
'isDrafts' => $data['isDrafts'],
|
|
'reg_money' => $data['reg_money'],
|
|
'apply_desc' => $data['apply_desc']??'',
|
|
'states' => $data['states']??1,
|
|
];
|
|
if($data['shop_id']>0){
|
|
$find=$this->where('shop_id',$data['shop_id'])->find();
|
|
}else{
|
|
$find=$this->where('business_code',$data['business_code'])->find();
|
|
}
|
|
if($find){
|
|
$find->save($date);
|
|
}else{
|
|
$this->save($date);
|
|
}
|
|
return success();
|
|
}
|
|
|
|
/***
|
|
* 扣除代理费用
|
|
* @param $site_id
|
|
* @param $reg_money
|
|
* @return array
|
|
*/
|
|
public function payAgent($site_id,$reg_money){
|
|
$agent_rate=model('website')->getValue(['site_id'=>$site_id],'agent_rate');
|
|
$money=$reg_money-($reg_money*$agent_rate/10);
|
|
model('website')->update(
|
|
[
|
|
'agent_arrears'=>Db::raw('agent_arrears -'.$money)
|
|
],
|
|
['site_id'=>$site_id]
|
|
);
|
|
model('agent_account_log')->add([
|
|
'site_id'=>$site_id,
|
|
'money'=>$money,
|
|
'type'=>'dec',
|
|
'action_name'=>'支付注册-'.$money,
|
|
]);
|
|
return success();
|
|
}
|
|
} |