|
@@ -913,7 +913,7 @@ class SaleReportByRelaComNo extends Base
|
|
|
unset($customer2_tmp);
|
|
|
unset($uid_tmp);
|
|
|
|
|
|
- return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
|
|
|
+ return app_show(0, '请求成功', ['count' => $count, 'list' => $list]);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -923,7 +923,7 @@ class SaleReportByRelaComNo extends Base
|
|
|
|
|
|
$param = $this->request->only(['token', 'start_date' => '', 'end_date' => ''], 'post', 'trim');
|
|
|
|
|
|
- $where = [['s.is_del', '=', 0], ['oo.status', '=', 2], ['s.supplierNo', '=', $this->relaComNo]];
|
|
|
+ $where = [['oo.is_del', '=', 0], ['oo.status', '=', 2], ['s.is_del', '=', 0], ['s.supplierNo', '=', $this->relaComNo]];
|
|
|
if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['s.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
|
|
|
|
|
|
// $data = Db::name('order_out')
|
|
@@ -959,11 +959,11 @@ class SaleReportByRelaComNo extends Base
|
|
|
// }
|
|
|
|
|
|
$list = $this->saleNotSignedExportTemp($where);
|
|
|
+
|
|
|
excelSave('未签收报表' . date('YmdHis'), ['创建人', '创建人所属部门', '下单时间', '订单号', '一级企业', '二级企业', '客户名称', '商品名称', '数量', '单位', '单价', '金额', '发货时间'], $list);
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//针对"【一、管理报表】5.未签收报表_导出"数据量太大
|
|
|
private function saleNotSignedExportTemp(array $where = [])
|
|
|
{
|
|
@@ -972,7 +972,7 @@ class SaleReportByRelaComNo extends Base
|
|
|
->field('s.apply_name 创建人,"" 创建人所属部门,s.addtime 下单时间,s.orderCode 订单号,"" 一级企业,"" 二级企业,"" 客户名称,s.good_name 商品名称,s.good_num 数量,"" 单位,s.sale_price 单价,s.total_price 金额,oo.sendtime 发货时间,s.good_code,s.order_type,s.apply_id,s.customer_code')
|
|
|
->leftJoin('sale s', 's.orderCode=oo.orderCode')
|
|
|
// ->leftJoin('customer_info csi', 'csi.companyNo=s.customer_code')
|
|
|
- ->leftJoin('order_out out', 'out.orderCode=s.orderCode AND out.is_del=0')
|
|
|
+// ->leftJoin('order_out out', 'out.orderCode=s.orderCode AND out.is_del=0')
|
|
|
->where($where)
|
|
|
->order('s.addtime', 'desc')
|
|
|
->cursor();
|
|
@@ -1328,8 +1328,8 @@ class SaleReportByRelaComNo extends Base
|
|
|
->leftJoin('consult_bids cb', 'cb.infoNo=ci.infoNo AND cb.is_del=0')
|
|
|
->leftJoin('sale s', 's.zxNo=cb.bidNo AND s.is_del=0')
|
|
|
->leftJoin('consult_order co', 'co.zxNo=cb.zxNo')
|
|
|
- ->leftJoin('depart_user du', 'du.uid=co.saleid AND du.is_del=0')
|
|
|
- ->leftJoin('company_item item', 'item.id=du.itemid')
|
|
|
+// ->leftJoin('depart_user du', 'du.uid=co.saleid AND du.is_del=0')
|
|
|
+// ->leftJoin('company_item item', 'item.id=du.itemid')
|
|
|
// ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo')
|
|
|
->leftJoin('brand b', 'b.id=ci.brand_id')
|
|
|
->leftJoin('unit u', 'u.id=ci.unit')
|
|
@@ -1339,12 +1339,12 @@ class SaleReportByRelaComNo extends Base
|
|
|
|
|
|
$data = Db::name('consult_info')
|
|
|
->alias('ci')
|
|
|
- ->field('ci.addtime,co.salesman,item.name,cb.infoNo,"" companyName,ci.use_desc,ci.good_name,b.brand_name,ci.model,s.good_code,ci.cat_id,ci.budget_price,u.unit,ci.num,s.sale_price,ci.arrival_time,ci.is_addrs,ci.is_custom,ci.remark,ci.status,ci.bargain_code,s.orderCode,co.khNo')
|
|
|
+ ->field('ci.addtime,co.salesman,"" name,cb.infoNo,"" companyName,ci.use_desc,ci.good_name,b.brand_name,ci.model,s.good_code,ci.cat_id,ci.budget_price,u.unit,ci.num,s.sale_price,ci.arrival_time,ci.is_addrs,ci.is_custom,ci.remark,ci.status,ci.bargain_code,s.orderCode,co.khNo,co.saleid')
|
|
|
->leftJoin('consult_bids cb', 'cb.infoNo=ci.infoNo AND cb.is_del=0')
|
|
|
->leftJoin('sale s', 's.zxNo=cb.bidNo AND s.is_del=0')
|
|
|
->leftJoin('consult_order co', 'co.zxNo=cb.zxNo')
|
|
|
- ->leftJoin('depart_user du', 'du.uid=co.saleid AND du.is_del=0')
|
|
|
- ->leftJoin('company_item item', 'item.id=du.itemid')
|
|
|
+// ->leftJoin('depart_user du', 'du.uid=co.saleid AND du.is_del=0')
|
|
|
+// ->leftJoin('company_item item', 'item.id=du.itemid')
|
|
|
// ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo')
|
|
|
->leftJoin('brand b', 'b.id=ci.brand_id')
|
|
|
->leftJoin('unit u', 'u.id=ci.unit')
|
|
@@ -1354,10 +1354,13 @@ class SaleReportByRelaComNo extends Base
|
|
|
->cursor();
|
|
|
|
|
|
$userCommon = \app\admin\common\User::getIns();
|
|
|
- $list = $customer2_tmp = [];
|
|
|
+ $list = $customer2_tmp = $tmp = [];
|
|
|
|
|
|
foreach ($data as $value) {
|
|
|
|
|
|
+ if (!isset($tmp[$value['saleid']])) $tmp[$value['saleid']] = get_company_name_by_uid($value['saleid']);
|
|
|
+ $value['name']=$tmp[$value['saleid']] ?? '';
|
|
|
+
|
|
|
if (!isset($customer2_tmp[$value['khNo']])) {
|
|
|
$temp = $userCommon->handle('cInfo', ['companyNo' => $value['khNo']]);
|
|
|
$customer2_tmp[$value['khNo']] = [
|
|
@@ -1404,12 +1407,12 @@ class SaleReportByRelaComNo extends Base
|
|
|
|
|
|
$data = Db::name('consult_info')
|
|
|
->alias('ci')
|
|
|
- ->field('ci.addtime 咨询时间,co.salesman 业务员,item.name 业务部门,cb.infoNo 咨询单号,"" 一级组织,"" 二级组织,"" 客户名称,ci.use_desc 产品用途,ci.good_name 产品名称,b.brand_name 品牌,ci.model 型号,s.good_code 产品编码,"" 一级分类,ci.cat_id,ci.budget_price 预算单价,u.unit 单位,ci.num 需求数量,"" 预算总价,s.sale_price 单价,ci.arrival_time 要求到货时间,ci.is_addrs 是否一地,ci.is_custom 定制,ci.remark 咨询备注,ci.status 竞单状态,ci.bargain_code 上次咨询单单号,s.orderCode 销售订单编号,co.khNo')
|
|
|
+ ->field('ci.addtime 咨询时间,co.salesman 业务员,"" 业务部门,cb.infoNo 咨询单号,"" 一级组织,"" 二级组织,"" 客户名称,ci.use_desc 产品用途,ci.good_name 产品名称,b.brand_name 品牌,ci.model 型号,s.good_code 产品编码,"" 一级分类,ci.cat_id,ci.budget_price 预算单价,u.unit 单位,ci.num 需求数量,"" 预算总价,s.sale_price 单价,ci.arrival_time 要求到货时间,ci.is_addrs 是否一地,ci.is_custom 定制,ci.remark 咨询备注,ci.status 竞单状态,ci.bargain_code 上次咨询单单号,s.orderCode 销售订单编号,co.khNo,co.saleid')
|
|
|
->leftJoin('consult_bids cb', 'cb.infoNo=ci.infoNo AND cb.is_del=0')
|
|
|
->leftJoin('sale s', 's.zxNo=cb.bidNo AND s.is_del=0')
|
|
|
->leftJoin('consult_order co', 'co.zxNo=cb.zxNo')
|
|
|
- ->leftJoin('depart_user du', 'du.uid=co.saleid AND du.is_del=0')
|
|
|
- ->leftJoin('company_item item', 'item.id=du.itemid')
|
|
|
+// ->leftJoin('depart_user du', 'du.uid=co.saleid AND du.is_del=0')
|
|
|
+// ->leftJoin('company_item item', 'item.id=du.itemid')
|
|
|
// ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo')
|
|
|
->leftJoin('brand b', 'b.id=ci.brand_id')
|
|
|
->leftJoin('unit u', 'u.id=ci.unit')
|
|
@@ -1418,9 +1421,11 @@ class SaleReportByRelaComNo extends Base
|
|
|
->cursor();
|
|
|
|
|
|
$userCommon = \app\admin\common\User::getIns();
|
|
|
- $list = $customer2_tmp = [];
|
|
|
+ $list = $customer2_tmp = $tmp=[];
|
|
|
|
|
|
foreach ($data as $value) {
|
|
|
+ if (!isset($tmp[$value['saleid']])) $tmp[$value['saleid']] = get_company_name_by_uid($value['saleid']);
|
|
|
+ $value['业务部门']=$tmp[$value['saleid']] ?? '';
|
|
|
|
|
|
if (!isset($customer2_tmp[$value['khNo']])) {
|
|
|
$temp = $userCommon->handle('cInfo', ['companyNo' => $value['khNo']]);
|
|
@@ -1452,6 +1457,7 @@ class SaleReportByRelaComNo extends Base
|
|
|
unset($value['itemid']);
|
|
|
unset($value['cat_id']);
|
|
|
unset($value['khNo']);
|
|
|
+ unset($value['saleid']);
|
|
|
|
|
|
$list[] = $value;
|
|
|
}
|
|
@@ -1650,14 +1656,14 @@ class SaleReportByRelaComNo extends Base
|
|
|
->leftJoin('order_addr oa', 'oa.id=oo.addrid')
|
|
|
->leftJoin('result_info ri', 'ri.result_code=or.error_code')
|
|
|
->where('or.is_del', 0)
|
|
|
- ->whereIn('or.returnCode', $th_types[2])
|
|
|
+ ->whereIn('or.returnCode', $th_types[2] ?? [])
|
|
|
->column('or.id,or.outCode,or.status,or.apply_id,or.apply_name,oa.contactor,oa.mobile,oa.addr,ri.result,oa.addr_code', 'or.returnCode');
|
|
|
|
|
|
|
|
|
$all_order_back = Db::name('order_back')
|
|
|
->alias('ob')
|
|
|
->where('ob.is_del', 0)
|
|
|
- ->whereIn('ob.thNo', $th_types[3])
|
|
|
+ ->whereIn('ob.thNo', $th_types[3] ?? [])
|
|
|
->withAttr('status', function ($val) {
|
|
|
return isset($this->order_back_status[$val]) ? $this->order_back_status[$val] : '';
|
|
|
})
|
|
@@ -1746,14 +1752,14 @@ class SaleReportByRelaComNo extends Base
|
|
|
->leftJoin('order_addr oa', 'oa.id=oo.addrid')
|
|
|
->leftJoin('result_info ri', 'ri.result_code=or.error_code')
|
|
|
->where('or.is_del', 0)
|
|
|
- ->whereIn('or.returnCode', $th_types[2])
|
|
|
+ ->whereIn('or.returnCode', $th_types[2] ?? [])
|
|
|
->column('or.id,or.outCode 发货申请单编码,or.status 退货单状态,or.apply_id,or.apply_name 创建人,"" 部门,oa.contactor 发货单联系人,oa.mobile 发货单联系人电话,oa.addr 发货单地址,ri.result 退货原因,oa.addr_code', 'or.returnCode');
|
|
|
|
|
|
|
|
|
$all_order_back = Db::name('order_back')
|
|
|
->alias('ob')
|
|
|
->where('ob.is_del', 0)
|
|
|
- ->whereIn('ob.thNo', $th_types[3])
|
|
|
+ ->whereIn('ob.thNo', $th_types[3] ?? [])
|
|
|
->withAttr('退货单状态', function ($val) {
|
|
|
return isset($this->order_back_status[$val]) ? $this->order_back_status[$val] : '';
|
|
|
})
|
|
@@ -2095,7 +2101,7 @@ class SaleReportByRelaComNo extends Base
|
|
|
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['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')
|
|
@@ -2104,10 +2110,11 @@ class SaleReportByRelaComNo 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")
|
|
|
+// ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+// ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
->leftJoin("purchease_order d", "d.cgdNo=os.cgdNo")
|
|
|
-// ->leftJoin("supplier e", "e.code=d.supplierNo")->where($where)
|
|
|
+// ->leftJoin("supplier e", "e.code=d.supplierNo")
|
|
|
+ ->where($where)
|
|
|
->order("a.addtime desc")
|
|
|
->count('a.id');
|
|
|
|
|
@@ -2118,10 +2125,11 @@ class SaleReportByRelaComNo 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")
|
|
|
+// ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+// ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
->leftJoin("purchease_order d", "d.cgdNo=os.cgdNo")
|
|
|
-// ->leftJoin("supplier e", "e.code=d.supplierNo")->where($where)
|
|
|
+// ->leftJoin("supplier e", "e.code=d.supplierNo")
|
|
|
+ ->where($where)
|
|
|
->page($param['page'], $param['size'])
|
|
|
->order("a.addtime desc")
|
|
|
->cursor();
|
|
@@ -2137,7 +2145,7 @@ class SaleReportByRelaComNo extends Base
|
|
|
|
|
|
if (!isset($tmp_person[$value['supplierNo']])) {
|
|
|
$tmp = $userCommon->handle('sInfo', ['code' => $value['supplierNo']]);
|
|
|
- $tmp_person[$value['supplierNo']] = $tmp['data']['person'];
|
|
|
+ $tmp_person[$value['supplierNo']] = $tmp['data']['person'] ?? '';
|
|
|
}
|
|
|
$value['person'] = $tmp_person[$value['supplierNo']];
|
|
|
|
|
@@ -2194,7 +2202,7 @@ class SaleReportByRelaComNo extends Base
|
|
|
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['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')
|
|
@@ -2204,8 +2212,8 @@ class SaleReportByRelaComNo 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")
|
|
|
+// ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+// ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
->leftJoin("purchease_order d", "d.cgdNo=os.cgdNo")
|
|
|
// ->leftJoin("supplier e", "e.code=d.supplierNo")
|
|
|
->where($where)
|
|
@@ -2224,7 +2232,7 @@ class SaleReportByRelaComNo extends Base
|
|
|
|
|
|
if (!isset($tmp_person[$value['supplierNo']])) {
|
|
|
$tmp = $userCommon->handle('sInfo', ['code' => $value['supplierNo']]);
|
|
|
- $tmp_person[$value['supplierNo']] = $tmp['data']['person'];
|
|
|
+ $tmp_person[$value['supplierNo']] = $tmp['data']['person'] ?? '';
|
|
|
}
|
|
|
$value['采购员'] = $tmp_person[$value['supplierNo']];
|
|
|
|
|
@@ -2303,8 +2311,8 @@ class SaleReportByRelaComNo extends Base
|
|
|
->leftJoin("order_send os", "os.outCode=a.outCode")
|
|
|
->leftJoin("purchease_order po", "po.cgdNo=os.cgdNo")
|
|
|
->leftJoin("order_addr oa", "oa.id=a.addrid")
|
|
|
- ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
- ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
+// ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+// ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
->leftJoin("supplier c", "c.code=po.supplierNo")
|
|
|
->where($where)
|
|
|
->order("a.addtime desc")
|
|
@@ -2312,22 +2320,26 @@ class SaleReportByRelaComNo 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,"" cgder,a.post_name,a.post_code,oa.contactor,oa.mobile,oa.addr,oa.addr_code,a.remark,b.order_type,po.supplierNo')
|
|
|
+ ->field('a.addtime,a.orderCode,a.sendtime,a.outCode,a.status,b.good_name,b.sale_price,a.send_num,a.apply_name,"" apply_company,"" cgder,a.post_name,a.post_code,oa.contactor,oa.mobile,oa.addr,oa.addr_code,a.remark,b.order_type,po.supplierNo,a.apply_id')
|
|
|
->leftJoin("sale b", "b.orderCode=a.orderCode")
|
|
|
->leftJoin("order_send os", "os.outCode=a.outCode")
|
|
|
->leftJoin("purchease_order po", "po.cgdNo=os.cgdNo")
|
|
|
->leftJoin("order_addr oa", "oa.id=a.addrid")
|
|
|
- ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
- ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
+// ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+// ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
// ->leftJoin("supplier c", "c.code=po.supplierNo")
|
|
|
->where($where)
|
|
|
->page($param['page'], $param['size'])
|
|
|
->order("a.addtime desc")
|
|
|
->cursor();
|
|
|
|
|
|
- $list = $tmp = [];
|
|
|
+ $list = $tmp = $tmp_company_name = [];
|
|
|
foreach ($data as $value) {
|
|
|
|
|
|
+ if (!isset($tmp_company_name[$value['apply_id']])) $tmp_company_name[$value['apply_id']] = get_company_name_by_uid($value['apply_id']);
|
|
|
+
|
|
|
+ $value['apply_company'] = $tmp_company_name[$value['apply_id']] ?? '';
|
|
|
+
|
|
|
$value['send_total_price'] = round($value['send_num'] * $value['sale_price'], 2);
|
|
|
|
|
|
$value['status'] = isset($this->order_out_status[$value['status']]) ? $this->order_out_status[$value['status']] : '';
|
|
@@ -2347,10 +2359,12 @@ class SaleReportByRelaComNo extends Base
|
|
|
$list[] = $value;
|
|
|
}
|
|
|
|
|
|
- $person = \app\admin\common\User::getIns()->handle('sGetList', ['more_code' => array_values($tmp), 'size' => count($tmp)]);
|
|
|
- $person = array_column($person['data']['list'], 'person', 'code');
|
|
|
- foreach ($list as &$value) {
|
|
|
- $value['cgder'] = $person[$value['supplierNo']] ?? '';
|
|
|
+ if ($tmp) {
|
|
|
+ $person = \app\admin\common\User::getIns()->handle('sGetList', ['more_code' => array_values($tmp), 'size' => count($tmp)]);
|
|
|
+ $person = array_column($person['data']['list'], 'person', 'code');
|
|
|
+ foreach ($list as &$value) {
|
|
|
+ $value['cgder'] = $person[$value['supplierNo']] ?? '';
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
unset($tmp);
|
|
@@ -2375,13 +2389,13 @@ class SaleReportByRelaComNo 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 部门,"" 采购员,a.post_name 快递公司,a.post_code 快递单号,oa.contactor 收货人,oa.mobile 收货电话,oa.addr 收货地址,oa.addr_code,a.remark 备注,b.order_type 订单类型,po.supplierNo')
|
|
|
+ ->field('a.addtime 下单日期,a.orderCode 订单编号,a.sendtime 发货时间,a.outCode 发货申请单号,a.status 发货申请单状态,b.good_name 商品名称,b.sale_price 产品单价,a.send_num 发货数量,"" 发货申请单总价,a.apply_name 申请人,"" 部门,"" 采购员,a.post_name 快递公司,a.post_code 快递单号,oa.contactor 收货人,oa.mobile 收货电话,oa.addr 收货地址,oa.addr_code,a.remark 备注,b.order_type 订单类型,po.supplierNo,a.apply_id')
|
|
|
->leftJoin("sale b", "b.orderCode=a.orderCode")
|
|
|
->leftJoin("order_send os", "os.outCode=a.outCode")
|
|
|
->leftJoin("purchease_order po", "po.cgdNo=os.cgdNo")
|
|
|
->leftJoin("order_addr oa", "oa.id=a.addrid")
|
|
|
- ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
- ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
+// ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+// ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
// ->leftJoin("supplier c", "c.code=po.supplierNo")
|
|
|
->where($where)
|
|
|
->order("a.addtime desc")
|
|
@@ -2390,6 +2404,10 @@ class SaleReportByRelaComNo extends Base
|
|
|
$list = $tmp = [];
|
|
|
foreach ($data as $value) {
|
|
|
|
|
|
+ if (!isset($tmp_company_name[$value['apply_id']])) $tmp_company_name[$value['apply_id']] = get_company_name_by_uid($value['apply_id']);
|
|
|
+
|
|
|
+ $value['部门'] = $tmp_company_name[$value['apply_id']] ?? '';
|
|
|
+
|
|
|
$value['发货申请单总价'] = round(bcmul($value['发货数量'], $value['产品单价'], 3), 2);
|
|
|
|
|
|
$value['发货申请单状态'] = isset($this->order_out_status[$value['发货申请单状态']]) ? $this->order_out_status[$value['发货申请单状态']] : '';
|
|
@@ -2407,15 +2425,18 @@ class SaleReportByRelaComNo extends Base
|
|
|
$value['业务公司编码'] = $this->relaComNo;
|
|
|
$value['业务公司名称'] = $this->relaComName;
|
|
|
unset($value['addr_code']);
|
|
|
- unset($value['supplierNo']);
|
|
|
+// unset($value['supplierNo']);
|
|
|
+ unset($value['apply_id']);
|
|
|
|
|
|
$list[] = $value;
|
|
|
}
|
|
|
|
|
|
- $person = \app\admin\common\User::getIns()->handle('sGetList', ['more_code' => array_values($tmp), 'size' => count($tmp)]);
|
|
|
- $person = array_column($person['data']['list'], 'person', 'code');
|
|
|
- foreach ($list as &$value) {
|
|
|
- $value['采购员'] = $person[$value['supplierNo']] ?? '';
|
|
|
+ if ($tmp) {
|
|
|
+ $person = \app\admin\common\User::getIns()->handle('sGetList', ['more_code' => array_values($tmp), 'size' => count($tmp)]);
|
|
|
+ $person = array_column($person['data']['list'], 'person', 'code');
|
|
|
+ foreach ($list as &$value) {
|
|
|
+ $value['采购员'] = $person[$value['supplierNo']] ?? '';
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
unset($tmp);
|
|
@@ -2556,21 +2577,21 @@ class SaleReportByRelaComNo extends Base
|
|
|
$param = $this->request->only(['token', 'apply_company' => '', 'start_day' => date('Y-m-01'), 'end_day' => date('Y-m-t')], 'post', 'trim');
|
|
|
|
|
|
$where = [['a.is_del', '=', 0], ['a.supplierNo', '=', $this->relaComNo]];
|
|
|
- if ($param['apply_company'] != '') $where[] = ['ci.name', 'like', '%' . $param['apply_company'] . '%'];
|
|
|
+// if ($param['apply_company'] != '') $where[] = ['ci.name', 'like', '%' . $param['apply_company'] . '%'];
|
|
|
if ($param['start_day'] != '' && $param['end_day'] != '') $where[] = ['a.addtime', 'between', [$param['start_day'] . ' 00:00:00', $param['end_day'] . ' 23:59:59']];
|
|
|
|
|
|
$data = Db::name('sale')
|
|
|
->alias('a')
|
|
|
- ->field('a.id,a.order_type,u.itemid,ci.name')
|
|
|
- ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
- ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
+ ->field('a.id,a.order_type,u.itemid,"" name,a.apply_id')
|
|
|
+// ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+// ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
->where($where)
|
|
|
->cursor();
|
|
|
$list = [];
|
|
|
$total = ['name' => '总计', 'tag_1' => 0, 'tag_2' => 0, 'tag_3' => 0, 'tag_total' => 0];
|
|
|
foreach ($data as $val) {
|
|
|
if (!isset($list[$val['itemid']])) $list[$val['itemid']] = [
|
|
|
- 'name' => $val['name'],
|
|
|
+ 'name' => get_company_name_by_uid($val['apply_id']),
|
|
|
'tag_1' => 0,
|
|
|
'tag_2' => 0,
|
|
|
'tag_3' => 0,
|
|
@@ -2597,20 +2618,20 @@ class SaleReportByRelaComNo extends Base
|
|
|
$param = $this->request->only(['token', 'apply_company' => '', 'start_day' => date('Y-m-01'), 'end_day' => date('Y-m-t')], 'post', 'trim');
|
|
|
|
|
|
$where = [['a.is_del', '=', 0], ['a.supplierNo', '=', $this->relaComNo]];
|
|
|
- if ($param['apply_company'] != '') $where[] = ['ci.name', 'like', '%' . $param['apply_company'] . '%'];
|
|
|
+// if ($param['apply_company'] != '') $where[] = ['ci.name', 'like', '%' . $param['apply_company'] . '%'];
|
|
|
if ($param['start_day'] != '' && $param['end_day'] != '') $where[] = ['a.addtime', 'between', [$param['start_day'] . ' 00:00:00', $param['end_day'] . ' 23:59:59']];
|
|
|
|
|
|
$data = Db::name('sale')
|
|
|
->alias('a')
|
|
|
- ->field('a.id,a.order_type,u.itemid,ci.name')
|
|
|
- ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
- ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
+ ->field('a.id,a.order_type,u.itemid,"" name,a.apply_id ')
|
|
|
+// ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
+// ->leftJoin("company_item ci", "ci.id=u.itemid")
|
|
|
->where($where)
|
|
|
->cursor();
|
|
|
$list = [];
|
|
|
$total = ['部门' => '总计', '库存品' => 0, '非库存品' => 0, '咨询采反' => 0, '总计' => 0];
|
|
|
foreach ($data as $k => $val) {
|
|
|
- if (!isset($list[$val['itemid']])) $list[$val['itemid']] = ['部门' => $val['name'], '库存品' => 0, '非库存品' => 0, '咨询采反' => 0, '总计' => 0, $value['业务公司编码'] = $this->relaComNo, $value['业务公司名称'] = $this->relaComName];
|
|
|
+ if (!isset($list[$val['itemid']])) $list[$val['itemid']] = ['部门' => get_company_name_by_uid($val['apply_id']), '库存品' => 0, '非库存品' => 0, '咨询采反' => 0, '总计' => 0, $value['业务公司编码'] = $this->relaComNo, $value['业务公司名称'] = $this->relaComName];
|
|
|
|
|
|
switch ($val['order_type']) {
|
|
|
case 1:
|