diff --git a/admin/controllers/Common.php b/admin/controllers/Common.php index 76cc6188..3e3ffd0e 100644 --- a/admin/controllers/Common.php +++ b/admin/controllers/Common.php @@ -1061,9 +1061,12 @@ class Common extends CI_Controller } else if ($type == 'customer') { $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); $re = $this->mdCustomers->get(array('id' => $id)); + } else if ($type == 'owners') { + $this->load->model('receiver/receiver_owners_model', 'mdOwners'); + $re = $this->mdOwners->get(array('id' => $id)); } if (!$re['mobile']) { - return $this->show_json(SYS_CODE_FAIL, '客户不存在!'); + return $this->show_json(SYS_CODE_FAIL, '手机不存在!'); } $mobile = $re['mobile']; $content = ''; @@ -1095,9 +1098,12 @@ class Common extends CI_Controller } else if ($type == 'customer') { $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); $re = $this->mdCustomers->get(array('id' => $id)); + } else if ($type == 'owners') { + $this->load->model('receiver/receiver_owners_model', 'mdOwners'); + $re = $this->mdOwners->get(array('id' => $id)); } if (!$re['mobile']) { - return $this->show_json(SYS_CODE_FAIL, '客户不存在!'); + return $this->show_json(SYS_CODE_FAIL, '手机不存在!'); } $mobile = $re['mobile']; if (!$content) { @@ -1140,6 +1146,9 @@ class Common extends CI_Controller } else if ($type == 'customer') { $this->load->model('receiver/receiver_customer_oplogs_model', 'mdOplogs'); $data['customer_id'] = $id; + } else if ($type == 'owners') { + $this->load->model('receiver/receiver_owners_oplogs_model', 'mdOplogs'); + $data['own_id'] = $id; } $this->mdOplogs->add($data);//增加操作记录 } @@ -1170,9 +1179,12 @@ class Common extends CI_Controller } else if ($type == 'customer') { $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); $re = $this->mdCustomers->get(array('id' => $id)); + } else if ($type == 'owners') { + $this->load->model('receiver/receiver_owners_model', 'mdOwners'); + $re = $this->mdOwners->get(array('id' => $id)); } if (!$re['mobile']) { - return $this->show_json(SYS_CODE_FAIL, '客户不存在!'); + return $this->show_json(SYS_CODE_FAIL, '手机不存在!'); } $mobile = $re['mobile']; $cache = &load_cache('redis'); diff --git a/admin/controllers/receiver/Owners.php b/admin/controllers/receiver/Owners.php new file mode 100644 index 00000000..9e76b3f9 --- /dev/null +++ b/admin/controllers/receiver/Owners.php @@ -0,0 +1,399 @@ + '车主电话', 'name' => '车主姓名', 'car_num' => '车牌号'); + private $searchTimeAry = array('c_time' => '创建时间', 'order_time' => '购车时间', 'ck_time' => '交付时间', 'u_time' => '最后操作时间'); + protected $log_dir; + + public function __construct() + { + parent::__construct(); + $this->load->model('receiver/receiver_owners_model', 'mdOwners'); + $this->load->model('receiver/receiver_owners_oplogs_model', 'mdOwnersOplogs'); + $this->load->model('receiver/receiver_owners_tag_model', 'mdOwnersTag'); + $this->load->model('receiver/receiver_owners_tagdata_model', 'mdOwnersTagdata'); + $this->load->model('receiver/receiver_xz_model'); + $this->log_dir = 'receiver_' . get_class($this); + } + + public function index() + { + return $this->lists(); + } + + public function lists() + { + $params = $this->input->get(); + $page = $params['page'] = $params['page'] ? intval($params['page']) : 1; + $size = $params['size'] = $params['size'] ? intval($params['size']) : 20; + $where = array('status>=0' => null); + if ($params['title']) { + $where["{$params['search_tp']} like '%{$params['title']}%'"] = null; + } + !$params['search_tp'] && $params['search_tp'] = 'mobile'; + if ($params['c_time']) { + $c_time = explode(' ~ ', $params['c_time']); + $c_time[0] && $where["c_time >="] = strtotime($c_time[0] . ' 00:00:00'); + $c_time[1] && $where["c_time <="] = strtotime($c_time[1] . ' 23:59:59'); + } + if ($params['order_time']) { + $order_time = explode(' ~ ', $params['order_time']); + $order_time[0] && $where["order_time >="] = $order_time[0] . ' 00:00:00'; + $order_time[1] && $where["order_time <="] = $order_time[1] . ' 23:59:59'; + } + if ($params['ck_time']) { + $ck_time = explode(' ~ ', $params['ck_time']); + $ck_time[0] && $where["ck_time >="] = $ck_time[0] . ' 00:00:00'; + $ck_time[1] && $where["ck_time <="] = $ck_time[1] . ' 23:59:59'; + } + if ($params['u_time']) { + $u_time = explode(' ~ ', $params['u_time']); + $u_time[0] && $where["u_time >="] = $u_time[0] . ' 00:00:00'; + $u_time[1] && $where["u_time <="] = $u_time[1] . ' 23:59:59'; + } + if ($params['sex']) { + $where["sex"] = $params['sex']; + } else { + $params['sex'] = ''; + } + if ($params['brand_id']) { + $where["brand_id"] = $params['brand_id']; + } else { + $params['brand_id'] = ''; + } + if ($params['s_id']) { + $where["s_id"] = $params['s_id']; + } else { + $params['s_id'] = ''; + } + if ($params['v_id']) { + $where["v_id"] = $params['v_id']; + } else { + $params['v_id'] = ''; + } + $count = $this->mdOwners->count($where); + $lists = []; + if ($count) { + $this->load->model('auto/auto_brand_model', 'mdBrand'); + $this->load->model('auto/auto_series_model', 'mdSeries'); + $this->load->model('auto/auto_attr_model', 'mdAttr'); + $res = $this->mdOwners->select($where, 'id desc', $page, $size); + + $str_brand_ids = implode(',', array_unique(array_column($res, 'brand_id'))); + $map_brands = $this->mdBrand->map('id', 'name', ["id in({$str_brand_ids})" => null]); + $str_s_ids = implode(',', array_unique(array_column($res, 's_id'))); + $map_series = $this->mdSeries->map('id', 'name', ["id in({$str_s_ids})" => null]); + $str_v_ids = implode(',', array_unique(array_column($res, 'v_id'))); + $map_attrs = $this->mdAttr->map('id', 'title', ["id in({$str_v_ids})" => null]); + + foreach ($res as $key => $val) { + if (SUPER_ADMIN == $this->role || $this->role == 35) { + $mobile_sub = $val['mobile']; + } else { + $mobile_sub = $val['mobile'] ? substr_replace($val['mobile'], '*****', 0, 5) : ''; + } + $sex = $car_name = ''; + if ($val['sex']) { + $sex = $val['sex'] == 1 ? '男' : '女'; + } + $map_brands[$val['brand_id']] && $car_name = $map_brands[$val['brand_id']]; + $map_series[$val['s_id']] && $car_name = $car_name ? $car_name . '-' . $map_series[$val['s_id']] : $map_series[$val['s_id']]; + $map_attrs[$val['v_id']] && $car_name = $car_name ? $car_name . '-' . $map_attrs[$val['v_id']] : $map_attrs[$val['v_id']]; + $lists[] = array( + 'id' => $val['id'], + 'name' => $val['name'], + 'mobile' => $val['mobile'], + 'mobile_sub' => $mobile_sub, + 'sex' => $sex, + 'age' => $this->getAgeByBirth($val['birth_day']), + 'car_name' => $car_name, + 'car_num' => $val['car_num'], + 'order_time' => $val['order_time'] != '0000-00-00 00:00:00' ? $val['order_time'] : '', + 'ck_time' => $val['ck_time'] != '0000-00-00 00:00:00' ? $val['ck_time'] : '', + ); + } + } + $this->data['lists'] = $lists; + $this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); + $this->data['searchTpAry'] = $this->searchTpAry; + $this->data['searchTimeAry'] = $this->searchTimeAry; + $this->data['params'] = $params; + $this->data['_title'] = '车主列表'; + return $this->show_view('receiver/owners/lists', true); + } + + public function get() + { + $id = $this->input->get('id'); + $row = $this->mdOwners->get(array('id' => $id)); + if (!$row) { + return $this->show_json(SYS_CODE_FAIL, '车主不存在!'); + } + //用户信息 + if (SUPER_ADMIN == $this->role || 35 == $this->role) { + $mobile_sub = $row['mobile']; + } else { + $mobile_sub = $row['mobile'] ? substr_replace($row['mobile'], '*****', 0, 5) : ''; + } + $info = $row; + $info['mobile'] = $mobile_sub; + $info['order_time'] = $row['order_time'] != '0000-00-00 00:00:00' ? $row['order_time'] : ''; + $info['ck_time'] = $row['ck_time'] != '0000-00-00 00:00:00' ? $row['ck_time'] : ''; + $info['c_time'] = date('Y-m-d H:i:s', $row['c_time']); + $info['tag'] = $this->get_tag($row['id']); + //操作日志 + $rows_log = $this->mdOwnersOplogs->select(array('own_id' => $id), 'id desc', 0, 0); + $logs = []; + foreach ($rows_log as $key => $value) { + $rec_text = $rec_url = ''; + if ($value['type'] == 2) { + $rec_row = $this->receiver_xz_model->get(['id' => $value['log']], 'rec_url,duration'); + if ($rec_row['duration']) { + $rec_row['rec_url'] && $rec_url = $rec_row['rec_url']; + !$rec_row['rec_url'] && $rec_text = '录音暂未生成'; + } else { + $rec_text = '未接通'; + } + } + $imgs = []; + if ($value['imgs']) { + $json_imgs = json_decode($value['imgs'], true); + foreach ($json_imgs as $key1 => $value1) { + $imgs[] = build_qiniu_image_url($value1); + } + } + $logs[] = array( + 'uname' => $value['uname'], + 'log' => $value['log'], + 'imgs' => $imgs, + 'rec_url' => $rec_url, + 'rec_text' => $rec_text, + 'type_name' => $this->mdOwnersOplogs->typeAry()[$value['type']], + 'c_time' => date('Y-m-d H:i', $value['c_time']) + ); + } + $this->data['info'] = $info; + $this->data['logs'] = $logs; + $this->data['_title'] = '车主户详情'; + return $this->show_view('receiver/owners/get', true); + } + + public function add() + { + // TODO: Implement add() method. + } + + /** + * 新增日志 + * @return bool + */ + function add_log() + { + $params = $this->input->post(); + if (!$params['id']) { + return $this->show_json(SYS_CODE_FAIL, '参数错误!'); + } + if (!$params['log']) { + return $this->show_json(SYS_CODE_FAIL, '请输入内容!'); + } + $addData = array( + 'own_id' => $params['id'], + 'uid' => $this->uid, + 'uname' => $this->username, + 'type' => intval($params['type']), + 'log' => $params['log'], + 'c_time' => time() + ); + $id = $this->mdOwnersOplogs->add($addData); + if ($id) { + return $this->show_json(SYS_CODE_SUCCESS, '添加成功'); + } else { + return $this->show_json(SYS_CODE_FAIL, '添加失败'); + } + } + + /** + * 编辑 + * @return bool + */ + public function edit() + { + $info = $this->input->post('info'); + if (!$info) { + return $this->show_json(SYS_CODE_FAIL, '非法参数!'); + } + $row = $this->mdOwners->get(array('id' => $info['id'])); + if (!$row) { + return $this->show_json(SYS_CODE_FAIL, '车主信息不存在!'); + } + $msg = '修改成功'; + $code = SYS_CODE_SUCCESS; + if ($info['editType'] == 1) { + } else if ($info['editType'] == 2) { + //更新车主信息 + $ret = $this->mdOwners->update(['name' => $info['name'], 'birth_day' => $info['birth_day'], 'sex' => $info['sex'], + 'brand_id' => $info['brand_id'], 's_id' => $info['s_id'], 'v_id' => $info['v_id'], 'car_num' => $info['car_num'], + 'order_time' => $info['order_time'], 'ck_time' => $info['ck_time']], ['id' => $info['id']]); + if (!$ret) { + $code = SYS_CODE_FAIL; + $msg = '修改车主信息失败'; + } else { + $msg = '修改车主信息成功'; + $this->addLog(array('own_id' => $info['id'], 'type' => 0, 'log' => '更新车主信息')); + } + } else if ($info['editType'] == 3) { + $id = $info['id']; + //客户标签 + if (!$info['tag']) { + return $this->show_json(SYS_CODE_FAIL, '客户画像不存在!'); + } + $add_tag = []; + //查找已加入标签 + $res_td = $this->mdOwnersTagdata->select(['o_id' => $id], 'id desc', 0, 0, 't_id'); + $tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : ''; + foreach ($info['tag'] as $key => $val) { + foreach ($val['list'] as $key2 => $val2) { + if ($val['type'] == 'checkbox') { + if ($val2['checked'] == 'true') { + if (!$tag_data || !in_array($val2['id'], $tag_data)) {//未加标签,新增 + $add_tag[] = ['o_id' => $id, 't_id' => $val2['id'], 'c_time' => time()]; + } + } else { + if ($tag_data && in_array($val2['id'], $tag_data)) {//删除标签 + $this->mdOwnersTagdata->delete(['o_id' => $id, 't_id' => $val2['id']]); + } + } + } else { + if ($val['value'] == $val2['id']) { + if (!$tag_data || !in_array($val2['id'], $tag_data)) {//未加标签,新增 + $add_tag[] = ['o_id' => $id, 't_id' => $val2['id'], 'c_time' => time()]; + } + } else { + if ($tag_data && in_array($val2['id'], $tag_data)) {//删除标签 + $this->mdOwnersTagdata->delete(['o_id' => $id, 't_id' => $val2['id']]); + } + } + } + } + } + if ($add_tag && count($add_tag)) { + $this->mdOwnersTagdata->add_batch($add_tag); + } + $this->addLog(array('own_id' => $info['id'], 'type' => 0, 'log' => '修改车主画像')); + } + return $this->show_json($code, $msg); + } + + public function del() + { + } + + public function batch() + { + // TODO: Implement batch() method. + } + + public function export() + { + // TODO: Implement export() method. + } + + /** + * Notes:增加日志 + * Created on: 2021/7/23 10:48 + * Created by: dengbw + * @param array $ary + * @return mixed + */ + private function addLog($ary = array()) + { + $id = 0; + if ($ary['log']) { + $addData = array( + 'own_id' => $ary['own_id'], + 'uid' => $this->uid, + 'uname' => $this->username, + 'type' => intval($ary['type']), + 'log' => $ary['log'], + 'c_time' => time() + ); + $id = $this->mdOwnersOplogs->add($addData); + } + return $id; + } + + /** + * Notes:车主标签 + * Created on: 2022/6/16 14:47 + * Created by: dengbw + * @param $id + * @return array + */ + private function get_tag($id) + { + $show = $res_td = []; + $res = $this->mdOwnersTag->select(['status' => 1, 'pid' => 0], 'sort desc,id desc', 0, 0, 'id,name,type'); + if ($res) { + $id && $res_td = $this->mdOwnersTagdata->select(['o_id' => $id], 'id desc', 0, 0, 't_id');//查找用户选择 + $tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : ''; + foreach ($res as $key => $val) { + $list = []; + $value = ''; + $res2 = $this->mdOwnersTag->select(['status' => 1, 'pid' => $val['id']], 'sort desc,id desc', 0, 0, 'id,name'); + foreach ($res2 as $key2 => $val2) { + //检查是否选中标签 + $setValue = ['id' => $val2['id'], 'name' => $val2['name']]; + if ($val['type'] == 'checkbox') { + $setValue['checked'] = $tag_data && in_array($val2['id'], $tag_data) ? true : false; + } else { + if ($tag_data && in_array($val2['id'], $tag_data)) { + $value = $val2['id']; + } + } + $list[] = $setValue; + } + $show[] = ['id' => $val['id'], 'name' => $val['name'], 'type' => $val['type'], 'value' => $value, 'list' => $list]; + } + } + return $show; + } + + /** + * Notes:根据生日计算年龄,年龄的格式是:2018-01-22 + * Created on: 2022/6/16 14:47 + * Created by: dengbw + * @param $birthday + * @return false|int|string + */ + private function getAgeByBirth($birthday) + { + $birth_year = date('Y', strtotime($birthday)); + $birth_month = date('m', strtotime($birthday)); + $birth_day = date('d', strtotime($birthday)); + if (empty($birth_year) || empty($birth_month) || empty($birth_day)) { + return 0; + } + $current_year = date('Y', time()); + $current_month = date('m', time()); + $current_day = date('d', time()); + if ($birth_year >= $current_year) { + return 0; + } + $age = $current_year - $birth_year - 1; + if ($current_month > $birth_month) { + return $age + 1; + } else if ($current_month == $birth_month && $current_day >= $birth_day) { + return $age + 1; + } else { + return $age; + } + } + +} \ No newline at end of file diff --git a/admin/views/receiver/owners/get.php b/admin/views/receiver/owners/get.php new file mode 100644 index 00000000..d564dd41 --- /dev/null +++ b/admin/views/receiver/owners/get.php @@ -0,0 +1,583 @@ +
+
+
+
+
+ + 车主信息 + + + + +
+
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + +
车主姓名:
+
车主电话:{{info.mobile}}加入时间:{{info.c_time}}
+ + + + + +
车主生日:
+
+ + + + + +
车主性别:  男  + 女  +
+
+ + + + + +
品牌车型: +
+ +
+
+ +
+
+ +
+
+
+ + + + + +
车牌号码:
+
+ + + + + +
购车时间:
+
+ + + + + +
交付时间:
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ + 车主画像 + + + + +
+
+ + + + + +
+
+ +
+
+
+
+
+
+
+
+ + 操作日志 + + + 新增小记 + +
+
+
+
+ + + + + + + + + + + $val) { ?> + + + + + + + + +
操作人员内容类型操作时间
+ + + + + + + + +
+ $val1) { ?> +
+ + + +
+ +
+ +
+
+
+
+
+
+ +
+
+ + + diff --git a/admin/views/receiver/owners/lists.php b/admin/views/receiver/owners/lists.php new file mode 100644 index 00000000..2fd7fdba --- /dev/null +++ b/admin/views/receiver/owners/lists.php @@ -0,0 +1,331 @@ + +
+ + +
+
+ 个客户 +
+ + + + + + + + + + + + + + + + +
ID车主姓名车主电话车辆车牌号性别年龄购车时间交付时间
+
+
+
+
+
+ +
+
+ + +
+ + diff --git a/api/controllers/plan/Liche.php b/api/controllers/plan/Liche.php index 40d5cf2f..61be9d4f 100644 --- a/api/controllers/plan/Liche.php +++ b/api/controllers/plan/Liche.php @@ -1,4 +1,5 @@ load->model('receiver/order/receiver_order_contracts_model'); - $this->load->model('receiver/order/receiver_orders_v2_model'); + } - $this->load->library('receiver/orders_v2_entity'); + /** + * Notes:新增车主信息 + * Created on: 2022/6/14 17:15 + * Created by: dengbw + * https://liche-api-dev.xiaoyu.com/plan/liche/add_owners?rds=1 + * https://api.liche.cn/plan/liche/add_owners + */ + public function add_owners() + { + $params = $this->input->get(); + $size = 5000;//每次最多处理多少条 + $rds = intval($this->input->get('rds')); + $redis = &load_cache('redis'); + $redisKey = 'receiver_owners_c_time'; + if ($rds) { + $redis->delete($redisKey); + } + $c_time = $redis->get($redisKey); + !$c_time && $c_time = strtotime(date('Y-m-d') . ' 00:00:00'); + $log = array(); + $this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrders'); + $this->load->model('receiver/order/receiver_order_agents_model', 'mdOrdersAgents'); + $this->load->model('app/liche/app_liche_users_model', 'mdUsers'); + $this->load->model('receiver/receiver_owners_model', 'mdOwners'); + $t1 = 'lc_receiver_orders_v2'; + $t2 = 'lc_receiver_order_status'; + $where = ["{$t2}.c_time>=" => $c_time, "{$t1}.status>=" => 0, "{$t1}.owner_name<>" => '', "{$t1}.owner_mobile<>" => '', + "{$t2}.pid_status" => 5, "{$t2}.status" => 1]; + $having = "total >= 1"; + $orderby = "{$t2}.c_time asc"; + $fileds = "{$t1}.id,{$t1}.brand_id,{$t1}.s_id,{$t1}.v_id,{$t1}.owner_name,{$t1}.owner_mobile,{$t1}.order_time,{$t1}.ck_time + ,{$t1}.info_json,{$t2}.c_time"; + $res = $this->mdOrders->selectOrders($where, $orderby, 1, $size, '', $fileds, $having); + if (!$res) { + if ($params['rds']) { + echo '1执行到当前c_time:' . date('Y-m-d H:i:s', $c_time) . '暂无数据'; + } + return; + } + $str_o_ids = implode(',', array_unique(array_column($res, 'id'))); + $map_agents = $this->mdOrdersAgents->map('o_id', 'car_num', ["o_id in({$str_o_ids})" => null]); + $str_mobiles = implode(',', array_unique(array_column($res, 'owner_mobile'))); + $map_users = $this->mdUsers->map('mobile', 'id', ["mobile in({$str_mobiles})" => null]); + foreach ($res as $key => $value) { + $c_time = $value['c_time']; + $birth_day = '0000-00-00'; + $sex = 0; + if ($value['info_json']) { + $info_json = json_decode($value['info_json'], true); + if ($info_json['c_owner_cardid']) { + $cardid = $info_json['c_owner_cardid']; + $birth_day = date('Y-m-d', strtotime(substr($cardid, 6, 8))); + $sex = substr($cardid, -2, 1) % 2 == 0 ? 2 : 1; //1为男 2为女 + } + } + $uid = intval($map_users[$value['owner_mobile']]); + $car_num = $map_agents[$value['id']] ? $map_agents[$value['id']] : ''; + $data = ['o_id' => $value['id'], 'uid' => $uid, 'name' => $value['owner_name'], 'mobile' => $value['owner_mobile'], + 'birth_day' => $birth_day, 'sex' => $sex, 'brand_id' => $value['brand_id'], 's_id' => $value['s_id'], + 'v_id' => $value['v_id'], 'order_time' => $value['order_time'], 'ck_time' => $value['ck_time'], 'car_num' => $car_num]; + $re = $this->mdOwners->get(['o_id' => $value['id']]); + if ($re) { + $this->mdOwners->update($data, ['id' => $re['id']]); + } else { + $data['c_time'] = time(); + $id = $this->mdOwners->add($data); + $id && $log[] = ['id' => $id, 'name' => $data['name'], 'mobile' => $data['mobile']]; + } + } + $redis->save($redisKey, $c_time); + if ($params['rds']) { + echo '
2执行到当前c_time:' . date('Y-m-d H:i:s', $c_time); + echo '
成功新增:
'; + if ($log) { + echo json_encode($log, JSON_UNESCAPED_UNICODE); + echo '
'; + } + echo '数据库获取:
'; + echo json_encode($res, JSON_UNESCAPED_UNICODE); + } } //获取未签名pdf - public function un_sign_pdf(){ - $row = $this->receiver_order_contracts_model->get(['o_id>='=>Orders_v2_entity::V2_START_ID,'flag'=>0,'file !='=>'','status'=>1]); + public function un_sign_pdf() + { + $this->load->model('receiver/order/receiver_order_contracts_model'); + $this->load->model('receiver/order/receiver_orders_v2_model'); + $this->load->library('receiver/orders_v2_entity'); + $row = $this->receiver_order_contracts_model->get(['o_id>=' => Orders_v2_entity::V2_START_ID, 'flag' => 0, 'file !=' => '', 'status' => 1]); $receiver = $this->receiver_orders_v2_model->get(['id' => $row['o_id']]); - if(file_exists(FCPATH.$row['file']) && $receiver){ - $companys = $this->orders_v2_entity->get_biz_mchid($receiver['biz_id'],$receiver['brand_id']); + if (file_exists(FCPATH . $row['file']) && $receiver) { + $companys = $this->orders_v2_entity->get_biz_mchid($receiver['biz_id'], $receiver['brand_id']); $url = http_host_com(); $width = 130; $s_img = build_qiniu_image_url($companys['company']['img_seal']); - if($row['type']==1){ + if ($row['type'] == 1) { $page = 2; $height = 380; $s_img = build_qiniu_image_url($companys['srv_company']['img_seal']); - }elseif ($row['type']==3){ + } elseif ($row['type'] == 3) { $page = 1; $height = 620; - } else{ + } else { $page = 3; $height = 160; } @@ -41,32 +125,34 @@ class Liche extends HD_Controller 'width' => $width, 'height' => $height, 's_img' => $s_img, - 'file_url' => $url.'/'.$row['file'] + 'file_url' => $url . '/' . $row['file'] ]; - die(json_encode($data,JSON_UNESCAPED_UNICODE)); - }else{ - $this->receiver_order_contracts_model->update(['flag'=>1],['id'=>$row['id']]); + die(json_encode($data, JSON_UNESCAPED_UNICODE)); + } else { + $this->receiver_order_contracts_model->update(['flag' => 1], ['id' => $row['id']]); } } //覆盖pdf文件 - public function up_pdf(){ + public function up_pdf() + { + $this->load->model('receiver/order/receiver_order_contracts_model'); $id = $this->input->post('id'); - $row = $this->receiver_order_contracts_model->get(['id'=>$id,'flag'=>0]); - if($row){ - $file_path_arr = explode('/',$row['file']); + $row = $this->receiver_order_contracts_model->get(['id' => $id, 'flag' => 0]); + if ($row) { + $file_path_arr = explode('/', $row['file']); // $file_name = array_pop($file_path_arr); // $file_name = 'test.pdf'; // $file_path = implode('/',$file_path_arr); // $res = move_uploaded_file($_FILES['file']['tmp_name'],FCPATH.$file_path.'/'.$file_name); - move_uploaded_file($_FILES['file']['tmp_name'],FCPATH.$row['file']); - $res = $this->receiver_order_contracts_model->update(['flag'=>1],['id'=>$row['id']]); - if($res){ + move_uploaded_file($_FILES['file']['tmp_name'], FCPATH . $row['file']); + $res = $this->receiver_order_contracts_model->update(['flag' => 1], ['id' => $row['id']]); + if ($res) { $data = [ 'code' => 1, 'msg' => '保存成功' ]; - die(json_encode($data,JSON_UNESCAPED_UNICODE)); + die(json_encode($data, JSON_UNESCAPED_UNICODE)); } } } diff --git a/api/controllers/plan/Plan.php b/api/controllers/plan/Plan.php index a9fed3a8..34e31a02 100644 --- a/api/controllers/plan/Plan.php +++ b/api/controllers/plan/Plan.php @@ -37,6 +37,8 @@ class Plan extends CI_Controller $plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_manager_sms')), 'interval' => 2);//给店长发送待分配短信 $plan[] = array('url' => base_url(array('plan', 'licheb', 'users_log')), 'interval' => 2);//顾问日志 + $plan[] = array('url' => base_url(array('plan', 'liche', 'add_owners')), 'interval' => 5);//新增车主 + $plan[] = array('url' => base_url(array('plan', 'items', 'stock_log')), 'interval' => 5);//库存车辆日志 $plan[] = array('url' => base_url(array('plan', 'polyv', 'view_log')), 'interval' => 5);//直播观看详情数据 diff --git a/api/controllers/plan/Temp.php b/api/controllers/plan/Temp.php index be986c34..3b1da2b0 100644 --- a/api/controllers/plan/Temp.php +++ b/api/controllers/plan/Temp.php @@ -16,6 +16,84 @@ class Temp extends HD_Controller $this->log_file = 'temp.log'; } + /** + * Notes:加车主(状态交易完成) + * Created on: 2022/5/27 11:58 + * Created by: dengbw + * https://liche-api-dev.xiaoyu.com/plan/temp/receiver_owners + * https://api.liche.cn/plan/temp/receiver_owners + */ + public function receiver_owners() + { + $this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrders'); + $this->load->model('receiver/order/receiver_order_agents_model', 'mdOrdersAgents'); + $this->load->model('app/liche/app_liche_users_model', 'mdUsers'); + $this->load->model('receiver/receiver_owners_model', 'mdOwners'); + $param = $this->input->get(); + $param['page'] = intval($param['page']); + $param['size'] = intval($param['size']); + !$param['size'] && $param['size'] = 100; + !$param['page'] && $param['page'] = 1; + $counts = intval($param['counts']); + ob_start(); //打开缓冲区 + $t1 = 'lc_receiver_orders_v2'; + $t2 = 'lc_receiver_order_status'; + $where = ["{$t1}.status>=" => 0, "{$t1}.owner_name<>" => '', "{$t1}.owner_mobile<>" => '', "{$t2}.pid_status" => 5, "{$t2}.status" => 1]; + $having = "total >= 1"; + $orderby = "{$t2}.c_time asc"; + $fileds = "{$t1}.id,{$t1}.brand_id,{$t1}.s_id,{$t1}.v_id,{$t1}.owner_name,{$t1}.owner_mobile,{$t1}.order_time,{$t1}.ck_time + ,{$t1}.info_json"; + //$count = $this->mdOrders->selectOrders($where, '', '', '', 1, '', $having); + $res = $this->mdOrders->selectOrders($where, $orderby, $param['page'], $param['size'], '', $fileds, $having); + if (!$res) { + echo '
本次更新完成了:'; + echo '

成功更新 ' . $counts . ' 条'; + echo '

点击将再次更新>>>'; + exit; + } + $str_o_ids = implode(',', array_unique(array_column($res, 'id'))); + $map_agents = $this->mdOrdersAgents->map('o_id', 'car_num', ["o_id in({$str_o_ids})" => null]); + $str_mobiles = implode(',', array_unique(array_column($res, 'owner_mobile'))); + $map_users = $this->mdUsers->map('mobile', 'id', ["mobile in({$str_mobiles})" => null]); + $log = array(); + foreach ($res as $key => $value) { + $birth_day = '0000-00-00'; + $sex = 0; + if ($value['info_json']) { + $info_json = json_decode($value['info_json'], true); + if ($info_json['c_owner_cardid']) { + $cardid = $info_json['c_owner_cardid']; + $birth_day = date('Y-m-d', strtotime(substr($cardid, 6, 8))); + $sex = substr($cardid, -2, 1) % 2 == 0 ? 2 : 1; //1为男 2为女 + } + } + $uid = intval($map_users[$value['owner_mobile']]); + $car_num = $map_agents[$value['id']] ? $map_agents[$value['id']] : ''; + $data = ['o_id' => $value['id'], 'uid' => $uid, 'name' => $value['owner_name'], 'mobile' => $value['owner_mobile'], + 'birth_day' => $birth_day, 'sex' => $sex, 'brand_id' => $value['brand_id'], 's_id' => $value['s_id'], + 'v_id' => $value['v_id'], 'order_time' => $value['order_time'], 'ck_time' => $value['ck_time'], 'car_num' => $car_num]; + $re = $this->mdOwners->get(['o_id' => $value['id']]); + if ($re) { + $this->mdOwners->update($data, ['id' => $re['id']]); + } else { + $data['c_time'] = time(); + $id = $this->mdOwners->add($data); + if ($id) { + $log[] = ['id' => $id, 'name' => $data['name'], 'mobile' => $data['mobile']]; + $counts++; + } + } + } + echo '
成功新增:'; + if ($log) { + echo json_encode($log, JSON_UNESCAPED_UNICODE); + } + echo '

数据库获取:'; + echo json_encode($res, JSON_UNESCAPED_UNICODE); + header('refresh:3;url=/plan/temp/receiver_owners?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1)); + ob_end_flush();//输出全部内容到浏览器 + } + /** * Notes:更新企微好友 * Created on: 2022/5/27 11:58 diff --git a/api/controllers/plan/Xzcall.php b/api/controllers/plan/Xzcall.php index f95fd606..c43ec055 100644 --- a/api/controllers/plan/Xzcall.php +++ b/api/controllers/plan/Xzcall.php @@ -68,6 +68,9 @@ class Xzcall extends HD_Controller } else if ($row['cf_title'] == 'customer') {//客户拨打电话回调 $this->load->model('receiver/receiver_customer_oplogs_model', 'mdOplogs'); $addData['customer_id'] = $row['cf_id']; + } else if ($row['cf_title'] == 'owners') {//车主拨打电话回调 + $this->load->model('receiver/receiver_owners_oplogs_model', 'mdOplogs'); + $addData['own_id'] = $row['cf_id']; } $this->mdOplogs->add($addData); $xcall = new Xcall($this->admin_config); @@ -94,14 +97,14 @@ class Xzcall extends HD_Controller } $this->load->library('receiver/customers_entity'); $visit = $row['cf_title'] == 'customer' ? 1 : 0; - $this->customers_entity->add_log_visit($cust['id'], $row['cf_uid'], $data['uname'], $row['id'], 2,$visit); + $this->customers_entity->add_log_visit($cust['id'], $row['cf_uid'], $data['uname'], $row['id'], 2, $visit); } } else { - if($data['virtualMobile']=='13391247942'){ //推送test环境 + if ($data['virtualMobile'] == '13391247942') { //推送test环境 $url = "https://api.lc.haodian.cn/plan/xzcall"; $this->load->library('mycurl'); - $res = $this->mycurl->httpPost($url,$data); - debug_log('结束,推送test环境:'.json_encode($res,JSON_UNESCAPED_UNICODE), $this->log_file); + $res = $this->mycurl->httpPost($url, $data); + debug_log('结束,推送test环境:' . json_encode($res, JSON_UNESCAPED_UNICODE), $this->log_file); } debug_log("error: 未找到拨打记录", $this->log_file); } @@ -148,12 +151,12 @@ class Xzcall extends HD_Controller $jsondata['file_info'] = $data; $up_data['json_data'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE); $this->receiver_xz_model->update($up_data, ['id' => $row['id']]); - }else{ - //推送test环境 + } else { + //推送test环境 $url = "https://api.lc.haodian.cn/plan/xzcall/video"; $this->load->library('mycurl'); - $res = $this->mycurl->httpPost($url,$data); - debug_log('结束,推送test环境:'.json_encode($res,JSON_UNESCAPED_UNICODE), $this->log_file); + $res = $this->mycurl->httpPost($url, $data); + debug_log('结束,推送test环境:' . json_encode($res, JSON_UNESCAPED_UNICODE), $this->log_file); } debug_log("end " . __FUNCTION__, $this->log_file); echo '{"result":"0","error":""}'; @@ -187,14 +190,14 @@ class Xzcall extends HD_Controller if ($o_id) { $params = []; $test && $params['test'] = 1; - $this->load->library('qyrobot',$params); - if($type){ - if(!$pay_time){ + $this->load->library('qyrobot', $params); + if ($type) { + if (!$pay_time) { die('pay_time:不能为空'); } - $robot_res = $this->qyrobot->deposit_notify_v2($o_id,1,$pay_time); - }else{ + $robot_res = $this->qyrobot->deposit_notify_v2($o_id, 1, $pay_time); + } else { $robot_res = $this->qyrobot->deposit_notify_v2($o_id); } var_dump($robot_res); @@ -202,7 +205,8 @@ class Xzcall extends HD_Controller } //更新订单服务id - public function up_srv_ids(){ + public function up_srv_ids() + { $page = $this->input->get('page'); $size = $this->input->get('size'); !$page && $page = 1; @@ -210,31 +214,31 @@ class Xzcall extends HD_Controller $where = [ "srv_ids like '%3%'" => null ]; - $rows = $this->orders_model->select($where,'id asc',$page,$size,'id,srv_ids,jsondata'); - if($rows){ - foreach($rows as $item){ + $rows = $this->orders_model->select($where, 'id asc', $page, $size, 'id,srv_ids,jsondata'); + if ($rows) { + foreach ($rows as $item) { $res = false; - $srv_ids_arr = explode(',',$item['srv_ids']); - if(in_array(3,$srv_ids_arr)){ - $jsondata = json_decode($item['jsondata'],true); + $srv_ids_arr = explode(',', $item['srv_ids']); + if (in_array(3, $srv_ids_arr)) { + $jsondata = json_decode($item['jsondata'], true); $jsondata['old_srv_ids'] = $item['srv_ids']; $jsondata['if_fine'] = 1; - foreach($srv_ids_arr as $key=>$val){ - if($val==3){ + foreach ($srv_ids_arr as $key => $val) { + if ($val == 3) { unset($srv_ids_arr[$key]); break; } } $updata = [ - 'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE), - 'srv_ids' => implode(',',$srv_ids_arr) + 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE), + 'srv_ids' => implode(',', $srv_ids_arr) ]; - $res = $this->orders_model->update($updata,['id'=>$item['id']]); + $res = $this->orders_model->update($updata, ['id' => $item['id']]); } $log = "{$item['id']}更新结果:{$res}
"; echo $log; } - }else{ + } else { echo "finish"; } } diff --git a/common/models/receiver/Receiver_owners_model.php b/common/models/receiver/Receiver_owners_model.php new file mode 100644 index 00000000..a8292c42 --- /dev/null +++ b/common/models/receiver/Receiver_owners_model.php @@ -0,0 +1,30 @@ +table_name, 'default'); + } + + /** + * Notes:状态 + * Created on: 2022/6/13 10:31 + * Created by: dengbw + * @return array + */ + public function statusAry() + { + return [1 => '正常', 0 => '禁用']; + } + +} \ No newline at end of file diff --git a/common/models/receiver/Receiver_owners_oplogs_model.php b/common/models/receiver/Receiver_owners_oplogs_model.php new file mode 100644 index 00000000..2dbf5981 --- /dev/null +++ b/common/models/receiver/Receiver_owners_oplogs_model.php @@ -0,0 +1,36 @@ +table_name, 'default'); + } + + /** + * Notes:类型 + * Created on: 2022/6/15 16:51 + * Created by: dengbw + * @param int $id + * @return array|mixed + */ + public function typeAry($id = 0) + { + $arr = [0 => '小记', 1 => '发短信', 2 => '拨打号码', 3 => '系统']; + if ($id) { + return $arr[$id]; + } else { + return $arr; + } + } + +}