作者 王晓刚
1 个管道 的构建 通过 耗费 14 秒

广告详情

... ... @@ -3,12 +3,10 @@
<component name="ChangeListManager">
<list default="true" id="309ad746-5b2a-4c29-af46-e7925a35765c" name="默认的" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/application/home/controller/Collect.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/home/controller/Collect.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/application/home/controller/Goods.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/home/controller/Goods.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/application/home/controller/Index.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/home/controller/Index.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/application/home/controller/User.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/home/controller/User.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/application/home/controller/Question.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/home/controller/Question.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/application/home/view/goods/content_detail.html" beforeDir="false" afterPath="$PROJECT_DIR$/application/home/view/goods/content_detail.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/public/assets/advertising/css/advDetail.css" beforeDir="false" afterPath="$PROJECT_DIR$/public/assets/advertising/css/advDetail.css" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
... ... @@ -25,29 +23,17 @@
<file leaf-file-name="index.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/home/view/index/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="476">
<state relative-caret-position="731">
<caret line="43" column="57" selection-start-line="43" selection-start-column="30" selection-end-line="43" selection-end-column="57" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="content_detail.html" pinned="false" current-in-tab="true">
<file leaf-file-name="content_detail.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/home/view/goods/content_detail.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="407">
<caret line="282" column="22" selection-start-line="282" selection-start-column="22" selection-end-line="282" selection-end-column="22" />
<folding>
<element signature="n#style#0;n#div#2;n#div#4;n#div#0;n#body#0;n#html#0;n#!!top" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="advDetail.css" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/public/assets/advertising/css/advDetail.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="305">
<caret line="40" column="37" selection-start-line="40" selection-start-column="37" selection-end-line="40" selection-end-column="37" />
<state relative-caret-position="1836">
<caret line="173" column="12" selection-start-line="173" selection-start-column="12" selection-end-line="173" selection-end-column="12" />
</state>
</provider>
</entry>
... ... @@ -55,17 +41,8 @@
<file leaf-file-name="User.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/home/controller/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="674">
<caret line="185" column="14" selection-start-line="185" selection-start-column="14" selection-end-line="185" selection-end-column="14" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="User.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/home/model/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="20" column="20" selection-start-line="20" selection-start-column="20" selection-end-line="20" selection-end-column="20" />
<state relative-caret-position="3026">
<caret line="187" column="56" selection-start-line="187" selection-start-column="56" selection-end-line="187" selection-end-column="56" />
</state>
</provider>
</entry>
... ... @@ -73,8 +50,8 @@
<file leaf-file-name="Index.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/home/controller/Index.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="623">
<caret line="123" column="52" selection-start-line="123" selection-start-column="52" selection-end-line="123" selection-end-column="52" />
<state relative-caret-position="2567">
<caret line="159" column="57" selection-start-line="159" selection-start-column="57" selection-end-line="159" selection-end-column="57" />
</state>
</provider>
</entry>
... ... @@ -82,17 +59,17 @@
<file leaf-file-name="Goods.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/home/controller/Goods.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="606">
<caret line="78" column="22" selection-start-line="78" selection-start-column="22" selection-end-line="78" selection-end-column="22" />
<state relative-caret-position="419">
<caret line="87" selection-start-line="87" selection-end-line="87" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Question.php" pinned="false" current-in-tab="false">
<file leaf-file-name="Question.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/application/home/controller/Question.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="510">
<caret line="46" column="13" selection-start-line="46" selection-start-column="13" selection-end-line="46" selection-end-column="13" />
<state relative-caret-position="606">
<caret line="115" column="16" selection-start-line="115" selection-start-column="16" selection-end-line="115" selection-end-column="16" />
</state>
</provider>
</entry>
... ... @@ -100,7 +77,7 @@
<file leaf-file-name="helper.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/thinkphp/helper.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="289">
<state relative-caret-position="4352">
<caret line="279" column="63" selection-start-line="279" selection-start-column="56" selection-end-line="279" selection-end-column="63" />
</state>
</provider>
... ... @@ -137,11 +114,14 @@
<find>sun_05</find>
<find>collect_img</find>
<find>bottom_collect</find>
<find>quest_ans</find>
<find>btn_all</find>
<find>btn_msg</find>
<find>quest_condition</find>
<find>detail_qust</find>
<find>right_btn</find>
<find>new_time</find>
<find>is_where_satisfy</find>
<find>quest_ans</find>
<find>quest_condition</find>
</findStrings>
<replaceStrings>
<replace />
... ... @@ -153,7 +133,6 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/application/admin/view/user_money_log/index.html" />
<option value="$PROJECT_DIR$/application/admin/controller/UserMoneyLog.php" />
<option value="$PROJECT_DIR$/public/assets/js/backend/user_money_log.js" />
<option value="$PROJECT_DIR$/application/admin/view/user_money_log_audit/index.html" />
... ... @@ -199,11 +178,12 @@
<option value="$PROJECT_DIR$/application/home/view/user/authorization_view.html" />
<option value="$PROJECT_DIR$/application/common/controller/WechatBase.php" />
<option value="$PROJECT_DIR$/application/home/controller/Collect.php" />
<option value="$PROJECT_DIR$/application/home/controller/Index.php" />
<option value="$PROJECT_DIR$/application/home/controller/Goods.php" />
<option value="$PROJECT_DIR$/public/assets/advertising/css/advDetail.css" />
<option value="$PROJECT_DIR$/application/home/controller/Index.php" />
<option value="$PROJECT_DIR$/application/home/controller/User.php" />
<option value="$PROJECT_DIR$/application/home/controller/Goods.php" />
<option value="$PROJECT_DIR$/application/home/view/goods/content_detail.html" />
<option value="$PROJECT_DIR$/application/home/controller/Question.php" />
</list>
</option>
</component>
... ... @@ -461,28 +441,8 @@
<workItem from="1572223206994" duration="28857000" />
<workItem from="1572309778506" duration="26117000" />
<workItem from="1572395935540" duration="28313000" />
<workItem from="1572483209367" duration="27197000" />
</task>
<task id="LOCAL-00010" summary="调试授权">
<created>1571979769963</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1571979769963</updated>
</task>
<task id="LOCAL-00011" summary="调试授权">
<created>1572329583925</created>
<option name="number" value="00011" />
<option name="presentableId" value="LOCAL-00011" />
<option name="project" value="LOCAL" />
<updated>1572329583925</updated>
</task>
<task id="LOCAL-00012" summary="调试授权">
<created>1572329761583</created>
<option name="number" value="00012" />
<option name="presentableId" value="LOCAL-00012" />
<option name="project" value="LOCAL" />
<updated>1572329761584</updated>
<workItem from="1572483209367" duration="35426000" />
<workItem from="1572568391799" duration="2840000" />
</task>
<task id="LOCAL-00013" summary="证书">
<created>1572331840264</created>
... ... @@ -806,27 +766,48 @@
<option name="project" value="LOCAL" />
<updated>1572507400807</updated>
</task>
<option name="localTasksCounter" value="59" />
<task id="LOCAL-00059" summary="广告详情">
<created>1572519039581</created>
<option name="number" value="00059" />
<option name="presentableId" value="LOCAL-00059" />
<option name="project" value="LOCAL" />
<updated>1572519039582</updated>
</task>
<task id="LOCAL-00060" summary="广告详情">
<created>1572519147942</created>
<option name="number" value="00060" />
<option name="presentableId" value="LOCAL-00060" />
<option name="project" value="LOCAL" />
<updated>1572519147942</updated>
</task>
<task id="LOCAL-00061" summary="广告详情">
<created>1572519181391</created>
<option name="number" value="00061" />
<option name="presentableId" value="LOCAL-00061" />
<option name="project" value="LOCAL" />
<updated>1572519181391</updated>
</task>
<option name="localTasksCounter" value="62" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="240735000" />
<option name="totallyTimeSpent" value="251804000" />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
<editor active="true" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.13965885" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="调试" order="7" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" weight="0.32997763" />
<window_info anchor="right" id="Database" order="3" />
<window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" order="7" show_stripe_button="false" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Terminal" order="7" weight="0.32997763" />
<window_info anchor="bottom" id="运行" order="7" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.1380597" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="right" id="Database" order="3" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="找到" order="8" weight="0.32997763" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
... ... @@ -841,26 +822,26 @@
</layout>
<layout-to-restore>
<window_info anchor="bottom" id="找到" order="14" weight="0.32997763" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="bottom" id="运行" order="10" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" order="8" show_stripe_button="false" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.1380597" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Database Changes" order="9" show_stripe_button="false" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="运行" order="10" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="right" id="Database" order="3" />
<window_info anchor="bottom" id="Terminal" order="11" weight="0.32997763" />
<window_info anchor="bottom" id="Event Log" order="12" side_tool="true" weight="0.32997763" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Database Changes" order="9" show_stripe_button="false" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="bottom" id="调试" order="13" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info id="Favorites" order="2" side_tool="true" />
</layout-to-restore>
</component>
... ... @@ -993,9 +974,6 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="776">
<caret line="178" column="5" lean-forward="true" selection-start-line="82" selection-start-column="4" selection-end-line="178" selection-end-column="5" />
<folding>
<element signature="e#40#74#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
... ... @@ -1003,9 +981,6 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="453">
<caret line="131" column="44" lean-forward="true" selection-start-line="131" selection-start-column="44" selection-end-line="131" selection-end-column="44" />
<folding>
<element signature="e#40#74#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
... ... @@ -1062,9 +1037,6 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="544">
<caret line="37" column="43" selection-start-line="37" selection-start-column="43" selection-end-line="37" selection-end-column="43" />
<folding>
<element signature="e#129#163#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
... ... @@ -1075,9 +1047,6 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="578">
<caret line="76" column="20" selection-start-line="76" selection-start-column="20" selection-end-line="76" selection-end-column="49" />
<folding>
<element signature="e#40#74#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
... ... @@ -1156,9 +1125,6 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
<caret line="63" selection-start-line="63" selection-end-line="63" selection-end-column="28" />
<folding>
<element signature="n#style#0;n#html#0;n#!!top" />
</folding>
</state>
</provider>
</entry>
... ... @@ -1171,18 +1137,11 @@
</entry>
<entry file="file://$PROJECT_DIR$/thinkphp/helper.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="289">
<state relative-caret-position="4352">
<caret line="279" column="63" selection-start-line="279" selection-start-column="56" selection-end-line="279" selection-end-column="63" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/home/view/index/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="476">
<caret line="43" column="57" selection-start-line="43" selection-start-column="30" selection-end-line="43" selection-end-column="57" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/home/controller/Collect.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="527">
... ... @@ -1190,60 +1149,64 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/home/controller/Question.php">
<entry file="file://$PROJECT_DIR$/application/home/controller/Member.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="510">
<caret line="46" column="13" selection-start-line="46" selection-start-column="13" selection-end-line="46" selection-end-column="13" />
</state>
<state relative-caret-position="-2142" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/home/controller/Goods.php">
<entry file="file://$PROJECT_DIR$/public/assets/advertising/css/advDetail.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="606">
<caret line="78" column="22" selection-start-line="78" selection-start-column="22" selection-end-line="78" selection-end-column="22" />
<state relative-caret-position="305">
<caret line="40" column="37" selection-start-line="40" selection-start-column="37" selection-end-line="40" selection-end-column="37" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/home/controller/Member.php">
<entry file="file://$PROJECT_DIR$/application/home/view/index/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-2142" />
<state relative-caret-position="731">
<caret line="43" column="57" selection-start-line="43" selection-start-column="30" selection-end-line="43" selection-end-column="57" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/home/controller/Index.php">
<entry file="file://$PROJECT_DIR$/application/home/model/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="623">
<caret line="123" column="52" selection-start-line="123" selection-start-column="52" selection-end-line="123" selection-end-column="52" />
<state relative-caret-position="238">
<caret line="20" column="20" selection-start-line="20" selection-start-column="20" selection-end-line="20" selection-end-column="20" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/public/assets/advertising/css/advDetail.css">
<entry file="file://$PROJECT_DIR$/application/home/controller/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="305">
<caret line="40" column="37" selection-start-line="40" selection-start-column="37" selection-end-line="40" selection-end-column="37" />
<state relative-caret-position="3026">
<caret line="187" column="56" selection-start-line="187" selection-start-column="56" selection-end-line="187" selection-end-column="56" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/home/model/User.php">
<entry file="file://$PROJECT_DIR$/application/home/controller/Index.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="20" column="20" selection-start-line="20" selection-start-column="20" selection-end-line="20" selection-end-column="20" />
<state relative-caret-position="2567">
<caret line="159" column="57" selection-start-line="159" selection-start-column="57" selection-end-line="159" selection-end-column="57" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/home/controller/User.php">
<entry file="file://$PROJECT_DIR$/application/home/controller/Goods.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="674">
<caret line="185" column="14" selection-start-line="185" selection-start-column="14" selection-end-line="185" selection-end-column="14" />
<state relative-caret-position="419">
<caret line="87" selection-start-line="87" selection-end-line="87" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/home/view/goods/content_detail.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="407">
<caret line="282" column="22" selection-start-line="282" selection-start-column="22" selection-end-line="282" selection-end-column="22" />
<folding>
<element signature="n#style#0;n#div#2;n#div#4;n#div#0;n#body#0;n#html#0;n#!!top" expanded="true" />
</folding>
<state relative-caret-position="1836">
<caret line="173" column="12" selection-start-line="173" selection-start-column="12" selection-end-line="173" selection-end-column="12" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/application/home/controller/Question.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="606">
<caret line="115" column="16" selection-start-line="115" selection-start-column="16" selection-end-line="115" selection-end-column="16" />
</state>
</provider>
</entry>
... ...
... ... @@ -72,11 +72,27 @@ class Goods extends WechatBase
if(empty($user)){
$this->error('查无此人');
}
//判断用户是否答过题
$is_answer = Db::name('user_question_answer')->where(['goods_id'=>$goods_id,'user_id'=>$this->user_id])->find();
if(empty($is_answer)){
$data['is_answer'] = 0;//未答过
}else{
$data['is_answer'] = 1;//答过题
}
//数据回显
$question = json_decode($data['question'],true);
foreach($question as $key => $q){
$user_question_answer = Db::name('user_question_answer')->where(['user_id'=>$this->user_id,'goods_id'=>$goods_id,'question_key'=>$key])->find();
$question[$key]['answer'] = $user_question_answer;
//判断答题是否全部正确
}
$data['question'] = $question;
//判断用户是否完成答题条件
if(empty($user['mobile']) || empty($user['name']) || empty($user['card'])){
$user['is_satisfy'] = 0;
$user['is_satisfy'] = 0;//不满足
}else{
$user['is_satisfy'] = 1;
$user['is_satisfy'] = 1;//满足
}
$this->assign('user',$user);
$this->assign('data',$data);
... ...
... ... @@ -104,6 +104,11 @@ class Index extends WechatBase
$this->success('SUCCESS','',$data);
}
/**
* 收藏操作
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function collect(){
$type = $this->request->param('type',0,'intval');
$goods_id = $this->request->param('goods_id',0,'intval');
... ... @@ -126,6 +131,58 @@ class Index extends WechatBase
$this->success('SUCCESS');
}
/**
* 判断距离是否满足条件
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function distance_where(){
$param = $this->request->param();
$validate = new \think\Validate([
'user_id' => 'require',
'longitude' => 'require',
'latitude' => 'require',
'goods_id' => 'require',
]);
$validate->message([
'user_id' => 'user_id参数错误',
'longitude.require' => 'longitude参数错误!',
'latitude.require' => 'latitude参数错误!',
'goods_id.require' => 'goods_id参数错误!',
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$goods = Db::name('goods')->where(['id'=>$param['goods_id']])->find();
$user = Db::name('user')->where(['id'=>$param['user_id']])->find();
$user['age'] = getAge($user['birthday']);//年龄
$distance = distance($goods,$param);//根据两地经纬度获取距离
$is_distance = 1;
//判断距离条件是否满足
if($goods['distance'] != 0){
if($distance > $goods['distance']){
$is_distance = 0;
$this->success('SUCCESS','',['is_where_satisfy'=>$is_distance]);
}
}
//判断性别
if($goods['sex'] != 0){
if($user['gender'] == $goods['sex']){
$is_distance = 0;
$this->success('SUCCESS','',['is_where_satisfy'=>$is_distance]);
}
}
//判断年龄是否满足
if($goods['min_age'] != 0 || $goods['max_age'] != 0){
if($goods['min_age'] <= $user['age'] && $user['age'] <= $goods['max_age']){
$is_distance = 0;
$this->success('SUCCESS','',['is_where_satisfy'=>$is_distance]);
}
}
$this->success('SUCCESS','',['is_where_satisfy'=>$is_distance]);
}
}
\ No newline at end of file
... ...
... ... @@ -16,7 +16,7 @@ use think\Db;
class Question extends WechatBase
{
/**
* 获取题
* 获取题(废弃)
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
... ... @@ -86,32 +86,35 @@ class Question extends WechatBase
* @throws \think\exception\PDOException
*/
public function push_answer(){
$question_ids = $this->request->param('question_ids');
$question_keys = $this->request->param('question_key');
$answers = $this->request->param('answers');
$goods_id = $this->request->param('goods_id',0,'intval');
$user_id = $this->request->param('user_id',0,'intval');
if(empty($question_ids) || empty($answers) || empty($types) || empty($goods_id) || empty($user_id)){
if(empty($question_keys) || empty($answers) || empty($types) || empty($goods_id) || empty($user_id)){
$this->error('404');
}
$user = Db::name('user')->where(['id'=>$user_id])->find();//用户信息
$goods = Db::name('goods')->where(['id'=>$goods_id])->find();//广告信息
$merchant = Db::name('user')->where(['id'=>$goods['user_id']])->find();//商户信息
$admin = Db::name('admin')->where(['id'=>$goods['admin_id']])->find();//商户信息
//判断广告信息是否过期
if($goods['end_time'] < time()){
$this->error('广告已过截止时间');
}
Db::startTrans();
//清空上次答题记录
$result1 = Db::name('question_user_answer')->where(['user_id'=>$user_id,'goods_id'=>$goods_id,['question_id'=>['in',$question_ids]]])->delete();
foreach($question_ids as $key => $question_id){
if(empty($queston_id)){
$this->error("第".($key+1)."个question_id不能为空");
$result1 = Db::name('question_user_answer')->where(['user_id'=>$user_id,'goods_id'=>$goods_id])->delete();
foreach($question_keys as $key => $question_key){
if(empty($question_key)){
$this->error("第".($key+1)."个question_key不能为空");
}
if(empty($answers[$key])){
$this->error("第".($key+1)."个answer不能为空");
}
//判断是否正确
$question = Db::name('question')->where(['id'=>$question_id])->find();
$question = json_decode($goods['question'],true);
if(empty($question[$question_key])){
}
if($question['question_answer'] == $answers[$key]){
$is_correct = 1;
}else{
... ... @@ -120,7 +123,7 @@ class Question extends WechatBase
}
$arr['user_id'] = $user_id;
$arr['goods_id'] = $goods_id;
$arr['question_id'] = $question_id;
$arr['question_id'] = $question_key;
$arr['answer'] = $answers[$key];
$arr['type'] = $question['type'];
$arr['is_correct'] = $is_correct;
... ... @@ -141,7 +144,7 @@ class Question extends WechatBase
$this->error('您已获得过该广告的奖励');
}
//判断商家余额是否够用
if($merchant['money'] < $goods['exp']){
if($admin['money'] < $goods['exp']){
$this->error('商家余额不足');
}
//用户获得奖励
... ... @@ -159,10 +162,10 @@ class Question extends WechatBase
}
$result4 = Db::name('user')->where(['id'=>$user_id])->update(['exp'=>$user['exp']+$goods['exp']]);
//扣除商家余额
$arr2['user_id'] = $merchant['id'];
$arr2['before_money'] = $merchant['money'];
$arr2['user_id'] = $admin['id'];
$arr2['before_money'] = $admin['money'];
$arr2['money'] = $goods['exp'];
$arr2['after_money'] = $merchant['money']-$goods['exp'];
$arr2['after_money'] = $admin['money']-$goods['exp'];
$arr2['type'] = 5;
$arr2['goods_id'] = $goods_id;
$arr2['createtime'] = time();
... ...
... ... @@ -25,8 +25,7 @@
<div class="detail_qust">
<div class="quest_box quest_ans">
<div class="quest_title">题目</div>
{php}$question = json_decode($data['question'],true);{/php}
{foreach name="$question" item="q"}
{foreach name="$data.question" item="q"}
{if condition="$q['question_type'] eq 2"}
<div class="quest_single">
<div class="question">
... ... @@ -133,11 +132,75 @@
</div>
{include file="public/js" /}
<script>
$(function(){
//全局变量
var goods_id = "{$data.id}";//用户id
var user_id = "{$user.id}";//广告id
var is_satisfy = "{$user.is_satisfy}";//是否满足答题条件(用户是否完善信息)
var is_where_satisfy = 0;//是否满足商户条件
var is_where_satisfy = '';//是否满足商户条件
var city = '';
var lat = '';
var lng = '';
//定位当前位置
var geolocation = new qq.maps.Geolocation("LQNBZ-F3L34-EQMUR-DILMD-LBR4Q-GDFOH", "myapp");
var positionNum = 0;
var options = {
timeout: 5000
};
function showPosition(position) {
city = position.city; //城市
lat = position.lat; //经度
lng = position.lng; //纬度
//保存到用户表
$.ajax({
url:"{:url('home/user/location')}",
type:"POST",
data:{'user_id':user_id,'longitude':lng,'latitude':lat},
success:function(res){
if(res.code == 1){
toast('定位成功');
}else{
toast('定位失败');
}
},
error:function(res){
toast('与服务器断开连接')
}
});
//判断商户条件是否满足
$.ajax({
url:"{:url('home/index/distance_where')}",
type:"POST",
data:{'user_id':user_id,'longitude':lng,'latitude':lat,'goods_id':goods_id},
success:function(res){
if(res.code == 1){
is_where_satisfy = res.data.is_where_satisfy;
if (is_satisfy == '1' && is_where_satisfy == '1') {
init();
}else{
$(".quest_condition").show();
}
}else{
toast('与服务器断开连接')
}
},
error:function(){
toast('与服务器断开连接');
}
});
}
function showErr() {
toast('定位失败');
};
//定位
geolocation.getLocation(showPosition, showErr, options);
// 观看X时间后出现题
function init(){
... ... @@ -155,18 +218,7 @@
}, timer);
}
function showQuest() {
// 是否满足答题条件
var satisfy = 2;
if (satisfy == 1) {
// 满足
$(".quest_ans").show()
} else {
$(".quest_condition").show()
}
};
// 判断是否完善信息
/*// 判断是否完善信息
var either = 1;
if (either == 1) {
// 未完善信息
... ... @@ -175,9 +227,9 @@
})
} else {
$(".btn_msg").addClass("btn_all");
}
}*/
// 查看更多 完善信息
// 查看更多
$(".btn_more").click(function() {
window.location.href = "{:url('home/index/index')}"
})
... ... @@ -188,7 +240,7 @@
$(this).find(".choice_img").attr("src", "__CDN__/assets/advertising/img/sun_07@2x.png");
$(this).siblings().find(".answer_word").removeClass("choice_ans");
$(this).siblings().find(".choice_img").attr("src", "__CDN__/assets/advertising/img/sun_06@2x.png");
})
});
... ... @@ -265,51 +317,9 @@
}
});
});
</script>
<script>
$(function(){
var city = '';
var lat = '';
var lng = '';
//定位当前位置
// 地图定位
var geolocation = new qq.maps.Geolocation("LQNBZ-F3L34-EQMUR-DILMD-LBR4Q-GDFOH", "myapp");
var positionNum = 0;
var options = {
timeout: 5000
};
function showPosition(position) {
alert(JSON.stringify(position));
city = position.city; //城市
lat = position.lat; //经度
lng = position.lng; //纬度
$.ajax({
url:"{:url('home/user/location')}",
type:"POST",
data:{'user_id':user_id,'longitude':lng,'latitude':lat},
success:function(res){
if(res.code == 1){
toast('定位成功');
}else{
toast('定位失败');
}
},
error:function(res){
toast('与服务器断开连接')
}
})
}
function showErr() {
toast('定位失败');
};
$(function() {
//定位
geolocation.getLocation(showPosition, showErr, options);
});
});
</script>
</body>
... ...
... ... @@ -180,7 +180,7 @@ input:disabled {
/* 导航栏 */
.nav {
position: fixed;
/*position: fixed;*/
bottom: 0;
left: 0;
width: 100%;
... ...