market_order_import
This commit is contained in:
@@ -254,6 +254,24 @@ class OrganizationUser extends BaseController
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:批量删除用户
|
||||
* Created on: 2022/9/8 17:11
|
||||
* Created by: dengbw
|
||||
*/
|
||||
public function batch_delete()
|
||||
{
|
||||
$ids = $this->input_param('ids');
|
||||
if (!$ids) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
$str_ids = implode(',', $ids);
|
||||
if ($str_ids) {
|
||||
$this->mdSyliveUser->update(['status' => -1], ["userId in($str_ids)" => null]);
|
||||
}
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:栓验字段
|
||||
* Created on: 2022/9/21 15:52
|
||||
|
||||
@@ -275,7 +275,7 @@ class Activity extends BaseController
|
||||
}
|
||||
$jsondata['bottoms'] = $setBottoms;
|
||||
$jsondata['blacklist'] = intval($this->input_param('blacklist'));
|
||||
!$signBespeak['status'] && $signBespeak = ['status' => 0, 'title' => '', 'content' => '', 'itemId' => ''];
|
||||
!$signBespeak['status'] && $signBespeak = ['status' => 0, 'title' => '', 'content' => '', 'itemId' => ''];
|
||||
$jsondata['signBespeak'] = $signBespeak;
|
||||
$jsondata['barrage'] = $this->input_param('barrage');
|
||||
$jsondata['button'] = $this->input_param('button');
|
||||
@@ -375,7 +375,7 @@ class Activity extends BaseController
|
||||
$jsondata['banner'] = $banner;
|
||||
$jsondata['serviceLink'] = $serviceLink;
|
||||
$jsondata['blacklist'] = intval($this->input_param('blacklist'));
|
||||
!$signBespeak['status'] && $signBespeak = ['status' => 0, 'title' => '', 'content' => '', 'itemId' => ''];
|
||||
!$signBespeak['status'] && $signBespeak = ['status' => 0, 'title' => '', 'content' => '', 'itemId' => ''];
|
||||
$jsondata['signBespeak'] = $signBespeak;
|
||||
$jsondata['barrage'] = $this->input_param('barrage');
|
||||
$jsondata['button'] = $this->input_param('button');
|
||||
@@ -551,7 +551,7 @@ class Activity extends BaseController
|
||||
*/
|
||||
public function batch_delete()
|
||||
{
|
||||
$ids = $this->inputs;
|
||||
$ids = $this->input_param('ids');
|
||||
if (!$ids) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ class groupsOrder extends BaseController
|
||||
$consultant = $this->consultantGet(['activityId' => $v['activityId'], 'userId' => $v['userId']
|
||||
, 'levelId1' => $v['levelId1'], 'levelId2' => $v['levelId2'], 'levelId3' => $v['levelId3']
|
||||
, 'bizId' => $v['bizId'], 'cfUserId' => $v['cfUserId']]);
|
||||
$insiders = $map_user[$v['userId']]? '是' : '否';//内部人员
|
||||
$insiders = $map_user[$v['userId']] ? '是' : '否';//内部人员
|
||||
$list1 = [
|
||||
'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'] : ''
|
||||
@@ -241,4 +241,140 @@ class groupsOrder extends BaseController
|
||||
'levelName2' => $levelName2, 'levelName3' => $levelName3];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:导入订单
|
||||
* Created on: 2023/4/26 17:24
|
||||
* Created by: dengbw
|
||||
* @throws PHPExcel_Exception
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function import_post()
|
||||
{
|
||||
$activityId = intval($_POST['activityId']);
|
||||
if (!$activityId) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
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请拆分多个表格导入');
|
||||
}
|
||||
$this->load->model('market/Market_sylive_items_model', 'mdSyliveItems');
|
||||
$this->load->model('market/Market_sylive_groups_user_model', 'mdSyliveGroupsUser');
|
||||
$done = 0;
|
||||
for ($_row = 2; $_row <= $rowCnt; $_row++) { //读取内容
|
||||
$mobile = $objWorksheet->getCell('B' . $_row)->getValue();
|
||||
if ($mobile) {
|
||||
$re_order = $this->mdSyliveOrder->get(['mobile' => $mobile, "activityId" => $activityId]);
|
||||
if (!$re_order) {
|
||||
$addData["uname"] = $objWorksheet->getCell('A' . $_row)->getValue();
|
||||
$addData["totalPrice"] = $objWorksheet->getCell('C' . $_row)->getValue();
|
||||
$addData["itemTitle"] = $objWorksheet->getCell('D' . $_row)->getValue();
|
||||
$addData["createTime"] = $objWorksheet->getCell('E' . $_row)->getValue();
|
||||
$bizName = $objWorksheet->getCell('F' . $_row)->getValue();
|
||||
$cfMobile = $objWorksheet->getCell('H' . $_row)->getValue();
|
||||
$addData["mobile"] = $mobile;
|
||||
$addData["status"] = 1;
|
||||
$addData["activityId"] = $activityId;
|
||||
if ($addData["itemTitle"]) {
|
||||
$re_order = $this->mdSyliveItems->get(['title' => $addData["itemTitle"], "activityId" => $activityId]);
|
||||
if ($re_order) {
|
||||
$addData["itemId"] = $re_order['itemId'];
|
||||
$addData["itemPrice"] = $re_order['price'];
|
||||
}
|
||||
}
|
||||
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['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'];
|
||||
}
|
||||
$id = $this->mdSyliveOrder->add($addData);
|
||||
if ($id) {
|
||||
$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 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']];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -237,7 +237,7 @@ class User extends BaseController
|
||||
*/
|
||||
public function batch_delete()
|
||||
{
|
||||
$ids = $this->inputs;
|
||||
$ids = $this->input_param('ids');
|
||||
if (!$ids) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user