Commit cf6e99f5 authored by hujun's avatar hujun

首页弹窗

parent 27ff12b9
<?php
namespace app\api\controller;
use app\api\extend\Basic;
use app\model\CActivity;
use app\model\CCoupon;
use think\Request;
/**
......@@ -10,9 +12,40 @@ use think\Request;
* Time: 10:17
*/
class Coupon extends Basic{
private $m_coupon;
private $m_activity;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->m_coupon = new CCoupon();
$this->m_activity = new CActivity();
}
/**
* @return \think\Response
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function getHomeCoupon()
{
if (empty($this->userId)) {
// return $this->response(101, '请登录');
}
$data = [];
$where['user_id'] = $this->userId;
$where['user_id'] = 1;
$where['first_show'] = 0;
$coupon_data = $this->m_coupon->getCouponColumn('id,activity_id', $where);
if (!empty($coupon_data)) {
$activity_id = array_unique(array_values($coupon_data));
$coupon_id = array_keys($coupon_data);
$activity_where['id'] = ['in', $activity_id];
$data = $this->m_activity->getActivity('money,return_type,return_action', $activity_where);
// $this->m_coupon->updateData(['first_show'=>1], ['id'=>['in',$coupon_id]]);
}
return $this->response(200, '', $data);
}
}
\ No newline at end of file
......@@ -46,6 +46,24 @@ class CCoupon extends BaseModel
return $result;
}
/**
* @param $field
* @param $params
* @return array
*/
public function getCouponColumn($field,$params)
{
if (!isset($params['status'])) {
$params['status'] = 0;
}
$result = $this->db_
->where($params)
->column($field);
//dump($this->getLastSql());
return $result;
}
/**
* @param $where
* @param string $field
......@@ -69,6 +87,17 @@ class CCoupon extends BaseModel
return $result;
}
/**
* @param $data
* @param $where
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function updateData($data, $where) {
return $this->db_->where($where)->update($data);
}
/**
*
*/
......
......@@ -435,12 +435,10 @@ Route::group('api', [
'sendSms' => ['api/member/sendSms', ['method' => 'get']], //发送短信
'check_code' => ['api/member/check_code', ['method' => 'get']], //检测短信
'index' => ['api/member/index', ['method' => 'get']],
//get broker
'getHomeCoupon' => ['api/Coupon/getHomeCoupon', ['method' => 'get']],
'getBroker' => ['api/broker/index', ['method' => 'get']], //获取当前商铺或街铺的经纪人评论信息列表
'getBrokerV2' => ['api/broker/indexV2', ['method' => 'get']], //获取当前商铺或街铺的经纪人评论信息列表
'test' => ['api/broker/testtest', ['method' => 'get']], //获取当前商铺或街铺的经纪人评论信息列表
// 'test' => ['api/broker/testtest', ['method' => 'get']], //获取当前商铺或街铺的经纪人评论信息列表
'commentAndDeal' => ['api/broker/commentAndDeal', ['method' => 'get']], //获取当前经纪人的评价和交易列表
'brokerDetail' => ['api/broker/brokerDetail', ['method' => 'get']], //经纪人详情
//post broker
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment