当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayToolkit::requireds方法代码示例

本文整理汇总了PHP中Topxia\Common\ArrayToolkit::requireds方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayToolkit::requireds方法的具体用法?PHP ArrayToolkit::requireds怎么用?PHP ArrayToolkit::requireds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Topxia\Common\ArrayToolkit的用法示例。


在下文中一共展示了ArrayToolkit::requireds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: uploadMaterial

 public function uploadMaterial($material)
 {
     if (!ArrayToolkit::requireds($material, array('courseId', 'fileId'))) {
         throw $this->createServiceException('参数缺失,上传失败!');
     }
     $course = $this->getCourseService()->getCourse($material['courseId']);
     if (empty($course)) {
         throw $this->createServiceException('课程不存在,上传资料失败!');
     }
     $fields = array('courseId' => $material['courseId'], 'lessonId' => empty($material['lessonId']) ? 0 : $material['lessonId'], 'description' => empty($material['description']) ? '' : $material['description'], 'userId' => $this->getCurrentUser()->id, 'createdTime' => time());
     if (empty($material['fileId'])) {
         if (empty($material['link'])) {
             throw $this->createServiceException('资料链接地址不能为空,添加资料失败!');
         }
         $fields['fileId'] = 0;
         $fields['link'] = $material['link'];
         $fields['title'] = empty($material['description']) ? $material['link'] : $material['description'];
     } else {
         $fields['fileId'] = (int) $material['fileId'];
         $file = $this->getUploadFileService()->getFile($material['fileId']);
         if (empty($file)) {
             throw $this->createServiceException('文件不存在,上传资料失败!');
         }
         $fields['link'] = '';
         $fields['title'] = $file['filename'];
         $fields['fileSize'] = $file['size'];
     }
     $material = $this->getMaterialDao()->addMaterial($fields);
     $this->getCourseService()->increaseLessonMaterialCount($fields['lessonId']);
     return $material;
 }
开发者ID:styling,项目名称:LeesPharm,代码行数:31,代码来源:MaterialServiceImpl.php

示例2: createOrder

 public function createOrder($info)
 {
     $user = $this->getCurrentUser();
     if (!$user->isLogin()) {
         throw $this->createServiceException('用户未登录,不能创建订单');
     }
     if (!ArrayToolkit::requireds($info, array('targetId'))) {
         throw $this->createServiceException('订单数据缺失,创建资料交换失败。');
     }
     // 获得锁
     $user = $this->getUserService()->getUser($user['id'], true);
     $exchange = $this->getExchangeService()->getExchange($info['targetId']);
     if (empty($exchange)) {
         throw $this->createServiceException('资料不存在,操作失败。');
     }
     $order = array();
     $order['title'] = "兑换资料《{$exchange['title']}》";
     $order['sn'] = $this->generateOrderSn($order);
     $order['userId'] = $info['userId'];
     $order['targetType'] = $info['targetType'];
     $order['targetId'] = $info['targetId'];
     $order['payment'] = $info['payment'];
     $order['totalPoints'] = $info["totalPoints"];
     $order['status'] = 'created';
     $order['createdTime'] = time();
     if (!empty($info['note'])) {
         $order['data'] = array('note' => $info['note']);
     }
     $order = $this->getExchangeOrdersDao()->addOrder($order);
     if (empty($order)) {
         throw $this->createServiceException('创建资料兑换订单失败!');
     }
     // $this->_createLog($order['id'], 'created', '创建订单');
     return $order;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:35,代码来源:ExchangeOrdersServiceImpl.php

示例3: createOrder

 public function createOrder($order)
 {
     if (!ArrayToolkit::requireds($order, array('userId', 'title', 'amount', 'targetType', 'targetId', 'payment'))) {
         throw $this->createServiceException('创建订单失败:缺少参数。');
     }
     $order = ArrayToolkit::parts($order, array('userId', 'title', 'amount', 'targetType', 'targetId', 'payment', 'note', 'snPrefix', 'data', 'couponCode', 'coinAmount', 'coinRate', 'priceType', 'totalPrice', 'coupon', 'couponDiscount', 'discountId', 'discount'));
     $orderUser = $this->getUserService()->getUser($order['userId']);
     if (empty($orderUser)) {
         throw $this->createServiceException("订单用户(#{$order['userId']})不存在,不能创建订单。");
     }
     if (!in_array($order['payment'], array('none', 'alipay', 'alipaydouble', 'tenpay', 'coin'))) {
         throw $this->createServiceException('创建订单失败:payment取值不正确。');
     }
     $order['sn'] = $this->generateOrderSn($order);
     unset($order['snPrefix']);
     if (!empty($order['couponCode'])) {
         $couponInfo = $this->getCouponService()->checkCouponUseable($order['couponCode'], $order['targetType'], $order['targetId'], $order['amount']);
         if ($couponInfo['useable'] != 'yes') {
             throw $this->createServiceException("优惠码不可用");
         }
     }
     unset($order['couponCode']);
     $order['amount'] = number_format($order['amount'], 2, '.', '');
     if (intval($order['amount'] * 100) == 0) {
         $order['payment'] = 'none';
     }
     $order['status'] = 'created';
     $order['createdTime'] = time();
     $order = $this->getOrderDao()->addOrder($order);
     $this->_createLog($order['id'], 'created', '创建订单');
     return $order;
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:32,代码来源:OrderServiceImpl.php

示例4: filterTestpaperFields

 protected function filterTestpaperFields($fields, $mode = 'create')
 {
     $filtedFields = array();
     $filtedFields['updatedUserId'] = $this->getCurrentUser()->id;
     $filtedFields['updatedTime'] = time();
     if ($mode == 'create') {
         if (!ArrayToolkit::requireds($fields, array('name', 'pattern', 'target'))) {
             throw $this->createServiceException('缺少必要字段!');
         }
         $filtedFields['name'] = $fields['name'];
         $filtedFields['target'] = $fields['target'];
         $filtedFields['pattern'] = $fields['pattern'];
         $filtedFields['description'] = empty($fields['description']) ? '' : $fields['description'];
         $filtedFields['limitedTime'] = empty($fields['limitedTime']) ? 0 : (int) $fields['limitedTime'];
         $filtedFields['metas'] = empty($fields['metas']) ? array() : $fields['metas'];
         $filtedFields['status'] = 'draft';
         $filtedFields['createdUserId'] = $this->getCurrentUser()->id;
         $filtedFields['createdTime'] = time();
     } else {
         if (array_key_exists('name', $fields)) {
             $filtedFields['name'] = empty($fields['name']) ? '' : $fields['name'];
         }
         if (array_key_exists('description', $fields)) {
             $filtedFields['description'] = empty($fields['description']) ? '' : $fields['description'];
         }
         if (array_key_exists('limitedTime', $fields)) {
             $filtedFields['limitedTime'] = empty($fields['limitedTime']) ? 0 : (int) $fields['limitedTime'];
         }
         if (array_key_exists('passedScore', $fields)) {
             $filtedFields['passedScore'] = empty($fields['passedScore']) ? 0 : (double) $fields['passedScore'];
         }
     }
     return $filtedFields;
 }
开发者ID:nanyi,项目名称:EduSoho,代码行数:34,代码来源:TestpaperServiceImpl.php

示例5: saveNote

 /**
  *类似这样的,提交数据保存到数据的流程是:
  *
  *  1. 检查参数是否正确,不正确就抛出异常
  *  2. 过滤数据
  *  3. 插入到数据库
  *  4. 更新其他相关的缓存字段
  */
 public function saveNote(array $note)
 {
     if (!ArrayToolkit::requireds($note, array('lessonId', 'courseId', 'content'))) {
         throw $this->createServiceException('缺少必要的字段,保存笔记失败');
     }
     list($course, $member) = $this->getCourseService()->tryTakeCourse($note['courseId']);
     $user = $this->getCurrentUser();
     if (!$this->getCourseService()->getCourseLesson($note['courseId'], $note['lessonId'])) {
         throw $this->createServiceException('课时不存在,保存笔记失败');
     }
     $note = ArrayToolkit::filter($note, array('courseId' => 0, 'lessonId' => 0, 'content' => '', 'status' => 0));
     $note['content'] = $this->purifyHtml($note['content']) ?: '';
     $note['length'] = $this->calculateContnentLength($note['content']);
     $existNote = $this->getUserLessonNote($user['id'], $note['lessonId']);
     if (!$existNote) {
         $note['userId'] = $user['id'];
         $note['createdTime'] = time();
         $note['updatedTime'] = time();
         $note = $this->getNoteDao()->addNote($note);
         $this->getDispatcher()->dispatch('course.note.create', new ServiceEvent($note));
     } else {
         $note['updatedTime'] = time();
         $note = $this->getNoteDao()->updateNote($existNote['id'], $note);
         $this->getDispatcher()->dispatch('course.note.update', new ServiceEvent($note, array('preStatus' => $existNote['status'])));
     }
     $this->getCourseService()->setMemberNoteNumber($note['courseId'], $note['userId'], $this->getNoteDao()->getNoteCountByUserIdAndCourseId($note['userId'], $note['courseId']));
     return $note;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:36,代码来源:NoteServiceImpl.php

示例6: createOrder

 public function createOrder($info)
 {
     $connection = ServiceKernel::instance()->getConnection();
     try {
         $connection->beginTransaction();
         $user = $this->getCurrentUser();
         if (!$user->isLogin()) {
             throw $this->createServiceException('用户未登录,不能创建订单');
         }
         if (!ArrayToolkit::requireds($info, array('targetId', 'payment'))) {
             throw $this->createServiceException('订单数据缺失,创建课程订单失败。');
         }
         // 获得锁
         $user = $this->getUserService()->getUser($user['id'], true);
         if ($this->getClassroomService()->isClassroomStudent($info['targetId'], $user['id'])) {
             throw $this->createServiceException('已经是班级学员,创建订单失败。');
         }
         $classroom = $this->getClassroomService()->getClassroom($info['targetId']);
         if (empty($classroom)) {
             throw $this->createServiceException('班级不存在,创建课程订单失败。');
         }
         if ($classroom['private'] == 1) {
             throw $this->createServiceException('该班级是封闭班级,学员不能自行加入!');
         }
         $order = array();
         $order['userId'] = $user['id'];
         $order['title'] = "购买班级《{$classroom['title']}》";
         $order['targetType'] = 'classroom';
         $order['targetId'] = $classroom['id'];
         $order['payment'] = $info['payment'];
         $order['amount'] = empty($info['amount']) ? 0 : $info['amount'];
         $order['priceType'] = $info['priceType'];
         $order['totalPrice'] = $info["totalPrice"];
         $order['coinRate'] = $info['coinRate'];
         $order['coinAmount'] = $info['coinAmount'];
         $order['snPrefix'] = 'CR';
         if (!empty($info['note'])) {
             $order['data'] = array('note' => $info['note']);
         }
         if (!empty($info['coupon'])) {
             $order['coupon'] = $info['coupon'];
             $order['couponDiscount'] = $info['couponDiscount'];
         }
         $order = $this->getOrderService()->createOrder($order);
         if (empty($order)) {
             throw $this->createServiceException('创建订单失败!');
         }
         // 免费班级,就直接将订单置为已购买
         if (intval($order['amount'] * 100) == 0 && intval($order['coinAmount'] * 100) == 0 && empty($order['coupon'])) {
             list($success, $order) = $this->getOrderService()->payOrder(array('sn' => $order['sn'], 'status' => 'success', 'amount' => $order['amount'], 'paidTime' => time()));
             $info = array('orderId' => $order['id'], 'remark' => empty($order['data']['note']) ? '' : $order['data']['note']);
             $this->getClassroomService()->becomeStudent($order['targetId'], $order['userId'], $info);
         }
         $connection->commit();
         return $order;
     } catch (\Exception $e) {
         $connection->rollBack();
         throw $e;
     }
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:60,代码来源:ClassroomOrderServiceImpl.php

示例7: becomeStudentAndCreateOrder

 public function becomeStudentAndCreateOrder($userId, $courseId, $data)
 {
     if (!ArrayToolkit::requireds($data, array("price", "remark"))) {
         throw $this->createServiceException("参数不对!");
     }
     $user = $this->getUserService()->getUser($userId);
     if (empty($user)) {
         throw $this->createNotFoundException("用户{$user['nickname']}不存在");
     }
     $course = $this->getCourseService()->getCourse($courseId);
     if (empty($course)) {
         throw $this->createNotFoundException("课程{$course['title']}不存在");
     }
     if ($this->getCourseService()->isCourseStudent($course['id'], $user['id'])) {
         throw $this->createNotFoundException("用户已经是学员,不能添加!");
     }
     $orderTitle = "购买课程《{$course['title']}》";
     if (isset($data["isAdminAdded"]) && $data["isAdminAdded"] == 1) {
         $orderTitle = $orderTitle . "(管理员添加)";
     }
     $order = $this->getOrderService()->createOrder(array('userId' => $user['id'], 'title' => $orderTitle, 'targetType' => 'course', 'targetId' => $course['id'], 'amount' => $data['price'], 'totalPrice' => $data['price'], 'payment' => 'none', 'snPrefix' => 'C'));
     $this->getOrderService()->payOrder(array('sn' => $order['sn'], 'status' => 'success', 'amount' => $order['amount'], 'paidTime' => time()));
     $info = array('orderId' => $order['id'], 'note' => $data['remark']);
     $this->getCourseService()->becomeStudent($order['targetId'], $order['userId'], $info);
     $member = $this->getCourseService()->getCourseMember($course['id'], $user['id']);
     if (isset($data["isAdminAdded"]) && $data["isAdminAdded"] == 1) {
         $this->getNotificationService()->notify($member['userId'], 'student-create', array('courseId' => $course['id'], 'courseTitle' => $course['title']));
     }
     $this->getLogService()->info('course', 'add_student', "课程《{$course['title']}》(#{$course['id']}),添加学员{$user['nickname']}(#{$user['id']}),备注:{$data['remark']}");
     return array($course, $member, $order);
 }
开发者ID:latticet,项目名称:EduSoho_jb51,代码行数:31,代码来源:CourseMemberServiceImpl.php

示例8: addFile

 public function addFile($targetType, $targetId, array $fileInfo = array(), UploadedFile $originalFile = null)
 {
     if (!ArrayToolkit::requireds($fileInfo, array('filename', 'key', 'size'))) {
         throw $this->createServiceException('参数缺失,添加用户文件失败!');
     }
     $uploadFile = array();
     $uploadFile['targetId'] = $targetId;
     $uploadFile['targetType'] = $targetType;
     $uploadFile['hashId'] = $fileInfo['key'];
     $uploadFile['filename'] = $fileInfo['filename'];
     $uploadFile['ext'] = pathinfo($uploadFile['filename'], PATHINFO_EXTENSION);
     $uploadFile['size'] = (int) $fileInfo['size'];
     $uploadFile['etag'] = empty($fileInfo['etag']) ? '' : $fileInfo['etag'];
     $uploadFile['length'] = empty($fileInfo['length']) ? 0 : intval($fileInfo['length']);
     $uploadFile['metas'] = $this->encodeMetas(empty($fileInfo['metas']) ? array() : $fileInfo['metas']);
     $uploadFile['metas2'] = $this->encodeMetas(empty($fileInfo['metas2']) ? array() : $fileInfo['metas2']);
     if (empty($fileInfo['convertHash'])) {
         $uploadFile['convertHash'] = "ch-{$uploadFile['hashId']}";
         $uploadFile['convertStatus'] = 'none';
         $uploadFile['convertParams'] = '';
     } else {
         $uploadFile['convertHash'] = "{$fileInfo['convertHash']}";
         $uploadFile['convertStatus'] = 'waiting';
         $uploadFile['convertParams'] = $fileInfo['convertParams'];
     }
     $uploadFile['type'] = FileToolkit::getFileTypeByMimeType($fileInfo['mimeType']);
     $uploadFile['canDownload'] = empty($uploadFile['canDownload']) ? 0 : 1;
     $uploadFile['storage'] = 'cloud';
     $uploadFile['createdUserId'] = $this->getCurrentUser()->id;
     $uploadFile['updatedUserId'] = $uploadFile['createdUserId'];
     $uploadFile['updatedTime'] = $uploadFile['createdTime'] = time();
     return $uploadFile;
 }
开发者ID:styling,项目名称:LeesPharm,代码行数:33,代码来源:CloudFileImplementorImpl.php

示例9: addCard

 public function addCard($card)
 {
     if (!ArrayToolkit::requireds($card, array('cardType', 'cardId', 'deadline', 'userId'))) {
         throw $this->createServiceException('缺少必要字段,新创建卡失败!');
     }
     $card['createdTime'] = time();
     return $this->getCardDao()->addCard($card);
 }
开发者ID:robert-li-2015,项目名称:EduSoho,代码行数:8,代码来源:CardServiceImpl.php

示例10: shouldPayAmount

 public function shouldPayAmount($targetId, $priceType, $cashRate, $coinEnabled, $orderData)
 {
     if (!ArrayToolkit::requireds($orderData, array('buyType', 'targetId', 'unitType', 'duration'))) {
         throw new Exception('订单数据缺失,创建会员订单失败。');
     }
     if (!in_array($orderData['buyType'], array('new', 'renew', 'upgrade'))) {
         throw new Exception('购买类型不正确,创建会员订单失败。');
     }
     if (!(array_key_exists("buyType", $orderData) && $orderData["buyType"] == "upgrade")) {
         $orderData['duration'] = intval($orderData['duration']);
         if (empty($orderData['duration'])) {
             throw new Exception('会员开通时长不正确,创建会员订单失败。');
         }
         if (!in_array($orderData['unitType'], array('month', 'year'))) {
             throw new Exception('付费方式不正确,创建会员订单失败。');
         }
     }
     $level = $this->getLevelService()->getLevel($orderData['targetId']);
     if (empty($level)) {
         throw new Exception('会员等级不存在,创建会员订单失败。');
     }
     if (empty($level['enabled'])) {
         throw new Exception('会员等级已关闭,创建会员订单失败。');
     }
     $currentUser = $this->getLevelService()->getCurrentUser();
     if (array_key_exists("buyType", $orderData) && $orderData["buyType"] == "upgrade") {
         $totalPrice = $this->getVipService()->calUpgradeMemberAmount($currentUser->id, $level['id']);
     } else {
         $unitPrice = $level[$orderData['unitType'] . 'Price'];
         if ($priceType == "Coin") {
             $unitPrice = NumberToolkit::roundUp($unitPrice * $cashRate);
         }
         $totalPrice = $unitPrice * $orderData['duration'];
     }
     $amount = $totalPrice;
     //优惠码优惠价格
     $couponApp = $this->getAppService()->findInstallApp("Coupon");
     $couponSetting = $this->getSettingService()->get("coupon");
     if (!empty($couponApp) && isset($couponSetting["enabled"]) && $couponSetting["enabled"] == 1 && $orderData["couponCode"] && trim($orderData["couponCode"]) != "") {
         $couponResult = $this->afterCouponPay($orderData["couponCode"], 'vip', $targetId, $totalPrice, $priceType, $cashRate);
         if (isset($couponResult["useable"]) && $couponResult["useable"] == "yes" && isset($couponResult["afterAmount"])) {
             $amount = $couponResult["afterAmount"];
         }
     }
     //虚拟币优惠价格
     if (array_key_exists("coinPayAmount", $orderData)) {
         $amount = $this->afterCoinPay($coinEnabled, $priceType, $cashRate, $amount, $orderData['coinPayAmount'], $orderData["payPassword"]);
     }
     if ($priceType == "Coin") {
         $amount = $amount / $cashRate;
     }
     if ($amount <= 0) {
         $amount = 0;
     }
     $totalPrice = NumberToolkit::roundUp($totalPrice);
     $amount = NumberToolkit::roundUp($amount);
     return array($amount, $totalPrice, empty($couponResult) ? null : $couponResult);
 }
开发者ID:latticet,项目名称:EduSoho_jb51,代码行数:58,代码来源:VipOrderProcessor.php

示例11: createAttribute

 public function createAttribute($attribute)
 {
     if (!ArrayToolkit::requireds($attribute, array('productId', 'attrId', 'attrValue'))) {
         throw $this->createServiceException("缺少必要参数,,添加属性失败");
     }
     $this->_filterAttributeFields($attribute);
     $attribute = $this->getProductAttributeDao()->addAttribute($attribute);
     //   $this->getLogService()->info('attribute', 'create', "添加栏目 {$attribute['name']}(#{$attribute['id']})", $attribute);
     return $attribute;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:10,代码来源:ProductAttributeServiceImpl.php

示例12: createProduct

 public function createProduct($fields)
 {
     if (!ArrayToolkit::requireds($fields, array('name'))) {
         throw $this->createServiceException('缺少必要字段,创建课程失败!');
     }
     $fields = ArrayToolkit::parts($fields, array('name', 'price', 'categoryId', 'userId'));
     $fields['productDetail'] = !empty($fields['productDetail']) ? $this->purifyHtml($fields['productDetail']) : '';
     $fields['userId'] = $this->getCurrentUser()->id;
     $fields['createdTime'] = time();
     $product = $this->getCourseDao()->addProduct(ProductSerialize::serialize($fields));
     return $product;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:12,代码来源:ProductServiceImpl.php

示例13: createExchange

 public function createExchange($exchange)
 {
     if (!ArrayToolkit::requireds($exchange, array('title', 'points', 'about'))) {
         throw $this->createServiceException('缺少必要字段,添加交换物品失败!');
     }
     $exchange['about'] = !empty($exchange['about']) ? $this->purifyHtml($exchange['about']) : '';
     $exchange['createdTime'] = time();
     $exchange['userId'] = $this->getCurrentUser()->id;
     $exchange = $this->getExchangeDao()->addExchange($exchange);
     $exchange = $this->getExchange($exchange['id']);
     return $exchange;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:12,代码来源:ExchangeServiceImpl.php

示例14: createGift

 public function createGift($gift)
 {
     if (!ArrayToolkit::requireds($gift, array('giftName'))) {
         throw $this->createServiceException('缺少必要字段,添加礼品失败!');
     }
     $gift = ArrayToolkit::parts($gift, array('giftName', 'points', 'detail'));
     $gift['detail'] = !empty($gift['detail']) ? $this->purifyHtml($gift['detail']) : '';
     $gift['createdTime'] = time();
     $gift = $this->getGiftDao()->addGift($gift);
     $gift = $this->getGift($gift['id']);
     //   $this->getLogService()->info('gift', 'create', "添加礼品《{$gift['giftName']}》(#{$gift['id']})");
     return $gift;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:13,代码来源:GiftServiceImpl.php

示例15: createBlock

 public function createBlock($block)
 {
     if (!ArrayToolkit::requireds($block, array('code', 'title'))) {
         throw $this->createServiceException("创建编辑区失败,缺少必要的字段");
     }
     $user = $this->getCurrentUser();
     $block['userId'] = $user['id'];
     $block['tips'] = empty($block['tips']) ? '' : $block['tips'];
     $block['createdTime'] = time();
     $block['updateTime'] = time();
     $createdBlock = $this->getBlockDao()->addBlock($block);
     $blockHistoryInfo = array('blockId' => $createdBlock['id'], 'content' => $createdBlock['content'], 'userId' => $createdBlock['userId'], 'createdTime' => time());
     $this->getBlockHistoryDao()->addBlockHistory($blockHistoryInfo);
     return $createdBlock;
 }
开发者ID:styling,项目名称:LeesPharm,代码行数:15,代码来源:BlockServiceImpl.php


注:本文中的Topxia\Common\ArrayToolkit::requireds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。