| xqd
@@ -10,7 +10,7 @@ namespace App\Models;
|
|
|
|
|
|
class Order extends BaseModel
|
|
|
{
|
|
|
- protected $appends = ['is_evaluate', 'order_duration'];
|
|
|
+ protected $appends = ['is_evaluate', 'order_duration', 'consult_duration', 'callback_phone'];
|
|
|
|
|
|
CONST UNPAID = 1, NOTACCEPT = 2, ISING = 3, FINISHED = 4,CANCELED=5,ISOUT=6; //订单状态(1.未支付 2.进行中 3.已完成 4.已取消)
|
|
|
public static $_order_status = [
|
| xqd
@@ -44,7 +44,7 @@ class Order extends BaseModel
|
|
|
* Create By 2020/11/18 11:06
|
|
|
*/
|
|
|
public function userDocter(){
|
|
|
- return $this->hasOne(UserDocter::class,'user_id','user_id')->select(['id', 'remark']);;
|
|
|
+ return $this->hasOne(UserDocter::class,'user_id','user_id')->select(['id', 'remark']);
|
|
|
}
|
|
|
|
|
|
public function patients(){
|
| xqd
@@ -120,10 +120,10 @@ class Order extends BaseModel
|
|
|
OrderPack::deductPackData($order['pay_order_pack_id'], $order['product_type'], $order['payment_amount']);
|
|
|
}
|
|
|
|
|
|
- if (!empty($order['docter_id'])) {
|
|
|
+ /* if (!empty($order['docter_id'])) {
|
|
|
//更新医生的服务人数
|
|
|
Docter::where('id', $order['docter_id'])->increment('service_persons');
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
//如果是门诊预约,预约时间段的订单数要加1
|
|
|
if ($order['product_type'] == 3) {
|
| xqd
@@ -132,6 +132,12 @@ class Order extends BaseModel
|
|
|
SchedulePeriod::where('docter_id', $order['docter_id'])->where('organization_id', $order['organization_id'])->where('time_period_id', $orderPatient['time_period_id'])->where('schedule_date', $schedule_date)->increment('order_num');
|
|
|
}
|
|
|
|
|
|
+ //如果是疫苗就减少疫苗库存
|
|
|
+ if ($order['product_type'] == 4) {
|
|
|
+ $orderVaccine = OrderVaccine::where('order_id', $order_id)->first();
|
|
|
+ OrganizationVaccine::where('org_id', $order['organization_id'])->where('vaccine_id', $orderVaccine['vaccine_id'])->decrement('stock');
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
| xqd
@@ -188,4 +194,28 @@ class Order extends BaseModel
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ public function getConsultDurationAttribute()
|
|
|
+ {
|
|
|
+ $duration = 0;
|
|
|
+ if ($this->product_type == 1) {
|
|
|
+ $duration = CallLog::where('order_id', $this->id)->where('talk_time', '<>', null)->sum('talk_time');
|
|
|
+ $duration = !empty($duration) ? $duration : 0;
|
|
|
+ }
|
|
|
+ elseif ($this->product_type == 2) {
|
|
|
+ $duration = $this->end_time - $this->receiving_time;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $duration > 0 ? $duration : 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getCallbackPhoneAttribute()
|
|
|
+ {
|
|
|
+ $secret_no = '';
|
|
|
+ if ($this->product_type == 1) {
|
|
|
+ $secret_no = CallLog::where('order_id', $this->id)->orderBy('id', 'desc')->value('secret_no');
|
|
|
+ }
|
|
|
+
|
|
|
+ return !empty($secret_no) ? $secret_no : '';
|
|
|
+ }
|
|
|
}
|