|
@@ -10,6 +10,8 @@ namespace App\Models;
|
|
|
|
|
|
class Order extends BaseModel
|
|
class Order extends BaseModel
|
|
{
|
|
{
|
|
|
|
+ protected $appends = ['is_evaluate', 'order_duration'];
|
|
|
|
+
|
|
CONST UNPAID = 1, ISING = 2, FINISHED = 3,CANCELED=4; //订单状态(1.未支付 2.进行中 3.已完成 4.已取消)
|
|
CONST UNPAID = 1, ISING = 2, FINISHED = 3,CANCELED=4; //订单状态(1.未支付 2.进行中 3.已完成 4.已取消)
|
|
public static $_order_status = [
|
|
public static $_order_status = [
|
|
self::UNPAID=>'未支付',
|
|
self::UNPAID=>'未支付',
|
|
@@ -62,7 +64,7 @@ class Order extends BaseModel
|
|
//支付完成的处理方法
|
|
//支付完成的处理方法
|
|
public static function payCompletedHandle($order_id)
|
|
public static function payCompletedHandle($order_id)
|
|
{
|
|
{
|
|
- $order = Order::select(['user_id', 'product_type', 'total_amount', 'payment_type', 'payment_amount'])->where('id', $order_id)->first();
|
|
|
|
|
|
+ $order = Order::select(['user_id', 'docter_id', 'product_type', 'total_amount', 'payment_type', 'payment_amount', 'order_sn'])->where('id', $order_id)->first();
|
|
//发送下单消息
|
|
//发送下单消息
|
|
if ($order['product_type'] < 6) {
|
|
if ($order['product_type'] < 6) {
|
|
$product_type_text = config('config.product_type_map')[$order['product_type']];
|
|
$product_type_text = config('config.product_type_map')[$order['product_type']];
|
|
@@ -81,7 +83,40 @@ class Order extends BaseModel
|
|
$user = User::select(['balance'])->where('id', $order['user_id'])->first();
|
|
$user = User::select(['balance'])->where('id', $order['user_id'])->first();
|
|
UserMessage::saveMessage($order['user_id'], 8, $order_id, [round($order['payment_amount']/100, 2), round($user['balance']/100, 2)]);
|
|
UserMessage::saveMessage($order['user_id'], 8, $order_id, [round($order['payment_amount']/100, 2), round($user['balance']/100, 2)]);
|
|
}
|
|
}
|
|
|
|
+ //发送医生端消息
|
|
|
|
+ DocterMessage::saveMessage($order['docter_id'], $order['user_id'], 1, $order_id, [$order['order_sn']]);
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function suggest()
|
|
|
|
+ {
|
|
|
|
+ return $this->hasOne(Suggest::class)->select(['id', 'order_id']);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function getIsEvaluateAttribute()
|
|
|
|
+ {
|
|
|
|
+ $user = User::getUserByToken();
|
|
|
|
+ $is_evaluate = 0;
|
|
|
|
+ if (Evaluate::where('order_id', $this->id)->where('user_id', $user['id'])->exists()) {
|
|
|
|
+ $is_evaluate = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $is_evaluate;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function getOrderDurationAttribute()
|
|
|
|
+ {
|
|
|
|
+ if (!empty($this->outtime) && !empty($this->receiving_time)) {
|
|
|
|
+ $diff = $this->outtime - $this->receiving_time;
|
|
|
|
+ $hour = round($diff/3600);
|
|
|
|
+ if ($hour == 0) {
|
|
|
|
+ return round($diff/60).'分钟';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $hour.'小时';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return '';
|
|
|
|
+ }
|
|
}
|
|
}
|