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

提交

@@ -89,8 +89,8 @@ @@ -89,8 +89,8 @@
89 <file leaf-file-name="Pay.php" pinned="false" current-in-tab="true"> 89 <file leaf-file-name="Pay.php" pinned="false" current-in-tab="true">
90 <entry file="file://$PROJECT_DIR$/application/api/controller/Pay.php"> 90 <entry file="file://$PROJECT_DIR$/application/api/controller/Pay.php">
91 <provider selected="true" editor-type-id="text-editor"> 91 <provider selected="true" editor-type-id="text-editor">
92 - <state relative-caret-position="569">  
93 - <caret line="729" column="46" lean-forward="true" selection-start-line="729" selection-start-column="46" selection-end-line="729" selection-end-column="46" /> 92 + <state relative-caret-position="300">
  93 + <caret line="704" column="39" lean-forward="true" selection-start-line="704" selection-start-column="39" selection-end-line="704" selection-end-column="39" />
94 <folding> 94 <folding>
95 <element signature="e#574#693#0#PHP" expanded="false" /> 95 <element signature="e#574#693#0#PHP" expanded="false" />
96 <element signature="e#699#1012#0#PHP" expanded="false" /> 96 <element signature="e#699#1012#0#PHP" expanded="false" />
@@ -98,6 +98,7 @@ @@ -98,6 +98,7 @@
98 <element signature="e#3099#3419#0#PHP" expanded="false" /> 98 <element signature="e#3099#3419#0#PHP" expanded="false" />
99 <element signature="e#3424#5506#0#PHP" expanded="false" /> 99 <element signature="e#3424#5506#0#PHP" expanded="false" />
100 <element signature="e#5512#5930#0#PHP" expanded="false" /> 100 <element signature="e#5512#5930#0#PHP" expanded="false" />
  101 + <element signature="e#5935#16029#0#PHP" expanded="false" />
101 <element signature="e#6179#6269#0#PHP" expanded="false" /> 102 <element signature="e#6179#6269#0#PHP" expanded="false" />
102 <element signature="e#6347#6443#0#PHP" expanded="false" /> 103 <element signature="e#6347#6443#0#PHP" expanded="false" />
103 <element signature="e#6806#15962#0#PHP" expanded="false" /> 104 <element signature="e#6806#15962#0#PHP" expanded="false" />
@@ -114,11 +115,14 @@ @@ -114,11 +115,14 @@
114 <element signature="e#26803#27196#0#PHP" expanded="false" /> 115 <element signature="e#26803#27196#0#PHP" expanded="false" />
115 <element signature="e#27223#30701#0#PHP" expanded="false" /> 116 <element signature="e#27223#30701#0#PHP" expanded="false" />
116 <element signature="e#30730#33635#0#PHP" expanded="false" /> 117 <element signature="e#30730#33635#0#PHP" expanded="false" />
117 - <element signature="e#40897#48069#0#PHP" expanded="false" />  
118 - <element signature="e#43163#46884#0#PHP" expanded="false" />  
119 - <element signature="e#46940#47050#0#PHP" expanded="false" />  
120 - <element signature="e#47326#47395#0#PHP" expanded="false" />  
121 - <element signature="e#48092#48309#0#PHP" expanded="false" /> 118 + <element signature="e#34556#35875#0#PHP" expanded="false" />
  119 + <element signature="e#35896#39401#0#PHP" expanded="false" />
  120 + <element signature="e#39449#39551#0#PHP" expanded="false" />
  121 + <element signature="e#40141#47313#0#PHP" expanded="false" />
  122 + <element signature="e#42407#46128#0#PHP" expanded="false" />
  123 + <element signature="e#46184#46294#0#PHP" expanded="false" />
  124 + <element signature="e#46570#46639#0#PHP" expanded="false" />
  125 + <element signature="e#47336#47553#0#PHP" expanded="false" />
122 </folding> 126 </folding>
123 </state> 127 </state>
124 </provider> 128 </provider>
@@ -211,9 +215,9 @@ @@ -211,9 +215,9 @@
211 <sorting>DEFINITION_ORDER</sorting> 215 <sorting>DEFINITION_ORDER</sorting>
212 </component> 216 </component>
213 <component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" /> 217 <component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
214 - <component name="ProjectFrameBounds" extendedState="1">  
215 - <option name="x" value="105" />  
216 - <option name="y" value="49" /> 218 + <component name="ProjectFrameBounds">
  219 + <option name="x" value="31" />
  220 + <option name="y" value="54" />
217 <option name="width" value="1871" /> 221 <option name="width" value="1871" />
218 <option name="height" value="1007" /> 222 <option name="height" value="1007" />
219 </component> 223 </component>
@@ -250,13 +254,6 @@ @@ -250,13 +254,6 @@
250 <item name="runtime" type="2a2b976b:PhpTreeStructureProvider$1" /> 254 <item name="runtime" type="2a2b976b:PhpTreeStructureProvider$1" />
251 <item name="log" type="2a2b976b:PhpTreeStructureProvider$1" /> 255 <item name="log" type="2a2b976b:PhpTreeStructureProvider$1" />
252 </path> 256 </path>
253 - <path>  
254 - <item name="areial" type="b2602c69:ProjectViewProjectNode" />  
255 - <item name="areial" type="2a2b976b:PhpTreeStructureProvider$1" />  
256 - <item name="runtime" type="2a2b976b:PhpTreeStructureProvider$1" />  
257 - <item name="log" type="2a2b976b:PhpTreeStructureProvider$1" />  
258 - <item name="201912" type="2a2b976b:PhpTreeStructureProvider$1" />  
259 - </path>  
260 </expand> 257 </expand>
261 <select /> 258 <select />
262 </subPane> 259 </subPane>
@@ -343,7 +340,7 @@ @@ -343,7 +340,7 @@
343 <workItem from="1575541798312" duration="2359000" /> 340 <workItem from="1575541798312" duration="2359000" />
344 <workItem from="1575592025964" duration="640000" /> 341 <workItem from="1575592025964" duration="640000" />
345 <workItem from="1575599624364" duration="95000" /> 342 <workItem from="1575599624364" duration="95000" />
346 - <workItem from="1575680867057" duration="22248000" /> 343 + <workItem from="1575680867057" duration="22728000" />
347 </task> 344 </task>
348 <task id="LOCAL-00001" summary="调试"> 345 <task id="LOCAL-00001" summary="调试">
349 <created>1574145133364</created> 346 <created>1574145133364</created>
@@ -356,7 +353,7 @@ @@ -356,7 +353,7 @@
356 <servers /> 353 <servers />
357 </component> 354 </component>
358 <component name="TimeTrackingManager"> 355 <component name="TimeTrackingManager">
359 - <option name="totallyTimeSpent" value="332147000" /> 356 + <option name="totallyTimeSpent" value="332627000" />
360 </component> 357 </component>
361 <component name="TodoView"> 358 <component name="TodoView">
362 <todo-panel id="selected-file"> 359 <todo-panel id="selected-file">
@@ -368,7 +365,7 @@ @@ -368,7 +365,7 @@
368 </todo-panel> 365 </todo-panel>
369 </component> 366 </component>
370 <component name="ToolWindowManager"> 367 <component name="ToolWindowManager">
371 - <frame x="105" y="49" width="1871" height="1007" extended-state="1" /> 368 + <frame x="31" y="54" width="1871" height="1007" extended-state="0" />
372 <editor active="true" /> 369 <editor active="true" />
373 <layout> 370 <layout>
374 <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.17669795" sideWeight="0.5" order="1" side_tool="false" content_ui="combo" /> 371 <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.17669795" sideWeight="0.5" order="1" side_tool="false" content_ui="combo" />
@@ -861,16 +858,16 @@ @@ -861,16 +858,16 @@
861 </entry> 858 </entry>
862 <entry file="file://$PROJECT_DIR$/runtime/log/201912/07.log"> 859 <entry file="file://$PROJECT_DIR$/runtime/log/201912/07.log">
863 <provider selected="true" editor-type-id="text-editor"> 860 <provider selected="true" editor-type-id="text-editor">
864 - <state relative-caret-position="0">  
865 - <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> 861 + <state relative-caret-position="-1206">
  862 + <caret line="10" column="9" lean-forward="true" selection-start-line="10" selection-start-column="9" selection-end-line="10" selection-end-column="9" />
866 <folding /> 863 <folding />
867 </state> 864 </state>
868 </provider> 865 </provider>
869 </entry> 866 </entry>
870 <entry file="file://$PROJECT_DIR$/application/api/controller/Pay.php"> 867 <entry file="file://$PROJECT_DIR$/application/api/controller/Pay.php">
871 <provider selected="true" editor-type-id="text-editor"> 868 <provider selected="true" editor-type-id="text-editor">
872 - <state relative-caret-position="569">  
873 - <caret line="729" column="46" lean-forward="true" selection-start-line="729" selection-start-column="46" selection-end-line="729" selection-end-column="46" /> 869 + <state relative-caret-position="300">
  870 + <caret line="704" column="39" lean-forward="true" selection-start-line="704" selection-start-column="39" selection-end-line="704" selection-end-column="39" />
874 <folding> 871 <folding>
875 <element signature="e#574#693#0#PHP" expanded="false" /> 872 <element signature="e#574#693#0#PHP" expanded="false" />
876 <element signature="e#699#1012#0#PHP" expanded="false" /> 873 <element signature="e#699#1012#0#PHP" expanded="false" />
@@ -878,6 +875,7 @@ @@ -878,6 +875,7 @@
878 <element signature="e#3099#3419#0#PHP" expanded="false" /> 875 <element signature="e#3099#3419#0#PHP" expanded="false" />
879 <element signature="e#3424#5506#0#PHP" expanded="false" /> 876 <element signature="e#3424#5506#0#PHP" expanded="false" />
880 <element signature="e#5512#5930#0#PHP" expanded="false" /> 877 <element signature="e#5512#5930#0#PHP" expanded="false" />
  878 + <element signature="e#5935#16029#0#PHP" expanded="false" />
881 <element signature="e#6179#6269#0#PHP" expanded="false" /> 879 <element signature="e#6179#6269#0#PHP" expanded="false" />
882 <element signature="e#6347#6443#0#PHP" expanded="false" /> 880 <element signature="e#6347#6443#0#PHP" expanded="false" />
883 <element signature="e#6806#15962#0#PHP" expanded="false" /> 881 <element signature="e#6806#15962#0#PHP" expanded="false" />
@@ -894,11 +892,14 @@ @@ -894,11 +892,14 @@
894 <element signature="e#26803#27196#0#PHP" expanded="false" /> 892 <element signature="e#26803#27196#0#PHP" expanded="false" />
895 <element signature="e#27223#30701#0#PHP" expanded="false" /> 893 <element signature="e#27223#30701#0#PHP" expanded="false" />
896 <element signature="e#30730#33635#0#PHP" expanded="false" /> 894 <element signature="e#30730#33635#0#PHP" expanded="false" />
897 - <element signature="e#40897#48069#0#PHP" expanded="false" />  
898 - <element signature="e#43163#46884#0#PHP" expanded="false" />  
899 - <element signature="e#46940#47050#0#PHP" expanded="false" />  
900 - <element signature="e#47326#47395#0#PHP" expanded="false" />  
901 - <element signature="e#48092#48309#0#PHP" expanded="false" /> 895 + <element signature="e#34556#35875#0#PHP" expanded="false" />
  896 + <element signature="e#35896#39401#0#PHP" expanded="false" />
  897 + <element signature="e#39449#39551#0#PHP" expanded="false" />
  898 + <element signature="e#40141#47313#0#PHP" expanded="false" />
  899 + <element signature="e#42407#46128#0#PHP" expanded="false" />
  900 + <element signature="e#46184#46294#0#PHP" expanded="false" />
  901 + <element signature="e#46570#46639#0#PHP" expanded="false" />
  902 + <element signature="e#47336#47553#0#PHP" expanded="false" />
902 </folding> 903 </folding>
903 </state> 904 </state>
904 </provider> 905 </provider>
@@ -701,107 +701,94 @@ class Pay extends Api @@ -701,107 +701,94 @@ class Pay extends Api
701 //查询该用户信息以及是否为会员身份 701 //查询该用户信息以及是否为会员身份
702 $user = Db::name('user')->where('id',$data['user_id'])->find(); 702 $user = Db::name('user')->where('id',$data['user_id'])->find();
703 $mobile = $user['mobile']; 703 $mobile = $user['mobile'];
  704 + Log::info($user);
  705 + Log::info($mobile);
704 $str = "【仁甲看见】"; 706 $str = "【仁甲看见】";
705 - // 启动事务  
706 - Db::startTrans();  
707 - try{  
708 - if(!empty($pic_id)){  
709 - //将购买次数加1  
710 - foreach ($pic_id as $key => $v){  
711 - //非会员  
712 - if($user['is_vip'] == 0){  
713 - $pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();  
714 - $total_money = $pic['money'] + $pic['price'];  
715 - Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$total_money]);  
716 - }else{  
717 - //是会员  
718 - $pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();  
719 - $total_money = $pic['money'] + ($pic['price']*0.75);  
720 - Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$total_money]);  
721 - }  
722 - }  
723 - //拼接发送短信的内容  
724 - foreach ($pic_id as $key => $v){  
725 - $pic = Db::name('pic')->field('id,title,url,code')->where('id',$v)->find();  
726 - $str .= "图片标题:$pic[title],云盘地址:$pic[url],提取码:$pic[code],";  
727 - }  
728 - }  
729 -  
730 - if(!empty($video_id)){  
731 - //判断是否为会员 707 + if(!empty($pic_id)){
  708 + //将购买次数加1
  709 + foreach ($pic_id as $key => $v){
  710 + //非会员
732 if($user['is_vip'] == 0){ 711 if($user['is_vip'] == 0){
733 - //不是会员的情况  
734 - //将购买次数加1  
735 - foreach ($video_id as $key => $val){  
736 - $video = Db::name('video')->field('id,buy_num,price,four_price,eight_price,money')->where('id',$val['id'])->find();  
737 - if($val['attr'] == 1){  
738 - $video_money = $video['money'] + $video['price'];  
739 - }elseif ($val['attr'] == 2){  
740 - $video_money = $video['money'] + $video['four_price'];  
741 - }else{  
742 - $video_money = $video['money'] + $video['eight_price'];  
743 - }  
744 - Db::name('video')->where('id',$video['id'])->update(['buy_num'=>$video['buy_num']+1,'money'=>$video_money]);  
745 - } 712 + $pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
  713 + $total_money = $pic['money'] + $pic['price'];
  714 + Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$total_money]);
746 }else{ 715 }else{
747 - //是会员的情况  
748 - //将购买次数加1  
749 - foreach ($video_id as $key => $val){  
750 - $video = Db::name('video')->field('id,buy_num,price,four_price,eight_price,money')->where('id',$val['id'])->find();  
751 - if($val['attr'] == 1){  
752 - $video_money = $video['money'] + ($video['price']*0.75);  
753 - }elseif ($val['attr'] == 2){  
754 - $video_money = $video['money'] + ($video['four_price']*0.75);  
755 - }else{  
756 - $video_money = $video['money'] + ($video['eight_price']*0.75);  
757 - }  
758 - Db::name('video')->where('id',$video['id'])->update(['buy_num'=>$video['buy_num']+1,'money'=>$video_money]);  
759 - } 716 + //是会员
  717 + $pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
  718 + $total_money = $pic['money'] + ($pic['price']*0.75);
  719 + Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$total_money]);
760 } 720 }
761 -  
762 - //判断视频的属性  
763 - foreach ($video_id as &$val){ 721 + }
  722 + //拼接发送短信的内容
  723 + foreach ($pic_id as $key => $v){
  724 + $pic = Db::name('pic')->field('id,title,url,code')->where('id',$v)->find();
  725 + $str .= "图片标题:$pic[title],云盘地址:$pic[url],提取码:$pic[code],";
  726 + }
  727 + }
  728 + if(!empty($video_id)){
  729 + //判断是否为会员
  730 + if($user['is_vip'] == 0){
  731 + //不是会员的情况
  732 + //将购买次数加1
  733 + foreach ($video_id as $key => $val){
  734 + $video = Db::name('video')->field('id,buy_num,price,four_price,eight_price,money')->where('id',$val['id'])->find();
764 if($val['attr'] == 1){ 735 if($val['attr'] == 1){
765 - $val['attr'] = '2k'; 736 + $video_money = $video['money'] + $video['price'];
766 }elseif ($val['attr'] == 2){ 737 }elseif ($val['attr'] == 2){
767 - $val['attr'] = '4k'; 738 + $video_money = $video['money'] + $video['four_price'];
768 }else{ 739 }else{
769 - $val['attr'] = '8k'; 740 + $video_money = $video['money'] + $video['eight_price'];
770 } 741 }
  742 + Db::name('video')->where('id',$video['id'])->update(['buy_num'=>$video['buy_num']+1,'money'=>$video_money]);
771 } 743 }
772 - //拼接发送短信的内容  
773 - foreach ($video_id as $k=>$v){  
774 - if($v['attr'] == '4k'){  
775 - $video = Db::name('video')->field('id,title,four_url,four_code')->where('id',$v['id'])->find();  
776 - $str .= "视频标题:$video[title],云盘地址:$video[four_url],提取码:$video[four_code]";  
777 - }elseif ($v['attr'] == '2k'){  
778 - $video = Db::name('video')->field('id,title,two_url,two_code')->where('id',$v['id'])->find();  
779 - $str .= "视频标题:$video[title],云盘地址:$video[two_url],提取码:$video[two_code]";  
780 - }elseif ($v['attr'] == '8k'){  
781 - $video = Db::name('video')->field('id,title,eight_url,eight_code')->where('id',$v['id'])->find();  
782 - $str .= "视频标题:$video[title],云盘地址:$video[eight_url],提取码:$video[eight_code]"; 744 + }else{
  745 + //是会员的情况
  746 + //将购买次数加1
  747 + foreach ($video_id as $key => $val){
  748 + $video = Db::name('video')->field('id,buy_num,price,four_price,eight_price,money')->where('id',$val['id'])->find();
  749 + if($val['attr'] == 1){
  750 + $video_money = $video['money'] + ($video['price']*0.75);
  751 + }elseif ($val['attr'] == 2){
  752 + $video_money = $video['money'] + ($video['four_price']*0.75);
  753 + }else{
  754 + $video_money = $video['money'] + ($video['eight_price']*0.75);
783 } 755 }
  756 + Db::name('video')->where('id',$video['id'])->update(['buy_num'=>$video['buy_num']+1,'money'=>$video_money]);
784 } 757 }
785 } 758 }
786 - //发送短信  
787 - if(!empty($mobile)){  
788 - $result = $this->sms($mobile,$str); 759 +
  760 + //判断视频的属性
  761 + foreach ($video_id as &$val){
  762 + if($val['attr'] == 1){
  763 + $val['attr'] = '2k';
  764 + }elseif ($val['attr'] == 2){
  765 + $val['attr'] = '4k';
  766 + }else{
  767 + $val['attr'] = '8k';
  768 + }
789 } 769 }
790 - //支付成功,更新订单状态  
791 - $toporder['status'] = 2;  
792 - $toporder['paytime'] = time();  
793 - $res = Db::name('order')->where('num',$message['out_trade_no'])->update($toporder);  
794 - if($res){  
795 - true; 770 + //拼接发送短信的内容
  771 + foreach ($video_id as $k=>$v){
  772 + if($v['attr'] == '4k'){
  773 + $video = Db::name('video')->field('id,title,four_url,four_code')->where('id',$v['id'])->find();
  774 + $str .= "视频标题:$video[title],云盘地址:$video[four_url],提取码:$video[four_code]";
  775 + }elseif ($v['attr'] == '2k'){
  776 + $video = Db::name('video')->field('id,title,two_url,two_code')->where('id',$v['id'])->find();
  777 + $str .= "视频标题:$video[title],云盘地址:$video[two_url],提取码:$video[two_code]";
  778 + }elseif ($v['attr'] == '8k'){
  779 + $video = Db::name('video')->field('id,title,eight_url,eight_code')->where('id',$v['id'])->find();
  780 + $str .= "视频标题:$video[title],云盘地址:$video[eight_url],提取码:$video[eight_code]";
  781 + }
796 } 782 }
797 - // 提交事务  
798 - Db::commit();  
799 - } catch (\Exception $e) {  
800 - dump($e->getMessage());  
801 - // 回滚事务  
802 - Db::rollback();  
803 - $this->error('购买失败');  
804 } 783 }
  784 + //发送短信
  785 + if(!empty($mobile)){
  786 + $result = $this->sms($mobile,$str);
  787 + }
  788 + //支付成功,更新订单状态
  789 + $toporder['status'] = 2;
  790 + $toporder['paytime'] = time();
  791 + Db::name('order')->where('num',$message['out_trade_no'])->update($toporder);
805 }else{ 792 }else{
806 //支付失败 793 //支付失败
807 $toporder['status'] = 1; 794 $toporder['status'] = 1;