|
@@ -339,13 +339,15 @@ class SaleReport extends Base
|
|
|
->order('s.addtime', 'desc')
|
|
|
->cursor();
|
|
|
|
|
|
- $list = [];
|
|
|
+ $list = $tmp_customer = $tmp_item = [];
|
|
|
foreach ($data as $value) {
|
|
|
|
|
|
if (!empty($value['itemid'])) {
|
|
|
- $customer_org1 = array_column(get_top_customer_org($value['itemid']), 'name', 'level');
|
|
|
- $value['一级企业'] = isset($customer_org1[1]) ? $customer_org1[1] : '';
|
|
|
- $value['二级企业'] = isset($customer_org1[2]) ? $customer_org1[2] : '';
|
|
|
+
|
|
|
+ if (!isset($tmp_customer[$value['itemid']])) $tmp_customer[$value['itemid']] = array_column(get_top_customer_org($value['itemid']), 'name', 'level');
|
|
|
+// $customer_org1 = array_column(get_top_customer_org($value['itemid']), 'name', 'level');
|
|
|
+ $value['一级企业'] = isset($tmp_customer[$value['itemid']][1]) ? $tmp_customer[$value['itemid']][1] : '';
|
|
|
+ $value['二级企业'] = isset($tmp_customer[$value['itemid']][2]) ? $tmp_customer[$value['itemid']][2] : '';
|
|
|
}
|
|
|
|
|
|
if ($value['订单类型'] == 3 || $value['订单类型'] == 4) {
|
|
@@ -365,7 +367,8 @@ class SaleReport extends Base
|
|
|
$value['是否库存'] = isset($this->all_stock[$value['是否库存']]) ? $this->all_stock[$value['是否库存']] : '';
|
|
|
$value['订单类型'] = isset($this->all_order_type[$value['订单类型']]) ? $this->all_order_type[$value['订单类型']] : '';
|
|
|
|
|
|
- $value['创建人所属部门'] = get_company_name_by_uid($value['apply_id']);//获取创建人的所属部门
|
|
|
+ if (!isset($tmp_item[$value['apply_id']])) $tmp_item[$value['apply_id']] = get_company_name_by_uid($value['apply_id']);
|
|
|
+ $value['创建人所属部门'] = $tmp_item[$value['apply_id']];//获取创建人的所属部门
|
|
|
|
|
|
unset($value['itemid']);
|
|
|
unset($value['apply_id']);
|
|
@@ -1397,7 +1400,7 @@ class SaleReport extends Base
|
|
|
$where = [['b.is_del', '=', 0], ['b.send_type', '=', 2]];//send_type==2 延迟发货
|
|
|
if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['a.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
|
|
|
if ($param['start_sendtime'] != '' && $param['end_sendtime'] != '') $where[] = ['a.sendtime', 'between', [$param['start_sendtime'] . ' 00:00:00', $param['end_sendtime'] . ' 23:59:59']];
|
|
|
- if ($param['status'] != '') $where[] = ['b.status', '=', $param['status']];
|
|
|
+ if ($param['status'] != '') $where[] = ['a.status', '=', $param['status']];
|
|
|
if ($param['apply_company'] != '') $where[] = ['ci.name', 'like', '%' . $param['apply_company'] . '%'];
|
|
|
if ($param['order_type'] != '') $where[] = ['b.order_type', '=', $param['order_type']];
|
|
|
|
|
@@ -1416,7 +1419,7 @@ class SaleReport extends Base
|
|
|
|
|
|
$data = Db::name('order_out')
|
|
|
->alias('a')
|
|
|
- ->field('a.addtime,a.orderCode,os.cgdNo,bus.company,a.apply_name,a.apply_id,b.status,a.send_num,b.good_code,b.good_name,v.companyName,b.wsend_num,b.skuCode,b.order_type,e.person')
|
|
|
+ ->field('a.addtime,a.orderCode,os.cgdNo,bus.company,a.apply_name,a.apply_id,a.status,a.send_num,b.good_code,b.good_name,v.companyName,b.wsend_num,b.skuCode,b.order_type,e.person')
|
|
|
->leftJoin("sale b", "b.orderCode=a.orderCode")
|
|
|
->leftJoin("customer_info v", "v.companyNo=b.customer_code")
|
|
|
->leftJoin("order_send os", "os.outCode=a.outCode")
|
|
@@ -1453,7 +1456,7 @@ class SaleReport extends Base
|
|
|
|
|
|
$value['send_date'] = date('Y-m-d H:i:s', strtotime($value['addtime']) + $goon['customized'] * 24 * 3600);
|
|
|
|
|
|
- $value['status'] = isset($this->all_sale_status[$value['status']]) ? $this->all_sale_status[$value['status']] : '';
|
|
|
+ $value['status'] = isset($this->order_out_status[$value['status']]) ? $this->order_out_status[$value['status']] : '';
|
|
|
|
|
|
$list[] = $value;
|
|
|
}
|
|
@@ -1470,13 +1473,13 @@ class SaleReport extends Base
|
|
|
$where = [['b.is_del', '=', 0], ['b.send_type', '=', 2]];//send_type==2 延迟发货
|
|
|
if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['a.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
|
|
|
if ($param['start_sendtime'] != '' && $param['end_sendtime'] != '') $where[] = ['a.sendtime', 'between', [$param['start_sendtime'] . ' 00:00:00', $param['end_sendtime'] . ' 23:59:59']];
|
|
|
- if ($param['status'] != '') $where[] = ['b.status', '=', $param['status']];
|
|
|
+ if ($param['status'] != '') $where[] = ['a.status', '=', $param['status']];
|
|
|
if ($param['apply_company'] != '') $where[] = ['ci.name', 'like', '%' . $param['apply_company'] . '%'];
|
|
|
if ($param['order_type'] != '') $where[] = ['b.order_type', '=', $param['order_type']];
|
|
|
|
|
|
$data = Db::name('order_out')
|
|
|
->alias('a')
|
|
|
- ->field('a.addtime 下单时间,a.orderCode 订单编号,os.cgdNo 采购单编号,bus.company 公司名称,a.apply_name 申请人,"" 部门,a.apply_id,b.status 状态,a.send_num 出库总数,"" 商品分类,b.good_code 商品编码,b.good_name 商品名称,v.companyName 客户名称,b.wsend_num 未发货数量,"" 应发货日期,b.skuCode,b.order_type 订单类型,e.person 采购员')
|
|
|
+ ->field('a.addtime 下单时间,a.orderCode 订单编号,os.cgdNo 采购单编号,bus.company 公司名称,a.apply_name 申请人,"" 部门,a.apply_id,a.status 状态,a.send_num 出库总数,"" 商品分类,b.good_code 商品编码,b.good_name 商品名称,v.companyName 客户名称,b.wsend_num 未发货数量,"" 应发货日期,b.skuCode,b.order_type 订单类型,e.person 采购员')
|
|
|
->leftJoin("sale b", "b.orderCode=a.orderCode")
|
|
|
->leftJoin("customer_info v", "v.companyNo=b.customer_code")
|
|
|
->leftJoin("order_send os", "os.outCode=a.outCode")
|
|
@@ -1515,7 +1518,7 @@ class SaleReport extends Base
|
|
|
|
|
|
$value['应发货日期'] = date('Y-m-d H:i:s', strtotime($value['下单时间']) + $goon['customized'] * 24 * 3600);
|
|
|
|
|
|
- $value['状态'] = isset($this->all_sale_status[$value['状态']]) ? $this->all_sale_status[$value['状态']] : '';
|
|
|
+ $value['状态'] = isset($this->order_out_status[$value['状态']]) ? $this->order_out_status[$value['状态']] : '';
|
|
|
$value['订单类型'] = isset($this->all_order_type[$value['订单类型']]) ? $this->all_order_type[$value['订单类型']] : '';
|
|
|
|
|
|
unset($value['apply_id']);
|
|
@@ -1537,7 +1540,7 @@ class SaleReport extends Base
|
|
|
$where = [['b.send_type', '=', 1]];//send_type==1 直接发货
|
|
|
if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['a.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
|
|
|
if ($param['start_sendtime'] != '' && $param['end_sendtime'] != '') $where[] = ['a.sendtime', 'between', [$param['start_sendtime'] . ' 00:00:00', $param['end_sendtime'] . ' 23:59:59']];
|
|
|
- if ($param['status'] != '') $where[] = ['b.status', '=', $param['status']];
|
|
|
+ if ($param['status'] != '') $where[] = ['a.status', '=', $param['status']];
|
|
|
if ($param['apply_company'] != '') $where[] = ['ci.name', 'like', '%' . $param['apply_company'] . '%'];
|
|
|
if ($param['order_type'] != '') $where[] = ['b.order_type', '=', $param['order_type']];
|
|
|
|
|
@@ -1556,7 +1559,7 @@ class SaleReport extends Base
|
|
|
|
|
|
$data = Db::name('order_out')
|
|
|
->alias('a')
|
|
|
- ->field('a.addtime,a.orderCode,a.sendtime,a.outCode,b.status,b.good_name,b.sale_price,a.send_num,a.apply_name,ci.name apply_company,c.person cgder,a.post_name,a.post_code,oa.contactor,oa.mobile,oa.addr,oa.addr_code,a.remark,b.order_type')
|
|
|
+ ->field('a.addtime,a.orderCode,a.sendtime,a.outCode,a.status,b.good_name,b.sale_price,a.send_num,a.apply_name,ci.name apply_company,c.person cgder,a.post_name,a.post_code,oa.contactor,oa.mobile,oa.addr,oa.addr_code,a.remark,b.order_type')
|
|
|
->leftJoin("sale b", "b.orderCode=a.orderCode")
|
|
|
->leftJoin("order_send os", "os.outCode=a.outCode")
|
|
|
->leftJoin("purchease_order po", "po.cgdNo=os.cgdNo")
|
|
@@ -1574,7 +1577,7 @@ class SaleReport extends Base
|
|
|
|
|
|
$value['send_total_price'] = round($value['send_num'] * $value['sale_price'], 2);
|
|
|
|
|
|
- $value['status'] = isset($this->all_sale_status[$value['status']]) ? $this->all_sale_status[$value['status']] : '';
|
|
|
+ $value['status'] = isset($this->order_out_status[$value['status']]) ? $this->order_out_status[$value['status']] : '';
|
|
|
|
|
|
//拼接省市区
|
|
|
if (!json_decode($value['addr_code'])) {
|
|
@@ -1599,13 +1602,13 @@ class SaleReport extends Base
|
|
|
$where = [['b.send_type', '=', 1]];//send_type==1 直接发货
|
|
|
if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['a.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
|
|
|
if ($param['start_sendtime'] != '' && $param['end_sendtime'] != '') $where[] = ['a.sendtime', 'between', [$param['start_sendtime'] . ' 00:00:00', $param['end_sendtime'] . ' 23:59:59']];
|
|
|
- if ($param['status'] != '') $where[] = ['b.status', '=', $param['status']];
|
|
|
+ if ($param['status'] != '') $where[] = ['a.status', '=', $param['status']];
|
|
|
if ($param['apply_company'] != '') $where[] = ['ci.name', 'like', '%' . $param['apply_company'] . '%'];
|
|
|
if ($param['order_type'] != '') $where[] = ['b.order_type', '=', $param['order_type']];
|
|
|
|
|
|
$data = Db::name('order_out')
|
|
|
->alias('a')
|
|
|
- ->field('a.addtime 下单日期,a.orderCode 订单编号,a.sendtime 发货时间,a.outCode 发货申请单号,b.status 发货申请单状态,b.good_name 商品名称,b.sale_price 产品单价,a.send_num 发货数量,"" 发货申请单总价,a.apply_name 申请人,ci.name 部门,c.person 采购员,a.post_name 快递公司,a.post_code 快递单号,oa.contactor 收货人,oa.mobile 收货电话,oa.addr 收货地址,oa.addr_code,a.remark 备注,b.order_type 订单类型')
|
|
|
+ ->field('a.addtime 下单日期,a.orderCode 订单编号,a.sendtime 发货时间,a.outCode 发货申请单号,a.status 发货申请单状态,b.good_name 商品名称,b.sale_price 产品单价,a.send_num 发货数量,"" 发货申请单总价,a.apply_name 申请人,ci.name 部门,c.person 采购员,a.post_name 快递公司,a.post_code 快递单号,oa.contactor 收货人,oa.mobile 收货电话,oa.addr 收货地址,oa.addr_code,a.remark 备注,b.order_type 订单类型')
|
|
|
->leftJoin("sale b", "b.orderCode=a.orderCode")
|
|
|
->leftJoin("order_send os", "os.outCode=a.outCode")
|
|
|
->leftJoin("purchease_order po", "po.cgdNo=os.cgdNo")
|
|
@@ -1622,7 +1625,7 @@ class SaleReport extends Base
|
|
|
|
|
|
$value['发货申请单总价'] = round(bcmul($value['发货数量'], $value['产品单价'], 3), 2);
|
|
|
|
|
|
- $value['发货申请单状态'] = isset($this->all_sale_status[$value['发货申请单状态']]) ? $this->all_sale_status[$value['发货申请单状态']] : '';
|
|
|
+ $value['发货申请单状态'] = isset($this->order_out_status[$value['发货申请单状态']]) ? $this->order_out_status[$value['发货申请单状态']] : '';
|
|
|
$value['订单类型'] = isset($this->all_order_type[$value['订单类型']]) ? $this->all_order_type[$value['订单类型']] : '';
|
|
|
|
|
|
//拼接省市区
|