|
@@ -5,7 +5,7 @@ namespace app\admin\controller;
|
|
|
use think\facade\Db;
|
|
|
use think\facade\Validate;
|
|
|
|
|
|
-//销售报表处理类
|
|
|
+//前端报表处理类
|
|
|
class SaleReport extends Base
|
|
|
{
|
|
|
|
|
@@ -1389,14 +1389,17 @@ class SaleReport extends Base
|
|
|
|
|
|
}
|
|
|
|
|
|
- //【八、无地址待发货订单】
|
|
|
+ //【八、延时发货申请单统计】
|
|
|
public function orderOutNotAddr()
|
|
|
{
|
|
|
+ $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'start_sendtime' => '', 'end_sendtime' => '', 'status' => '', 'apply_company' => '', 'page' => 1, 'size' => 15, 'order_type' => ''], 'post', 'trim');
|
|
|
|
|
|
- $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
|
|
|
-
|
|
|
- $where = [['b.send_type', '=', 2]];//send_type==2 延迟发货
|
|
|
+ $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[] = ['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']];
|
|
|
|
|
|
$count = Db::name('order_out')
|
|
|
->alias('a')
|
|
@@ -1404,17 +1407,21 @@ class SaleReport extends Base
|
|
|
->leftJoin("customer_info v", "v.companyNo=b.customer_code")
|
|
|
->leftJoin("order_send os", "os.outCode=a.outCode")
|
|
|
->leftJoin("business bus", "bus.companyNo=b.supplierNo")
|
|
|
+ ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+ ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
->where($where)
|
|
|
->order("a.addtime desc")
|
|
|
->count('a.id');
|
|
|
|
|
|
$data = Db::name('order_out')
|
|
|
->alias('a')
|
|
|
- ->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,a.order_type')
|
|
|
+ ->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')
|
|
|
->leftJoin("sale b", "b.orderCode=a.orderCode")
|
|
|
->leftJoin("customer_info v", "v.companyNo=b.customer_code")
|
|
|
->leftJoin("order_send os", "os.outCode=a.outCode")
|
|
|
->leftJoin("business bus", "bus.companyNo=b.supplierNo")
|
|
|
+ ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+ ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
->where($where)
|
|
|
->page($param['page'], $param['size'])
|
|
|
->order("a.addtime desc")
|
|
@@ -1435,7 +1442,7 @@ class SaleReport extends Base
|
|
|
->alias('a')
|
|
|
->field('a.id,b.cat_id,b.customized')
|
|
|
->join('good b', 'b.spuCode=a.spuCode', 'left')
|
|
|
- ->where(['a.skuCode' => $value['skuCode']])
|
|
|
+ ->where(['a.is_del' => 0, 'a.skuCode' => $value['skuCode']])
|
|
|
->find();
|
|
|
}
|
|
|
|
|
@@ -1450,22 +1457,28 @@ class SaleReport extends Base
|
|
|
return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
|
|
|
}
|
|
|
|
|
|
- //【八、无地址待发货订单】
|
|
|
+ //【八、延时发货申请单统计】
|
|
|
public function orderOutNotAddrExport()
|
|
|
{
|
|
|
|
|
|
- $param = $this->request->only(['token', 'start_date' => '', 'end_date' => ''], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'start_sendtime' => '', 'end_sendtime' => '', 'status' => '', 'apply_company' => '', 'page' => 1, 'size' => 15, 'order_type' => ''], 'post', 'trim');
|
|
|
|
|
|
- $where = [['b.send_type', '=', 2]];//send_type==2 延迟发货
|
|
|
+ $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[] = ['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,a.status 状态,a.send_num 出库总数,"" 商品分类,b.good_code 商品编码,b.good_name 商品名称,v.companyName 客户名称,b.wsend_num 未发货数量,"" 应发货日期,b.skuCode,a.order_type')
|
|
|
+ ->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 订单类型')
|
|
|
->leftJoin("sale b", "b.orderCode=a.orderCode")
|
|
|
->leftJoin("customer_info v", "v.companyNo=b.customer_code")
|
|
|
->leftJoin("order_send os", "os.outCode=a.outCode")
|
|
|
->leftJoin("business bus", "bus.companyNo=b.supplierNo")
|
|
|
+ ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+ ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
->where($where)
|
|
|
->order("a.addtime desc")
|
|
|
->cursor();
|
|
@@ -1475,17 +1488,18 @@ class SaleReport extends Base
|
|
|
|
|
|
$value['部门'] = get_company_name_by_uid($value['apply_id']);
|
|
|
|
|
|
- if ($value['order_type'] == 3 || $value['order_type'] == 4) {
|
|
|
+ if ($value['订单类型'] == 3 || $value['订单类型'] == 4) {
|
|
|
$goon = Db::name("good_zixun")
|
|
|
->field('id,cat_id,customized')
|
|
|
->where(["spuCode" => $value['商品编码'], "is_del" => 0])
|
|
|
->find();
|
|
|
+
|
|
|
} else {
|
|
|
$goon = Db::name('good_platform')
|
|
|
->alias('a')
|
|
|
->field('a.id,b.cat_id,b.customized')
|
|
|
->join('good b', 'b.spuCode=a.spuCode', 'left')
|
|
|
- ->where(['a.skuCode' => $value['skuCode']])
|
|
|
+ ->where(['a.is_del' => 0, 'a.skuCode' => $value['skuCode']])
|
|
|
->find();
|
|
|
}
|
|
|
|
|
@@ -1493,29 +1507,30 @@ class SaleReport extends Base
|
|
|
$value['应发货日期'] = date('Y-m-d H:i:s', strtotime($value['下单时间']) + $goon['customized'] * 24 * 3600);
|
|
|
|
|
|
$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']);
|
|
|
unset($value['skuCode']);
|
|
|
- unset($value['order_type']);
|
|
|
|
|
|
$list[] = $value;
|
|
|
}
|
|
|
|
|
|
if (empty($list)) $list[] = '没有相关可导出的数据';
|
|
|
- excelSave('无地址待发货订单' . date('YmdHis'), array_keys($list[0]), $list);
|
|
|
+ excelSave('延时发货申请单' . date('YmdHis'), array_keys($list[0]), $list);
|
|
|
|
|
|
}
|
|
|
|
|
|
- //【九、有地址待发货订单】
|
|
|
+ //【九、直接发货申请单统计 】
|
|
|
public function orderOutAddr()
|
|
|
{
|
|
|
- $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'start_sendtime' => '', 'end_sendtime' => '', 'status' => '', 'apply_company' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'start_sendtime' => '', 'end_sendtime' => '', 'status' => '', 'apply_company' => '', 'page' => 1, 'size' => 15, 'order_type' => ''], 'post', 'trim');
|
|
|
|
|
|
$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[] = ['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']];
|
|
|
|
|
|
$count = Db::name('order_out')
|
|
|
->alias('a')
|
|
@@ -1531,7 +1546,7 @@ class SaleReport extends Base
|
|
|
|
|
|
$data = Db::name('order_out')
|
|
|
->alias('a')
|
|
|
- ->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,po.cgder,a.post_name,a.post_code,oa.contactor,oa.mobile,oa.addr,oa.addr_code,a.remark')
|
|
|
+ ->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,po.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")
|
|
@@ -1565,20 +1580,21 @@ class SaleReport extends Base
|
|
|
|
|
|
}
|
|
|
|
|
|
- //【九、有地址待发货订单】
|
|
|
+ //【九、直接发货申请单统计 】
|
|
|
public function orderOutAddrExport()
|
|
|
{
|
|
|
- $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'start_sendtime' => '', 'end_sendtime' => '', 'status' => '', 'apply_company' => ''], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'start_sendtime' => '', 'end_sendtime' => '', 'status' => '', 'apply_company' => '', 'order_type' => ''], 'post', 'trim');
|
|
|
|
|
|
$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[] = ['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 发货申请单号,a.status 发货申请单状态,b.good_name 商品名称,b.sale_price 产品单价,a.send_num 发货数量,"" 发货申请单总价,a.apply_name 申请人,ci.name 部门,po.cgder 采购人,a.post_name 快递公司,a.post_code 快递单号,oa.contactor 收货人,oa.mobile 收货电话,oa.addr 收货地址,oa.addr_code,a.remark 备注')
|
|
|
+ ->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 部门,po.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")
|
|
@@ -1595,6 +1611,7 @@ class SaleReport extends Base
|
|
|
$value['发货申请单总价'] = round($value['发货数量'] * $value['产品单价'], 2);
|
|
|
|
|
|
$value['发货申请单状态'] = isset($this->order_out_status[$value['发货申请单状态']]) ? $this->order_out_status[$value['发货申请单状态']] : '';
|
|
|
+ $value['订单类型'] = isset($this->all_order_type[$value['订单类型']]) ? $this->all_order_type[$value['订单类型']] : '';
|
|
|
|
|
|
//拼接省市区
|
|
|
if (!json_decode($value['addr_code'])) {
|
|
@@ -1610,7 +1627,84 @@ class SaleReport extends Base
|
|
|
}
|
|
|
|
|
|
if (empty($list)) $list[] = '没有相关可导出的数据';
|
|
|
- excelSave('有地址待发货单列表' . date('YmdHis'), array_keys($list[0]), $list);
|
|
|
+ excelSave('直接发货申请单统计' . date('YmdHis'), array_keys($list[0]), $list);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //【十、无地址销售订单】
|
|
|
+ public function saleNotAddr()
|
|
|
+ {
|
|
|
+
|
|
|
+ $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'status' => '', 'apply_company' => '', 'page' => 1, 'size' => 15, 'order_type' => ''], 'post', 'trim');
|
|
|
+
|
|
|
+ $where = [['a.send_type', '=', 2], ['a.is_del', '=', 0]];//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['status'] != '') $where[] = ['a.status', '=', $param['status']];
|
|
|
+ if ($param['apply_company'] != '') $where[] = ['ci.name', 'like', '%' . $param['apply_company'] . '%'];
|
|
|
+ if ($param['order_type'] != '') $where[] = ['a.order_type', '=', $param['order_type']];
|
|
|
+
|
|
|
+ $count = Db::name('sale')
|
|
|
+ ->alias('a')
|
|
|
+ ->leftJoin("order_addr b", "b.orderCode=a.orderCode AND b.is_del=0")
|
|
|
+ ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+ ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
+ ->where($where)
|
|
|
+ ->group('a.id,a.orderCode,a.order_type,a.good_code,a.skuCode,good_name,a.good_num,a.send_num,a.wsend_num,a.status,u.nickname,ci.name,b.orderCode')
|
|
|
+ ->having('a.good_num > SUM(b.receipt_quantity) ')
|
|
|
+ ->count('a.id');
|
|
|
+
|
|
|
+ $data = Db::name('sale')
|
|
|
+ ->alias('a')
|
|
|
+ ->field('a.id,a.orderCode,a.order_type,a.good_code,a.skuCode,good_name,a.good_num,a.send_num,a.wsend_num,a.status,u.nickname,ci.name,(a.good_num - SUM(b.receipt_quantity) ) as not_addr_address_good_num')
|
|
|
+ ->leftJoin("order_addr b", "b.orderCode=a.orderCode AND b.is_del=0")
|
|
|
+ ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+ ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
+ ->where($where)
|
|
|
+ ->group('a.id,a.orderCode,a.order_type,a.good_code,a.skuCode,good_name,a.good_num,a.send_num,a.wsend_num,a.status,u.nickname,ci.name,b.orderCode')
|
|
|
+ ->having('a.good_num > SUM(b.receipt_quantity) ')
|
|
|
+ ->page($param['page'], $param['size'])
|
|
|
+ ->order("a.addtime desc")
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ return app_show(0, '请求成功', ['list' => $data, 'count' => $count]);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //【十、无地址销售订单-导出】
|
|
|
+ public function saleNotAddrExport()
|
|
|
+ {
|
|
|
+
|
|
|
+ $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'status' => '', 'apply_company' => '', 'order_type' => ''], 'post', 'trim');
|
|
|
+
|
|
|
+ $where = [['a.send_type', '=', 2], ['a.is_del', '=', 0]];//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['status'] != '') $where[] = ['a.status', '=', $param['status']];
|
|
|
+ if ($param['apply_company'] != '') $where[] = ['ci.name', 'like', '%' . $param['apply_company'] . '%'];
|
|
|
+ if ($param['order_type'] != '') $where[] = ['a.order_type', '=', $param['order_type']];
|
|
|
+
|
|
|
+ $data = Db::name('sale')
|
|
|
+ ->alias('a')
|
|
|
+ ->field('a.orderCode 订单编号,a.order_type 订单类型,a.good_code 商品成本编码,a.skuCode 商品上线编码,good_name 商品名称,a.good_num 购买数量,a.send_num 已发货数量,a.wsend_num 未发货数量,a.status 订单状态,u.nickname 申请人名称,ci.name 申请人所属部门,(a.good_num - SUM(b.receipt_quantity) ) as 无地址数量')
|
|
|
+ ->leftJoin("order_addr b", "b.orderCode=a.orderCode AND b.is_del=0")->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+ ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
+ ->where($where)
|
|
|
+ ->group('a.id,a.orderCode,a.order_type,a.good_code,a.skuCode,good_name,a.good_num,a.send_num,a.wsend_num,a.status,u.nickname,ci.name,b.orderCode')
|
|
|
+ ->having('a.good_num > SUM(b.receipt_quantity) ')
|
|
|
+ ->order("a.addtime desc")
|
|
|
+ ->cursor();
|
|
|
+
|
|
|
+ $list = [];
|
|
|
+ foreach ($data as $value) {
|
|
|
+
|
|
|
+ $value['订单类型'] = isset($this->all_order_type[$value['订单类型']]) ? $this->all_order_type[$value['订单类型']] : '';
|
|
|
+ $value['订单状态'] = isset($this->all_sale_status[$value['订单状态']]) ? $this->all_sale_status[$value['订单状态']] : '';
|
|
|
+
|
|
|
+ $list[] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (empty($list)) $list[] = '没有相关可导出的数据';
|
|
|
+ excelSave('无地址销售订单列表' . date('YmdHis'), array_keys($list[0]), $list);
|
|
|
|
|
|
}
|
|
|
|