diff --git a/admin/controllers/receiver/CluesCfrom.php b/admin/controllers/receiver/CluesCfrom.php new file mode 100644 index 00000000..591d2f7d --- /dev/null +++ b/admin/controllers/receiver/CluesCfrom.php @@ -0,0 +1,192 @@ + ['title' => '客户标签', 'url' => '/receiver/tag'], + 2 => ['title' => '车主标签', 'url' => '/receiver/ownersTag'], + 3 => ['title' => '战败标签', 'url' => '/receiver/tag?tag_type=1'], + 4 => ['title' => '意向标签', 'url' => '/receiver/tag?tag_type=2'] + ]; + + public function __construct() + { + parent::__construct(); + $this->load->model('receiver/receiver_clues_cfrom_model', 'mdCluesCfrom'); + } + + //首页信息 + 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 = []; + $where = ["status<>" => -1, 'pid' => 0]; + if (strlen($params['status'])) { + $where['status'] = $params['status']; + } + if ($params['title']) { + $where['title'] = $params['title']; + } + $count = $this->mdCluesCfrom->count($where); + if ($count) { + $res = $this->mdCluesCfrom->select($where, "c_time desc", $params['page'], $params['size']); + foreach ($res as $key => $value) { + $setValue = []; + $setValue['id'] = $value['id']; + $setValue['name'] = $value['title']; + $options = ''; + $res_cfrom = $this->mdCluesCfrom->select(["status<>" => -1, 'pid' => $value['id']], "c_time desc", 0, 0, 'title'); + $res_cfrom && $options = implode(',', array_column($res_cfrom, 'title')); + $setValue['options'] = $options; + $lists[] = $setValue; + } + } + $this->data['lists'] = $lists; + $this->data['params'] = $params; + $this->data['_title'] = '线索来源列表'; + $this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count); + return $this->show_view('receiver/cluescfrom/lists', true); + } + + public function get_options() + { + $id = intval($this->input->post('id')); + if (!$id) { + return $this->show_json(SYS_CODE_FAIL, '参数错误!'); + } + $res_tag = $this->mdCluesCfrom->select(["status" => 1, 'pid' => $id], "c_time desc", 0, 0, 'title as name'); + $this->data['lists'] = $res_tag; + return $this->show_json(SYS_CODE_SUCCESS); + } + + //展示单条数据 + public function get() + { + $id = intval($this->input->get('id')); + if ($id) { + $url = "receiver/CluesCfrom/edit"; + $re = $this->mdCluesCfrom->get(['id' => $id]); + if (!$re) { + return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); + } + $name = $re['title']; + } else { + $url = "receiver/CluesCfrom/add"; + $name = ''; + } + $this->data['showInfo'] = ['id' => $id, 'name' => $name, 'url' => $url]; + return $this->show_view('receiver/cluescfrom/edit'); + } + + //添加单条数据 + public function add() + { + $params = $this->input->post(); + if (!$params['name']) { + return $this->show_json(SYS_CODE_FAIL, '名称不能为空!'); + } + $re = $this->mdCluesCfrom->get(['name' => $params['name'], 'pid' => 0, "status<>" => -1]); + if ($re) { + return $this->show_json(SYS_CODE_FAIL, '名称已存在了!'); + } + $id = $this->mdCluesCfrom->add(['name' => $params['name'], 'c_time' => time()]); + if (!$id) { + return $this->show_json(SYS_CODE_FAIL, '保存失败'); + } + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + //编辑单条数据 + public function edit() + { + $params = $this->input->post(); + if (!$params['id']) { + return $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + if (!$params['name']) { + return $this->show_json(SYS_CODE_FAIL, '请输入名称'); + } + $re = $this->mdCluesCfrom->get(array('name' => $params['name'], 'pid' => 0, "status<>" => -1)); + if ($re && $re['id'] != $params['id']) { + return $this->show_json(SYS_CODE_FAIL, '名称已存在了!'); + } + $this->mdCluesCfrom->update(['name' => $params['name']], ['id' => $params['id']]); + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + //删除单条数据 + public function del() + { + $id = $this->input->post('id'); + if (!$id) { + $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + $re = $this->mdCluesCfrom->get(['id' => $id]); + if (!$re) { + return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); + } + $this->mdCluesCfrom->update(['status' => -1], ['id' => $id]); + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); + } + + //修改来源选项 + function edit_options() + { + $pid = $this->input->post('id'); + $options = $this->input->post('options'); + if (!$pid || !$options) { + return $this->show_json(SYS_CODE_FAIL, '参数错误!'); + } + $re = $this->mdCluesCfrom->get(['id' => $pid]); + if (!$re) { + return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); + } + $add_tag = $edit_tag = []; + foreach ($options as $key => $value) { + $data = ['name' => $value['name'], 'status' => $value['status']]; + if ($value['name']) { + if ($value['id']) {//修改 + $this->mdCluesCfrom->update($data, ['id' => $value['id']]); + } else {//新增 + $add_tag[] = ['name' => $value['name'], 'c_time' => time()]; + $data['pid'] = $pid; + $this->mdCluesCfrom->add($data); + } + } + } + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + function edit_status() + { + $id = $this->input->post('id'); + $stauts = intval($this->input->post('status')); + if (!$id) { + $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + $this->mdCluesCfrom->update(['status' => $stauts], ['id' => $id]); + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); + } + + //批量操作(默认修改状态) + public function batch() + { + + } + + //导出数据列表 + public function export() + { + + } +} \ No newline at end of file diff --git a/admin/views/receiver/cluescfrom/edit.php b/admin/views/receiver/cluescfrom/edit.php new file mode 100644 index 00000000..c73770c5 --- /dev/null +++ b/admin/views/receiver/cluescfrom/edit.php @@ -0,0 +1,31 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 越大越靠前 +
+
+
+ +
+
\ No newline at end of file diff --git a/admin/views/receiver/cluescfrom/lists.php b/admin/views/receiver/cluescfrom/lists.php new file mode 100644 index 00000000..f120ea33 --- /dev/null +++ b/admin/views/receiver/cluescfrom/lists.php @@ -0,0 +1,225 @@ +
+ +
+
共有条数据
+ + + + + + + + + + + + + + + + + + + + + + + + +
名称标签选项类型排序状态
+ 编辑选项 + 编辑标签 + + 关闭 + + + 开启 + + 删除 +
+ +
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/common/models/market/Market_sylive_activity_model.php b/common/models/market/Market_sylive_activity_model.php index 858af198..60cf3492 100644 --- a/common/models/market/Market_sylive_activity_model.php +++ b/common/models/market/Market_sylive_activity_model.php @@ -20,10 +20,11 @@ class Market_sylive_activity_model extends HD_Model * @param $mch_id * @return string|string[] */ - public function pay_config($mch_id=''){ + public function pay_config($mch_id = '') + { $conf_arr = [ - '1614399682' => APPPATH."../api/third_party/WXconfig/dcz_WxPay.Config.php", //东创紫联支付配置 - '1604032585' => APPPATH."../api/third_party/WXconfig/hdy_WxPay.Config.php", //好店云支付配置 + '1614399682' => APPPATH . "../api/third_party/WXconfig/dcz_WxPay.Config.php", //东创紫联支付配置 + '1604032585' => APPPATH . "../api/third_party/WXconfig/hdy_WxPay.Config.php", //好店云支付配置 ]; return $mch_id ? $conf_arr[$mch_id] : $conf_arr; } diff --git a/common/models/market/Market_sylive_blacklist_model.php b/common/models/market/Market_sylive_blacklist_model.php new file mode 100644 index 00000000..8de28430 --- /dev/null +++ b/common/models/market/Market_sylive_blacklist_model.php @@ -0,0 +1,11 @@ +table_name, 'default'); + } +} \ No newline at end of file diff --git a/common/models/market/Market_sylive_checkdata_model.php b/common/models/market/Market_sylive_checkdata_model.php new file mode 100644 index 00000000..e32256c8 --- /dev/null +++ b/common/models/market/Market_sylive_checkdata_model.php @@ -0,0 +1,18 @@ +table_name, 'default'); + } + +} \ No newline at end of file diff --git a/common/models/market/Market_sylive_customer_model.php b/common/models/market/Market_sylive_customer_model.php new file mode 100644 index 00000000..119d39d3 --- /dev/null +++ b/common/models/market/Market_sylive_customer_model.php @@ -0,0 +1,51 @@ +table_name, 'default'); + } + + /** + * Notes:回访标签 + * Created on: 2023/2/27 14:46 + * Created by: dengbw + * @param string $id + * @return array|mixed + */ + public function visitTagAry($id = '') + { + $arr = [1 => '无效', 2 => '战败', 3 => '高意向', 4 => '有意向', 5 => '低意向', 6 => '无意向']; + if (strlen($id)) { + return $arr[$id]; + } else { + return $arr; + } + } + + /** + * Notes:支付状态 + * Created on: 2022/9/26 14:46 + * Created by: dengbw + * @param string $status + * @return array|mixed + */ + public function statusAry($status = '') + { + $arr = [0 => '待分配', 1 => '待回访', 2 => '已回访']; + if (strlen($status)) { + return $arr[$status]; + } else { + return $arr; + } + } +} \ No newline at end of file diff --git a/market/controllers/api/sylive/Activity.php b/market/controllers/api/sylive/Activity.php index 2a61d338..73ff823d 100644 --- a/market/controllers/api/sylive/Activity.php +++ b/market/controllers/api/sylive/Activity.php @@ -21,6 +21,8 @@ class Activity extends BaseController $this->load->model('market/Market_sylive_activity_team_model', 'mdSyliveActivityTeam'); $this->load->model('market/Market_sylive_groups_model', 'mdSyliveGroups'); $this->load->model('market/Market_sylive_groups_user_model', 'mdSyliveGroupsUser'); + $this->load->model('market/Market_sylive_customer_model', 'mdSyliveCustomer'); + $this->load->model('market/Market_sylive_blacklist_model', 'mdSyliveBlacklist'); } /** @@ -60,11 +62,14 @@ class Activity extends BaseController $dateRange = $v['timeStart'] != '0000-00-00 00:00:00' ? [$v['timeStart'], $v['timeEnd']] : ''; $status = intval($v['status']); $activityId = intval($v['activityId']); - $bgImg = $channelImg = $banner = $sharePhoto = $shareImg = $shareTitle = $pay = $bottoms = []; + $bgImg = $channelImg = $banner = $sharePhoto = $shareImg = $shareTitle = $pay = $bottoms = $showBlacklist = []; $item = ['itemImg' => [], 'title' => '', 'introduction' => '', 'price' => '', 'stock' => '', 'dateRange' => '']; $coupon = ['img' => [], 'title' => '', 'rules' => '', 'price' => '', 'dateRange' => '']; $draw = ['bgImg' => [], 'sms' => '', 'winNum' => [], 'winType' => []]; $pay = ['way' => 1, 'price' => '', 'img' => []]; + $signBespeak = ['status' => 0, 'title' => '', 'content' => '', 'itemId' => '']; + $barrage = ['color' => 0, 'title' => '']; + $button = ['title' => '']; $v['shareTitle'] && $shareTitle = json_decode($v['shareTitle'], true); $jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : []; if ($jsondata['item']) { @@ -147,13 +152,16 @@ class Activity extends BaseController $re_gro = $this->mdSyliveGroups->get(['activityId' => $activityId, 'parentId' => 0, 'status>=' => 0]); $re_gro && $groups = 1; $blacklist = intval($jsondata['blacklist']); + $jsondata['signBespeak'] && $signBespeak = $jsondata['signBespeak']; + $jsondata['barrage'] && $barrage = $jsondata['barrage']; + $jsondata['button'] && $button = $jsondata['button']; //抽奖配置 $re_draw = $this->mdSyliveActivityDraw->get(['activityId' => $activityId]); if ($re_draw) { if ($re_draw['bgImg']) { $draw['bgImg'] = [['uid' => 1, 'fileUrl' => $re_draw['bgImg'], 'url' => build_qiniu_image_url($re_draw['bgImg']), 'status' => 'done']]; } - $re_draw['sms'] && $draw['sms'] = $re_draw['sms']; + $re_draw['sms'] && $draw['sms'] = $re_draw['sms']; $re_draw['winNum'] && $draw['winNum'] = json_decode($re_draw['winNum'], true); if ($re_draw['winType']) { $winType = []; @@ -166,12 +174,27 @@ class Activity extends BaseController $draw['winType'] = $winType; } } + //访问标签 + $visitTag = []; + $visitTagAry = $this->mdSyliveCustomer->visitTagAry(); + foreach ($visitTagAry as $k2 => $v2) { + $tag = $jsondata['visitTag'][$k2] ? $jsondata['visitTag'][$k2] : ''; + $visitTag[] = ['id' => $k2, 'title' => $v2, 'tag' => $tag]; + } + if ($blacklist) { + $res_bl = $this->mdSyliveBlacklist->select(['activityId' => $activityId], 'blacklistId desc', 0, 0, 'blacklistId,mobile'); + foreach ($res_bl as $k2 => $v2) { + $showBlacklist[] = ['id' => $v2['blacklistId'], 'mobile' => $v2['mobile'], 'type' => 'show']; + } + } $list[] = [ 'activityId' => $activityId, 'title' => $v['title'], 'channelId' => $v['channelId'], 'pay' => $pay, 'organizationId' => $organizationId, 'activityStart' => $activityStart, 'shareTitle' => $shareTitle, 'dateRange' => $dateRange, 'coupon' => $coupon, 'drawCode' => $v['drawCode'], 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'banner' => $banner, 'sharePhoto' => $sharePhoto, 'shareImg' => $shareImg, 'item' => $item, 'url' => $url, - 'mchId' => $v['mchId'], 'protocolTitle' => $v['protocolTitle'], 'protocol' => $v['protocol'], 'serviceLink' => $serviceLink, 'bottoms' => $bottoms, 'draw' => $draw - , 's_time' => $v['timeStart'], 'e_time' => $v['timeEnd'], 'status' => $status, 'groups' => $groups, 'blacklist' => $blacklist, 'createTime' => $v['createTime']]; + 'mchId' => $v['mchId'], 'protocolTitle' => $v['protocolTitle'], 'protocol' => $v['protocol'], 'serviceLink' => $serviceLink, + 'bottoms' => $bottoms, 'draw' => $draw, 'visitTag' => $visitTag, 'blacklist' => $blacklist, 'showBlacklist' => $showBlacklist, + 'signBespeak' => $signBespeak, 'barrage' => $barrage, 'button' => $button, + 's_time' => $v['timeStart'], 'e_time' => $v['timeEnd'], 'status' => $status, 'groups' => $groups, 'createTime' => $v['createTime']]; } } $date = ['list' => $list, 'count' => $count]; @@ -203,7 +226,7 @@ class Activity extends BaseController $serviceLink = $this->input_param('serviceLink'); $activityStart = $this->input_param('activityStart'); $bottoms = $this->input_param('bottoms'); - $blacklist = intval($this->input_param('blacklist')); + $signBespeak = $this->input_param('signBespeak'); if (!$title) { $this->return_json('请输入活动标题'); } @@ -251,7 +274,11 @@ class Activity extends BaseController $setBottoms[] = $v; } $jsondata['bottoms'] = $setBottoms; - $jsondata['blacklist'] = $blacklist; + $jsondata['blacklist'] = intval($this->input_param('blacklist')); + !$signBespeak['status'] && $signBespeak = ['status' => 0, 'title' => '', 'content' => '', 'itemId' => '']; + $jsondata['signBespeak'] = $signBespeak; + $jsondata['barrage'] = $this->input_param('barrage'); + $jsondata['button'] = $this->input_param('button'); $jsondata = json_encode($jsondata, JSON_UNESCAPED_UNICODE); $createTime = date('Y-m-d H:i:s'); $addData = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId, 'jsondata' => $jsondata @@ -298,7 +325,7 @@ class Activity extends BaseController $organizationId = intval($this->input_param('organizationId')); $activityStart = $this->input_param('activityStart'); $bottoms = $this->input_param('bottoms'); - $blacklist = intval($this->input_param('blacklist')); + $signBespeak = $this->input_param('signBespeak'); if (!$activityId) { $this->return_json('参数错误'); } @@ -347,7 +374,11 @@ class Activity extends BaseController $jsondata['pay'] = $pay; $jsondata['banner'] = $banner; $jsondata['serviceLink'] = $serviceLink; - $jsondata['blacklist'] = $blacklist; + $jsondata['blacklist'] = intval($this->input_param('blacklist')); + !$signBespeak['status'] && $signBespeak = ['status' => 0, 'title' => '', 'content' => '', 'itemId' => '']; + $jsondata['signBespeak'] = $signBespeak; + $jsondata['barrage'] = $this->input_param('barrage'); + $jsondata['button'] = $this->input_param('button'); $setBottoms = []; foreach ($bottoms as $v) { if ($v['urlType'] == 'link') { @@ -435,6 +466,51 @@ class Activity extends BaseController $this->return_response($groupsIds); } + /** + * Notes:活动信息 + * Created on: 2023/3/02 10:37 + * Created by: dengbw + */ + public function info_get() + { + $activityId = $this->input_param('activityId'); + $type = $this->input_param('type'); + if (!$activityId) { + $this->return_json('参数错误'); + } + $select = 'activityId,title,channelId'; + if ($type == 'customer') { + $select = 'title,jsondata'; + } + $re = $this->mdSyliveActivity->get(['activityId' => $activityId], $select); + if (!$re) { + $this->return_json('活动不存在'); + } + $info = []; + if ($type == 'customer') { + $info['title'] = $re['title']; + $statusAry = $visitTagAry = []; + $getStatusAry = $this->mdSyliveCustomer->statusAry(); + foreach ($getStatusAry as $k => $v) { + $statusAry[] = ['value' => $k, 'label' => $v]; + } + $jsonData = $re['jsondata'] ? json_decode($re['jsondata'], true) : []; + $getVisitTagAry = $this->mdSyliveCustomer->visitTagAry(); + foreach ($getVisitTagAry as $k => $v) { + $label = $v; + if ($jsonData['visitTag'][$k]) { + $label = $label . '(' . $jsonData['visitTag'][$k] . ')'; + } + $visitTagAry[] = ['value' => $k, 'label' => $label]; + } + $info['statusAry'] = $statusAry; + $info['visitTagAry'] = $visitTagAry; + } else { + $info = $re; + } + $this->return_response($info); + } + /** * Notes:活动详情 * Created on: 2022/9/29 10:37 @@ -582,6 +658,35 @@ class Activity extends BaseController $this->return_response(); } + /** + * Notes:修改回访标签 + * Created on: 2023/2/27 10:08 + * Created by: dengbw + */ + public function visit_tag_put() + { + $activityId = intval($this->input_param('activityId')); + if (!$activityId) { + $this->return_json('参数错误'); + } + $visitTag = $this->input_param('visitTag'); + $re = $this->mdSyliveActivity->get(['activityId' => $activityId], 'jsondata'); + $jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : []; + $setVisitTag = []; + if ($visitTag) { + foreach ($visitTag as $v) { + $v['tag'] && $setVisitTag[$v['id']] = $v['tag']; + } + } + $jsondata['visitTag'] = $setVisitTag ? $setVisitTag : []; + $upDate['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE); + $ret = $this->mdSyliveActivity->update($upDate, ['activityId' => $activityId]); + if (!$ret) { + $this->return_json('修改回访标签失败'); + } + $this->return_response(); + } + /** * Notes:修改抽奖配置 * Created on: 2023/1/30 10:08 @@ -627,4 +732,100 @@ class Activity extends BaseController $this->return_response(); } + /** + * Notes:修改黑名单 + * Created on: 2023/3/03 10:08 + * Created by: dengbw + */ + public function blacklist_put() + { + $activityId = intval($this->input_param('activityId')); + if (!$activityId) { + $this->return_json('参数错误'); + } + $blacklist = $this->input_param('blacklist'); + $addDate = []; + $delId = ''; + foreach ($blacklist as $v) { + if ($v['type'] == 'add' && $v['mobile']) { + $re = $this->mdSyliveBlacklist->get(['activityId' => $activityId, 'mobile' => $v['mobile']]); + if (!$re) { + $addDate[] = ['mobile' => $v['mobile'], 'activityId' => $activityId, 'createTime' => date('Y-m-d H:i:s')]; + } + } else if ($v['type'] == 'del' && $v['id']) { + $delId = $delId ? $delId . ',' . $v['id'] : $v['id']; + } + } + if (count($addDate)) { + $this->mdSyliveBlacklist->add_batch($addDate); + } + if ($delId) { + $this->mdSyliveBlacklist->delete(["blacklistId in({$delId})" => null]); + } + $this->return_response(); + } + + /** + * Notes:导入黑名单 + * Created on: 2023/3/06 17:24 + * Created by: dengbw + * @throws PHPExcel_Exception + * @throws PHPExcel_Reader_Exception + */ + public function blacklist_import_post() + { + require_once COMMPATH . '/third_party/PHPExcel/IOFactory.php'; + $res = $this->upload(); + if (!$res['code']) { + return $this->return_json($res['message']); + } + $file = $res['path']; + if ($res['file_ext'] == '.xls') { + $reader = \PHPExcel_IOFactory::createReader('Excel5'); // 读取 excel 文档 + } elseif ($res['file_ext'] == '.xlsx') { + $reader = \PHPExcel_IOFactory::createReader('Excel2007'); // 读取 excel 文档 + } else { + return $this->return_json('文件无法识别'); + } + $PHPExcel = $reader->load($file); // 文档名称 + $objWorksheet = $PHPExcel->getActiveSheet(); + $rowCnt = $objWorksheet->getHighestRow(); //获取总行数 + if ($rowCnt > 800) { + @unlink($file); + $this->return_json('数据大于800请拆分多个表格导入'); + } + $activityId = $_POST['activityId']; + $addDate = []; + for ($_row = 2; $_row <= $rowCnt; $_row++) { //读取内容 + $mobile = $objWorksheet->getCell('A' . $_row)->getValue(); + if ($mobile) { + $re = $this->mdSyliveBlacklist->get(['activityId' => $activityId, 'mobile' => $mobile]); + if (!$re) { + $addDate[] = ['mobile' => $mobile, 'activityId' => $activityId, 'createTime' => date('Y-m-d H:i:s')]; + } + } + } + $count = count($addDate); + if ($count) { + $this->mdSyliveBlacklist->add_batch($addDate); + } + @unlink($file); + $this->return_response('', "成功新增{$count}个黑名单"); + } + + private function upload() + { + $config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . '/temp/'; + $config['allowed_types'] = '*'; + $config['max_size'] = 5120; + $config['file_name'] = 'blacklist_' . time() . rand(1, 99999); + $this->load->library('upload', $config); + if (!$this->upload->do_upload('file')) { + return ['code' => SYS_CODE_FAIL, 'message' => $this->upload->display_errors('', '')]; + } else { + $data = $this->upload->data(); + return ['code' => SYS_CODE_SUCCESS, 'path' => $data['full_path'], 'file_ext' => $data['file_ext']]; + } + } + } diff --git a/market/controllers/api/sylive/Goods.php b/market/controllers/api/sylive/Goods.php index bff0d7d8..9826fa43 100644 --- a/market/controllers/api/sylive/Goods.php +++ b/market/controllers/api/sylive/Goods.php @@ -72,7 +72,8 @@ class Goods extends BaseController $list[] = ['itemId' => $v['itemId'], 'activityId' => $v['activityId'], 'title' => $v['title'], 'banner' => $banner , 'dateRange' => $dateRange, 'useRange' => $useRange, 'descrip' => $v['descrip'], 'price' => $v['price'], 'stock' => $v['stock'] , 'timeStart' => $timeStart, 'sort' => $v['sort'], 'status' => intval($v['status']), 'createTime' => $v['createTime'] - , 'ifAddress' => intval($v['ifAddress']), 'type' => intval($v['type']), 'typeName' => $this->mdSyliveItems->typeAry($v['type']), 'url' => $url]; + , 'ifAddress' => intval($v['ifAddress']), 'ifCode' => intval($v['ifCode']), 'type' => intval($v['type']), + 'typeName' => $this->mdSyliveItems->typeAry($v['type']), 'url' => $url]; } } $date = ['list' => $list, 'count' => $count]; @@ -88,9 +89,11 @@ class Goods extends BaseController { $activityId = intval($this->input_param('activityId')); $type = $this->input_param('type'); + $price = $this->input_param('price'); $where['status>='] = 0; $where['activityId'] = $activityId; strlen($type) && $where['type'] = $type; + strlen($price) && $where['price'] = $price; $list = $this->mdSyliveItems->select($where, 'sort asc,itemId desc', 0, 0, 'itemId,title'); $this->return_response_list($list); } @@ -110,6 +113,7 @@ class Goods extends BaseController $stock = $this->input_param('stock'); $sort = $this->input_param('sort'); $ifAddress = intval($this->input_param('ifAddress')); + $ifCode = intval($this->input_param('ifCode')); $dateRange = $this->input_param('dateRange'); $useRange = $this->input_param('useRange'); $type = intval($this->input_param('type')); @@ -120,7 +124,7 @@ class Goods extends BaseController $this->return_json('请输入商品标题'); } $addDate = ['activityId' => $activityId, 'title' => $title, 'price' => $price, 'stock' => $stock, 'sort' => $sort - , 'ifAddress' => $ifAddress, 'descrip' => $descrip, 'type' => $type, 'createTime' => date('Y-m-d H:i:s')]; + , 'ifAddress' => $ifAddress, 'ifCode' => $ifCode, 'descrip' => $descrip, 'type' => $type, 'createTime' => date('Y-m-d H:i:s')]; $addDate['timeStart'] = $dateRange[0] ? $dateRange[0] : '0000-00-00 00:00:00'; $addDate['timeEnd'] = $dateRange[1] ? $dateRange[1] : '0000-00-00 00:00:00'; $addDate['useStart'] = $useRange[0] ? $useRange[0] : '0000-00-00 00:00:00'; @@ -155,6 +159,7 @@ class Goods extends BaseController $stock = $this->input_param('stock'); $sort = intval($this->input_param('sort')); $ifAddress = intval($this->input_param('ifAddress')); + $ifCode = intval($this->input_param('ifCode')); $dateRange = $this->input_param('dateRange'); $useRange = $this->input_param('useRange'); $type = intval($this->input_param('type')); @@ -169,7 +174,7 @@ class Goods extends BaseController $this->return_json('商品不存在'); } $upDate = ['title' => $title, 'price' => $price, 'stock' => $stock, 'sort' => $sort - , 'ifAddress' => $ifAddress, 'descrip' => $descrip, 'type' => $type]; + , 'ifAddress' => $ifAddress, 'ifCode' => $ifCode, 'descrip' => $descrip, 'type' => $type]; $upDate['timeStart'] = $dateRange[0] ? $dateRange[0] : '0000-00-00 00:00:00'; $upDate['timeEnd'] = $dateRange[1] ? $dateRange[1] : '0000-00-00 00:00:00'; $upDate['useStart'] = $useRange[0] ? $useRange[0] : '0000-00-00 00:00:00'; diff --git a/market/controllers/api/sylive/GroupsCustomer.php b/market/controllers/api/sylive/GroupsCustomer.php new file mode 100644 index 00000000..94ff78d5 --- /dev/null +++ b/market/controllers/api/sylive/GroupsCustomer.php @@ -0,0 +1,287 @@ +load->model('market/Market_sylive_customer_model', 'mdSyliveCustomer'); + $this->load->model('market/Market_sylive_groups_model', 'mdSyliveGroups'); + $this->load->model('market/Market_sylive_groups_user_model', 'mdSyliveGroupsUser'); + $this->load->model('market/Market_sylive_user_model', 'mdSyliveUser'); + $this->load->model('market/Market_sylive_activity_model', 'mdSyliveActivity'); + } + + /** + * Notes:订单管理列表 + * Created on: 2022/12/08 14:48 + * Created by: dengbw + */ + public function index_get() + { + $date = $this->dataSelect($this->inputs); + $this->return_response_list($date); + } + + /** + * Notes:导出订单数据 + * Created on: 2022/12/08 15:26 + * Created by: dengbw + */ + public function export_get() + { + $this->inputs['page'] = 1; + $this->inputs['limit'] = 10000; + $date = $this->dataSelect($this->inputs); + $this->return_response_list($date); + } + + /** + * Notes:导入审核数据 + * Created on: 2023/2/22 17:24 + * Created by: dengbw + * @throws PHPExcel_Exception + * @throws PHPExcel_Reader_Exception + */ + public function import_post() + { + require_once COMMPATH . '/third_party/PHPExcel/IOFactory.php'; + $res = $this->upload(); + if (!$res['code']) { + return $this->return_json($res['message']); + } + $file = $res['path']; + if ($res['file_ext'] == '.xls') { + $reader = \PHPExcel_IOFactory::createReader('Excel5'); // 读取 excel 文档 + } elseif ($res['file_ext'] == '.xlsx') { + $reader = \PHPExcel_IOFactory::createReader('Excel2007'); // 读取 excel 文档 + } else { + return $this->return_json('文件无法识别'); + } + $PHPExcel = $reader->load($file); // 文档名称 + $objWorksheet = $PHPExcel->getActiveSheet(); + $rowCnt = $objWorksheet->getHighestRow(); //获取总行数 + if ($rowCnt > 800) { + @unlink($file); + $this->return_json('数据大于800请拆分多个表格导入'); + } + $activityId = $_POST['activityId']; + $done = 0; + for ($_row = 2; $_row <= $rowCnt; $_row++) { //读取内容 + $name = $objWorksheet->getCell('A' . $_row)->getValue(); + $mobile = $objWorksheet->getCell('B' . $_row)->getValue(); + $bizName = $objWorksheet->getCell('C' . $_row)->getValue(); + //$cfName = $objWorksheet->getCell('D' . $_row)->getValue(); + $cfMobile = $objWorksheet->getCell('E' . $_row)->getValue(); + $level = $objWorksheet->getCell('F' . $_row)->getValue(); + if ($mobile) { + $re = $this->mdSyliveCustomer->get(['activityId' => $activityId, 'mobile' => $mobile, 'status<>' => -1]); + if (!$re) { + !$name && $name = ''; + !$level && $level = ''; + $addData = ['activityId' => $activityId, 'name' => $name, 'mobile' => $mobile, 'level' => $level + , 'createTime' => date('Y-m-d H:i:s')]; + if ($cfMobile) { + $re_user = $this->mdSyliveUser->get(['mobile' => $cfMobile, 'organizationId>' => 0, 'status<>' => -1]); + if ($re_user['userId']) { + $addData['cfUserId'] = $re_user['userId']; + $re_groUser = $this->mdSyliveGroupsUser->get(['activityId' => $activityId, 'userId' => $re_user['userId'], 'status<>' => -1]); + if ($re_groUser['bizId']) { + $addData['status'] = 1; + $addData['bizId'] = $re_groUser['bizId']; + $addData['levelId1'] = $re_groUser['levelId1']; + $addData['levelId2'] = $re_groUser['levelId2']; + $addData['levelId3'] = $re_groUser['levelId3']; + } + } + } + if (!$addData['bizId'] && $bizName) { + $re_gro = $this->mdSyliveGroups->get(['activityId' => $activityId, 'groupsName' => $bizName, 'ifBiz' => 1, 'status<>' => -1]); + if ($re_gro['groupsId']) { + $addData['bizId'] = $re_gro['groupsId']; + $levelAry = $this->getLevelAry($re_gro['parentId']); + $levelAry['levelId1'] && $addData['levelId1'] = $levelAry['levelId1']; + $levelAry['levelId2'] && $addData['levelId2'] = $levelAry['levelId2']; + $levelAry['levelId3'] && $addData['levelId3'] = $levelAry['levelId3']; + } + } + $re_user = $this->mdSyliveUser->get(['mobile' => $mobile, 'status<>' => -1]); + if ($re_user['userId']) { + $addData['userId'] = $re_user['userId']; + } + $customerId = $this->mdSyliveCustomer->add($addData); + $customerId && $done++; + } + } + } + @unlink($file); + $this->return_response('', "成功新增{$done}个客户"); + } + + /** + * Notes:获取分组等级ID + * Created on: 2023/3/01 14:30 + * Created by: dengbw + * @param $groupsId + * @param array $data + * @return array + */ + private function getLevelAry($groupsId, $data = []) + { + $re = $this->mdSyliveGroups->get(['groupsId' => $groupsId], 'groupsId,parentId,groupsLevel'); + if (!$re) { + return $data; + } else { + if ($re['groupsLevel']) {//分类id + $levelId = "levelId" . $re['groupsLevel']; + $data[$levelId] = $re['groupsId']; + } + if ($re['parentId']) { + return $this->getLevelAry($re['parentId'], $data); + } else { + return $data; + } + } + } + + private function dataSelect($params) + { + $activityId = intval($params['activityId']); + $page = $params['page']; + $limit = $params['limit']; + $name = $params['name']; + $mobile = $params['mobile']; + $bizId = $params['bizId']; + $status = $params['status']; + $visitTagId = $params['visitTagId']; + $sort = $params['sort']; + $order = $params['order']; + !$page && $page = 1; + !$limit && $limit = 10; + $sort_order = 'customerId desc'; + if ($sort && $order) { + $sort_order = $sort . ' ' . $order; + } + $list = []; + if (strlen($status)) { + $where["status"] = $status; + } else { + $where["status>=0"] = null; + } + $activityId && $where['activityId'] = $activityId; + $name && $where['name LIKE "%' . trim($name) . '%"'] = null; + $mobile && $where['mobile LIKE "%' . trim($mobile) . '%"'] = null; + $visitTagId && $where['visitTagId'] = $visitTagId; + if ($bizId) { + $res_org = $this->mdSyliveGroups->get(["groupsId" => $bizId]); + if ($res_org) { + if ($res_org['groupsLevel']) { + $levelId = 'levelId' . $res_org['groupsLevel']; + $where[$levelId] = $bizId; + } else if ($res_org['parentId']) {//门店 + $where['bizId'] = $bizId; + } + } + } + if ($limit == 10000) { + $count = $limit; + } else { + $count = $this->mdSyliveCustomer->count($where); + } + if ($count) { + $re = $this->mdSyliveActivity->get(['activityId' => $activityId], 'jsondata'); + $jsonData = $re['jsondata'] ? json_decode($re['jsondata'], true) : []; + $visitTagAry = $this->mdSyliveCustomer->visitTagAry(); + $statusAry = $this->mdSyliveCustomer->statusAry(); + $res = $this->mdSyliveCustomer->select($where, $sort_order, $page, $limit); + foreach ($res as $v) { + $consultant = $this->consultantGet(['activityId' => $v['activityId'] + , 'levelId1' => $v['levelId1'], 'levelId2' => $v['levelId2'], 'levelId3' => $v['levelId3'] + , 'bizId' => $v['bizId'], 'cfUserId' => $v['cfUserId']]); + $status = intval($v['status']); + $statusName = $statusAry[$status]; + $visitTagName = '-'; + $visitTagId = $v['visitTagId']; + if ($visitTagId) { + $visitTagName = $visitTagAry[$visitTagId]; + if ($jsonData['visitTag'][$visitTagId]) { + $visitTagName = $visitTagName . '(' . $jsonData['visitTag'][$visitTagId] . ')'; + } + } + $item = [ + 'customerId' => $v['customerId'], 'name' => $v['name'], 'mobile' => $v['mobile'], 'level' => $v['level'] + , 'statusName' => $statusName, 'visitTagName' => $visitTagName, 'levelName1' => $consultant['levelName1'] + , 'levelName2' => $consultant['levelName2'], 'levelName3' => $consultant['levelName3'] + , 'stores' => $consultant['stores'], 'consultant' => $consultant['consultant'] + ]; + $list[] = $item; + } + } + if ($limit == 10000) { + return $list; + } else { + return ['list' => $list, 'count' => $count]; + } + } + + /** + * Notes:获取顾问信息 + * Created on: 2022/12/08 11:29 + * Created by: dengbw + * @param $params + * @return string + */ + private function consultantGet($params) + { + $stores = $consultant = $levelName1 = $levelName2 = $levelName3 = ''; + $levelId1 = intval($params['levelId1']); + $levelId2 = intval($params['levelId2']); + $levelId3 = intval($params['levelId3']); + $bizId = intval($params['bizId']); + $cfUserId = intval($params['cfUserId']); + if ($bizId) { + $res_org = $this->mdSyliveGroups->get(["groupsId" => $bizId]); + $res_org['groupsName'] && $stores = $res_org['groupsName']; + } + if ($levelId1) { + $res_org = $this->mdSyliveGroups->get(["groupsId" => $levelId1]); + $res_org['groupsName'] && $levelName1 = $res_org['groupsName']; + } + if ($levelId2) { + $res_org = $this->mdSyliveGroups->get(["groupsId" => $levelId2]); + $res_org['groupsName'] && $levelName2 = $res_org['groupsName']; + } + if ($levelId3) { + $res_org = $this->mdSyliveGroups->get(["groupsId" => $levelId3]); + $res_org['groupsName'] && $levelName3 = $res_org['groupsName']; + } + $re_user = $this->mdSyliveUser->get(['userId' => $cfUserId]); + $re_user['uname'] && $consultant = $re_user['uname']; + return ['stores' => $stores, 'consultant' => $consultant, 'levelName1' => $levelName1, + 'levelName2' => $levelName2, 'levelName3' => $levelName3]; + } + + private function upload() + { + $config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . '/temp/'; + $config['allowed_types'] = '*'; + $config['max_size'] = 5120; + $config['file_name'] = 'customer_' . time() . rand(1, 99999); + $this->load->library('upload', $config); + if (!$this->upload->do_upload('file')) { + return ['code' => SYS_CODE_FAIL, 'message' => $this->upload->display_errors('', '')]; + } else { + $data = $this->upload->data(); + return ['code' => SYS_CODE_SUCCESS, 'path' => $data['full_path'], 'file_ext' => $data['file_ext']]; + } + } + +} \ No newline at end of file diff --git a/market/controllers/api/sylive/GroupsExchange.php b/market/controllers/api/sylive/GroupsExchange.php new file mode 100644 index 00000000..730faa01 --- /dev/null +++ b/market/controllers/api/sylive/GroupsExchange.php @@ -0,0 +1,395 @@ +load->model('market/Market_sylive_order_model', 'mdSyliveOrder'); + $this->load->model('market/Market_sylive_checkdata_model', 'mdSyliveCheckdata'); + $this->load->model('market/Market_sylive_user_model', 'mdSyliveUser'); + $this->load->model('market/Market_sys_admin_model', 'mdSysAdmin'); + $this->load->model('market/Market_sylive_groups_model', 'mdSyliveGroups'); + $this->load->model('market/Market_sylive_activity_kpidata_model', 'mdSyliveActivityKpidata'); + $this->load->model('market/Market_sylive_items_model', 'mdSyliveItems'); + } + + /** + * Notes:订单管理列表 + * Created on: 2022/12/08 14:48 + * Created by: dengbw + */ + public function index_get() + { + $date = $this->orderList($this->inputs); + $this->return_response_list($date); + } + + /** + * Notes:导出订单数据 + * Created on: 2022/12/08 15:26 + * Created by: dengbw + */ + public function export_get() + { + $this->inputs['page'] = 1; + $this->inputs['limit'] = 10000; + $date = $this->orderList($this->inputs); + $this->return_response_list($date); + } + + /** + * Notes:操作详情 + * Created on: 2023/2/21 9:45 + * Created by: dengbw + */ + public function detail_get() + { + $cfId = intval($this->input_param('cfId')); + $type = intval($this->input_param('type')); + $ifCheckAry = [0 => '未审核', 1 => '通过', -1 => '驳回']; + $date = []; + $where = ['cfId' => $cfId, 'type' => $type]; + $res = $this->mdSyliveCheckdata->select($where, 'id DESC', 0, 0); + if ($res) { + $address = ''; + $re = $this->mdSyliveOrder->get(['id' => $cfId]); + if ($re['jsondata']) { + $jsondata = json_decode($re['jsondata'], true); + if ($jsondata['address']) { + $address = $jsondata['address']['region'] . $jsondata['address']['detail']; + } + } + $this->load->library('AliWuliu'); + $cfUids = implode(',', array_column($res, 'cfUid')); + $map_users = $cfUids ? $this->mdSyliveUser->map('userId', 'uname,nickname', ["userId in({$cfUids})" => null]) : []; + $adminUids = implode(',', array_column($res, 'adminUid')); + $map_admins = $adminUids ? $this->mdSysAdmin->map('userId', 'username,nickname', ["userId in({$adminUids})" => null]) : []; + foreach ($res as $v) { + $cfName = $adminName = $adminTime = ''; + $mapUser = $map_users[$v['cfUid']]; + if ($mapUser) { + $cfName = $mapUser['uname'] ? $mapUser['uname'] : $mapUser['nickname']; + } + $mapAdmin = $map_admins[$v['adminUid']]; + if ($mapAdmin) { + $adminName = $mapAdmin['nickname'] ? $mapAdmin['nickname'] : $mapAdmin['username']; + } + $jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : []; + $logistics = []; + if ($jsondata) { + $jsondata['adminTime'] && $adminTime = $jsondata['adminTime']; + $courierNo = $jsondata['courierNo']; + if ($courierNo) { + if (strstr($courierNo, 'SF') || strstr($courierNo, 'FW')) { + $re_order = $this->mdSyliveOrder->get(['id' => $v['cfId']]); + if ($re_order['mobile']) { + $courierNo = $courierNo . ':' . substr($re_order['mobile'], -4); + } + } + $re_wl = $this->aliwuliu->kdi($courierNo, '', $debug = false); + if ($re_wl['code'] == 1 && $re_wl['result']) { + $result = $re_wl['result']; + $expName = $result['expName'] ? $result['expName'] : '物流单号'; + $logistics[] = ['time' => $expName, 'status' => $jsondata['courierNo']]; + foreach ($result['list'] as $v2) { + $logistics[] = $v2; + } + } else { + $logistics[] = ['time' => '物流单号', 'status' => $jsondata['courierNo']]; + } + } + } + $cfTime = date('Y-m-d H:i:s', $v['createTime']); + $address = count($logistics) ? $address : ''; + $date[] = ['adminName' => $adminName, 'adminTime' => $adminTime, 'cfName' => $cfName, 'cfTime' => $cfTime + , 'logistics' => $logistics, 'descrip' => $v['descrip'], 'address' => $address + , 'ifCheckName' => $ifCheckAry[$v['ifCheck']]]; + } + } + $this->return_response_list($date); + } + + /** + * Notes:审核数据 + * Created on: 2023/2/21 14:43 + * Created by: dengbw + */ + public function status_put() + { + $cfId = intval($this->input_param('cfId')); + $type = intval($this->input_param('type')); + $useStatus = $this->input_param('useStatus'); + $descrip = $this->input_param('descrip'); + if (!$cfId) { + $this->return_json('参数错误'); + } + $ret = $this->updateCheck(['cfId' => $cfId, 'type' => $type, 'useStatus' => $useStatus, 'descrip' => $descrip]); + if (!$ret) { + $this->return_json('审核失败'); + } + $this->return_response(); + } + + /** + * Notes:导入审核数据 + * Created on: 2023/2/22 17:24 + * Created by: dengbw + * @throws PHPExcel_Exception + * @throws PHPExcel_Reader_Exception + */ + public function import_post() + { + require_once COMMPATH . '/third_party/PHPExcel/IOFactory.php'; + $res = $this->upload(); + if (!$res['code']) { + return $this->return_json($res['message']); + } + $file = $res['path']; + if ($res['file_ext'] == '.xls') { + $reader = \PHPExcel_IOFactory::createReader('Excel5'); // 读取 excel 文档 + } elseif ($res['file_ext'] == '.xlsx') { + $reader = \PHPExcel_IOFactory::createReader('Excel2007'); // 读取 excel 文档 + } else { + return $this->return_json('文件无法识别'); + } + $PHPExcel = $reader->load($file); // 文档名称 + $objWorksheet = $PHPExcel->getActiveSheet(); + $rowCnt = $objWorksheet->getHighestRow(); //获取总行数 + if ($rowCnt > 800) { + @unlink($file); + $this->return_json('数据大于800请拆分多个表格导入'); + } + $done = 0; + for ($_row = 2; $_row <= $rowCnt; $_row++) { //读取内容 + $sid = $objWorksheet->getCell('A' . $_row)->getValue(); + if ($sid) { + $re_order = $this->mdSyliveOrder->get(['sid' => $sid]); + $cfId = $re_order['id']; + if ($cfId) { + $useStatus = $objWorksheet->getCell('B' . $_row)->getValue(); + $descrip = ''; + if ($useStatus == '通过') { + $useStatus = 2; + $courierNo = $objWorksheet->getCell('C' . $_row)->getValue(); + $courierNo && $descrip = $courierNo; + } else { + $useStatus = 3; + $getDescrip = $objWorksheet->getCell('D' . $_row)->getValue(); + $getDescrip && $descrip = $getDescrip; + } + $getType = $objWorksheet->getCell('E' . $_row)->getValue(); + $type = $getType == '抽奖' ? 1 : 0; + $ret = $this->updateCheck(['cfId' => $cfId, 'type' => $type, 'useStatus' => $useStatus, 'descrip' => $descrip]); + if ($ret) { + $done++; + } + } + } + } + @unlink($file); + $this->return_response('', "成功审核{$done}条"); + } + + private function updateCheck($params = []) + { + $cfId = $params['cfId']; + $type = $params['type']; + $useStatus = $params['useStatus']; + $descrip = $params['descrip']; + $ifCheck = 0; + $jsonData['adminTime'] = date('Y-m-d H:i:s'); + if ($useStatus == 2) { + $ifCheck = 1; + $upDate['ifCheck'] = $ifCheck; + $jsonData['courierNo'] = $descrip; + } else if ($useStatus == 3) { + $ifCheck = -1; + $upDate['descrip'] = $descrip; + } + $upDate['ifCheck'] = $ifCheck; + $upDate['jsondata'] = json_encode($jsonData, JSON_UNESCAPED_UNICODE); + $re = $this->mdSyliveCheckdata->max('id', ['cfId' => $cfId, 'type' => $type]); + if ($re['id']) { + $this->mdSyliveCheckdata->update($upDate, ['id' => $re['id']]); + } + $upDate = []; + if ($type == 1) { + $upDate['winUseStatus'] = $useStatus; + } else { + $upDate['useStatus'] = $useStatus; + } + $ret = $this->mdSyliveOrder->update($upDate, ['id' => $cfId]); + return $ret; + } + + private function orderList($params) + { + $activityId = intval($params['activityId']); + $page = $params['page']; + $limit = $params['limit']; + $uname = $params['uname']; + $mobile = $params['mobile']; + $sort = $params['sort']; + $order = $params['order']; + $bizId = $params['bizId']; + $itemId = $params['itemId']; + !$page && $page = 1; + !$limit && $limit = 10; + $sort_order = 'id desc'; + if ($sort && $order) { + $sort_order = $sort . ' ' . $order; + } + $list = []; + $useType = intval($params['useType']); + $useStatus = intval($params['useStatus']); + if ($useType == 1) { + $exchangeName = '抽奖'; + if ($useStatus) { + $where['winUseStatus'] = $useStatus; + } else { + $where['winUseStatus>'] = 0; + } + } else { + $exchangeName = '订单'; + if ($useStatus) { + $where['useStatus'] = $useStatus; + } else { + $where['useStatus>'] = 0; + } + } + $activityId && $where['activityId'] = $activityId; + $itemId && $where['itemId'] = $itemId; + $uname && $where['uname LIKE "%' . trim($uname) . '%"'] = null; + $mobile && $where['mobile LIKE "%' . trim($mobile) . '%"'] = null; + if ($bizId) { + $res_org = $this->mdSyliveGroups->get(["groupsId" => $bizId]); + if ($res_org) { + if ($res_org['groupsLevel']) { + $levelId = 'levelId' . $res_org['groupsLevel']; + $where[$levelId] = $bizId; + } else if ($res_org['parentId']) {//门店 + $where['bizId'] = $bizId; + } + } + } + if ($limit == 10000) { + $count = $limit; + } else { + $count = $this->mdSyliveOrder->count($where); + } + if ($count) { + $res = $this->mdSyliveOrder->select($where, $sort_order, $page, $limit); + $itemIds = implode(',', array_column($res, 'itemId')); + $map_items = $this->mdSyliveItems->map('itemId', 'ifAddress', ["itemId in({$itemIds})" => null]); + foreach ($res as $v) { + $consultant = $this->consultantGet(['activityId' => $v['activityId'], 'userId' => $v['userId'] + , 'levelId1' => $v['levelId1'], 'levelId2' => $v['levelId2'], 'levelId3' => $v['levelId3'] + , 'bizId' => $v['bizId'], 'cfUserId' => $v['cfUserId']]); + $useStatus = $useType == 1 ? $v['winUseStatus'] : $v['useStatus']; + $useStatusName = '未审核'; + if ($useStatus == 2) { + $useStatusName = '通过'; + } else if ($useStatus == 3) { + $useStatusName = '驳回'; + } + $ifAddress = intval($map_items[$v['itemId']]); + $item = [ + 'id' => $v['id'], 'sid' => $v['sid'], 'uname' => $v['uname'], 'mobile' => $v['mobile'], 'itemTitle' => $v['itemTitle'] + , 'totalPrice' => $v['totalPrice'], 'payTime' => $v['payTime'] != '0000-00-00 00:00:00' ? $v['payTime'] : '' + , 'winTime' => $v['winTime'] ? $v['winTime'] : '', 'useStatusName' => $useStatusName, 'useStatus' => intval($useStatus) + , 'levelName1' => $consultant['levelName1'], 'levelName2' => $consultant['levelName2'], 'levelName3' => $consultant['levelName3'] + , 'stores' => $consultant['stores'], 'consultant' => $consultant['consultant'], 'exchangeName' => $exchangeName + , 'ifAddress' => $ifAddress + ]; + if ($limit == 10000) { + $address = $biz = ''; + $jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : []; + if ($jsondata['address']) { + $address = $jsondata['address']['region'] . $jsondata['address']['detail']; + } + if ($jsondata['biz']) { + $biz = $jsondata['biz']; + } + $item['address'] = $address; + $item['biz'] = $biz; + } + $list[] = $item; + } + } + if ($limit == 10000) { + return $list; + } else { + return ['list' => $list, 'count' => $count]; + } + } + + /** + * Notes:获取顾问信息 + * Created on: 2022/12/08 11:29 + * Created by: dengbw + * @param $params + * @return string + */ + private function consultantGet($params) + { + $stores = $consultant = $levelName1 = $levelName2 = $levelName3 = ''; + $levelId1 = intval($params['levelId1']); + $levelId2 = intval($params['levelId2']); + $levelId3 = intval($params['levelId3']); + $bizId = intval($params['bizId']); + $cfUserId = intval($params['cfUserId']); + if (!$bizId) { + $re = $this->mdSyliveActivityKpidata->get(['activityId' => $params['activityId'], 'userId' => $params['userId'], 'kpi' => 'order']); + if ($re) { + $levelId1 = $re['levelId1']; + $levelId2 = $re['levelId2']; + $levelId3 = $re['levelId3']; + $bizId = $re['bizId']; + $cfUserId = $re['cfUserId']; + } + } + $res_org = $this->mdSyliveGroups->get(["groupsId" => $bizId]); + $res_org['groupsName'] && $stores = $res_org['groupsName']; + if ($levelId1) { + $res_org = $this->mdSyliveGroups->get(["groupsId" => $levelId1]); + $res_org['groupsName'] && $levelName1 = $res_org['groupsName']; + } + if ($levelId2) { + $res_org = $this->mdSyliveGroups->get(["groupsId" => $levelId2]); + $res_org['groupsName'] && $levelName2 = $res_org['groupsName']; + } + if ($levelId3) { + $res_org = $this->mdSyliveGroups->get(["groupsId" => $levelId3]); + $res_org['groupsName'] && $levelName3 = $res_org['groupsName']; + } + $re_user = $this->mdSyliveUser->get(['userId' => $cfUserId]); + $re_user['uname'] && $consultant = $re_user['uname']; + return ['stores' => $stores, 'consultant' => $consultant, 'levelName1' => $levelName1, + 'levelName2' => $levelName2, 'levelName3' => $levelName3]; + } + + private function upload() + { + $config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . '/temp/'; + $config['allowed_types'] = '*'; + $config['max_size'] = 5120; + $config['file_name'] = 'exchange_' . time() . rand(1, 99999); + $this->load->library('upload', $config); + if (!$this->upload->do_upload('file')) { + return ['code' => SYS_CODE_FAIL, 'message' => $this->upload->display_errors('', '')]; + } else { + $data = $this->upload->data(); + return ['code' => SYS_CODE_SUCCESS, 'path' => $data['full_path'], 'file_ext' => $data['file_ext']]; + } + } + +} \ No newline at end of file diff --git a/www/market/temp/blacklist.xlsx b/www/market/temp/blacklist.xlsx new file mode 100644 index 00000000..beafbe12 Binary files /dev/null and b/www/market/temp/blacklist.xlsx differ diff --git a/www/market/temp/customer.xlsx b/www/market/temp/customer.xlsx new file mode 100644 index 00000000..ec65e507 Binary files /dev/null and b/www/market/temp/customer.xlsx differ diff --git a/www/market/temp/exchange.xlsx b/www/market/temp/exchange.xlsx new file mode 100644 index 00000000..f65aa64a Binary files /dev/null and b/www/market/temp/exchange.xlsx differ