作者 郭盛
1 个管道 的构建 通过 耗费 1 秒

修改接口

... ... @@ -1859,41 +1859,46 @@ class User extends Api
$this->error(['code'=>2,'msg'=>'sql执行失败']);
}else{
$send = new Pay();
//修改用户余额以及订单状态 同时给用户发送短信
$update = $user['money'] - $param['total'];
Db::name('user')->where('id',$param['user_id'])->update(['money'=>$update]);
Db::name('iphone')->where('id',$data_order)->update(['status'=>2]);
//查询订单数据
$order_info = Db::name('iphone')->where('id',$data_order)->find();
//用户购买的什么素材
if(empty($order_info['video_id'])){
$pic = Db::name('pic')->where('id',$order_info['pic_id'])->find();
//发送短信,通知客户
$mobile = $user['mobile'];
$content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。图片标题:$pic[title],云盘地址:$pic[url]";
//发送短信
$send->sms($mobile,$content);
}elseif (empty($order_info['pic_id'])){
$video_id = unserialize($order_info['video_id']);
$video = Db::name('video')->where('id',$video_id['id'])->find();
//发送短信,通知客户
$mobile = $user['mobile'];
if($video_id['attr'] == 1){
$content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[two_url]";
}elseif ($video_id['attr'] == 2){
$content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[four_url]";
}elseif ($video_id['attr'] == 3){
$content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[eight_url]";
Db::startTrans();
try{
//修改用户余额以及订单状态 同时给用户发送短信
$update = $user['money'] - $param['total'];
Db::name('user')->where('id',$param['user_id'])->update(['money'=>$update]);
Db::name('iphone')->where('id',$data_order)->update(['status'=>2]);
//查询订单数据
$order_info = Db::name('iphone')->where('id',$data_order)->find();
//用户购买的什么素材
if(empty($order_info['video_id'])){
$pic = Db::name('pic')->where('id',$order_info['pic_id'])->find();
//发送短信,通知客户
$mobile = $user['mobile'];
$content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。图片标题:$pic[title],云盘地址:$pic[url]";
//发送短信
$send->sms($mobile,$content);
}elseif (empty($order_info['pic_id'])){
$video_id = unserialize($order_info['video_id']);
$video = Db::name('video')->where('id',$video_id['id'])->find();
//发送短信,通知客户
$mobile = $user['mobile'];
if($video_id['attr'] == 1){
$content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[two_url]";
}elseif ($video_id['attr'] == 2){
$content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[four_url]";
}elseif ($video_id['attr'] == 3){
$content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[eight_url]";
}
//发送短信
$send->sms($mobile,$content);
}
//发送短信
$send->sms($mobile,$content);
Db::commit();
$this->success('success');
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->error('error');
}
}
... ...