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

修改总金额

... ... @@ -88,8 +88,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="129">
<caret line="195" column="41" lean-forward="true" selection-start-line="195" selection-start-column="41" selection-end-line="195" selection-end-column="41" />
<state relative-caret-position="702">
<caret line="212" column="64" lean-forward="false" selection-start-line="212" selection-start-column="64" selection-end-line="212" selection-end-column="64" />
<folding>
<element signature="e#574#693#0#PHP" expanded="false" />
<element signature="e#699#1012#0#PHP" expanded="false" />
... ... @@ -99,19 +99,22 @@
<element signature="e#5512#5930#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#11994#13769#0#PHP" expanded="false" />
<element signature="e#13842#14262#0#PHP" expanded="false" />
<element signature="e#14267#21920#0#PHP" expanded="false" />
<element signature="e#21937#22234#0#PHP" expanded="false" />
<element signature="e#22239#22632#0#PHP" expanded="false" />
<element signature="e#22659#26137#0#PHP" expanded="false" />
<element signature="e#26166#29071#0#PHP" expanded="false" />
<element signature="e#29100#33019#0#PHP" expanded="false" />
<element signature="e#31071#32508#0#PHP" expanded="false" />
<element signature="e#31530#32486#0#PHP" expanded="false" />
<element signature="e#33048#37131#0#PHP" expanded="false" />
<element signature="e#34898#36646#0#PHP" expanded="false" />
<element signature="e#37154#37371#0#PHP" expanded="false" />
<element signature="e#9132#11216#0#PHP" expanded="false" />
<element signature="e#11280#11398#0#PHP" expanded="false" />
<element signature="e#12255#14030#0#PHP" expanded="false" />
<element signature="e#14103#14523#0#PHP" expanded="false" />
<element signature="e#14528#22620#0#PHP" expanded="false" />
<element signature="e#22637#22934#0#PHP" expanded="false" />
<element signature="e#22939#23332#0#PHP" expanded="false" />
<element signature="e#23359#26837#0#PHP" expanded="false" />
<element signature="e#26866#29771#0#PHP" expanded="false" />
<element signature="e#29800#33863#0#PHP" expanded="false" />
<element signature="e#31623#31872#0#PHP" expanded="false" />
<element signature="e#31915#33352#0#PHP" expanded="false" />
<element signature="e#32374#33330#0#PHP" expanded="false" />
<element signature="e#33892#38355#0#PHP" expanded="false" />
<element signature="e#36122#37870#0#PHP" expanded="false" />
<element signature="e#38378#38595#0#PHP" expanded="false" />
</folding>
</state>
</provider>
... ... @@ -203,9 +206,9 @@
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds" extendedState="7">
<option name="x" value="307" />
<option name="y" value="132" />
<component name="ProjectFrameBounds">
<option name="x" value="120" />
<option name="y" value="42" />
<option name="width" value="1700" />
<option name="height" value="1000" />
</component>
... ... @@ -335,7 +338,7 @@
<workItem from="1575541798312" duration="2359000" />
<workItem from="1575592025964" duration="640000" />
<workItem from="1575599624364" duration="95000" />
<workItem from="1575680867057" duration="12522000" />
<workItem from="1575680867057" duration="12849000" />
</task>
<task id="LOCAL-00001" summary="调试">
<created>1574145133364</created>
... ... @@ -348,7 +351,7 @@
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="322421000" />
<option name="totallyTimeSpent" value="322748000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
... ... @@ -360,10 +363,10 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="7" />
<frame x="120" y="42" width="1700" height="1000" 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.1705757" sideWeight="0.5" order="1" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.19512194" sideWeight="0.5" order="1" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32912987" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
... ... @@ -857,8 +860,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/application/api/controller/Pay.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="129">
<caret line="195" column="41" lean-forward="true" selection-start-line="195" selection-start-column="41" selection-end-line="195" selection-end-column="41" />
<state relative-caret-position="702">
<caret line="212" column="64" lean-forward="false" selection-start-line="212" selection-start-column="64" selection-end-line="212" selection-end-column="64" />
<folding>
<element signature="e#574#693#0#PHP" expanded="false" />
<element signature="e#699#1012#0#PHP" expanded="false" />
... ... @@ -868,19 +871,22 @@
<element signature="e#5512#5930#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#11994#13769#0#PHP" expanded="false" />
<element signature="e#13842#14262#0#PHP" expanded="false" />
<element signature="e#14267#21920#0#PHP" expanded="false" />
<element signature="e#21937#22234#0#PHP" expanded="false" />
<element signature="e#22239#22632#0#PHP" expanded="false" />
<element signature="e#22659#26137#0#PHP" expanded="false" />
<element signature="e#26166#29071#0#PHP" expanded="false" />
<element signature="e#29100#33019#0#PHP" expanded="false" />
<element signature="e#31071#32508#0#PHP" expanded="false" />
<element signature="e#31530#32486#0#PHP" expanded="false" />
<element signature="e#33048#37131#0#PHP" expanded="false" />
<element signature="e#34898#36646#0#PHP" expanded="false" />
<element signature="e#37154#37371#0#PHP" expanded="false" />
<element signature="e#9132#11216#0#PHP" expanded="false" />
<element signature="e#11280#11398#0#PHP" expanded="false" />
<element signature="e#12255#14030#0#PHP" expanded="false" />
<element signature="e#14103#14523#0#PHP" expanded="false" />
<element signature="e#14528#22620#0#PHP" expanded="false" />
<element signature="e#22637#22934#0#PHP" expanded="false" />
<element signature="e#22939#23332#0#PHP" expanded="false" />
<element signature="e#23359#26837#0#PHP" expanded="false" />
<element signature="e#26866#29771#0#PHP" expanded="false" />
<element signature="e#29800#33863#0#PHP" expanded="false" />
<element signature="e#31623#31872#0#PHP" expanded="false" />
<element signature="e#31915#33352#0#PHP" expanded="false" />
<element signature="e#32374#33330#0#PHP" expanded="false" />
<element signature="e#33892#38355#0#PHP" expanded="false" />
<element signature="e#36122#37870#0#PHP" expanded="false" />
<element signature="e#38378#38595#0#PHP" expanded="false" />
</folding>
</state>
</provider>
... ...
... ... @@ -191,6 +191,7 @@ class Pay extends Api
$uid = $this->uid;
$login = Db::name('user')
->where('id',$uid)
->field('id,is_vip')
->find();
// 启动事务
Db::startTrans();
... ... @@ -198,19 +199,21 @@ class Pay extends Api
if(!empty($pic_id)){
//将购买次数加1
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($login['is_vip'] == 0){
$money = $pic['money'] + $pic['price'];
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$money]);
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$pic['money']+$pic['price']]);
}else{
//是会员
$money = $pic['money'] + $pic['price'] * 0.75;
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$money]);
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$pic['money']+$pic['price']]);
}
}
//拼接发送短信的内容
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)){
//将购买次数加1
... ... @@ -346,25 +349,32 @@ class Pay extends Api
$this->error(['code'=>2,'msg'=>'余额不足,请充值后重试']);
}
$money = $res['money'] - $data['total'];
$uid = $this->uid;
$login = Db::name('user')
->where('id',$uid)
->field('id,is_vip')
->find();
// 启动事务
Db::startTrans();
try{
if(!empty($pic_id)){
//修改购买次数
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($user['is_vip'] == 0){
$money = $pic['money'] + $pic['price'];
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$money]);
if($login['is_vip'] == 0){
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$pic['money']+$pic['price']]);
}else{
//是会员
$money = $pic['money'] + $pic['price'] * 0.75;
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$money]);
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$pic['money']+$pic['price']]);
}
}
//拼接发送短信内容
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)){
//修改购买次数
... ... @@ -647,19 +657,19 @@ class Pay extends Api
//判断用户是否为会员
if(!empty($pic_id)){
foreach ($pic_id as $key => $v){
//短信内容
$pic = Db::name('pic')->field('id,title,url,code,price,buy_num,money')->where('id',$v)->find();
$str .= "图片标题:$pic[title],云盘地址:$pic[url],提取码:$pic[code],";
//非会员
if($user['is_vip'] == 0){
$money = $pic['money'] + $pic['price'];
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$money]);
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$pic['money']+$pic['price']]);
}else{
//是会员
$money = $pic['money'] + $pic['price'] * 0.75;
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$money]);
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$pic['money']+$pic['price']]);
}
}
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)){
... ... @@ -720,21 +730,29 @@ class Pay extends Api
$user = Db::name('user')->where('id',$data['user_id'])->find();
$mobile = $user['mobile'];
$str = "【仁甲看见】";
//判断用户是否为会员
$login = Db::name('user')
->where('id',$data['user_id'])
->field('id,is_vip')
->find();
if(!empty($pic_id)){
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($user['is_vip'] == 0){
$money = $pic['money'] + $pic['price'];
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$money]);
if($login['is_vip'] == 0){
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$pic['money']+$pic['price']]);
}else{
//是会员
$money = $pic['money'] + $pic['price'] * 0.75;
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$money]);
$pic = Db::name('pic')->field('id,price,buy_num,money')->where('id',$v)->find();
Db::name('pic')->where('id',$pic['id'])->update(['buy_num'=>$pic['buy_num']+1,'money'=>$pic['money']+$pic['price']]);
}
}
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)){
foreach ($video_id as $key => $val){
... ...