|
@@ -26,14 +26,11 @@ class handleCxData extends command
|
|
|
{
|
|
|
|
|
|
$date = date('Y-m-d H:i:s');
|
|
|
- $goodset =Cache::store("redis")->get("JsHandle");
|
|
|
+ $goodset =Cache::store('redis')->get('JsHandle');
|
|
|
if($goodset ==1) return;
|
|
|
- Cache::store("redis")->set("JsHandle",1,180);
|
|
|
+ Cache::store('redis')->set('JsHandle',1,180);
|
|
|
Db::startTrans();
|
|
|
$results = Db::name('caixiao_data')
|
|
|
- ->withAttr("data",function ($v){
|
|
|
- return json_decode(str_replace(array("\r\n", "\r", "\n","\\"), '', $v),true);
|
|
|
- })
|
|
|
->where("status",1)
|
|
|
->where("addtime",">=",date("Y-m-d H:i:s",time()-1800))
|
|
|
->lock(true)
|
|
@@ -42,24 +39,33 @@ class handleCxData extends command
|
|
|
if ($results) {
|
|
|
try {
|
|
|
foreach ($results as $result) {
|
|
|
- $data=$result['data'] ?? [];
|
|
|
+ $dataStr=$result['data'] ?$this->checkData($result['data']): '';
|
|
|
+ if($dataStr==''){
|
|
|
+ $output->writeln("[$date]:{$result['id']}数据解析失败");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $data=json_decode($dataStr,true);
|
|
|
+ if(is_null($data)){
|
|
|
+ $output->writeln("[$date]:{$result['id']}数据解析失败");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
$qrd_insert_data=$wait_insert_data=$cgd_insert_data=[];
|
|
|
$data['cat_name']=is_array($data['cat_name']) ? $data['cat_name'] : json_decode($data['cat_name'],true);
|
|
|
if ($result['order_type'] == 1) {
|
|
|
$data['total_price']=$data['total_price'] - $data['th_fee'] - $data['diff_fee'];
|
|
|
- $exitReport=Db::name("report_code")->where('qrdNo' , $data['orderCode'])->findOrEmpty();
|
|
|
+ $exitReport=Db::name('report_code')->where('qrdNo' , $data['orderCode'])->findOrEmpty();
|
|
|
$repostinsert=[
|
|
|
- "qrdNo"=>$data['orderCode'] ,
|
|
|
- "seller_id"=>$data['apply_id'] ,
|
|
|
- "seller"=>$data['apply_name'] ,
|
|
|
- "customerName"=>$data['customer_name'] ,
|
|
|
- "customerNo"=>$data['customer_code'] ,
|
|
|
- "companyNo"=>$data['supplierNo'] ,
|
|
|
- "companyName"=>$data['supplier_name'] ,
|
|
|
- "cgdNo"=>$data['cgdNo'] ,
|
|
|
+ 'qrdNo'=>$data['orderCode'] ,
|
|
|
+ 'seller_id'=>$data['apply_id'] ,
|
|
|
+ 'seller'=>$data['apply_name'] ,
|
|
|
+ 'customerName'=>$data['customer_name'] ,
|
|
|
+ 'customerNo'=>$data['customer_code'] ,
|
|
|
+ 'companyNo'=>$data['supplierNo'] ,
|
|
|
+ 'companyName'=>$data['supplier_name'] ,
|
|
|
+ 'cgdNo'=>$data['cgdNo'] ,
|
|
|
];
|
|
|
- if (empty($exitReport)) Db::name("report_code")->insert($repostinsert);
|
|
|
- else Db::name("report_code")->where($exitReport)->update($repostinsert);
|
|
|
+ if (empty($exitReport)) Db::name('report_code')->insert($repostinsert);
|
|
|
+ else Db::name('report_code')->where($exitReport)->update($repostinsert);
|
|
|
$exists_qrd=Db::name('qrd_info')
|
|
|
->whereIn('sequenceNo' , $data['orderCode'])
|
|
|
->field('id,status')->findOrEmpty();
|
|
@@ -70,14 +76,14 @@ class handleCxData extends command
|
|
|
if (!empty($exists_qrd)) {
|
|
|
if ($exists_qrd['status'] == 0) {
|
|
|
$report=[
|
|
|
- "qrdNo"=>$data['orderCode'] ,
|
|
|
- "seller_id"=>$data['apply_id'] ,
|
|
|
- "seller"=>$data['apply_name'] ,
|
|
|
- "customerName"=>$data['customer_name'] ,
|
|
|
- "customerNo"=>$data['customer_code'] ,
|
|
|
- "companyNo"=>$data['supplierNo'] ,
|
|
|
- "companyName"=>$data['supplier_name'] ,
|
|
|
- "cgdNo"=>$data['cgdNo'] ,
|
|
|
+ 'qrdNo'=>$data['orderCode'] ,
|
|
|
+ 'seller_id'=>$data['apply_id'] ,
|
|
|
+ 'seller'=>$data['apply_name'] ,
|
|
|
+ 'customerName'=>$data['customer_name'] ,
|
|
|
+ 'customerNo'=>$data['customer_code'] ,
|
|
|
+ 'companyNo'=>$data['supplierNo'] ,
|
|
|
+ 'companyName'=>$data['supplier_name'] ,
|
|
|
+ 'cgdNo'=>$data['cgdNo'] ,
|
|
|
];
|
|
|
$re=Db::name('qrd_info')
|
|
|
->where('id' , $exists_qrd['id'])
|
|
@@ -87,7 +93,7 @@ class handleCxData extends command
|
|
|
'ownerName'=>$data['apply_name'] ,//销售员,
|
|
|
'ownerid'=>$data['apply_id'] ,//销售员id,
|
|
|
'department'=>$data['depart'] ,//部门,
|
|
|
- 'manager'=>$data['manager']??"",
|
|
|
+ 'manager'=>$data['manager']??'',
|
|
|
'managerid'=>$data['managerid']??0,
|
|
|
'createdTime'=>$data['addtime'] ,//销售单创建时间,
|
|
|
'qrdType'=>$data['order_type'] ,//销售单类型,
|
|
@@ -105,10 +111,11 @@ class handleCxData extends command
|
|
|
'goodName'=>$data['good_name'] ,//商品名称,
|
|
|
'goodBrand'=>$data['brand'] ,//商品品牌,
|
|
|
'firstCat'=>$data['cat_name'][0]['cat_name'] ?? "" ,//一级分类,
|
|
|
- 'secCat'=>$data['cat_name'][1]['cat_name'] ?? "" ,//二级分类,
|
|
|
- 'thirdCat'=>$data['cat_name'][2]['cat_name'] ?? "" ,//三级分类,
|
|
|
+ 'secCat'=>!isset($data['cat_name'][1]) ? '' : $data['cat_name'][1]['cat_name'] ,//二级分类,
|
|
|
+ 'thirdCat'=>!isset($data['cat_name'][2]) ? '' : $data['cat_name'][2]['cat_name'] ,
|
|
|
+ //三级分类,
|
|
|
'catInfo'=>json_encode($data['cat_name'] , JSON_UNESCAPED_UNICODE) ,//分类详情,
|
|
|
- 'fundCode'=>$data['cat_name'][2]['fund_code'] ?? "" ,//核算编码,
|
|
|
+ 'fundCode'=>isset($data['cat_name'][2]) ? $data['cat_name'][2]['fund_code'] : '',//核算编码,
|
|
|
'goodMaterial'=>'' ,//商品材质,
|
|
|
'goodUnit'=>$data['unit'] ,//商品单位,
|
|
|
'goodDesc'=>$data['cost_desc'] ,//工艺说明,
|
|
@@ -139,8 +146,8 @@ class handleCxData extends command
|
|
|
'sendStatus'=>$data['send_status'] ,//发货状态,
|
|
|
'pay_status'=>$data['total_price'] == 0 ? 3 : 1 ,//收款状态,1未付,2部分,3完结
|
|
|
'inv_status'=>$data['total_price'] == 0 ? 3 : 1 ,//开票状态,,1未付,2部分,3完结
|
|
|
- 'remark'=>"" ,//备注,
|
|
|
- 'cxCode'=>$data['oldCode'] ?? "" ,//备注,
|
|
|
+ 'remark'=>'' ,//备注,
|
|
|
+ 'cxCode'=>$data['oldCode'] ?? '' ,//备注,
|
|
|
'diff_weight'=>$data['diff_weight'] ,//工差重量,
|
|
|
'diff_fee'=>$data['diff_fee'] ,//工差金额,
|
|
|
'area'=>$data['customer_name'] ,//公司,
|
|
@@ -149,7 +156,7 @@ class handleCxData extends command
|
|
|
'cgdNo'=>$data['cgdNo'] ,//采购单号,
|
|
|
'thNum'=>$data['th_num'] ,//退货数量,
|
|
|
'th_fee'=>$data['th_fee'] ,//退货金额,
|
|
|
- 'pay_source'=>$data['pay_source'] ?? "" ,//支付渠道,
|
|
|
+ 'pay_source'=>$data['pay_source'] ?? '' ,//支付渠道,
|
|
|
'is_del'=>0 ,//是否删除,
|
|
|
'addtime'=>$date ,
|
|
|
'updatetime'=>$date ,
|
|
@@ -164,10 +171,10 @@ class handleCxData extends command
|
|
|
}
|
|
|
else {
|
|
|
$wait_insert_data=[
|
|
|
- "order_type"=>$result['order_type'] ,
|
|
|
- "data"=>json_encode($result['data'] , JSON_UNESCAPED_UNICODE) ,
|
|
|
- "orderCode"=>$data['orderCode'] ,
|
|
|
- "status"=>1 ,
|
|
|
+ 'order_type'=>$result['order_type'] ,
|
|
|
+ 'data'=>json_encode($result['data'] , JSON_UNESCAPED_UNICODE) ,
|
|
|
+ 'orderCode'=>$data['orderCode'] ,
|
|
|
+ 'status'=>1 ,
|
|
|
];
|
|
|
$re=Db::name('qrd_info')
|
|
|
->where('id' , $exists_qrd['id'])
|
|
@@ -197,11 +204,11 @@ class handleCxData extends command
|
|
|
'wsendNum'=>$data['wsend_num'] ,//未发货数量,
|
|
|
'sendType'=>$data['send_type'] ,//发货方式
|
|
|
'sendStatus'=>$data['send_status'] ,//发货状态,
|
|
|
- 'remark'=>"" ,//备注,
|
|
|
+ 'remark'=>'' ,//备注,
|
|
|
'area'=>$data['customer_name'] ,//公司,
|
|
|
'customerAttr'=>$all_branch[$data['customer_code']]['parent'] ?? '' ,//客户属性,
|
|
|
'branch'=>$all_branch[$data['customer_code']]['branch'] ?? '' ,//分公司,从客户表中查
|
|
|
- 'pay_source'=>$data['pay_source'] ?? "" ,//支付渠道,
|
|
|
+ 'pay_source'=>$data['pay_source'] ?? '' ,//支付渠道,
|
|
|
'updatetime'=>$date
|
|
|
]
|
|
|
);
|
|
@@ -233,10 +240,11 @@ class handleCxData extends command
|
|
|
'goodName'=>$data['good_name'] ,//商品名称,
|
|
|
'goodBrand'=>$data['brand'] ,//商品品牌,
|
|
|
'firstCat'=>$data['cat_name'][0]['cat_name'] ?? "" ,//一级分类,
|
|
|
- 'secCat'=>$data['cat_name'][1]['cat_name'] ?? "" ,//二级分类,
|
|
|
- 'thirdCat'=>$data['cat_name'][2]['cat_name'] ?? "" ,//三级分类,
|
|
|
+ 'secCat'=>!isset($data['cat_name'][1]) ? '' : $data['cat_name'][1]['cat_name'] ,//二级分类,
|
|
|
+ 'thirdCat'=>!isset($data['cat_name'][2]) ? '' : $data['cat_name'][2]['cat_name'] ,
|
|
|
+ //三级分类,
|
|
|
'catInfo'=>json_encode($data['cat_name'] , JSON_UNESCAPED_UNICODE) ,//分类详情,
|
|
|
- 'fundCode'=>$data['cat_name'][2]['fund_code'] ?? "" ,//核算编码,
|
|
|
+ 'fundCode'=>isset($data['cat_name'][2]) ? $data['cat_name'][2]['fund_code'] : '',
|
|
|
'goodMaterial'=>'' ,//商品材质,
|
|
|
'goodUnit'=>$data['unit'] ,//商品单位,
|
|
|
'goodDesc'=>$data['cost_desc'] ,//工艺说明,
|
|
@@ -267,8 +275,8 @@ class handleCxData extends command
|
|
|
'sendStatus'=>$data['send_status'] ,//发货状态,
|
|
|
'pay_status'=>$data['total_price'] == 0 ? 3 : 1 ,//收款状态,1未付,2部分,3完结
|
|
|
'inv_status'=>$data['total_price'] == 0 ? 3 : 1 ,//开票状态,,1未付,2部分,3完结
|
|
|
- 'remark'=>"" ,//备注,
|
|
|
- 'cxCode'=>$data['oldCode'] ?? "" ,//备注,
|
|
|
+ 'remark'=>'' ,//备注,
|
|
|
+ 'cxCode'=>$data['oldCode'] ?? '' ,//备注,
|
|
|
'diff_weight'=>$data['diff_weight'] ,//工差重量,
|
|
|
'diff_fee'=>$data['diff_fee'] ,//工差金额,
|
|
|
'area'=>$data['customer_name'] ,//公司,
|
|
@@ -277,7 +285,7 @@ class handleCxData extends command
|
|
|
'cgdNo'=>$data['cgdNo'] ,//采购单号,
|
|
|
'thNum'=>$data['th_num'] ,//退货数量,
|
|
|
'th_fee'=>$data['th_fee'] ,//退货金额,
|
|
|
- 'pay_source'=>$data['pay_source'] ?? "" ,//支付渠道,
|
|
|
+ 'pay_source'=>$data['pay_source'] ?? '' ,//支付渠道,
|
|
|
'is_del'=>0 ,//是否删除,
|
|
|
'addtime'=>$date ,
|
|
|
'updatetime'=>$date ,
|
|
@@ -296,24 +304,24 @@ class handleCxData extends command
|
|
|
} else {
|
|
|
//已存在
|
|
|
$data['total_fee']=$data['total_fee'] - $data['th_fee'] - $data['diff_fee'];
|
|
|
- $exitReport=Db::name("report_code")->where('cgdNo' , $data['cgdNo'])->findOrEmpty();
|
|
|
+ $exitReport=Db::name('report_code')->where('cgdNo' , $data['cgdNo'])->findOrEmpty();
|
|
|
$repostinsert=[
|
|
|
- "qrdNo"=>$data['qrdNo'] ,
|
|
|
- "cgder_id"=>$data['cgder_id'] ,
|
|
|
- "cgder"=>$data['cgder'] ,
|
|
|
- "supplierName"=>$data['supplier_name'] ,
|
|
|
- "supplierNo"=>$data['supplierNo'] ,
|
|
|
- "companyNo"=>$data['companyNo'] ,
|
|
|
- "companyName"=>$data['companyName'] ,
|
|
|
- "cgdNo"=>$data['cgdNo'] ,
|
|
|
+ 'qrdNo'=>$data['qrdNo'] ,
|
|
|
+ 'cgder_id'=>$data['cgder_id'] ,
|
|
|
+ 'cgder'=>$data['cgder'] ,
|
|
|
+ 'supplierName'=>$data['supplier_name'] ,
|
|
|
+ 'supplierNo'=>$data['supplierNo'] ,
|
|
|
+ 'companyNo'=>$data['companyNo'] ,
|
|
|
+ 'companyName'=>$data['companyName'] ,
|
|
|
+ 'cgdNo'=>$data['cgdNo'] ,
|
|
|
];
|
|
|
- if (empty($exitReport)) Db::name("report_code")->insert($repostinsert);
|
|
|
- else Db::name("report_code")->where($exitReport)->update($repostinsert);
|
|
|
+ if (empty($exitReport)) Db::name('report_code')->insert($repostinsert);
|
|
|
+ else Db::name('report_code')->where($exitReport)->update($repostinsert);
|
|
|
$exists_cgd=Db::name('cgd_info')
|
|
|
->whereIn('sequenceNo' , $data['cgdNo'])
|
|
|
->field('id,status')->findOrEmpty();
|
|
|
- $data['qrdSend'] = Db::name("qrd_info")->where(["cgdNo"=>$data['cgdNo']])->value
|
|
|
- ("sendStatus",1);
|
|
|
+ $data['qrdSend'] = Db::name('qrd_info')->where(['cgdNo'=>$data['cgdNo']])->value
|
|
|
+ ('sendStatus',1);
|
|
|
if (!empty($exists_cgd)) {
|
|
|
|
|
|
//未对账,更新
|
|
@@ -341,10 +349,11 @@ class handleCxData extends command
|
|
|
'goodBrand'=>$data['brand'] ,//商品品牌',
|
|
|
'goodModel'=>'' ,//商品型号',
|
|
|
'firstCat'=>$data['cat_name'][0]['cat_name'] ,//商品一级分类',
|
|
|
- 'secCat'=>$data['cat_name'][1]['cat_name'] ,//二级分类',
|
|
|
- 'thirdCat'=>$data['cat_name'][2]['cat_name'] ,//三级分类',
|
|
|
- 'catInfo'=>json_encode($data['cat_name'] , JSON_UNESCAPED_UNICODE) ,//分类明细',
|
|
|
- 'fundCode'=>$data['cat_name'][2]['fund_code'] ,//NOT NULL,
|
|
|
+ 'secCat'=>!isset($data['cat_name'][1]) ? '' : $data['cat_name'][1]['cat_name'] ,//二级分类,
|
|
|
+ 'thirdCat'=>!isset($data['cat_name'][2]) ? '' : $data['cat_name'][2]['cat_name'] ,
|
|
|
+ //三级分类,
|
|
|
+ 'catInfo'=>json_encode($data['cat_name'] , JSON_UNESCAPED_UNICODE) ,//分类详情,
|
|
|
+ 'fundCode'=>isset($data['cat_name'][2]) ? $data['cat_name'][2]['fund_code'] : '',
|
|
|
'goodMaterial'=>'' ,//商品材质',
|
|
|
'goodUnit'=>$data['unit'] ,//商品单位',
|
|
|
'goodDesc'=>$data['cost_desc'] ,//工艺说明',
|
|
@@ -380,7 +389,7 @@ class handleCxData extends command
|
|
|
'wareHouse'=>$data['wsm_code'] ,//仓库名称',
|
|
|
'wsmCode'=>$data['wsm_code'] ,//仓库编号',
|
|
|
'remark'=>'' ,//备注',
|
|
|
- 'cxCode'=>$data['oldCode'] ?? "" ,//备注,
|
|
|
+ 'cxCode'=>$data['oldCode'] ?? '' ,//备注,
|
|
|
'pay_status'=>$data['total_fee'] == 0 ? 3 : 1 ,//付款情况',
|
|
|
'inv_status'=>$data['total_fee'] == 0 ? 3 : 1 ,//开票情况',
|
|
|
'diff_weight'=>$data['diff_weight'] ,//工差重量',
|
|
@@ -396,10 +405,10 @@ class handleCxData extends command
|
|
|
|
|
|
} else {
|
|
|
$wait_insert_data=[
|
|
|
- "order_type"=>$result['order_type'] ,
|
|
|
- "data"=>json_encode($result['data'] , JSON_UNESCAPED_UNICODE) ,
|
|
|
- "orderCode"=>$data['cgdNo'] ,
|
|
|
- "status"=>1 ,
|
|
|
+ 'order_type'=>$result['order_type'] ,
|
|
|
+ 'data'=>json_encode($result['data'] , JSON_UNESCAPED_UNICODE) ,
|
|
|
+ 'orderCode'=>$data['cgdNo'] ,
|
|
|
+ 'status'=>1 ,
|
|
|
];
|
|
|
|
|
|
Db::name('cgd_info')
|
|
@@ -439,7 +448,7 @@ class handleCxData extends command
|
|
|
'wareHouse'=>$data['wsm_code'] ,//仓库名称',
|
|
|
'wsmCode'=>$data['wsm_code'] ,//仓库编号',
|
|
|
'remark'=>'' ,//备注',
|
|
|
- 'cxCode'=>$data['oldCode'] ?? "" ,//备注,
|
|
|
+ 'cxCode'=>$data['oldCode'] ?? '' ,//备注,
|
|
|
'check_rate'=>'' ,//修正后的税率',
|
|
|
'updatetime'=>$date ,
|
|
|
]
|
|
@@ -468,10 +477,11 @@ class handleCxData extends command
|
|
|
'goodBrand'=>$data['brand'] ,//商品品牌',
|
|
|
'goodModel'=>'' ,//商品型号',
|
|
|
'firstCat'=>$data['cat_name'][0]['cat_name'] ?? "" ,//商品一级分类',
|
|
|
- 'secCat'=>$data['cat_name'][1]['cat_name'] ,//二级分类',
|
|
|
- 'thirdCat'=>$data['cat_name'][2]['cat_name'] ,//三级分类',
|
|
|
- 'catInfo'=>json_encode($data['cat_name'] , JSON_UNESCAPED_UNICODE) ,//分类明细',
|
|
|
- 'fundCode'=>$data['cat_name'][2]['fund_code'] ,//NOT NULL,
|
|
|
+ 'secCat'=>!isset($data['cat_name'][1]) ? '' : $data['cat_name'][1]['cat_name'] ,//二级分类,
|
|
|
+ 'thirdCat'=>!isset($data['cat_name'][2]) ? '' : $data['cat_name'][2]['cat_name'] ,
|
|
|
+ //三级分类,
|
|
|
+ 'catInfo'=>json_encode($data['cat_name'] , JSON_UNESCAPED_UNICODE) ,//分类详情,
|
|
|
+ 'fundCode'=>isset($data['cat_name'][2]) ? $data['cat_name'][2]['fund_code'] : '',
|
|
|
'goodMaterial'=>'' ,//商品材质',
|
|
|
'goodUnit'=>$data['unit'] ,//商品单位',
|
|
|
'goodDesc'=>$data['cost_desc'] ,//工艺说明',
|
|
@@ -515,7 +525,7 @@ class handleCxData extends command
|
|
|
'thNum'=>$data['th_num'] ,//退货数量',
|
|
|
'th_fee'=>$data['th_fee'] ,//退货金额',
|
|
|
'check_rate'=>'' ,//修正后的税率',
|
|
|
- 'cxCode'=>$data['oldCode'] ?? "" ,//备注,
|
|
|
+ 'cxCode'=>$data['oldCode'] ?? '' ,//备注,
|
|
|
'is_del'=>0 ,
|
|
|
'addtime'=>$date ,
|
|
|
'updatetime'=>$date ,
|
|
@@ -527,20 +537,23 @@ class handleCxData extends command
|
|
|
if ($qrd_insert_data) Db::name('qrd_info')->insertAll($qrd_insert_data);
|
|
|
if ($cgd_insert_data) Db::name('cgd_info')->insertAll($cgd_insert_data);
|
|
|
if ($wait_insert_data) Db::name('caixiao_wait')->insert($wait_insert_data);
|
|
|
- Db::name("caixiao_data")->where('uniqkey' , $result['uniqkey'])->update(['status'=>0]);
|
|
|
+ Db::name('caixiao_data')->where('uniqkey' , $result['uniqkey'])->update(['status'=>0]);
|
|
|
$output->writeln("[$date]:{$result['id']}处理成功");
|
|
|
- } Cache::store("redis")->set("JsHandle",0,180);
|
|
|
+ } Cache::store('redis')->set('JsHandle',0,180);
|
|
|
Db::commit();
|
|
|
} catch (Exception $exception) {
|
|
|
- Cache::store("redis")->set("JsHandle",0,180);
|
|
|
+ Cache::store('redis')->set('JsHandle',0,180);
|
|
|
Db::rollback();
|
|
|
$output->writeln($exception->getMessage());
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
- Cache::store("redis")->set("JsHandle",0,180);
|
|
|
+ Cache::store('redis')->set('JsHandle',0,180);
|
|
|
Db::rollback();
|
|
|
}
|
|
|
|
|
|
+ public function checkData($data){
|
|
|
+ return str_replace(array("\r\n" , "\r" , "\n" , "\\" , '/' , '//', ' ') , '' , $data);
|
|
|
+ }
|
|
|
}
|