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

提交

... ... @@ -89,8 +89,8 @@
<file leaf-file-name="Pay.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/application/api/controller/Pay.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="569">
<caret line="729" column="46" lean-forward="true" selection-start-line="729" selection-start-column="46" selection-end-line="729" selection-end-column="46" />
<state relative-caret-position="300">
<caret line="704" column="39" lean-forward="true" selection-start-line="704" selection-start-column="39" selection-end-line="704" selection-end-column="39" />
<folding>
<element signature="e#574#693#0#PHP" expanded="false" />
<element signature="e#699#1012#0#PHP" expanded="false" />
... ... @@ -98,6 +98,7 @@
<element signature="e#3099#3419#0#PHP" expanded="false" />
<element signature="e#3424#5506#0#PHP" expanded="false" />
<element signature="e#5512#5930#0#PHP" expanded="false" />
<element signature="e#5935#16029#0#PHP" expanded="false" />
<element signature="e#6179#6269#0#PHP" expanded="false" />
<element signature="e#6347#6443#0#PHP" expanded="false" />
<element signature="e#6806#15962#0#PHP" expanded="false" />
... ... @@ -114,11 +115,14 @@
<element signature="e#26803#27196#0#PHP" expanded="false" />
<element signature="e#27223#30701#0#PHP" expanded="false" />
<element signature="e#30730#33635#0#PHP" expanded="false" />
<element signature="e#40897#48069#0#PHP" expanded="false" />
<element signature="e#43163#46884#0#PHP" expanded="false" />
<element signature="e#46940#47050#0#PHP" expanded="false" />
<element signature="e#47326#47395#0#PHP" expanded="false" />
<element signature="e#48092#48309#0#PHP" expanded="false" />
<element signature="e#34556#35875#0#PHP" expanded="false" />
<element signature="e#35896#39401#0#PHP" expanded="false" />
<element signature="e#39449#39551#0#PHP" expanded="false" />
<element signature="e#40141#47313#0#PHP" expanded="false" />
<element signature="e#42407#46128#0#PHP" expanded="false" />
<element signature="e#46184#46294#0#PHP" expanded="false" />
<element signature="e#46570#46639#0#PHP" expanded="false" />
<element signature="e#47336#47553#0#PHP" expanded="false" />
</folding>
</state>
</provider>
... ... @@ -211,9 +215,9 @@
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds" extendedState="1">
<option name="x" value="105" />
<option name="y" value="49" />
<component name="ProjectFrameBounds">
<option name="x" value="31" />
<option name="y" value="54" />
<option name="width" value="1871" />
<option name="height" value="1007" />
</component>
... ... @@ -250,13 +254,6 @@
<item name="runtime" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="log" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="areial" type="b2602c69:ProjectViewProjectNode" />
<item name="areial" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="runtime" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="log" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="201912" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
</expand>
<select />
</subPane>
... ... @@ -343,7 +340,7 @@
<workItem from="1575541798312" duration="2359000" />
<workItem from="1575592025964" duration="640000" />
<workItem from="1575599624364" duration="95000" />
<workItem from="1575680867057" duration="22248000" />
<workItem from="1575680867057" duration="22728000" />
</task>
<task id="LOCAL-00001" summary="调试">
<created>1574145133364</created>
... ... @@ -356,7 +353,7 @@
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="332147000" />
<option name="totallyTimeSpent" value="332627000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
... ... @@ -368,7 +365,7 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="105" y="49" width="1871" height="1007" extended-state="1" />
<frame x="31" y="54" width="1871" height="1007" extended-state="0" />
<editor active="true" />
<layout>
<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 @@
</entry>
<entry file="file://$PROJECT_DIR$/runtime/log/201912/07.log">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<state relative-caret-position="-1206">
<caret line="10" column="9" lean-forward="true" selection-start-line="10" selection-start-column="9" selection-end-line="10" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/api/controller/Pay.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="569">
<caret line="729" column="46" lean-forward="true" selection-start-line="729" selection-start-column="46" selection-end-line="729" selection-end-column="46" />
<state relative-caret-position="300">
<caret line="704" column="39" lean-forward="true" selection-start-line="704" selection-start-column="39" selection-end-line="704" selection-end-column="39" />
<folding>
<element signature="e#574#693#0#PHP" expanded="false" />
<element signature="e#699#1012#0#PHP" expanded="false" />
... ... @@ -878,6 +875,7 @@
<element signature="e#3099#3419#0#PHP" expanded="false" />
<element signature="e#3424#5506#0#PHP" expanded="false" />
<element signature="e#5512#5930#0#PHP" expanded="false" />
<element signature="e#5935#16029#0#PHP" expanded="false" />
<element signature="e#6179#6269#0#PHP" expanded="false" />
<element signature="e#6347#6443#0#PHP" expanded="false" />
<element signature="e#6806#15962#0#PHP" expanded="false" />
... ... @@ -894,11 +892,14 @@
<element signature="e#26803#27196#0#PHP" expanded="false" />
<element signature="e#27223#30701#0#PHP" expanded="false" />
<element signature="e#30730#33635#0#PHP" expanded="false" />
<element signature="e#40897#48069#0#PHP" expanded="false" />
<element signature="e#43163#46884#0#PHP" expanded="false" />
<element signature="e#46940#47050#0#PHP" expanded="false" />
<element signature="e#47326#47395#0#PHP" expanded="false" />
<element signature="e#48092#48309#0#PHP" expanded="false" />
<element signature="e#34556#35875#0#PHP" expanded="false" />
<element signature="e#35896#39401#0#PHP" expanded="false" />
<element signature="e#39449#39551#0#PHP" expanded="false" />
<element signature="e#40141#47313#0#PHP" expanded="false" />
<element signature="e#42407#46128#0#PHP" expanded="false" />
<element signature="e#46184#46294#0#PHP" expanded="false" />
<element signature="e#46570#46639#0#PHP" expanded="false" />
<element signature="e#47336#47553#0#PHP" expanded="false" />
</folding>
</state>
</provider>
... ...
... ... @@ -701,107 +701,94 @@ class Pay extends Api
//查询该用户信息以及是否为会员身份
$user = Db::name('user')->where('id',$data['user_id'])->find();
$mobile = $user['mobile'];
Log::info($user);
Log::info($mobile);
$str = "【仁甲看见】";
// 启动事务
Db::startTrans();
try{
if(!empty($pic_id)){
//将购买次数加1
foreach ($pic_id as $key => $v){
//非会员
if($user['is_vip'] == 0){
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
$total_money = $pic['money'] + $pic['price'];
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$total_money]);
}else{
//是会员
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
$total_money = $pic['money'] + ($pic['price']*0.75);
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$total_money]);
}
}
//拼接发送短信的内容
foreach ($pic_id as $key => $v){
$pic = Db::name('pic')->field('id,title,url,code')->where('id',$v)->find();
$str .= "图片标题:$pic[title],云盘地址:$pic[url],提取码:$pic[code],";
}
}
if(!empty($video_id)){
//判断是否为会员
if(!empty($pic_id)){
//将购买次数加1
foreach ($pic_id as $key => $v){
//非会员
if($user['is_vip'] == 0){
//不是会员的情况
//将购买次数加1
foreach ($video_id as $key => $val){
$video = Db::name('video')->field('id,buy_num,price,four_price,eight_price,money')->where('id',$val['id'])->find();
if($val['attr'] == 1){
$video_money = $video['money'] + $video['price'];
}elseif ($val['attr'] == 2){
$video_money = $video['money'] + $video['four_price'];
}else{
$video_money = $video['money'] + $video['eight_price'];
}
Db::name('video')->where('id',$video['id'])->update(['buy_num'=>$video['buy_num']+1,'money'=>$video_money]);
}
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
$total_money = $pic['money'] + $pic['price'];
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$total_money]);
}else{
//是会员的情况
//将购买次数加1
foreach ($video_id as $key => $val){
$video = Db::name('video')->field('id,buy_num,price,four_price,eight_price,money')->where('id',$val['id'])->find();
if($val['attr'] == 1){
$video_money = $video['money'] + ($video['price']*0.75);
}elseif ($val['attr'] == 2){
$video_money = $video['money'] + ($video['four_price']*0.75);
}else{
$video_money = $video['money'] + ($video['eight_price']*0.75);
}
Db::name('video')->where('id',$video['id'])->update(['buy_num'=>$video['buy_num']+1,'money'=>$video_money]);
}
//是会员
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
$total_money = $pic['money'] + ($pic['price']*0.75);
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$total_money]);
}
//判断视频的属性
foreach ($video_id as &$val){
}
//拼接发送短信的内容
foreach ($pic_id as $key => $v){
$pic = Db::name('pic')->field('id,title,url,code')->where('id',$v)->find();
$str .= "图片标题:$pic[title],云盘地址:$pic[url],提取码:$pic[code],";
}
}
if(!empty($video_id)){
//判断是否为会员
if($user['is_vip'] == 0){
//不是会员的情况
//将购买次数加1
foreach ($video_id as $key => $val){
$video = Db::name('video')->field('id,buy_num,price,four_price,eight_price,money')->where('id',$val['id'])->find();
if($val['attr'] == 1){
$val['attr'] = '2k';
$video_money = $video['money'] + $video['price'];
}elseif ($val['attr'] == 2){
$val['attr'] = '4k';
$video_money = $video['money'] + $video['four_price'];
}else{
$val['attr'] = '8k';
$video_money = $video['money'] + $video['eight_price'];
}
Db::name('video')->where('id',$video['id'])->update(['buy_num'=>$video['buy_num']+1,'money'=>$video_money]);
}
//拼接发送短信的内容
foreach ($video_id as $k=>$v){
if($v['attr'] == '4k'){
$video = Db::name('video')->field('id,title,four_url,four_code')->where('id',$v['id'])->find();
$str .= "视频标题:$video[title],云盘地址:$video[four_url],提取码:$video[four_code]";
}elseif ($v['attr'] == '2k'){
$video = Db::name('video')->field('id,title,two_url,two_code')->where('id',$v['id'])->find();
$str .= "视频标题:$video[title],云盘地址:$video[two_url],提取码:$video[two_code]";
}elseif ($v['attr'] == '8k'){
$video = Db::name('video')->field('id,title,eight_url,eight_code')->where('id',$v['id'])->find();
$str .= "视频标题:$video[title],云盘地址:$video[eight_url],提取码:$video[eight_code]";
}else{
//是会员的情况
//将购买次数加1
foreach ($video_id as $key => $val){
$video = Db::name('video')->field('id,buy_num,price,four_price,eight_price,money')->where('id',$val['id'])->find();
if($val['attr'] == 1){
$video_money = $video['money'] + ($video['price']*0.75);
}elseif ($val['attr'] == 2){
$video_money = $video['money'] + ($video['four_price']*0.75);
}else{
$video_money = $video['money'] + ($video['eight_price']*0.75);
}
Db::name('video')->where('id',$video['id'])->update(['buy_num'=>$video['buy_num']+1,'money'=>$video_money]);
}
}
//发送短信
if(!empty($mobile)){
$result = $this->sms($mobile,$str);
//判断视频的属性
foreach ($video_id as &$val){
if($val['attr'] == 1){
$val['attr'] = '2k';
}elseif ($val['attr'] == 2){
$val['attr'] = '4k';
}else{
$val['attr'] = '8k';
}
}
//支付成功,更新订单状态
$toporder['status'] = 2;
$toporder['paytime'] = time();
$res = Db::name('order')->where('num',$message['out_trade_no'])->update($toporder);
if($res){
true;
//拼接发送短信的内容
foreach ($video_id as $k=>$v){
if($v['attr'] == '4k'){
$video = Db::name('video')->field('id,title,four_url,four_code')->where('id',$v['id'])->find();
$str .= "视频标题:$video[title],云盘地址:$video[four_url],提取码:$video[four_code]";
}elseif ($v['attr'] == '2k'){
$video = Db::name('video')->field('id,title,two_url,two_code')->where('id',$v['id'])->find();
$str .= "视频标题:$video[title],云盘地址:$video[two_url],提取码:$video[two_code]";
}elseif ($v['attr'] == '8k'){
$video = Db::name('video')->field('id,title,eight_url,eight_code')->where('id',$v['id'])->find();
$str .= "视频标题:$video[title],云盘地址:$video[eight_url],提取码:$video[eight_code]";
}
}
// 提交事务
Db::commit();
} catch (\Exception $e) {
dump($e->getMessage());
// 回滚事务
Db::rollback();
$this->error('购买失败');
}
//发送短信
if(!empty($mobile)){
$result = $this->sms($mobile,$str);
}
//支付成功,更新订单状态
$toporder['status'] = 2;
$toporder['paytime'] = time();
Db::name('order')->where('num',$message['out_trade_no'])->update($toporder);
}else{
//支付失败
$toporder['status'] = 1;
... ...