|
|
@@ -8,6 +8,7 @@ use App\OwnerPriceExpress;
|
|
|
use App\OwnerPriceExpressProvince;
|
|
|
use App\Services\common\QueryService;
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use App\Traits\ServiceAppAop;
|
|
|
|
|
|
@@ -111,6 +112,8 @@ class OwnerPriceExpressService
|
|
|
$result = app(QueryService::class)->priceModelAuditOrRecoverQuery($isAudit,OwnerPriceExpress::query(),$ownerId,$ids);
|
|
|
if ($result["delete"])$this->destroy($result["delete"]);
|
|
|
if ($result["update"])OwnerPriceExpress::query()->whereIn("id",$result["update"])->update(["operation"=>null,"target_id"=>null]);
|
|
|
+ if (!is_array($ownerId))$ownerId = [$ownerId];
|
|
|
+ foreach ($ownerId as $owner)Cache::tags("expressFeeOwner:".$owner)->flush();
|
|
|
}
|
|
|
|
|
|
public function updateDetail(array $params, array $values)
|
|
|
@@ -233,6 +236,31 @@ sql
|
|
|
},null);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param integer $owner
|
|
|
+ * @param integer $logistic
|
|
|
+ * @param integer $province
|
|
|
+ *
|
|
|
+ * @return OwnerPriceExpress|\stdClass|null
|
|
|
+ */
|
|
|
+ public function getOwnerPriceExpress($owner,$logistic,$province)
|
|
|
+ {
|
|
|
+ return Cache::tags("expressFeeOwner:".$owner)->remember("expressFee:".$owner.$logistic.$province,config("cache.expirations.rarelyChange"),
|
|
|
+ function ()use($owner,$logistic,$province){
|
|
|
+ return OwnerPriceExpress::query()->with(["details"=>function($query)use($province){
|
|
|
+ /** @var Builder $query */
|
|
|
+ $query->where("province_id",$province);
|
|
|
+ }])->whereHas("owners",function ($query)use($owner){
|
|
|
+ /** @var Builder $query */
|
|
|
+ $query->where("id",$owner);
|
|
|
+ })->whereHas("logistics",function ($query)use($logistic){
|
|
|
+ /** @var Builder $query */
|
|
|
+ $query->where("id",$logistic);
|
|
|
+ })->where(function(Builder $query){
|
|
|
+ $query->whereNull("operation")->orWhere("operation","");
|
|
|
+ })->first();
|
|
|
+ });
|
|
|
+ }
|
|
|
/**
|
|
|
*
|
|
|
* @param double $weight
|
|
|
@@ -245,18 +273,7 @@ sql
|
|
|
{
|
|
|
if (!$weight)return array(null,null);
|
|
|
|
|
|
- $model = OwnerPriceExpress::query()->with(["details"=>function($query)use($province_id){
|
|
|
- /** @var Builder $query */
|
|
|
- $query->where("province_id",$province_id);
|
|
|
- }])->whereHas("owners",function ($query)use($owner_id){
|
|
|
- /** @var Builder $query */
|
|
|
- $query->where("id",$owner_id);
|
|
|
- })->whereHas("logistics",function ($query)use($logistic_id){
|
|
|
- /** @var Builder $query */
|
|
|
- $query->where("id",$logistic_id);
|
|
|
- })->where(function(Builder $query){
|
|
|
- $query->whereNull("operation")->orWhere("operation","");
|
|
|
- })->first();
|
|
|
+ $model = $this->getOwnerPriceExpress($owner_id,$logistic_id,$province_id);
|
|
|
if (!$model || count($model->details)<1)return array(null,null);
|
|
|
|
|
|
if ($model->amount_interval){
|