service = app(OwnerStoragePriceModelService::class); $this->data["models"] = [ factory(OwnerStoragePriceModel::class)->create([ "minimum_area" => 600, //最低起租面积 "price" => 80.4, //单价 "discount_type" => "按单减免", //减免类型 "discount_value" => 0.1, //减免值 "unit_id" => 1, //单位ID ])->toArray(), factory(OwnerStoragePriceModel::class)->create([ "minimum_area" => 600, //最低起租面积 "price" => 80.4, //单价 "discount_type" => "固定减免", //减免类型 "discount_value" => 3.6, //减免值 "unit_id" => 1, //单位ID ])->toArray(), ]; $this->data["owners"] = [ factory(Owner::class)->create(["user_owner_group_id"=>1])->toArray() ]; $this->data["reports"] = [ factory(OwnerReport::class)->create([ "owner_id" => $this->data["owners"][0]["id"], "owner_bill_report_id" =>1, "total" => 1587, "counting_month" => "2020-10-10" ])->toArray() ]; } /** * @group customer */ public function testCalculationAmount() { $model = OwnerStoragePriceModel::query()->find($this->data["models"][0]["id"]); $result = $this->service->calculationAmount($model,548.98,$this->data["owners"][0]["id"],"2020-10-10"); $this->assertEquals(48081.3,$result); $model = OwnerStoragePriceModel::query()->find($this->data["models"][1]["id"]); $result = $this->service->calculationAmount($model,548.98,$this->data["owners"][0]["id"],"2020-10-10"); $this->assertEquals(48236.4,$result); } public function tearDown(): void { OwnerStoragePriceModel::destroy(array_column($this->data["models"],"id")); Owner::destroy(array_column($this->data["owners"],"id")); OwnerReport::destroy(array_column($this->data["reports"],"id")); parent::tearDown(); } }