正在显示
1 个修改的文件
包含
90 行增加
和
3 行删除
@@ -1767,6 +1767,8 @@ class User extends Api | @@ -1767,6 +1767,8 @@ class User extends Api | ||
1767 | "msg": "成功", | 1767 | "msg": "成功", |
1768 | "time": "1571492001", | 1768 | "time": "1571492001", |
1769 | "data": { | 1769 | "data": { |
1770 | + "is_vip"://是否是会员1是0否 | ||
1771 | + "is_enough"://余额是否充足1充足2不足 | ||
1770 | "order_id"://订单ID | 1772 | "order_id"://订单ID |
1771 | } | 1773 | } |
1772 | }) | 1774 | }) |
@@ -1774,11 +1776,14 @@ class User extends Api | @@ -1774,11 +1776,14 @@ class User extends Api | ||
1774 | public function iphone_order() | 1776 | public function iphone_order() |
1775 | { | 1777 | { |
1776 | $param['user_id'] = $this->uid; | 1778 | $param['user_id'] = $this->uid; |
1777 | - $user = Db::name('user')->where('id',$param['user_id'])->field('mobile,id,type')->find(); | 1779 | + $user = Db::name('user')->where('id',$param['user_id'])->field('mobile,id,type,is_vip,money,mobile')->find(); |
1778 | if($user['type'] == 0){ | 1780 | if($user['type'] == 0){ |
1779 | $this->error('该功能只支持苹果用户'); | 1781 | $this->error('该功能只支持苹果用户'); |
1780 | } | 1782 | } |
1781 | 1783 | ||
1784 | + //查看用户是否是vip | ||
1785 | + $data['is_vip'] = $user['is_vip']; | ||
1786 | + | ||
1782 | //接收视频ID加视频属性 | 1787 | //接收视频ID加视频属性 |
1783 | $video['id'] = $this->request->post('video_id'); | 1788 | $video['id'] = $this->request->post('video_id'); |
1784 | $video['attr'] = $this->request->post('video_attr'); | 1789 | $video['attr'] = $this->request->post('video_attr'); |
@@ -1799,9 +1804,12 @@ class User extends Api | @@ -1799,9 +1804,12 @@ class User extends Api | ||
1799 | $this->error(['code'=>3,'msg'=>'非法操作']); | 1804 | $this->error(['code'=>3,'msg'=>'非法操作']); |
1800 | } | 1805 | } |
1801 | 1806 | ||
1807 | + //查询用户余额是否充足 | ||
1808 | + if($user['money'] < $param['total']){ | ||
1809 | + $data['is_enough'] = 2; | ||
1810 | + | ||
1802 | $where['user_id'] = ['eq',$param['user_id']]; | 1811 | $where['user_id'] = ['eq',$param['user_id']]; |
1803 | $where['status'] = ['eq',2]; | 1812 | $where['status'] = ['eq',2]; |
1804 | - | ||
1805 | if(!empty($video['id']) && !empty($video['attr'])){ | 1813 | if(!empty($video['id']) && !empty($video['attr'])){ |
1806 | $video_s = serialize($video); | 1814 | $video_s = serialize($video); |
1807 | //查看该图片或者该视频属性是否已经购买过 | 1815 | //查看该图片或者该视频属性是否已经购买过 |
@@ -1843,8 +1851,87 @@ class User extends Api | @@ -1843,8 +1851,87 @@ class User extends Api | ||
1843 | $send = new Pay(); | 1851 | $send = new Pay(); |
1844 | $send->sms($mobile,$content); | 1852 | $send->sms($mobile,$content); |
1845 | $send->sms($mobile1,$content); | 1853 | $send->sms($mobile1,$content); |
1846 | - $this->success('SUCCESS',['order_id'=>$data]); | 1854 | + $this->success('SUCCESS',$data); |
1855 | + } | ||
1856 | + | ||
1857 | + }else{ | ||
1858 | + $data['is_enough'] = 1; | ||
1859 | + | ||
1860 | + $where['user_id'] = ['eq',$param['user_id']]; | ||
1861 | + $where['status'] = ['eq',2]; | ||
1862 | + if(!empty($video['id']) && !empty($video['attr'])){ | ||
1863 | + $video_s = serialize($video); | ||
1864 | + //查看该图片或者该视频属性是否已经购买过 | ||
1865 | + $res = Db::name('iphone') | ||
1866 | + ->where($where) | ||
1867 | + ->where('video_id',$video_s) | ||
1868 | + ->find(); | ||
1869 | + if(!empty($res)){ | ||
1870 | + $this->error(['code'=>2,'msg'=>'该属性的视频已经购买过了']); | ||
1871 | + } | ||
1872 | + $param['video_id'] = serialize($video); | ||
1873 | + }else{ | ||
1874 | + //查询图片ID | ||
1875 | + $arr = Db::name('iphone') | ||
1876 | + ->field('pic_id') | ||
1877 | + ->where($where) | ||
1878 | + ->select(); | ||
1879 | + foreach ($arr as &$v){ | ||
1880 | + if(!empty($v['pic_id'])){ | ||
1881 | + if($v['pic_id'] == $pic_id){ | ||
1882 | + $this->error(['code'=>2,'msg'=>'该图片已经购买过了','pic_id'=>$pic_id]); | ||
1883 | + } | ||
1884 | + } | ||
1885 | + } | ||
1886 | + $param['pic_id'] = $pic_id; | ||
1887 | + } | ||
1888 | + $param['createtime'] = time(); | ||
1889 | + $param['num'] = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8); | ||
1890 | + $data_order = Db::name('iphone') | ||
1891 | + ->insertGetId($param); | ||
1892 | + if(empty($data_order)){ | ||
1893 | + $this->error(['code'=>2,'msg'=>'sql执行失败']); | ||
1894 | + }else{ | ||
1895 | + $send = new Pay(); | ||
1896 | + | ||
1897 | + //修改用户余额以及订单状态 同时给用户发送短信 | ||
1898 | + $update = $user['money'] - $param['total']; | ||
1899 | + Db::name('user')->where('id',$param['user_id'])->update(['money'=>$update]); | ||
1900 | + Db::name('iphone')->where('id',$data_order)->update(['status'=>2]); | ||
1901 | + | ||
1902 | + | ||
1903 | + //查询订单数据 | ||
1904 | + $order_info = Db::name('iphone')->where('id',$data_order)->find(); | ||
1905 | + //用户购买的什么素材 | ||
1906 | + if(empty($order_info['video_id'])){ | ||
1907 | + $pic = Db::name('pic')->where('id',$data['pic_id'])->find(); | ||
1908 | + | ||
1909 | + //发送短信,通知客户 | ||
1910 | + $mobile = $user['mobile']; | ||
1911 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。图片标题:$pic[title],云盘地址:$pic[url]"; | ||
1912 | + //发送短信 | ||
1913 | + | ||
1914 | + $send->sms($mobile,$content); | ||
1915 | + | ||
1916 | + }elseif (empty($data['pic_id'])){ | ||
1917 | + $video_id = unserialize($data['video_id']); | ||
1918 | + $video = Db::name('video')->where('id',$video_id['id'])->find(); | ||
1919 | + //发送短信,通知客户 | ||
1920 | + $mobile = $user['mobile']; | ||
1921 | + if($video_id['attr'] == 1){ | ||
1922 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[two_url]"; | ||
1923 | + }elseif ($video_id['attr'] == 2){ | ||
1924 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[four_url]"; | ||
1925 | + }elseif ($video_id['attr'] == 3){ | ||
1926 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[eight_url]"; | ||
1847 | } | 1927 | } |
1928 | + //发送短信 | ||
1929 | + $send->sms($mobile,$content); | ||
1930 | + } | ||
1931 | + } | ||
1932 | + | ||
1933 | + } | ||
1934 | + | ||
1848 | 1935 | ||
1849 | } | 1936 | } |
1850 | 1937 |
-
请 注册 或 登录 后发表评论