'商品成本编号', 'good_code' => '商品编码', 'good_name' => '商品名称', 'cat_id' => '分类', 'brand_id' => '品牌', 'good_unit' => '商品单位', 'good_type' => '', 'companyNo' => '业务企业', 'moq' => '起订量', 'customized' => '定制工期', 'tax' => '税点', 'supplierNo' => '供应商', 'is_auth' => '是否有销售权限', 'is_stock' => '是否库存品', 'auth_img' => '销售授权图片', 'after_sales' => '售后说明', 'craft_desc' => '工艺说明', 'good_remark' => '商品备注', 'good_size' => '商品尺寸', 'weight' => '商品重量', 'packing_way' => '包装方式', 'packing_size' => '装箱尺寸', 'packing_spec' => '装箱规格', 'packing_list' => '包装清单', 'packing_weight' => '装箱重量', 'good_bar' => '商品条形码', 'supply_area' => '供货区域', 'delivery_place' => '发货地', 'origin_place' => '产地', 'delivery_day' => '物流时间', 'lead_time' => '供货周期', 'sample_day' => '调样周期', 'sample_fee' => '调样费用', 'good_img' => '商品详情主图 ', 'good_thumb_img' => '商品缩略图', 'good_info_img' => '商品详情图', 'cert_fee' => '证书费', 'packing_fee' => '包装费', 'cost_fee' => '工艺费', 'mark_fee' => '加标费', 'demo_fee' => '打样费', 'open_fee' => '开模费', 'noble_metal' => '贵金属种类', 'noble_weight' => '贵金属重量', 'is_gold_price' => '是否使用实时金价', 'cgd_gold_price' => '供应商采购金价', 'market_price' => '市场价', 'nake_price' => '含税成本价', 'is_step' => '阶梯价是否启用', 'is_online' => '是否上线', 'status' => '状态', 'createrid' => '创建人id', 'creater' => '创建人', 'is_del' => '是否删除', 'addtime' => '创建时间', 'updatetime' => '修改时间', 'is_exclusive' => '是否专属类型', 'is_diff' => '是否有工差', 'config' => '配置', 'other_config' => '其他配置', ]; //产品价格和产品导出 public function exportGood() { $param = $this->request->only(['start_date', 'end_date', 'platform_id', 'status'], 'post', 'trim'); $val = Validate::rule([ 'start_date|筛选开始时间' => 'require|date|elt:end_date', 'end_date|筛选结束时间' => 'require|date', 'platform_id|筛选平台ID' => 'require|number|gt:0', 'status|状态' => 'require|number|in:1,2,3,4,5', ]); if (!$val->check($param)) return json_show(1004, $val->getError()); $where_ladder = [['gl.is_del', '=', 0]]; $where_good = [['g.is_del', '=', 0]]; if (!empty($param['start_date']) && !empty($param['end_date'])) { $where_ladder[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; $where_good[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; } if (!empty($param['platform_id'])) { $where_ladder[] = ['gp.platform_code', '=', $param['platform_id']]; $where_good[] = ['gp.platform_code', '=', $param['platform_id']]; } if (!empty($param['status'])) { $where_ladder[] = ['gp.exam_status', '=', $param['status']]; $where_good[] = ['gp.exam_status', '=', $param['status']]; } $data = []; //产品价格 $rs_ladder = Db::name('good_ladder') ->alias('gl') ->field('g.good_name 商品名称,gl.market_price 市场价,g.tax 税率,gl.min_num 起订量,gl.sale_price 售价,gl.skuCode 商品编码,gl.cost_fee 工艺费,gl.market_platform 对比平台') ->where($where_ladder) ->leftJoin('good_platform gp', 'gp.skuCode=gl.skuCode') ->leftJoin('good g', 'g.spuCode=gp.spuCode') ->order('g.id') ->select() ->toArray(); if (!empty($rs_ladder)) { $data[] = [ 'head' => array_keys($rs_ladder[0]), 'list' => $rs_ladder, 'filename' => '产品价格' . date('YmdHis'), ]; } //产品 $rs_temp_good = Db::name('good') ->alias('g') ->field('"" 一级分类,"" 二级分类, g.cat_id 三级分类,g.good_name 商品名称,g.good_type 商品类型,g.brand_id 商品品牌,\'\' 型号,g.origin_place 产地,g.good_unit 计量单位,g.weight 重量g,\'\' 响应时间,g.lead_time 供货周期,g.good_size 商品尺寸,g.packing_size 装箱尺寸,g.packing_way 包装方式,g.packing_spec 装箱规格,g.packing_list 包装清单,g.delivery_place 发货地,g.delivery_day 物流时间,gp.skuCode 商品编码,g.supplierNo 供应商名称,g.creater 采购员,g.spuCode') ->where($where_good) ->leftJoin('good_platform gp', 'gp.spuCode=g.spuCode') // ->leftJoin('supplier s', 's.code=g.supplierNo') ->order('g.id') ->select() ->toArray(); $supplerArr = array_column($rs_temp_good, "供应商名称"); $userCommon = \app\admin\common\User::getIns(); $supplier_temp = $userCommon->handle('getCodeAndName', ['code' => $supplerArr]); $supplier = $supplier_temp['data'] ?? []; $all_good_type = [0 => '非定制商品', 1 => '定制商品']; $all_brand = Db::name('brand')->whereIn('id', array_column($rs_temp_good, '商品品牌'))->where('is_del', 0)->column('brand_name', 'id'); $all_cat = Db::name('cat') ->alias('c3') ->whereIn('c3.id', array_column($rs_temp_good, '三级分类')) ->where('c3.is_del', 0) ->leftJoin('cat c2', 'c2.id=c3.pid') ->leftJoin('cat c1', 'c1.id=c2.pid') ->column('c3.cat_name cat_name_3,c2.cat_name cat_name_2,c1.cat_name cat_name_1', 'c3.id'); $all_unit = Db::name('unit')->whereIn('id', array_column($rs_temp_good, '计量单位'))->where('is_del', 0)->column('unit', 'id'); foreach ($rs_temp_good as &$value) { $value['商品品牌'] = isset($all_brand[$value['商品品牌']]) ? $all_brand[$value['商品品牌']] : ''; $value['商品类型'] = isset($all_good_type[$value['商品类型']]) ? $all_good_type[$value['商品类型']] : ''; $value['一级分类'] = isset($all_cat[$value['三级分类']]['cat_name_1']) ? $all_cat[$value['三级分类']]['cat_name_1'] : ''; $value['二级分类'] = isset($all_cat[$value['三级分类']]['cat_name_2']) ? $all_cat[$value['三级分类']]['cat_name_2'] : ''; $value['三级分类'] = isset($all_cat[$value['三级分类']]['cat_name_3']) ? $all_cat[$value['三级分类']]['cat_name_3'] : ''; $value['供应商名称'] = $supplier[$value['供应商名称']] ?? ""; $temp = explode(',', $value['产地']); $value['产地'] = GetAddr(json_encode(['provice_code' => isset($temp[0]) ? $temp[0] : '', 'city_code' => isset($temp[1]) ? $temp[1] : '', 'area_code' => isset($temp[2]) ? $temp[2] : ''])); $value['计量单位'] = isset($all_unit[$value['计量单位']]) ? $all_unit[$value['计量单位']] : ''; $temp_2 = explode(',', $value['发货地']); $value['发货地'] = GetAddr(json_encode(['provice_code' => isset($temp_2[0]) ? $temp_2[0] : '', 'city_code' => isset($temp_2[1]) ? $temp_2[1] : '', 'area_code' => isset($temp_2[2]) ? $temp_2[2] : ''])); $value['型号'] = Db::name('good_spec') ->alias('gp') ->field('') ->leftJoin('specs s', 's.id=gp.spec_id') ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id') ->where([ 'gp.spuCode' => $value['spuCode'], 'gp.is_del' => 0, 's.spec_name' => '型号', ]) ->value('sv.spec_value', ''); $value['响应时间'] = Db::name('good_spec') ->alias('gp') ->field('') ->leftJoin('specs s', 's.id=gp.spec_id') ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id') ->where([ 'gp.spuCode' => $value['spuCode'], 'gp.is_del' => 0, 's.spec_name' => '响应时间', ]) ->value('sv.spec_value', ''); unset($value['spuCode']); } if (!empty($rs_temp_good)) { $data[] = [ 'head' => array_keys($rs_temp_good[0]), 'list' => $rs_temp_good, 'filename' => '产品' . date('YmdHis'), ]; } if (empty($data)) { $data[] = [ 'head' => ['没有可供导出的数据'], 'list' => [], 'filename' => date('YmdHis'), ]; } excelSaveBatch($data); } //【一、采购日报表】1.竞价单总数 public function zixunTotal() { $param = $this->request->only([ 'token', 'start_date' =>date('Y-m-01'), 'end_date' => date('Y-m-d'), ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['a.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['a.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; // $count = Db::name('consult_info') // ->alias('a') // ->field('DATE_FORMAT(a.addtime,"%Y-%m-%d") addtime,cii.name,count(a.id) total') // ->leftJoin('consult_order b', 'b.zxNo=a.zxNo') // ->leftJoin('depart_user c', 'c.uid=b.saleid AND c.is_del=0') // ->leftJoin('company_item cii', 'cii.id=c.itemid') // ->where($where) // ->group('addtime,cii.id') // ->order('addtime') // ->count(); $list = Db::name('consult_info') ->alias('a') ->field('DATE_FORMAT(a.addtime,"%Y-%m-%d") addtime,b.saleid,count(a.id) total') ->leftJoin('consult_order b', 'b.zxNo=a.zxNo') // ->leftJoin('depart_user c', 'c.uid=b.saleid AND c.is_del=0') // ->leftJoin('company_item cii', 'cii.id=c.itemid') ->where($where) ->group('addtime,b.saleid') ->order('addtime', 'desc') // ->page($param['page'], $param['size']) ->select() ->toArray(); $saleArr=array_unique(array_column($list,"saleid")); $departArr =get_company_name_by_uid($saleArr); $data=[]; foreach ($list as $value) { $depart=$departArr[$value['saleid']] ?? '0'; if (!isset($data[$value['addtime'] . '-' . $depart])) $data[$value['addtime'] . '-' . $depart]=['addtime'=>$value['addtime'] , 'name'=>$depart , 'total'=>0]; $data[$value['addtime'] . '-' . $depart]['total']+=$value['total']; } return json_show(0 , '请求成功' , array_values($data)); } //【一、采购日报表】2.采购订单总金额 public function purcheaseOrderSum() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', // 'page' => 1, // 'size' => 15, ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date|创建开始日期' => 'date|elt:end_date', 'end_date|创建结束日期' => 'date|egt:start_date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['po.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['po.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; $list = Db::name('purchease_order') ->alias('po') ->field('po.id,DATE_FORMAT(po.addtime,"%Y%m%d") addtime,po.cgder_id,0 itemid,"" name,po.total_fee,po.good_num,po.status,po.supplierNo') ->where($where) ->order(['addtime' => 'desc', 'itemid' => 'asc']) ->select() ->toArray(); $all_supplier_no =array_unique(array_column($list, 'supplierNo')) ; $all_cgder_id =array_unique(array_column($list, 'cgder_id')) ; $all_supplier = checkHasAccountBySupplierNos($all_supplier_no);//检查这些供应商账号是否开通账户 $all_cgder = get_company_name_by_uid($all_cgder_id);//检查这些供应商账号是否开通账户 $all_supplier = array_keys($all_supplier); $data = []; foreach ($list as $value) { if (!isset($data[$value['addtime']][$value['itemid']])) { $data[$value['addtime']][$value['itemid']] = [ 'addtime' => date('Y-m-d', strtotime($value['addtime'])), 'name' => $all_cgder [$value['cgder_id']]??"", 'total_fee' => '0', 'total_num' => '0', 'good_num' => '0', 'wait_confirm_total_fee' => '0',//待与供应商确认-总金额 'wait_confirm_total_num' => '0',//待与供应商确认-总单数 'wait_in_total_fee' => '0',//待入库-总金额 'wait_in_total_num' => '0',//待入库-总单数 ]; } $data[$value['addtime']][$value['itemid']]['total_fee'] = bcadd($data[$value['addtime']][$value['itemid']]['total_fee'], $value['total_fee'], 2); $data[$value['addtime']][$value['itemid']]['total_num'] = bcadd($data[$value['addtime']][$value['itemid']]['total_num'], 1); $data[$value['addtime']][$value['itemid']]['good_num'] = bcadd($data[$value['addtime']][$value['itemid']]['good_num'], $value['good_num']); switch ($value['status']) { case 0: $data[$value['addtime']][$value['itemid']]['wait_confirm_total_fee'] = bcadd($data[$value['addtime']][$value['itemid']]['wait_confirm_total_fee'], $value['total_fee'], 2); $data[$value['addtime']][$value['itemid']]['wait_confirm_total_num'] = bcadd($data[$value['addtime']][$value['itemid']]['wait_confirm_total_num'], '1'); break; case 1: $data[$value['addtime']][$value['itemid']]['wait_in_total_fee'] = bcadd($data[$value['addtime']][$value['itemid']]['wait_in_total_fee'], $value['total_fee'], 2); $data[$value['addtime']][$value['itemid']]['wait_in_total_num'] = bcadd($data[$value['addtime']][$value['itemid']]['wait_in_total_num'], 1); break; } } //去除下标 $da = []; foreach ($data as $v) { foreach ($v as $vvv) { $da[] = $vvv; } } return json_show(0, '请求成功', $da); } //【一、采购日报表】3.采购员回复竞价单数 public function consultBidsSum() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['cb.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['cb.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; $list = Db::name('consult_bids') ->alias('cb') ->field('DATE_FORMAT(cb.addtime,"%Y-%m-%d") addtime,cb.createrid,SUM(c.num) num,COUNT(cb.id) total,cb.cgder nickname,"" name,cb.supplierName') ->leftJoin('consult_info c', 'c.infoNo=cb.infoNo') ->where($where) ->group('addtime,cb.createrid,cb.cgder') ->order('addtime desc,cb.createrid') ->cursor(); $data = []; foreach ($list as $value) { $bumen=get_company_name_by_uid([$value['createrid']]); $value['name'] = $bumen[$value['createrid']]??'供应商'; if ($value['name'] == '供应商') { $data[] = $value; continue; } if (!isset($data[$value['addtime']][$value['name']][$value['nickname']])) { $data[$value['addtime']][$value['name']][$value['nickname']] = [ 'addtime' => $value['addtime'], 'name' => $value['name'], 'nickname' => $value['nickname'], 'num' => '0', 'total' => '0', ]; } $data[$value['addtime']][$value['name']][$value['nickname']]['num'] = bcadd($data[$value['addtime']][$value['name']][$value['nickname']]['num'], $value['num']); $data[$value['addtime']][$value['name']][$value['nickname']]['total'] = bcadd($data[$value['addtime']][$value['name']][$value['nickname']]['total'], $value['total']); } //去除下标 $da = []; foreach ($data as $key => $val) { if (is_numeric($key)) $da[] = $val; else { foreach ($val as $val2) { foreach ($val2 as $val3) { $da[] = $val3; } } } } $da[] = ['addtime' => '汇总', 'itemid' => 0, 'createrid' => 0, 'num' => array_sum(array_column($da, 'num')), 'total' => array_sum(array_column($da, 'total')), 'nickname' => '', 'name' => '']; return json_show(0, '请求成功', $da); } //【一、采购日报表】4.采购员订单金额 public function purcheaseOrderSumByUser() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; //先组织子查询 $rs = Db::name('purchease_order') ->field('id,DATE_FORMAT(addtime, "%Y-%m-%d") addtime,cgder_id,cgder,total_fee,status,good_num,supplierNo,supplier_name,0 wait_total_fee,0 wait_good_num,0 count_num') ->where($where) ->order('addtime desc,cgder_id') ->select() ->toArray(); $all_supplier = array_column($rs, 'supplierNo'); $has_account = checkHasAccountBySupplierNos(array_unique($all_supplier));//检查供应商是否开通账号 // $supplier = Db::name('supplier')->whereIn('code', array_keys($has_account))->column('name', 'code'); $data = []; foreach ($rs as $value) { $key = $value['cgder_id']; if (isset($has_account[$value['supplierNo']])) $key = $value['supplierNo'];//如果开通了供应商账号,更改下标 if (!isset($data[$value['addtime']][$key])) { $data[$value['addtime']][$key] = [ 'addtime' => $value['addtime'], 'cgder' => isset($has_account[$value['supplierNo']]) ? $value['supplier_name'] ?? '' : $value['cgder'], 'name' => isset($has_account[$value['supplierNo']]) ? '供应商' : get_company_name_by_uid($key), 'count_num' => '0', 'total_fee' => '0', 'good_num' => '0', 'wait_total_fee' => '0', 'wait_good_num' => '0', ]; } if ($value['status'] == 0) { $data[$value['addtime']][$key]['wait_total_fee'] = bcadd($data[$value['addtime']][$key]['wait_total_fee'], $value['total_fee'], 2); $data[$value['addtime']][$key]['wait_good_num'] = bcadd($data[$value['addtime']][$key]['wait_good_num'], $value['good_num']); } else { $data[$value['addtime']][$key]['total_fee'] = bcadd($data[$value['addtime']][$key]['total_fee'], $value['total_fee'], 2); $data[$value['addtime']][$key]['good_num'] = bcadd($data[$value['addtime']][$key]['good_num'], $value['good_num']); } $data[$value['addtime']][$key]['count_num'] = bcadd($data[$value['addtime']][$key]['count_num'], 1); } $da = []; //去除下标 foreach ($data as $v) { foreach ($v as $vv) { $da[] = $vv; } } return json_show(0, '请求成功', $da); } //【二、咨询单报表】1.已采反报价信息_列表 public function consultInfoBidsSum() { $param = $this->request->only([ 'token', 'zxNo' => [], 'start_date' => '', 'end_date' => '', 'cbaddtime_start_date' => '', 'cbaddtime_end_date' => '', 'supplier' => '', 'creater' => '', 'good_name' => '', 'apply_name' => '', 'page' => 1, 'size' => 15, ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date|竞价开始时间' => 'date|elt:end_date', 'end_date|竞价开始时间' => 'date|egt:start_date', 'cbaddtime_start_date|采购回复开始时间' => 'date|elt:cbaddtime_end_date', 'cbaddtime_end_date|采购回复开始时间' => 'date|egt:cbaddtime_start_date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['cb.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['ci.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['cbaddtime_start_date'] != '' && $param['cbaddtime_end_date'] != '') $where[] = ['cb.addtime', 'between', [$param['cbaddtime_start_date'] . ' 00:00:00', $param['cbaddtime_end_date'] . ' 23:59:59']]; if ($param['supplier'] != '') $where[] = ['cb.supplierNo|cb.supplierName', 'like', '%' . $param['supplier'] .'%']; if ($param['creater'] != '') $where[] = ['cb.creater', 'like', '%' . $param['creater'] . '%']; if ($param['zxNo'] != '') $where[] = ['cb.infoNo', 'like', '%' . $param['zxNo'] . '%']; if ($param['good_name'] != '') $where[] = ['cb.good_name', 'like', '%' . $param['good_name'] . '%']; if ($param['apply_name'] != '') $where[] = ['co.salesman', 'like', '%' . $param['apply_name'] . '%']; $count = Db::name('consult_bids') ->alias('cb') ->leftJoin('consult_info ci', 'ci.infoNo=cb.infoNo') ->leftJoin('consult_order co', 'co.zxNo=cb.zxNo') // ->leftJoin('supplier s', 's.code=cb.supplierNo') // ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo') ->where($where) ->count('cb.id'); $data = Db::name('consult_bids') ->alias('cb') ->field('cb.id,ci.addtime,cb.bidNo,cb.infoNo zxNo,cb.addtime cbaddtime,cb.good_name, cb.supplierName supplier,cb.total_fee,cb.delivery_day,cb.work_day,cb.expire_day,cb.creater, cb.createrid,"" name,ci.num,ci.arrival_time,co.saleid,co.salesman,"" salesman_name,co.khNo') ->leftJoin('consult_info ci', 'ci.infoNo=cb.infoNo') ->leftJoin('consult_order co', 'co.zxNo=cb.zxNo') ->where($where) ->page($param['page'], $param['size']) ->order('ci.addtime', 'desc') ->select() ->toArray(); $ComArr =array_unique(array_column($data , "khNo")) ; $userCommon = \app\admin\common\User::getIns(); $supplier_temp = $userCommon->handle('getCodeAndName', ['code' => $ComArr]); $supplier = $supplier_temp['data'] ?? []; //获取所有创建人的部门 $item_name = get_company_name_by_uid(array_unique(array_merge(array_column($data, 'createrid'), array_column($data, 'saleid')))); foreach ($data as &$value) { $value['name'] = $item_name[$value['createrid']] ?? ''; $value['salesman_name'] = $item_name[$value['saleid']] ?? ''; $value['companyName'] = $supplier[$value['khNo']] ?? ''; } //汇总 $data[] = [ 'id' => 0, 'addtime' => '汇总', 'bidNo' => '', 'zxNo' => '', 'cbaddtime' => '', 'good_name' => '', 'supplier' => '', 'total_fee' => array_sum(array_column($data, 'total_fee')), 'delivery_day' => '', 'work_day' => '', 'expire_day' => '', 'creater' => '', 'num' => array_sum(array_column($data, 'num')), 'arrival_time' => '', 'salesman' => '', 'companyName' => '', ]; return json_show(0, '请求成功', ['count' => $count, 'list' => $data]); } //【二、咨询单报表】1.已采反报价信息_导出 public function consultInfoBidsSumExport() { $param = $this->request->only([ 'token', 'zxNo' => [], 'start_date' => '', 'end_date' => '', 'cbaddtime_start_date' => '', 'cbaddtime_end_date' => '', 'supplier' => '', 'creater' => '', 'good_name' => '', 'apply_name' => '', 'page' => 1, 'size' => 15, ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date|竞价开始时间' => 'date|elt:end_date', 'end_date|竞价开始时间' => 'date|egt:start_date', 'cbaddtime_start_date|采购回复开始时间' => 'date|elt:cbaddtime_end_date', 'cbaddtime_end_date|采购回复开始时间' => 'date|egt:cbaddtime_start_date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $rs = Db::name('consult_bids') ->alias('cb') ->where('cb.is_del', 0); if ($param['start_date'] != '' && $param['end_date'] != '') $rs->whereBetween('ci.addtime', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']); if ($param['zxNo'] != '') $rs->whereIn('cb.infoNo', $param['zxNo']); if ($param['cbaddtime_start_date'] != '' && $param['cbaddtime_end_date'] != '') $rs->whereBetween('cb.addtime', [$param['cbaddtime_start_date'] . ' 00:00:00', $param['cbaddtime_end_date'] . ' 23:59:59']); if ($param['supplier'] != '') $rs->whereLike('cb.supplierNo|s.name', '%' . $param['supplier'] . '%'); if ($param['creater'] != '') $rs->whereLike('cb.creater', '%' . $param['creater'] . '%'); if ($param['good_name'] != '') $where[] = ['cb.good_name', 'like', '%' . $param['good_name'] . '%']; if ($param['apply_name'] != '') $where[] = ['co.salesman', 'like', '%' . $param['apply_name'] . '%']; $data = $rs ->field('ci.addtime as 咨询时间,cb.bidNo as 采购单反馈单号,cb.infoNo as 咨询订单号,cb.addtime as 回复时间,cb.good_name as 产品名称,cb.supplierName as 供应商名称,cb.total_fee 成本合计,cb.delivery_day 物流时间,cb.work_day 产品工期,cb.expire_day 信息有效期,cb.creater 采购员,"" 采购员所属部门,ci.num 需求数量,ci.arrival_time 要求到货日期,co.salesman 业务人员,"" 业务人员所属部门,"" 客户名称,co.khNo,cb.createrid,co.saleid') ->leftJoin('consult_info ci', 'ci.infoNo=cb.infoNo') ->leftJoin('consult_order co', 'co.zxNo=cb.zxNo') ->where($where) ->cursor(); $list = []; $supplier=[]; $depart=[]; foreach ($data as $value) { if(!isset($depart[$value['createrid']])){ $depart[$value['createrid']]=get_company_name_by_uid($value['createrid']); } if(!isset($depart[$value['saleid']])){ $depart[$value['saleid']]=get_company_name_by_uid($value['saleid']); } $value['采购员所属部门'] = $depart[$value['createrid']]; $value['业务人员所属部门'] = $depart[$value['saleid']]; if(!isset($supplier[$value['khNo']])){ $userCommon = \app\admin\common\User::getIns(); $supplier_temp = $userCommon->handle('getCodeAndName', ['code' => $value['khNo']]); $supplier[$value['khNo']] = isset($supplier_temp['data']) ? $supplier_temp['data'][$value['khNo']]:''; } $value['客户名称'] = $supplier[$value['khNo']]; unset($value['createrid']); unset($value['khNo']); unset($value['saleid']); $list[] = $value; } if (empty($list)) $list[] = ['没有可供导出的数据']; $headerArr = array_keys($list[0]); excelSave('咨询单报表-已采反报价信息' . date('YmdHis'), $headerArr, $list); } //【二、咨询单报表】2.未采反信息_列表 public function consultInfoBidsSumNot() { $param = $this->request->only([ 'token', 'companyName' => '', 'start_date' => '', 'end_date' => '', 'start_updatetime' => '', 'end_updatetime' => '', "apply_name"=>"", "status"=>"", "departid"=>"", 'page' => 1, 'size' => 15, ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date', 'start_updatetime' => 'date|elt:end_updatetime', 'end_updatetime' => 'date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['ci.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['ci.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['companyName'] != '') $where[] = ['csi.companyName', 'like', '%' . $param['companyName'] . '%']; if ($param['apply_name'] != '') $where[] = ['co.salesman', 'like', '%' . $param['apply_name'] . '%']; if ($param['status'] != '') $where[] = ['ci.status', '=', $param['status']]; if ($param['departid'] != ''){ // $uarr =get_company_item_user_by_name($param['dapart']); $where[] = ['co.depart', '=', $param['departid']]; } if ($param['start_updatetime'] != '' && $param['end_updatetime'] != '') $where[] = ['ci.updatetime', 'between', [$param['start_updatetime'] . ' 00:00:00', $param['end_updatetime'] . ' 23:59:59']]; $status = [1 => '招标进行中', 2 => '招标已结束', 3 => '等待议价结果', 4 => '确认商品', 5 => '成功转单', 6 => '超时已关闭', 7 => '招标已暂停']; $count = Db::name('consult_info') ->alias('ci') ->leftJoin('consult_bids cb', 'cb.infoNo=ci.infoNo') ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo') ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo') ->where($where) ->whereNull('cb.id') ->order('ci.arrival_time', 'desc') ->count('ci.id'); $data = Db::name('consult_info') ->alias('ci') ->field('ci.infoNo zxNo,ci.good_name,ci.num,csi.companyName,ci.addtime,co.endtime,ci.updatetime,ci.status,co.salesman,co.saleid') ->leftJoin('consult_bids cb', 'cb.infoNo=ci.infoNo') ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo') ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo') ->where($where) ->whereNull('cb.id')//未采反,即咨询单没有对应的反馈单,所以反馈单id应该是null ->order('ci.arrival_time', 'desc') ->page($param['page'], $param['size']) ->withAttr('status', function ($val) use ($status) { return isset($status[$val]) ? $status[$val] : ''; }) ->select() ->toArray(); $deparuid =get_company_name_by_uid(array_unique(array_column($data,"saleid"))); foreach ($data as &$v) { $v['depart']=$deparuid[$v['saleid']]??""; } return json_show(0, '请求成功', ['list' => $data, 'count' => $count]); } //【二、咨询单报表】2.未采反信息_导出 public function consultInfoBidsSumNotExport() { $param = $this->request->only([ 'token', 'companyName' => '', 'start_date' => '', 'end_date' => '', 'start_updatetime' => '', 'end_updatetime' => '', "apply_name"=>"", "status"=>"", "departid"=>"", ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date', 'start_updatetime' => 'date|elt:end_updatetime', 'end_updatetime' => 'date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['ci.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['ci.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['companyName'] != '') $where[] = ['csi.companyName', 'like', '%' . $param['companyName'] . '%']; if ($param['start_updatetime'] != '' && $param['end_updatetime'] != '') $where[] = ['ci.updatetime', 'between', [$param['start_updatetime'] . ' 00:00:00', $param['end_updatetime'] . ' 23:59:59']]; if ($param['apply_name'] != '') $where[] = ['co.salesman', 'like', '%' . $param['apply_name'] . '%']; if ($param['status'] != '') $where[] = ['ci.status', '=', $param['status']]; if ($param['departid'] != ''){ // $uarr =get_company_item_user_by_name($param['dapart']); $where[] = ['co.createrid', '=', $param['departid']]; } $status = [1 => '招标进行中', 2 => '招标已结束', 3 => '等待议价结果', 4 => '确认商品', 5 => '成功转单', 6 => '超时已关闭', 7 => '招标已暂停']; $data = Db::name('consult_info') ->alias('ci') ->field('ci.infoNo 竞价订单号,ci.good_name 商品名称, ci.num 需求数量,csi.companyName 客户名称,ci.addtime 创建时间,co.endtime 截止时间,ci.updatetime 结束时间, ci.status 状态,co.salesman 业务人员,co.saleid 部门') ->leftJoin('consult_bids cb', 'cb.infoNo=ci.infoNo') ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo') ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo') ->where($where) ->whereNull('cb.id') ->order('ci.arrival_time', 'desc') ->withAttr('状态', function ($val) use ($status) { return isset($status[$val]) ? $status[$val] : ''; }) ->select() ->toArray(); // echo Db::name('consult_info')->getLastSql(); if (empty($data)) $list[] = ['没有可供导出的数据']; else{ $deparuid =get_company_name_by_uid(array_unique(array_column($data,"部门"))); $list=[]; foreach ($data as &$v) { $v['部门']=$deparuid[$v['部门']]??""; $list[]=$v; } } $headerArr = array_keys($list[0]); excelSave('咨询单报表-未采反信息' . date('YmdHis'), $headerArr, $list); } //【三、订单明细报表】列表 public function orderListDetailed() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', 'status' => '', 'page' => 1, 'size' => 15, ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['po.is_del', '=', 0], ["po.order_type", "<>", 1]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['po.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['status'] != '') $where[] = ['po.status', '=', $param['status']]; $all_status = ['待与供应商确认', '待入库', '部分入库', '入库完成', '已取消订单']; $all_send_status = [1 => '未发货', 2 => '部分发货', 3 => '已发货']; $all_is_stock = [0 => '非库存品', 1 => '库存品']; $count = Db::name('purchease_order') ->alias('po') // ->leftJoin('business b', 'b.companyNo=po.companyNo') ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo') ->leftJoin('good_basic gb', 'gb.spuCode=po.spuCode AND gb.is_del=0') ->where($where) ->count('po.id'); $data = Db::name('purchease_order') ->alias('po') ->field('po.cgdNo,po.addtime,po.supplierNo,po.supplier_name,po.good_name,gb.is_stock,po.good_num,po.nake_fee,po.total_fee,po.status,po.send_status,po.wsend_num,"" creater,"" creater_name,"" company,po.cgder_id,po.cgder,"" name,"" send_time,on.orderCode,po.order_type,po.bkcode,po.spuCode,po.companyNo') // ->leftJoin('business b', 'b.companyNo=po.companyNo') ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo') ->leftJoin('good_basic gb', 'gb.spuCode=po.spuCode AND gb.is_del=0') ->where($where) ->page($param['page'], $param['size']) ->order('po.addtime', 'desc') ->select() ->toArray(); $names = get_headquarters_code_and_name(array_unique(array_column($data, 'companyNo'))); $list = []; foreach ($data as $v) { //单据状态 $v['status'] = isset($all_status[$v['status']]) ? $all_status[$v['status']] : ''; //发货状态 $v['send_status'] = isset($all_send_status[$v['send_status']]) ? $all_send_status[$v['send_status']] : ''; //商品库存性质 $v['is_stock'] = isset($all_is_stock[$v['is_stock']]) ? $all_is_stock[$v['is_stock']] : ''; //创建人//order_type==1备库单 if ($v['order_type'] == 1) $temp = Db::name('purchease')->where(['bk_code' => $v['bkcode'], 'spuCode' => $v['spuCode'], 'is_del' => 0])->field('id,apply_name,apply_id')->findOrEmpty(); else $temp = Db::name('sale')->where(['orderCode' => $v['orderCode'], 'is_del' => 0])->field('id,apply_id,apply_name')->findOrEmpty(); $v['creater'] = isset($temp['apply_name']) ? $temp['apply_name'] : ''; $v['apply_id'] = $temp['apply_id']; // $v['creater_name'] = $tmp_names[$temp['apply_id']]; //创建时间 $v['send_time'] = Db::name('order_out') ->where(['orderCode' => $v['orderCode']]) ->order('addtime', 'desc') ->value('addtime'); // $v['name'] = $company_names[$v['cgder_id']] ?? ''; $v['company'] = $names[$v['companyNo']] ?? ''; $list[] = $v; } $company_names = get_company_name_by_uid(array_unique(array_merge(array_column($data, 'cgder_id'), array_column($data, 'apply_id')))); foreach ($list as &$value) { $value['name'] = $company_names[$value['cgder_id']] ?? ''; $value['creater_name'] = $company_names[$value['apply_id']] ?? ''; } return json_show(0, '请求成功', ['list' => $list, 'count' => $count]); } //【三、订单明细报表】导出 public function orderListDetailedExport() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', 'status' => '', ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['po.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['po.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['status'] != '') $where[] = ['po.status', '=', $param['status']]; $all_status = ['待与供应商确认', '待入库', '部分入库', '入库完成', '已取消订单']; $all_send_status = [1 => '未发货', 2 => '部分发货', 3 => '已发货']; $all_is_stock = [0 => '非库存品', 1 => '库存品']; $data = Db::name('purchease_order') ->alias('po') ->field('po.cgdNo 采购单编号,po.addtime 创建时间,po.supplierNo 供应商编号,po.supplier_name 供应商名称,po.good_name 商品名称,gb.is_stock 商品库存性质,po.good_num 购买数量,po.nake_fee 裸价,po.total_fee 成本合计,po.status 单据状态,po.send_status 发货状态,po.wsend_num 未发货数量,"" 创建人,"" 创建人所属部门,"" 客户名称,po.cgder 采购员,"" 采购员所属部门,"" 发货时间,on.orderCode,po.order_type,po.bkcode,po.spuCode,po.cgder_id,po.companyNo') // ->leftJoin('business b', 'b.companyNo=po.companyNo') ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo') ->leftJoin('good_basic gb', 'gb.spuCode=po.spuCode AND gb.is_del=0') ->where($where) ->order('po.addtime', 'desc') ->select() ->toArray(); $list = []; $names = get_headquarters_code_and_name(array_unique(array_column($data, 'companyNo'))); foreach ($data as $v) { //单据状态 $v['单据状态'] = isset($all_status[$v['单据状态']]) ? $all_status[$v['单据状态']] : ''; //发货状态 $v['发货状态'] = isset($all_send_status[$v['发货状态']]) ? $all_send_status[$v['发货状态']] : ''; //商品库存性质 $v['商品库存性质'] = isset($all_is_stock[$v['商品库存性质']]) ? $all_is_stock[$v['商品库存性质']] : ''; //创建人//order_type==1备库单 if ($v['order_type'] == 1) $temp = Db::name('purchease')->where(['bk_code' => $v['bkcode'], 'spuCode' => $v['spuCode'], 'is_del' => 0])->field('id,apply_name,apply_id')->find(); else $temp = Db::name('sale')->where(['orderCode' => $v['orderCode'], 'is_del' => 0])->field('id,apply_id,apply_name')->find(); $v['创建人'] = isset($temp['apply_name']) ? $temp['apply_name'] : ''; $v['apply_id'] = $temp['apply_id']; // $v['创建人所属部门'] = get_company_name_by_uid($temp['apply_id'] ?? 0); //创建时间 $v['发货时间'] = Db::name('order_out') ->where(['orderCode' => $v['orderCode']]) ->order('addtime', 'desc') ->value('addtime'); // $v['采购员所属部门'] = $company_names[$v['cgder_id']] ?? ''; $v['客户名称'] = $names[$v['companyNo']] ?? ''; unset($v['orderCode']); unset($v['order_type']); unset($v['bkcode']); unset($v['spuCode']); unset($v['companyNo']); // unset($v['cgder_id']); $list[] = $v; } $company_names = get_company_name_by_uid(array_unique(array_merge(array_column($data, 'cgder_id'), array_column($data, 'apply_id')))); foreach ($list as &$value) { $value['创建人所属部门'] = $company_names[$value['apply_id']] ?? ''; $value['采购员所属部门'] = $company_names[$value['cgder_id']] ?? ''; unset($value['apply_id']); unset($value['cgder_id']); } if (empty($list)) $list[] = ['没有可供导出的数据']; $headerArr = array_keys($list[0]); excelSave('订单明细报表' . date('YmdHis'), $headerArr, $list); } //【四、售后明细报表】列表 public function orderReturnList() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', 'page' => 1, 'size' => 15, ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['or.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['or.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; $all_status = [1 => '待业务审核', 2 => '待采购审核', 3 => '待设置仓库', 4 => '待客户退货', 5 => '售后已完成', 6 => '业务已驳回', 7 => '采购已驳回', 8 => '申请已取消']; //总数 $count = Db::name('order_return') ->alias('or') ->leftJoin('order_num on', 'on.orderCode=or.orderCode') ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo') ->leftJoin('order_out oo', 'oo.outCode=or.outCode AND oo.status=3 AND oo.is_del=0') ->leftJoin('result_info ri', 'ri.result_code=or.error_code') ->where($where) ->count('or.id'); $list = Db::name('order_return') ->alias('or') ->field('or.id,or.returnCode,or.addtime,on.cgdNo,po.supplierNo,po.supplier_name,or.good_name,or.total_num, oo.updatetime receipttime ,or.error_num,or.error_remark,ri.result error_reason,or.status,po.cgder,"" name,po.cgder_id') ->leftJoin('order_num on', 'on.orderCode=or.orderCode') ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo') ->leftJoin('order_out oo', 'oo.outCode=or.outCode AND oo.status=3 AND oo.is_del=0') ->leftJoin('result_info ri', 'ri.result_code=or.error_code') // ->leftJoin('depart_user u', 'u.uid=po.cgder_id AND u.is_del=0') // ->leftJoin('company_item ci', 'ci.id=u.itemid') ->where($where) ->withAttr('status', function ($val) use ($all_status) { return isset($all_status[$val]) ? $all_status[$val] : $val; }) ->page($param['page'], $param['size']) ->order('or.addtime desc') ->select() ->toArray(); $company_names = get_company_name_by_uid(array_unique(array_column($list, 'cgder_id'))); foreach ($list as &$value) { $value['name'] = $company_names[$value['cgder_id']] ?? ''; } return json_show(0, '请求成功', ['list' => $list, 'count' => $count]); } //【四、售后明细报表】导出 public function orderReturnListExport() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['or.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['or.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; $all_status = [2 => '业务主管审核', 3 => '采购主管审核', 6 => '业务驳回', 7 => '采购驳回', 8 => '取消']; $list = Db::name('order_return') ->alias('or') ->field('or.returnCode 售后单编号,or.addtime 创建时间,on.cgdNo 采购单编号,po.supplier_name 供应商名称,or.good_name 产品名称,or.total_num 购买数量, oo.updatetime 签收日期,or.error_num 售后数量,or.error_remark 问题描述,ri.result 异常原因,or.status 售后状态,po.cgder 采购员,"" 采购员所属部门,po.cgder_id') ->leftJoin('order_num on', 'on.orderCode=or.orderCode') ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo') ->leftJoin('order_out oo', 'oo.outCode=or.outCode AND oo.status=3 AND oo.is_del=0') ->leftJoin('result_info ri', 'ri.result_code=or.error_code') // ->leftJoin('depart_user u', 'u.uid=po.cgder_id AND u.is_del=0') // ->leftJoin('company_item ci', 'ci.id=u.itemid') ->where($where) ->withAttr('售后状态', function ($val) use ($all_status) { return isset($all_status[$val]) ? $all_status[$val] : $val; }) ->order('or.addtime desc') ->select() ->toArray(); $company_names = get_company_name_by_uid(array_unique(array_column($list, 'cgder_id'))); foreach ($list as &$value) { $value['采购员所属部门'] = $company_names[$value['cgder_id']] ?? ''; unset($value['cgder_id']); } if (empty($list)) $list[] = ['没有可供导出的数据']; $headerArr = array_keys($list[0]); excelSave('售后明细报表' . date('YmdHis'), $headerArr, $list); } //【五、供应商报表】列表 public function supplierList() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', 'update_start_date' => '', 'update_end_date' => '', 'page' => 1, 'size' => 15, ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date', 'update_start_date' => 'date|elt:update_end_date', 'update_end_date' => 'date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = []; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['s.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['update_start_date'] != '' && $param['update_end_date'] != '') $where[] = ['s.updatetime', 'between', [$param['update_start_date'] . ' 00:00:00', $param['update_end_date'] . ' 23:59:59']]; $all_source = [0 => '客户提供', 1 => '供应商', 2 => '公司开发']; $all_pay_type = [0 => '现结', 1 => '月清', 2 => '双月清']; $all_delivery_way = [0 => '供应商发货', 1 => '公司自提']; //总数 $count = Db::name('supplier') ->alias('s') ->where($where) ->count('s.id'); $list = Db::name('supplier') ->alias('s') ->field('s.id,s.addtime,s.name,s.creater,s.createrid,"" company_name,s.nature,s.source,s.pay_type,s.delivery_way,s.updatetime') ->where($where) ->page($param['page'], $param['size']) ->withAttr('source', function ($val) use ($all_source) { return is_numeric($val) ? (isset($all_source[$val]) ? $all_source[$val] : '') : $val; }) ->withAttr('pay_type', function ($val) use ($all_pay_type) { return is_numeric($val) ? (isset($all_pay_type[$val]) ? $all_pay_type[$val] : '') : $val; }) ->withAttr('delivery_way', function ($val) use ($all_delivery_way) { return is_numeric($val) ? (isset($all_delivery_way[$val]) ? $all_delivery_way[$val] : '') : $val; }) ->withAttr('company_name', function ($val, $data) { return get_company_name_by_uid($data['createrid']); }) ->order('s.addtime desc') ->select() ->toArray(); return json_show(0, '请求成功', ['list' => $list, 'count' => $count]); } //【五、供应商报表】导出 public function supplierListExport() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', 'update_start_date' => '', 'update_end_date' => '', ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date', 'update_start_date' => 'date|elt:update_end_date', 'update_end_date' => 'date', ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = []; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['s.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['update_start_date'] != '' && $param['update_end_date'] != '') $where[] = ['s.updatetime', 'between', [$param['update_start_date'] . ' 00:00:00', $param['update_end_date'] . ' 23:59:59']]; $all_source = [0 => '客户提供', 1 => '供应商', 2 => '公司开发']; $all_pay_type = [0 => '现结', 1 => '月清', 2 => '双月清']; $all_delivery_way = [0 => '供应商发货', 1 => '公司自提']; $list = Db::name('supplier') ->alias('s') ->field('s.addtime 录入供应商时间,s.name 供应商名称,s.creater 采购维护人,"" 采购维护人所属部门,s.nature 供应商性质,s.source 供应商来源,s.pay_type 付款方式,s.delivery_way 发货方式,s.updatetime 修改供应商时间,s.createrid') ->where($where) ->order('s.addtime desc') ->cursor(); $data = []; foreach ($list as $value) { $value['供应商来源'] = is_numeric($value['供应商来源']) ? (isset($all_source[$value['供应商来源']]) ? $all_source[$value['供应商来源']] : '') : $value['供应商来源']; $value['付款方式'] = is_numeric($value['付款方式']) ? (isset($all_pay_type[$value['付款方式']]) ? $all_pay_type[$value['付款方式']] : '') : $value['付款方式']; $value['发货方式'] = is_numeric($value['发货方式']) ? (isset($all_delivery_way[$value['发货方式']]) ? $all_delivery_way[$value['发货方式']] : '') : $value['发货方式']; $value['采购维护人所属部门'] = get_company_name_by_uid($value['createrid']); unset($value['createrid']); $data[] = $value; } if (empty($data)) $data[] = ['没有可供导出的数据']; $headerArr = array_keys($data[0]); excelSave('供应商报表' . date('YmdHis'), $headerArr, $data); } //【六、退货流水报表】列表 public function SaleReturnList() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', 'page' => 1, 'size' => 15, ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['s.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['s.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; $count = Db::name('sale_return') ->alias('s') ->where($where) ->leftJoin('sale ss', 'ss.orderCode=s.orderCode AND ss.is_del=0') ->leftJoin('order_num on', 'on.orderCode=s.orderCode') ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo') ->leftJoin('good_basic gb', 'gb.spuCode=s.good_code AND gb.is_del=0') ->leftJoin('result_info ri', 'ri.result_code=s.error_code AND ri.is_del=0') // ->leftJoin('supplier sp', 'sp.code=gb.supplierNo') ->count('s.id'); $list = Db::name('sale_return') ->alias('s') ->field('s.id,s.returnCode,s.addtime,po.cgdNo,gb.supplierName supplier_name,s.good_name,gb.is_stock,ss.good_num,po.cgder_id,po.cgder,"" name,s.num,on.send_num,ri.result,s.is_th') ->where($where) ->leftJoin('sale ss', 'ss.orderCode=s.orderCode AND ss.is_del=0') ->leftJoin('order_num on', 'on.orderCode=s.orderCode') ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo') ->leftJoin('good_basic gb', 'gb.spuCode=s.good_code AND gb.is_del=0') ->leftJoin('result_info ri', 'ri.result_code=s.error_code AND ri.is_del=0') // ->leftJoin('supplier sp', 'sp.code=gb.supplierNo') ->page($param['page'], $param['size']) ->order('s.addtime desc') ->select() ->toArray(); $company_names = get_company_name_by_uid(array_unique(array_column($list, 'cgder_id'))); $data = []; foreach ($list as $value) { $value['name'] = $company_names[$value['cgder_id']] ?? ''; $data[] = $value; } return json_show(0, '请求成功', ['list' => $data, 'count' => $count]); } //【六、退货流水报表】导出 public function SaleReturnExport() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '' ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['s.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['s.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; $all_is_th = [0 => '不可以', 1 => '可以']; $all_is_stock = [0 => '非库存品', 1 => '库存品']; $list = Db::name('sale_return') ->alias('s') ->field('s.returnCode 退货单号,s.addtime 退货时间,po.cgdNo 采购单编号,po.supplier_name 供应商名称,po.good_name 产品名称,gb.is_stock 商品库存性质,po.good_num 购买数量,po.cgder 采购员,"" 采购员所属部门,s.num 退货数量,on.send_num 已发货数量,ri.result 退货原因,s.is_th 供应商是否可以退货,po.cgder_id') ->where($where) ->leftJoin('order_num on', 'on.orderCode=s.orderCode') ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo') ->leftJoin('good_basic gb', 'gb.spuCode=po.spuCode AND gb.is_del=0') ->leftJoin('result_info ri', 'ri.result_code=s.error_code AND ri.is_del=0') ->order('s.addtime desc') ->select() ->toArray(); $company_names = get_company_name_by_uid(array_unique(array_column($list, 'cgder_id'))); $data = []; foreach ($list as $value) { $value['供应商是否可以退货'] = isset($all_is_th[$value['供应商是否可以退货']]) ? $all_is_th[$value['供应商是否可以退货']] : ''; $value['商品库存性质'] = isset($all_is_stock[$value['商品库存性质']]) ? $all_is_stock[$value['商品库存性质']] : ''; $value['采购员所属部门'] = $company_names[$value['cgder_id']] ?? '';//get_company_name_by_uid($value['cgder_id'] ?? 0); unset($value['cgder_id']); $data[] = $value; } unset($list); if (empty($data)) $data[] = ['没有可供导出的数据']; $headerArr = array_keys($data[0]); excelSave('退货流水报表' . date('YmdHis'), $headerArr, $data); } //【七、商品报表】1.商品上线报表_列表 public function GoodOnlineList() { $param = $this->request->only([ 'token', 'creater' => '', 'supplier_name' => '', 'start_date' => '', 'end_date' => '', 'page' => 1, 'size' => 15, ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['gp.is_del', '=', 0], ['gp.exam_status', '=', 6]]; //exam_status==6 上线成功 if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.online_time', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];//当上面状态确定为exam_status==6时,上线时间也可以取 updatetime if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%']; // if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%']; $count = Db::name('good_platform') ->alias('gp') ->where($where) ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('brand b', 'b.id=gb.brand_id') // ->leftJoin('supplier s', 's.code=gb.supplierNo') ->count('gp.id'); $list = Db::name('good_platform') ->alias('gp') ->field('gb.createrid,gb.creater,"" company_name,gp.skuCode,gp.spuCode,gb.good_name,b.brand_name,"" good_model,gb.supplierName name,gb.tax,gb.nake_price,gp.online_time') ->where($where) ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('brand b', 'b.id=gb.brand_id') // ->leftJoin('supplier s', 's.code=gb.supplierNo') ->order('gp.updatetime desc') ->page($param['page'], $param['size']) ->select() ->toArray(); $company_names = get_company_name_by_uid(array_unique(array_column($list, 'cgder_id'))); $data = []; foreach ($list as $value) { $value['company_name'] = $company_names[$value['createrid']] ?? '';//get_company_name_by_uid($value['createrid']); $value['good_model'] = Db::name('good_spec') ->alias('gp') ->leftJoin('specs s', 's.id=gp.spec_id') ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id') ->where([ 'gp.spuCode' => $value['spuCode'], 'gp.is_del' => 0, 's.spec_name' => '型号', ]) ->value('sv.spec_value', ''); $data[] = $value; } return json_show(0, '请求成功', ['list' => $data, 'count' => $count]); } //【七、商品报表】1.商品上线报表_导出 public function GoodOnlineExport() { $param = $this->request->only([ 'token', 'creater' => '', 'supplier_name' => '', 'start_date' => '', 'end_date' => '' ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['gp.is_del', '=', 0], ['gp.exam_status', '=', 6]]; //exam_status==6 上线成功 if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.online_time', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%']; // if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%']; $list = Db::name('good_platform') ->alias('gp') ->field('gb.creater 采购维护人,"" 采购维护人所属部门,gp.skuCode 商品上线编号,gp.spuCode 商品成本编号,gb.good_name 商品名称,b.brand_name 品牌名称,"" 商品型号,gb.supplierName 供应商名称,gb.tax 税点,gb.nake_price 成本价合计,gp.online_time 上线时间,gb.createrid') ->where($where) ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('brand b', 'b.id=gb.brand_id') // ->leftJoin('supplier s', 's.code=gb.supplierNo') ->order('gp.updatetime desc') ->cursor(); $data = []; foreach ($list as $value) { $value['采购维护人所属部门'] = get_company_name_by_uid($value['createrid']);; $value['商品型号'] = Db::name('good_spec') ->alias('gp') ->field('') ->leftJoin('specs s', 's.id=gp.spec_id') ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id') ->where([ 'gp.spuCode' => $value['商品成本编号'], 'gp.is_del' => 0, 's.spec_name' => '型号', ]) ->value('sv.spec_value', ''); unset($value['createrid']); $data[] = $value; } if (empty($data)) $data[] = ['没有可供导出的数据']; $headerArr = array_keys($data[0]); excelSave('商品上线报表' . date('YmdHis'), $headerArr, $data); } //【七、商品报表】2.商品下线报表_列表 public function GoodOfflineList() { $param = $this->request->only([ 'token', 'creater' => '', 'supplier_name' => '', 'start_date' => '', 'end_date' => '', 'page' => 1, 'size' => 15, ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['gp.is_del', '=', 0], ['gp.exam_status', '=', 8]]; //exam_status==8 下线成功 if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.updatetime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%']; if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%']; $count = Db::name('good_platform') ->alias('gp') ->where($where) ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') // ->leftJoin('supplier s', 's.code=gb.supplierNo') ->count('gp.id'); $list = Db::name('good_platform') ->alias('gp') ->field('gp.updatetime,gb.createrid,gb.creater,"" company_name,gb.creater,gp.skuCode,gp.spuCode,gb.good_name,gb.supplierName name') ->where($where) ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') // ->leftJoin('supplier s', 's.code=gb.supplierNo') // ->withAttr('company_name', function ($val, $data) { // return get_company_name_by_uid($data['createrid']); // }) ->page($param['page'], $param['size']) ->select() ->toArray(); $company_names = get_company_name_by_uid(array_unique(array_column($list, 'createrid'))); foreach ($list as &$value) { $value['company_name'] = $company_names[$value['createrid']] ?? ''; } return json_show(0, '请求成功', ['list' => $list, 'count' => $count]); } //【七、商品报表】2.商品下线报表_导出 public function GoodOfflineExport() { $param = $this->request->only([ 'token', 'creater' => '', 'supplier_name' => '', 'start_date' => '', 'end_date' => '' ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['gp.is_del', '=', 0], ['gp.exam_status', '=', 8]]; //exam_status==8 下线成功 if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.updatetime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%']; // if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%']; $list = Db::name('good_platform') ->alias('gp') ->field('gp.updatetime 商品下线时间,gb.creater 采购维护人,"" 采购维护人所属部门,gp.skuCode 商品上线编号,gp.spuCode 商品成本编号,gb.good_name 商品名称,gb.supplierName 供应商名称,gb.createrid') ->where($where) ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') // ->leftJoin('supplier s', 's.code=gb.supplierNo') ->select() ->toArray(); $company_names = get_company_name_by_uid(array_unique(array_column($list, 'createrid'))); $data = []; foreach ($list as $value) { $value['采购维护人所属部门'] = $company_names[$value['createrid']] ?? ''; unset($value['createrid']); $data[] = $value; } if (empty($data)) $data[] = ['没有可供导出的数据']; $headerArr = array_keys($data[0]); excelSave('商品下线报表' . date('YmdHis'), $headerArr, $data); } //【七、商品报表】3.商品修改报表_列表 public function ChangeLogList() { $param = $this->request->only([ 'token', 'creater' => '', 'supplier_name' => '', 'start_date' => '', 'end_date' => '', 'page' => 1, 'size' => 15, ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['cl.type', '=', 3]]; //type==3 商品成本变化记录 if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['cl.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%']; if ($param['supplier_name'] != '') $where[] = ['gb.supplierName', 'like', '%' . $param['supplier_name'] . '%']; $count = Db::name('change_log') ->alias('cl') ->leftJoin('good_basic gb', 'gb.spuCode=cl.code AND gb.is_del=0') ->where($where) ->count('cl.id'); $data = Db::name('change_log') ->alias('cl') ->field('cl.addtime,gb.createrid,gb.creater,"" company_name,cl.code,gb.good_name,gb.supplierName name,cl.before_info,cl.after_info') ->leftJoin('good_basic gb', 'gb.spuCode=cl.code AND gb.is_del=0') ->where($where) ->order('cl.addtime', 'desc') ->page($param['page'], $param['size']) ->select() ->toArray(); $company_names = get_company_name_by_uid(array_unique(array_column($data, 'createrid'))); $list = []; foreach ($data as $value) { $before_info = json_decode($value['before_info'], true); $after_info = json_decode($value['after_info'], true); if (isset($after_info['field_change'])) unset($after_info['field_change']); $value['before_info'] = []; foreach ($after_info as $kk => $vv) { //特殊字段处理 switch ($kk) { //品牌 case 'brand_id': $all_brand = Db::name('brand') ->whereIn('id', [$before_info[$kk], $vv]) ->where('is_del', 0) ->column('brand_name', 'id'); $value['before_info'][$kk] = isset($all_brand[$before_info[$kk]]) ? $all_brand[$before_info[$kk]] : ''; $after_info[$kk] = isset($all_brand[$vv]) ? $all_brand[$vv] : ''; break; //分类 case 'cat_id': $value['before_info'][$kk] = implode('/', array_column(made($before_info[$kk]), 'name')); $after_info[$kk] = implode('/', array_column(made($vv), 'name')); break; //发货地 case 'delivery_place': $delivery_place = explode(',', $before_info[$kk]); $value['before_info'][$kk] = empty($delivery_place) ? $before_info[$kk] : GetAddr(json_encode(['provice_code' => $delivery_place[0] ?? '', 'city_code' => $delivery_place[1] ?? '', 'area_code' => $delivery_place[2] ?? ''])); $delivery_place_2 = explode(',', $vv); $after_info[$kk] = empty($delivery_place_2) ? $vv : GetAddr(json_encode(['provice_code' => $delivery_place_2[0] ?? '', 'city_code' => $delivery_place_2[1] ?? '', 'area_code' => $delivery_place_2[2] ?? ''])); break; //产地 case 'origin_place': $origin_place = explode(',', $before_info[$kk]); $value['before_info'][$kk] = empty($origin_place) ? $before_info[$kk] : GetAddr(json_encode(['provice_code' => $origin_place[0] ?? '', 'city_code' => $origin_place[1] ?? '', 'area_code' => $origin_place[2] ?? ''])); $origin_place_2 = explode(',', $vv); $after_info[$kk] = empty($vv) ? $vv : GetAddr(json_encode(['provice_code' => $origin_place_2[0] ?? '', 'city_code' => $origin_place_2[1] ?? '', 'area_code' => $origin_place_2[2] ?? ''])); break; //商品单位 case 'good_unit': $all_unit = Db::name('unit') ->whereIn('id', [$before_info[$kk], $vv]) ->where(['is_del' => 0]) ->column('unit', 'id'); $value['before_info'][$kk] = isset($all_unit[$before_info[$kk]]) ? $all_unit[$before_info[$kk]] : ''; $after_info[$kk] = isset($all_unit[$vv]) ? $all_unit[$vv] : ''; break; //业务企业,供应商 case 'companyNo': case 'supplierNo': // $all_supplier = Db::name('supplier') // ->whereIn('code', [$before_info[$kk], $vv]) // ->where(['is_del' => 0]) // ->column('name', 'code'); $all_names = get_headquarters_code_and_name([$before_info[$kk], $vv]); $value['before_info'][$kk] = isset($all_names[$before_info[$kk]]) ? $all_names[$before_info[$kk]] : ''; $after_info[$kk] = isset($all_names[$vv]) ? $all_names[$vv] : ''; break; //供货区域 case 'supply_area': if ($before_info[$kk] == 1) $value['before_info'][$kk] = '全国'; elseif ($before_info[$kk] == 2) $value['before_info'][$kk] = '全国除偏远'; else $value['before_info'][$kk] = ''; if ($vv == 1) $after_info[$kk] = '全国'; elseif ($vv == 2) $after_info[$kk] = '全国除偏远'; else $after_info[$kk] = ''; break; //贵金属种类 case 'noble_metal': if ($before_info[$kk] == 1) $value['before_info'][$kk] = '18K'; elseif ($before_info[$kk] == 2) $value['before_info'][$kk] = '24K'; elseif ($before_info[$kk] == 3) $value['before_info'][$kk] = '白银'; else $value['before_info'][$kk] = ''; if ($vv == 1) $after_info[$kk] = '18K'; elseif ($vv == 2) $after_info[$kk] = '24K'; elseif ($vv == 3) $after_info[$kk] = '白银'; else $after_info[$kk] = ''; break; //专属类型 case 'is_exclusive': $value['before_info'][$kk] = implode('/', array_column(mai($before_info[$kk]), 'rname')); $after_info[$kk] = implode('/', array_column(mai($vv), 'rname')); break; default: $value['before_info'][$kk] = $before_info[$kk]; break; } } $value['after_info'] = $after_info; $value['company_name'] = $company_names[$value['createrid']] ?? ''; $list[] = $value; } return json_show(0, '请求成功', ['list' => $list, 'count' => $count]); } //【七、商品报表】3.商品修改报表_导出 public function ChangeLogExport() { $param = $this->request->only([ 'token', 'creater' => '', 'supplier_name' => '', 'start_date' => '', 'end_date' => '' ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['cl.type', '=', 3]]; //type==3 商品成本变化记录 if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['cl.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%']; if ($param['supplier_name'] != '') $where[] = ['gb.supplierName', 'like', '%' . $param['supplier_name'] . '%']; $data = Db::name('change_log') ->alias('cl') ->field('cl.addtime 商品操作时间,gb.creater 采购维护人,"" 采购维护人所在部门,cl.code 商品成本编号,gb.good_name 商品名称,gb.supplierName 供应商名称,cl.before_info 修改前的内容,cl.after_info 修改后的内容,gb.createrid') ->leftJoin('good_basic gb', 'gb.spuCode=cl.code AND gb.is_del=0') // ->leftJoin('supplier s', 's.code=gb.supplierNo') ->where($where) ->select() ->toArray(); $company_names = get_company_name_by_uid(array_unique(array_column($data, 'createrid'))); $list = []; foreach ($data as $value) { $before_info = json_decode($value['修改前的内容'], true); $after_info = json_decode($value['修改后的内容'], true); if (isset($after_info['field_change'])) { $field_change = json_decode($after_info['field_change'], true); $before_new = $after_new = []; foreach ($field_change as $v) { //特殊字段处理 switch ($v) { //品牌 case 'brand_id': $all_brand = Db::name('brand') ->whereIn('id', [$before_info[$v] ?? 0, $after_info[$v] ?? 0]) ->where('is_del', 0) ->column('brand_name', 'id'); if (isset($before_info[$v])) $before_info[$v] = isset($all_brand[$before_info[$v]]) ? $all_brand[$before_info[$v]] : ''; if (isset($after_info[$v])) $after_info[$v] = isset($all_brand[$after_info[$v]]) ? $all_brand[$after_info[$v]] : ''; break; //分类 case 'cat_id': if (isset($before_info[$v])) $before_info[$v] = implode('/', array_column(made($before_info[$v]), 'name')); if (isset($after_info[$v])) $after_info[$v] = implode('/', array_column(made($after_info[$v]), 'name')); break; //发货地 case 'delivery_place': $delivery_place = explode(',', $before_info[$v]); $before_info[$v] = empty($delivery_place) ? $before_info[$v] : GetAddr(json_encode(['provice_code' => $delivery_place[0] ?? '', 'city_code' => $delivery_place[1] ?? '', 'area_code' => $delivery_place[2] ?? ''])); $delivery_place_2 = explode(',', $after_info[$v]); $after_info[$v] = empty($delivery_place_2) ? $after_info[$v] : GetAddr(json_encode(['provice_code' => $delivery_place_2[0] ?? '', 'city_code' => $delivery_place_2[1] ?? '', 'area_code' => $delivery_place_2[2] ?? ''])); break; //产地 case 'origin_place': $origin_place = explode(',', $before_info[$v]); $before_info[$v] = empty($origin_place) ? $before_info[$v] : GetAddr(json_encode(['provice_code' => $origin_place[0] ?? '', 'city_code' => $origin_place[1] ?? '', 'area_code' => $origin_place[2] ?? ''])); $origin_place_2 = explode(',', $after_info[$v]); $after_info[$v] = empty($origin_place_2) ? $after_info[$v] : GetAddr(json_encode(['provice_code' => $origin_place_2[0] ?? '', 'city_code' => $origin_place_2[1] ?? '', 'area_code' => $origin_place_2[2] ?? ''])); break; //商品单位 case 'good_unit': $all_unit = Db::name('unit') ->whereIn('id', [$before_info[$v] ?? 0, $after_info[$v] ?? 0]) ->where(['is_del' => 0]) ->column('unit', 'id'); if (isset($before_info[$v])) $before_info[$v] = isset($all_unit[$before_info[$v]]) ? $all_unit[$before_info[$v]] : ''; if (isset($after_info[$v])) $after_info[$v] = isset($all_unit[$after_info[$v]]) ? $all_unit[$after_info[$v]] : ''; break; //业务企业,供应商 case 'companyNo': case 'supplierNo': // $all_supplier = Db::name('supplier') // ->whereIn('code', [$before_info[$v], $after_info[$v]]) // ->where(['is_del' => 0]) // ->column('name', 'code'); $all_names = get_headquarters_code_and_name([$before_info[$v], $after_info[$v]]); $before_info[$v] = $all_names[$before_info[$v]] ?? ''; $after_info[$v] = $all_names[$after_info[$v]] ?? ''; break; //供货区域 case 'supply_area': if (isset($before_info[$v])) { if ($before_info[$v] == 1) $before_info[$v] = '全国'; elseif ($before_info[$v] == 2) $before_info[$v] = '全国除偏远'; else $before_info[$v] = ''; } if (isset($after_info[$v])) { if ($after_info[$v] == 1) $after_info[$v] = '全国'; elseif ($after_info[$v] == 2) $after_info[$v] = '全国除偏远'; else $after_info[$v] = ''; } break; //贵金属种类 case 'noble_metal': if (isset($before_info[$v])) { if ($before_info[$v] == 1) $before_info[$v] = '18K'; elseif ($before_info[$v] == 2) $before_info[$v] = '24K'; elseif ($before_info[$v] == 3) $before_info[$v] = '白银'; else $before_info[$v] = ''; } if (isset($after_info[$v])) { if ($after_info[$v] == 1) $after_info[$v] = '18K'; elseif ($after_info[$v] == 2) $after_info[$v] = '24K'; elseif ($after_info[$v] == 3) $after_info[$v] = '白银'; else $after_info[$v] = ''; } break; //专属类型 case 'is_exclusive': if (isset($before_info[$v])) $before_info[$v] = implode('/', array_column(mai($before_info[$v]), 'rname')); if (isset($after_info[$v])) $after_info[$v] = implode('/', array_column(mai($after_info[$v]), 'rname')); break; //状态 case 'status': $all_status = [1 => '待完善成本', 2 => '待产品审核', 3 => '待财务定价', 4 => '待财务审核定价', 5 => '待上线', 6 => '上线成功', 7 => '审核失败', 8 => '已下线']; if (isset($before_info[$v])) $before_info[$v] = isset($all_status[$before_info[$v]]) ? $all_status[$before_info[$v]] : ''; if (isset($after_info[$v])) $after_info[$v] = isset($all_status[$after_info[$v]]) ? $all_status[$after_info[$v]] : ''; } $key = isset($this->good_field_title[$v]) ? $this->good_field_title[$v] : $v; if (isset($before_info[$v])) $before_new[$key] = $before_info[$v]; if (isset($after_info[$v])) $after_new[$key] = $after_info[$v]; } $value['修改前的内容'] = json_encode($before_new, JSON_UNESCAPED_UNICODE); $value['修改后的内容'] = json_encode($after_new, JSON_UNESCAPED_UNICODE); $value['采购维护人所在部门'] = $company_names[$value['createrid']] ?? '';//get_company_name_by_uid($value['createrid']); unset($value['createrid']); } $list[] = $value; } if (empty($list)) $list[] = ['没有可供导出的数据']; $headerArr = array_keys($list[0]); excelSave('商品修改报表' . date('YmdHis'), $headerArr, $list); } //【八、结算报表】_列表(暂不做) //【八、结算报表】_导出(暂不做) //【九、出入库明细报表】_列表 public function GoodLogList() { /** * $param = $this->request->only([ * 'token', * 'creater' => '', * 'supplier_name' => '', * 'start_date' => '', * 'end_date' => '', * 'page' => 1, * 'size' => 15 * ], 'post', 'trim'); * **/ } //【九、出入库明细报表】_导出 public function GoodLogExport() { /** * $param = $this->request->only([ * 'token', * // 'creater' => '', * // 'supplier_name' => '', * // 'start_date' => '', * // 'end_date' => '' * ], 'post', 'trim'); * * $val_params = Validate::rule([ * 'start_date' => 'date|elt:end_date', * 'end_date' => 'date' * ]); * * if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); * * // $where = [['gl.action_type', '=', 'CGD']]; * // if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.updatetime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; * // if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%']; * // if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%']; * * * $list = Db::name('good_log') * ->alias('gl') * ->field('"" 创建人,"" 创建人公司,"" 创建人部门,"" 创建时间,"" 单据状态,"" 采购单号,gl.type 出入库类型,gb.good_name 商品名称,gb.spuCode 产品编码,gl.stock 出入库数量,gl.addtime 出入库日期,"" 维护人员,"" 发起人,wi.wsm_type 库房性质,s.name 库房公司,wi.name 库房名称') * // ->where($where) * ->leftJoin('good_stock gs', 'gs.id=gl.stock_id') * ->leftJoin('good_basic gb', 'gb.spuCode=gs.spuCode AND gb.is_del=0') * ->leftJoin('warehouse_info wi', 'wi.wsm_code=gs.wsm_code') * ->leftJoin('supplier s', 's.code=wi.supplierNo') * // ->leftJoin('supplier s', 's.code=gb.supplierNo') * ->select() * ->toArray(); * halt($list); * if (empty($list)) $list[] = ['没有可供导出的数据']; * * $headerArr = array_keys($list[0]); * excelSave('出入库明细报表' . date('YmdHis'), $headerArr, $list); **/ } //【商品信息】基本信息(赵丹要的)_列表 public function goodSimpleZhao() { $param = $this->request->only([ 'token', 'creater' => '', 'supplier_name' => '', 'start_date' => '', 'end_date' => '', 'page' => 1, 'size' => 15 ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['gp.is_del', '=', 0]]; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%']; if ($param['supplier_name'] != '') $where[] = ['gb.supplierName', 'like', '%' . $param['supplier_name'] . '%']; $count = Db::name('good_platform') ->alias('gp') ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('brand b', 'b.id=gb.brand_id') ->leftJoin('unit u', 'u.id=gb.good_unit') // ->leftJoin('supplier s', 's.code=gb.supplierNo') ->leftJoin('platform p', 'p.id=gp.platform_code') ->where($where) ->count('gp.id'); $list = Db::name('good_platform') ->alias('gp') ->field('gp.skuCode,gp.spuCode,gp.plat_code,gb.good_name,b.brand_name,gb.cat_id,gb.companyName company,gb.creater,p.platform_name,gp.online_time,gp.exam_status,gb.is_stock,gb.good_type,u.unit,gb.good_remark,gb.craft_desc,gb.noble_metal,gb.cgd_gold_price,gb.demo_fee,gb.open_fee,gb.sample_fee,gb.tax,gb.supply_area,gb.supplierName name,gp.addtime') ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('brand b', 'b.id=gb.brand_id') ->leftJoin('unit u', 'u.id=gb.good_unit') // ->leftJoin('supplier s', 's.code=gb.supplierNo') ->leftJoin('platform p', 'p.id=gp.platform_code') // ->leftJoin('business bi', 'bi.companyNo=gb.companyNo') ->where($where) ->order('gp.id', 'desc') ->page($param['page'], $param['size']) ->cursor(); $exam_status = [0 => '待提交', 1 => '待完善成本', 2 => '待产品审核', 3 => '待财务定价', 4 => '待财务审核定价', 5 => '待上线', 6 => '上线成功', 7 => '审核失败', 8 => '已下线']; $is_stock = [0 => '不是', 1 => '是']; $good_type = [0 => '不是', 1 => '是']; $noble_metal = [1 => '18K', 2 => '24K', 3 => '白银']; $supply_area = [1 => '全国', 2 => '全国除偏远']; $data = []; foreach ($list as $value) { $value['catinfo'] = made($value['cat_id']); $value['exam_status'] = isset($exam_status[$value['exam_status']]) ? $exam_status[$value['exam_status']] : ''; $value['is_stock'] = isset($is_stock[$value['is_stock']]) ? $is_stock[$value['is_stock']] : ''; $value['good_type'] = isset($good_type[$value['good_type']]) ? $good_type[$value['good_type']] : ''; $value['specifications'] = Db::name('good_spec') ->alias('gp') ->leftJoin('specs s', 's.id=gp.spec_id') ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id') ->where([ 'gp.spuCode' => $value['spuCode'], 'gp.is_del' => 0, 's.spec_name' => '规格', ])->value('sv.spec_value', ''); $value['model'] = Db::name('good_spec') ->alias('gp') ->leftJoin('specs s', 's.id=gp.spec_id') ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id') ->where([ 'gp.spuCode' => $value['spuCode'], 'gp.is_del' => 0, 's.spec_name' => '型号', ])->value('sv.spec_value', ''); $value['noble_metal'] = isset($noble_metal[$value['noble_metal']]) ? $noble_metal[$value['noble_metal']] : ''; $value['supply_area'] = isset($supply_area[$value['supply_area']]) ? $supply_area[$value['supply_area']] : ''; $data[] = $value; } return json_show(0, '请求成功', ['list' => $data, 'count' => $count]); } //【商品信息】基本信息(赵丹要的)_导出 public function goodSimpleZhaoExport() { $param = $this->request->only([ 'token', 'creater' => '', 'supplier_name' => '', 'start_date' => '', 'end_date' => '' ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = [['gp.is_del', '=', 0]]; //exam_status==6 上线成功 if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%']; if ($param['supplier_name'] != '') $where[] = ['gb.supplierName', 'like', '%' . $param['supplier_name'] . '%']; $list = Db::name('good_platform') ->alias('gp') ->field('gp.skuCode as 商品上线编号,gp.spuCode as 商品成本编号,gp.plat_code as 平台商品编码,gb.good_name as 商品名称,b.brand_name as 品牌名称,gb.cat_id as 分类,gb.companyName as 业务企业名称,gb.creater as 采购员,p.platform_name as 上线平台,gp.online_time as 上线完成时间,gp.exam_status as 上下线状态,gb.is_stock as 是否库存品,gb.good_type as 是否定制,"" as 规格,"" as 型号,u.unit as 单位,gb.good_remark as 商品备注,gb.craft_desc as 工艺说明,gb.noble_metal as 贵金属信息,gb.cgd_gold_price as 供应商采购金价,gb.demo_fee as 打样费,gb.open_fee as 开模费,gb.sample_fee as 调样费,gb.tax as 税点,gb.supply_area as 供货区域,gb.supplierName as 供应商名称,gp.addtime 申请上线时间') ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('brand b', 'b.id=gb.brand_id') ->leftJoin('unit u', 'u.id=gb.good_unit') // ->leftJoin('supplier s', 's.code=gb.supplierNo') ->leftJoin('platform p', 'p.id=gp.platform_code') // ->leftJoin('business bi', 'bi.companyNo=gb.companyNo') ->where($where) ->order('gp.id', 'desc') ->cursor(); $exam_status = [0 => '待提交', 1 => '待完善成本', 2 => '待产品审核', 3 => '待财务定价', 4 => '待财务审核定价', 5 => '待上线', 6 => '上线成功', 7 => '审核失败', 8 => '已下线']; $is_stock = [0 => '不是', 1 => '是']; $good_type = [0 => '不是', 1 => '是']; $noble_metal = [1 => '18K', 2 => '24K', 3 => '白银']; $supply_area = [1 => '全国', 2 => '全国除偏远']; $data = []; foreach ($list as $value) { $value['分类'] = implode('/', array_column(made($value['分类']), 'name')); $value['上下线状态'] = isset($exam_status[$value['上下线状态']]) ? $exam_status[$value['上下线状态']] : ''; $value['是否库存品'] = isset($is_stock[$value['是否库存品']]) ? $is_stock[$value['是否库存品']] : ''; $value['是否定制'] = isset($good_type[$value['是否定制']]) ? $good_type[$value['是否定制']] : ''; $value['规格'] = Db::name('good_spec') ->alias('gp') ->leftJoin('specs s', 's.id=gp.spec_id') ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id') ->where([ 'gp.spuCode' => $value['商品成本编号'], 'gp.is_del' => 0, 's.spec_name' => '规格', ])->value('sv.spec_value', ''); $value['型号'] = Db::name('good_spec') ->alias('gp') ->leftJoin('specs s', 's.id=gp.spec_id') ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id') ->where([ 'gp.spuCode' => $value['商品成本编号'], 'gp.is_del' => 0, 's.spec_name' => '型号', ])->value('sv.spec_value', ''); $value['贵金属信息'] = isset($noble_metal[$value['贵金属信息']]) ? $noble_metal[$value['贵金属信息']] : ''; $value['供货区域'] = isset($supply_area[$value['供货区域']]) ? $supply_area[$value['供货区域']] : ''; $data[] = $value; } if (empty($data)) $data[] = ['没有可供导出的数据']; $headerArr = array_keys($data[0]); excelSave('商品信息导出表(基本信息)' . date('YmdHis'), $headerArr, $data); } //【商品信息】成本(赵丹要的)_列表 public function goodCostZhao() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', 'spuCode' => '', 'page' => 1, 'size' => 15 ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = []; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['spuCode'] != '') $where[] = ['gp.spuCode', 'like', '%' . $param['spuCode'] . '%']; $count = Db::name('good_platform') ->alias('gp') ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('platform p', 'p.id=gp.platform_code') ->leftJoin('good_nake gn', 'gn.spuCode=gb.spuCode') ->leftJoin('good_ladder c', 'c.skuCode=gp.skuCode AND c.is_del=0') ->where($where) ->count('gp.id'); $data = Db::name('good_platform') ->alias('gp') ->field('gp.skuCode,gp.spuCode,gp.plat_code,gb.good_name,p.platform_name,gp.online_time,c.min_num moq,gn.nake_fee,gb.cost_fee,gn.delivery_fee,gb.cert_fee,gb.mark_fee,gb.packing_fee,gn.other_fee,gn.nake_total,gp.addtime') ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('platform p', 'p.id=gp.platform_code') ->leftJoin('good_nake gn', 'gn.spuCode=gb.spuCode') ->leftJoin('good_ladder c', 'c.skuCode=gp.skuCode AND c.is_del=0')//加入c.is_del可以命中索引 ->where($where) ->order('gp.id', 'desc') ->page($param['page'], $param['size']) ->select() ->toArray(); return json_show(0, '请求成功', ['list' => $data, 'count' => $count]); } //【商品信息】成本(赵丹要的)_导出 public function goodCostZhaoExport() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', 'spuCode' => '', ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = []; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['spuCode'] != '') $where[] = ['gp.spuCode', 'like', '%' . $param['spuCode'] . '%']; $data = Db::name('good_platform') ->alias('gp') ->field('gp.skuCode as 商品上线编号,gp.spuCode as 商品成本编号,gp.plat_code as 平台商品编码,gb.good_name as 商品名称,p.platform_name as 上线平台,gp.online_time as 上线完成时间,c.min_num 起订量,gn.nake_fee 成本单价,gb.cost_fee 工艺费,gn.delivery_fee 物流费,gb.cert_fee 证书费,gb.mark_fee 加标费,gb.packing_fee 包装费,gn.other_fee 其他费用,gn.nake_total 成本合计,gp.addtime 申请上线时间') ->where($where) ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('platform p', 'p.id=gp.platform_code') ->leftJoin('good_nake gn', 'gn.spuCode=gb.spuCode') ->leftJoin('good_ladder c', 'c.skuCode=gp.skuCode AND c.is_del=0') ->order('gp.id', 'desc') ->select() ->toArray(); if (empty($data)) $data[] = ['没有可供导出的数据']; $headerArr = array_keys($data[0]); excelSave('商品信息导出表(成本)' . date('YmdHis'), $headerArr, $data); } //【商品信息】售价(赵丹要的)_列表 public function goodPriceZhao() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', 'spuCode' => '', 'page' => 1, 'size' => 15 ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = []; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['spuCode'] != '') $where[] = ['gp.spuCode', 'like', '%' . $param['spuCode'] . '%']; $count = Db::name('good_platform') ->alias('gp') ->where($where) ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('platform p', 'p.id=gp.platform_code') ->leftJoin('good_ladder gl', 'gl.skuCode=gp.skuCode') ->count('gp.id'); $data = Db::name('good_platform') ->alias('gp') ->field('gp.skuCode,gp.spuCode,gp.plat_code,gb.good_name,p.platform_name,gp.online_time,gl.min_num moq,gl.sale_price,gl.cost_fee,gl.market_price,gl.market_platform,gp.addtime') ->where($where) ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('platform p', 'p.id=gp.platform_code') ->leftJoin('good_ladder gl', 'gl.skuCode=gp.skuCode AND gl.is_del=0')//加入is_del可以命中索引 ->order('gp.id', 'desc') ->page($param['page'], $param['size']) ->select() ->toArray(); return json_show(0, '请求成功', ['list' => $data, 'count' => $count]); } //【商品信息】售价(赵丹要的)_导出 public function goodPriceZhaoExport() { $param = $this->request->only([ 'token', 'start_date' => '', 'end_date' => '', 'spuCode' => '' ], 'post', 'trim'); $val_params = Validate::rule([ 'start_date' => 'date|elt:end_date', 'end_date' => 'date' ]); if (!$val_params->check($param)) return json_show(1004, $val_params->getError()); $where = []; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']]; if ($param['spuCode'] != '') $where[] = ['gp.spuCode', 'like', '%' . $param['spuCode'] . '%']; $data = Db::name('good_platform') ->alias('gp') ->field('gp.skuCode as 商品上线编号,gp.spuCode as 商品成本编号,gp.plat_code as 平台商品编码,gb.good_name as 商品名称,p.platform_name as 上线平台,gp.online_time as 上线完成时间,gl.min_num 起订量,gl.sale_price 售价,gl.cost_fee 工艺费,gl.market_price 市场价,gl.market_platform 对比平台,gp.addtime 申请上线时间') ->where($where) ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0') ->leftJoin('platform p', 'p.id=gp.platform_code') ->leftJoin('good_ladder gl', 'gl.skuCode=gp.skuCode AND gl.is_del=0') ->order('gp.id', 'desc') ->select() ->toArray(); if (empty($data)) $data[] = ['没有可供导出的数据']; $headerArr = array_keys($data[0]); excelSave('商品信息导出表(售价)' . date('YmdHis'), $headerArr, $data); } }