diff --git a/admin/config/database.php b/admin/config/database.php index 6f278111..44b72086 100644 --- a/admin/config/database.php +++ b/admin/config/database.php @@ -94,3 +94,25 @@ $db['default'] = array( 'failover' => array(), 'save_queries' => TRUE ); + +$db['agentdb'] = array( + 'dsn' => '', + 'hostname' => 'mysql:host=127.0.0.1;port=3306;dbname=agentdb', + 'username' => 'devuser', + 'password' => 'DEV@hdy123456', + 'database' => 'agentdb', + 'dbdriver' => 'pdo', + 'dbprefix' => 'lc_', + 'pconnect' => FALSE, + 'db_debug' => (ENVIRONMENT !== 'production'), + 'cache_on' => FALSE, + 'cachedir' => '', + 'char_set' => 'utf8mb4', + 'dbcollat' => 'utf8_general_ci', + 'swap_pre' => '', + 'encrypt' => FALSE, + 'compress' => FALSE, + 'stricton' => FALSE, + 'failover' => array(), + 'save_queries' => TRUE +); diff --git a/admin/controllers/Common.php b/admin/controllers/Common.php index 9c24a1b1..26c32838 100644 --- a/admin/controllers/Common.php +++ b/admin/controllers/Common.php @@ -419,7 +419,7 @@ class Common extends CI_Controller $province_id = intval($this->input->post('province_id')); $city_id = intval($this->input->post('city_id')); $county_id = intval($this->input->post('county_id')); - $type = intval($this->input->post('type')); + $type = $this->input->post('type'); $unset_city_limit = intval($this->input->post('unset_city_limit')); $use_shop_list = $this->input->post('use_shop_list'); @@ -441,7 +441,11 @@ class Common extends CI_Controller $city_id && $where['city_id'] = $city_id; $county_id && $where['county_id'] = $county_id;; $ids && $where['id not in (' . $ids . ')'] = null; - $type && $where['type'] = $type; + if (is_array($type)) { + $type && $where['type in (' . implode(',', $type) . ')'] = null; + } else { + $type == 1 && $where['type'] = 1; + } if (($province_id && $city_id) || $unset_city_limit) { $count = $this->mdBiz->count($where); @@ -452,6 +456,10 @@ class Common extends CI_Controller $setValue = array(); $setValue['id'] = $value['id']; $setValue['name'] = $value['biz_name']; + if (is_array($type)) { + $bizType = $this->mdBiz->type_ary($value['type']); + $setValue['name'] .= '(' . $bizType . ')'; + } $img = $value['headimg'] ? $value['headimg'] : $value['cover']; $setValue['img'] = $img ? build_qiniu_image_url($img) : ''; $setValue['sort'] = $key; diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index 735f3ad8..d5968cf3 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -309,7 +309,7 @@ class Clues extends HD_Controller $setValue['log'] = $value['log']; $setValue['type_name'] = $this->mdOplogs->typeAry()[$value['type']]; $setValue['c_time'] = date('Y-m-d H:i', $value['c_time']); - list($rec_url,$rec_text) = $this->mdOplogs->getRecordUrl($value['id']); + list($rec_url, $rec_text) = $this->mdOplogs->getRecordUrl($value['id']); // if ($value['type'] == 2) {//拨打电话 // $rec_text = '未接通'; // $row = $this->mdReceiverXz->get(array('id' => $value['log'])); @@ -568,14 +568,14 @@ class Clues extends HD_Controller if (!$params['log']) { return $this->show_json(SYS_CODE_FAIL, '请输入内容!'); } - if(strlen($params['buy_time'])){ + if (strlen($params['buy_time'])) { $buy_time_cn = Receiver_clues_model::BUY_TIME_LIST[$params['buy_time']]; $addData = array( 'clue_id' => $params['id'], 'uid' => $this->uid, 'uname' => $this->username, 'type' => intval($params['type']), - 'log' => '修改意向购车周期为:'.$buy_time_cn, + 'log' => '修改意向购车周期为:' . $buy_time_cn, 'c_time' => time() ); $this->mdOplogs->add($addData); @@ -1303,11 +1303,15 @@ class Clues extends HD_Controller 'c_time' => $re['c_time'], 'rec_time' => $info['rec_time'] ); - $customers_id = $this->customers_model->add($add); if (!$customers_id) { continue; } + if ($biz['type'] == Biz_model::BIZ_TYPE_SPACE) { + //解锁 + /** @var MyResponse $result */ + $result = $this->customers_model->unlock($customers_id, $biz['id'], false); + } //同步线索日志到客户日志 $this->load->library('receiver/customers_entity'); $this->customers_entity->syn_clues($customers_id, $re['id']); diff --git a/admin/views/receiver/clues/edit.php b/admin/views/receiver/clues/edit.php index cfc9e9e6..d3f0e172 100644 --- a/admin/views/receiver/clues/edit.php +++ b/admin/views/receiver/clues/edit.php @@ -763,7 +763,7 @@ type: 'post', dataType: 'json', data: { - type: 5, + type: [1,5], page: that.brandsThPage, province_id: that.info.province_id_admin, city_id: that.info.city_id_admin, diff --git a/agent/admin/controllers/Common.php b/agent/admin/controllers/Common.php index 4e48848f..4129daeb 100644 --- a/agent/admin/controllers/Common.php +++ b/agent/admin/controllers/Common.php @@ -78,13 +78,16 @@ class Common extends CI_Controller $this->load->model('agent/auto_product_model'); $this->biz_model->set_db('ssdb'); $productId = intval($this->input->get('productId')); + $types = Biz_model::BIZ_TYPE_4s . ',' . Biz_model::BIZ_TYPE_SPACE; $where = [ 'status' => 1, - 'type' => Biz_model::BIZ_TYPE_4s ]; if ($productId) { $product = $this->auto_product_model->get(['id' => $productId]); - $where['car_brand_id'] = $product['brandId'] ?: 0; + $brandId = $product['brandId'] ?: 0; + $where["(car_brand_id={$brandId} and type=" . Biz_model::BIZ_TYPE_4s . " or type=" . Biz_model::BIZ_TYPE_SPACE . ")"] = null; + } else { + $where["type in ({$types})"] = null; } $lists = $this->biz_model->select($where, 'id desc', 0, 0, 'id,biz_name as name,city_id'); echo json_encode($lists, JSON_UNESCAPED_UNICODE); @@ -162,7 +165,7 @@ class Common extends CI_Controller $children[$key]['children'] = []; } } - if($newChildren){ + if ($newChildren) { $resList[] = [ 'value' => $item['value'], 'label' => $item['label'], diff --git a/agent/admin/controllers/api/Common.php b/agent/admin/controllers/api/Common.php index 0e95b746..2e825d79 100644 --- a/agent/admin/controllers/api/Common.php +++ b/agent/admin/controllers/api/Common.php @@ -81,13 +81,16 @@ class Common extends CI_Controller $this->load->model('agent/auto_product_model'); $this->biz_model->set_db('ssdb'); $productId = intval($this->input->get('productId')); + $types = Biz_model::BIZ_TYPE_4s . ',' . Biz_model::BIZ_TYPE_SPACE; $where = [ 'status' => 1, - 'type' => Biz_model::BIZ_TYPE_4s ]; if ($productId) { $product = $this->auto_product_model->get(['id' => $productId]); - $where['car_brand_id'] = $product['brandId'] ?: 0; + $brandId = $product['brandId'] ?: 0; + $where["(car_brand_id={$brandId} and type=" . Biz_model::BIZ_TYPE_4s . " or type=" . Biz_model::BIZ_TYPE_SPACE . ")"] = null; + } else { + $where["type in ({$types})"] = null; } $lists = $this->biz_model->select($where, 'id desc', 0, 0, 'id,biz_name as name,city_id'); echo json_encode($lists, JSON_UNESCAPED_UNICODE); @@ -165,7 +168,7 @@ class Common extends CI_Controller $children[$key]['children'] = []; } } - if($newChildren){ + if ($newChildren) { $resList[] = [ 'value' => $item['value'], 'label' => $item['label'], diff --git a/agent/admin/controllers/auto/Biz.php b/agent/admin/controllers/auto/Biz.php index 66c54c27..342ae12b 100644 --- a/agent/admin/controllers/auto/Biz.php +++ b/agent/admin/controllers/auto/Biz.php @@ -21,11 +21,11 @@ class Biz extends BaseController $this->biz_model->set_db('ssdb'); $where = [ 'status' => 1, - 'type' => Biz_model::BIZ_TYPE_4s + 'type in (' . Biz_model::BIZ_TYPE_4s . ',' . Biz_model::BIZ_TYPE_SPACE . ')' => null ]; $cityId && $where['city_id'] = $cityId; if ($userCouponId) { - $userCoupon = $this->auto_user_coupon_model->get(['id'=>$userCouponId]); + $userCoupon = $this->auto_user_coupon_model->get(['id' => $userCouponId]); $couponBiz = $this->productCouponBiz->select(['coupon_id' => $userCoupon['couponId']], '', '', '', 'biz_id'); $bizIds = implode(',', array_column($couponBiz, 'biz_id')) ?: 0; $where['id in (' . $bizIds . ')'] = null; diff --git a/agent/admin/controllers/auto/Ucenter.php b/agent/admin/controllers/auto/Ucenter.php index 9be8c54a..574334ce 100644 --- a/agent/admin/controllers/auto/Ucenter.php +++ b/agent/admin/controllers/auto/Ucenter.php @@ -65,8 +65,8 @@ class Ucenter extends BaseController $rows = $this->auto_user_coupon_model->select($where, 'id desc', $page, $limit, '', 'AutoUserCouponEntity'); if ($count) { foreach ($rows as $v) { - /** @var AutoProductCouponEntity $autoProductCouponEntity */ - $autoProductCouponEntity = $this->auto_product_coupon_model->get(['id' => $v->couponId], '', 'AutoProductCouponEntity'); +// /** @var AutoProductCouponEntity $autoProductCouponEntity */ +// $autoProductCouponEntity = $this->auto_product_coupon_model->get(['id' => $v->couponId], '', 'AutoProductCouponEntity'); $list[] = [ 'id' => $v->id, 'sid' => $v->sid, diff --git a/agent/admin/controllers/pingan/Common.php b/agent/admin/controllers/pingan/Common.php index 0e95b746..5a810a60 100644 --- a/agent/admin/controllers/pingan/Common.php +++ b/agent/admin/controllers/pingan/Common.php @@ -81,13 +81,16 @@ class Common extends CI_Controller $this->load->model('agent/auto_product_model'); $this->biz_model->set_db('ssdb'); $productId = intval($this->input->get('productId')); + $types = Biz_model::BIZ_TYPE_4s . ',' . Biz_model::BIZ_TYPE_SPACE; $where = [ 'status' => 1, - 'type' => Biz_model::BIZ_TYPE_4s ]; if ($productId) { $product = $this->auto_product_model->get(['id' => $productId]); - $where['car_brand_id'] = $product['brandId'] ?: 0; + $brandId = $product['brandId'] ?: 0; + $where["(car_brand_id={$brandId} and type=" . Biz_model::BIZ_TYPE_4s . " or type=" . Biz_model::BIZ_TYPE_SPACE . ")"] = null; + } else { + $where["type in ({$types})"] = null; } $lists = $this->biz_model->select($where, 'id desc', 0, 0, 'id,biz_name as name,city_id'); echo json_encode($lists, JSON_UNESCAPED_UNICODE); diff --git a/api/controllers/wxapp/licheb/Cusorder.php b/api/controllers/wxapp/licheb/Cusorder.php index c8dabb06..53ec7567 100644 --- a/api/controllers/wxapp/licheb/Cusorder.php +++ b/api/controllers/wxapp/licheb/Cusorder.php @@ -17,6 +17,7 @@ class Cusorder extends Wxapp $this->check_mobile = array();//需要手机号 $this->check_headimg = array();//授权微信信息 + $this->load->model('receiver/receiver_clues_model', 'clues_model'); $this->load->model('receiver/receiver_customers_model', 'customers_model'); $this->load->model('receiver/receiver_clues_cfrom_model', 'clues_cfrom_model'); $this->load->model('receiver/order/receiver_orders_model', 'orders_model'); @@ -225,9 +226,10 @@ class Cusorder extends Wxapp $id = $this->input_param('id'); $status = $this->input_param('status'); $row = $this->orders_model->get(['id' => $id]); + $clues = $this->clues_model->get(['id' => $row['clue_id']]); $data_row = $this->receiver_order_datas_model->get(['o_id' => $id]); if (!$row || !$status) throw new Exception('参数错误', ERR_PARAMS_ERROR); - if ($biz['type'] != Biz_model::BIZ_TYPE_4s) { //不是4s店铺 + if ($clues['app_id'] != Receiver_clues_model::APP_ID_ACTIVITY) { //不是4s店铺 if ($status == 1) { //下定信息确认无误 判断:合同、付款凭证、身份证、权益书必须上传 if (!$data_row['contract_img']) throw new Exception('合同未上传', ERR_PARAMS_ERROR); if (!$data_row['cardida'] && !$row['main_type']) throw new Exception('身份证未上传', ERR_PARAMS_ERROR); @@ -462,6 +464,7 @@ class Cusorder extends Wxapp $car_name = isset($cars[$val['car_id']]) ? $cars[$val['car_id']][0]['name'] : ''; $img_status = $this->order_datas_entity->data_status($order_datas[$val['id']][0], $val['status']); $customer = $this->customers_model->get(['id' => $val['customer_id']]); + $clues = $this->clues_model->get(['id' => $val['clue_id']]); $of_title = ''; if ($customer['of_id']) { $of = $this->clues_cfrom_model->get(array('id' => $customer['of_id'])); @@ -479,7 +482,7 @@ class Cusorder extends Wxapp '车型' => ['type' => 'text', 'value' => $car_name, 'bg_color' => ''], ]; $o_data_4 = $o_data_3 = $o_data_2 = []; - if ($biz['type'] == Biz_model::BIZ_TYPE_4s) { + if ($clues['app_id'] == Receiver_clues_model::APP_ID_ACTIVITY) { $o_data_1['客户身份证'] = ['type' => 'text', 'value' => $img_status['cardida']['text'], 'bg_color' => $img_status['cardida']['color']]; } else { $o_data_1['付款方式'] = ['type' => 'text', 'value' => $val['payway'] ? '全款' : '按揭', 'bg_color' => '']; @@ -517,7 +520,7 @@ class Cusorder extends Wxapp 'text' => '', 'status' => 0 //核销状态 0未核销 1已核销 ]; - if ($biz['type'] == Biz_model::BIZ_TYPE_4s) { + if ($clues['app_id'] == Receiver_clues_model::APP_ID_ACTIVITY) { $destroy_show = $this->orders_entity->getDestroy($val['id']); } $lists[] = [ @@ -529,7 +532,8 @@ class Cusorder extends Wxapp 'status_name' => $status_arr[$val['status']], 'other_data' => $other_data, 'allot' => $allot, - 'destroy' => $destroy_show + 'destroy' => $destroy_show, + 'app_id' => $clues['app_id'] ?: 0 ]; } } @@ -548,6 +552,7 @@ class Cusorder extends Wxapp if (!$row) { throw new Exception('订单不存在', ERR_PARAMS_ERROR); } + $clues = $this->clues_model->get(['id' => $row['clue_id']]); $money_json = json_decode($row['money_json'], true); $brand = $this->auto_brand_model->get(['id' => $row['brand_id']], 'name'); @@ -562,7 +567,7 @@ class Cusorder extends Wxapp $row['in_color'] && $car_data['内饰颜色'] = $row['in_color']; $bt_cn_array = [0 => '下定信息确认无误', 1 => '发票信息确认无误', 2 => '交付信息确认无误']; $bt_cn = $bt_cn_array[$row['status']]; - if ($biz['type'] != Biz_model::BIZ_TYPE_4s) { + if ($clues['app_id'] != Receiver_clues_model::APP_ID_ACTIVITY) { $row['delry_time'] != '0000-00-00 00:00:00' && $car_data['期望交付时间'] = date('Y-m-d', strtotime($row['delry_time'])); $money_json['confirm_amount'] && $car_data['定金'] = $money_json['confirm_amount']; $money_json['discount_amount'] && $car_data['车身优惠'] = $money_json['discount_amount']; @@ -580,7 +585,7 @@ class Cusorder extends Wxapp $bt_cn = '确认订单'; } $edit_info_status = false; - if ($biz['type'] != Biz_model::BIZ_TYPE_4s && $row['status'] > 0) { + if ($clues['app_id'] != Receiver_clues_model::APP_ID_ACTIVITY && $row['status'] > 0) { $edit_info_status = true; } $data = [ @@ -609,6 +614,7 @@ class Cusorder extends Wxapp 'edit_info_status' => $edit_info_status, 'edit_order_status' => $row['status'] > 1 ? false : true, 'group_id' => $this->session['group_id'], + 'app_id' => $clues['app_id'] ?: 0 ]; if ($row['admin_id']) { $admin_row = $this->app_user_model->get(['id' => $row['admin_id']], 'uname'); diff --git a/api/controllers/wxapp/licheb/Cusorderdata.php b/api/controllers/wxapp/licheb/Cusorderdata.php index d8e96376..a0ece09f 100644 --- a/api/controllers/wxapp/licheb/Cusorderdata.php +++ b/api/controllers/wxapp/licheb/Cusorderdata.php @@ -20,6 +20,7 @@ class Cusorderdata extends Wxapp $this->check_mobile = array();//需要手机号 $this->check_headimg = array();//授权微信信息 + $this->load->model('receiver/receiver_clues_model', 'clues_model'); $this->load->model('receiver/order/receiver_orders_model', 'orders_model'); $this->load->model('receiver/order/receiver_order_datas_model'); $this->load->model("biz/biz_model"); @@ -160,6 +161,7 @@ class Cusorderdata extends Wxapp if (!$row) { throw new Exception('参数错误', ERR_PARAMS_ERROR); } + $clues = $this->clues_model->get(['id' => $row['clues_id']]); $biz = $this->get_biz_info(); $data_row = $this->receiver_order_datas_model->get(['o_id' => $id]); $jsondata = json_decode($data_row['jsondata'], true); @@ -201,7 +203,7 @@ class Cusorderdata extends Wxapp return $res_data; } //个人核对身份证 - if ($biz['type'] != Biz_model::BIZ_TYPE_4s && $userinfo['IdNum'] != $row['card_id']) { + if ($clues['app_id'] != Receiver_clues_model::APP_ID_ACTIVITY && $userinfo['IdNum'] != $row['card_id']) { $res_data['code'] = API_CODE_ORC_FAIL; $res_data['data'] = [ ['caridA' => false, 'errmsg' => '身份证号码与客户不一致'], @@ -289,7 +291,7 @@ class Cusorderdata extends Wxapp $this->orders_model->update(['status' => 2], ['id' => $id]); } //4s店保存识别身份证 - if ($biz['type'] == Biz_model::BIZ_TYPE_4s) { + if ($clues['app_id'] == Receiver_clues_model::APP_ID_ACTIVITY) { $this->orders_model->update(['card_id' => $idNum], ['id' => $id]); } $log = array( diff --git a/api/controllers/wxapp/licheb/Xz.php b/api/controllers/wxapp/licheb/Xz.php index 0ab3717b..f3a0e9a7 100644 --- a/api/controllers/wxapp/licheb/Xz.php +++ b/api/controllers/wxapp/licheb/Xz.php @@ -32,11 +32,11 @@ class Xz extends Wxapp protected function get() { - $biz = $this->get_biz_info(); - $biz_type = $biz['type']; - if ($biz_type != Biz_model::BIZ_TYPE_4s) { - throw new Hd_Exception('系统调整,暂停服务', API_CODE_FAIL); - } +// $biz = $this->get_biz_info(); +// $biz_type = $biz['type']; +// if ($biz_type != Biz_model::BIZ_TYPE_4s) { +// throw new Hd_Exception('系统调整,暂停服务', API_CODE_FAIL); +// } //平安外呼 $id = $this->input_param('id'); $type = intval($this->input_param('type')); diff --git a/common/libraries/entity/AutoUserCouponEntity.php b/common/libraries/entity/AutoUserCouponEntity.php index 62cb8408..7dde6125 100644 --- a/common/libraries/entity/AutoUserCouponEntity.php +++ b/common/libraries/entity/AutoUserCouponEntity.php @@ -164,7 +164,7 @@ class AutoUserCouponEntity throw new Exception('更新核销码状态失败', API_CODE_FAIL); } //跟新客户为订单客户 - $this->ci->receiver_customers_model->update(['status' => 3], ['id' => $customersRow['id']]); + $this->ci->receiver_customers_model->update(['status' => 2], ['id' => $customersRow['id']]); $this->ci->db->trans_commit(); return new MyRESPONSE(EXIT_SUCCESS, '核销成功'); } catch (Exception $e) { diff --git a/common/models/biz/Biz_model.php b/common/models/biz/Biz_model.php index efb4d365..4fbf316c 100644 --- a/common/models/biz/Biz_model.php +++ b/common/models/biz/Biz_model.php @@ -12,6 +12,7 @@ class Biz_model extends HD_Model { private $table_name = 'lc_biz'; + const BIZ_TYPE_SPACE = 1; //空间站 const BIZ_TYPE_4s = 5; //4S店 public function __construct() diff --git a/common/models/receiver/Receiver_customers_model.php b/common/models/receiver/Receiver_customers_model.php index 4221d7ca..5995602d 100644 --- a/common/models/receiver/Receiver_customers_model.php +++ b/common/models/receiver/Receiver_customers_model.php @@ -308,9 +308,10 @@ class Receiver_customers_model extends HD_Model * 解锁线索并分佣 * @param $id * @param $bizId + * @param bool $deductBizMoney 是否需要扣除门店费用 * @return MyResponse */ - public function unlock($id, $bizId) + public function unlock($id, $bizId, $deductBizMoney = true) { $log_path = "customer_unlock.log"; $this->load->model('receiver/receiver_clues_model'); @@ -348,10 +349,12 @@ class Receiver_customers_model extends HD_Model if (!is_numeric($res)) { throw new Exception('更新优惠券状态失败'); } - //扣除门店金额 - $res = $this->deductBizMoney($row['rid'], $bizId); - if (!$res->isSuccess()) { - throw new Exception($res->getMessage()); + if ($deductBizMoney) { + //扣除门店金额 + $res = $this->deductBizMoney($row['rid'], $bizId); + if (!$res->isSuccess()) { + throw new Exception($res->getMessage()); + } } $this->db->trans_commit(); $this->auto_user_coupon_model->db->trans_commit();