...
|
...
|
@@ -394,46 +394,47 @@ class Pay extends Api |
|
|
->find();
|
|
|
//return_code 表示通信状态
|
|
|
if ($message['return_code'] === 'SUCCESS') {
|
|
|
|
|
|
if ($message['result_code'] === 'SUCCESS') {
|
|
|
//支付成功,更新订单状态
|
|
|
$toporder['status'] = 2;
|
|
|
$toporder['paytime'] = time();
|
|
|
$money = $data['money'];
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
//判断用户充值金额是否大于等于8000
|
|
|
if($data['money']>=8000){
|
|
|
//大于等于的情况
|
|
|
$arr = Db::name('user')->where('id',$data['user_id'])->find();
|
|
|
//判断用户是否已经是会员了
|
|
|
if($arr['is_vip'] == 1){
|
|
|
//已经是会员
|
|
|
$list['money'] = $arr['money'] + $money;
|
|
|
Db::name('user')->where('id',$data['user_id'])->update(['money'=>$list['money']]);
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
}else{
|
|
|
//不是会员
|
|
|
if($data['status'] == 1) {
|
|
|
//支付成功,更新订单状态
|
|
|
$toporder['status'] = 2;
|
|
|
$toporder['paytime'] = time();
|
|
|
$money = $data['money'];
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
//判断用户充值金额是否大于等于8000
|
|
|
if ($data['money'] >= 8000) {
|
|
|
//大于等于的情况
|
|
|
$arr = Db::name('user')->where('id', $data['user_id'])->find();
|
|
|
//判断用户是否已经是会员了
|
|
|
if ($arr['is_vip'] == 1) {
|
|
|
//已经是会员
|
|
|
$list['money'] = $arr['money'] + $money;
|
|
|
Db::name('user')->where('id', $data['user_id'])->update(['money' => $list['money']]);
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
} else {
|
|
|
//不是会员
|
|
|
$list['money'] = $arr['money'] + $money;
|
|
|
$list['is_vip'] = 1;
|
|
|
Db::name('user')->where('id', $data['user_id'])->update($list);
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
}
|
|
|
} else {
|
|
|
//小于8000的情况
|
|
|
$arr = Db::name('user')->where('id', $data['user_id'])->find();
|
|
|
$list['money'] = $arr['money'] + $money;
|
|
|
$list['is_vip'] = 1;
|
|
|
Db::name('user')->where('id',$data['user_id'])->update($list);
|
|
|
Db::name('user')->where('id', $data['user_id'])->update(['money' => $list['money']]);
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
}
|
|
|
}else{
|
|
|
//小于8000的情况
|
|
|
$arr = Db::name('user')->where('id',$data['user_id'])->find();
|
|
|
$list['money'] = $arr['money'] + $money;
|
|
|
Db::name('user')->where('id',$data['user_id'])->update(['money'=>$list['money']]);
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
dump($e->getMessage());
|
|
|
// 回滚事务
|
|
|
Db::rollback();
|
|
|
}
|
|
|
} catch (\Exception $e) {
|
|
|
dump($e->getMessage());
|
|
|
// 回滚事务
|
|
|
Db::rollback();
|
|
|
}
|
|
|
}else{
|
|
|
$toporder['status'] = 1;
|
...
|
...
|
@@ -443,7 +444,6 @@ class Pay extends Api |
|
|
}else{
|
|
|
return $fail('通信失败,请稍后再通知我');
|
|
|
}
|
|
|
return true; // 返回处理完成
|
|
|
});
|
|
|
$response->send();
|
|
|
}
|
...
|
...
|
|