model = Db::name('sms'); } /** * 发送短息 * @return void */ public function send($params=[]) { $result = [ 'status' => 1, 'msg' => '操作成功', 'data' => [], ]; try { $dataParams = isset($params['data_params']) ? $params['data_params'] : []; //配置 $config = config('alisms'); if (isset($params['template'])) { $config['template'] = $params['template']; } $alisms = new Alisms(); $result = $alisms->mobile($params['mobile']) ->template($config['template']) ->param($dataParams) ->send(); if (!$result) { throw new Exception('发送消息失败'); } } catch (Exception $e) { $result['status'] = 0; $result['msg'] = $e->getMessage(); } return $result; } /** * 保养提醒保存 * @return void */ public function carRemindSave($params=[]) { $result = [ 'status' => 1, 'msg' => '操作成功', 'data' => [], ]; try { $orderId = isset($params['order_id']) ? $params['order_id'] : 0; $companyId = isset($params['company_id']) ? $params['company_id'] : 0; $userId = isset($params['user_id']) ? $params['user_id'] : 0; $carId = isset($params['car_id']) ? $params['car_id'] : 0; $carNo = isset($params['car_number']) ? $params['car_number'] : ''; $upkeepTime = isset($params['upkeep_time']) ? $params['upkeep_time'] : 0; $remindTime = !empty($upkeepTime) ? $upkeepTime - 86400 : 0; $time = time(); if ($remindTime > 0 && $upkeepTime > $time) { $data = [ 'order_id' => $orderId, //订单ID 'company_id' => $companyId, //门店ID 'user_id' => $userId, //用户ID 'car_id' => $carId, //车辆ID 'car_number' => $carNo, //车牌号 'upkeep_time' => $upkeepTime,//保养时间 'remind_time' => $remindTime,//提醒时间 ]; $remindWhere['user_id'] = $userId; $remindWhere['company_id'] = $companyId; $remindWhere['car_id'] = $carId; $userCarRemind = Db::name('user_car_remind')->where($remindWhere)->find(); if (!empty($userCarRemind)) { if ($upkeepTime != $userCarRemind['upkeep_time']) { $data['is_remind'] = 0; $data['updatetime'] = $time; $result = Db::name('user_car_remind')->where($remindWhere)->update($data); if (!$result) { throw new Exception('更新保养提醒失败'); } } } else { $data['createtime'] = $time; $result = Db::name('user_car_remind')->insertGetId($data); if (!$result) { throw new Exception('记录保养提醒失败'); } } } } catch (Exception $e) { $result['status'] = 0; $result['msg'] = $e->getMessage(); } return $result; } }