|
@@ -3,6 +3,7 @@ declare (strict_types=1);
|
|
|
|
|
|
namespace app\command;
|
|
namespace app\command;
|
|
|
|
|
|
|
|
+use app\admin\common\User;
|
|
use think\console\Command;
|
|
use think\console\Command;
|
|
use think\console\Input;
|
|
use think\console\Input;
|
|
use think\console\Output;
|
|
use think\console\Output;
|
|
@@ -136,9 +137,9 @@ class NowReportHandle extends Command
|
|
{
|
|
{
|
|
$data = Db::name('order_back')
|
|
$data = Db::name('order_back')
|
|
->alias('ob')
|
|
->alias('ob')
|
|
- ->field('ob.thNo 退货单号,ob.status 流程进度,ob.addtime 退货发起日期,"" 退货人所在部门,ob.apply_name 退货人,ob.return_num 退货数量,ob.total_fee 退货销售货款,ob.remark 退货备注,c.companyName 客户名称,ob.customer_code 客户编码,"" 一级组织,"" 二级组织,"" 三级组织,p.platform_name 平台名称,s.poNo PO编号,s.orderCode 确认单编号,s.order_type 确认单类型,s.addtime 确认单下单时间,"" 业务人员所在部门,ob.cgder 业务人员,s.good_code 确认单产品编号,ob.good_name 产品名称,s.skuCode 产品编码,"" 一级分类,0 售前记录总数,ob.apply_id,ob.cgderid,s.cat_id,c.itemid')
|
|
|
|
|
|
+ ->field('ob.thNo 退货单号,ob.status 流程进度,ob.addtime 退货发起日期,"" 退货人所在部门,ob.apply_name 退货人,ob.return_num 退货数量,ob.total_fee 退货销售货款,ob.remark 退货备注,"" 客户名称,ob.customer_code 客户编码,"" 一级组织,"" 二级组织,"" 三级组织,p.platform_name 平台名称,s.poNo PO编号,s.orderCode 确认单编号,s.order_type 确认单类型,s.addtime 确认单下单时间,"" 业务人员所在部门,ob.cgder 业务人员,s.good_code 确认单产品编号,ob.good_name 产品名称,s.skuCode 产品编码,"" 一级分类,0 售前记录总数,ob.apply_id,ob.cgderid,s.cat_id')
|
|
->leftJoin('sale s', 's.orderCode=ob.orderCode')
|
|
->leftJoin('sale s', 's.orderCode=ob.orderCode')
|
|
- ->leftJoin('customer_info c', 'c.companyNo=ob.customer_code AND c.is_del=0')
|
|
|
|
|
|
+// ->leftJoin('customer_info c', 'c.companyNo=ob.customer_code AND c.is_del=0')
|
|
->leftJoin('platform p', 'p.id=ob.platform_id')
|
|
->leftJoin('platform p', 'p.id=ob.platform_id')
|
|
->where(['ob.is_del' => 0, 'ob.status' => 4])
|
|
->where(['ob.is_del' => 0, 'ob.status' => 4])
|
|
->whereBetween('ob.addtime', [$start_date, $end_date])
|
|
->whereBetween('ob.addtime', [$start_date, $end_date])
|
|
@@ -147,10 +148,21 @@ class NowReportHandle extends Command
|
|
$all_status = [1 => '待业务审批', 2 => '待专员审批', 3 => '待主管审批', 4 => '退货完成', 5 => '业务驳回', 6 => '采购驳回', 7 => '专员审批不通过'];
|
|
$all_status = [1 => '待业务审批', 2 => '待专员审批', 3 => '待主管审批', 4 => '退货完成', 5 => '业务驳回', 6 => '采购驳回', 7 => '专员审批不通过'];
|
|
$all_order_type = [1 => '备库', 2 => '非库存', 3 => '咨询采反', 4 => '项目采反', 5 => '平台部订单库存品', 6 => '平台部订单非库存品'];
|
|
$all_order_type = [1 => '备库', 2 => '非库存', 3 => '咨询采反', 4 => '项目采反', 5 => '平台部订单库存品', 6 => '平台部订单非库存品'];
|
|
$list = [];
|
|
$list = [];
|
|
|
|
+
|
|
|
|
+ $tmp_customer=[];
|
|
|
|
+ $userCommon = new User();
|
|
foreach ($data as $value) {
|
|
foreach ($data as $value) {
|
|
|
|
|
|
$value['流程进度'] = isset($all_status[$value['流程进度']]) ? $all_status[$value['流程进度']] : '';
|
|
$value['流程进度'] = isset($all_status[$value['流程进度']]) ? $all_status[$value['流程进度']] : '';
|
|
|
|
|
|
|
|
+ if(!isset($tmp_customer[$value['customer_code']])) {
|
|
|
|
+ $temp = $userCommon->handle('cInfo',['companyNo'=>$value['customer_code']]);
|
|
|
|
+ $tmp_customer[$value['customer_code']]=['companyName'=>$temp['data']['companyName']??'','itemid'=>$temp['data']['itemid']??''];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $value['客户名称'] = $tmp_customer[$value['customer_code']]['companyName'];
|
|
|
|
+ $value['itemid'] = $tmp_customer[$value['customer_code']]['itemid'];
|
|
|
|
+
|
|
if (!empty($value['itemid'])) {
|
|
if (!empty($value['itemid'])) {
|
|
$customer_org1 = get_top_customer_org($value['itemid']);
|
|
$customer_org1 = get_top_customer_org($value['itemid']);
|
|
|
|
|
|
@@ -257,7 +269,7 @@ class NowReportHandle extends Command
|
|
->leftJoin('order_num won', 'won.orderCode=wtd.orderCode')
|
|
->leftJoin('order_num won', 'won.orderCode=wtd.orderCode')
|
|
->leftJoin('purchease_order wpo', 'wpo.cgdNo=won.cgdNo and wpo.is_del=0')
|
|
->leftJoin('purchease_order wpo', 'wpo.cgdNo=won.cgdNo and wpo.is_del=0')
|
|
->leftJoin('supplier wps', 'wps.code=wpo.supplierNo')
|
|
->leftJoin('supplier wps', 'wps.code=wpo.supplierNo')
|
|
- ->leftJoin('customer_info wci', 'wci.companyNo =ws.customer_code')
|
|
|
|
|
|
+// ->leftJoin('customer_info wci', 'wci.companyNo =ws.customer_code')
|
|
->whereBetween('wtd.addtime', [$start_date, $end_date])
|
|
->whereBetween('wtd.addtime', [$start_date, $end_date])
|
|
->field(" year(wtd.addtime) '年',
|
|
->field(" year(wtd.addtime) '年',
|
|
month(wtd.addtime) '月',
|
|
month(wtd.addtime) '月',
|
|
@@ -273,8 +285,6 @@ class NowReportHandle extends Command
|
|
ws.platform_id '平台类型',
|
|
ws.platform_id '平台类型',
|
|
ws.platform_order '平台订单号',
|
|
ws.platform_order '平台订单号',
|
|
'' as '客户属性',
|
|
'' as '客户属性',
|
|
- wci.itemid as '分公司',
|
|
|
|
- wci.companyName '客户名称',
|
|
|
|
wtd.spuCode '产品编码',
|
|
wtd.spuCode '产品编码',
|
|
'' as '财务核算码',
|
|
'' as '财务核算码',
|
|
'' as `一级分类`,
|
|
'' as `一级分类`,
|
|
@@ -303,11 +313,30 @@ class NowReportHandle extends Command
|
|
if(ws.is_stock=1,'是','否') '是否库存',
|
|
if(ws.is_stock=1,'是','否') '是否库存',
|
|
'' as '发货方式',
|
|
'' as '发货方式',
|
|
if(ifnull(wsr.is_th,wor.is_th)=0,'否','是') as '供应商是否同意退货',
|
|
if(ifnull(wsr.is_th,wor.is_th)=0,'否','是') as '供应商是否同意退货',
|
|
- if(wps.pay_type='0','现结',if(wps.pay_type='1','月结',if(wps.pay_type='2','双月结',wps.pay_type))) as '付款方式'
|
|
|
|
|
|
+ if(wps.pay_type='0','现结',if(wps.pay_type='1','月结',if(wps.pay_type='2','双月结',wps.pay_type))) as '付款方式',
|
|
|
|
+ ws.customer_code
|
|
")->order("wtd.addtime")->cursor();
|
|
")->order("wtd.addtime")->cursor();
|
|
|
|
|
|
|
|
+ $userCommon = new User();
|
|
|
|
+
|
|
|
|
+ $temp_customer = [];
|
|
|
|
+
|
|
$com = [];
|
|
$com = [];
|
|
foreach ($data as $value) {
|
|
foreach ($data as $value) {
|
|
|
|
+ // wci.itemid as '分公司',
|
|
|
|
+ // wci.companyName '客户名称',
|
|
|
|
+
|
|
|
|
+ if(!isset($temp_customer[$value['customer_code']])){
|
|
|
|
+ $tmp = $userCommon->handle('cInfo',['companyNo'=>$value['customer_code']]);
|
|
|
|
+ $temp_customer[$value['customer_code']] = [
|
|
|
|
+ '分公司'=>$tmp['data']['itemid']??'',
|
|
|
|
+ '客户名称'=>$tmp['data']['companyName']??'',
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $value['分公司'] = $temp_customer[$value['customer_code']]['分公司']??'';
|
|
|
|
+ $value['客户名称'] = $temp_customer[$value['customer_code']]['客户名称']??'';
|
|
|
|
+
|
|
$value['业务部门'] = get_company_name_by_uid(intval($value['业务部门']));
|
|
$value['业务部门'] = get_company_name_by_uid(intval($value['业务部门']));
|
|
$value['财务核算码']=Db::name("cat")->where(["id"=>$value['三级分类']])->value("fund_code",'');
|
|
$value['财务核算码']=Db::name("cat")->where(["id"=>$value['三级分类']])->value("fund_code",'');
|
|
$comp =get_top_customer_org($value['分公司']);
|
|
$comp =get_top_customer_org($value['分公司']);
|
|
@@ -334,6 +363,8 @@ class NowReportHandle extends Command
|
|
$value['单位']=isset($good['good_unit'])?Db::name("unit")->where(["id"=>$good['good_unit']])->value('unit',''):"";
|
|
$value['单位']=isset($good['good_unit'])?Db::name("unit")->where(["id"=>$good['good_unit']])->value('unit',''):"";
|
|
$value['税点']=isset($good['tax'])?$good['tax'].'%':"";
|
|
$value['税点']=isset($good['tax'])?$good['tax'].'%':"";
|
|
$value['平台类型']= Db::name("platform")->where(["id"=>$value['平台类型']])->value("platform_name",'');
|
|
$value['平台类型']= Db::name("platform")->where(["id"=>$value['平台类型']])->value("platform_name",'');
|
|
|
|
+
|
|
|
|
+ unset($value['customer_code']);
|
|
yield $com[] = $value;
|
|
yield $com[] = $value;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -609,9 +640,9 @@ class NowReportHandle extends Command
|
|
|
|
|
|
$data = Db::name('sale')
|
|
$data = Db::name('sale')
|
|
->alias('s')
|
|
->alias('s')
|
|
- ->field('s.addtime 确认单下单时间,s.orderCode 订单编号,s.order_type 订单类型,s.status 订单状态,s.apply_name 创建人,ci.name 部门,b.company 销售方公司,"" 一级组织,"" 二级组织,csi.companyName 购买方公司,p.platform_name 所属平台,s.platform_order 平台订单号,s.poNo 其他单号,s.paytime 承诺回款时间,ou.order_use 订单用途,"" 活动类型,s.good_name 产品名称,"" 一级分类,gb.tax 税率,s.sale_price 销售单价,s.good_num 下单数量,s.total_price 销售总额,po.cgder 采购人,gb.customized 工期时间,s.arrive_time 要求到货时间,s.remark 备注,s.is_stock 是否库存品,csi.itemid,s.cat_id,s.is_activity,s.good_type')
|
|
|
|
- ->leftJoin('customer_info csi', 'csi.companyNo=s.customer_code')
|
|
|
|
- ->leftJoin('business b', 'b.companyNo=s.supplierNo')
|
|
|
|
|
|
+ ->field('s.addtime 确认单下单时间,s.orderCode 订单编号,s.order_type 订单类型,s.status 订单状态,s.apply_name 创建人,ci.name 部门,"" 销售方公司,"" 一级组织,"" 二级组织,"" 购买方公司,p.platform_name 所属平台,s.platform_order 平台订单号,s.poNo 其他单号,s.paytime 承诺回款时间,ou.order_use 订单用途,"" 活动类型,s.good_name 产品名称,"" 一级分类,gb.tax 税率,s.sale_price 销售单价,s.good_num 下单数量,s.total_price 销售总额,po.cgder 采购人,gb.customized 工期时间,s.arrive_time 要求到货时间,s.remark 备注,s.is_stock 是否库存品,s.cat_id,s.is_activity,s.good_type,s.customer_code,s.supplierNo')
|
|
|
|
+// ->leftJoin('customer_info csi', 'csi.companyNo=s.customer_code')
|
|
|
|
+// ->leftJoin('business b', 'b.companyNo=s.supplierNo')
|
|
->leftJoin('platform p', 'p.id=s.platform_id')
|
|
->leftJoin('platform p', 'p.id=s.platform_id')
|
|
->leftJoin('good_basic gb', 'gb.spuCode=s.good_code')
|
|
->leftJoin('good_basic gb', 'gb.spuCode=s.good_code')
|
|
->leftJoin('order_use ou', 'ou.id=s.use_order')
|
|
->leftJoin('order_use ou', 'ou.id=s.use_order')
|
|
@@ -624,9 +655,26 @@ class NowReportHandle extends Command
|
|
->order('s.addtime', 'desc')
|
|
->order('s.addtime', 'desc')
|
|
->cursor();
|
|
->cursor();
|
|
|
|
|
|
- $list = [];
|
|
|
|
|
|
+ $list = $tmp_codes = $tmp_customer = [];
|
|
|
|
+
|
|
|
|
+ $userCommon = new User();
|
|
foreach ($data as $value) {
|
|
foreach ($data as $value) {
|
|
|
|
|
|
|
|
+ if(!isset($tmp_codes[$value['supplierNo']])) {
|
|
|
|
+ $names = $userCommon->handle('getCodeAndName',['code'=>$value['supplierNo']]);
|
|
|
|
+ $tmp_codes[$value['supplierNo']] = $names['data'][$value['supplierNo']]??'';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!isset($tmp_customer[$value['customer_code']])){
|
|
|
|
+ $tmp = $userCommon->handle('cInfo',['companyNo'=>$value['customer_code']]);
|
|
|
|
+ $tmp_customer[$value['customer_code']]=['itemid'=>$tmp['data']['itemid'],'companyName'=>$tmp['data']['companyName']];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $value['购买方公司'] = $tmp_customer[$value['customer_code']]['companyName'];
|
|
|
|
+ $value['itemid'] = $tmp_customer[$value['customer_code']]['itemid'];
|
|
|
|
+ $value['销售方公司'] = $tmp_codes[$value['supplierNo']];
|
|
|
|
+
|
|
|
|
+
|
|
$value['订单类型'] = isset($all_order_type[$value['订单类型']]) ? $all_order_type[$value['订单类型']] : '';
|
|
$value['订单类型'] = isset($all_order_type[$value['订单类型']]) ? $all_order_type[$value['订单类型']] : '';
|
|
$value['订单状态'] = isset($all_sale_status[$value['订单状态']]) ? $all_sale_status[$value['订单状态']] : '';
|
|
$value['订单状态'] = isset($all_sale_status[$value['订单状态']]) ? $all_sale_status[$value['订单状态']] : '';
|
|
|
|
|
|
@@ -649,6 +697,8 @@ class NowReportHandle extends Command
|
|
unset($value['cat_id']);
|
|
unset($value['cat_id']);
|
|
unset($value['is_activity']);
|
|
unset($value['is_activity']);
|
|
unset($value['good_type']);
|
|
unset($value['good_type']);
|
|
|
|
+ unset($value['customer_code']);
|
|
|
|
+ unset($value['supplierNo']);
|
|
|
|
|
|
yield $list[] = $value;
|
|
yield $list[] = $value;
|
|
}
|
|
}
|
|
@@ -1091,7 +1141,7 @@ class NowReportHandle extends Command
|
|
$value["商品分类"]=Db::name("cat")->where("id",$value["商品分类"])->value("cat_name",'');
|
|
$value["商品分类"]=Db::name("cat")->where("id",$value["商品分类"])->value("cat_name",'');
|
|
$value["反馈商品分类"]=Db::name("cat")->where("id",$value["反馈商品分类"])->value("cat_name",'');
|
|
$value["反馈商品分类"]=Db::name("cat")->where("id",$value["反馈商品分类"])->value("cat_name",'');
|
|
$value["反馈商品单位"]=Db::name("unit")->where("id",$value["反馈商品单位"])->value("unit",'');
|
|
$value["反馈商品单位"]=Db::name("unit")->where("id",$value["反馈商品单位"])->value("unit",'');
|
|
- $value["业务公司"]=Db::name("business")->where("companyNo",$value["业务公司"])->value("company","");
|
|
|
|
|
|
+ $value["业务公司"]=Db::connect('mysql_sys')->name("business")->where("companyNo",$value["业务公司"])->value("company","");
|
|
$value["所属平台"]=Db::name("platform")->where("id", $value["所属平台"])->value("platform_name","");
|
|
$value["所属平台"]=Db::name("platform")->where("id", $value["所属平台"])->value("platform_name","");
|
|
$value['申请人部门'] = Db::name("depart_user")->alias("a")->leftJoin("company_item ci", "a.itemid=ci.id")->where(["a.uid" => $value['申请人部门'], "a.status" => 1, "a.is_del" => 0])->value('ci.name', '');
|
|
$value['申请人部门'] = Db::name("depart_user")->alias("a")->leftJoin("company_item ci", "a.itemid=ci.id")->where(["a.uid" => $value['申请人部门'], "a.status" => 1, "a.is_del" => 0])->value('ci.name', '');
|
|
//状态 ;1招标进行中 2 招标已结束 3 等待议价结果 4.确认商品 5成功转单 6 取消转单 7 招标已暂
|
|
//状态 ;1招标进行中 2 招标已结束 3 等待议价结果 4.确认商品 5成功转单 6 取消转单 7 招标已暂
|
|
@@ -1105,7 +1155,7 @@ class NowReportHandle extends Command
|
|
$value["议价状态"]=$arr[$value["议价状态"]]??"";
|
|
$value["议价状态"]=$arr[$value["议价状态"]]??"";
|
|
$value['单位']=Db::name("unit")->where("id",$value['单位'])->value("unit",'');
|
|
$value['单位']=Db::name("unit")->where("id",$value['单位'])->value("unit",'');
|
|
$value['议价原因']=Db::name("result_info")->where("id",$value['议价原因'])->value("result_desc",'');
|
|
$value['议价原因']=Db::name("result_info")->where("id",$value['议价原因'])->value("result_desc",'');
|
|
- $value['客户名称']=Db::name("customer_info")->where("companyNo",$value['客户名称'])->value("companyName",'');
|
|
|
|
|
|
+ $value['客户名称']=Db::connect('mysql_sys')->name("customer_info")->where("companyNo",$value['客户名称'])->value("companyName",'');
|
|
yield $value;
|
|
yield $value;
|
|
}
|
|
}
|
|
}
|
|
}
|