diff --git a/admin/controllers/app/liche/Blindbox.php b/admin/controllers/app/liche/Blindbox.php
new file mode 100644
index 00000000..bc426e9b
--- /dev/null
+++ b/admin/controllers/app/liche/Blindbox.php
@@ -0,0 +1,268 @@
+load->model('app/liche/app_liche_blind_box_model', 'mdBlindBox');
+ }
+
+ public function index()
+ {
+ return $this->lists();
+ }
+
+ public function lists()
+ {
+ $params = $this->input->get();
+ $params['page'] = $params['page'] ? intval($params['page']) : 1;
+ $params['size'] = $params['size'] ? intval($params['size']) : 20;
+ $lists = array();
+ $where = array('status>' => -1);
+ $count = $this->mdBlindBox->count($where);
+ if ($count) {
+ $this->load->library('MyEncryption');
+ $res = $this->mdBlindBox->select($where, 'id desc', $params['page'], $params['size']);
+ foreach ($res as $key => $value) {
+ $setValue = array();
+ $setValue['id'] = $value['id'];
+ $setValue['title'] = $value['title'];
+ $setValue['s_time'] = $value['s_time'];
+ $setValue['e_time'] = $value['e_time'];
+ $setValue['c_time'] = date('Y-m-d H:i', $value['c_time']);
+ $setValue['status_name'] = $this->mdBlindBox->statusAry($value['status']);
+ $url = http_host_com('home') . "/h5/syt/blindbox?skey=" . $this->myencryption->base64url_encode("id=" . $value['id']);
+ $setValue['url'] = urlencode($url);
+ $lists[] = $setValue;
+ }
+ }
+ $this->data['_title'] = '盲盒抽奖列表';
+ $this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
+ $this->data['lists'] = $lists;
+ $this->data['params'] = $params;
+ return $this->show_view('/app/liche/blindbox/lists', true);
+ }
+
+ public function get()
+ {
+ $params = $this->input->get();
+ $id = intval($params['id']);
+ $title = $time = $rule = $prizes_content = $prizes_note = $prizes_winning_ins = $share_desc = $bottom_word =
+ $bg_color = $lottery_num = '';
+ $bg_img = $share_img = ['value' => '', 'src' => ''];
+ $prizes_list = [];
+ if ($id > 0) {
+ $re = $this->mdBlindBox->get(array('id' => $id));
+ if (!$re || empty($re)) {
+ return $this->show_json(SYS_CODE_FAIL, '数据不存在!');
+ }
+ $_title = '编辑盲盒抽奖';
+ $dataInfo['editType'] = 0;
+ $dataInfo['edit_url'] = '/app/liche/blindbox/edit';
+ $dataInfo['status'] = $re['status'];
+ $title = $re['title'];
+ $re['s_time'] && $time = $re['s_time'] . " ~ " . $re['e_time'];
+ $lottery_num = $re['lottery_num'];
+ if ($re['jsondata']) {
+ $jsondata = json_decode($re['jsondata'], true);
+ if ($jsondata['bg_img']) {
+ $bg_img['value'] = $jsondata['bg_img'];
+ $bg_img['src'] = build_qiniu_image_url($jsondata['bg_img']);
+ }
+ $jsondata['bg_color'] && $bg_color = $jsondata['bg_color'];
+ $jsondata['share_desc'] && $share_desc = $jsondata['share_desc'];
+ if ($jsondata['share_img']) {
+ $share_img['value'] = $jsondata['share_img'];
+ $share_img['src'] = build_qiniu_image_url($jsondata['share_img']);
+ }
+ $jsondata['bottom_word'] && $bottom_word = $jsondata['bottom_word'];
+ $jsondata['rule'] && $rule = $jsondata['rule'];
+ }
+ if ($re['prizes']) {//奖品配置
+ $prizes = json_decode($re['prizes'], true);
+ $prizes_content = $prizes['content'];
+ $prizes_note = $prizes['note'];
+ $prizes_winning_ins = $prizes['winning_ins'];
+ foreach ($prizes['list'] as $key => $value) {
+ $value['img_src'] = $value['img_value'] ? build_qiniu_image_url($value['img_value']) : '';
+ $prizes_list[] = $value;
+ }
+ }
+ } else {
+ $_title = '新增盲盒抽奖';
+ $dataInfo['editType'] = 2;
+ $dataInfo['edit_url'] = '/app/liche/blindbox/add';
+ $dataInfo['status'] = 0;
+ }
+ $status_list = [];
+ foreach ($this->mdBlindBox->statusAry() as $key => $value) {
+ $status_list[] = array("id" => $key, "name" => $value);
+ }
+ $dataInfo['id'] = $id;
+ $dataInfo['title'] = $title;
+ $dataInfo['bg_img'] = $bg_img;
+ $dataInfo['bg_color'] = $bg_color;
+ $dataInfo['time'] = $time;
+ $dataInfo['lottery_num'] = $lottery_num;
+ $dataInfo['share_desc'] = $share_desc;
+ $dataInfo['share_img'] = $share_img;
+ $dataInfo['bottom_word'] = $bottom_word;
+ $dataInfo['rule'] = $rule;
+ $dataInfo['prizes_content'] = $prizes_content;
+ $dataInfo['prizes_note'] = $prizes_note;
+ $dataInfo['prizes_winning_ins'] = $prizes_winning_ins;
+ $this->data['info'] = $dataInfo;
+ $this->data['status_list'] = $status_list;
+ $this->data['prizes_list'] = $prizes_list;
+ $this->data['_title'] = $_title;
+ return $this->show_view('/app/liche/blindbox/edit', true);
+ }
+
+ public function add()
+ {
+ $info = $this->input->post('info');
+ $checkData = $this->checkData($info);
+ if (!$checkData['code']) {
+ return $this->show_json($checkData['code'], $checkData['msg']);
+ }
+ $re = $this->mdBlindBox->get(array("title" => $info['title'], "status<>" => -1));
+ if ($re) {
+ return $this->show_json(SYS_CODE_FAIL, '该标题已存在!');
+ }
+ $json_data['bg_img'] = $info['bg_img']['value'];
+ $json_data['bg_color'] = $info['bg_color'];
+ $json_data['share_desc'] = $info['share_desc'];
+ $json_data['share_img'] = $info['share_img']['value'];
+ $json_data['bottom_word'] = $info['bottom_word'];
+ $json_data['rule'] = $info['rule'];
+ $jsondata = json_encode($json_data, JSON_UNESCAPED_UNICODE);
+ $prizes['content'] = $info['prizes_content'];
+ $prizes['note'] = $info['prizes_note'];
+ $prizes['winning_ins'] = $info['prizes_winning_ins'];
+ $prizes_list = [];
+ foreach ($info['prizes_list'] as $key => $value) {
+ unset($value['img_src']);
+ $prizes_list[] = $value;
+ }
+ $prizes['list'] = $prizes_list;
+ $prizes = json_encode($prizes, JSON_UNESCAPED_UNICODE);
+ $addData = ["title" => $info['title'], "lottery_num" => $info['lottery_num'], "jsondata" => $jsondata, "prizes" => $prizes
+ , "status" => $info['status'], "c_time" => time()];
+ if ($info['time']) {
+ $time = explode(' ~ ', $info['time']);
+ $addData['s_time'] = $time[0];
+ $addData['e_time'] = $time[1];
+ }
+ $id = $this->mdBlindBox->add($addData);
+ if (!$id) {
+ return $this->show_json(SYS_CODE_FAIL, '新增失败!');
+ }
+ $this->data['type'] = 'add';
+ $this->data['id'] = $id;
+ return $this->show_json(SYS_CODE_SUCCESS, '新增成功!');
+ }
+
+ public function edit()
+ {
+ $info = $this->input->post('info');
+ $checkData = $this->checkData($info);
+ if (!$checkData['code']) {
+ return $this->show_json($checkData['code'], $checkData['msg']);
+ }
+ if (!$info['id']) {
+ return $this->show_json(SYS_CODE_FAIL, '参数错误!');
+ }
+ $json_data['bg_img'] = $info['bg_img']['value'];
+ $json_data['bg_color'] = $info['bg_color'];
+ $json_data['share_desc'] = $info['share_desc'];
+ $json_data['share_img'] = $info['share_img']['value'];
+ $json_data['bottom_word'] = $info['bottom_word'];
+ $json_data['rule'] = $info['rule'];
+ $jsondata = json_encode($json_data, JSON_UNESCAPED_UNICODE);
+ $prizes['content'] = $info['prizes_content'];
+ $prizes['note'] = $info['prizes_note'];
+ $prizes['winning_ins'] = $info['prizes_winning_ins'];
+ $prizes_list = [];
+ foreach ($info['prizes_list'] as $key => $value) {
+ unset($value['img_src']);
+ $prizes_list[] = $value;
+ }
+ $prizes['list'] = $prizes_list;
+ $prizes = json_encode($prizes, JSON_UNESCAPED_UNICODE);
+ $updateData = ["title" => $info['title'], "lottery_num" => $info['lottery_num'], "jsondata" => $jsondata, "prizes" => $prizes];
+ if ($info['time']) {
+ $time = explode(' ~ ', $info['time']);
+ $updateData['s_time'] = $time[0];
+ $updateData['e_time'] = $time[1];
+ }
+ $this->mdBlindBox->update($updateData, ['id' => $info['id']]);
+ $this->data['type'] = 'edit';
+ return $this->show_json(SYS_CODE_SUCCESS, '修改成功!');
+ }
+
+ /**
+ * Notes:修改状态
+ * Created on: 2020/8/24 11:12
+ * Created by: dengbw
+ * @return bool|void
+ */
+ public function edit_status()
+ {
+ $info = $this->input->post('info');
+ if (!$info['id']) {
+ return $this->show_json(SYS_CODE_FAIL, '参数错误!');
+ }
+ $this->mdBlindBox->update(array("status" => intval($info['status'])), array('id' => $info['id']));
+ return $this->show_json(SYS_CODE_SUCCESS, '操作成功!');
+ }
+
+
+ /**
+ * Notes:检查新增/修改数据
+ * Created on: 2020/8/20 11:59
+ * Created by: dengbw
+ * @param $info
+ * @return array
+ */
+ private function checkData($info)
+ {
+ $msg = '';
+ $code = SYS_CODE_FAIL;
+ if (!$info) {
+ $msg = '非法参数';
+ } else if (!$info['title']) {
+ $msg = '请输入标题';
+ } else if (!$info['bg_img']) {
+ $msg = '请上传背景图片';
+ } else if (!$info['bg_color']) {
+ $msg = '请上传背景颜色';
+ } else if (!$info['time']) {
+ $msg = '请选择活动时间';
+ } else if (!$info['rule']) {
+ $msg = '请输入其它事项';
+ } else {
+ $code = SYS_CODE_SUCCESS;
+ }
+ return array('code' => $code, 'msg' => $msg);
+ }
+
+ public function del()
+ {
+ }
+
+ public function batch()
+ {
+ // TODO: Implement batch() method.
+ }
+
+ public function export()
+ {
+ }
+}
\ No newline at end of file
diff --git a/admin/controllers/app/liche/Main.php b/admin/controllers/app/liche/Main.php
index 19352844..4fc91282 100644
--- a/admin/controllers/app/liche/Main.php
+++ b/admin/controllers/app/liche/Main.php
@@ -21,6 +21,7 @@ class Main extends HD_Controller
$this->load->model('bobing/bobing_user_model', 'mdBobingUser');
$this->load->model('app/user_accountlog_model');
$this->load->model('app/liche/app_liche_luckybag_users_model', 'mdLuckyBagUsers');
+ $this->load->model('app/liche/app_liche_blind_box_model', 'mdBlindBox');
}
public function index()
@@ -57,6 +58,15 @@ class Main extends HD_Controller
),
);
+ $value = $this->mdBlindBox->count(['status>' => -1]);
+ $list[] = array(
+ 'title' => '盲盒抽奖(个)',
+ 'value' => $value,
+ 'btns' => array(
+ array('name' => '查看详情', 'url' => '/app/liche/blindbox'),
+ ),
+ );
+
$value = $this->mdTopics->count(array('app_id' => $this->app_id));
$list[] = array(
'title' => '专题(个)',
diff --git a/admin/controllers/app/licheb/Userslog.php b/admin/controllers/app/licheb/Userslog.php
index 12600b46..73125bdd 100644
--- a/admin/controllers/app/licheb/Userslog.php
+++ b/admin/controllers/app/licheb/Userslog.php
@@ -58,7 +58,47 @@ class Userslog extends HD_Controller
private function dataBizSelect($params)
{
- $lists = $where = [];
+ $lists = $where = $where_c = $where_dt = [];
+ $same_day = 0;
+ if ($params['time']) {
+ $time = explode(' ~ ', $params['time']);
+ $time[0] == $time[1] && $same_day = 1;
+ if ($time[0]) {
+ $where["log_date>="] = $time[0];
+ $where_c["c_time>="] = strtotime("{$time[0]} 00:00:00");
+ $where_dt["dt_time>="] = "{$time[0]} 00:00:00";
+ }
+ if ($time[1]) {
+ $where["log_date<="] = $time[1];
+ $where_c["c_time<="] = strtotime("{$time[1]} 23:59:59");
+ $where_dt["dt_time<="] = "{$time[1]} 23:59:59";
+ }
+ } else {
+ $where_c["c_time>="] = strtotime("2022-04-15 00:00:00");
+ $where_dt["dt_time>="] = "2022-04-15 00:00:00";
+ }
+ //门店搜索
+ if (!$same_day && ($params['type'] || $params['biz_id'] || $params['city_id'] || $params['county_id'])) {
+ $where_cdt['status'] = 1;
+ $params['type'] && $where_cdt['type'] = $params['type'];
+ $params['biz_id'] && $where_cdt['id'] = $params['biz_id'];
+ $params['city_id'] && $where_cdt['city_id'] = $params['city_id'];
+ $params['county_id'] && $where_cdt['county_id'] = $params['county_id'];
+ $res_biz = $this->mdBiz->select($where_cdt, 'id desc', 0, 0, 'id');
+ if ($res_biz) {
+ $str_ids = implode(',', array_column($res_biz, 'id'));
+ $where_c["biz_id in ({$str_ids})"] = null;
+ $where_dt["biz_id in ({$str_ids})"] = null;
+ } else {
+ $where_c['biz_id'] = -2;
+ $where_dt['biz_id'] = -2;
+ }
+ }
+ if ($params['type']) {
+ $where["type"] = $params['type'];
+ } else {
+ $params['type'] = '';
+ }
if ($params['biz_id']) {
$where['biz_id'] = $params['biz_id'];
} else if ($params['city_id']) {
@@ -77,16 +117,6 @@ class Userslog extends HD_Controller
$params['county_id'] = '';
$params['biz_id'] = '';
}
- if ($params['type']) {
- $where["type"] = $params['type'];
- } else {
- $params['type'] = '';
- }
- if ($params['time']) {
- $time = explode(' ~ ', $params['time']);
- $time[0] && $where["log_date>="] = $time[0];
- $time[1] && $where["log_date<="] = $time[1];
- }
$total = $this->mdBizsLog->count($where);
$offlineSources = $this->mdCustomers->offlineSources();
if ($total) {
@@ -163,15 +193,29 @@ class Userslog extends HD_Controller
$customers = $c_num = $orders = 0;
$customers_info = $c_num_info = $orders_info = '';
foreach ($offlineSources as $k => $v) {
- $sum2 = $this->mdUsersLog->sum("customer_{$k}", $where);//客户数
- if ($sum2['customer_' . $k]) {//客户数
- $customers += $sum2['customer_' . $k];
- $customers_info .= "
{$v['name']}:{$sum2['customer_'.$k]}";
- }
- $sum2 = $this->mdUsersLog->sum("c_num_{$k}", $where);//进店人数
- if ($sum2['c_num_' . $k]) {
- $c_num += $sum2['c_num_' . $k];
- $c_num_info .= "
{$v['name']}:{$sum2['c_num_'.$k]}";
+ if ($same_day) {
+ $sum2 = $this->mdUsersLog->sum("customer_{$k}", $where);//客户数
+ if ($sum2['customer_' . $k]) {//客户数
+ $customers += $sum2['customer_' . $k];
+ $customers_info .= "
{$v['name']}:{$sum2['customer_'.$k]}";
+ }
+ $sum2 = $this->mdUsersLog->sum("c_num_{$k}", $where);//进店人数
+ if ($sum2['c_num_' . $k]) {
+ $c_num += $sum2['c_num_' . $k];
+ $c_num_info .= "
{$v['name']}:{$sum2['c_num_'.$k]}";
+ }
+ } else {
+ $count2 = $this->mdCustomers->count(array_merge($where_c, ['of_id' => $k]));//客户数
+ if ($count2) {
+ $customers += $count2;
+ $customers_info .= "
{$v['name']}:{$count2}";
+ }
+ $count2 = $this->mdCustomers->count(array_merge($where_dt, ['of_id' => $k]));//进店人数
+ if ($count2) {
+
+ $c_num += $count2;
+ $c_num_info .= "
{$v['name']}:{$count2}";
+ }
}
$sum2 = $this->mdUsersLog->sum("order_{$k}", $where);//订单数
if ($sum2['order_' . $k]) {
diff --git a/admin/views/app/liche/blindbox/edit.php b/admin/views/app/liche/blindbox/edit.php
new file mode 100644
index 00000000..4d31fadd
--- /dev/null
+++ b/admin/views/app/liche/blindbox/edit.php
@@ -0,0 +1,461 @@
+
| ID | +标题 | +开始时间 | +结束时间 | +创建时间 | +状态 | +
|---|---|---|---|---|---|
| = $v['id'] ?> | += $v['title'] ?> | += $v['s_time'] ?> | += $v['e_time'] ?> | += $v['c_time'] ?> | += $v['status_name'] ?> | +
| + 分享链接 + 编辑 + | +|||||