1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\listener;
- use app\admin\model\OrderReturn;use app\admin\model\SaleReturn;class ThData
- {
- /**
- * 事件监听处理
- *
- * @return mixed
- */
- public function handle($event)
- {//
- \app\admin\model\ThData::create($event);
- $data=[];
- switch ($event['th_type']){
- case 1:
- $data=$this->beforeOrder($event);
- break;
- case 2:
- $data=$this->afterOrder($event);
- break;
- case 3:
- case 4:
- break;
- }
- if(empty($data)==false)\app\admin\model\ThStock::create($data);
-
- }
- //售后退货 供应商不同意退货
- protected function afterOrder($event){
- $model =new OrderReturn();
- $info =$model->where(["returnCode"=>$event['thCode']])->findOrEmpty();
- if($info->isEmpty())return[];
- if($info->status==5 && $info->return_tag==2){
- $data=[
- "thCode"=>$info->returnCode,
- "th_type"=>2,
- "order_type"=>$info->order_type,
- "supplierNo"=>$info->supplierNo,
- "supplierName"=>$info->supplierName,
- "companyNo"=>$info->companyNo,
- "companyName"=>$info->companyName,
- "customerNo"=>$info->customer_code,
- "customerName"=>$info->customer_name,
- "th_num"=>$info->error_num,
- "th_cgd_price"=>$event['sale_price'],
- "th_sale_price"=>$event['cgd_price'],
- "good_code"=>$info->good_code,
- "good_name"=>$info->good_name,
- "orderCode"=>$info->orderCode,
- 'cgdCode'=>$event['cgdNo'],
- "apply_id"=>$info->apply_id,
- "apply_name"=>$info->apply_name,
- ];
- }else $data=[];
- return $data;
- }
- //售前退货 供应商不同意退货
- protected function beforeOrder($event){
- $model =new SaleReturn();
- $info =$model->where(['returnCode'=>$event['thCode']])->findOrEmpty();
- if($info->isEmpty())return[];
- if($info->status==4 && $info->is_th==0){
- $data=[
- 'thCode'=>$info->returnCode,
- 'th_type'=>1,
- 'order_type'=>$info->order_type,
- 'supplierNo'=>$info->supplierNo,
- 'supplierName'=>$info->supplierName,
- 'companyNo'=>$info->companyNo,
- 'companyName'=>$info->companyName,
- 'customerNo'=>$info->customer_code,
- 'customerName'=>$info->customer_name,
- 'th_num'=>$info->num,
- 'th_cgd_price'=>$event['sale_price'],
- 'th_sale_price'=>$event['cgd_price'],
- 'good_code'=>$info->good_code,
- 'good_name'=>$info->good_name,
- 'orderCode'=>$info->orderCode,
- 'cgdCode'=>$event['cgdNo'],
- 'apply_id'=>$info->apply_id,
- 'apply_name'=>$info->apply_name,
- ];
- }else $data=[];
- return $data;
- }
-
-
-
- }
|