149 lines
5.3 KiB
PHP
149 lines
5.3 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
namespace addon\saasagent\api\controller;
|
|
use app\api\controller\BaseApi;
|
|
use addon\saasagent\model\WeappletReg;
|
|
use addon\saasagent\validate\Reg;
|
|
use app\model\system\Cron;
|
|
use addon\saasagent\model\OrderCreate;
|
|
use app\model\web\WebSite as WebsiteModel;
|
|
use think\facade\Cache;
|
|
|
|
class Mincode extends BaseApi
|
|
{
|
|
/***
|
|
* 获取注册列表
|
|
* @return false|string
|
|
* @throws \think\db\exception\DbException
|
|
*/
|
|
public function list()
|
|
{
|
|
$token = $this->checkToken();
|
|
if ($token['code'] < 0) return $this->response($token);
|
|
$resModel = new WeappletReg();
|
|
$where = [
|
|
'agent_site_id' => $this->site_id,
|
|
'member_id' => $this->member_id,
|
|
];
|
|
$list = $resModel->where($where)->paginate()->each(function ($data) use ($resModel){
|
|
if($data->pay_status==0){
|
|
$data->status_text='待支付';
|
|
}else{
|
|
$data->status_text=$resModel->StatusText[$data->status];
|
|
}
|
|
return $data;
|
|
});
|
|
return $this->response($this->success($list));
|
|
}
|
|
|
|
/****
|
|
* 注册小程序
|
|
* @return false|string
|
|
*/
|
|
public function reg()
|
|
{
|
|
$token = $this->checkToken();
|
|
if ($token['code'] < 0) return $this->response($token);
|
|
$data = request()->post();
|
|
$validate = new Reg();
|
|
$website_model = new WebsiteModel();
|
|
$agnetInfo=$website_model->getWebSite(['member_id'=>$this->member_id])['data'];
|
|
if($agnetInfo['is_apply']!=1) return $this->response($this->error('您还不是代理商'));
|
|
if ($validate->scene()->check($data)) {
|
|
$data['site_id'] = 0;
|
|
$data['member_id'] = $this->member_id;
|
|
$data['agent_site_id'] = $this->site_id;
|
|
$data['pay_money'] = $agnetInfo['wxreg_rate'];
|
|
$data['app_type'] = 'weapp';
|
|
$resModel = new WeappletReg();
|
|
$where = [
|
|
['member_id', '=', $this->member_id],
|
|
['name', '=', $data['name']],
|
|
['status', '>', 0]
|
|
];
|
|
$resInfo = $resModel->where($where)->find();
|
|
if ($resInfo) {
|
|
$save = $resInfo->save($data);
|
|
} else {
|
|
$order_no = $resModel->createOrderNo($data['site_id'], $data['member_id']);
|
|
$data['order_no'] =$order_no;
|
|
$save = $resModel->save($data);
|
|
}
|
|
if ($save) {
|
|
$res = $this->success('录入完成');
|
|
} else {
|
|
$res = $this->error();
|
|
}
|
|
} else {
|
|
$res = $this->error($validate->getError());
|
|
}
|
|
return $this->response($res);
|
|
}
|
|
|
|
/***
|
|
* 编辑注册信息
|
|
* @return false|string
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function editinfo()
|
|
{
|
|
$token = $this->checkToken();
|
|
if ($token['code'] < 0) return $this->response($token);
|
|
$data = request()->post();
|
|
$validate = new Reg();
|
|
if ($validate->check($data)) {
|
|
$resModel = new WeappletReg();
|
|
$where = [
|
|
['id', '=', $data['id']],
|
|
['status', '>', 0]
|
|
];
|
|
$resInfo = $resModel->where($where)->find();
|
|
if ($resInfo && $resInfo['status']!=0) {
|
|
if ($resInfo->save($data)) {
|
|
if($resInfo['pay_status']==1){
|
|
$cron_model = new Cron();
|
|
$execute_time=time();
|
|
$cron_model->addCron(1, 0, "提交小程序申请", "ApplyAutoSubmit", $execute_time, $resInfo['id']);
|
|
}
|
|
$res = $this->success('编辑成功');
|
|
} else {
|
|
$res = $this->error('资料相同未更新');
|
|
}
|
|
} else {
|
|
$res = $this->error('信息不存在或已审核');
|
|
}
|
|
} else {
|
|
$res = $this->error($validate->getError());
|
|
}
|
|
return $this->response($res);
|
|
}
|
|
|
|
/***
|
|
* 获取注册信息
|
|
* @return false|string
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function info()
|
|
{
|
|
$token = $this->checkToken();
|
|
if ($token['code'] < 0) return $this->response($token);
|
|
$id=input('id',0);
|
|
$resModel = new WeappletReg();
|
|
$resInfo = $resModel->where('id',$id)->find();
|
|
return $this->response($this->success($resInfo));
|
|
}
|
|
} |