UserService::getCurrentLoginUserId(), 'order_no' => OrderService::createOrderNo(), 'identity_id' => $identityInfo['identity_id'], 'order_type' => $identityInfo['type'], 'pay_price' => $identityInfo['price'], 'month' => $identityInfo['month'], 'platform' => getPlatform(), 'store_id' => self::$storeId, ]; return $this->save($data); } /** * 获取订单详情 (待付款状态) * @param string $orderNo 订单号 * @return array|null|static */ public static function getPayDetail(string $orderNo) { return self::detail(['order_no' => $orderNo]); } /** * @notes:编辑 * @param $data * @return bool * @author: wanghousheng */ public function edit($data): bool { return $this->save($data) !== false; } public function identity(): HasOne { return $this->hasOne(Identity::class, 'identity_id', 'identity_id') ->bind(['identity_name' => 'name']); } /** * @notes:开卡记录 * @param array $where * @return array * @throws BaseException * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException * @author: wanghousheng */ public function cardList(array $where = []): array { $userId = UserService::getCurrentLoginUserId(); $params['user_id'] = $userId; $params['pay_status'] = PayStatus::SUCCESS; $where = array_merge($where, $params); $list = $this->where($where) ->with(['identity']) ->order('pay_time', 'desc') ->limit(20) ->select(); $data = []; if (!empty($list)) { foreach ($list as $value) { $data[] = [ 'start_time' => date("Y-m-d", $value['pay_time']), 'end_time' => date("Y-m-d", strtotime("+{$value['month']} months", $value['pay_time'])), 'name' => $value['identity_name'], 'month' => $value['month'], ]; } } return $data; } }