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

重复购买

... ... @@ -2,6 +2,7 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="e93f11c2-a7d9-4d35-8b1c-8dd18e7f5fef" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/application/api/controller/User.php" afterPath="$PROJECT_DIR$/application/api/controller/User.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/public/api.html" afterPath="$PROJECT_DIR$/public/api.html" />
</list>
... ... @@ -17,8 +18,8 @@
<file leaf-file-name="User.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/application/api/controller/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="303">
<caret line="282" column="37" lean-forward="true" selection-start-line="282" selection-start-column="37" selection-end-line="282" selection-end-column="37" />
<state relative-caret-position="274">
<caret line="1118" column="9" lean-forward="false" selection-start-line="1118" selection-start-column="9" selection-end-line="1118" selection-end-column="9" />
<folding>
<element signature="e#365#484#0#PHP" expanded="false" />
<element signature="e#490#1228#0#PHP" expanded="false" />
... ... @@ -30,6 +31,7 @@
<element signature="e#4973#5810#0#PHP" expanded="false" />
<element signature="e#5815#8010#0#PHP" expanded="false" />
<element signature="e#8016#8661#0#PHP" expanded="false" />
<element signature="e#8666#9762#0#PHP" expanded="false" />
<element signature="e#9768#10470#0#PHP" expanded="false" />
<element signature="e#10475#11675#0#PHP" expanded="false" />
<element signature="e#11681#12257#0#PHP" expanded="false" />
... ... @@ -62,17 +64,16 @@
<element signature="e#32644#34597#0#PHP" expanded="false" />
<element signature="e#32798#32884#0#PHP" expanded="false" />
<element signature="e#32973#33061#0#PHP" expanded="false" />
<element signature="e#34609#35369#0#PHP" expanded="false" />
<element signature="e#35374#37784#0#PHP" expanded="false" />
<element signature="e#37810#38641#0#PHP" expanded="false" />
<element signature="e#38647#39067#0#PHP" expanded="false" />
<element signature="e#39072#39555#0#PHP" expanded="false" />
<element signature="e#39561#40367#0#PHP" expanded="false" />
<element signature="e#40372#43526#0#PHP" expanded="false" />
<element signature="e#43541#44869#0#PHP" expanded="false" />
<element signature="e#44885#45912#0#PHP" expanded="false" />
<element signature="e#45919#46677#0#PHP" expanded="false" />
<element signature="e#46682#49069#0#PHP" expanded="false" />
<element signature="e#34603#35363#0#PHP" expanded="false" />
<element signature="e#38103#38934#0#PHP" expanded="false" />
<element signature="e#38940#39360#0#PHP" expanded="false" />
<element signature="e#39365#39848#0#PHP" expanded="false" />
<element signature="e#39854#40660#0#PHP" expanded="false" />
<element signature="e#40665#43819#0#PHP" expanded="false" />
<element signature="e#43834#45162#0#PHP" expanded="false" />
<element signature="e#45178#46205#0#PHP" expanded="false" />
<element signature="e#46212#46970#0#PHP" expanded="false" />
<element signature="e#46975#49362#0#PHP" expanded="false" />
</folding>
</state>
</provider>
... ... @@ -81,7 +82,7 @@
<file leaf-file-name="Pay.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/api/controller/Pay.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="179">
<state relative-caret-position="372">
<caret line="247" column="31" lean-forward="false" selection-start-line="247" selection-start-column="31" selection-end-line="247" selection-end-column="31" />
<folding>
<element signature="e#450#569#0#PHP" expanded="false" />
... ... @@ -177,8 +178,8 @@
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds">
<option name="x" value="257" />
<option name="y" value="25" />
<option name="x" value="381" />
<option name="y" value="73" />
<option name="width" value="1806" />
<option name="height" value="974" />
</component>
... ... @@ -277,7 +278,7 @@
<workItem from="1574336957891" duration="1350000" />
<workItem from="1574382087071" duration="22007000" />
<workItem from="1574410294356" duration="15863000" />
<workItem from="1574469667436" duration="14388000" />
<workItem from="1574469667436" duration="21200000" />
</task>
<task id="LOCAL-00001" summary="调试">
<created>1574145133364</created>
... ... @@ -290,7 +291,7 @@
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="192198000" />
<option name="totallyTimeSpent" value="199010000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
... ... @@ -302,7 +303,7 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="257" y="25" width="1806" height="974" extended-state="0" />
<frame x="381" y="73" width="1806" height="974" extended-state="0" />
<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.15005727" 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" />
... ... @@ -685,7 +686,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/application/api/controller/Pay.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="179">
<state relative-caret-position="372">
<caret line="247" column="31" lean-forward="false" selection-start-line="247" selection-start-column="31" selection-end-line="247" selection-end-column="31" />
<folding>
<element signature="e#450#569#0#PHP" expanded="false" />
... ... @@ -708,8 +709,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/application/api/controller/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="303">
<caret line="282" column="37" lean-forward="true" selection-start-line="282" selection-start-column="37" selection-end-line="282" selection-end-column="37" />
<state relative-caret-position="274">
<caret line="1118" column="9" lean-forward="false" selection-start-line="1118" selection-start-column="9" selection-end-line="1118" selection-end-column="9" />
<folding>
<element signature="e#365#484#0#PHP" expanded="false" />
<element signature="e#490#1228#0#PHP" expanded="false" />
... ... @@ -721,6 +722,7 @@
<element signature="e#4973#5810#0#PHP" expanded="false" />
<element signature="e#5815#8010#0#PHP" expanded="false" />
<element signature="e#8016#8661#0#PHP" expanded="false" />
<element signature="e#8666#9762#0#PHP" expanded="false" />
<element signature="e#9768#10470#0#PHP" expanded="false" />
<element signature="e#10475#11675#0#PHP" expanded="false" />
<element signature="e#11681#12257#0#PHP" expanded="false" />
... ... @@ -753,17 +755,16 @@
<element signature="e#32644#34597#0#PHP" expanded="false" />
<element signature="e#32798#32884#0#PHP" expanded="false" />
<element signature="e#32973#33061#0#PHP" expanded="false" />
<element signature="e#34609#35369#0#PHP" expanded="false" />
<element signature="e#35374#37784#0#PHP" expanded="false" />
<element signature="e#37810#38641#0#PHP" expanded="false" />
<element signature="e#38647#39067#0#PHP" expanded="false" />
<element signature="e#39072#39555#0#PHP" expanded="false" />
<element signature="e#39561#40367#0#PHP" expanded="false" />
<element signature="e#40372#43526#0#PHP" expanded="false" />
<element signature="e#43541#44869#0#PHP" expanded="false" />
<element signature="e#44885#45912#0#PHP" expanded="false" />
<element signature="e#45919#46677#0#PHP" expanded="false" />
<element signature="e#46682#49069#0#PHP" expanded="false" />
<element signature="e#34603#35363#0#PHP" expanded="false" />
<element signature="e#38103#38934#0#PHP" expanded="false" />
<element signature="e#38940#39360#0#PHP" expanded="false" />
<element signature="e#39365#39848#0#PHP" expanded="false" />
<element signature="e#39854#40660#0#PHP" expanded="false" />
<element signature="e#40665#43819#0#PHP" expanded="false" />
<element signature="e#43834#45162#0#PHP" expanded="false" />
<element signature="e#45178#46205#0#PHP" expanded="false" />
<element signature="e#46212#46970#0#PHP" expanded="false" />
<element signature="e#46975#49362#0#PHP" expanded="false" />
</folding>
</state>
</provider>
... ...
... ... @@ -1042,9 +1042,7 @@ class User extends Api
}
}
/**
/**
* @ApiTitle (创建组合订单)
* @ApiSummary (创建组合订单)
* @ApiMethod (POST)
... ... @@ -1069,44 +1067,52 @@ class User extends Api
{
$param['user_id'] = $this->uid;
$video_id = explode(',',$this->request->post('video_id'));
$video_attr = explode(',',$this->request->post('video_attr'));
//接收视频ID加视频属性
$video_ids = $this->request->post('video_id');
$video_attrs = $this->request->post('video_attr');
$video_id = explode(',',$video_ids);
$video_attr = explode(',',$video_attrs);
$key = ['id','attr'];
$a = $this->array_merge_more($key,$video_id,$video_attr);
// print_r($a);die;
//接收图片的ID
$pic_id = explode(',',$this->request->post('pic_id'));
$where['user_id'] = ['eq',$param['user_id']];
$where['status'] = ['eq',2];
$res = Db::name('order')
->field('video_id')
->where($where)
->select();
foreach ($res as &$v){
$v['video_id'] = unserialize($v['video_id']);
if(!empty($v['video_id'])){
foreach ($v['video_id'] as $v1){
foreach ($a as &$v2){
if($v1['id'] == $v2['id'] && $v1['attr'] == $v2['attr']){
$this->error(['code'=>2,'msg'=>'该属性的视频已经购买过了','video_id'=>$v1['id']]);
if(!empty($video_ids) && !empty($video_attrs)){
$a = $this->array_merge_more($key,$video_id,$video_attr);
//查询视频ID
$res = Db::name('order')
->field('video_id')
->where($where)
->select();
foreach ($res as &$v){
$v['video_id'] = unserialize($v['video_id']);
if(!empty($v['video_id']) && !empty($a)){
foreach ($v['video_id'] as $v1){
foreach ($a as &$v2){
if($v1['id'] == $v2['id'] && $v1['attr'] == $v2['attr']){
$this->error(['code'=>2,'msg'=>'该属性的视频已经购买过了','video_id'=>$v2['id']]);
}
}
}
}
}
}
$param['video_id'] = serialize($a);
$arr = Db::name('order')
->field('id,pic_id')
->where($where)
->select();
foreach ($arr as &$v){
$v['pic_id'] = explode(',',$v['pic_id']);
$param['pic_id'] = explode(',',$this->request->post('pic_id'));
if(!empty($param['pic_id'])){
foreach ($param['pic_id'] as $v3){
if(in_array($v3['pic_id'],$v['pic_id'])){
$this->error(['code'=>2,'msg'=>'该图片已经购买过了','pic_id'=>$v3['pic_id']]);
$param['video_id'] = serialize($a);
}else{
//查询图片ID
$arr = Db::name('order')
->field('pic_id')
->where($where)
->select();
foreach ($arr as &$v){
$v['pic_id'] = explode(',',$v['pic_id']);
if(!empty($v['pic_id'])){
foreach ($pic_id as $v3){
if(in_array($v3,$v['pic_id'])){
$this->error(['code'=>2,'msg'=>'该图片已经购买过了','pic_id'=>$v3]);
}
}
}
}
... ...
... ... @@ -5529,7 +5529,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2019-11-23 13:45:04 </div>
Generated on 2019-11-23 15:38:40 </div>
<div class="col-md-6" align="right">
<a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
</div>
... ...