master
cody 5 months ago
parent bd8743449e
commit f96758e7f4

@ -210,11 +210,7 @@ class OrdersController extends CommonController
$order = $order->refreshTotal();
$order->balance = $order->customer->balance;
// 是否需要签订协议0否1是
$order->need_agreements = 0;
if ($order->paramedic_id && $order->id != 66685 && $order->project_id != 7 && strtotime($order->created_at) >= strtotime(Orders::AGREEMENT_START_DATE)
&& ($order->orderAgreements->isEmpty() || ($order->orderAgreements->isNotEmpty() && $order->orderAgreements[0]->paramedic_id != $order->paramedic_id))) {
$order->need_agreements = 1;
}
$order->need_agreements = $order->needAgreements();
}
return response()->json($data->toArray());
}
@ -345,11 +341,7 @@ class OrdersController extends CommonController
}
$order->group_by_paramedic = collect($group_by_paramedic);
// 是否需要签订协议0否1是
$order->need_agreements = 0;
if ($order->paramedic_id && $order->id != 66685 && $order->project_id != 7 && strtotime($order->created_at) >= strtotime(Orders::AGREEMENT_START_DATE)
&& ($order->orderAgreements->isEmpty() || ($order->orderAgreements->isNotEmpty() && $order->orderAgreements[0]->paramedic_id != $order->paramedic_id))) {
$order->need_agreements = 1;
}
$order->need_agreements = $order->needAgreements();
if ($ajax === true) {
return response()->json($order->toArray());
}

@ -26,6 +26,20 @@ class Orders extends SoftDeletesModel
protected $appends = ["status_name", "days"];
/**
* 判断是否要签协议
*/
public function needAgreements()
{
if ($this->paramedic_id && $this->project->agreement == 1
&& strtotime($this->created_at) >= strtotime(Orders::AGREEMENT_START_DATE)
&& ($this->orderAgreementByLast()->isEmpty() || ($this->orderAgreementByLast()->isNotEmpty() && $this->orderAgreementByLast()->paramedic_id != $this->paramedic_id))) {
return 1;
}
return 0;
}
public function getStatusLabelAttribute($pure_text = true)
{
switch ($this->status) {

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateProjectAddAgreement extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('project', function (Blueprint $table) {
$table->tinyInteger('agreement')->nullable()->default(1)->comment('是否需要签订协议');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
Loading…
Cancel
Save