55 lines
2.2 KiB
PHP
55 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
namespace addon\saas\event;
|
|
use think\facade\Db;
|
|
class SaasOrderBuy
|
|
{
|
|
/***
|
|
* 小程序注册成功扣款
|
|
* @param $param
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function handle($param)
|
|
{
|
|
if ($param) {
|
|
$where['from_type'] = 'aliapp';
|
|
$where['appid'] = $param['mini_app_id'];
|
|
$find = Db::name('agent_account')->where($where)->find();
|
|
if (!$find) {
|
|
$w = [
|
|
'app_type' => 'aliapp',
|
|
'appid' => $param['mini_app_id']
|
|
];
|
|
$regInfo = Db::name('applet_reg')->where($w)->order('id desc')->find();
|
|
Db::name('website')->where('site_id', '=', $regInfo['ag_site_id'])
|
|
->dec('agent_money', $regInfo['reg_fee'])
|
|
->update(); //记录扣款
|
|
$bill = [
|
|
'ag_site_id' => $regInfo['ag_site_id'],
|
|
'user_id' => $regInfo['user_id'],
|
|
'site_id' => $regInfo['site_id'],
|
|
'appid' => $param['mini_app_id'],
|
|
'account_data' => $regInfo['reg_fee'],
|
|
'from_type' => 'aliapp',
|
|
'type_name' => '支付宝小程序注册',
|
|
'create_time' => time(),
|
|
];//插入扣款流水
|
|
Db::name('agent_account')->insert($bill);
|
|
}
|
|
}
|
|
return success();
|
|
}
|
|
} |