login_white = '';// $this->check_status = array();//用户状态校验 $this->check_mobile = array();//需要手机号 $this->check_headimg = array();//授权微信信息 $this->majia_white = array('get');//超级管理员披上马甲可操作权限 $this->load->model('app/liche/App_liche_cms_model', 'mdLicheCms'); $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); $this->load->model('auto/auto_brand_model', 'mdAutoBrand'); $this->load->model('auto/auto_series_model', 'mdAutoSeries'); $this->load->model('auto/auto_attr_model', 'mdAutoAttr'); $this->load->model("biz/biz_model", 'mdBiz'); $this->load->model('items/items_model', 'mdItems'); $this->app_id == 1 && $this->app_id = 2;//获取狸车宝数据 } /** * Notes:店铺首页 * Created on: 2021/10/12 11:47 * Created by: dengbw * @return array * @throws Exception */ protected function get() { $this->load->model("biz/biz_statistics_model", 'mdBizStatistics'); $biz_id = intval($this->input_param('biz_id')); $re = $this->mdBiz->get(array('id' => $biz_id, 'status' => 1)); if (!$re || empty($re)) { throw new Hd_exception('门店不存在', API_CODE_FAIL); } //加店铺浏览 $where_s = ['app_id' => $this->app_id, 'biz_id' => $biz_id, 'day' => date('Y-m-d')]; $re_s = $this->mdBizStatistics->get($where_s); if ($re_s) { $this->mdBizStatistics->update(['browse_num = browse_num+1' => null], $where_s); } else { $where_s['browse_num'] = 1; $this->mdBizStatistics->add($where_s); } $lists = []; $sql = "SELECT id,brand_id,s_id,v_id,cor_id,ori_price FROM lc_items WHERE biz_id={$biz_id} AND bill_time='0000-00-00 00:00:00' AND status<>0 GROUP BY cor_id ORDER BY in_time DESC"; $res = $this->mdItems->db->query($sql)->result_array(); $brand_ids = $s_ids = $attr_vids = array(); foreach ($res as $v) { $v['brand_id'] && !in_array($v['brand_id'], $brand_ids) && $brand_ids[] = $v['brand_id']; $v['s_id'] && !in_array($v['s_id'], $s_ids) && $s_ids[] = $v['s_id']; $v['v_id'] && !in_array($v['v_id'], $attr_vids) && $attr_vids[] = $v['v_id']; } $map_brand = $map_sery = $map_vid = array(); if ($brand_ids) { $str_ids = implode(',', $brand_ids); $where = array("id in ({$str_ids})" => null); $map_brand = $this->mdAutoBrand->map('id', 'name', $where); } if ($s_ids) { $str_ids = implode(',', $s_ids); $where = array("id in ({$str_ids})" => null); $map_sery = $this->mdAutoSeries->map('id', 'name', $where); } if ($attr_vids) { $str_ids = implode(',', $attr_vids); $where = array("id in ({$str_ids})" => null); $map_vid = $this->mdAutoAttr->map('id', 'title', $where); } foreach ($res as $key => $val) { $id = $img = ''; $re_attr = $this->mdAutoAttr->get(['id' => $val['cor_id']], 'jsondata'); if ($re_attr['jsondata']) { $jsondata = json_decode($re_attr['jsondata'], true); $jsondata['img'] && $img = build_qiniu_image_url($jsondata['img']); } $title = $map_brand[$val['brand_id']]; $map_sery[$val['s_id']] && $title .= '-' . $map_sery[$val['s_id']]; $map_vid[$val['v_id']] && $title .= '-' . $map_vid[$val['v_id']]; $where_l = ['target_id' => $val['brand_id'], 'position' => 2, 'status' => 1, 'e_time>=' => time()]; $re_l = $this->mdLicheCms->max('id', $where_l); $re_l['id'] && $id = $re_l['id']; $lists[] = [ 'cms_id' => $id, 'title' => $title, 'img' => $img, 'ori_price' => ['title' => '厂商指导价¥', 'value' => $val['ori_price']], ]; } $this->data['title'] = '店铺'; $this->data['bg_img'] = 'https://qs.haodian.cn/wechat_app/liche/storeInfo/theme.png'; $this->data['biz_name'] = '狸车· ' . $re['biz_name'] . '店'; $this->data['address'] = $re['address']; $this->data['lat'] = $re['lat']; $this->data['lng'] = $re['lng']; $this->data['lists'] = $lists; return $this->data; } /** * Notes:店铺素材库首页 * Created on: 2021/11/3 9:44 * Created by: dengbw * @return array * @throws Hd_exception */ protected function get_material() { $this->load->model('app/material/Material_biz_statistics_model', 'mdMaterialBizStatistics'); $this->load->model('app/material/Material_template_model', 'mdTemplate'); $this->load->model('app/material/Material_biz_model', 'mdMaterialBiz'); $biz_id = intval($this->input_param('biz_id')); $re = $this->mdBiz->get(array('id' => $biz_id, 'status' => 1)); if (!$re || empty($re)) { throw new Hd_exception('门店不存在', API_CODE_FAIL); } //加店铺浏览 $where_s = ['app_id' => $this->app_id, 'biz_id' => $biz_id, 't_id' => 0, 'day' => date('Y-m-d')]; $re_s = $this->mdMaterialBizStatistics->get($where_s); if ($re_s) { $this->mdMaterialBizStatistics->update(['browse_num = browse_num+1' => null], $where_s); } else { $where_s['browse_num'] = 1; $this->mdMaterialBizStatistics->add($where_s); } $auto_brands = $list = array(); if ($re['jsondata']) { $jsondata = json_decode($re['jsondata'], true); if ($jsondata['auto_brands']) { $brand_ids = implode(',', $jsondata['auto_brands']); $res_b = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1), "id desc", 0, 0, 'name'); $res_b && $auto_brands = array_column($res_b, 'name'); } } $where = ['a.status' => 1, 'b.app_id' => $this->app_id, 'b.biz_id' => $biz_id]; $this->mdTemplate->db->from('lc_material_template as a'); $this->mdTemplate->db->join('lc_material_biz as b', "b.t_id=a.id", 'left'); $this->mdTemplate->db->select('a.id, a.cover,b.biz_id,b.app_id'); $this->mdTemplate->db->where($where); $this->mdTemplate->db->order_by('a.id Desc'); $this->mdTemplate->db->limit(50); $res = $this->mdTemplate->db->get()->result_array(); foreach ($res as $key => $value) { $list[] = array( 'id' => $value['id'], 'cover' => $value['cover'] ? build_qiniu_image_url($value['cover']) : ''); } //统计浏览数 $re_s = $this->mdMaterialBizStatistics->sum('browse_num', ['app_id' => $this->app_id, 'biz_id' => $biz_id]); //$orders = $this->mdMaterialBizStatistics->count_order(array('c.biz_id' => $biz_id, 'c.cf_id' => $this->cf_id, 'c.status >=' => 0)); $this->data['title'] = '店铺'; $this->data['biz_name'] = $re['biz_name']; $this->data['address'] = $re['address']; $this->data['lat'] = $re['lat']; $this->data['lng'] = $re['lng']; $this->data['auto_brands'] = $auto_brands; //$this->data['statistics'] = $re_s['browse_num'] . '人浏览 | ' . $orders . '笔成交'; $this->data['statistics'] = $re_s['browse_num'] . '人浏览'; $this->data['topics'] = array('title' => '热门', 'list' => $list); return $this->data; } /** * Notes:预约报名 * Created on: 2021/10/12 17:51 * Created by: dengbw * @throws Hd_exception */ protected function put() { $biz_id = intval($this->input_param('biz_id')); $t_id = intval($this->input_param('t_id')); $type = $this->input_param('type'); if (!$biz_id || !$this->session['mobile']) { throw new Hd_exception('参数错误', API_CODE_FAIL); } $re_biz = $this->mdBiz->get(['id' => $biz_id, 'status' => 1]); if (!$re_biz) { return $this->Hd_exception(SYS_CODE_FAIL, '预约的门店不存在!'); } if ($type == 'biz') { $cf_id = 29; $cf_title = '自有资源'; } else { $cf_id = $this->cf_id; $cf_title = '素材推广'; } $add_data = [ 'name' => $this->session['uname'] ? $this->session['uname'] : '', 'mobile' => $this->session['mobile'], 'biz_id' => $biz_id, 'city_id' => $re_biz['city_id'], 'county_id' => $re_biz['county_id'], 'cf_title' => $cf_title, 'cf_id' => $cf_id, 't_id' => $t_id, 'p_time' => date('Y-m-d H:i:s'), 'c_time' => time() ]; $where = ['biz_id' => $biz_id, 'mobile' => $add_data['mobile'], 'cf_id' => $add_data['cf_id']]; $t_id && $where['t_id'] = $t_id; $re_cus = $this->mdCustomers->get($where); if ($re_cus) { //throw new Hd_exception('您已经预约报名了', API_CODE_FAIL); throw new Hd_exception('预约报名成功了!', API_CODE_SUCCESS); } $id = $this->mdCustomers->add($add_data); if (!$id) { throw new Hd_exception('预约报名失败!', API_CODE_FAIL); } throw new Hd_exception('预约报名成功!', API_CODE_SUCCESS); } }