正在显示
1 个修改的文件
包含
38 行增加
和
33 行删除
@@ -1859,41 +1859,46 @@ class User extends Api | @@ -1859,41 +1859,46 @@ class User extends Api | ||
1859 | $this->error(['code'=>2,'msg'=>'sql执行失败']); | 1859 | $this->error(['code'=>2,'msg'=>'sql执行失败']); |
1860 | }else{ | 1860 | }else{ |
1861 | $send = new Pay(); | 1861 | $send = new Pay(); |
1862 | - | ||
1863 | - //修改用户余额以及订单状态 同时给用户发送短信 | ||
1864 | - $update = $user['money'] - $param['total']; | ||
1865 | - Db::name('user')->where('id',$param['user_id'])->update(['money'=>$update]); | ||
1866 | - Db::name('iphone')->where('id',$data_order)->update(['status'=>2]); | ||
1867 | - | ||
1868 | - | ||
1869 | - //查询订单数据 | ||
1870 | - $order_info = Db::name('iphone')->where('id',$data_order)->find(); | ||
1871 | - //用户购买的什么素材 | ||
1872 | - if(empty($order_info['video_id'])){ | ||
1873 | - $pic = Db::name('pic')->where('id',$order_info['pic_id'])->find(); | ||
1874 | - | ||
1875 | - //发送短信,通知客户 | ||
1876 | - $mobile = $user['mobile']; | ||
1877 | - $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。图片标题:$pic[title],云盘地址:$pic[url]"; | ||
1878 | - //发送短信 | ||
1879 | - | ||
1880 | - $send->sms($mobile,$content); | ||
1881 | - | ||
1882 | - }elseif (empty($order_info['pic_id'])){ | ||
1883 | - $video_id = unserialize($order_info['video_id']); | ||
1884 | - $video = Db::name('video')->where('id',$video_id['id'])->find(); | ||
1885 | - //发送短信,通知客户 | ||
1886 | - $mobile = $user['mobile']; | ||
1887 | - if($video_id['attr'] == 1){ | ||
1888 | - $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[two_url]"; | ||
1889 | - }elseif ($video_id['attr'] == 2){ | ||
1890 | - $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[four_url]"; | ||
1891 | - }elseif ($video_id['attr'] == 3){ | ||
1892 | - $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[eight_url]"; | 1862 | + Db::startTrans(); |
1863 | + try{ | ||
1864 | + //修改用户余额以及订单状态 同时给用户发送短信 | ||
1865 | + $update = $user['money'] - $param['total']; | ||
1866 | + Db::name('user')->where('id',$param['user_id'])->update(['money'=>$update]); | ||
1867 | + Db::name('iphone')->where('id',$data_order)->update(['status'=>2]); | ||
1868 | + //查询订单数据 | ||
1869 | + $order_info = Db::name('iphone')->where('id',$data_order)->find(); | ||
1870 | + //用户购买的什么素材 | ||
1871 | + if(empty($order_info['video_id'])){ | ||
1872 | + $pic = Db::name('pic')->where('id',$order_info['pic_id'])->find(); | ||
1873 | + | ||
1874 | + //发送短信,通知客户 | ||
1875 | + $mobile = $user['mobile']; | ||
1876 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。图片标题:$pic[title],云盘地址:$pic[url]"; | ||
1877 | + //发送短信 | ||
1878 | + | ||
1879 | + $send->sms($mobile,$content); | ||
1880 | + | ||
1881 | + }elseif (empty($order_info['pic_id'])){ | ||
1882 | + $video_id = unserialize($order_info['video_id']); | ||
1883 | + $video = Db::name('video')->where('id',$video_id['id'])->find(); | ||
1884 | + //发送短信,通知客户 | ||
1885 | + $mobile = $user['mobile']; | ||
1886 | + if($video_id['attr'] == 1){ | ||
1887 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[two_url]"; | ||
1888 | + }elseif ($video_id['attr'] == 2){ | ||
1889 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[four_url]"; | ||
1890 | + }elseif ($video_id['attr'] == 3){ | ||
1891 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[eight_url]"; | ||
1892 | + } | ||
1893 | + //发送短信 | ||
1894 | + $send->sms($mobile,$content); | ||
1893 | } | 1895 | } |
1894 | - //发送短信 | ||
1895 | - $send->sms($mobile,$content); | 1896 | + Db::commit(); |
1896 | $this->success('success'); | 1897 | $this->success('success'); |
1898 | + } catch (\Exception $e) { | ||
1899 | + // 回滚事务 | ||
1900 | + Db::rollback(); | ||
1901 | + $this->error('error'); | ||
1897 | } | 1902 | } |
1898 | } | 1903 | } |
1899 | 1904 |
-
请 注册 或 登录 后发表评论