|
@@ -1616,23 +1616,22 @@ class SaleReportByRelaComNo extends Base
|
|
|
{
|
|
|
$param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
|
|
|
|
|
|
- $where = [['thd.is_del', '=', 0], ['thd.th_type', 'in', [2, 3]], ['s.supplierNo', '=', $this->relaComNo]];
|
|
|
+ $where = [['thd.is_del', '=', 0], ['s.supplierNo', '=', $this->relaComNo]];
|
|
|
if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['thd.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
|
|
|
|
|
|
$count = Db::name('th_data')
|
|
|
->alias('thd')
|
|
|
->leftJoin('sale s', 's.orderCode=thd.orderCode')
|
|
|
-// ->leftJoin('customer_info c', 'c.companyNo=s.customer_code')
|
|
|
->where($where)
|
|
|
->order('thd.addtime', 'desc')
|
|
|
->count('thd.id');
|
|
|
|
|
|
$data = Db::name('th_data')
|
|
|
->alias('thd')
|
|
|
- ->field('thd.id,thd.th_type,thd.addtime return_time,thd.thCode,"" outCode,"" status,"" apply_name,"" apply_company,thd.orderCode,s.addtime,"" companyName,s.good_name,s.sale_price,s.wsend_num,s.th_num,s.th_fee,"" contactor,"" mobile,"" addr,"" result,s.customer_code')
|
|
|
+ ->field('thd.id,thd.th_type,thd.addtime return_time,thd.thCode,"" outCode,"" status,s.apply_name,s.apply_id apply_company,thd.orderCode,s.addtime,s.customerName companyName,s.good_name,s.sale_price,s.wsend_num,thd.th_num,thd.th_fee,"" contactor,"" mobile,"" addr,"" result')
|
|
|
->leftJoin('sale s', 's.orderCode=thd.orderCode')
|
|
|
-// ->leftJoin('customer_info c', 'c.companyNo=s.customer_code')
|
|
|
->where($where)
|
|
|
+ ->limit($param['page'],$param['size'])
|
|
|
->order('thd.addtime', 'desc')
|
|
|
->select()
|
|
|
->toArray();
|
|
@@ -1649,9 +1648,6 @@ class SaleReportByRelaComNo extends Base
|
|
|
->withAttr('status', function ($val) {
|
|
|
return isset($this->all_order_return_status[$val]) ? $this->all_order_return_status[$val] : '';
|
|
|
})
|
|
|
-// ->withAttr('apply_company', function ($val, $da) {
|
|
|
-// return get_company_name_by_uid($da['apply_id']);
|
|
|
-// })
|
|
|
->leftJoin('order_out oo', 'oo.outCode=or.outCode')
|
|
|
->leftJoin('order_addr oa', 'oa.id=oo.addrid')
|
|
|
->leftJoin('result_info ri', 'ri.result_code=or.error_code')
|
|
@@ -1667,9 +1663,6 @@ class SaleReportByRelaComNo extends Base
|
|
|
->withAttr('status', function ($val) {
|
|
|
return isset($this->order_back_status[$val]) ? $this->order_back_status[$val] : '';
|
|
|
})
|
|
|
-// ->withAttr('apply_company', function ($val, $da) {
|
|
|
-// return get_company_name_by_uid($da['apply_id']);
|
|
|
-// })
|
|
|
->leftJoin('order_out oo', 'oo.outCode=ob.outCode')
|
|
|
->leftJoin('order_addr oa', 'oa.id=oo.addrid')
|
|
|
->leftJoin('result_info ri', 'ri.result_code=ob.return_code')
|
|
@@ -1677,11 +1670,10 @@ class SaleReportByRelaComNo extends Base
|
|
|
|
|
|
$list = [];
|
|
|
|
|
|
- $all_uids = array_unique(array_merge(array_column($all_order_return, 'apply_id'), array_column($all_order_back, 'apply_id')));
|
|
|
- $all_company = get_company_name_by_uid($all_uids);
|
|
|
+ $all_uids = array_unique(array_merge(array_column($all_order_return, 'apply_id'), array_column
|
|
|
+ ($all_order_back, 'apply_id'), array_column($data, 'apply_company')));
|
|
|
+ $all_company = get_company_name_by_uid($all_uids);
|
|
|
|
|
|
- $userCommon = \app\admin\common\User::getIns();
|
|
|
- $names = $userCommon->handle('getCodeAndName', ['code' => array_column($data, 'customer_code')]);
|
|
|
foreach ($data as $value) {
|
|
|
if ($value['th_type'] == 2) {
|
|
|
$value['outCode'] = isset($all_order_return[$value['thCode']]['outCode']) ? $all_order_return[$value['thCode']]['outCode'] : '';
|
|
@@ -1701,11 +1693,15 @@ class SaleReportByRelaComNo extends Base
|
|
|
$value['mobile'] = isset($all_order_back[$value['thCode']]['mobile']) ? $all_order_back[$value['thCode']]['mobile'] : '';
|
|
|
$value['addr'] = isset($all_order_back[$value['thCode']]['addr']) ? $all_order_back[$value['thCode']]['addr'] : '';
|
|
|
$value['result'] = isset($all_order_back[$value['thCode']]['result']) ? $all_order_back[$value['thCode']]['result'] : '';
|
|
|
+ }else{
|
|
|
+ $value['apply_company'] = $all_company[$value['apply_company'] ?? 0] ?? '';
|
|
|
+ $value['status'] = $value['th_type']==1?"销售退货完成":"取消订单完成";
|
|
|
+ $value['result'] = $value['th_type']==1?"销售退货":"取消订单";
|
|
|
}
|
|
|
$value['relaComNo'] = $this->relaComNo;
|
|
|
$value['relaComName'] = $this->relaComName;
|
|
|
|
|
|
- $value['companyName'] = $names['data'][$value['customer_code']];
|
|
|
+// $value['companyName'] = $names['data'][$value['customer_code']];
|
|
|
|
|
|
$list[] = $value;
|
|
|
}
|
|
@@ -1722,12 +1718,12 @@ class SaleReportByRelaComNo extends Base
|
|
|
{
|
|
|
$param = $this->request->only(['token', 'start_date' => '', 'end_date' => ''], 'post', 'trim');
|
|
|
|
|
|
- $where = [['thd.is_del', '=', 0], ['thd.th_type', 'in', [2, 3]], ['s.supplierNo', '=', $this->relaComNo]];
|
|
|
+ $where = [['thd.is_del', '=', 0], ['s.supplierNo', '=', $this->relaComNo]];
|
|
|
if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['thd.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
|
|
|
|
|
|
$data = Db::name('th_data')
|
|
|
->alias('thd')
|
|
|
- ->field('thd.id,thd.th_type,thd.addtime 退货时间,thd.thCode 退货单号,"" 发货申请单编码,"" 退货单状态,"" 创建人,"" 部门,thd.orderCode 确认单编号,s.addtime 下单日期,"" 客户名称,s.good_name 产品名称,s.sale_price 单价,s.wsend_num 未发货数量,s.th_num 退货数量,s.th_fee 退货销售货款,"" 发货单联系人,"" 发货单联系人电话,"" 发货单地址,"" 退货原因,s.customer_code')
|
|
|
+ ->field('thd.id,thd.th_type,thd.addtime 退货时间,thd.thCode 退货单号,"" 发货申请单编码,"" 退货单状态,s.apply_name 创建人,s.apply_id 部门,thd.orderCode 确认单编号,s.addtime 下单日期,s.customerName 客户名称,s.good_name 产品名称,s.sale_price 单价,s.wsend_num 未发货数量,thd.th_num 退货数量,thd.th_fee 退货销售货款,"" 发货单联系人,"" 发货单联系人电话,"" 发货单地址,"" 退货原因')
|
|
|
->leftJoin('sale s', 's.orderCode=thd.orderCode')
|
|
|
// ->leftJoin('customer_info c', 'c.companyNo=s.customer_code')
|
|
|
->where($where)
|
|
@@ -1772,10 +1768,11 @@ class SaleReportByRelaComNo extends Base
|
|
|
->column('ob.id,ob.outCode 发货申请单编码,ob.status 退货单状态,ob.apply_id,ob.apply_name 创建人,"" 部门,oa.contactor 发货单联系人,oa.mobile 发货单联系人电话,oa.addr 发货单地址,ri.result 退货原因,oa.addr_code', 'thNo');
|
|
|
|
|
|
$list = [];
|
|
|
- $userCommon = \app\admin\common\User::getIns();
|
|
|
- $names = $userCommon->handle('getCodeAndName', ['code' => array_column($data, 'customer_code')]);
|
|
|
+// $userCommon = \app\admin\common\User::getIns();
|
|
|
+// $names = $userCommon->handle('getCodeAndName', ['code' => array_column($data, 'customer_code')]);
|
|
|
|
|
|
- $all_uids = array_unique(array_merge(array_column($all_order_return, 'apply_id'), array_column($all_order_back, 'apply_id')));
|
|
|
+ $all_uids = array_unique(array_merge(array_column($all_order_return, 'apply_id'), array_column
|
|
|
+ ($all_order_back, 'apply_id'), array_column($data, '部门')));
|
|
|
$all_company = get_company_name_by_uid($all_uids);
|
|
|
|
|
|
foreach ($data as $value) {
|
|
@@ -1797,9 +1794,13 @@ class SaleReportByRelaComNo extends Base
|
|
|
$value['发货单联系人电话'] = isset($all_order_back[$value['退货单号']]['发货单联系人电话']) ? $all_order_back[$value['退货单号']]['发货单联系人电话'] : '';
|
|
|
$value['发货单地址'] = isset($all_order_back[$value['退货单号']]['发货单地址']) ? $all_order_back[$value['退货单号']]['发货单地址'] : '';
|
|
|
$value['退货原因'] = isset($all_order_back[$value['退货单号']]['退货原因']) ? $all_order_back[$value['退货单号']]['退货原因'] : '';
|
|
|
+ }else{
|
|
|
+ $value['部门'] = $all_company[$value['部门'] ?? 0] ?? '';
|
|
|
+ $value['退货单状态'] = $value['th_type']==1?"销售退货完成":"取消订单完成";
|
|
|
+ $value['退货原因'] = $value['th_type']==1?"销售退货":"取消订单";
|
|
|
}
|
|
|
|
|
|
- $value['客户名称'] = $names['data'][$value['customer_code']];
|
|
|
+// $value['客户名称'] = $names['data'][$value['customer_code']];
|
|
|
|
|
|
$value['业务公司编码'] = $this->relaComNo;
|
|
|
$value['业务公司名称'] = $this->relaComName;
|