Jelajahi Sumber

一些BUG修复与页面修复

Zhouzhendong 4 tahun lalu
induk
melakukan
0414794c36

+ 1 - 1
app/Components/ApiResponse.php

@@ -9,7 +9,7 @@ trait ApiResponse
     public function response($data, int $code = 200,string $message = null)
     {
         $response = ["status_code"=>$code,"data"=>$data,"message"=>$message];
-        header("Content-Type","application/json;charset=utf-8");
+        header("Content-Type","application/json; charset=UTF-8");
         echo json_encode($response,JSON_UNESCAPED_UNICODE);
         exit();
     }

+ 11 - 2
app/Http/ApiControllers/WaybillController.php

@@ -9,6 +9,7 @@ use App\Http\Requests\AndroidGateRequest;
 use App\Http\Requests\Api\WaybillDispatch;
 use App\Services\WaybillService;
 use App\Waybill;
+use Illuminate\Database\Eloquent\Collection;
 
 class WaybillController
 {
@@ -63,13 +64,21 @@ class WaybillController
 
         /** @var WaybillService $service */
         $service = app("WaybillService");
-        $query = $service->getDispatchQuery();
+        $query = $service->getDispatchQuery()->orderByDesc("deliver_at");
         if ($search)$query->where(function ($query)use($search){
             $query->where("waybill_number","like","%{$search}%")
                 ->orWhere("carrier_bill","like","%{$search}%");
         });
         if ($deliverAt)$query->where("deliver_at","like",$deliverAt."%");
-        $this->response($query->paginate($paginate,'*', 'page',$page)->append(["carrier_name","amount_unit_name","remove_relation"]));
+        /** @var Collection $waybills */
+        $waybills = $query->paginate($paginate,'*', 'page',$page)->append(["carrier_name","amount_unit_name","remove_relation"]);
+        $result = null;
+        if ($waybills->count()>0){
+            $startDate = substr($waybills->first()->deliver_at,0,10);
+            $endDate = substr($waybills->last()->deliver_at,0,10);
+            $result = ["2021-10-08"=>2];
+        }
+        $this->response(["waybills"=>$waybills,"mapping"=>$result]);
     }
 
     /**

+ 32 - 24
app/Http/Controllers/CustomerController.php

@@ -11,6 +11,7 @@ use App\Owner;
 use App\OwnerAreaReport;
 use App\OwnerBillReport;
 use App\OwnerFeeDetail;
+use App\OwnerFeeExpress;
 use App\OwnerFeeLogistic;
 use App\OwnerFeeOperation;
 use App\OwnerFeeOperationDetail;
@@ -521,32 +522,39 @@ class CustomerController extends Controller
         $endDate = request("endDate");
         $owner = request("owner");
         if (!$startData)$this->error("非法参数");
-        $details = OwnerFeeDetail::query()->where("worked_at",">=",$startData." 00:00:00");
-        if ($endDate)$details->where("worked_at","<=",$endDate." 23:59:59");
-        if (count($owner)>0)$details->whereIn("owner_id",$owner);
-
-        $fee = OwnerFeeDetail::query()->where("created_at",">=",$startData." 00:00:00");
-        if ($endDate)$fee->where("created_at","<=",$endDate." 23:59:59");
-        if (count($owner)>0)$fee->whereIn("owner_id",$owner);
-        $fee->delete();
-
-        $feeQuery = OwnerFeeOperation::query()->where("worked_at",">=",$startData);
-        if ($endDate)$feeQuery->where("worked_at","<=",$endDate);
-        if (count($owner)>0)$feeQuery->whereIn("owner_id",$owner);
-        OwnerFeeOperationDetail::query()->whereIn("owner_fee_operation_id",$feeQuery)->delete();
-        $feeQuery->delete();
-
-        $fee = OwnerFeeLogistic::query()->where("created_at",">=",$startData." 00:00:00");
-        if ($endDate)$fee->where("created_at","<=",$endDate." 23:59:59");
-        if (count($owner)>0)$fee->whereIn("owner_id",$owner);
-        $fee->delete();
-
-        $details->get()->each(function ($detail){
-            dispatch(new ResetInstantBill($detail));
-        });
+        DB::beginTransaction();
+        try {
+            $details = OwnerFeeDetail::query()->where("worked_at",">=",$startData." 00:00:00");
+            if ($endDate)$details->where("worked_at","<=",$endDate." 23:59:59");
+            if (count($owner)>0)$details->whereIn("owner_id",$owner);
+
+            $fee = OwnerFeeExpress::query()->where("created_at",">=",$startData." 00:00:00");
+            if ($endDate)$fee->where("created_at","<=",$endDate." 23:59:59");
+            if (count($owner)>0)$fee->whereIn("owner_id",$owner);
+            $fee->delete();
+
+            $feeQuery = OwnerFeeOperation::query()->select("id")->where("worked_at",">=",$startData);
+            if ($endDate)$feeQuery->where("worked_at","<=",$endDate);
+            if (count($owner)>0)$feeQuery->whereIn("owner_id",$owner);
+            OwnerFeeOperationDetail::query()->whereIn("owner_fee_operation_id",$feeQuery)->delete();
+            $feeQuery->delete();
+
+            $fee = OwnerFeeLogistic::query()->where("created_at",">=",$startData." 00:00:00");
+            if ($endDate)$fee->where("created_at","<=",$endDate." 23:59:59");
+            if (count($owner)>0)$fee->whereIn("owner_id",$owner);
+            $fee->delete();
+
+            $details->get()->each(function ($detail){
+                dispatch(new ResetInstantBill($detail));
+            });
+            DB::commit();
+            $this->success();
+        }catch (\Exception $e){
+            DB::rollBack();
+            $this->error("失败");
+        }
         //$this->restoreResetInstantBillOrder($startData,$endDate);
         //$this->restoreResetInstantBillStore($startData,$endDate);
-        $this->success();
     }
     private function restoreResetInstantBillOrder($startData,$endDate)
     {

+ 12 - 99
app/Http/Controllers/ProcessController.php

@@ -66,75 +66,9 @@ class ProcessController extends Controller
                 $processDailies=ProcessDaily::with(['processDailyParticipants','process'])
                     ->orderBy('date','DESC')->where('process_id',$id)->get();
             }
-            //$processDailies=$this->countManHour($processDailies);
         }
         return $processDailies;
     }
-
-    /*//根据参与人查找打卡记录计算工时信息
-    public function countManHour($processDailies){
-        foreach ($processDailies as $processDaily){
-            $date=$processDaily->date;
-            foreach ($processDaily->processDailyParticipants as $processDailyParticipant){
-                $processDailyParticipant->started_at=Carbon::parse($processDailyParticipant->started_at)->format('H:i');
-                $processDailyParticipant->ended_at=Carbon::parse($processDailyParticipant->ended_at)->format('H:i');
-                $processDailyParticipant=$this->countParticipantManHour($processDailyParticipant,$date);
-            }
-        }
-        return $processDailies;
-    }*/
-
-    /*//计算单参与人工时信息
-    public function countParticipantManHour($processDailyParticipant,$date){
-        $user_id=$processDailyParticipant->user_id;
-        $userDutyCheckStart=UserDutyCheck::select('id','checked_at')->where('user_id',$user_id)
-            ->where('checked_at','like',$date.'%')->where('type','登入')->orderBy('id')->first();
-        $userDutyCheckEnd=UserDutyCheck::select('id','checked_at')->where('user_id',$user_id)
-            ->where('checked_at','like',$date.'%')->where('type','登出')->orderBy('id','desc')->first();
-        //跨日情况寻找下一天
-        if (!$userDutyCheckEnd){
-            $date=date("Y-m-d",strtotime("+1 day",strtotime($date)));
-            $userDutyCheckEnd=UserDutyCheck::select('id','checked_at')->where('user_id',$user_id)
-                ->where('checked_at','like',$date.'%')->where('type','登出')->orderBy('id','desc')->first();
-        }
-        if (!$userDutyCheckStart || !$userDutyCheckEnd){
-            return $processDailyParticipant;
-        }
-        $dateStart=Carbon::parse($userDutyCheckStart->checked_at);
-        $dateEnd=Carbon::parse($userDutyCheckEnd->checked_at);
-        $hour=($dateEnd->diffInSeconds($dateStart))/3600; //打卡工时
-        if ($processDailyParticipant->dinner_duration)$hour=$hour-(($processDailyParticipant->dinner_duration)/60); //减晚饭时间
-        $hour=$this->isHour($userDutyCheckStart,$hour); //去除休息时间
-        $processDailyParticipant->hour=round($hour,2);
-        if ($hour&&$processDailyParticipant->hour_count){
-            $diff=abs(round($processDailyParticipant->hour_count-$hour,2));
-            $processDailyParticipant->diff=$diff;
-        }
-
-        //计件工 保留
-        // if ($processDailyParticipant->unit_count){
-        //   return $processDailyParticipant;
-        //}
-        if ($hour&&$hour>8){
-            $processDailyParticipant->billingHour=8;
-            return $processDailyParticipant;
-        }
-        if ($hour&&$hour<=8){
-            $processDailyParticipant->billingHour=round($hour,2);
-        }
-        return $processDailyParticipant;
-    }*/
-
-/*    //打卡工时减休息时间
-    private function isHour($userDutyCheckStart,$hour){
-
-        $date=$userDutyCheckStart->checked_at;
-        $date=Carbon::parse($date)->format('H');
-        if ((int)$date<=11){
-            $hour=$hour-1;
-        }
-        return $hour;
-    }*/
     //生成二次加工单缺失时间记录及本日记录
     private function createDeficiencyData($processDailies,$today){
         $processDailiesArr=[];
@@ -202,15 +136,15 @@ class ProcessController extends Controller
         if(!Gate::allows('二次加工管理-交接完成')){ return ['success'=>false,'data'=>'您无权进行该操作!'];  }
         $process=Process::with('processDailies')->find($request->id);
         if (!$process || $process->status == '交接完成')return ['success'=>false];
-        $result=$this->statistic($process);
+        $this->statistic($process);
         $process->update(['status'=>'交接完成']);
         $process->createOperatorLog('交接完成');
-        $processStatistic=$result['data'];
-        app('LogService')->log(__METHOD__,"完成二次加工单_".__FUNCTION__,json_encode($process)." || ".json_encode($processStatistic),Auth::user()['id']);
         app('ProcessService')->createInstantBill($process);
         return ['success'=>true,'data'=>'交接完成'];
     }
     private function statistic($process, $sign_end = false){
+        $processStatistic=ProcessStatistic::query()->find($process->id);
+        if (!$processStatistic)return ['success'=>true];
         if (count($process->processDailies)>0){
             $completed_amount=0;
             foreach ($process->processDailies as $processDaily){
@@ -235,7 +169,6 @@ class ProcessController extends Controller
                 $total_cost += ($processDailyParticipant->hour_count)*($processDailyParticipant->hour_price);
             }
         };
-        $processStatistic=ProcessStatistic::query()->find($process->id);
         $processStatistic->revenue=$revenue;
         $processStatistic->duration_days=$duration_days;
         $processStatistic->duration_man_hours=$duration_man_hours;
@@ -369,7 +302,7 @@ class ProcessController extends Controller
         }]);
 
         // 重置统计开始时间
-        event(new ResetProcessStatisticStartDateEvent($processDailyParticipant->processDaily->process));
+        //event(new ResetProcessStatisticStartDateEvent($processDailyParticipant->processDaily->process));
 
 
         if ($processDailyParticipant->processDaily && $processDailyParticipant->processDaily->process &&
@@ -378,8 +311,6 @@ class ProcessController extends Controller
         }
         $result=[];
         $processDaily=ProcessDaily::with('process')->select('process_id','date')->find($daily_id);
-        //$date=$processDaily->date;
-        //$processDailyParticipant=$this->countParticipantManHour($processDailyParticipant,$date);
         if ($processDaily->process && $processDaily->process->status=="待加工"){
             $process=Process::find($processDaily->process_id);
             $process->status="加工中";
@@ -389,7 +320,6 @@ class ProcessController extends Controller
             if (!$processStatistic){
                 Log::warning("二次加工统单不存在2",["user"=>Auth::id(),"param"=>$processDaily->process_id]);
             }else {
-                //$processStatistic->started_at=date('Y-m-d H:i:s');
                 $processStatistic->started_at=$processDaily->date.' '.$started_at;
                 $processStatistic->update();
                 app('LogService')->log(__METHOD__,"二次加工单加工中".__FUNCTION__,json_encode($process)." || ".json_encode($processStatistic),Auth::user()['id']);
@@ -452,7 +382,7 @@ class ProcessController extends Controller
         if (!$processDailyParticipant || !$processDailyParticipant->processDaily
             || !$processDailyParticipant->processDaily->process || !$processDailyParticipant->userLabor) return ['success'=>false,'data'=>"修改失败,该信息不存在"];
         if ($processDailyParticipant->userLabor->isOccupiedAt($processDailyParticipant->processDaily->date,$request->started_at)){
-            ['success'=>false,'data'=>"该临时工此时间段已存在工作记录"];
+            return ['success'=>false,'data'=>"该临时工此时间段已存在工作记录"];
         }
         $processDailyParticipant->user_id=$request->input('user_id');
         $processDailyParticipant->started_at=$request->input('started_at');
@@ -468,19 +398,8 @@ class ProcessController extends Controller
         if ($processDailyParticipant->processDaily->process->status=='交接完成'){
             $this->statistic($processDailyParticipant->processDaily->process);
         }
-        //$processDailyParticipant=$this->countParticipantManHour($processDailyParticipant,$processDailyParticipant->processDaily->date);
         return ['success'=>true,'data'=>$processDailyParticipant];
     }
-    /*//参与人审核
-    public function processDailyParticipantAudit($id){
-        if(!Gate::allows('人事管理-任务审核')){ return redirect(url('/'));  }
-        $processDailyParticipant=ProcessDailyParticipant::select('id','status')->find($id);
-        if (!$processDailyParticipant) return ['success'=>false];
-        $processDailyParticipant->status='已审核';
-        $processDailyParticipant->update();
-        app('LogService')->log(__METHOD__,"登记工时参与人审核".__FUNCTION__,json_encode($processDailyParticipant),Auth::user()['id']);
-        return ['success'=>true,'processDailyParticipant'=>$processDailyParticipant];
-    }*/
     //获取全部教程
     public function getTutorials($id){
         $process=Process::with('tutorials')->find($id);
@@ -519,7 +438,7 @@ class ProcessController extends Controller
     /**
      * Show the form for creating a new resource.
      *
-     * @return \Illuminate\Http\Response
+     * @return Application|Factory|\Illuminate\Http\Response|View
      */
     public function create()
     {
@@ -565,6 +484,9 @@ class ProcessController extends Controller
             'status'=>'待审核',
         ]);
         $process->save();
+        ProcessStatistic::query()->create([
+            'process_id'=>$process->id,
+        ]);
         $process->createOperatorLog('创建');
         $processContents=[];
         foreach ($request->input('processContents') as $processContent){
@@ -614,12 +536,6 @@ class ProcessController extends Controller
         }
         $process->code='P'.date ("Ymd").str_pad($process->id,3,"0",STR_PAD_LEFT);
         $process->update();
-        $processStatistic=new ProcessStatistic([
-            'process_id'=>$process->id,
-        ]);
-        $processStatistic->save();
-        app('LogService')->log(__METHOD__,"录入二次加工单".__FUNCTION__,json_encode($request->input()),Auth::user()['id']);
-        //if ($request->input('tutorials'))$process->tutorials()->sync($request->input('tutorials'));
         return ['success'=>true];
     }
     //修改价格
@@ -701,7 +617,7 @@ class ProcessController extends Controller
      * Show the form for editing the specified resource.
      *
      * @param  int  $id
-     * @return \Illuminate\Http\Response
+     * @return Application|Factory|\Illuminate\Http\Response|View
      */
     public function edit($id)
     {
@@ -884,8 +800,7 @@ class ProcessController extends Controller
             $query->where('type','成品单');
         }]);
         if (count($process->processesContents) == 0)return ['success'=>false,'data'=>'没有成本单不得验收!'];
-        $result=$this->statistic($process, true);
-        //if (!$result['success'])return $result;
+        $this->statistic($process, true);
         $process->update([
             'status'=>'待交接'
         ]);
@@ -1001,9 +916,7 @@ class ProcessController extends Controller
             $query->with("process");
         }])->find($id);
         if ($pro->delete()) {
-
-            event(new ResetProcessStatisticStartDateEvent($pro->processDaily->process));
-
+            //event(new ResetProcessStatisticStartDateEvent($pro->processDaily->process));
             return ['success'=>true];
         }
         return ['success'=>false , 'data'=>'记录不存在!'];

+ 16 - 13
app/Http/Controllers/TestController.php

@@ -118,7 +118,7 @@ class TestController extends Controller
         $this->data["active_test"] = "active";
     }
 
-    public function method(AndroidGateRequest $request, $method)
+    public function method(Request $request, $method)
     {
         try {
             return call_user_func([$this, $method], $request);
@@ -197,19 +197,22 @@ class TestController extends Controller
         }
         app("BatchService")->assignTasks($batches);
     }
-    public function test(AndroidGateRequest $request)
+    public function test()
     {
-        dd(Waybill::query()->with(["order:id,address","logistic:id,name","amountUnit:id,name"])
-            ->select("id","order_id","logistic_id","amount_unit_id",
-                "waybill_number","destination","recipient","recipient_mobile",
-                "carrier_bill","warehouse_weight","carrier_weight","inquire_tel",
-                "warehouse_weight_other","carrier_weight_other","amount","origination")
-            ->paginate(15)->append(["carrier_name","amount_unit_name","remove_relation"])->toJson());
-        $url = config('api_logistic.collectUpload.ZTO.prod.url');
-        $xAppKey =  config('api_logistic.collectUpload.ZTO.prod.x-appKey');
-        $appSecret = config('api_logistic.collectUpload.ZTO.prod.appSecret');
-        $appId = config('api_logistic.collectUpload.ZTO.prod.appId');
-        dd(env('APP_ENV'));
+        $ids = [];
+        $sql = <<<sql
+select id from orders where owner_id = 396
+           and wms_status = '订单完成'
+     and wms_edittime>='2021-09-01 00:00:00' and wms_edittime<'2021-10-01 00:00:00' and id not in
+(select outer_id from owner_fee_details where owner_id = 396 and created_at>='2021-09-01 00:00:00' and created_at<'2021-10-01 00:00:00'
+    and outer_table_name = 'orders')
+sql;
+        foreach (DB::select(DB::raw($sql)) as $order){
+            $ids[] = $order->id;
+        }
+        $orders = Order::query()->whereIn("id",$ids)->get();
+        dispatch(new OrderCreateInstantBill($orders));
+        return;
         //中通接口请求body
         $collectUploadDTOS = [[
             'billCode' => "75811463670235",

+ 1 - 1
app/Services/WaybillService.php

@@ -372,7 +372,7 @@ class WaybillService
     public function getDispatchQuery():Builder
     {
         return Waybill::query()->with(["order:id,address","logistic:id,name","amountUnit:id,name"])
-            ->select("id","order_id","logistic_id","amount_unit_id",
+            ->select("id","order_id","logistic_id","amount_unit_id","deliver_at",
                 "waybill_number","destination","recipient","recipient_mobile",
                 "carrier_bill","warehouse_weight","carrier_weight","inquire_tel",
                 "warehouse_weight_other","carrier_weight_other","amount","origination")->where(function ($query){

+ 6 - 4
resources/views/finance/instantBill.blade.php

@@ -54,8 +54,8 @@
                     </td>
                     <td :rowspan="bill.rowspan"><span>@{{ bill.shopName }}</span></td>
                     <td :rowspan="bill.rowspan"><span>@{{ bill.operationBill }}</span></td>
-                    <td :rowspan="bill.rowspan"><span>@{{ bill.consigneeName }}</span></td>
-                    <td :rowspan="bill.rowspan"><span>@{{ bill.consigneePhone }}</span></td>
+                    <td :rowspan="bill.rowspan"><span v-if="bill.is_encryption" class="text-danger">*加密*</span><span v-else>@{{ bill.consigneeName }}</span></td>
+                    <td :rowspan="bill.rowspan"><span v-if="bill.is_encryption" class="text-danger">*加密*</span><span v-else>@{{ bill.consigneePhone }}</span></td>
                     <td><span>@{{ bill.commodityAmount }}</span></td>
                     <td :rowspan="bill.rowspan"><span>@{{ bill.province }}</span></td>
                     <td>
@@ -102,7 +102,7 @@
                         type : "{{$detail->type}}",
                         shopName : "{{$detail->shop ? $detail->shop->name : ''}}",
                         operationBill : "{{$detail->operation_bill}}",
-                        consigneeName : "{{$detail->consignee_name}}",
+                        consigneeName : ("{{$detail->consignee_name}}" && "{{$detail->consignee_name}}".length>50 && ("{{$detail->consignee_name}}".substring(0,3)==='~Ag' || "{{$detail->consignee_name}}".substring(0,1)==='#')) ? "加密" : "{{$detail->consignee_name}}",
                         consigneePhone : "{{$detail->consignee_phone}}",
                         commodityAmount : "{{$detail->commodity_amount}}",
                         logisticBill : "{{$detail->logistic_bill}}",
@@ -116,7 +116,9 @@
                         createdAt : "{{$detail->created_at}}",
                         total : "{{$detail->work_fee + $detail->logistic_fee}}",
                         items:{!! $detail->items !!},
-                        rowspan:Number("{{count($detail->items)}}")+1
+                        rowspan:Number("{{count($detail->items)}}")+1,
+                        is_encryption : !!("{{$detail->consignee_phone}}".length>50 && ("{{$detail->consignee_phone}}".substring(0,3)==='~Ag' || "{{$detail->consignee_phone}}".substring(0,1)==='#'
+                            || "{{$detail->consignee_phone}}".substring(0,1)==='$')),
                     },
                     @endforeach
                 ],

+ 2 - 2
resources/views/rejected/edit.blade.php

@@ -4,12 +4,12 @@
 @section('content')
 
     <div id="nav2">
-        @component('rejected.menu')
+        {{--@component('rejected.menu')
             @can('退货管理-录入')
                 <li class="nav-item">
                     <a class="nav-link" href="javascript:;" :class="{active:isActive('edit',3)}">修改</a>
                 </li> @endcan
-        @endcomponent
+        @endcomponent--}}
     </div>
     <div class="container-fluid d-none" id="editPanel">
         <div class="card mb-2">