Browse Source

验证用户是否缴费

master
wanghongjun 1 year ago
parent
commit
d0e4cde42e
  1. 4
      app/controller/admin/InvoiceIssuance.php
  2. 52
      app/controller/api/InvoiceIssuance.php
  3. 46
      app/service/invoice/InvoiceIssuanceService.php
  4. 43
      app/validate/InvoiceIssuanceValidate.php
  5. 1
      route/apiRoute.php

4
app/controller/admin/InvoiceIssuance.php

@ -10,7 +10,7 @@ class InvoiceIssuance extends Base
{
/**
* 获取微信用户列表
* 获取发票申请列表
* @return Response
* @throws \think\db\exception\DbException
*/
@ -23,7 +23,7 @@ class InvoiceIssuance extends Base
$InvoiceIssuanceModel = new InvoiceIssuanceModel();
$InvoiceHead = new InvoiceHead();
$field = 'id,project_id,merge,pucode_id,expire_time,mobile,email,create_time,status,amount,invoice_head_id,cancel_time,issuance_time';
$field = 'id,project_id,merge,pucode,expire_time,mobile,email,create_time,status,amount,invoice_head_id,cancel_time,issuance_time';
$listObj = $InvoiceIssuanceModel->order('create_time', 'DESC')
->field($field)

52
app/controller/api/InvoiceIssuance.php

@ -17,6 +17,7 @@ class InvoiceIssuance extends Base
{
/**
* 获取首页数据
* @return Response
*/
public function getList(): Response
@ -33,7 +34,11 @@ class InvoiceIssuance extends Base
}
}
public function getApplyData()
/**
* 获取申请前数据
* @return Response
*/
public function getApplyData(): Response
{
$wechat_user_id = $this->request->wechat_user_id;
@ -58,9 +63,31 @@ class InvoiceIssuance extends Base
]);
}
public function getInvoiceHead()
/**
* 验证是否缴费 并返回金额
* @return Response
*/
public function validateFeePay(): Response
{
try {
$param = $this->request->post();
validate(InvoiceIssuanceValidate::class)->scene('feePay')->check($param);
$res = InvoiceIssuanceService::validateFeePay($param['pucode'],$param['expire_time'],$param['project_id']);
return $this->buildSuccess($res);
} catch (\Exception $e) {
return $this->buildFailed(ReturnCode::NOT_EXISTS, $e->getMessage());
}
}
/**
* 获取发票抬头
* @return Response
*/
public function getInvoiceHead(): Response
{
try {
$wechat_user_id = $this->request->wechat_user_id;
@ -91,9 +118,12 @@ class InvoiceIssuance extends Base
}
}
public function add()
/**
* 新增、编辑
* @return Response
*/
public function add(): Response
{
try {
$params = $this->request->post();
@ -105,7 +135,7 @@ class InvoiceIssuance extends Base
$data = [
'wechat_user_id' => $wechat_user_id,
'project_id' => $params['project_id'],
'pucode_id' => $params['pucode_id'],
'pucode' => $params['pucode'],
];
$where = [['status', '>', 0], ['delete_time', '=', 0]];
@ -154,7 +184,11 @@ class InvoiceIssuance extends Base
}
}
public function delete()
/**
* 删除
* @return Response
*/
public function delete(): Response
{
try {
$params = $this->request->post();
@ -171,7 +205,11 @@ class InvoiceIssuance extends Base
}
}
public function getQrCode()
/**
* 获取二维码
* @return Response
*/
public function getQrCode(): Response
{
// 验证

46
app/service/invoice/InvoiceIssuanceService.php

@ -4,12 +4,14 @@ namespace app\service\invoice;
use app\model\InvoiceHead;
use app\model\InvoiceIssuance;
use app\service\webService\FeeService;
use Endroid\QrCode\Builder\Builder;
use Endroid\QrCode\Encoding\Encoding;
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh;
use Endroid\QrCode\Label\Alignment\LabelAlignmentCenter;
use Endroid\QrCode\Label\Font\NotoSans;
use Endroid\QrCode\Writer\PngWriter;
use fast\FuncException;
class InvoiceIssuanceService
{
@ -65,7 +67,49 @@ class InvoiceIssuanceService
return $data->toArray();
}
public static function getQrCode()
/**
*
* @param $pucode
* @param $expire_time
* @param $project_id
* @return string[]
* @throws FuncException
*/
public static function validateFeePay($pucode, $expire_time, $project_id): array
{
$expire_date = date('Ym', strtotime($expire_time));
$errorMsg = '该账单还未缴费,请先完成缴费。';
switch ($project_id) {
case 1:
$FeeService = new FeeService($pucode);
$param = [
'startCostYearMonth' => $expire_date,
'endCostYearMonth' => $expire_date,
'PaymentStatus' => 2,
];
$ComputeDetail = $FeeService->getComputeDetail($param);
if ($ComputeDetail['MsgID'] != 1) {
throw new FuncException($errorMsg);
}
return ['amount' => $ComputeDetail['WaterAmount']];
case 2:
throw new FuncException('尚未开发,请耐心等待!');
default:
throw new FuncException('尚未开发,请耐心等待!');
}
}
/**
* 获取二维码
* @return string
*/
public static function getQrCode(): string
{
//$ChinaTaxes = new ChinaTaxes();

43
app/validate/InvoiceIssuanceValidate.php

@ -9,36 +9,41 @@ class InvoiceIssuanceValidate extends Validate
/**
* 验证规则.
*/
protected $rule = [
'project_id|开票项目' => 'require|number|in:1,2,3',
'merge|合并开票' => 'require|number',
'pucode_id|用户编号' => 'require|number',
'expire_time|到期时间' => 'require',
'mobile|手机号' => 'require|mobile',
'email|邮箱' => 'require|email',
'amount|开票金额' => 'require',
'id|发票编号' => 'require|number'
];
protected $rule
= [
'project_id|开票项目' => 'require|number|in:1,2,3',
'merge|合并开票' => 'require|number',
'pucode|用户编号' => 'require|number',
'expire_time|到期时间' => 'require',
'mobile|手机号' => 'require|mobile',
'email|邮箱' => 'require|email',
'amount|开票金额' => 'require',
'id|发票编号' => 'require|number'
];
/**
* 提示消息.
*/
protected $message = [
];
protected $message
= [
];
/**
* 字段描述.
*/
protected $field = [
];
protected $field
= [
];
/**
* 验证场景.
*/
protected $scene = [
'add' => ['project_id', 'merge', 'pucode_id', 'expire_time', 'mobile', 'email', 'amount'],
'edit' => ['project_id', 'merge', 'pucode_id', 'expire_time', 'mobile', 'email', 'amount', 'id'],
'delete' => ['id']
];
protected $scene
= [
'add' => ['project_id', 'merge', 'pucode', 'expire_time', 'mobile', 'email', 'amount'],
'edit' => ['project_id', 'merge', 'pucode', 'expire_time', 'mobile', 'email', 'amount', 'id'],
'delete' => ['id'],
'feePay' => ['pucode', 'expire_time', 'project_id']
];
}

1
route/apiRoute.php

@ -13,6 +13,7 @@ Route::group('api', function() {
Route::rule('InvoiceIssuance/delete', 'api.InvoiceIssuance/delete', 'post')->middleware(\app\middleware\WechatAuth::class);
Route::rule('InvoiceIssuance/getList', 'api.InvoiceIssuance/getList', 'post')->middleware(\app\middleware\WechatAuth::class);
Route::rule('InvoiceIssuance/getQrCode', 'api.InvoiceIssuance/getQrCode', 'get')->middleware(\app\middleware\WechatAuth::class);
Route::rule('InvoiceIssuance/validateFeePay', 'api.InvoiceIssuance/validateFeePay', 'post')->middleware(\app\middleware\WechatAuth::class);
// 测试FeeService 接口
Route::rule('Test/index', 'api.Test/index', 'get');
//MISS路由定义

Loading…
Cancel
Save