Db::startTrans();
try{
$order = Db::name('charge')->where('order_no', $data['out_trade_no'])->find();
if(!$order){
echo 'FAIL';
exit();
}
if($order['status']==){
echo 'FAIL';
exit();
}
DB::table('charge')->where('order_no', $data['out_trade_no'])->update(['status'=>1, 'update_time'=>time()
Db::table('user')->where('id', $order['user_id])->setInc('money', $order['money']);
$data = array(
'uid' => $order['user_id'],
'type' => 3,
'relation' => $order['id'],
'money' => $order['money'],
'info' => '会员充值' . $order['money'] . '元',
'create_time' => time(),
'create_ip' => request()->ip()
);
Db::name('wealthlog')->insert($data);
//提交事务
Db::commit();
echo 'SUCCESS';
} catch (Exception $e) {
//回滚事务
Db::rollback();
echo 'FAIL';
}
---------------------
版权声明:本文为CSDN博主「Wake_me_Up123」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wake_me_up123/article/details/82259557