Преглед на файлове

订单管理:分箱号导出
运输管理:模型缺失,日志记录,倒叙日志
入库预约:允许当天产能充足时上午逾期至下午
即时账单:修复退货部分记录,区分新品入库与退货入库

Zhouzhendong преди 4 години
родител
ревизия
6be9e8d442

+ 12 - 3
app/Http/Controllers/DeliveryAppointmentController.php

@@ -514,7 +514,7 @@ html;
     }
 
     /**
-     * 验证预约码
+     * 验证预约码  允许当日产能满足后的逾期
      *
      */
     public function checkAppointment()
@@ -524,15 +524,24 @@ html;
         if (!$number)return ["status"=>417];
         $period = app("DeliveryAppointmentService")->getPeriod();
         if ($period===false)return ["status"=>416]; //非法时段扫码
-        $car = DeliveryAppointmentCar::query()->whereNull("delivery_time")->where("status",0)
+        $mark = false;
+        mark:
+        $car = DeliveryAppointmentCar::query()->whereNull("delivery_time")->whereIn("status",0)
             ->where("appointment_number",$number)->whereHas("deliveryAppointment",function (Builder $query)use($period){
                 $query->where("appointment_date",date("Y-m-d"))
                 ->where("date_period",$period)->where("status",0);
             })->first();
+        if (!$car && $period===1){$period = 0;$mark = true;goto mark;}
+        if ($mark && $car){
+            $car->load("deliveryAppointment");
+            $available = app("DeliveryAppointmentService")->getAvailableCapacity($car->deliveryAppointment->appointment_date,$car->deliveryAppointment->date_period,$car->deliveryAppointment->warehouse_id);
+            if ($available<$car->deliveryAppointment->capacity)$car = null;
+        }
         if (!$car)return ["status"=>417];
         $car->update(["delivery_time"=>date("Y-m-d H:i:s"),"status"=>1]);
         /** @var DeliveryAppointmentCar $car */
-        event(new DeliveryAppointmentEvent($car));
+        if ($mark)DeliveryAppointment::query()->where("id",$car->delivery_appointment_id)->update(["status" => 0]);
+        else event(new DeliveryAppointmentEvent($car));
         return ["status"=>200,"k"=>$car->delivery_appointment_id];
     }
 

+ 15 - 0
app/Http/Controllers/WaybillController.php

@@ -166,6 +166,11 @@ class WaybillController extends Controller
             $waybillPayoffService->updateOrCreate($waybillPayoffParam);
         }
         app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        WaybillAuditLog::query()->create([
+            'waybill_id'=>$id,
+            'audit_stage'=>'发起调度',
+            'user_id'=>Auth::id(),
+        ]);
         return redirect('transport/waybill/index')->with('successTip','运单“'.$waybill->waybill_number.'”调度成功');
     }
 
@@ -824,6 +829,11 @@ class WaybillController extends Controller
         if(!GAte::allows('运输管理-运单-删除')){return['success'=>0,'status'=>'没有权限'];}
         if(is_null($id)){return ['success'=>'0','status'=>'传入id为空'];}
         $result =  Waybill::where('id',$id)->delete();
+        WaybillAuditLog::query()->create([
+            'waybill_id'=>$id,
+            'audit_stage'=>'删除运单',
+            'user_id'=>Auth::id(),
+        ]);
         return ['success'=>$result,'status'=>$result];
     }
 
@@ -853,6 +863,11 @@ class WaybillController extends Controller
             $waybill->restore();
         });
         app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        foreach ($ids as $id) WaybillAuditLog::query()->create([
+            'waybill_id'=>$id,
+            'audit_stage'=>'恢复运单',
+            'user_id'=>Auth::id(),
+        ]);
         return ['success'=>'true','waybills'=>$waybills];
     }
     // 修改运费

+ 31 - 0
app/Jobs/ResetInstantBill.php

@@ -8,12 +8,14 @@ use App\OwnerFeeDetail;
 use App\OwnerFeeDetailLogistic;
 use App\Process;
 use App\Province;
+use App\RejectedBill;
 use App\Services\CacheService;
 use App\Services\OwnerPriceDirectLogisticService;
 use App\Services\OwnerPriceExpressService;
 use App\Services\OwnerPriceLogisticService;
 use App\Services\OwnerPriceOperationService;
 use App\Store;
+use App\StoreRejected;
 use App\Waybill;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -191,6 +193,35 @@ class ResetInstantBill implements ShouldQueue
                     "work_tax_fee" => $taxFee
                 ]);
                 break;
+            case "rejected_bills":
+                $rejectedBill = RejectedBill::query()->find($this->detail->outer_id);
+                /** @var \stdClass $rejectedBill */
+                $number = array_column(StoreRejected::query()->where("logistic_number_return",$rejectedBill->logistic_number_return)->get()->toArray(),"store_id");
+
+                foreach (Store::query()->with("storeItems")->whereIn("id",$number)->get() as $store){
+                    /** @var OwnerPriceOperationService $service */
+                    $service = app("OwnerPriceOperationService");
+                    list($id,$money,$taxFee) = $service->matching($store, Feature::MAPPING["store"], $store->owner_id, "入库",0);
+                    $bill = OwnerFeeDetail::query()->where("outer_id",$store->id)->where("outer_table_name","stores")->first();
+                    if ($bill) $bill->update([
+                        "work_fee" => $money,
+                        "owner_price_operation_id" => $id,
+                        "outer_id" => $rejectedBill->id,
+                        "outer_table_name" => "rejected_bills",
+                    ]); else app("OwnerFeeDetailService")->create([
+                        "owner_id" => $store->owner_id,
+                        "worked_at" => $store->created_at,
+                        "type" => "收货",
+                        "operation_bill" => $store->asn_code,
+                        "commodity_amount" => array_sum(array_column($store->storeItems->toArray(), "amount")),
+                        "work_fee" => $money,
+                        "owner_price_operation_id" => $id,
+                        "created_at" => date('Y-m-d H:i:s'),
+                        "outer_id" => $rejectedBill->id,
+                        "outer_table_name" => "rejected_bills",
+                        "work_tax_fee" => $taxFee,
+                    ]);
+                }
         }
     }
 }

+ 27 - 0
app/Services/DeliveryAppointmentService.php

@@ -7,6 +7,7 @@ use App\DeliveryAppointmentDetail;
 use App\Services\common\QueryService;
 use App\Traits\ServiceAppAop;
 use App\DeliveryAppointment;
+use App\Warehouse;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Facades\Auth;
 use phpDocumentor\Reflection\Types\Integer;
@@ -171,4 +172,30 @@ class DeliveryAppointmentService
         }])->find($id);
         if ($delivery->cars_count == 0)$delivery->update(["status"=>2]);
     }
+
+    /**
+     * 获取指定时段可用产能
+     *
+     * @param string $date
+     * @param int $period
+     * @param integer $warehouseId
+     *
+     * @return double
+     */
+    public function getAvailableCapacity($date,$period,$warehouseId)
+    {
+        $result = DeliveryAppointment::query()->selectRaw("appointment_date,date_period,SUM(capacity) AS capacity")
+            ->where("appointment_date",$date)
+            ->where("date_period",$period)
+            ->where("warehouse_id",$warehouseId)
+            ->where("status",0)
+            ->groupBy(["appointment_date","date_period"])
+            ->lockForUpdate()->first();
+        if (!$result)return 0;
+        /** @var \stdClass $warehouse */
+        $warehouse = Warehouse::query()->find($warehouseId);
+        if (!$warehouse)return 0;
+        $total = $warehouse->production_capacity*DeliveryAppointment::HOUR[$period];
+        return $total-$result->capacity;
+    }
 }

+ 2 - 2
app/Services/OrderService.php

@@ -253,7 +253,7 @@ class OrderService
         $sql="select ACT_ALLOCATION_DETAILS.CHECKTIME,DOC_ORDER_HEADER.addtime,DOC_ORDER_HEADER.C_PROVINCE,DOC_ORDER_HEADER.C_CITY,DOC_ORDER_HEADER.C_DISTRICT,DOC_ORDER_HEADER.C_CONTACT,DOC_ORDER_HEADER.OrderNo,DOC_ORDER_HEADER.SOStatus,DOC_ORDER_HEADER.WAREHOUSEID,DOC_ORDER_HEADER.CustomerID
         ,DOC_ORDER_HEADER.C_Tel2,DOC_ORDER_HEADER.C_Tel1,DOC_ORDER_HEADER.CarrierName,DOC_ORDER_HEADER.IssuePartyName,DOC_ORDER_HEADER.EDIREMARKS2,
        DOC_ORDER_HEADER.WaveNo,DOC_ORDER_HEADER.SOReference1
-        ,DOC_ORDER_HEADER.soreference5,DOC_ORDER_HEADER.EDISENDFLAG2,DOC_ORDER_HEADER.EDISendTime2,DOC_ORDER_HEADER.Notes,DOC_ORDER_HEADER.ERPCANCELFLAG,
+        ,ACT_ALLOCATION_DETAILS.PICKTOTRACEID as soreference5,DOC_ORDER_HEADER.EDISENDFLAG2,DOC_ORDER_HEADER.EDISendTime2,DOC_ORDER_HEADER.Notes,DOC_ORDER_HEADER.ERPCANCELFLAG,
        DOC_ORDER_HEADER.Picking_Print_Flag,DOC_ORDER_HEADER.EDISENDFLAG
         ,DOC_ORDER_HEADER.ReleaseStatus,DOC_ORDER_HEADER.C_Address1,DOC_ORDER_HEADER.OrderTime,DOC_Order_Details.CustomerID,
        DOC_Order_Details.SKU,DOC_Order_Details.QtyOrdered,DOC_Order_Details.LOTNUM,DOC_Order_Details.LineStatus,DOC_Order_Details.OrderLineNo,order_code.codename_c as orderCodeName,
@@ -296,7 +296,7 @@ class OrderService
                       GROUP BY ACT_ALLOCATION_DETAILS.CHECKTIME,DOC_ORDER_HEADER.addtime,DOC_ORDER_HEADER.C_PROVINCE,DOC_ORDER_HEADER.C_CITY,
                       DOC_ORDER_HEADER.C_DISTRICT,DOC_ORDER_HEADER.C_CONTACT,DOC_ORDER_HEADER.OrderNo,DOC_ORDER_HEADER.SOStatus,DOC_ORDER_HEADER.WAREHOUSEID,
                       DOC_ORDER_HEADER.CustomerID,DOC_ORDER_HEADER.C_Tel2,DOC_ORDER_HEADER.C_Tel1,DOC_ORDER_HEADER.CarrierName,DOC_ORDER_HEADER.IssuePartyName,
-                      DOC_ORDER_HEADER.EDIREMARKS2,DOC_ORDER_HEADER.WaveNo,DOC_ORDER_HEADER.SOReference1, DOC_ORDER_HEADER.soreference5,
+                      DOC_ORDER_HEADER.EDIREMARKS2,DOC_ORDER_HEADER.WaveNo,DOC_ORDER_HEADER.SOReference1, ACT_ALLOCATION_DETAILS.PICKTOTRACEID,
                       DOC_ORDER_HEADER.EDISENDFLAG2,DOC_ORDER_HEADER.EDISendTime2,DOC_ORDER_HEADER.Notes,DOC_ORDER_HEADER.ERPCANCELFLAG,
                       DOC_ORDER_HEADER.Picking_Print_Flag,DOC_ORDER_HEADER.EDISENDFLAG,DOC_ORDER_HEADER.ReleaseStatus,DOC_ORDER_HEADER.C_Address1,
                       DOC_ORDER_HEADER.OrderTime,DOC_Order_Details.CustomerID,DOC_Order_Details.SKU,DOC_Order_Details.QtyOrdered,DOC_Order_Details.LOTNUM,

+ 4 - 2
app/Services/RejectedBillService.php

@@ -358,6 +358,8 @@ class RejectedBillService
             if ($bill) $bill->update([
                     "work_fee" => $money,
                     "owner_price_operation_id" => $id,
+                    "outer_id" => $rejectedBill->id,
+                    "outer_table_name" => "rejected_bills",
             ]); else app("OwnerFeeDetailService")->create([
                 "owner_id" => $store->owner_id,
                 "worked_at" => $store->created_at,
@@ -367,8 +369,8 @@ class RejectedBillService
                 "work_fee" => $money,
                 "owner_price_operation_id" => $id,
                 "created_at" => date('Y-m-d H:i:s'),
-                "outer_id" => $store->id,
-                "outer_table_name" => "stores",
+                "outer_id" => $rejectedBill->id,
+                "outer_table_name" => "rejected_bills",
                 "work_tax_fee" => $taxFee,
             ]);
         }

+ 1 - 1
app/Waybill.php

@@ -105,7 +105,7 @@ class Waybill extends Model
         return $this->hasOne('App\CarType','id','carType_id');
     }
     public function waybillAuditLogs(){
-        return $this->hasMany('App\WaybillAuditLog','waybill_id','id');
+        return $this->hasMany('App\WaybillAuditLog','waybill_id','id')->orderByDesc("created_at");
     }
     public function uploadFile(){
         return $this->hasOne('App\UploadFile','table_id','id')->where('table_name','waybills');

+ 8 - 4
resources/js/queryForm/header.js

@@ -84,8 +84,10 @@ window.Header = function getHeader(object) {
                 while(trs[0] && trs[0].tagName !== 'TR')trs = trs[0].children;
                 if (trs[0]){
                     for (let j=0;j<trs.length;j++){
-                        trs[j].children[i].firstElementChild.style.width = wid+"px";
-                        trs[j].children[i].style.minWidth = wid+"px";
+                        if (trs[j].children[i]){
+                            trs[j].children[i].firstElementChild.style.width = wid+"px";
+                            trs[j].children[i].style.minWidth = wid+"px";
+                        }
                     }
                 }
             }
@@ -267,8 +269,10 @@ window.Header = function getHeader(object) {
                             while (table.tagName!=='TABLE') table = table.parentElement;
                             if (table.id!==object.el)continue;
                         }
-                        trs[j].children[moveTd.index].firstElementChild.style.width = newWidth;
-                        trs[j].children[moveTd.index].style.minWidth = newWidth;
+                        if (trs[j].children[moveTd.index]){
+                            trs[j].children[moveTd.index].firstElementChild.style.width = newWidth;
+                            trs[j].children[moveTd.index].style.minWidth = newWidth;
+                        }
                     }
                     _targetDom.style.width = _targetDom.offsetWidth+diff+"px";
                     moveTd.oldX = event.clientX;

+ 7 - 2
resources/views/finance/instantBill.blade.php

@@ -57,7 +57,7 @@
                     <td :rowspan="bill.rowspan"><span>@{{ bill.consigneeName }}</span></td>
                     <td :rowspan="bill.rowspan"><span>@{{ bill.consigneePhone }}</span></td>
                     <td><span>@{{ bill.commodityAmount }}</span></td>
-                    <td><span>@{{ bill.province }}</span></td>
+                    <td :rowspan="bill.rowspan"><span>@{{ bill.province }}</span></td>
                     <td>
                         <span>
                             <span v-if="bill.rowspan <= 1">@{{ bill.logisticBill }}</span>
@@ -74,7 +74,7 @@
                 <tr v-for="item in bill.items">
                     <td><span>@{{ item.amount }}</span></td>
                     <td><span>@{{ item.logistic_bill }}</span></td>
-                    <td><span>@{{ item.volume }}</span></td>
+                    <td><span>@{{ item.volume | convert }}</span></td>
                     <td><span>@{{ item.weight }}</span></td>
                     <td><span>@{{ item.logistic_fee }}</span></td>
                 </tr>
@@ -223,6 +223,11 @@
                     },true)
                 },
             },
+            filters:{
+                convert(val){
+                    return val ? Number(val/10)/100 : '';
+                },
+            },
         });
     </script>
 @stop