| xqd
@@ -100,12 +100,6 @@ class Notification extends BaseModel
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public static function createAndSend($data)
|
|
|
- {
|
|
|
- $item = Notification::create($data);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 租赁时间到期 status = 4
|
|
|
* @param $id
|
| xqd
@@ -133,26 +127,87 @@ class Notification extends BaseModel
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ public static function createAndSend($data)
|
|
|
+ {
|
|
|
+ $item = Notification::create($data);
|
|
|
+ $content = $item->getNameContent();
|
|
|
+ $user = User::find($data['user_id']);
|
|
|
+ $official_app = app('wechat.official_account.default');
|
|
|
+ if($content && isset($content['official']) && $user && $user['official_open_id']) {
|
|
|
+ $info = $content['official'];
|
|
|
+ $official_app->template_message->send([
|
|
|
+ 'touser' => $user['official_open_id'],
|
|
|
+ 'template_id' => $info['template_id'],
|
|
|
+ 'miniprogram' => [
|
|
|
+ 'appid' => env('WECHAT_MINI_PROGRAM_APPID'),
|
|
|
+ 'pagepath' => $info['page'],
|
|
|
+ ],
|
|
|
+ 'data' => $info['data'],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function getNameContent()
|
|
|
{
|
|
|
+ $order = Order::find($this['order_id']);
|
|
|
+ $status_name = $order ? $order->getStatusName() : '';
|
|
|
+ $source = ($order->project ? $order->project->name : '') . '-' . ($order->workPoint ? $order->workPoint->name : '') . '-' . ($order->user ? $order->user->name : '');
|
|
|
if($this['type'] == 1) {
|
|
|
+ $detail = OrderDevice::where('order_id', $order->id)->count() . '个设备,¥' . ($order->money / 100);
|
|
|
+ $type = '设备租赁订单';
|
|
|
if($this['status'] == 1) {
|
|
|
return [
|
|
|
'name' => '租赁审批成功通知',
|
|
|
- 'content' => '你的设备租赁申请已通过,请确认相关信息:'
|
|
|
+ 'content' => '你的设备租赁申请已通过,请确认相关信息:',
|
|
|
+ 'official' => [
|
|
|
+ 'template_id' => 'dlRsvUWqeziBvGbdT89b69slvZll6gZVRCotIXCwwjM',
|
|
|
+ 'page' => 'pages/order-detail/index?id=' . $this['order_id'],
|
|
|
+ 'data' => [
|
|
|
+ 'first' => '您有一个订单已通过审核,请注意查看!',
|
|
|
+ 'keyword1' => $this['created_at'],
|
|
|
+ 'keyword2' => $type,
|
|
|
+ 'keyword3' => $status_name,
|
|
|
+ 'keyword4' => $source,
|
|
|
+ 'keyword5' => $detail,
|
|
|
+ 'remark' => '点击进入小程序查看详情。',
|
|
|
+ ]
|
|
|
+ ]
|
|
|
];
|
|
|
} else if($this['status'] == 2) {
|
|
|
return [
|
|
|
'name' => '租赁审批待处理通知',
|
|
|
'content' => '你有一条设备租赁申请待审批,请确认相关信息:',
|
|
|
'official' => [
|
|
|
- 'template_id'
|
|
|
+ 'template_id' => 'dlRsvUWqeziBvGbdT89b69slvZll6gZVRCotIXCwwjM',
|
|
|
+ 'page' => 'pages/order-detail/index?id=' . $this['order_id'],
|
|
|
+ 'data' => [
|
|
|
+ 'first' => '您有一条待审核的订单,请注意查看!',
|
|
|
+ 'keyword1' => $this['created_at'],
|
|
|
+ 'keyword2' => $type,
|
|
|
+ 'keyword3' => $status_name,
|
|
|
+ 'keyword4' => $source,
|
|
|
+ 'keyword5' => $detail,
|
|
|
+ 'remark' => '点击进入小程序查看详情,请及时处理。',
|
|
|
+ ]
|
|
|
]
|
|
|
];
|
|
|
} else if($this['status'] == 3) {
|
|
|
return [
|
|
|
'name' => '租赁审批驳回通知',
|
|
|
- 'content' => '你有一条设备租赁申请被驳回,请确认相关信息:'
|
|
|
+ 'content' => '你有一条设备租赁申请被驳回,请确认相关信息:',
|
|
|
+ 'official' => [
|
|
|
+ 'template_id' => 'dlRsvUWqeziBvGbdT89b69slvZll6gZVRCotIXCwwjM',
|
|
|
+ 'page' => 'pages/order-detail/index?id=' . $this['order_id'],
|
|
|
+ 'data' => [
|
|
|
+ 'first' => '您有一个订单已被驳回,请注意查看!',
|
|
|
+ 'keyword1' => $this['created_at'],
|
|
|
+ 'keyword2' => $type,
|
|
|
+ 'keyword3' => $status_name,
|
|
|
+ 'keyword4' => $source,
|
|
|
+ 'keyword5' => $detail,
|
|
|
+ 'remark' => '点击进入小程序查看详情,请及时处理。',
|
|
|
+ ]
|
|
|
+ ]
|
|
|
];
|
|
|
} else if($this['status'] == 4) {
|
|
|
return [
|
| xqd
@@ -162,24 +217,78 @@ class Notification extends BaseModel
|
|
|
} else if($this['status'] == 5) {
|
|
|
return [
|
|
|
'name' => '租赁完成通知',
|
|
|
- 'content' => '你有一条设备租赁已完成消息,请确认相关信息:'
|
|
|
+ 'content' => '你有一条设备租赁已完成消息,请确认相关信息:',
|
|
|
+ 'official' => [
|
|
|
+ 'template_id' => 'dlRsvUWqeziBvGbdT89b69slvZll6gZVRCotIXCwwjM',
|
|
|
+ 'page' => 'pages/order-detail/index?id=' . $this['order_id'],
|
|
|
+ 'data' => [
|
|
|
+ 'first' => '有一个订单已完成,请注意查看!',
|
|
|
+ 'keyword1' => $this['created_at'],
|
|
|
+ 'keyword2' => $type,
|
|
|
+ 'keyword3' => $status_name,
|
|
|
+ 'keyword4' => $source,
|
|
|
+ 'keyword5' => $detail,
|
|
|
+ 'remark' => '点击进入小程序查看详情。',
|
|
|
+ ]
|
|
|
+ ]
|
|
|
];
|
|
|
}
|
|
|
} else {
|
|
|
+ $detail = OrderDevice::where('order_id', $order->id)->count() . '个设备';
|
|
|
+ $type = '设备调用订单';
|
|
|
if($this['status'] == 1) {
|
|
|
return [
|
|
|
'name' => '调用审批成功通知',
|
|
|
- 'content' => '你的设备调用申请已通过,请确认相关信息:'
|
|
|
+ 'content' => '你的设备调用申请已通过,请确认相关信息:',
|
|
|
+ 'official' => [
|
|
|
+ 'template_id' => 'dlRsvUWqeziBvGbdT89b69slvZll6gZVRCotIXCwwjM',
|
|
|
+ 'page' => 'pages/order-detail/index?id=' . $this['order_id'],
|
|
|
+ 'data' => [
|
|
|
+ 'first' => '您有一个订单已通过审核,请注意查看!',
|
|
|
+ 'keyword1' => $this['created_at'],
|
|
|
+ 'keyword2' => $type,
|
|
|
+ 'keyword3' => $status_name,
|
|
|
+ 'keyword4' => $source,
|
|
|
+ 'keyword5' => $detail,
|
|
|
+ 'remark' => '点击进入小程序查看详情。',
|
|
|
+ ]
|
|
|
+ ]
|
|
|
];
|
|
|
} else if($this['status'] == 2) {
|
|
|
return [
|
|
|
'name' => '调用审批待处理通知',
|
|
|
- 'content' => '你有一条设备调用申请待审批,请确认相关信息:'
|
|
|
+ 'content' => '你有一条设备调用申请待审批,请确认相关信息:',
|
|
|
+ 'official' => [
|
|
|
+ 'template_id' => 'dlRsvUWqeziBvGbdT89b69slvZll6gZVRCotIXCwwjM',
|
|
|
+ 'page' => 'pages/order-detail/index?id=' . $this['order_id'],
|
|
|
+ 'data' => [
|
|
|
+ 'first' => '您有一条待审核的订单,请注意查看!',
|
|
|
+ 'keyword1' => $this['created_at'],
|
|
|
+ 'keyword2' => $type,
|
|
|
+ 'keyword3' => $status_name,
|
|
|
+ 'keyword4' => $source,
|
|
|
+ 'keyword5' => $detail,
|
|
|
+ 'remark' => '点击进入小程序查看详情,请及时处理。',
|
|
|
+ ]
|
|
|
+ ]
|
|
|
];
|
|
|
} else if($this['status'] == 3) {
|
|
|
return [
|
|
|
'name' => '调用审批驳回通知',
|
|
|
- 'content' => '你有一条设备调用申请被驳回,请确认相关信息:'
|
|
|
+ 'content' => '你有一条设备调用申请被驳回,请确认相关信息:',
|
|
|
+ 'official' => [
|
|
|
+ 'template_id' => 'dlRsvUWqeziBvGbdT89b69slvZll6gZVRCotIXCwwjM',
|
|
|
+ 'page' => 'pages/order-detail/index?id=' . $this['order_id'],
|
|
|
+ 'data' => [
|
|
|
+ 'first' => '您有一个订单已被驳回,请注意查看!',
|
|
|
+ 'keyword1' => $this['created_at'],
|
|
|
+ 'keyword2' => $type,
|
|
|
+ 'keyword3' => $status_name,
|
|
|
+ 'keyword4' => $source,
|
|
|
+ 'keyword5' => $detail,
|
|
|
+ 'remark' => '点击进入小程序查看详情,请及时处理。',
|
|
|
+ ]
|
|
|
+ ]
|
|
|
];
|
|
|
} else if($this['status'] == 4) {
|
|
|
return [
|
| xqd
@@ -189,7 +298,20 @@ class Notification extends BaseModel
|
|
|
} else if($this['status'] == 5) {
|
|
|
return [
|
|
|
'name' => '调用完成通知',
|
|
|
- 'content' => '你有一条设备调用已完成消息,请确认相关信息:'
|
|
|
+ 'content' => '你有一条设备调用已完成消息,请确认相关信息:',
|
|
|
+ 'official' => [
|
|
|
+ 'template_id' => 'dlRsvUWqeziBvGbdT89b69slvZll6gZVRCotIXCwwjM',
|
|
|
+ 'page' => 'pages/order-detail/index?id=' . $this['order_id'],
|
|
|
+ 'data' => [
|
|
|
+ 'first' => '有一个订单已完成,请注意查看!',
|
|
|
+ 'keyword1' => $this['created_at'],
|
|
|
+ 'keyword2' => $type,
|
|
|
+ 'keyword3' => $status_name,
|
|
|
+ 'keyword4' => $source,
|
|
|
+ 'keyword5' => $detail,
|
|
|
+ 'remark' => '点击进入小程序查看详情。',
|
|
|
+ ]
|
|
|
+ ]
|
|
|
];
|
|
|
} else if($this['status'] == 6) {
|
|
|
return [
|