dao = $dao; } public function create($data) { return $this->dao->create($data); } /** * 写入 PV记录 * @param UserPvLogEntity $userPvLogEntity * @return UserPvLogEntity */ public function createByEntity(UserPvLogEntity $userPvLogEntity): UserPvLogEntity { $result = $this->dao->create($userPvLogEntity->toUnderlineArray())->toArray(); /** @var UserPvLogEntity $entity */ $entity = UserPvLogEntity::newInstance($result); return $entity; } /** * 添加Pv 记录 * @param int $uid * @param float $pv * @param string $mark * @param string $orderType * @param string $orderId * @return UserPvLogEntity */ public function addUserPvLog(int $uid, float $pv, string $mark = '', string $orderType = '', string $orderId = ''): UserPvLogEntity { if (!empty($orderType)) { if (!empty($orderId)) { if ($orderType == UserPvLogEnum::ORDER_TYPE['Platform']['code']) { /** @var StoreOrderRepository $storeOrderRepository */ $storeOrderRepository = app()->make(StoreOrderRepository::class); $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId((int)$orderId); if (empty($storeOrderEntity->getOrderId())) { throw new ValidateException('未查询到订单信息'); } } } } /** @var UserPvLogEntity $userPvLogEntity */ $userPvLogEntity = UserPvLogEntity::newInstance(); $userPvLogEntity->setUid($uid) ->setPv($pv) ->setMark($mark) ->setOrderType($orderType) ->setOrderId($orderId) ->setAddtime(time()) ->setStatus(UserPvLogEnum::STATUS['PendingConfirmation']['code']); return $this->createByEntity($userPvLogEntity); } }