Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

gogs 1 tahun lalu
induk
melakukan
aaa5347870

+ 1 - 0
app/Model/BasicType.php

@@ -37,5 +37,6 @@ class BasicType extends UseScopeBaseModel
         24 => '平台类型',
         25 => '业务类型',
         26 => '销售类型',
+        27 => '采购类型',
     ];
 }

+ 13 - 0
app/Model/ConstructionFile.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class ConstructionFile extends Model
+{
+    protected $table = "construction_file"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+}

+ 77 - 28
app/Service/ConstructionService.php

@@ -4,6 +4,7 @@ namespace App\Service;
 
 use App\Model\BasicType;
 use App\Model\Construction;
+use App\Model\ConstructionFile;
 use App\Model\ConstructionInfo;
 use App\Model\ConstructionProductInfo;
 use App\Model\Customer;
@@ -11,6 +12,7 @@ use App\Model\DeliveryNote;
 use App\Model\Depart;
 use App\Model\Employee;
 use App\Model\SalesOrder;
+use App\Model\SalesOrderInfo;
 use App\Model\SalesOrderProductInfo;
 use App\Model\ScheduleInfo;
 use App\Model\SeeRange;
@@ -72,6 +74,9 @@ class ConstructionService extends Service
             ConstructionProductInfo::where('del_time',0)
                 ->where('construction_id',$data['id'])
                 ->update(['del_time' => $time]);
+            ConstructionFile::where('del_time',0)
+                ->where('construction_id',$data['id'])
+                ->update(['del_time' => $time]);
 
             if(! empty($data['construction_contact'])){
                 $insert = [];
@@ -125,6 +130,20 @@ class ConstructionService extends Service
 
             if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
 
+            if(! empty($data['file'])){
+                $insert = [];
+                foreach ($data['file'] as $value){
+                    $insert[] = [
+                        'construction_id' => $data['id'],
+                        'file' => $value['url'],
+                        'name' => $value['name'],
+                        'mark' => $value['mark'] ?? "",
+                        'crt_time' => $time,
+                    ];
+                }
+                ConstructionFile::insert($insert);
+            }
+
             DB::commit();
         }catch (\Exception $exception){
             DB::rollBack();
@@ -230,6 +249,20 @@ class ConstructionService extends Service
 
             if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
 
+            if(! empty($data['file'])){
+                $insert = [];
+                foreach ($data['file'] as $value){
+                    $insert[] = [
+                        'construction_id' => $data['id'],
+                        'file' => $value['url'],
+                        'name' => $value['name'],
+                        'mark' => $value['mark'] ?? "",
+                        'crt_time' => $time,
+                    ];
+                }
+                ConstructionFile::insert($insert);
+            }
+
             DB::commit();
         }catch (\Exception $exception){
             DB::rollBack();
@@ -262,6 +295,9 @@ class ConstructionService extends Service
             ConstructionInfo::where('del_time',0)
                 ->where('construction_id',$data['id'])
                 ->update(['del_time' => time()]);
+            ConstructionFile::where('del_time',0)
+                ->where('construction_id',$data['id'])
+                ->update(['del_time' => $time]);
             ConstructionProductInfo::where('del_time',0)
                 ->where('construction_id',$data['id'])
                 ->update(['del_time' => time()]);
@@ -344,6 +380,19 @@ class ConstructionService extends Service
         }
         $construction = $construction[0];
 
+        $construction['file'] = [];
+        $file = ConstructionFile::where('del_time',0)
+            ->where('construction_id',$construction['id'])
+            ->select('id','construction_id','file','name','mark')
+            ->get()->toArray();
+        foreach ($file as $value){
+            $construction['file'][] = [
+                'url' => $value['file'],
+                'name' => $value['name'],
+                'mark' => $value['mark'],
+            ];
+        }
+
         $construction_info = ConstructionInfo::where('del_time',0)
             ->where('construction_id',$construction['id'])
             ->select('id','construction_id','employee_id','type','contact_type','contact_info')
@@ -486,12 +535,12 @@ class ConstructionService extends Service
 //            if(empty($data['construction_contact'])) return [false,'联系方式不能为空'];
 //            if(empty($data['address1']) || empty($data['address2'])) return [false,'地址不能为空'];
         }
-        //校验排班
-        if(empty($data['schedule_id']) ||empty($data['day_stamp']) || empty($data['day_start_stamp']) || empty($data['day_end_stamp'])) return [false,'排班时间信息不能为空'];
+        //校验排班 todo
+//        if(empty($data['schedule_id']) ||empty($data['day_stamp']) || empty($data['day_start_stamp']) || empty($data['day_end_stamp'])) return [false,'排班时间信息不能为空'];
 
         //所属部门 以及  顶级部门
         if(empty($data['depart_id'])) {
-            $data['depart_id'] = $this->getDepazrt($user);
+            $data['depart_id'] = $this->getDepart($user);
             $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
         }
 
@@ -547,16 +596,16 @@ class ConstructionService extends Service
                 ->exists();
             if($bool) return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
 
-            $schedule = ScheduleInfo::where('del_time',0)
-                ->where('day',$data['day_stamp'])
-                ->where('start_time',$data['day_start_stamp'])
-                ->where('end_time',$data['day_end_stamp'])
-                ->where('is_use',ScheduleInfo::not_use)
-                ->first();
-            if(! empty($schedule)) return [false,'该时间段排班已满或不存在!'];
-            $data['schedule_info_id'] = $schedule->id;
-            list($status,$msg) = $this->limitingSendRequestBackg(ScheduleInfo::limit_key . $schedule->id);
-            if(! $status) return [false,'操作频繁,请稍等!'];
+//            $schedule = ScheduleInfo::where('del_time',0)
+//                ->where('day',$data['day_stamp'])
+//                ->where('start_time',$data['day_start_stamp'])
+//                ->where('end_time',$data['day_end_stamp'])
+//                ->where('is_use',ScheduleInfo::not_use)
+//                ->first();
+//            if(! empty($schedule)) return [false,'该时间段排班已满或不存在!'];
+//            $data['schedule_info_id'] = $schedule->id;
+//            list($status,$msg) = $this->limitingSendRequestBackg(ScheduleInfo::limit_key . $schedule->id);
+//            if(! $status) return [false,'操作频繁,请稍等!'];
         }else{
             if(empty($data['id'])) return [false,'ID不能为空'];
             $bool = Construction::where('del_time',0)
@@ -567,21 +616,21 @@ class ConstructionService extends Service
                 ->exists();
             if($bool)  return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
 
-            $construction = Construction::where('id',$data['id'])->first();
-            if(empty($construction)) return [false,'施工单不存在或已被删除'];
-            $construction = $construction->toArray();
-            if($construction['day_stamp'] != $data['day_stamp'] || $construction['day_start_stamp'] != $data['day_start_stamp'] && $construction['day_end_stamp'] != $data['day_end_stamp']) {
-                $schedule = ScheduleInfo::where('del_time',0)
-                    ->where('day',$data['day_stamp'])
-                    ->where('start_time',$data['day_start_stamp'])
-                    ->where('end_time',$data['day_end_stamp'])
-                    ->where('is_use',ScheduleInfo::not_use)
-                    ->first();
-                if(! empty($schedule)) return [false,'该时间段排班已满或不存在!'];
-                $data['schedule_info_id'] = $schedule->id;
-                list($status,$msg) = $this->limitingSendRequestBackg(ScheduleInfo::limit_key . $schedule->id);
-                if(! $status) return [false,'操作频繁,请稍等!'];
-            }
+//            $construction = Construction::where('id',$data['id'])->first();
+//            if(empty($construction)) return [false,'施工单不存在或已被删除'];
+//            $construction = $construction->toArray();
+//            if($construction['day_stamp'] != $data['day_stamp'] || $construction['day_start_stamp'] != $data['day_start_stamp'] && $construction['day_end_stamp'] != $data['day_end_stamp']) {
+//                $schedule = ScheduleInfo::where('del_time',0)
+//                    ->where('day',$data['day_stamp'])
+//                    ->where('start_time',$data['day_start_stamp'])
+//                    ->where('end_time',$data['day_end_stamp'])
+//                    ->where('is_use',ScheduleInfo::not_use)
+//                    ->first();
+//                if(! empty($schedule)) return [false,'该时间段排班已满或不存在!'];
+//                $data['schedule_info_id'] = $schedule->id;
+//                list($status,$msg) = $this->limitingSendRequestBackg(ScheduleInfo::limit_key . $schedule->id);
+//                if(! $status) return [false,'操作频繁,请稍等!'];
+//            }
         }
 
         return [true, [$product_submit, $product_save]];

+ 4 - 1
app/Service/PurchaseOrderService.php

@@ -37,6 +37,7 @@ class PurchaseOrderService extends Service
         try{
             DB::beginTransaction();
             $material_model = PurchaseOrder::where('order_number',$data['order_number'])->first();
+            $material_model->purchase_type = $data['purchase_type'] ?? 0;
             $material_model->order_number = $data['order_number'];
             $material_model->depart_id = $data['depart_id'] ?? 0;
             $material_model->top_depart_id = $data['top_depart_id'] ?? 0;
@@ -114,6 +115,7 @@ class PurchaseOrderService extends Service
             DB::beginTransaction();
             $material_model = new PurchaseOrder();
             $material_model->order_number = $data['order_number'];
+            $material_model->purchase_type = $data['purchase_type'] ?? 0;
             $material_model->depart_id = $data['depart_id'] ?? 0;
             $material_model->top_depart_id = $data['top_depart_id'] ?? 0;
             $material_model->total = $data['total'] ?? 0;
@@ -184,11 +186,12 @@ class PurchaseOrderService extends Service
 
         $order = PurchaseOrder::where('order_number',$data['order_number'])
             ->where('del_time',0)
-            ->select('id','order_number','depart_id','mark','state','crt_id','order_type','sales_order_id','supplier','purchase_id','total','other_fee','discount_fee','purchase_total','crt_time','storehouse_id','top_depart_id')
+            ->select('id','order_number','depart_id','mark','state','crt_id','order_type','sales_order_id','supplier','purchase_id','total','other_fee','discount_fee','purchase_total','crt_time','storehouse_id','top_depart_id','purchase_type')
             ->first();
         if(empty($order)) return [false, '采购订单不存在或已被删除'];
         $order = $order->toArray();
         $order['file'] = [];
+        $order['purchase_type_title'] = BasicType::where('id',$order['purchase_type'])->value('title') ?? '';
         $order['storehouse_title'] = Storehouse::where('id',$order['storehouse_id'])->value('title');
         $supplier = Supplier::where('id',$order['supplier'])->first();
         $order['supplier_title'] = $supplier->title ?? '';

+ 29 - 10
app/Service/U8ServerService.php

@@ -281,17 +281,27 @@ class U8ServerService extends Service
             foreach ($value['product'] as $son){
                 //子表数据
                 $bodys[] = [
-                    "iappids"=>"", //子表id
                     "cinvcode"=>$son['code'], //存货编码
                     "iquantity"=>$son['number'], //数量
                     "inum"=>$son['number'], //件数
-                    "ipertaxrate"=>$son['ipertaxrate'], //税率
-                    "iunitprice"=>$son['iunitprice'], //原币单价
-                    "itaxprice"=>$son['itaxprice'], //原币含税单价
+                    "itaxrate"=>$son['itaxrate'], //税率
+                    "iunitprice"=>$son['iunitprice'],//原币单价
+                    "itaxunitprice"=>$son['itaxunitprice'], // 原币含税单价
                     "isum"=>$son['isum'], //原币价税合计
                     "imoney"=>$son['imoney'], //原币无税金额
                     "itax"=>$son['itax'],//原币税额
                     "cbmemo"=>$son['mark'], //表体备注
+//                    "iappids"=>"", //子表id
+//                    "cinvcode"=>$son['code'], //存货编码
+//                    "iquantity"=>$son['number'], //数量
+//                    "inum"=>$son['number'], //件数
+//                    "ipertaxrate"=>$son['ipertaxrate'], //税率
+//                    "iunitprice"=>$son['iunitprice'], //原币单价
+//                    "itaxprice"=>$son['itaxprice'], //原币含税单价
+//                    "isum"=>$son['isum'], //原币价税合计
+//                    "imoney"=>$son['imoney'], //原币无税金额
+//                    "itax"=>$son['itax'],//原币税额
+//                    "cbmemo"=>$son['mark'], //表体备注
                     "cdefine22"=>$son['cdefine22'], //手机号码
                     "cdefine23"=>"",
                     "cdefine24"=>"",
@@ -427,6 +437,9 @@ class U8ServerService extends Service
         $emp = Employee::whereIn('id',array_unique(array_column($main,'purchase_id')))
             ->pluck('number','id')
             ->toArray();
+        $code_map = BasicType::whereIn('id',array_unique(array_column($main,'purchase_type')))
+            ->pluck('title','id')
+            ->toArray();
 
         $sub = PurchaseOrderInfo::whereIn('purchase_order_id',$id)
             ->where('del_time',0)
@@ -467,7 +480,7 @@ class U8ServerService extends Service
             $sub_map[$value['purchase_order_id']][] = $value;
         }
         foreach ($main as $key => $value){
-            $main[$key]['cptname'] = $supplier[$value['supplier']] ?? "";
+            $main[$key]['cptname'] = $code_map[$value['purchase_type']] ?? "";
             $main[$key]['cvenname'] = $supplier[$value['supplier']] ?? "";
             $main[$key]['cdepname'] = $depart[$value['depart_id']] ?? "";
             $main[$key]['cpersoncode'] = $emp[$value['purchase_id']] ?? "";
@@ -500,7 +513,7 @@ class U8ServerService extends Service
             ->pluck('title','id')
             ->toArray();
         $emp = Employee::whereIn('id',array_unique(array_column($main,'crt_id')))
-            ->pluck('number','id')
+            ->pluck('emp_name','id')
             ->toArray();
         $see = SeeRange::where('del_time',0)
             ->whereIn('data_id',array_column($main,'id'))
@@ -513,19 +526,25 @@ class U8ServerService extends Service
             $product_tmp = $product_map[$value['product_id']] ?? [];
             $main_tmp = $main_map[$value['sales_order_id']] ?? [];
 
+//            "itaxrate"=>$son['itaxrate'], //税率
+//            "iunitprice"=>$son['iunitprice'],//原币单价
+//            "itaxunitprice"=>$son['itaxunitprice'], // 原币含税单价
+//            "isum"=>$son['isum'], //原币价税合计
+//            "imoney"=>$son['imoney'], //原币无税金额
+//            "itax"=>$son['itax'],//原币税额
             //计算金额
             if($value['rate'] > 0){
-                $value['ipertaxrate'] = $value['rate'];
+                $value['itaxrate'] = $value['rate'];
                 $rate = round($value['rate'] / 100,2);
                 $value['iunitprice'] = round($value['price'] / (1 + $rate),2);
-                $value['itaxprice'] = $value['price'];
+                $value['itaxunitprice'] = $value['price'];
                 $value['isum'] = round($value['price'] * $value['number'],2);
                 $value['imoney'] = round($value['iunitprice'] * $value['number'],2);
                 $value['itax'] = round($value['isum'] - $value['imoney'],2);
             }else{
-                $value['ipertaxrate'] = 0;
+                $value['itaxrate'] = 0;
                 $value['iunitprice'] = $value['price'];
-                $value['itaxprice'] = $value['price'];
+                $value['itaxunitprice'] = $value['price'];
                 $value['isum'] = $value['price'] * $value['number'];
                 $value['imoney'] = $value['isum'];
                 $value['itax'] = 0;