Browse Source

申请开票接口优化 增加事务

master
wanghongjun 2 years ago
parent
commit
83f85e8054
  1. 4
      app/controller/api/InvoiceIssuance.php

4
app/controller/api/InvoiceIssuance.php

@ -7,6 +7,7 @@ use app\model\InvoiceIssuance as InvoiceIssuanceModel;
use app\util\ReturnCode;
use app\validate\InvoiceHeadValidate;
use app\validate\InvoiceIssuanceValidate;
use think\facade\Db;
class InvoiceIssuance extends Base
{
@ -41,6 +42,7 @@ class InvoiceIssuance extends Base
$data['mobile'] = $params['mobile'];
$data['email'] = $params['email'];
Db::startTrans();
//验证 、 新建抬头、获取抬头id
validate(InvoiceHeadValidate::class)->scene('type')->check($data);
validate(InvoiceHeadValidate::class)->scene('type'.$data['type'])->check($data);
@ -62,8 +64,10 @@ class InvoiceIssuance extends Base
}
}
Db::commit();
return $this->buildSuccess();
} catch (\Exception $e) {
Db::rollback();
return $this->buildFailed(ReturnCode::INVALID, $e->getMessage());
}
}

Loading…
Cancel
Save