完善提现功能:商城商户入驻和开通交易审批流
This commit is contained in:
parent
6883c63dc1
commit
074ce4a630
@ -4,6 +4,8 @@ namespace app\api\controller;
|
||||
|
||||
use app\api\lists\approve\ApproveLists;
|
||||
use app\common\model\Approve;
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
|
||||
class ApproveController extends BaseApiController
|
||||
@ -13,31 +15,71 @@ class ApproveController extends BaseApiController
|
||||
return $this->dataLists(new ApproveLists());
|
||||
}
|
||||
|
||||
public function approveType()
|
||||
{
|
||||
$list = Approve::where(['status' => 1])->field(['id,name'])->select()->toArray();
|
||||
$this->success('成功', $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 前台通用审批接口 审批后的业务逻辑,
|
||||
*/
|
||||
public function audit()
|
||||
{
|
||||
$params = $this->request->param(); // id check_status remark
|
||||
$approve = Approve::find($params['id']);
|
||||
if (!$approve) {
|
||||
$this->fail('数据不存在');
|
||||
try {
|
||||
$params = $this->request->param(); // id check_status remark
|
||||
$approve = Approve::find($params['id']);
|
||||
if (!$approve) {
|
||||
throw new Exception('数据不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
|
||||
// 拒绝通过
|
||||
if ($params['check_status'] == 3) {
|
||||
$this->refuse($approve, $params);
|
||||
}
|
||||
// 修改任务完成状态
|
||||
if ($params['check_status'] == 2) {
|
||||
$this->pass($approve);
|
||||
}
|
||||
|
||||
// 回调商城,通知审核状态
|
||||
if (in_array($approve['type'], [2, 3])) {
|
||||
$shopMerchantInfo = json_decode($approve['extend']);
|
||||
self::shopCallBack($approve, $shopMerchantInfo, $params);
|
||||
}
|
||||
Db::commit();
|
||||
return $this->fail('操作成功');
|
||||
} catch (Exception $exception) {
|
||||
Db::rollback();
|
||||
return $this->fail('审核失败');
|
||||
}
|
||||
Db::startTrans();
|
||||
// 拒绝通过
|
||||
}
|
||||
|
||||
private static function pass(Approve $approve)
|
||||
{
|
||||
$approve->check_status = 2;
|
||||
$approve->save();
|
||||
}
|
||||
|
||||
private static function refuse(Approve $approve, $params)
|
||||
{
|
||||
$approve->check_status = 3;
|
||||
$approve->remard = $params['remark'];
|
||||
$approve->save();
|
||||
}
|
||||
|
||||
private static function shopCallBack(Approve $approve, $shopMerchantInfo, $params)
|
||||
{
|
||||
$status = $params['check_status'] == 2? 1: 2;
|
||||
if ($params['check_status'] == 3) {
|
||||
$this->refuse($approve);
|
||||
$status = 2;
|
||||
}
|
||||
// 修改任务完成状态
|
||||
if ($params['check_status'] == 2) {
|
||||
$this->pass($approve);
|
||||
}
|
||||
}
|
||||
// 通知商城审批状态
|
||||
$requestResponse = HttpClient::create()->request('POST', env('url.shop_prefix') . '/api/merchant/syncStatus/'.$shopMerchantInfo['mer_intention_id'], [
|
||||
'body' => ['status' => $status, 'type' => $approve['type']]
|
||||
]);
|
||||
|
||||
private static function pass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static function refuse()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ use app\common\model\contract\ShopContract;
|
||||
|
||||
class CeshiController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['index', 'ceshi', 'ceshi1', 'ceshi2'];
|
||||
public array $notNeedLogin = ['index', 'ceshi', 'ceshi1', 'ceshi2', 'task_ceshi'];
|
||||
|
||||
public function index()
|
||||
{ //1201
|
||||
@ -122,4 +122,58 @@ class CeshiController extends BaseApiController
|
||||
app(JunziqianController::class)->organizationReapply($shopMerchantCertificationData);
|
||||
halt(111);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务刷新
|
||||
*/
|
||||
public function ceshi(){
|
||||
$time=strtotime(date('Y-m-d'));
|
||||
// $time=strtotime(date('Y-m-d'));
|
||||
// $tiem_end=$time+86399;where('cron_time','<',$time)->
|
||||
$plan_all=TaskScheduling::where('id',8)->with('company_info')->select()->toArray();
|
||||
foreach($plan_all as $k=>$v){
|
||||
$all=TaskTemplate::where('status',1)->where('task_scheduling',$v['id'])->limit(30)->select()->toArray();
|
||||
if($all){
|
||||
$plan_all[$k]['template']=$all;
|
||||
}else{
|
||||
unset($plan_all[$k]);
|
||||
}
|
||||
}
|
||||
$company_id=[];
|
||||
foreach($plan_all as $k=>$v){
|
||||
foreach($v['template'] as $kk=>$vv){
|
||||
TaskLogic::CronAdd($vv,$v);
|
||||
}
|
||||
$company_id[]=$v['company_id'];
|
||||
}
|
||||
Company::where('id','in',$company_id)->inc('day_count')->update();
|
||||
}
|
||||
|
||||
public function task_ceshi()
|
||||
{
|
||||
$time = strtotime(date('Y-m-d'));
|
||||
// $tiem_end=$time+86399;
|
||||
$plan_all = TaskScheduling::where('cron_time', '<', $time)->where('status', 1)->with('company_info')->select()->toArray();
|
||||
|
||||
$plan_ids = [];
|
||||
foreach ($plan_all as $k => $v) {
|
||||
$all = TaskTemplate::where('status', 1)->where('task_scheduling', $v['id'])->limit(30)->select()->toArray();
|
||||
$plan_ids[] = $v['id'];
|
||||
if ($all) {
|
||||
$plan_all[$k]['template'] = $all;
|
||||
} else {
|
||||
unset($plan_all[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
$company_id = [];
|
||||
foreach ($plan_all as $k => $v) {
|
||||
foreach ($v['template'] as $kk => $vv) {
|
||||
TaskLogic::CronAdd($vv,$v);
|
||||
}
|
||||
$company_id[] = $v['company_id'];
|
||||
}
|
||||
Company::where('id', 'in', $company_id)->inc('day_count')->update();
|
||||
TaskScheduling::where('id', 'in', $plan_ids)->update(['cron_time' => time()]);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user