market_groups_1208
This commit is contained in:
@@ -54,10 +54,11 @@ class Temp extends HD_Controller
|
||||
$bizId = $re['organizationId'];
|
||||
}
|
||||
}
|
||||
if ($bizId) {
|
||||
$ret = $this->mdSyliveUser->update(['bizId' => $bizId], ['userId' => $v['userId']]);
|
||||
$topOrgId = $this->getTopOrgId($v['organizationId']);
|
||||
if ($bizId || $topOrgId) {
|
||||
$ret = $this->mdSyliveUser->update(['bizId' => $bizId, 'topOrgId' => $topOrgId], ['userId' => $v['userId']]);
|
||||
if ($ret) {
|
||||
$log[] = ['userId' => $v['userId'], 'bizId' => $bizId];
|
||||
$log[] = ['userId' => $v['userId'], 'bizId' => $bizId, 'topOrgId' => $topOrgId];
|
||||
$counts++;
|
||||
}
|
||||
}
|
||||
@@ -72,6 +73,29 @@ class Temp extends HD_Controller
|
||||
ob_end_flush();//输出全部内容到浏览器
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:获取顶级机构id
|
||||
* Created on: 2022/12/8 14:39
|
||||
* Created by: dengbw
|
||||
* @param $organizationId
|
||||
* @param $topOrgId
|
||||
* @return mixed
|
||||
*/
|
||||
private function getTopOrgId($organizationId, $topOrgId = 0)
|
||||
{
|
||||
$re = $this->mdSyliveOrganization->get(['organizationId' => $organizationId], 'organizationId,parentId');
|
||||
if (!$re) {
|
||||
return $topOrgId;
|
||||
} else {
|
||||
$topOrgId = $re['organizationId'];
|
||||
if ($re['parentId']) {
|
||||
return $this->getTopOrgId($re['parentId'], $topOrgId);
|
||||
} else {
|
||||
return $topOrgId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:更新门店日志
|
||||
* Created on: 2022/3/09 11:58
|
||||
|
||||
@@ -29,7 +29,7 @@ class User extends Admin
|
||||
}
|
||||
$row = $this->market_sylive_organization_model->get(['organizationId' => $this->biz_id]);
|
||||
$org_arr = $this->sylive_entity->get_level_lists($this->session['org_id']);
|
||||
$headimg = $org_arr[0]['logo'] ? build_qiniu_image_url($org_arr[0]['logo']):Sylive_entity::HD_IMG;
|
||||
$headimg = $org_arr[0]['logo'] ? build_qiniu_image_url($org_arr[0]['logo']) : Sylive_entity::HD_IMG;
|
||||
$this->data['headimg'] = $headimg;
|
||||
$this->data['biz_name'] = $row['organizationName'];
|
||||
$this->data['biz_id'] = $this->biz_id;
|
||||
@@ -94,13 +94,15 @@ class User extends Admin
|
||||
$this->show_json('', 400, '门店未添加顾问类型,请联系管理员');
|
||||
}
|
||||
$organizationId = $re_org['organizationId'];
|
||||
$re = $this->user_model->get(['mobile' => $mobile]);
|
||||
$topOrgId = $this->getTopOrgId($organizationId);
|
||||
$re = $this->user_model->get(['mobile' => $mobile, 'topOrgId' => $topOrgId]);
|
||||
if ($re && $re['status'] != -1) {
|
||||
if ($re['teamId'] || $re['organizationId']) {
|
||||
$this->show_json('', 400, '手机号已存在');
|
||||
}
|
||||
}
|
||||
$addDate = ['organizationId' => $organizationId, 'uname' => $uname, 'status' => 0, 'teamId' => 0];
|
||||
$addDate = ['topOrgId' => $topOrgId, 'organizationId' => $organizationId, 'biz_id' => $this->biz_id,
|
||||
'uname' => $uname, 'status' => 0, 'teamId' => 0];
|
||||
if ($re['userId']) {
|
||||
$this->user_model->update($addDate, ['userId' => $re['userId']]);
|
||||
$this->show_json('', 200, '绑定用户成功');
|
||||
@@ -139,7 +141,7 @@ class User extends Admin
|
||||
if ($re['mobile'] == $mobile) {
|
||||
$uppDate = ['uname' => $uname];
|
||||
} else {
|
||||
$re = $this->user_model->get(['mobile' => $mobile]);
|
||||
$re = $this->user_model->get(['mobile' => $mobile, 'topOrgId' => $re['topOrgId']]);
|
||||
if ($re && $re['status'] != -1) {
|
||||
if ($re['teamId'] || $re['organizationId']) {
|
||||
$this->show_json('', 400, '手机号已存在');
|
||||
@@ -165,4 +167,27 @@ class User extends Admin
|
||||
$this->show_json('', 200, '操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:获取顶级机构id
|
||||
* Created on: 2022/12/8 14:39
|
||||
* Created by: dengbw
|
||||
* @param $organizationId
|
||||
* @param $topOrgId
|
||||
* @return mixed
|
||||
*/
|
||||
private function getTopOrgId($organizationId, $topOrgId = 0)
|
||||
{
|
||||
$re = $this->mdSyliveOrganization->get(['organizationId' => $organizationId], 'organizationId,parentId');
|
||||
if (!$re) {
|
||||
return $topOrgId;
|
||||
} else {
|
||||
$topOrgId = $re['organizationId'];
|
||||
if ($re['parentId']) {
|
||||
return $this->getTopOrgId($re['parentId'], $topOrgId);
|
||||
} else {
|
||||
return $topOrgId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -155,6 +155,43 @@ class Activity extends BaseController
|
||||
$this->return_response_list($date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:活动详情
|
||||
* Created on: 2022/9/29 10:37
|
||||
* Created by: dengbw
|
||||
* @param null $activityId
|
||||
*/
|
||||
public function index_get($activityId = null)
|
||||
{
|
||||
if (!$activityId) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
$re = $this->mdSyliveActivity->get(['activityId' => $activityId], 'activityId,title');
|
||||
if (!$re) {
|
||||
$this->return_json('活动不存在');
|
||||
}
|
||||
$this->return_response($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:复制活动
|
||||
* Created on: 2022/12/8 10:08
|
||||
* Created by: dengbw
|
||||
* @param null $activityId
|
||||
*/
|
||||
public function copy_get($activityId = null)
|
||||
{
|
||||
if (!$activityId) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
$re = $this->mdSyliveActivity->get(['activityId' => $activityId]);
|
||||
if (!$re) {
|
||||
$this->return_json('活动不存在');
|
||||
}
|
||||
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:添加活动
|
||||
* Created on: 2022/9/21 16:46
|
||||
@@ -247,24 +284,6 @@ class Activity extends BaseController
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:活动详情
|
||||
* Created on: 2022/9/29 10:37
|
||||
* Created by: dengbw
|
||||
* @param null $activityId
|
||||
*/
|
||||
public function index_get($activityId = null)
|
||||
{
|
||||
if (!$activityId) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
$re = $this->mdSyliveActivity->get(['activityId' => $activityId], 'activityId,title');
|
||||
if (!$re) {
|
||||
$this->return_json('活动不存在');
|
||||
}
|
||||
$this->return_response($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:修改活动
|
||||
* Created on: 2022/9/21 14:48
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
require_once APPPATH . 'controllers/api/BaseController.php';
|
||||
|
||||
/**
|
||||
* Notes:私域直播_分组订单管理
|
||||
* Created on: 2022/12/08 17:15
|
||||
* Created by: dengbw
|
||||
*/
|
||||
class groupsOrder extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('market/Market_sylive_order_model', 'mdSyliveOrder');
|
||||
$this->load->model('market/Market_sylive_user_model', 'mdSyliveUser');
|
||||
$this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization');
|
||||
$this->load->model('market/Market_sylive_team_model', 'mdSyliveTeam');
|
||||
$this->load->model('market/Market_sylive_activity_kpidata_model', 'mdSyliveActivityKpidata');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
private function orderList($params)
|
||||
{
|
||||
$activityId = intval($params['activityId']);
|
||||
$page = $params['page'];
|
||||
$limit = $params['limit'];
|
||||
$uname = $params['uname'];
|
||||
$mobile = $params['mobile'];
|
||||
$status = $params['status'];
|
||||
$cfrom = $params['cfrom'];
|
||||
$type = $params['type'];
|
||||
$sort = $params['sort'];
|
||||
$order = $params['order'];
|
||||
$bizId = $params['bizId'];
|
||||
$teamId = $params['teamId'];
|
||||
$itemId = $params['itemId'];
|
||||
!$page && $page = 1;
|
||||
!$limit && $limit = 10;
|
||||
$sort_order = 'id desc';
|
||||
if ($sort && $order) {
|
||||
if ($sort == 'statusName') {
|
||||
$sort_order = 'status ' . $order;
|
||||
} else if ($sort == 'typeName') {
|
||||
$sort_order = 'type ' . $order;
|
||||
} else if ($sort == 'cfromName') {
|
||||
$sort_order = 'cfrom ' . $order;
|
||||
} else {
|
||||
$sort_order = $sort . ' ' . $order;
|
||||
}
|
||||
}
|
||||
$list = [];
|
||||
if (!strlen($status)) {
|
||||
$status = 1;
|
||||
}
|
||||
$where['status'] = $status;
|
||||
$activityId && $where['activityId'] = $activityId;
|
||||
$itemId && $where['itemId'] = $itemId;
|
||||
$uname && $where['uname LIKE "%' . trim($uname) . '%"'] = null;
|
||||
$mobile && $where['mobile LIKE "%' . trim($mobile) . '%"'] = null;
|
||||
strlen($cfrom) && $where['cfrom'] = $cfrom;
|
||||
strlen($type) && $where['type'] = $type;
|
||||
$cfrom == 1 && $bizId = 0;
|
||||
if ($bizId) {
|
||||
$res_org = $this->mdSyliveOrganization->get(["organizationId" => $bizId]);
|
||||
if ($res_org) {
|
||||
if ($res_org['organizationType'] == 3) {//门店
|
||||
$where['bizId'] = $bizId;
|
||||
} else if ($res_org['organizationType'] == 2) {//大区
|
||||
$where['areaId'] = $bizId;
|
||||
}
|
||||
}
|
||||
} elseif ($teamId) {
|
||||
$res_team = $this->mdSyliveTeam->get(["teamId" => $bizId]);
|
||||
if ($res_team) {
|
||||
if ($res_team['teamType'] == 2) {//团队
|
||||
$where['bizId'] = $bizId;
|
||||
} else if ($res_team['teamType'] == 1) {//总部
|
||||
$where['areaId'] = $bizId;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($limit == 10000) {
|
||||
$count = $limit;
|
||||
} else {
|
||||
$count = $this->mdSyliveOrder->count($where);
|
||||
}
|
||||
if ($count) {
|
||||
$res = $this->mdSyliveOrder->select($where, $sort_order, $page, $limit);
|
||||
foreach ($res as $v) {
|
||||
$consultant = $this->consultantGet(['activityId' => $v['activityId'], 'userId' => $v['userId']
|
||||
, 'areaId' => $v['areaId'], 'bizId' => $v['bizId'], 'cfrom' => $v['cfrom'], 'cfUserId' => $v['cfUserId']]);
|
||||
$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'] : ''
|
||||
, 'typeName' => $this->mdSyliveOrder->typeAry($v['type'])
|
||||
, 'statusName' => $this->mdSyliveOrder->statusAry($v['status']), 'cfromName' => $this->mdSyliveOrder->cfromAry($v['cfrom'])
|
||||
, 'createTime' => $v['createTime'], 'area' => $consultant['area'], 'stores' => $consultant['stores'], 'consultant' => $consultant['consultant']
|
||||
];
|
||||
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)
|
||||
{
|
||||
$area = $stores = $consultant = '';
|
||||
$areaId = intval($params['areaId']);
|
||||
$bizId = intval($params['bizId']);
|
||||
$cfUserId = intval($params['cfUserId']);
|
||||
if (!$bizId) {
|
||||
$re = $this->mdSyliveActivityKpidata->get(['activityId' => $params['activityId'], 'userId' => $params['userId']
|
||||
, 'type' => $params['cfrom'], 'kpi' => 'order']);
|
||||
if ($re) {
|
||||
$areaId = $re['areaId'];
|
||||
$bizId = $re['bizId'];
|
||||
$cfUserId = $re['cfUserId'];
|
||||
}
|
||||
}
|
||||
if ($params['cfrom'] == 1) {
|
||||
$res_teama = $this->mdSyliveTeam->get(["teamId" => $areaId]);
|
||||
$res_teamb = $this->mdSyliveTeam->get(["teamId" => $bizId]);
|
||||
$res_teama['teamName'] && $area = $res_teama['teamName'];
|
||||
$res_teamb['teamName'] && $stores = $res_teamb['teamName'];
|
||||
} else {
|
||||
$res_orga = $this->mdSyliveOrganization->get(["organizationId" => $areaId]);
|
||||
$res_orgb = $this->mdSyliveOrganization->get(["organizationId" => $bizId]);
|
||||
$res_orga['organizationName'] && $area = $res_orga['organizationName'];
|
||||
$res_orgb['organizationName'] && $stores = $res_orgb['organizationName'];
|
||||
}
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $cfUserId]);
|
||||
$re_user['uname'] && $consultant = $re_user['uname'];
|
||||
return ['area' => $area, 'stores' => $stores, 'consultant' => $consultant];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class Order extends BaseController
|
||||
* Created on: 2022/11/08 14:48
|
||||
* Created by: dengbw
|
||||
*/
|
||||
public function page_get()
|
||||
public function index_get()
|
||||
{
|
||||
$date = $this->orderList($this->inputs);
|
||||
$this->return_response_list($date);
|
||||
|
||||
@@ -76,7 +76,12 @@ class User extends BaseController
|
||||
$keyword = trim($this->input_param('keyword'));
|
||||
$where = ['status>=' => 0, 'organizationId>' => 0];
|
||||
if ($keyword) {
|
||||
$this->load->model('market/Market_sylive_activity_model', 'mdSyliveActivity');
|
||||
$where["(uname LIKE '%{$keyword}%' OR mobile LIKE '%{$keyword}%')"] = null;
|
||||
$re = $this->mdSyliveActivity->get(['activityId' => $activityId]);
|
||||
if ($re['organizationId']) {//找当前顶级机构用户
|
||||
$where["topOrgId"] = $re['organizationId'];
|
||||
}
|
||||
} else if ($organizationIds) {
|
||||
$organizationIds = implode(',', $organizationIds);
|
||||
$where["organizationId in({$organizationIds}) or bizId in({$organizationIds})"] = null;
|
||||
@@ -142,10 +147,11 @@ class User extends BaseController
|
||||
if (!$uname) {
|
||||
$this->return_json('请输入姓名');
|
||||
}
|
||||
$re = $this->mdSyliveUser->get(['mobile' => $mobile]);
|
||||
$topOrgId = $this->getTopOrgId($organizationId);
|
||||
$re = $this->mdSyliveUser->get(['mobile' => $mobile, 'topOrgId' => $topOrgId]);
|
||||
if ($re && $re['status'] != -1) {
|
||||
if ($re['teamId'] || $re['organizationId']) {
|
||||
$this->return_json('手机号已存在');
|
||||
$this->return_json('手机号已存在当前机构');
|
||||
}
|
||||
}
|
||||
$bizId = 0;
|
||||
@@ -157,7 +163,8 @@ class User extends BaseController
|
||||
$bizId = $re_org['organizationId'];
|
||||
}
|
||||
}
|
||||
$addDate = ['organizationId' => $organizationId, 'uname' => $uname, 'bizId' => $bizId, 'status' => 0, 'teamId' => 0];
|
||||
$addDate = ['topOrgId' => $topOrgId, 'organizationId' => $organizationId, 'uname' => $uname,
|
||||
'bizId' => $bizId, 'status' => 0, 'teamId' => 0];
|
||||
if ($re['userId']) {
|
||||
$this->mdSyliveUser->update($addDate, ['userId' => $re['userId']]);
|
||||
$this->return_response([], '绑定用户成功');
|
||||
@@ -191,6 +198,17 @@ class User extends BaseController
|
||||
if (!$uname) {
|
||||
$this->return_json('请输入姓名');
|
||||
}
|
||||
$re = $this->mdSyliveUser->get(['userId' => $userId]);
|
||||
if (!$re) {
|
||||
$this->return_json('无此用户');
|
||||
}
|
||||
$topOrgId = $re['topOrgId'];
|
||||
if ($re['organizationId'] != $organizationId) {
|
||||
$topOrgId = $this->getTopOrgId($organizationId);
|
||||
if ($re['topOrgId'] && $re['topOrgId'] != $topOrgId) {
|
||||
$this->return_json('不可修改顶级机构');
|
||||
}
|
||||
}
|
||||
$bizId = 0;
|
||||
$re_org = $this->mdSyliveOrganization->get(['organizationId' => $organizationId]);
|
||||
if ($re_org) {
|
||||
@@ -200,7 +218,7 @@ class User extends BaseController
|
||||
$bizId = $re_org['organizationId'];
|
||||
}
|
||||
}
|
||||
$upDate = ['organizationId' => $organizationId, 'bizId' => $bizId, 'teamId' => 0, 'uname' => $uname];
|
||||
$upDate = ['topOrgId' => $topOrgId, 'organizationId' => $organizationId, 'bizId' => $bizId, 'teamId' => 0, 'uname' => $uname];
|
||||
$this->mdSyliveUser->update($upDate, ['userId' => $userId]);
|
||||
$this->return_response();
|
||||
}
|
||||
@@ -245,9 +263,10 @@ class User extends BaseController
|
||||
{
|
||||
$field = $this->input_param('field');
|
||||
$value = $this->input_param('value');
|
||||
$id = $this->input_param('id');
|
||||
if (!$id) {
|
||||
$where = [$field => $value, 'status<>' => -1];
|
||||
$organizationId = intval($this->input_param('organizationId'));
|
||||
if ($organizationId) {
|
||||
$topOrgId = $this->getTopOrgId($organizationId);
|
||||
$where = [$field => $value, 'topOrgId' => $topOrgId, 'status>=' => 0];
|
||||
$re = $this->mdSyliveUser->get($where);
|
||||
if ($re) {
|
||||
if ($field == 'mobile') {
|
||||
@@ -262,4 +281,27 @@ class User extends BaseController
|
||||
$this->return_json('不存在', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:获取顶级机构id
|
||||
* Created on: 2022/12/8 14:39
|
||||
* Created by: dengbw
|
||||
* @param $organizationId
|
||||
* @param $topOrgId
|
||||
* @return mixed
|
||||
*/
|
||||
private function getTopOrgId($organizationId, $topOrgId = 0)
|
||||
{
|
||||
$re = $this->mdSyliveOrganization->get(['organizationId' => $organizationId], 'organizationId,parentId');
|
||||
if (!$re) {
|
||||
return $topOrgId;
|
||||
} else {
|
||||
$topOrgId = $re['organizationId'];
|
||||
if ($re['parentId']) {
|
||||
return $this->getTopOrgId($re['parentId'], $topOrgId);
|
||||
} else {
|
||||
return $topOrgId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user