这里我的转账是使用的事务,并没有使用队列
控制器
<?php
declare (strict_types = 1);
namespace app\week2\controller;
use app\BaseController;
use app\week2\model\Transfer_log;
use app\Week2\model\User;
use app\week2\model\Wxuser;
use think\facade\Db;
use think\Response;
class Financial extends BaseController
{
/**
* Notes:用户财务页面初始查询
*/
public function index()
{
// 接收id
$id = $this->request->id;
//根据id 查询用户信息
$oneData = Wxuser::where('id',$id)->find();
if ($oneData)
{
return Response::create(['code'=>200,'msg'=>'请求成功','data'=>$oneData],'json');
}else{
return Response::create(['error_code'=>500,'msg'=>'请求失败','data'=>''],'json');
}
}
/**
* Notes:转账记录生成
*/
public function create()
{
$params =$this->request->param();
$params['u_id'] = $this->request->id;
$userOne = Wxuser::where('id',$params['u_id'])->find();
$userTwo = Wxuser::where('phone',$params['phone'])->find();
//将接收到的值添加
Db::startTrans();
try {
//Wxuser::where('id',$params['u_id'])->sa