|
@@ -16,11 +16,11 @@ class SaleReport extends Base
|
|
|
private $is_custom = [0 => '否', 1 => '是'];//是否定制
|
|
|
private $consult_info_status = [1 => '招标进行中', 2 => '招标已结束', 3 => '等待议价结果', 4 => '确认商品', 5 => '成功转单', 6 => '取消转单', 7 => '招标已暂停'];//状态
|
|
|
private $noble_metal = [1 => '18K', 2 => '24K', 3 => '白银'];//贵金属种类
|
|
|
- private $is_act = [0 => '否', 1 => '是'];//是否接受工差
|
|
|
private $all_order_return_status = [1 => '待业务审核', 2 => '待采购审核', 3 => '待设置仓库', 4 => '待客户退货', 5 => '售后已完成', 6 => '业务已驳回', 7 => '采购已驳回', 8 => '申请已取消'];
|
|
|
private $is_activity = [0 => '不参与活动', 1 => '参与活动'];
|
|
|
private $good_type = [1 => '正常商品', 2 => '赠品', 3 => '样品'];
|
|
|
private $sale_diff_status = [1 => '修改销售额', 2 => '不修改销售额'];
|
|
|
+ private $is_receive = [0 => '未收到', 1 => '收到'];
|
|
|
|
|
|
|
|
|
//【一、管理报表】1.日报_列表
|
|
@@ -771,6 +771,7 @@ class SaleReport extends Base
|
|
|
//【二、订单导出表】
|
|
|
public function saleDetailed()
|
|
|
{
|
|
|
+
|
|
|
$param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'status' => '', 'create_company' => '', 'company' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
|
|
|
|
|
|
$where = [['s.is_del', '=', 0]];
|
|
@@ -1061,7 +1062,6 @@ class SaleReport extends Base
|
|
|
|
|
|
return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//【四、工差明细表】
|
|
@@ -1103,42 +1103,185 @@ class SaleReport extends Base
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //【五、退货明细表】
|
|
|
+ public function thData()
|
|
|
+ {
|
|
|
+ $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'status' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
|
|
|
+
|
|
|
+ $where = [['thd.is_del', '=', 0]];
|
|
|
+ if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['thd.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
|
|
|
+ if ($param['status'] != '') $where[] = ['or.status', '=', $param['status']];
|
|
|
+
|
|
|
+ $count = Db::name('th_data')
|
|
|
+ ->alias('thd')
|
|
|
+ ->leftJoin('order_out oo', 'oo.orderCode=thd.orderCode')
|
|
|
+ ->leftJoin('order_addr oa', 'oa.id=oo.addrid')
|
|
|
+ ->leftJoin('order_return or', 'or.returnCode=thd.thCode')
|
|
|
+ ->leftJoin('sale s', 's.orderCode=thd.orderCode')
|
|
|
+ ->leftJoin('customer_info c', 'c.companyNo=s.customer_code')
|
|
|
+ ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
|
|
|
+ ->where($where)
|
|
|
+ ->count('thd.id');
|
|
|
+
|
|
|
+ $data = Db::name('th_data')
|
|
|
+ ->alias('thd')
|
|
|
+ ->field('thd.addtime return_time,thd.thCode,oo.outCode,or.status,thd.apply_name,thd.apply_id,thd.orderCode,s.addtime,c.companyName,s.good_name,s.sale_price,s.wsend_num,s.th_num,s.th_fee,oa.contactor,oa.mobile,oa.addr,oa.addr_code,ri.result_desc')
|
|
|
+ ->leftJoin('order_out oo', 'oo.orderCode=thd.orderCode')
|
|
|
+ ->leftJoin('order_addr oa', 'oa.id=oo.addrid')
|
|
|
+ ->leftJoin('order_return or', 'or.returnCode=thd.thCode')
|
|
|
+ ->leftJoin('sale s', 's.orderCode=thd.orderCode')
|
|
|
+ ->leftJoin('customer_info c', 'c.companyNo=s.customer_code')
|
|
|
+ ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
|
|
|
+ ->where($where)
|
|
|
+ ->page($param['page'], $param['size'])
|
|
|
+ ->order('thd.addtime', 'desc')
|
|
|
+ ->cursor();
|
|
|
+
|
|
|
+ $list = [];
|
|
|
+
|
|
|
+ foreach ($data as $value) {
|
|
|
+ $value['status'] = isset($this->all_order_return_status[$value['status']]) ? $this->all_order_return_status[$value['status']] : '';
|
|
|
+ $value['apply_company'] = get_company_name_by_uid($value['apply_id']);
|
|
|
+ $list[] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//【五、退货明细表】
|
|
|
public function thDataExport()
|
|
|
{
|
|
|
- $param = $this->request->only(['token', 'start_date' => '', 'end_date' => ''], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'status' => ''], 'post', 'trim');
|
|
|
|
|
|
- $where = [['pd.is_del', '=', 0]];
|
|
|
- if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['pd.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
|
|
|
+ $where = [['thd.is_del', '=', 0]];
|
|
|
+ if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['thd.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
|
|
|
+ if ($param['status'] != '') $where[] = ['or.status', '=', $param['status']];
|
|
|
|
|
|
$data = Db::name('th_data')
|
|
|
- ->alias('pd')
|
|
|
- ->field('pd.addtime 退货时间,pd. 退货单号')
|
|
|
-// ->field('pd.addtime 发起时间,sd.diffCode 工差单号,sd.orderCode 关联确认单,pd.apply_name 创建人,"" 部门,pd.apply_id,po.addtime 确认单下单日期,pd.good_name 产品名称,b.company 客户名称,gb.noble_metal 贵金属种类,pd.good_num 下单数量,pd.sale_price 单价,"" 总额,pd.good_weight 商品总重量,pd.diff_weight 工差重量,pd.diff_price 销售工差总费用,sd.is_act 是否修改销售额')
|
|
|
- ->leftJoin('sale_diff sd', 'sd.cgd_diffid=pd.id')
|
|
|
- ->leftJoin('purchease_order po', 'po.cgdNo=pd.cgdNo')
|
|
|
- ->leftJoin('business b', 'b.companyNo=po.companyNo')
|
|
|
- ->leftJoin('good_basic gb', 'gb.spuCode=po.spuCode')
|
|
|
+ ->alias('thd')
|
|
|
+ ->field('thd.addtime 退货时间,thd.thCode 退货单号,oo.outCode 发货申请单编码,or.status 退货单状态,thd.apply_name 创建人,thd.apply_id,"" 部门,thd.orderCode 确认单编号,s.addtime 下单日期,c.companyName 客户名称,s.good_name 产品名称,s.sale_price 单价,s.wsend_num 未发货数量,s.th_num 退货数量,s.th_fee 退货销售货款,oa.contactor 发货单联系人,oa.mobile 发货单联系人电话,oa.addr 发货单地址,oa.addr_code,ri.result_desc 退货原因')
|
|
|
+ ->leftJoin('order_out oo', 'oo.orderCode=thd.orderCode')
|
|
|
+ ->leftJoin('order_addr oa', 'oa.id=oo.addrid')
|
|
|
+ ->leftJoin('order_return or', 'or.returnCode=thd.thCode')
|
|
|
+ ->leftJoin('sale s', 's.orderCode=thd.orderCode')
|
|
|
+ ->leftJoin('customer_info c', 'c.companyNo=s.customer_code')
|
|
|
+ ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
|
|
|
->where($where)
|
|
|
- ->order('pd.addtime', 'desc')
|
|
|
+ ->order('thd.addtime', 'desc')
|
|
|
->cursor();
|
|
|
|
|
|
$list = [];
|
|
|
|
|
|
foreach ($data as $value) {
|
|
|
|
|
|
+ $value['退货单状态'] = isset($this->all_order_return_status[$value['退货单状态']]) ? $this->all_order_return_status[$value['退货单状态']] : '';
|
|
|
$value['部门'] = get_company_name_by_uid($value['apply_id']);
|
|
|
- $value['贵金属种类'] = isset($this->noble_metal[$value['贵金属种类']]) ? $this->noble_metal[$value['贵金属种类']] : '';
|
|
|
- $value['总额'] = round($value['单价'], $value['下单数量'], 2);
|
|
|
- $value['是否修改销售额'] = isset($this->is_act[$value['是否修改销售额']]) ? $this->is_act[$value['是否修改销售额']] : '';
|
|
|
+ //addr_code//要转编码吗?
|
|
|
+ unset($value['apply_id']);
|
|
|
+ unset($value['addr_code']);
|
|
|
+
|
|
|
+ $list[] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (empty($list)) $list[] = '没有相关可导出的数据';
|
|
|
+ excelSave('退货明细表' . date('YmdHis'), array_keys($list[0]), $list);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //【六、售后明细表】
|
|
|
+ public function orderReturnDetailed()
|
|
|
+ {
|
|
|
+ $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'status' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
|
|
|
+
|
|
|
+ $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']];
|
|
|
+ if ($param['status'] != '') $where[] = ['or.status', '=', $param['status']];
|
|
|
+
|
|
|
+ $count = Db::name('order_return')
|
|
|
+ ->alias('or')
|
|
|
+ ->leftJoin('customer_info c', 'c.companyNo=or.customer_code')
|
|
|
+ ->leftJoin('sale s', 's.orderCode=or.orderCode')
|
|
|
+ ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
|
|
|
+ ->where($where)
|
|
|
+ ->order('or.addtime', 'desc')
|
|
|
+ ->count('or.id');
|
|
|
+
|
|
|
+ $data = Db::name('order_return')
|
|
|
+ ->alias('or')
|
|
|
+ ->field('or.addtime,or.returnCode,or.apply_name,or.apply_id,or.outCode,or.total_num,or.status,or.orderCode,c.companyName,or.good_name,s.sale_price,or.is_receive,or.error_num,ri.result_desc,or.error_remark,or.except_code,c.itemid')
|
|
|
+ ->leftJoin('customer_info c', 'c.companyNo=or.customer_code')
|
|
|
+ ->leftJoin('sale s', 's.orderCode=or.orderCode')
|
|
|
+ ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
|
|
|
+ ->where($where)
|
|
|
+ ->page($param['page'], $param['size'])
|
|
|
+ ->order('or.addtime', 'desc')
|
|
|
+ ->cursor();
|
|
|
+
|
|
|
+ $list = [];
|
|
|
+
|
|
|
+ foreach ($data as $value) {
|
|
|
+
|
|
|
+ $value['status'] = isset($this->all_order_return_status[$value['status']]) ? $this->all_order_return_status[$value['status']] : '';
|
|
|
+ $value['is_receive'] = isset($this->is_receive[$value['is_receive']]) ? $this->is_receive[$value['is_receive']] : '';
|
|
|
+ $value['apply_company'] = get_company_name_by_uid($value['apply_id']);
|
|
|
+ $value['error_total_price'] = round($value['error_num'] * $value['sale_price'], 2);
|
|
|
+ if (!empty($value['itemid'])) {
|
|
|
+ $customer_org1 = array_column(get_top_customer_org($value['itemid']), 'name', 'level');
|
|
|
+ $value['first_customer_org'] = isset($customer_org1[1]) ? $customer_org1[1] : '';
|
|
|
+ $value['second_customer_org'] = isset($customer_org1[2]) ? $customer_org1[2] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+ $list[] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //【六、售后明细表】
|
|
|
+ public function orderReturnDetailedExport()
|
|
|
+ {
|
|
|
+ $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'status' => ''], 'post', 'trim');
|
|
|
+
|
|
|
+ $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']];
|
|
|
+ if ($param['status'] != '') $where[] = ['or.status', '=', $param['status']];
|
|
|
+
|
|
|
+ $data = Db::name('order_return')
|
|
|
+ ->alias('or')
|
|
|
+ ->field('or.addtime 售后时间,or.returnCode 售后申请编号,or.apply_name 申请人,or.apply_id,"" 部门,or.outCode 发货申请编号,or.total_num 发货数量,or.status 处理状态,or.orderCode 订单号,"" 一级组织,"" 二级组织,c.companyName 客户名称,or.good_name 商品名称,s.sale_price 销售单价,"" 异常金额,or.is_receive 收货情况,or.error_num 异常数量,ri.result_desc 异常原因,or.error_remark 异常备注,or.except_code 期望意愿,c.itemid')
|
|
|
+ ->leftJoin('customer_info c', 'c.companyNo=or.customer_code')
|
|
|
+ ->leftJoin('sale s', 's.orderCode=or.orderCode')
|
|
|
+ ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
|
|
|
+ ->where($where)
|
|
|
+ ->order('or.addtime', 'desc')
|
|
|
+ ->cursor();
|
|
|
+
|
|
|
+ $list = [];
|
|
|
+
|
|
|
+ foreach ($data as $value) {
|
|
|
+
|
|
|
+ $value['处理状态'] = isset($this->all_order_return_status[$value['处理状态']]) ? $this->all_order_return_status[$value['处理状态']] : '';
|
|
|
+ $value['收货情况'] = isset($this->is_receive[$value['收货情况']]) ? $this->is_receive[$value['收货情况']] : '';
|
|
|
+ $value['部门'] = get_company_name_by_uid($value['apply_id']);
|
|
|
+ $value['异常金额'] = round($value['异常数量'] * $value['销售单价'], 2);
|
|
|
+ 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] : '';
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
unset($value['apply_id']);
|
|
|
+ unset($value['itemid']);
|
|
|
|
|
|
$list[] = $value;
|
|
|
}
|
|
|
|
|
|
if (empty($list)) $list[] = '没有相关可导出的数据';
|
|
|
- excelSave('工差明细表' . date('YmdHis'), array_keys($list[0]), $list);
|
|
|
+ excelSave('售后明细表' . date('YmdHis'), array_keys($list[0]), $list);
|
|
|
|
|
|
}
|
|
|
|