"array" ]; const subjection=[ 0=>'', 1 => "宝时物流", 2 => "宝时供应链", ]; const IS_CHECK_ASN=[ 0 => "否", 1 => "是" ]; const IS_MANUAL_BACK=[ 0 => "否", 1 => "是" ]; /** * 退货管理里,客户审核的代码,是拼音+日期+计数,计数的后缀就是checking_count * */ public function getIncreasedCheckingCount() { $this['checking_count']=$this['checking_count']+1; $this->update(); return $this['checking_count']; } public function paperBoxes(): BelongsToMany { return $this->belongsToMany('\App\PaperBox', 'owner_paper_box', 'owner_id', 'paper_box_id'); } public function users(): BelongsToMany { return $this->belongsToMany('\App\User', 'owner_user', 'owner_id', 'user_id'); } public function orderTrackingOwner(){ return $this->belongsTo(OrderTrackingOwner::class,'id','owner_id'); } public function contracts() { //合同 return $this->hasMany(OwnerContract::class,"owner_id","id"); } public function order(){ return $this->hasOne(Order::class,'owner_id','id'); } public function customer() { //客户 return $this->hasOne(Customer::class,"id","customer_id"); } public function userOwnerGroup() { //项目组 return $this->hasOne(UserOwnerGroup::class,"id","user_owner_group_id"); } public function userWorkGroup() { //工作组 return $this->belongsTo(UserWorkgroup::class,"user_workgroup_id","id"); } public function ownerAreaReport() { //面积报表 return $this->hasOne(OwnerAreaReport::class,"owner_id","id"); } public function departmentObligationOwner() { //部门职能关联 return $this->hasMany(DepartmentObligationOwner::class,"owner_id","id") ->selectRaw('obligation_code,obligation_id,owner_id,department_id,max(valid_time)') ->groupBy('obligation_id','owner_id','department_id') ->whereNull('failure_time'); } public function ownerStoragePriceModels() { //仓储计费 $query = OwnerStoragePriceModel::query()->select("target_id") ->whereNotNull("operation")->where("operation","!=","") ->whereNotNull("target_id")->where("target_id","!=",""); return $this->belongsToMany(OwnerStoragePriceModel::class,"owner_storage_price_model_owner","owner_id","owner_storage_price_model_id") ->whereNotIn("id",$query)->where(function(Builder $query){ $query->where("operation","!=","D")->orWhereNull("operation"); }); } public function ownerPriceOperations() { //作业计费 $query = OwnerPriceOperation::query()->select("target_id") ->whereNotNull("operation")->where("operation","!=","") ->whereNotNull("target_id")->where("target_id","!=",""); return $this->belongsToMany(OwnerPriceOperation::class,"owner_price_operation_owner","owner_id","owner_price_operation_id") ->whereNotIn("id",$query)->where(function(Builder $query){ $query->where("operation","!=","D")->orWhereNull("operation"); }); } public function ownerPriceExpresses() { //快递计费 $query = OwnerPriceExpress::query()->select("target_id") ->whereNotNull("operation")->where("operation","!=","") ->whereNotNull("target_id")->where("target_id","!=",""); return $this->belongsToMany(OwnerPriceExpress::class,"owner_price_express_owner","owner_id","owner_price_express_id") ->whereNotIn("id",$query)->where(function(Builder $query){ $query->where("operation","!=","D")->orWhereNull("operation"); }); } public function ownerPriceLogistics() { //物流计费 $query = OwnerPriceLogistic::query()->select("target_id") ->whereNotNull("operation")->where("operation","!=","") ->whereNotNull("target_id")->where("target_id","!=",""); return $this->belongsToMany(OwnerPriceLogistic::class,"owner_price_logistic_owner","owner_id","owner_price_logistic_id") ->whereNotIn("id",$query)->where(function(Builder $query){ $query->where("operation","!=","D")->orWhereNull("operation"); }); } public function ownerPriceDirectLogistics() { //直发车计费 $query = OwnerPriceDirectLogistic::query()->select("target_id") ->whereNotNull("operation")->where("operation","!=","") ->whereNotNull("target_id")->where("target_id","!=",""); return $this->belongsToMany(OwnerPriceDirectLogistic::class,"owner_price_direct_logistic_owner","owner_id","owner_price_direct_logistic_id") ->whereNotIn("id",$query)->where(function(Builder $query){ $query->where("operation","!=","D")->orWhereNull("operation"); }); } public function ownerPriceSystem() { //系统计费 $query = OwnerPriceSystem::query()->select("target_id") ->whereNotNull("operation")->where("operation","!=","") ->whereNotNull("target_id")->where("target_id","!=",""); return $this->hasOne(OwnerPriceSystem::class,"owner_id","id") ->whereNotIn("id",$query)->where(function(Builder $query){ $query->where("operation","!=","D")->orWhereNull("operation"); }); } public function warehouse() { //仓库 return $this->belongsTo(Warehouse::class,"warehouse_id","id"); } public function ownerMaterials() { //耗材 return $this->hasMany(OwnerMaterial::class,"owner_id","id"); } public function taxRate() { //税率 return $this->belongsTo(TaxRate::class); } public function storageAudit() { //审核的仓储模型 return $this->belongsToMany(OwnerStoragePriceModel::class,"owner_storage_price_model_owner") ->select(DB::raw(1))->whereNotNull("operation") ->where("operation","!=","")->groupBy("owner_id"); } public function operationAudit() { //审核的作业模型 return $this->belongsToMany(OwnerPriceOperation::class,"owner_price_operation_owner") ->select(DB::raw(1))->whereNotNull("operation") ->where("operation","!=","")->groupBy("owner_id"); } public function expressAudit() { //审核的快递模型 return $this->belongsToMany(OwnerPriceExpress::class,"owner_price_express_owner") ->select(DB::raw(1))->whereNotNull("operation") ->where("operation","!=","")->groupBy("owner_id"); } public function logisticAudit() { //审核的物流模型 return $this->belongsToMany(OwnerPriceLogistic::class,"owner_price_logistic_owner") ->select(DB::raw(1))->whereNotNull("operation") ->where("operation","!=","")->groupBy("owner_id"); } public function directLogisticAudit() { //审核的直发模型 return $this->belongsToMany(OwnerPriceDirectLogistic::class,"owner_price_direct_logistic_owner") ->select(DB::raw(1))->whereNotNull("operation") ->where("operation","!=","")->groupBy("owner_id"); } public function systemAudit() { //审核的直发模型 return $this->hasOne(OwnerPriceSystem::class,"owner_id","id") ->select(DB::raw(1))->whereNotNull("operation") ->where("operation","!=",""); } public function ownerSundryFeeDetail(): HasMany { return $this->hasMany(OwnerSundryFeeDetail::class); } public function roles() { //角色 return $this->belongsToMany(Role::class); } }